{"source_code": "$\\ = $/;\n\n<>;\n\nfor( <> ){\n\t$c = 0;\n\t$_ % 2 and do { $c ++; $_ -= 9 };\n\t$_ % 4 == 2 and do { $c ++; $_ -= 6 };\n\tprint $c += $_ < 0 ? -1 - $c : $_ / 4;\n\t}\t", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tfor( map ~~<>, 1 .. $_ ){\n\t\tmy $c = 0;\n\t\t$_ % 2 and do { $c ++; $_ -= 9 };\n\t\t$_ % 4 == 2 and do { $c ++; $_ -= 6 };\n\t\tprint $c += $_ < 0 ? -1 - $c : $_ / 4;\n\t\t}\t\n\t}"}, {"source_code": "\n\nmy $q = <STDIN>;\nchomp ( $q );\nmy $f;\nmy $ans = 0;\nfor (1..$q) {\n    $f = <STDIN>;\n    chomp ( $f );\n    if ( $f < 4 ) {\n\tprint \"-1\";\n    }\n    elsif ( ($f == 4) or ($f == 6) or ($f == 9) ) {\n\tprint \"1\";\n    }\n    elsif ( ($f == 8) or ($f == 10) or ($f == 13) or ($f == 15) ) {\n\tprint \"2\";\n    }\n    elsif ( ($f == 5) or ($f == 7) or ($f == 11) ) {\n\tprint \"-1\";\n    }\n    elsif ( ($f == 14) or ($f == 12) ) {\n\tprint \"3\";\n    }\n    elsif ( $f % 4 == 3 or $f % 4 == 1 ) {\n\t$ans = int ( $f / 4 ) - 1;\n\tprint $ans;\n    }\n    else {\n\t$ans = int ( $f / 4 );\n\tprint $ans;\n    }\n    print \"\\n\";\n}\n\n\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\nprint /^([1-357]|11)$/ ? -1 : ( $_ >> 2 ) - $_ % 2 for <>"}, {"source_code": "sub in_list {\n    my ($a, @b) = @_;\n    my $y = 0;\n    $y |= ($a == $_) for @b;\n    $y;\n};\n\n<>; for $n (<>) {\n    if (in_list($n, 1, 2, 3, 5, 7, 11)) {\n        $k = -1;\n    } else {\n        $k = 0;\n        $k = 1, $n -= 9 if $n & 1;\n        $k += int($n / 4);\n    };\n    print $k, \"\\n\";\n};\n"}], "negative_code": [{"source_code": "\n\nmy $q = <STDIN>;\nchomp ( $q );\nmy $f;\nmy $ans = 0;\nfor (1..$q) {\n    $f = <STDIN>;\n    chomp ( $f );\n    if ( $f < 4 ) {\n\tprint \"-1\";\n    }\n    elsif ( ($f == 4) or ($f == 6) or ($f == 9) ) {\n\tprint \"1\";\n    }\n    elsif ( ($f == 8) or ($f == 10) or ($f == 13) or ($f == 15) ) {\n\tprint \"2\";\n    }\n    elsif ( ($f == 5) or ($f == 7) or ($f == 11) ) {\n\tprint \"-1\";\n    }\n    elsif ( ($f == 14) or ($f == 12) ) {\n\tprint \"3\";\n    }\n    elsif ( $f % 4 == 3 ) {\n\t$ans = int ( $f / 4 ) - 1;\n\tprint $ans;\n    }\n    else {\n\t$ans = int ( $f / 4 );\n\tprint $ans;\n    }\n    print \"\\n\";\n}\n\n\n"}, {"source_code": "sub in_list {\n    my ($a, @b) = @_;\n    my $y = 0;\n    $y |= ($a == $_) for @b;\n    $y;\n};\n\nfor $n (<STDIN>) {\n    if (in_list($n, 1, 2, 3, 5, 7, 11)) {\n        $k = -1;\n    } else {\n        $k = 0;\n        $k = 1, $n -= 9 if $n & 1;\n        $k += int($n / 4);\n    };\n    print $k, \"\\n\";\n};\n"}, {"source_code": "<>;\n\nfor( <> ){\n\t$c = 0;\n\t$_ % 2 and do { $c ++; $_ -= 9 };\n\t$_ % 4 == 2 and do { $c ++; $_ -= 6 };\n\tprint $c += $_ < 0 ? -1 - $c : $_ / 4;\n\t}\t"}], "src_uid": "0c2550b2df0849a62969edf5b73e0ac5"}
{"source_code": "$\\ = $/;\n$left = -10e9;\n<>;\n$ans = 0;\n\nwhile(<>){\n\t$prev = $x;\n\t($x, $h) = split;\n\t$x <= $left and do {$ans -- ; $left = $prev };\n\tif ($x - $left > $h ){\n\t\t$left = $x;\n\t\t} \n\t\telse {\n\t\t\t$left = $x + $h;\n\t\t\t}\n\t$ans ++\n}\n\nprint $ans", "positive_code": [{"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a"}, {"source_code": "$L =<>+-~ 0;\n\n\t$p = $x,\n\t($x, $h) = split,\n\t$x > $L || (-- $a, $L = $p ),\n\t$L = $x + $h * ($x - $L <= $h),\n\t$a ++ for <>;\n\nprint $a\n"}], "negative_code": [], "src_uid": "a850dd88a67a6295823e70e2c5c857c9"}
{"source_code": "<>;print join $\",map{$_-1+$_%2}split $\",<>", "positive_code": [{"source_code": "<STDIN>;\nprint(join(\" \", map {$_ - 1 + $_ % 2} split(\" \", <STDIN>)))"}, {"source_code": "$n = <STDIN>;\n@a = split(\" \", <STDIN>);\nfor (@a) {\n    print($_ - 1 + $_ % 2);\n    print(\" \");\n}\n"}, {"source_code": "<STDIN>;\n@a = map {$_ - 1 + $_ % 2} split(\" \", <STDIN>);\nprint(join(\" \", @a));\n"}, {"source_code": "<STDIN>;print(join($\",map{$_-1+$_%2}split($\",<STDIN>)))"}, {"source_code": "$n = <STDIN>;\n@a = split(\" \", <STDIN>);\nfor (@a) {\n    print($_ - 1 + $_ % 2, \" \");\n}\n"}, {"source_code": "$n = <STDIN>;\n@a = split(\" \", <STDIN>);\nfor (@a) {\n    if ($_ % 2 == 0) {\n        print($_ - 1);\n    } else {\n        print($_);\n    }\n    print(\" \");\n}\n"}, {"source_code": "<STDIN>;\nprint(join(\" \", map {$_ - 1 + $_ % 2} split(\" \", <STDIN>)));\n"}, {"source_code": "<>;print(join($\",map{$_-1+$_%2}split($\",<>)))"}, {"source_code": "<>;print join$\",map$_-1+$_%2,split$\",<>"}, {"source_code": "<STDIN>;print(join(\" \",map{$_-1+$_%2}split(\" \",<STDIN>)))"}], "negative_code": [{"source_code": "<>;print map$_-1+$_%2,split$\",<>"}, {"source_code": "<>;print map($_-1+$_%2).\"\",split$\",<>"}], "src_uid": "d00696cb27c679dda6e2e29314a8432b"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t$debug and print \"$n $k\";\n\t\n\tif( $k >= $n - 2 ){\n\t\tprint \"YES\";\n\t\t\n\t\tprint for\n\t\t\t'.' x $n,\n\t\t\tjoin( ( $k >= $n - 2 ? '#' : '.' ) x ( $n - 2 ), ( '.' ) x 2 );\n\t\t\n\t\t$k >= $n - 2 and $k -= $n - 2;\n\t\t$k < 0 and $k = 0;\n\t\t\n\t\t$_ = '.' . '#' x $k . '.' x ( $n - 2 - $k ) . '.';\n\t\t\n\t\ts/#(\\.+)\\.$/$1#./;\n\t\ts/^\\.+#\\.+$/ join '#', ( '.' x ( $n >> 1 ) ) x 2 /e;\n\t\t\n\t\tprint;\n\t\t\n\t\tprint '.' x $n;\n\t\t\n\t\t}\n\telse{\n\t\t$debug and print \"IDK\";\n\t\t\n\t\tif( $k % 2 == 0 ){\n\t\t\tprint \"YES\";\n\t\t\tprint '.' x $n;\n\t\t\tprint '.' . '#' x ( $k / 2 ) . '.' x ( $n - $k / 2 - 2 ) . '.';\n\t\t\tprint '.' . '#' x ( $k / 2 ) . '.' x ( $n - $k / 2 - 2 ) . '.';\n\t\t\tprint '.' x $n;\n\t\t\t}\n\t\telse{\n\t\t\tprint \"YES\";\n\t\t\tprint '.' x $n;\n\t\t#\tprint '.' . '#' x ( $k - 2 ) . '.' x ( $n - $k ) . '.';\n\t\t\tprint join '#' x $k, ( '.' x ( $n - $k >> 1 ) ) x 2;\n\t\t\tprint '.' x $n;\n\t\t\tprint '.' x $n;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print '-' x 15;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n( $n, $k ) = split ' ', <>;\n\nprint for\n\t'YES',\n\t'.' x $n,\n\t( map  { \".$_.\" }\n\t\tdo {\n\t\t\tif( $k % 2 == 0 ) {\n\t\t\t\t( '#' x ( $k / 2 ) . '.' x ( $n - 2 - $k / 2 ) ) x 2\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$inv = $k >= $n - 2;\n\t\t\t\t$k = ( $n - 2 ) * 2 - $k if $inv;\n\t\t\t\tmap { $inv ? y/#%/.#/r : y/%/./r }\n\t\t\t\t\t'%' x ( $n - 2 ), \n\t\t\t\t\t( join '#' x $k, ( '%' x ( $n - 2 - $k >> 1 ) ) x 2 ),\n\t\t\t\t}\n\t\t\t}\n\t),\n\t'.' x $n,"}, {"source_code": "( $n, $k ) = split ' ', <>;\n\n$_ = join \"\\n\", 'YES', ( '.' x $n ) x 4;\n\nwhile( $k -- ){\n\ts/\\.$ \\n\\K^(\\.*)\\.(\\#*)((??{ $1 ? '.' : '\\.' }))\\2\\.\\1$/\n\t\t\"$1$3$2\" . \"$3\" =~ y!.#!#.!r . \"$2$3$1\"\n\t/mex;\n\t}\n\nprint"}], "negative_code": [{"source_code": "( $n, $k ) = split ' ', <>;\n\nprint for\n\t'YES',\n\t'.' x $n,\n\t( map  { \".$_.\" }\n\t\tdo {\n\t\t\tif( $k % 2 == 0 ) {\n\t\t\t\t( '#' x ( $k / 2 ) . '.' x ( $n - 2 - $k / 2 ) ) x 2\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$inv = $k >= $n - 2;\n\t\t\t\t$k = ( $n - 2 ) * 2 - $k if $inv;\n\t\t\t\tmap { $inv ? y/#%/.#/r : y/%/./r }\n\t\t\t\t\t'%' x ( $n - 2 ), \n\t\t\t\t\t( join '#' x $k, ( '%' x ( $n - 2 - $k >> 1 ) ) x 2 ),\n\t\t\t\t}\n\t\t\t}\n\t),\n\t'.' x $n,"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\tprint\n\t\tjoin \"\\n\",\n\t\t'.' x $n,\n\t\tjoin( ( $k > $n - 2 ? '#' : '.' ) x ( $n - 2 ), ( '.' ) x 2 ),\n\t\tjoin(\n\t\t\t\t( $k % ( $n - 2 ) == 0 ) ? \n\t\t\t\t\t'.' x ( $n - 2 ) :\n\t\t\t\t\t( $k % ( $n - 2 ) == 1 ) ?\n\t\t\t\t\t\t( join '#', ( '.' x ( - 1 + int $n / 2 ) ) x 2 ) :\n\t\t\t\t\t\t( '#' x ( $k % ( $n - 2 ) - 1 ) . '.' x ( $n - $k % ( $n - 2 ) ) . '#' )\n\t\t\t\t,\n\t\t\t( '.' ) x 2\n\t\t\t),\n\t\t'.' x $n,\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t$debug and print \"$n $k\";\n\t\n\tif( $k >= $n - 2 ){\n\t\tprint \"YES\";\n\t\t\n\t\tprint for\n\t\t\t'.' x $n,\n\t\t\tjoin( ( $k >= $n - 2 ? '#' : '.' ) x ( $n - 2 ), ( '.' ) x 2 );\n\t\t\n\t\t$k >= $n - 2 and $k -= $n - 2;\n\t\t$k < 0 and $k = 0;\n\t\t\n\t\t$_ = '.' . '#' x $k . '.' x ( $n - 2 - $k ) . '.';\n\t\t\n\t\ts/#(\\.+)\\.$/$1#./;\n\t\ts/^\\.+#\\.+$/ join '#', ( '.' x ( $n >> 1 ) ) x 2 /e;\n\t\t\n\t\tprint;\n\t\t\n\t\tprint '.' x $n;\n\t\t\n\t\t}\n\telse{\n\t\t$debug and print \"IDK\";\n\t\t\n\t\tif( $k % 2 == 0 ){\n\t\t\tprint \"YES\";\n\t\t\tprint '.' x $n;\n\t\t\tprint '.' . '#' x ( $k / 2 ) . '.' x ( $n - $k / 2 - 2 ) . '.';\n\t\t\tprint '.' . '#' x ( $k / 2 ) . '.' x ( $n - $k / 2 - 2 ) . '.';\n\t\t\tprint '.' x $n;\n\t\t\t}\n\t\telsif( $k == 1 || $k == 3 ){\n\t\t\tprint \"NO\";\n\t\t\t}\n\t\telse{\n\t\t\tprint \"YES\";\n\t\t\tprint '.' x $n;\n\t\t\tmy $ins = '.' . '#' x ( $k - 2 ) . '.' x ( $n - $k ) . '.';\n\t\t\tprint $ins;\n\t\t\t$ins =~ s/#(#+)#/ '#' . ( '.' x length $1 ) . '#' /e;\n\t\t\tprint $ins;\n\t\t\tprint '.' x $n;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print '-' x 15;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t$debug and print \"$n $k\";\n\t\n\tprint for\n\t\t'.' x $n,\n\t\tjoin( ( $k >= $n - 2 ? '#' : '.' ) x ( $n - 2 ), ( '.' ) x 2 );\n\t\n\t$k >= $n - 2 and $k -= $n - 2;\n\t$k < 0 and $k = 0;\n\t\n\t$_ = '.' . '#' x $k . '.' x ( $n - 2 - $k ) . '.';\n\t\n\ts/#(\\.+)\\.$/$1#./;\n\ts/^\\.+#\\.+$/ join '#', ( '.' x ( $n >> 1 ) ) x 2 /e;\n\t\n\tprint;\n\t\n\tprint '.' x $n;\n\t\n\t$debug and print '-' x 15;\n\t}"}], "src_uid": "2669feb8200769869c4b2c29012059ed"}
{"source_code": "for $I(1..<>){\n\t\n\t($n, $p)=split/ /,<>;\n\t$s=$n+$n+$p;\n\t\n\tfor ($i=1; $i<$n; $i++){\n\t\t\n\t\tfor ($j=$i+1; $j<=$n; $j++){\n\t\t\t\n\t\t\tprint \"$i $j\\n\";\n\t\t\t--$s or last;\n\t\t\t\n\t\t\t}\n\t\t$s or last;\n\t\t\n\t\t}\n\t\n\t}", "positive_code": [{"source_code": "for (1..<>){\n\t\n\t<>=~/ /;\n\t$s=2*$`+$';\nL:\n\tfor $i(1..$`-1){\n\t\tfor $j($i+1..$`){\n\t\t\tprint \"$i $j\\n\";\n\t\t\t--$s or last L;\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "ddbac4053bd07eada84bc44275367ae2"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = sort { $a <=> $b} split / /, <>;\n$ans = 0;\nforeach (1 .. $n-1) {\n\tif ($a[$_] <= $a[$_-1]) {\n\t\t$ans += $a[$_-1] + 1 - $a[$_];\n\t\t$a[$_] = $a[$_-1] + 1;\n\t}\n}\nsay $ans;", "positive_code": [{"source_code": "<>;\nmy @arr = sort {$a <=> $b} split / /, <>;\nmy $ans = 0;\nfor(1..scalar @arr - 1) {\n    if ($arr[$_] <= $arr[$_ - 1]) {\n        $ans += $arr[$_ - 1] - $arr[$_] + 1;\n        $arr[$_] = $arr[$_ - 1] + 1;\n    }\n}\nprint $ans;\n"}, {"source_code": "<>;\n$M += ($_ < $m) * ($m - $_), $m += 1 + ($_ - $m) * ($_ > $m) for sort {$a <=> $b} split \" \", <>;\nprint 0 + $M"}], "negative_code": [{"source_code": "<>;\nmy @arr = sort {$a <=> $b} split / /, <>;\nmy $ans = 0;\nfor(1..scalar @arr - 1) {\n    if ($arr[$_] == $arr[$_ - 1]) {\n        $ans++;\n        $arr[$_]++;\n        $_--;\n    }\n}\nprint $ans;\n"}, {"source_code": "<>;\n$M += ($_ < $m) * (1 + $m - $_), $m += 1 + $_ * ($_ < $m) for sort {$a <=> $b} split \" \", <>;\nprint 0 + $M"}], "src_uid": "53ae714f04fd29721b8bbf77576b7ccf"}
{"source_code": "#!/usr/bin/perl\n\n$_ = <>;\n@ps = split / /;\nprint (($ps[0]/$ps[1])/($ps[0]/$ps[1] + $ps[2]/$ps[3] - $ps[0]/$ps[1]*$ps[2]/$ps[3]));\n\n", "positive_code": [{"source_code": "$inp = <STDIN>;\n    ($a,$b,$c,$d) = split(' ', $inp);\n    $x=$a/$b;\n    $y=$c/$d;\n    $ans=($x)/(1-(1.0-$x)*(1.0-$y));\n    printf '%.10f',$ans; "}, {"source_code": "while (<>=~/ (\\d+) (\\d+) /){\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$c++;\nfor(1..1e5){\n$a=$c*$`/$1;\n\t$S+=$a; $c-=$a;\n\t$c-=$c*$2/$'\n}\nprint $S\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\nwhile (<>=~/ (\\d+) (\\d+) /){\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$c++;\nfor(1..1e5){\n\t$S+=$c*$`/$1; $c-=$c*$`/$1;\n\t$K+=$c*$2/$'; $c-=$c*$2/$'\n}\nprint $S\n\n}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\nsub fact{\n\tmy $i= shift;   my $j= 1;\n\t$j*=$i-- while $i;\n\treturn $j\n}\n\n# Transpose \"charbox\"\nsub trans{\n\tmy @t=(); my $i=0; \n\t$i=0, s/./$t[$i++].=$&/eg for @_;\n\treturn @t\n}\n\nsub rotL{\n\tmy @t=(); my $i=0; my $j;\n\tfor (@_){\n\t\t$i=0, $j=length; $t[$i++].=chop while $j--\n\t}\n\treturn @t\n}\n\nsub rotR{\n    my @m=@_;  chomp @m;   my @t=();\n\tmy $i= length $m[0];\n\twhile ($i--){\n\t\t$t[$i]=~s/^/chop/e for @m\n\t}\nreturn @t\n}\n\nsub revlines{\n\t$_=reverse $_ for @_;\n\treturn @_\n}\n\n# Transpose \"value sets\" ## slow?\nsub trans_s{\n\tmy @t=(); my $j;\n\t$j=0, s/\\S+/($t[$j++].=\"$& \")?$&:$&/eg for @_;\n\tchop @t;\nreturn @t\n}\n\n# rotL_s\n# rotR_s\n\n# slow?\nsub revlines_s{\n\t$_=join\" \", reverse split/\\s+/ \tfor @_;\n\treturn @_\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n\tmy @m=sort @_; my @u;\n\tpush @u, my $i=shift @m;\n\t$i eq $_ or push @u, $i=$_ for @m;\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\nwhile (<>=~/ (\\d+) (\\d+) /){\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$c++;\nfor(1..1e3){\n\t$S+=$c*$`/$1; $c-=$c*$`/$1;\n\t$K+=$c*$2/$'; $c-=$c*$2/$'\n}\nprint $S\n\n}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\nsub fact{\n\tmy $i= shift;   my $j= 1;\n\t$j*=$i-- while $i;\n\treturn $j\n}\n\n# Transpose \"charbox\"\nsub trans{\n\tmy @t=(); my $i=0; \n\t$i=0, s/./$t[$i++].=$&/eg for @_;\n\treturn @t\n}\n\nsub rotL{\n\tmy @t=(); my $i=0; my $j;\n\tfor (@_){\n\t\t$i=0, $j=length; $t[$i++].=chop while $j--\n\t}\n\treturn @t\n}\n\nsub rotR{\n    my @m=@_;  chomp @m;   my @t=();\n\tmy $i= length $m[0];\n\twhile ($i--){\n\t\t$t[$i]=~s/^/chop/e for @m\n\t}\nreturn @t\n}\n\nsub revlines{\n\t$_=reverse $_ for @_;\n\treturn @_\n}\n\n# Transpose \"value sets\" ## slow?\nsub trans_s{\n\tmy @t=(); my $j;\n\t$j=0, s/\\S+/($t[$j++].=\"$& \")?$&:$&/eg for @_;\n\tchop @t;\nreturn @t\n}\n\n# rotL_s\n# rotR_s\n\n# slow?\nsub revlines_s{\n\t$_=join\" \", reverse split/\\s+/ \tfor @_;\n\treturn @_\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n\tmy @m=sort @_; my @u;\n\tpush @u, my $i=shift @m;\n\t$i eq $_ or push @u, $i=$_ for @m;\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n"}], "src_uid": "7b932b2d3ab65a353b18d81cf533a54e"}
{"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n", "positive_code": [{"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\""}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2,()/eg;\nprint $j?\"No\":\"Yes\""}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}, {"source_code": "$_=<>;\ns/./$i[++$j]=$&, $j>1 and $i[$j] eq $i[$j-1] and $j-=2/eg;\nprint $j?\"No\":\"Yes\"\n"}], "negative_code": [{"source_code": "$_=<>;\nwhile(s/\\+-\\+\\+-\\+|-\\+--\\+-|\\+--\\+|-\\+\\+-|\\+{2}|-{2}//g){};\nprint +$_?\"No\":\"Yes\""}, {"source_code": "$_=<>;\nwhile(/\\+\\+|--/){s/\\+-\\+\\+-\\+|-\\+--\\+-|\\+--\\+|-\\+\\+-|\\+{2}|-{2}//g};\nprint $_?\"No\":\"Yes\""}, {"source_code": "$_=<>;\nwhile(s/\\+-\\+\\+-\\+|-\\+--\\+-|\\+--\\+|-\\+\\+-|\\+{2}|-{2}//g){};\nprint $_?\"No\":\"Yes\""}, {"source_code": "$_=<>;\ns/\\+-\\+\\+-\\+|-\\+--\\+-|\\+--\\+|-\\+\\+-|\\+{2}|-{2}//g;\nprint $_?\"No\":\"Yes\""}], "src_uid": "89b4a7b4a6160ce784c588409b6ce935"}
{"source_code": "for (1..<>)\r\n{\r\n    <>;\r\n    chomp (my $in = <>);\r\n@a = split / /, $in;\r\n$a = @a[0];\r\n$b = @a[1];\r\n$c = @a[2];\r\n\r\nif ($a==$b) {\r\n        $x = $a;\r\n} else {\r\n        $x = $a == $c ? $a : $b;\r\n}\r\n\r\n$i = 1;\r\nforeach(@a) {\r\n        $_ != $x and print $i;\r\n        $i++;\r\n}\r\nprint \"\\n\";\r\n}\r\n\r\nexit;", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my %c = ();\r\n  for(my $i=0;$i<$n;$i++){\r\n    $c{$A[$i]}->{c} ++;\r\n    $c{$A[$i]}->{i} = $i;\r\n  }\r\n  my $r = 0;\r\n  foreach my $c1 (keys %c){\r\n    if( $c{$c1}->{c} == 1 ){\r\n      $r = $c{$c1}->{i};\r\n      last;\r\n    }\r\n  }\r\n  $r ++;\r\n  print \"$r\\n\";\r\n}\r\n\r\nexit(0);\r\n\r\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\tmy $this;\n\t\n\t$h{ $_ } == 1 and $this = $_ for keys %h;\n\t\n\tfor( my $i = 0; $i < @_; $i ++ ){\n\t\t$_[ $i ] == $this and do {\n\t\t\tprint $i + 1;\n\t\t\tlast;\n\t\t\t};\n\t\t}\n\t}"}], "negative_code": [{"source_code": "for (1..<>)\r\n{\r\n    <>;\r\n    chomp (my $in = <>);\r\n@a = split / /, $in;\r\n$a = @a[0];\r\n$b = @a[1];\r\n$c = @a[2];\r\n\r\nif ($a==$b) {\r\n        $x == $a;\r\n} else {\r\n        $x = $a == $c ? $a : $b;\r\n}\r\n\r\n$i = 1;\r\nforeach(@a) {\r\n        $_ != $x and print $i;\r\n        $i++;\r\n}\r\nprint \"\\n\";\r\n}\r\n\r\nexit;"}, {"source_code": "chomp (my $in = <>);\r\n@a = split / /, $in;\r\n$a = @a[0];\r\n$b = @a[1];\r\n$c = @a[2];\r\n\r\nif ($a==$b) {\r\n        $x == $a;\r\n} else {\r\n        $x = $a == $c ? $a : $b;\r\n}\r\n\r\n$i = 1;\r\nforeach(@a) {\r\n        $_ != $x and print $i;\r\n        $i++;\r\n}\r\n\r\nexit;"}, {"source_code": "chomp (my $in = <>);\r\n@a = split / /, $in;\r\n$a = @a[0];\r\n$b = @a[1];\r\n$c = @a[2];\r\n\r\nif ($a==$b) {\r\n        $x == $a;\r\n} else {\r\n        $x = $a == $c ? $a : $b;\r\n}\r\n\r\n$i = 1;\r\nforeach(@a) {\r\n        @_ != $x and print $i;\r\n        $i++;\r\n}\r\n\r\nexit;"}], "src_uid": "224a0b09547ec1441474efbd8e06353b"}
{"source_code": "use strict;\nuse warnings;\nuse v5.020;\n\nmy $t = <>;\nwhile($t--) {\n    my $n;# = <>;\n    chomp($n=<>);\n    my @ans;\n    if($n % 2 == 1){\n        push @ans, int($n);\n        for(my $i = 1; $i <= int($n/2); $i++){\n            push @ans, $i;\n            push @ans, $n-$i\n        }\n    } else {\n        push @ans, int($n/2);\n        for(my $i = 1; $i < $n/2; $i++){\n            push @ans, $i;\n            push @ans, $n+1-$i;\n        }\n        push @ans, $n/2 + 1;\n    }\n    say \"@ans\";\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy ($t) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nfor( my $t_loop=0; $t_loop<$t; $t_loop++ ){\n  \n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  \n  my @a = (1..$n);\n  print ( join(' ',@a) . \"\\n\");\n  \n}\n\nexit(0);\n\n"}], "negative_code": [], "src_uid": "1b3ac752bc9c0b5e20a76f028d4b3c15"}
{"source_code": "@A = 1 .. <>;\n\n@_ = split ' ', <>;\n\n$_ = <>, chomp;\n\n$_ .= '0';\n\n$i = 0;\n\nfor( split // ){\n\t$_[ $i ] > $max and $max = $_[ $i ];\n\tif( $_ ){\n\t\t$f = 1;\n\t\t}\n\telse{\n\t\tif( $f ){\n\t\t\t$max > $A[ $i ] and $fail = 1;\n\t\t\t$f = 0;\n    \t\t}\n    \telse{\n    \t\t$A[ $i ] != $_[ $i ] and $fail = 2;\n\t\t\t}\n\t\t}\n\t$i ++;\n\t}\n\nprint $fail ? \"NO\" : \"YES\"", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy @A = 1 .. $_;\n\t\n\t@_ = split ' ', <>;\n\t\n\t$_ = <>, chomp;\n\t\n\t$_ .= '0';\n\t\n\tmy $i = 0;\n\tmy @C;\n\tmy $max = 0;\n\tmy $f = 0;\n\tmy $fail = 0;\n\t\n\tfor( split // ){\n\t\t$_[ $i ] > $max and $max = $_[ $i ];\n\t\t$debug and print ' ' .$max . ' ' . $fail;\n\t\tif( $_ ){\n\t\t\t$f = 1;\n\t\t\t}\n\t\telse{\n\t\t\tif( $f ){\n\t\t\t\t$max > $A[ $i ] and $fail = 1;\n\t\t\t\t$f = 0;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$A[ $i ] != $_[ $i ] and $fail = 2;\n\t\t\t\t}\n\t\t\t}\n\t\t$i ++;\n\t\t}\n\t\n\tprint $fail ? \"NO\" : \"YES\";\n\t\n#\t$debug and print \"[@C]\";\n\t\n#\tmy $i = 0 + /^1/;\n\t\n#\ts/0\\K(?=1)|10\\K/|/g;\n\t\n#\t$debug and print;\n\t\n#\ts/\\d/ ' ' . shift @_ /eg;\n\t\n#\t$debug and print;\n\t\n#\t@_ = split '\\|';\n\t\n#\tmy @B;\n\t\n#\tfor( @_ ){\n#\t\tpush @B, $i ++ % 2 ?\n#\t\t\t( sort { $a <=> $b } split )\n#\t\t\t: split\n#\t\t\t;\n#\t\t}\n\t\n#\t$debug and print \"@B\";\n\t\n#\tmy @intervals;\n\t\n#\twhile( /1++1*+1*+1*+1*+1*+1*+1*+/g ){\n#\t\tpush @intervals, [ $-[0], $+[0] ];\n#\t\t}\n\t\n#\t$debug and print \"@{$_}\" for @intervals;\n\t\n#\tfor( @intervals ){\n#\t\tmy( $start, $end ) = @{ $_ };\n\t\t\n#\t\t@_[ $start .. $end ] =\n#\t\t\tsort { $a <=> $b } @_[ $start .. $end ];\n#\t\t}\n\t\n#\tprint @A ~~ @C ? \"YES\" : \"NO\";\n\t\n\t$debug and print '-' x 10;\n\t}"}], "negative_code": [], "src_uid": "094a880e93a2adfbcb6dcc2b5f043bab"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t\n\tmy $i = 0;\n\tmy $j = 0;\n\tmy @A;\n\tmy @j;\n\t\n\t() = / (\\w+),(\\d+) \n\t\t(?{\n\t\t\t\n\t\t\tpush @{ $A[@j - 0] }, $1;\n\t\t\t\n\t\t\t$debug and print \"<$&>\";\n\t\t\t\n\t\t\tpush @j, $2;\n\t\t\t\n\t\t\twhile( 1 ){\n\t\t\t\t@j or last;\n\t\t\t\t$j = pop @j;\n\t\t\t\t$j or next;\n\t\t\t\t$j --;\n\t\t\t\tpush @j, $j;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t\n\t\t\t$debug and print \"[@j]\";\n\t\t})\n\t/gx;\n\t\n\tprint ~~ @A;\n\tprint \"@$_\" for @A;\n\t\n\t$debug and print '-' x 10;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$\\ = $/;\n\n$_ = <>;\n\t\n() = / (\\w+),(\\d+) \n\t(?{\n\t\t\n\t\tpush @{ $A[@j - 0] }, $1;\n\t\t\n\t\tpush @j, $2;\n\t\t\n\t\twhile( 1 ){\n\t\t\t@j or last;\n\t\t\t$j = pop @j;\n\t\t\t$j or redo;\n\t\t\tpush @j, -- $j;\n\t\t\tlast;\n\t\t\t}\n\t})\n/gx;\n\nprint for ~~ @A, map \"@$_\", @A"}], "negative_code": [], "src_uid": "da08dd34ac3c05af58926f70abe5acd0"}
{"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n", "positive_code": [{"source_code": "my $n = int<>;\nmy @arr = split / /, <>;\nmy @ans;\n@arr = reverse sort{$a->[0] <=> $b-[0]} map{[$arr[$_], $_]} 0..$n-1;\nfor my $i(0..$n-1) {\n    $ans[$arr[$i]->[1]] = 1 + grep {$arr[$i]->[0] < $_->[0]} @arr;\n}\nprint \"@ans\\n\";\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "use strict;\nuse List::MoreUtils 'firstidx';\n \nmy $range = <STDIN>;\nmy @numbers = split / /, <STDIN>;\nmy @sorted = reverse sort { $a <=> $b } @numbers;\n \nfor my $i (0..$range-1) {\n    $numbers[$i] = ( firstidx { $_ == $numbers[$i] } @sorted ) + 1;\n}\n \n$, = ' ';\nprint @numbers;"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\nforeach (0..$n-1) {\n\tpush @arr, [($_, $a[$_])];\n}\n@arr = sort { $b->[1] <=> $a->[1] } @arr;\n($x, $tmp) = (1, $arr[0]->[1]);\npush @ans, [($arr[0]->[0], 1)];\nforeach (1..$n-1) {\n\tif ($arr[$_]->[1] != $tmp) {\n\t\t$tmp = $arr[$_]->[1];\n\t\t$x = $_+1;\n\t}\n\tpush @ans, [($arr[$_]->[0], $x)];\n}\n@ans = sort { $a->[0] <=> $b->[0] } @ans;\nprint $ans[$_]->[1], \" \" foreach (0..$n-1);"}, {"source_code": "#!perl\n$\\ = \"\\n\";\n\n$n = <>;\n\n@a = split /\\s/, <>;\n\n@a2 = sort {$a <=> $b} @a;\n\nfor my $i (reverse 0..$#a2)\n{\n    if (!$h{@a2[$i]})\n    {\n        $h{@a2[$i]} = $#a2 - $i + 1; \n    }\n}\n\nforeach (@a) {push @result, $h{$_};};\n\nprint \"@result\";\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n\nmy $n = <>;\nmy @num = split ' ',<>;\nmy (%rank,%freq);\nmy ($idx,$last) = (1,0);\nforeach(@num){\n    $freq{$_}++;\n}\nforeach(sort {$b <=> $a} keys %freq){\n    $rank{$_} = $last+1;\n    $last += $freq{$_};\n}\nforeach(@num){\n    print $rank{$_}, \" \";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n\nmy $n = <>;\nmy @num = split ' ',<>;\nmy @sorted = sort {$a <=> $b} @num;\nmy (%rank,%cnt);\nmy ($idx,$last) = (1,0);\nforeach(@sorted){\n    $cnt{$_}++;\n}\nforeach(sort {$b <=> $a} keys %cnt){\n    $rank{$_} = $last+1;\n    $last += $cnt{$_};\n}\nforeach(@num){\n    print $rank{$_}, \" \";\n}\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "<>;@a=split' ',<>;\n++$h{$_} for @a;\nfor (reverse(1..2000)) {\n  $x{$_}=$cnt+1,$cnt+=$h{$_} if exists $h{$_};\n}\nprint \"$x{$_} \" for @a;\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}, {"source_code": "<>;@a=split' ',<>;\nfor$x(@a){\n  printf \"%d \",1+grep {$x < $_} @a;\n}\n\n"}], "negative_code": [{"source_code": "my $t    = <STDIN>;\nmy @data = <STDIN>;\n\nfor (my $i = 0; $i <= $t; $i++)\n{\n    if ( ( 1 + $data[$i])  > ( 1 + $data[$i+1]) )\n    {\n        $tmp = $data[$i+1];\n        $data[$i+1] = $data[$i];\n        $data[$i] = $tmp; \n    }\n}\n\nprint @data;"}, {"source_code": "use strict;\nmy $t = <STDIN>;\nmy @input = split //, <STDIN>;\n\nmy $max = 0;\nfor my $i ( @input ) {\n    if ( $i > $max ) {\n        $max = $i;\n    }\n}\n\nmy %ranks;\nmy $rank = 1;\n\nwhile( $max ) {\n    if ( grep { $_ == $max } @input ) {\n        my $plus = scalar grep { $_ == $max } @input;\n        $ranks{ $max } = $rank;\n        $rank += $plus;\n    }\n    $max--;\n}\n\nprint $ranks{$_} for @input;"}, {"source_code": "use strict;\n$, = ' ';\nmy $t = <STDIN>;\nmy @input = split //, <STDIN>;\nmy $max = 0;\nfor my $i ( @input ) {\n    if ( $i > $max ) {\n        $max = $i;\n    }\n}\n\nmy %ranks;\nmy $rank = 1;\nmy @values;\nwhile( $max ) {\n    if ( grep { $_ == $max } @input ) {\n        my $plus = scalar grep { $_ == $max } @input;\n        $ranks{ $max } = $rank;\n        $rank += $plus;\n    }\n    $max--;\n}\n\npush @values, $ranks{$_} for @input;\nprint @values;"}, {"source_code": "use strict;\nuse List::MoreUtils 'firstidx';\n\nmy $range = <STDIN>;\nmy @numbers = split //, <STDIN>;\nmy @sorted = reverse sort @numbers;\n\nfor my $i (0..$range-1) {\n    $numbers[$i] = ( firstidx { /$numbers[$i]/ } @sorted ) + 1;\n}\n\n$, = ' ';\nprint @numbers;"}, {"source_code": "use strict;\nuse List::MoreUtils 'firstidx';\n \nmy $range = <STDIN>;\nmy @numbers = split / /, <STDIN>;\nmy @sorted = reverse sort @numbers;\n \nfor my $i (0..$range-1) {\n    $numbers[$i] = ( firstidx { /$numbers[$i]/ } @sorted ) + 1;\n}\n \n$, = ' ';\nprint @numbers;"}], "src_uid": "a5edbf422616cdac35e95a4f07efc7fd"}
{"source_code": "$_ = <>;\n\nmap {\n\t( $u, $v ) = split ' ', <>;\n\t$h{ $u }{ $v } ++;\n\t$h{ $v }{ $u } ++;\n\t} 2 .. $_;\n\nexit if $_ % 2 and print -1;\n\n@g = ( 1 ) x ( $_ + 1 );\n\n%N = %h;\n\nwhile( @_ = grep 1 == keys %{ $h{ $_ } }, keys %N ){\n\t\t\t\t\t\n\tundef %N;\n\t\n\tfor( @_ ){\n\t\tnext if not $P = ( keys %{ $h{ $_ } } )[ 0 ];\n\t\t$N{ $P } ++;\n\t\tdelete $h{ $P }{ $_ };\n\t\tdelete $h{ $_ };\n\t\t\n\t\t$g[ $_ ] % 2 ? $g[ $P ] += $g[ $_ ] : ++ $C;\n\t\t}\n\t}\n\nprint 0 + $C", "positive_code": [{"source_code": "$_ = <>;\n\nmap {\n\t( $u, $v ) = split ' ', <>;\n\t$h{ $u }{ $v } ++;\n\t$h{ $v }{ $u } ++;\n\t} 2 .. $_;\n\nexit if $_ % 2 and print -1;\n\n@g = ( 1 ) x ( $_ + 1 );\n\n%N = %h;\n\nwhile( @_ = grep 1 == keys %{ $h{ $_ } }, keys %N ){\n\t\t\t\t\t\n\tundef %N;\n\t\n\tfor( @_ ){\n\t\tnext if not $P = ( keys %{ $h{ $_ } } )[ 0 ];\n\t\t$N{ $P } ++;\n\t\tdelete $h{ $P }{ $_ };\n\t\tdelete $h{ $_ };\n\t\t\n\t\t$g[ $_ ] % 2 ? $g[ $P ] += $g[ $_ ] : ++ $C;\n\t\t}\n\t}\n\nprint 0 + $C"}, {"source_code": "$n = <>;\n%graph = map { $_ => [] } (1..$n);\nfor (2..$n) {\n\t($u, $v) = split ' ', <>;\n\tpush @{$graph{$u}}, $v;\n\tpush @{$graph{$v}}, $u;\n}\n\nsub dfs {\n\tmy $v = shift || 1;\n\tmy $par = shift || -1;\n\t(my $removed, my $size) = (0, 1);\n\tfor my $u (@{$graph{$v}}) {\n\t\tif ($u != $par) {\n\t\t\tmy $child = dfs($u, $v); # [removed, size]\n\t\t\t$removed += $child->[0];\n\t\t\tif (($child->[1]) % 2 == 0) {\n\t\t\t\t$removed += 1;\n\t\t\t}\n\t\t\t$size += $child->[1];\n\t\t}\n\t}\n\treturn [$removed, $size];\n}\n\n$removed = dfs()->[0];\nprint ($n % 2 == 0 ? $removed : -1);"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy %h;\n\t\n\tmap {\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t$h{ $u }{ $v } ++;\n\t\t$h{ $v }{ $u } ++;\n\t\t} 1 .. $_ - 1;\n\t\n\tif( $_ % 2 ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy @leafs = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\t$debug and print \"leafs: @leafs\";\n\t\n\tmy @g = ( 1 ) x ( $_ + 1 );\n\t\n\tmy $cnt = 0;\n\t\n\tmy %next = map { $_ => 1 } @leafs;\n\t\n##\tmy $c = 0;\n\t\n\twhile( 1 ){\n\t\t\n\t##\t$c ++ > 15 and last;\n\t\t\n\t\t@leafs = grep { 1 == keys %{ $h{ $_ } } } keys %next;\n\t\t\n\t\t$debug and print \"  leafs: @leafs\";\n\t\t\n\t\tlast if not @leafs;\n\t\t\n\t\tundef %next;\n\t\t\n\t\twhile( @leafs ){\n\t\t\tmy $leaf = shift @leafs;\n\t\t\tmy( $parent ) = keys %{ $h{ $leaf } };\n\t\t\tnext if not $parent;\n\t\t\t$next{ $parent } ++;\n\t\t\tdelete $h{ $parent }{ $leaf };\n\t\t\tdelete $h{ $leaf };\n\t\t\t\t\n\t\t\tif( $g[ $leaf ] % 2 == 0 ){\n\t\t\t\t$cnt ++;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$g[ $parent ] += $g[ $leaf ];\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t}\n\t\n\tprint $cnt;\n\t\n\t$debug and print '-' x 15;\n\t}"}, {"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/, $, = qq/ /;\nchomp ( my $n = <STDIN> );\nmy %graph = ();\nfor ( 2 .. $n ) {\n    my ( $u, $v ) = split qq/ /, <STDIN>;\n    $graph { $u } -> { $v } = 1;\n    $graph { $v } -> { $u } = 1;\n}\nmy %nodes = ();\nmy %visited = ();\nmy $removed = 0;\nsub dfs {\n    return 0 if $visited { $_ [ 0 ] };\n    my $curr = $_ [ 0 ];\n    $visited { $curr } = 1;\n    my $cnt = 1;\n    for my $ii ( keys %{ $graph { $curr } } ) { $cnt += dfs ( $ii ) }\n    if ( $cnt % 2 == 0 ) {\n        $removed += 1;\n        return 0;\n    } else { return $cnt }\n}\ndfs ( 1 );\nif ( $n % 2 == 1 ) { print qq/-1/ }\nelsif ( $removed == 0 ) { print qq/-1/ }\nelse { print ( $removed - 1 ) }\n"}], "negative_code": [{"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/;\nmy $n = <STDIN>;\nif ( $n == 0 ) { print qq/0/ }\nelsif ( $n % 2 == 0 ) { print $n - 1 - int ( $n / 2 ) }\nelse { print qq/-1/ }\n"}, {"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/, $, = qq/ /;\nchomp ( my $n = <STDIN> );\nmy %graph = ();\nfor ( 2 .. $n ) {\n    my ( $u, $v ) = split qq/ /, <STDIN>;\n    $graph { $u } -> { $v } = 1;\n    $graph { $v } -> { $u } = 1;\n}\nmy %nodes = ();\nmy %visited = ();\nmy $removed = 0;\nsub dfs {\n    return 0 if $visited { $_ [ 0 ] };\n    my $curr = $_ [ 0 ];\n    $visited { $curr } = 1;\n    my $cnt = 1;\n    for my $ii ( keys %{ $graph { $curr } } ) { $cnt += dfs ( $ii ) }\n    if ( $cnt % 2 == 0 ) {\n        $removed += 1;\n        return 0;\n    } else { return $cnt }\n}\ndfs ( 1 );\nif ( $removed == 0 ) { print qq/-1/ }\nelse { print ($removed - 1) }\n"}, {"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/;\nmy $n = <STDIN>;\nprint qq/-1/ if $n % 2 == 1;\nprint $n - 1 - int ( $n / 2 ) if $n % 2 == 0;\n"}, {"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/;\nmy $n = <STDIN>;\nmy %graph = ();\nmy ( $u, $v );\nfor my $edge ( 1 .. $n-1 ) {\n    ( $u, $v ) = split ( qq/ /, <STDIN> );\n    $graph { $u } = 0 if not exists $graph { $u };\n    $graph { $u } += 1;\n    $graph { $v } = 0 if not exists $graph { $v };\n    $graph { $v } += 1;\n}\nmy $val = grep { $_ == 1 } values %graph;\nsub min { $_ [ 0 ] < $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nsub max { $_ [ 0 ] > $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nif ( $n % 2 == 1 ) { print qq/-1/ }\nelse { print STDOUT max ( 0, min ( $n - 1 - $val, $n - 1 - int ( $n / 2 ) ) ) }\n\n"}], "src_uid": "711896281f4beff55a8826771eeccb81"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = eval join ' + ', @_;\n\t\n\tmy $half = 0;\n\t\n\tmy $ans;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\t$half += $_[ $i ];\n\t\t$half >= $sum / 2 and $ans = $i;\n\t\t$half >= $sum / 2 and last;\n\t\t}\n\t\n\tprint $ans + 1;\n\t}", "positive_code": [{"source_code": "$_ = <>;\n\n$s = eval join ' + ', @_ = split ' ', <>;\n\n( $h += $_[ $_ - 1 ] ) >= $s / 2 and print and last for 1 .. $_"}, {"source_code": "use warnings;\nuse strict;\n$\\  = qq/\\n/, $, = qq/ /;\n<STDIN>;\nsub ceil { int ( $_ [ 0 ] ) < $_ [ 0 ] ? int ( $_ [ 0 ] ) + 1 : $_ [ 0 ] }\nmy @arr = split qq/ /, <STDIN>;\nmy $sum = 0;\n$sum += $_ for @arr;\nmy $one = ceil ( $sum / 2 );\nmy ( $two, $ii ) = ( 0, 0 );\nwhile ( $two < $one ) {\n    $two += $arr [ $ii ];\n    $ii += 1;\n}\nprint $ii;\n"}], "negative_code": [], "src_uid": "241157c465fe5dd96acd514010904321"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tprint +( sort { $a <=> $b } split )[ 1 ];\n\t}", "positive_code": [{"source_code": "<>;\r\n\r\nprint +( sort { $a <=> $b } split )[ 1 ] . $/ while <>"}], "negative_code": [], "src_uid": "63c2142461c93ae4c962eac1ecb5b192"}
{"source_code": "$_ = <>;\n$c = 0;\nwhile ( <> ) {\n\t@a = split;\n\t$min = 10**9;\n\tforeach (@a) {\n\t\t$min = $min < $_? $min : $_;\n\t}\n\t$c = $min > $c? $min : $c;\n}\nprint $c;\n", "positive_code": [{"source_code": "<>;\n\nprint( (sort map { (sort map { sprintf \"%010s\", $_ } split)[ 0 ] } <> )[ -1 ] =~ s/^0+//r )"}, {"source_code": "<>;\n\nprint( (sort {$b <=> $a} map { (sort {$a <=> $b} split)[ 0 ] } <> )[ 0 ] )"}], "negative_code": [], "src_uid": "f2142bc2f44e5d8b77f8561c29038a73"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse bigint;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tfor( @_ ){\n\t\tmy( $A, $B, $k ) = split;\n\t\t\n\t\tif( $k % 2 == 1 ){\n\t\t\tprint $A * ( $k >> 1 ) + $A - $B * ( $k >> 1 );\n\t\t\t}\n\t\telse{\n\t\t\tprint $A * ( $k >> 1 ) - $B * ( $k >> 1 );\n\t\t\t}\n\t\t\n\t\t}\n\t\n\t}", "positive_code": [{"source_code": "use strict;\nuse warnings;\nuse integer;\n\n<>;\nwhile (<>) {\n\t/(\\d+) (\\d+) (\\d+)/;\n\tprint +($3 / 2) * ($1 - $2) + ($3 % 2) * $1, \"\\n\";\n}\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tfor( @_ ){\n\t\tmy( $A, $B, $k ) = split;\n\t\t\n\t\tif( $k % 2 == 1 ){\n\t\t\tprint $A * int( $k / 2 ) + $A - $B * int( $k / 2 );\n\t\t\t}\n\t\telse{\n\t\t\tprint 0 + ( $A - $B ) / 2 * $k;\n\t\t\t}\n\t\t\n\t\t}\n\t\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse bigint;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tfor( @_ ){\n\t\tmy( $A, $B, $k ) = split;\n\t\t\n\t\tif( $k % 2 == 1 ){\n\t\t\tprint $A * int( $k / 2 ) + $A - $B * int( $k / 2 );\n\t\t\t}\n\t\telse{\n\t\t\tprint 0 + ( $A - $B ) / 2 * $k;\n\t\t\t}\n\t\t\n\t\t}\n\t\n\t}"}], "src_uid": "1f435ba837f59b007167419896c836ae"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tprint $_ == 2 ? 2 : $_ % 2 ? 1 : 0;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub remainder {\n    my ($dividend, $divisor) = @_;\n}\n\n# solve\n\nmy $q = read_token;\n\nfor (1..$q) {\n    my $n = read_token;\n    if ($n == 2) {\n        say 2;\n        next;\n    }\n\n    if ($n % 2 == 1) {\n        say 1;\n    }\n    else {\n        say 0;\n    }\n}\n"}], "negative_code": [], "src_uid": "178876bfe161ba9ccfd80c9310f75cbc"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\tfor (1 .. $_){\n\t\t\t\t\n\t\t<>;\n\t\tmy %names = map { $_, 1 } split ' ', <>;\n\t\tmy @msgs = map ~~<>, 1 .. <>;\n\t\t\n\t\tchomp @msgs;\n\t\t\n\t\t@msgs = ( '!:', @msgs, '!:' );\n\t\t\n\t\tfor (@msgs){\n\t\t\tmy( $name, $text ) = split ':';\n\t\t\t\t\t\t\n\t\t\tmy %cand;\n\t\t\t\n\t\t\tif( $name eq '?' ){\n\t\t\t\t%cand = %names;\n\t\t\t\tdelete $cand{ $_ } for grep $names{ $_ }, /\\w+/g;\n\t\t\t}\n\t\t\t\t\t\t\n\t\t\t$_ = {\n\t\t\t\tname => $name,\n\t\t\t\ttext => $text,\n\t\t\t\tcand => { %cand },\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\tmy $FAIL = 0;\n\t\tmy $del = 1;\n\t\t\n\t\twhile( $del ){\n\t\t\t$del = 0;\n\t\t\tfor my $i (1 .. @msgs - 2, reverse 1 .. @msgs - 2){\n\t\t\t\tnext if $msgs[$i]->{name} ne '?';\n\t\t\t\t\t\t\t\t\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i + $_]->{name} } and $del ++ for -1, 1;\n\t\t\t\t\t\t\t\t\n\t\t\t\tmy $num = keys %{ $msgs[$i]->{cand} };\n\t\t\t\tif( $num == 1 ){\n\t\t\t\t\t( $msgs[$i]->{name} ) = keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\t}\n\t\t\t\telsif( $num == 0 ){\n\t\t\t\t\t$FAIL = 1;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tmy $idx = -2;\n\t\tmy $key;\n\t\t\n\t\tfor my $i (0 .. @msgs - 1){\n\t\t\tlast if $FAIL;\n\t\t\t\n\t\t\t$idx == $i - 1 and delete $msgs[$i]->{cand}->{$key};\n\t\t\t\n\t\t\t$msgs[$i]->{name} eq '?' and do {\n\t\t\t\t$key = ( keys %{ $msgs[$i]->{cand} } )[ 0 ];\n\t\t\t\t%{ $msgs[$i]->{cand} } = ();\n\t\t\t\t$msgs[$i]->{name} = $key;\n\t\t\t\t$idx = $i;\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\tprint $FAIL ? \"Impossible\" : join \"\\n\", map { \"$_->{name}:$_->{text}\" } @msgs[1 .. @msgs-2];\n\t\t\n\t\t}\n\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\tfor (1 .. $_){\n\t\t\t\t\n\t\t<>;\n\t\tmy %names = map { $_, 1 } split ' ', <>;\n\t\tmy @msgs = map ~~<>, 1 .. <>;\n\t\t\n\t\tchomp @msgs;\n\t\t\n\t\t@msgs = ( '!:', @msgs, '!:' );\n\t\t\n\t\tfor (@msgs){\n\t\t\tmy( $name, $text ) = split ':';\n\t\t\t\t\t\t\n\t\t\tmy %cand;\n\t\t\t\n\t\t\tif( $name eq '?' ){\n\t\t\t\t%cand = %names;\n\t\t\t\tdelete $cand{ $_ } for grep $names{ $_ }, /\\w+/g;\n\t\t\t}\n\t\t\t\t\t\t\n\t\t\t$_ = {\n\t\t\t\tname => $name,\n\t\t\t\ttext => $text,\n\t\t\t\tcand => { %cand },\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\tmy $FAIL = 0;\n\t\tmy $del = 1;\n\t\t\n\t\twhile( $del ){\n\t\t\t$del = 0;\n\t\t\tfor my $i (1 .. @msgs - 2, 1 .. @msgs - 2){\n\t\t\t\tnext if $msgs[$i]->{name} ne '?';\n\t\t\t\t\t\t\t\t\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i + $_]->{name} } and $del ++ for -1, 1;\n\t\t\t\t\t\t\t\t\n\t\t\t\tmy $num = keys %{ $msgs[$i]->{cand} };\n\t\t\t\tif( $num == 1 ){\n\t\t\t\t\t( $msgs[$i]->{name} ) = keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\t}\n\t\t\t\telsif( $num == 0 ){\n\t\t\t\t\t$FAIL = 1;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tmy $idx = -2;\n\t\tmy $key;\n\t\t\n\t\tfor my $i (0 .. @msgs - 1){\n\t\t\tlast if $FAIL;\n\t\t\t\n\t\t\t$idx == $i - 1 and delete $msgs[$i]->{cand}->{$key};\n\t\t\t\n\t\t\t$msgs[$i]->{name} eq '?' and do {\n\t\t\t\t$key = ( keys %{ $msgs[$i]->{cand} } )[ 0 ];\n\t\t\t\t%{ $msgs[$i]->{cand} } = ();\n\t\t\t\t$msgs[$i]->{name} = $key;\n\t\t\t\t$idx = $i;\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\tprint $FAIL ? \"Impossible\" : join \"\\n\", map { \"$_->{name}:$_->{text}\" } @msgs[1 .. @msgs-2];\n\t\t\n\t\t}\n\t\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tfor (1 .. $_){\n\t\t$debug and print '-' x 10;\n\t\t\n\t\tmy $n = <>;\n\t\tmy %names = map { $_, 1 } split ' ', <>;\n\t\tmy $m = <>;\n\t\tmy @msgs = map ~~<>, 1 .. $m;\n\t\t\n\t\tchomp @msgs;\n\t\t\n\t\tunshift @msgs, 'a!:';\n\t\tpush @msgs, 'z!:';\n\t\t\n\t\tfor (@msgs){\n\t\t\tmy( $name, $text ) = split ':';\n\t\t\tmy @found_names = grep { $names{ $_ } } /\\w+/g;\n\t\t\t\n\t\t\t$debug and print \"${name}[@found_names]\";\n\t\t\t\n\t\t\tmy %cand_names;\n\t\t\t\n\t\t\tif( $name eq '?' ){\n\t\t\t\t%cand_names = %names;\n\t\t\t\tdelete $cand_names{ $_ } for @found_names;\n\t\t\t}\n\t\t\t\t\t\t\n\t\t\t$_ = {\n\t\t\t\tname => $name,\n\t\t\t\ttext => $text,\n\t\t\t\tcand => { %cand_names },\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\t$debug and do {\n\t\t\tfor (@msgs){ \n\t\t\t\tprint \"[$_->{name}]\",\n\t\t\t\t\t\"[$_->{text}]\",\n\t\t\t\t\t\"[\", (join ' ', keys %{$_->{cand}} ), \"]\"\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\tmy $FAIL = 0;\n\t\tmy $del = 1;\n\t\t\n\t\twhile( $del ){\n\t\t\t$del = 0;\n\t\t\tfor my $i (1 .. @msgs - 2, reverse 1 .. @msgs - 2){\n\t\t\t\tnext if $msgs[$i]->{name} ne '?';\n\t\t\t\t\n\t\t\t\t$debug and print map \"<<$_>>\", join ' ', keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i-1]->{name} } and $del ++;\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i+1]->{name} } and $del ++;\n\t\t\t\t\n\t\t\t\t$debug and print \"del:$del\";\n\t\t\t\t\n\t\t\t\tmy $num = keys %{ $msgs[$i]->{cand} };\n\t\t\t\tif( $num == 1 ){\n\t\t\t\t\t( $msgs[$i]->{name} ) = keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\t}\n\t\t\t\telsif( $num == 0 ){\n\t\t\t\t\t$FAIL = 1;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t$debug and do {\n\t\t\tfor (@msgs){ \n\t\t\t\tprint \"[$_->{name}]\",\n\t\t\t\t\t\"[$_->{text}]\",\n\t\t\t\t\t\"[\", (join ' ', keys %{$_->{cand}} ), \"]\"\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\tmy $idx = -2;\n\t\tmy $key;\n\t\t\n\t\tfor my $i (0 .. @msgs - 1){\n\t\t\tlast if $FAIL;\n\t\t\t\n\t\t\t$idx == $i - 1 and delete $msgs[$i]->{cand}->{$key};\n\t\t\t\n\t\t\t$msgs[$i]->{name} eq '?' and do {\n\t\t\t\t$key = ( keys %{ $msgs[$i]->{cand} } )[ 0 ];\n\t\t\t\t%{ $msgs[$i]->{cand} } = ();\n\t\t\t\t$msgs[$i]->{name} = $key;\n\t\t\t\t$idx = $i;\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\tshift @msgs;\n\t\tpop @msgs;\n\t\t\n\t\tprint $FAIL ? \"Impossible\" : join \"\\n\", map { \"$_->{name}:$_->{text}\" } @msgs;\n\t\t\n\t\t}\n\t\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tfor (1 .. $_){\n\t\t$debug and print '-' x 10;\n\t\t\n\t\tmy $n = <>;\n\t\tmy %names = map { $_, 1 } split ' ', <>;\n\t\tmy $m = <>;\n\t\tmy @msgs = map ~~<>, 1 .. $m;\n\t\t\n\t\tchomp @msgs;\n\t\t\n\t\tunshift @msgs, 'a!:';\n\t\tpush @msgs, 'z!:';\n\t\t\n\t\tfor (@msgs){\n\t\t\tmy( $name, $text ) = split ':';\n\t\t\tmy @found_names = grep { $names{ $_ } } /\\w+/g;\n\t\t\t\n\t\t\t$debug and print \"${name}[@found_names]\";\n\t\t\t\n\t\t\tmy %cand_names;\n\t\t\t\n\t\t\tif( $name eq '?' ){\n\t\t\t\t%cand_names = %names;\n\t\t\t\tdelete $cand_names{ $_ } for @found_names;\n\t\t\t}\n\t\t\t\t\t\t\n\t\t\t$_ = {\n\t\t\t\tname => $name,\n\t\t\t\ttext => $text,\n\t\t\t\tcand => { %cand_names },\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\t$debug and do {\n\t\t\tfor (@msgs){ \n\t\t\t\tprint \"[$_->{name}]\",\n\t\t\t\t\t\"[$_->{text}]\",\n\t\t\t\t\t\"[\", (join ' ', keys %{$_->{cand}} ), \"]\"\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\tmy $FAIL = 0;\n\t\tmy $del = 1;\n\t\t\n\t\twhile( $del ){\n\t\t\t$del = 0;\n\t\t\tfor my $i (1 .. @msgs - 2){\n\t\t\t\tnext if $msgs[$i]->{name} ne '?';\n\t\t\t\t\n\t\t\t\t$debug and print map \"<<$_>>\", join ' ', keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i-1]->{name} } and $del ++;\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i+1]->{name} } and $del ++;\n\t\t\t\t\n\t\t\t\t$debug and print \"del:$del\";\n\t\t\t\t\n\t\t\t\tmy $num = keys %{ $msgs[$i]->{cand} };\n\t\t\t\tif( $num == 1 ){\n\t\t\t\t\t( $msgs[$i]->{name} ) = keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\t}\n\t\t\t\telsif( $num == 0 ){\n\t\t\t\t\t$FAIL = 1;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t$debug and do {\n\t\t\tfor (@msgs){ \n\t\t\t\tprint \"[$_->{name}]\",\n\t\t\t\t\t\"[$_->{text}]\",\n\t\t\t\t\t\"[\", (join ' ', keys %{$_->{cand}} ), \"]\"\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\tshift @msgs;\n\t\tpop @msgs;\n\t\t\n\t\tprint $FAIL ? \"Impossible\" : join \"\\n\", map { \"$_->{name}:$_->{text}\" } @msgs;\n\t\t\n\t\t}\n\t\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tfor (1 .. $_){\n\t\t$debug and print '-' x 10;\n\t\t\n\t\tmy $n = <>;\n\t\tmy %names = map { $_, 1 } split ' ', <>;\n\t\tmy $m = <>;\n\t\tmy @msgs = map ~~<>, 1 .. $m;\n\t\t\n\t\tchomp @msgs;\n\t\t\n\t\tunshift @msgs, 'a!:';\n\t\tpush @msgs, 'z!:';\n\t\t\n\t\tfor (@msgs){\n\t\t\tmy( $name, $text ) = split ':';\n\t\t\tmy @found_names = grep { $names{ $_ } } /\\w+/g;\n\t\t\t\n\t\t\t$debug and print \"${name}[@found_names]\";\n\t\t\t\n\t\t\tmy %cand_names;\n\t\t\t\n\t\t\tif( $name eq '?' ){\n\t\t\t\t%cand_names = %names;\n\t\t\t\tdelete $cand_names{ $_ } for @found_names;\n\t\t\t}\n\t\t\t\t\t\t\n\t\t\t$_ = {\n\t\t\t\tname => $name,\n\t\t\t\ttext => $text,\n\t\t\t\tcand => { %cand_names },\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\t$debug and do {\n\t\t\tfor (@msgs){ \n\t\t\t\tprint \"[$_->{name}]\",\n\t\t\t\t\t\"[$_->{text}]\",\n\t\t\t\t\t\"[\", (join ' ', keys %{$_->{cand}} ), \"]\"\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\tmy $FAIL = 0;\n\t\tmy $del = 1;\n\t\t\n\t\twhile( $del ){\n\t\t\t$del = 0;\n\t\t\tfor my $i (1 .. @msgs - 2){\n\t\t\t\tnext if $msgs[$i]->{name} ne '?';\n\t\t\t\t\n\t\t\t\t$debug and print map \"<<$_>>\", join ' ', keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i-1]->{name} } and $del ++;\n\t\t\t\tdelete $msgs[$i]->{cand}->{ $msgs[$i+1]->{name} } and $del ++;\n\t\t\t\t\n\t\t\t\t$debug and print \"del:$del\";\n\t\t\t\t\n\t\t\t\tmy $num = keys %{ $msgs[$i]->{cand} };\n\t\t\t\tif( $num == 1 ){\n\t\t\t\t\t( $msgs[$i]->{name} ) = keys %{ $msgs[$i]->{cand} };\n\t\t\t\t\t}\n\t\t\t\telsif( $num == 0 ){\n\t\t\t\t\t$FAIL = 1;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t$debug and do {\n\t\t\tfor (@msgs){ \n\t\t\t\tprint \"[$_->{name}]\",\n\t\t\t\t\t\"[$_->{text}]\",\n\t\t\t\t\t\"[\", (join ' ', keys %{$_->{cand}} ), \"]\"\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\tmy $idx = -2;\n\t\tmy $key;\n\t\t\n\t\tfor my $i (0 .. @msgs - 1){\n\t\t\tlast if $FAIL;\n\t\t\t\n\t\t\t$idx == $i - 1 and delete $msgs[$i]->{cand}->{$key};\n\t\t\t\n\t\t\t$msgs[$i]->{name} eq '?' and do {\n\t\t\t\t$key = ( keys %{ $msgs[$i]->{cand} } )[ 0 ];\n\t\t\t\t%{ $msgs[$i]->{cand} } = ();\n\t\t\t\t$msgs[$i]->{name} = $key;\n\t\t\t\t$idx = $i;\n\t\t\t\t};\n\t\t\t}\n\t\t\n\t\tshift @msgs;\n\t\tpop @msgs;\n\t\t\n\t\tprint $FAIL ? \"Impossible\" : join \"\\n\", map { \"$_->{name}:$_->{text}\" } @msgs;\n\t\t\n\t\t}\n\t\n\t}"}], "src_uid": "3ac91d8fc508ee7d1afcf22ea4b930e4"}
{"source_code": "<>; \n\n$/ = $\\; $_ = <>;\n\nprint /^-.*^-/ms && /^\\d.*^\\d/ms ? \"No\" : \"Yes\"", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tmy $L = 0;\n\tmy $R = 0;\n\t\n\tfor( @_ ){\n\t\tmy( $x, $y ) = split;\n\t\t$x > 0 and $R ++;\n\t\t$x < 0 and $L ++;\n\t\t}\n\t\n\tif( $R <= 1 or $L <= 1 ){\n\t\tprint \"Yes\"\n\t\t}\n\telse{\n\t\tprint \"No\"\n\t\t}\n\t}"}, {"source_code": "<>;\n\n/^-/ ? $R ++ : $L ++ for <>;\n\nprint $R > 1 && $L > 1 ? \"No\" : \"Yes\""}], "negative_code": [{"source_code": "$/ = $\\; $_ = <>;\n\nprint /^-.*^-/ms && /^\\d.*^\\d/ms ? \"No\" : \"Yes\""}], "src_uid": "cf7bf89a6038586b69d3b8021cee0b27"}
{"source_code": "for (1..<>) {\r\n        chomp (my $k = <>);\r\n        $i = 1, $x = 1;\r\n        while ($i < $k) {\r\n                $x++;\r\n                $i++;\r\n                $x%10 == 3 and $x++;\r\n                $x%3 == 0 and $x++;\r\n                $x%10 == 3 and $x++;\r\n                $x%3 == 0 and $x++;\r\n        }\r\n        print $x, \"\\n\";\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nmy ($t) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\nforeach my $tt ( 1 .. $t ){\r\n  my ($k) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n  my $c = 0;\r\n  my $i = 1;\r\n  while(1){\r\n    unless( $i % 3 == 0 or $i % 10 == 3 ){\r\n      $c++;\r\n      last if $c == $k;\r\n    }\r\n    $i++;\r\n  }\r\n  print \"$i\\n\";\r\n}\r\n"}], "negative_code": [], "src_uid": "c37604d5d833a567ff284d7ce5eda059"}
{"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\n\nsub issubstr {\n    my ($s,$a) = @_;\n    for (0 .. @$a-1) {\n\treturn 1 if index($a->[$_],$s) != -1;\n    }\n    return 0;\n}\n\n\nmy $n = int <>;\nmy @a;\nfor (1 .. $n) {\n    my $s = <>;\n    chomp $s;\n    push @a, $s;\n}\nmy $s = 'a';\nwhile (issubstr($s,\\@a)) {\n    $s++;\n}\nprint $s;\n", "positive_code": [{"source_code": "<>;\n$_ = join\"\",<>;\n\nfor $a(a..z,aa..zz,aaa..zzz){\n    # print \"$a\\n\";\n    if (!/$a/){\n        print $a;\n        exit\n        }\n    }"}, {"source_code": "my $num = <>;\nchomp $num;\nmy @title;\nfor (1..$num) {\n    my $title = <>;\n    chomp $title;\n    push @title, $title;\n}\n\nmy $title = '';\nmy $flag = 0;\nwhile (!$flag) {\n    for ('a'..'z') {\n        my $new = $title.$_;\n        if (!grep /$new/, @title) {\n            $title = $new;\n            $flag = 1;\n            last;\n        }\n    }\n    if (!$flag) {\n        if ($title =~ /^z*$/) {\n            $title = 'a' x (1 + length $title);\n        } else {\n            $title =~ /(.*?)([^z]z*)$/;\n            my $temp = $2;\n            $temp =~ y/a-z/b-za/;\n            $title = $1.$temp;\n        }\n    } \n    \n}\nprint $title;"}], "negative_code": [{"source_code": "my $num = <>;\nchomp $num;\nmy @title;\nfor (1..$num) {\n    my $title = <>;\n    chomp $title;\n    push @title, $title;\n}\n\nmy $title = '';\nmy $flag = 0;\nwhile (!$flag) {\n    for ('a'..'z') {\n        my $new = $title.$_;\n        if (!grep /$new/, @title) {\n            $title = $new;\n            $flag = 1;\n            last;\n        }\n    }\n    $title .= 'a' if !$flag;\n}\nprint $title;"}], "src_uid": "58fa5c2f270e2c34e8f9671d5ffdb9c8"}
{"source_code": "$_=<>;\nchomp;\ns/\"(.*?)\"/#<$1>#/g;\n#print \"$_\\n\";;                                                                 \n@a=split '#';\nfor(@a){\n#print \"|$_|\\n\";\n  unless(/^</) {\n    print \"<$_>\\n\" for split ' ';\n  } else {\n    print \"$_\\n\";\n  }\n}", "positive_code": [{"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "use List::MoreUtils qw/ uniq /;\n$text = \"\";\nwhile (<>) {\n    $text .= $_;\n}\nwhile ($text =~ /\"([^\"]*)\"|([a-zA-Z0-9\\.?!,]+)/g) {\n   print \"<\".$1.$2.\">\\n\"\n}"}, {"source_code": "$_=<>;print\"<$1$2>\\n\"while/(?:\"(.*?)\"|(\\S+))/g"}, {"source_code": "#!/usr/bin/perl\nuse warnings;\nuse utf8;\nuse strict;\n\nchomp (my $s = <STDIN>);\n\n\n#while ($s =~ /\\A\\s*(\"?)([A-Za-z0-9.,\\?! ]*?)\\1(\\s+|\\z)/) {\n#\tprint \"<$2>\\n\";\n#\t$s = $';\n#}\n\nwhile ($s =~ /\\A\\s* (?: \" ([A-Za-z0-9.,\\?!\\s]*) \" \\s*  |  ([A-Za-z0-9.,\\?!]+) (?:\\s+|\\z) )/x) {\n\tif (defined $1) {\n\t\tprint \"<$1>\\n\";\n\t}\n\tif (defined $2) {\n\t\tprint \"<$2>\\n\";\n\t}\n\t$s = $';\n}\n"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nmy $cmd = <STDIN>;\nmy @lexems = split( /([\"]{1}[A-Za-z0-9.,?! ]*[\"]{1})/, $cmd );\nforeach ( @lexems ){\n    $_ =~ s/^\\s+//;\n    $_ =~ s/\\s+$//;\n    if ( $_ ne '' ) {\n\tif ( $_ =~ m/^[\"]{1}[A-Za-z0-9.,?! ]*[\"]{1}$/ ){\n\t    $_ =~ s/([\"]{1})([A-Za-z0-9.,?! ]*)([\"]{1})/\\<$2\\>/;\n\t    print $_.\"\\n\";\n\t}\n\telse {\n\t    my @unquoted_lexems = split( /([ ]+)/, $_ );\n\t    foreach ( @unquoted_lexems ){\n\t\t    $_ =~ s/^\\s+//;\n\t\t    $_ =~ s/\\s+$//;\n\t\t    if ( $_ ne '' ) {\n\t\t\t\tprint '<'.$_.'>'.\"\\n\";\n\t\t\t}\n\t    }\n\t}\n    }\n}"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "#!/usr/bin/perl\n$_=<>;\ns/\\s*(\"[^\"]*\"|[^\\s]+)\\s*/<$1>\\n/g;\ns/\"//g;\nprint $_;\n"}, {"source_code": "while (<>){\n    chomp;\n    \n    @_=split//;\n    $i=$j=0;\n    for (@_){\n        if ($_ eq '\"'){\n            $i++;\n            #$j++;\n            print $i%2?\"<\":\">\\n\";\n            next\n            }\n        if ($i%2){\n            print;\n            next\n            }\n        else{\n            if ($_ ne \" \"){\n                $j or print \"<\";\n                $j++;\n                print;\n                \n                }\n            else {\n                $j and print \">\\n\";\n                $j=0;\n                }\n            \n            }\n        \n        }\n    $j and print \">\\n\";\n    \n    }"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "$_=<>;\nprint \"<$3$2>\\n\"while /(\"(.*?)\"|(\\S+))/g"}, {"source_code": "$_=<>;\nprint \"<$1$2>\\n\"while /(?:\"(.*?)\"|(\\S+))/g"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g"}, {"source_code": "use strict;\nmy @text = split '\"', <>;\nfor (my $i = 0; $i < scalar @text; $i++) {\n\tif ($i % 2 == 0) {\n\t\tfor (split /\\s+/, $text[$i]) {\n\t\t\tif ($_ ne \"\") {\n\t\t\t\tprint \"<\" . $_ . \">\\n\";\n\t\t\t}\n\t\t}\n\t} else {\n\t\tprint \"<\" . $text[$i] . \">\\n\";\n\t}\n}\n"}, {"source_code": "$_=<>;\nchomp;\nwhile (/\"(.*?)\"([ ]|$)|([^\\s]+)([ ]|$)/mg) {\ndefined($1)? print \"<$1>\\n\" :print (\"<$3>\\n\");\n}"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "$_=<>;print\"<$3$2>\\n\"while/(\"(.*?)\"|(\\S+))/g\n"}, {"source_code": "#!/usr/bin/perl\nmy $line = <>;\nchomp($line);\nforeach ($line =~ /([^\" ]*|\"[^\"]*\")/g) {\n    if ($_ ne \"\") {\n        s/\"//g;\n        print \"<$_>\\n\";\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n$text = <>;\n$text =~ s/\\s*(\"[^\"]*\"|[^\\s]+)\\s*/<$1>\\n/g;\n$text =~ s/\"//g;\nprint $text;"}], "negative_code": [{"source_code": "$_=<>;\nchomp;\nwhile (/\"(.*?)\"|([^\\s]+)\\s/g) {\ndefined($1)? print \"<$1>\\n\" :print (\"<$2>\\n\");\n}"}, {"source_code": "$_=<>;\nchomp;\nwhile (/\"(.*?)\"|([^\\s]+)[ ]/g) {\ndefined($1)? print \"<$1>\\n\" :print (\"<$2>\\n\");\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nmy $cmd = <STDIN>;\nmy @lexems = split( /([\"]{1}[A-Za-z0-9.,?! ]*[\"]{1})/, $cmd );\nforeach ( @lexems ){\n    $_ =~ s/^\\s+//;\n    $_ =~ s/\\s+$//;\n    if ( $_ ) {\n\tif ( $_ =~ m/^[\"]{1}[A-Za-z0-9.,?! ]*[\"]{1}$/ ){\n\t    $_ =~ s/([\"]{1})([A-Za-z0-9.,?! ]*)([\"]{1})/\\<$2\\>/;\n\t    print $_.\"\\n\";\n\t}\n\telse {\n\t    my @unquoted_lexems = split( /([ ]+)/, $_ );\n\t    foreach ( @unquoted_lexems ){\n\t\t    $_ =~ s/^\\s+//;\n\t\t    $_ =~ s/\\s+$//;\n\t\t    if ( $_ ) {\n\t\t\t\tprint '<'.$_.'>'.\"\\n\";\n\t\t\t}\n\t    }\n\t}\n    }\n}\n"}], "src_uid": "6c7858731c57e1b24c7a299a8eeab373"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m ) = split;\n\t\n\t@_ = ();\n\t\n\tfor( 1 .. $n ){\n\t\tpush @_, ~~<>;\n\t\t}\n\t\n\tchomp @_;\n\t\n\tif( $n == 1 ){\n\t\tprint 'X' x $m;\n\t\tnext;\n\t\t}\n\t\n\tif( $n % 3 == 1 ){\n\t\tunshift @_, '.' x $m;\n\t\t}\n\t\n\tmy $i = 0;\n\tfor( @_ ){\n\t\tif( $i % 3 == 1 ){\n\t\t\ts/\\./X/g;\n\t\t\t}\n\t\t$i ++;\n\t\t}\n\t\n\t$debug and print for @_;\n\t\n\tfor my $i ( 0 .. $n - 1 ){\n\t\tnext if $i % 3 != 2;\n\t\tnext if $i + 1 > $n - 1;\n\t\t\n\t\tmy $idx_X1;\n\t\tmy $idx_X2;\n\t\t\n\t\t$idx_X1 = index $_[ $i ], 'X';\n\t\t$idx_X2 = index $_[ $i + 1 ], 'X';\n\t\t\n\t\t$debug and print \"[$idx_X1][$idx_X2]\";\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $idx_X1 == -1 and $idx_X2 == -1 ){\n\t\t\t$_[ $i ] =~ s/\\./X/;\n\t\t\t$_[ $i + 1 ] =~ s/\\./X/;\n\t\t\t}\n\t\telsif( $idx_X1 >= 0 ){\n\t\t\tsubstr $_[ $i + 1 ], $idx_X1, 1, 'X';\n\t\t\t}\n\t\telse{\n\t\t\tsubstr $_[ $i ], $idx_X2, 1, 'X';\n\t\t\t}\n\t\t}\n\t\n\t$debug and print '-' x 3;\n\t\n\tif( $n % 3 == 1 ){\n\t\tshift @_;\n\t\t}\n\t\n\tprint join \"\\n\", @_;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/^\\.*\\bX\\b([^Y]{$m})\\K\\./Y/gms };\n\t\n\t$insert->();\n\t$_ = reverse;\n\t$insert->();\n\t$_ = reverse;\n\t\n\ty/Y/X/;\n\t\n\ts/^\\.(?=\\.*$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/^[^Y]*\\bX\\b([^Y]{$m})\\K\\./Y/gms };\n\t\n\t$insert->();\n\t$_ = reverse;\n\t$insert->();\n\t$_ = reverse;\n\t\n\ty/Y/X/;\n\t\n\ts/^\\.(?=\\.*$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/\\bX\\b([^Y]{$m})\\K\\./Y/gms };\n\t\n\t$insert->();\n\t$_ = reverse;\n\t$insert->();\n\t$_ = reverse;\n\t\n\ty/Y/X/;\n\t\n\ts/^\\.(?=\\.*$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/\\bX\\b(.{$m})\\K\\./X/gms };\n\t\n\t$insert->() or do {\n\t\t$_ = reverse;\n\t\t$insert->();\n\t\t$_ = reverse;\n\t\t};\n\t\n\ts/^\\.(?=\\.*$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/\\bX\\b(.{$m})\\K./X/gms };\n\t\n\t$insert->();\n\t$_ = reverse;\n\t\n\t$insert->();\n\t$_ = reverse;\n\t\n\ts/^\\.(?=\\.*$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/^X+\\n\\.*X(.{$m})\\K./X/gms };\n\t\n\t$insert->();\n\t$_ = reverse;\n\t\n\t$insert->();\n\t$_ = reverse;\n\t\n\ts/^\\.(?=\\.*$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\t\n\tchomp @_;\n\t\n\t$n % 3 == 1 and unshift @_, '.' x $m;\n\t\n\tfor( my $i = 1; $i <= $n; $i += 3 ){\n\t\t$_[ $i ] =~ y/./X/;\n\t\t}\n\t\n\t$_ = join \"\\n\", @_;\n\t\n\tmy $insert = sub { s/^X+\\n\\.*X(.{$m})\\K./X/gms };\n\t\n\t$insert->();\n\t$_ = reverse;\n\t\n\t$insert->();\n\t$_ = reverse;\n\t\n\ts/^\\.(?=\\.+$)/X/gms;\n\t\n\t$n % 3 == 1 and s/^.+\\n//;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m ) = split;\n\t\n\t@_ = ();\n\t\n\tfor( 1 .. $n ){\n\t\tpush @_, ~~<>;\n\t\t}\n\t\n\tchomp @_;\n\t\n\tif( $n == 1 ){\n\t\tprint 'X' x $m;\n\t\tnext;\n\t\t}\n\t\n\tmy $i = 0;\n\tfor( @_ ){\n\t\tif( $i % 3 == 1 ){\n\t\t\ts/\\./X/g;\n\t\t\t}\n\t\t$i ++;\n\t\t}\n\t\n\t$debug and print for @_;\n\t\n\tfor my $i ( 0 .. $n - 1 ){\n\t\tnext if $i % 3 != 2;\n\t\tnext if $i + 1 >= $n - 1;\n\t\t\n\t\tmy $idx_X1;\n\t\tmy $idx_X2;\n\t\t\n\t\t$idx_X1 = index $_[ $i ], 'X';\n\t\t$idx_X2 = index $_[ $i + 1 ], 'X';\n\t\t\n\t\t$debug and print \"[$idx_X1][$idx_X2]\";\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $idx_X1 == -1 and $idx_X2 == -1 ){\n\t\t\t$_[ $i ] =~ s/\\./X/;\n\t\t\t$_[ $i + 1 ] =~ s/\\./X/;\n\t\t\t}\n\t\telsif( $idx_X1 >= 0 ){\n\t\t\tsubstr $_[ $i + 1 ], $idx_X1, 1, 'X';\n\t\t\t}\n\t\telse{\n\t\t\tsubstr $_[ $i ], $idx_X2, 1, 'X';\n\t\t\t}\n\t\t}\n\t\n\t$debug and print '-' x 3;\n\t\n\t$debug and print for @_;\n\t\n\tprint join \"\\n\", @_;\n\t}"}], "src_uid": "669390a40a6ef9bf1547c71823da169b"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\nuse integer;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($r,$b,$d) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  if( $d == 0 ){\r\n    print ( $r == $b ? \"YES\\n\" : \"NO\\n\" ); next;\r\n  }\r\n  ($r,$b) = ($b,$r) if $r < $b;\r\n  my $di = $r - $b;\r\n  my $dv = ($di+($d-1))/$d;\r\n  if( $b < $dv ){\r\n    print \"NO\\n\";\r\n  } else {\r\n    print \"YES\\n\";\r\n  }\r\n  \r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "<>;for(<>){($c,$d,$f)=split;($c,$d)=sort{$a<=>$b}($c, $d);print$c*++$f>=$d?\"YES$/\":\"NO$/\"}"}, {"source_code": "<>;\r\n\r\nfor (<>) {\r\n    chomp;\r\n    ($c, $d, $f) = split;\r\n    ($c, $d) = sort{$a <=> $b}($c, $d);\r\n    print $c * ($f+1) >= $d ? \"YES$/\" : \"NO$/\";\r\n}"}], "negative_code": [], "src_uid": "c0ad2a6d14b0c9e09af2221d88a34d52"}
{"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    for(my $i=0; $i<$q; $i++) {\n        my $i= <$in>; chomp($i);\n        my ($b, $p, $f)= split(' ', $i);\n\n        $i= <$in>; chomp($i);\n        my ($h, $c)= split(' ', $i);\n\n        my $profit= 0;\n        if($h > $c) { # make hamburgers as much as u can\n            while($b>=2 && $p>0) {\n                $profit += $h;\n                $b-= 2;\n                $p--;\n            }\n\n            while($b>=2 && $f>0) {\n                $profit += $c;\n                $b-= 2;\n                $f--;\n            }\n        } else {\n            while($b>=2 && $f>0) {\n                $profit += $c;\n                $b-= 2;\n                $f--;\n            }\n\n            while($b>=2 && $p>0) {\n                $profit += $h;\n                $b-= 2;\n                $p--;\n            }\n        }\n\n        print $profit;\n        print $/;\n    }\n\n}\n\nmain() unless caller();\n\n", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nchomp (my $line = <STDIN>);\nmy $t = $line;\n\nfor (1..$t) {\n    $line = <STDIN>;\n    my ($b, $p, $f) = split q{ }, $line;\n    $b = $b - 1 if $b % 2 == 1;\n    $line = <STDIN>;\n    my ($h, $c) = split q{ }, $line;\n\n    my $price = 0;\n\n    if ( $h > $c ) {\n        $price += $h * make(\\$b, \\$p);\n        $price += $c * make(\\$b, \\$f);\n    }\n    else {\n        $price += $c * make(\\$b, \\$f);\n        $price += $h * make(\\$b, \\$p);\n    }\n    say $price;\n}\n\nsub make {\n    my ($b, $m) = @_;\n    my $count = 0;\n    if ( 2*$$m > $$b ) {\n        $count = $$b/2;\n        $$b = 0;\n        $$m -= $count;\n    }\n    else {\n        $count = $$m;\n        $$m = 0;\n        $$b -= 2 * $count;\n    }\n    return $count;\n}\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\n    ( $b, $p, $f, $h, $c, $s ) = split ' ', $_ . <> . 0;\n    \n    $b >>= 1;\n    \n    $_ = 'p' x $p . 'f' x $f;\n    \n    $_ = reverse if $h < $c;\n    \n    /(?(?{ $b == pos })(*ACCEPT)) . (?{ $s += $& eq 'p' ? $h : $c }) (*F)/x;\n    \n    print $s;\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print \"-\" x 15;\n\t\n\tmy( $b, $p, $f ) = split;\n\tmy( $h, $c ) = split ' ', <>;\n\t\n\t$b /= 2;\n\t\n\tmy $middle = 'p' x $p . 'f' x $f;\n\t\n\tif( $h < $c ){\n\t\t$middle = reverse $middle;\n\t\t}\n\t\n\tmy $L = substr $middle, 0, $b;\n\t\n\t$debug and print $L;\n\t\n\tmy $cp = () = $L =~ /p/g;\n\tmy $cf = () = $L =~ /f/g;\n\t\n\t$debug and print \"$cp $cf\";\n\t\n\tprint $cp * $h + $cf * $c;\n\t}"}], "negative_code": [{"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    for(my $i=0; $i<$q; $i++) {\n        my $i= <$in>; chomp($i);\n        my ($b, $p, $f)= split(' ', $i);\n\n        $i= <$in>; chomp($i);\n        my ($h, $c)= split(' ', $i);\n\n        my $profit= 0;\n        if($h > $c) { # make hamburgers as much as u can\n            while($b>=2 && $p>0) {\n                $profit += $h;\n                $b-= 2;\n                $p--;\n            }\n\n            while($b>=2 && $f>0) {\n                $profit += $c;\n                $b-= 2;\n                $f--;\n            }\n        } else {\n            while($b>=2 && $f>0) {\n                $profit += $c;\n                $b-= 2;\n                $f--;\n            }\n\n            while($b>=2 && $p>0) {\n                $profit += $h;\n                $b-= 2;\n                $p--;\n            }\n        }\n\n        print $profit;\n    }\n\n}\n\nmain() unless caller();\n\n"}], "src_uid": "92bf30e66f4d5ddebb697d2fa4fa0689"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $A = 'a' x 4;\n\t\n\tmy %h;\n\t\n\t$_ = join ' ', reverse \n\t\tmap { $h{ $_ } or $h{ $_ } = ++ $A and \"$A,\" } split ' ', <>;\n\t\n\tmy $ans = 0;\n\tmy $min;\n\tmy $new_min;\n\t\n\tm/\t\n\t\t\\b(\\w+)\\b(,)?+\n\t\t(?{\n\t\t\tif( not defined $min ){\n\t\t\t\t$min = $1;\n\t\t\t\t}\n\t\t\telsif( $min lt $1 or $min eq $1 and !$2 ){\n\t\t\t\t$ans ++;\n\t\t\t\t}\n\t\t\telsif( $min gt $1 ){\n\t\t\t\tif( not defined $new_min ){\n\t\t\t\t\t$new_min = $1;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$new_min gt $1 and $new_min = $1;\n\t\t\t\t\t$ans ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\tif( $min eq $1 and $2 ){\n\t\t\t\tif( defined $new_min ){\n\t\t\t\t\t$min = $new_min;\n\t\t\t\t\tundef $new_min;\n\t\t\t\t\t$ans ++;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tundef $min;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t(*FAIL)\n\t\t/x;\n\t\n\tprint $ans;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy @ABC;\nmy $abc = 'a';\n\nfor my $i ( 0 .. 2e5 ){\n\tpush @ABC, $abc ++;\n\t}\n\nwhile(<>){\n\t@_ = map $ABC[ $_ ], split ' ', <>;\n\t\n\t$_ = join ' ', @_;\n\t\n\tmy %B;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\t$B{ $_[ $i ] } = exists $B{ $_[ $i ] } ? $i : -1;\n\t\t}\n\t\n\tmy $ans = 0;\n\tmy $under = 0;\n\tmy $cover;\n\tmy $far_cover;\n\tmy $far_dist;\n\t\n\tmy $i = 0;\n\t\n\tm/\n\t\t\\b\\w+\\b\n\t\t(?{\n\t\t\t$i ++;\n\t\t\t\n\t\t\tif( $under ){\n\t\t\t\tif( $& eq $cover ){\n\t\t\t\t\tif( $B{ $& } + 1 != $i ){\n\t\t\t\t\t\t$ans ++;\n\t\t\t\t\t\t}\n\t\t\t\t\telsif( defined $far_dist and $far_dist >= $i ){\n\t\t\t\t\t\t$cover = $far_cover;\n\t\t\t\t\t\tundef $far_cover;\n\t\t\t\t\t\tundef $far_dist;\n\t\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t$under = 0;\n\t\t\t\t\t\tundef $cover;\n\t\t\t\t\t\tundef $far_dist;\n\t\t\t\t\t\tundef $far_cover;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$ans ++;\n\t\t\t\t\tif( $B{ $& } > -1 and not \n\t\t\t\t\t\t( defined $far_dist and $B{ $& } <= $far_dist ) ){\n\t\t\t\t\t\t$far_dist = $B{ $& };\n\t\t\t\t\t\t$far_cover = $&;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\tif( $B{ $& } > -1 ){\n\t\t\t\t\t$cover = $&;\n\t\t\t\t\t$under = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t})\n\t\t(*FAIL)\n\t\t/x;\n\t\t\n\tprint $ans;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = split ' ', <>;\n\t\n\t$debug and print \"[@_]\";\n\t\n\tmy @B = ( -2 ) x ( @_ + 1 );\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tif( $B[ $_[ $i ] ] == -2 ){\n\t\t\t$B[ $_[ $i ] ] = -1;\n\t\t\t}\n\t\telsif( $B[ $_[ $i ] ] > -2 ){\n\t\t\t$B[ $_[ $i ] ] = $i;\n\t\t\t}\n\t\t}\n\t\n\tmy $ans = 0;\n\tmy $under = 0;\n\tmy $cover;\n\tmy $far_cover;\n\tmy $far_dist;\n\t\n\tmy $i = 0;\n\t\n\twhile( @_ ){\n\t\t$_ = shift @_;\n\t\t$i ++;\n\t\t$debug and print \"$i:[$_]\";\n\t\t\n\t\tif( $under ){\n\t\t\tif( $_ == $cover ){\n\t\t\t\t$debug and print \" 1)\";\n\t\t\t\tif( $B[ $_ ] + 1 != $i ){\n\t\t\t\t\t$debug and print \"  1.1) $B[$_],$i\";\n\t\t\t\t\t$ans ++;\n\t\t\t\t\t}\n\t\t\t\telsif( defined $far_dist and $far_dist >= $i ){\n\t\t\t\t\t$cover = $far_cover;\n\t\t\t\t\tundef $far_cover;\n\t\t\t\t\tundef $far_dist;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$under = 0;\n\t\t\t\t\tundef $cover;\n\t\t\t\t\tundef $far_dist;\n\t\t\t\t\tundef $far_cover;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$debug and print \" 2)\";\n\t\t\t\t$ans ++;\n\t\t\t\t$debug and print \" $cover,$_\";\n\t\t\t\tif( $B[ $_ ] > -1 ){\n\t\t\t\t\tif( defined $far_dist ) {\n\t\t\t\t\t\tif( $B[ $_ ] > $far_dist ){\n\t\t\t\t\t\t\t$far_dist = $B[ $_ ];\n\t\t\t\t\t\t\t$far_cover = $_;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t$far_dist = $B[ $_ ];\n\t\t\t\t\t\t$far_cover = $_;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\telse{\n\t\t\t$debug and print \" 3)\";\n\t\t\tif( $B[ $_ ] > -1 ){\n\t\t\t\t$cover = $_;\n\t\t\t\t$under = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t}\n\t\n\tprint $ans;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $A = 'a' x 4;\n\t\n\tmy %h;\n\t\n\t$_ = join ' ', reverse \n\t\tmap { $h{ $_ } or $h{ $_ } = ++ $A and \"$A,\" } split ' ', <>;\n\t\n\tmy $ans = 0;\n\tmy $q = 0;\n\tmy $min = 'z';\n\t\n\tm/\t\n\t\t\\b(\\w+)\\b(,)?+\n\t\t(?{\n\t\t\tif( defined $2 and $min ge $1 ){\n\t\t\t\t$min eq $1 and -- $ans;\n\t\t\t\t$q > 1 and -- $ans;\n\t\t\t\t$q = 0;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t++ $ans;\n\t\t\t\t$min gt $1 and $min = $1 and ++ $q;\n\t\t\t\t}\n\t\t\t})\n\t\t(*FAIL)\n\t\t/x;\n\t\n\tprint $ans;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $A = 'a' x 4;\n\t\n\tmy %h;\n\t\n\t$_ = join ' ', reverse \n\t\tmap { $h{ $_ } or $h{ $_ } = ++ $A and \"$A,\" } split ' ', <>;\n\t\n\tmy $ans = 0;\n\tmy $min = 'z';\n\t\n\tm/\t\n\t\t\\b(\\w+)\\b(,)?+\n\t\t(?{\n\t\t\tif( $min lt $1 or $min eq $1 and !$2 ){\n\t\t\t\t$ans ++;\n\t\t\t\t}\n\t\t\t$1 lt $min and $min = $1;\n\t\t\t})\n\t\t(*FAIL)\n\t\t/x;\n\t\n\tprint $ans;\n\t}"}], "src_uid": "daf675dadc8edcd6734edbf3548eb6bf"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy %h;\n\t\n\tfor my $i ( 1 .. $_ ){\n\t\t<>;\n\t\t@_ = split ' ', <>;\n\t\tmy $sum = 0;\n\t\t$sum += $_ for @_;\n\t\t\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\t$h{ $sum - $_[ $j ] }{ $i } = $j + 1;\n\t\t\t}\n\t\t}\n\t\n\tmy $ok = 0;\n\t\n\tfor my $i ( keys %h ){\n\t\tmy @keys = keys %{ $h{ $i } };\n\t\tnext if @keys < 2;\n\t\tprint \"YES\";\n\t\tprint $keys[ 0 ], ' ', $h{ $i }{ $keys[ 0 ] };\n\t\tprint $keys[ 1 ], ' ', $h{ $i }{ $keys[ 1 ] };\n\t\t$ok = 1;\n\t\tlast;\n\t\t}\n\t\n\t$ok or print \"NO\";\n\t}", "positive_code": [{"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/, $, = qq/ /;\nsub sum { \n    my $result = 0;\n    $result += $_ for @{ $_ [ 0 ] };\n    $result;\n}\nmy $k = <STDIN>;\nchomp ( $k );\nmy %h = ();\nfor my $i ( 1 .. $k ) {\n    chomp ( my $n = <STDIN> );\n    my @a = split qq/ /, <STDIN>;\n    my $s = sum ( \\@a ); \n    my $index = 1;\n    for my $j ( @a ) {\n        if ( exists $h { $s - $j } and $h { $s - $j } -> [ 0 ] != $i ) {\n            print \"YES\";\n            print + $i, $index;\n            print + $h { $s - $j } -> [ 0 ], $h { $s - $j } -> [ 1 ];\n            exit;\n        } else { $h { $s - $j } = [ $i, $index ] }\n        $index += 1;\n    }\n}\nprint \"NO\";\n"}], "negative_code": [{"source_code": "use warnings;\nuse strict;\n$\\ = qq/\\n/, $, = qq/ /;\nsub sum { \n    my $result = 0;\n    $result += $_ for @{ $_ [ 0 ] };\n    $result;\n}\nmy $k = <STDIN>;\nchomp ( $k );\nmy %h = ();\nfor my $i ( 1 .. $k ) {\n    chomp ( my $n = <STDIN> );\n    my @a = split qq/ /, <STDIN>;\n    my $s = sum ( \\@a ); \n    my $index = 1;\n    for my $j ( @a ) {\n        if ( exists $h { $s - $j } and $h { $s - $j } -> [ 0 ] != $i ) {\n            print \"YES\";\n            print + $i, $j;\n            print + $h { $s - $j } -> [ 0 ], $h { $s - $j } -> [ 1 ];\n            exit;\n        } else { $h { $s - $j } = [ $i, $index ] }\n        $index += 1;\n    }\n}\nprint \"NO\";\n"}], "src_uid": "7561bca5fa2200ce9ae7e30e7076c6ab"}
{"source_code": "($n, $m) = split /\\s+/, <>; $i = 0;\nwhile ($row = <>) {\n\tif (($i++ == 0 || $i == $n) && $row =~ /1/) { print 2; exit; }\n\tif ($row =~ /^1.*|.*1$/) { print 2; exit; }\n}\nprint 4;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>=~/1/ and $F++;\nwhile(<>){\n\t/^1|1$/ and $F++;\n\t $a=$_;\n\t}\n$a=~/1/ and $F++;\n\nprint $F?2:4;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "($n, $m) = split / /, <>;\nwhile (<>) {\n\tchomp;\n\tpush @a, [split / /];\n}\n# print_a(\\@a);\n$n--;\n$m--;\nfor $i (0..$n) {\n\tif ($a[$i][0] == 1 || $a[$i][$m] == 1) {\n\t\tprint \"2\\n\";\n\t\texit;\n\t}\n}\nfor $j (0..$m) {\n\tif ($a[0][$j] == 1 || $a[$n][$j] == 1) {\n\t\tprint \"2\\n\";\n\t\texit;\n\t}\n}\nprint \"4\\n\";\n\nsub print_a() {\n\t$a = shift;\n\tfor $i (0..$n-1) {\n\t\tfor $j (0..$m-1) {\n\t\t\tprint $a->[$i][$j];\n\t\t}\n\t\tprint \"\\n\";\n\t}\n}"}], "negative_code": [{"source_code": "<>;\nwhile ($row = <>) {\n\tif ($row =~ /^1.*|.*1$/) {\n\t\tprint 2; exit;\n\t}\n}\nprint 4;\n"}, {"source_code": "<>; $row = <>;\nif ($row =~ /.*1.*/) { print 2; exit; }\nwhile ($row = <>) {\n\tif ($row =~ /^1.*|.*1$/) { print 2; exit; }\n}\nif ($row =~ /.*1.*/) { print 2; exit; }\nprint 4;\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>=~/1/ and $F++;\nwhile($a=<>){\n\t$a=~/^1|1$/ and $F++;\n\t}\n$a=~/1/ and $F++;\n\nprint $F?2:4;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>=~/1/ and $F++;\nwhile(<>){\n\t/^1|1$/ and $F++;\n\t}\n/1/ and $F++;\n\nprint $F?2:4;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "0d2fd9b58142c4f5282507c916690244"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n,$l,$r,$s) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  \r\n  my $k = $r - $l + 1;\r\n  \r\n  my $s_min = $k * ( $k + 1 ) / 2;\r\n  my $s_max = $n * ( $n + 1 ) / 2 - ( ($n-$k) * ( ($n-$k) + 1 ) / 2 );\r\n  if( $s < $s_min or $s_max < $s ){\r\n    print \"-1\\n\";\r\n    next;\r\n  }\r\n  \r\n  my $s1 = $s_min;\r\n  my @p1 = (1..$k); my @p2 = ();\r\n  while($s1 < $s){\r\n    my $s_max = ( $#p2 < 0 ? $n : $p2[0]-1 );\r\n    my $dif1 = $s_max - $p1[$#p1];\r\n    unless( $s1 + $dif1 <= $s ){\r\n      $dif1 = $s - $s1;\r\n      $s_max = $p1[$#p1] + $dif1;\r\n    }\r\n    pop(@p1);\r\n    unshift(@p2,$s_max);\r\n    $s1 += $dif1;\r\n  }\r\n  my @p = (@p1,@p2);\r\n  my @use = (); $#use = $n;\r\n  for(my $i=0;$i<=$#p;$i++){\r\n    $use[$p[$i]] = 1;\r\n  }\r\n  my @out = ();\r\n  my $idx = 1;\r\n  for(my $i=0;$i<$l-1;$i++){\r\n    while($use[$idx]){\r\n      $idx++;\r\n    }\r\n    push(@out,$idx);\r\n    $use[$idx] = 1;\r\n  }\r\n  push(@out,@p);\r\n  for(my $i=$r+1;$i<=$n;$i++){\r\n    while($use[$idx]){\r\n      $idx++;\r\n    }\r\n    push(@out,$idx);\r\n    $use[$idx] = 1;\r\n  }\r\n  print (join(' ',@out) . \"\\n\");\r\n  \r\n}\r\n\r\nexit(0);\r\n\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $L, $R, $s ) = split;\n\t\n\tmy $diff = $R - $L + 1;\n\t\n\tmy @arr = 1 .. $diff;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @arr;\n\t\n\tif( $s < $sum ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy $i = @arr - 1;\n\t\n\twhile( $s != $sum ){\n\t\t$arr[ $i ] ++;\n\t\t$sum ++;\n\t\t$i --;\n\t\t$i < 0 and $i = @arr - 1;\n\t\t}\n\t\n\tif( $arr[ @arr - 1 ] > $n ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy %h;\n\t\n\t$h{ $_ } ++ for @arr;\n\t\n\tfor( 1 .. $n ){\n\t\tnext if exists $h{ $_ };\n\t\t\n\t\tpush @arr, $_;\n\t\t}\n\t\n\tfor( 1 .. $L - 1 ){\n\t\tmy $tmp = pop @arr;\n\t\tunshift @arr, $tmp;\n\t\t}\n\t\n\tprint \"@arr\";\n\t}"}], "negative_code": [], "src_uid": "88c8376ad65c5c932c15dc09d6c4d75f"}
{"source_code": "my $n = <>;\nmy @sizes = split ' ', <>;\nmy $line = <>; chomp $line;\nmy (@is, @es);\n@is = sort { @sizes[$b - 1] <=> @sizes[$a - 1] } (1..$n);\nfor my $i (split '', $line) {\n    if ($i eq '0') {\n        $_ = pop @is;\n        push @es, $_;\n    } else {\n        $_ = pop @es;\n    }\n    print $_ . ' ';\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmy $i = 0;\n\t\n\tmap { $h{ $_ } = ++ $i } @_;\n\t\n\t@_ = sort { $a <=> $b } @_;\n\t\n\t$_ = <>, chomp;\n\t\n\tmy @ans;\n\tmy @stack;\n\t\n\tfor( split // ){\n\t\tif( $_ ){\n\t\t\tpush @ans, $h{ pop @stack };\n\t\t\t}\n\t\telse{\n\t\t\tmy $w = shift @_;\n\t\t\tpush @ans, $h{ $w };\n\t\t\tpush @stack, $w;\n\t\t\t}\n\t\t}\n\t\n\tprint \"@ans\";\n\t}"}, {"source_code": "<>;\n\n%h = map { $_, ++ $i } @_ = split ' ', <>;\n\n@_ = sort { $a <=> $b } @_;\n\nfor( <> =~ /./g ){\n\tpush @a, $_ ?\n\t\t$h{ pop @s }\n\t\t:\n\t\tdo {\n\t\t\tpush @s, $w = shift @_;\n\t\t\t$h{ $w }\n\t\t}\n\t}\n\nprint \"@a\""}], "negative_code": [], "src_uid": "161009edb8e3d438cdd8c0d1e202f783"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nfor ( 1..$line ) {\n    chomp ($line = <STDIN>);\n    my ($c, $m, $x) = split q{ }, $line;\n    my $answer = 0;\n\n    $answer = min(min($c, $m), int(($c+$m+$x)/3));\n\n    say $answer;\n}\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for (@numbers) {\n        $min = $_ if $_ < $min;\n    }\n    return $min;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x15;\n\t\n\tmy( $c, $m, $x ) = split;\n\t\n\t( $c, $m ) = sort { $b <=> $a } $c, $m;\n\t\n\tmy( $min ) = sort { $a <=> $b } $c, $m, $x;\n\t\n\t$debug and print \"$c, $m, $x\";\n\t\n\tmap $_ -= $min, $c, $m, $x;\n\t\n\t$debug and print \"$c, $m, $x\";\n\t\n\tprint $min + do {\n\t\tif( $x == 0 ){\n\t\t\t( sort { $a <=> $b } int( ( $c + $m ) / 3 ), $m )[ 0 ];\n\t\t\t}\n\t\telse{\n\t\t\t0;\n\t\t\t}\n\t\t};\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nfor ( 1..$line ) {\n    chomp ($line = <STDIN>);\n    my ($c, $m, $x) = split q{ }, $line;\n    my $answer = 0;\n\n    if ( $c >= 1 and $m >= 1 and $x >= 1 ) {\n        my $min = min($c, $m, $x);\n        $c -= $min, $m -= $min, $x -= $min;\n        $answer += $min;\n    }\n\n    if ( $c >= 3 and $m >= 3 ) {\n        my $min = min(int($c/3), int($m/3));\n        $c -= 3*$min, $m -= 3*$min;\n        $answer += $min*2;\n    }\n\n    if ( $c < $m ) { \n        ($c, $m) = ($m, $c);\n    }\n\n    if ( $c >= 2 and $m >= 1 ) {\n        $c -= 2, $m -= 1;\n        $answer += 1;\n        next;\n    }\n    last;\n\n    say $answer;\n}\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for (@numbers) {\n        $min = $_ if $_ < $min;\n    }\n    return $min;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nfor ( 1..$line ) {\n    chomp ($line = <STDIN>);\n    my ($c, $m, $x) = split q{ }, $line;\n    my $answer = 0;\n\n    if ( $c >= 1 and $m >= 1 and $x >= 1 ) {\n        my $min = min($c, $m, $x);\n        $c -= $min, $m -= $min, $x -= $min;\n        $answer += $min;\n    }\n\n    while ( 1 ) {\n    \n        if ( $c < $m ) {\n            ($c, $m) = ($m, $c);\n        }\n\n        if ( $c >= 2 and $m >= 1 ) {\n            my $min = min(int($c/2), $m);\n            $c -= 2*$min, $m -= $min;\n            $answer += $min;\n            next;\n        }\n        last;\n    }\n\n    say $answer;\n}\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for (@numbers) {\n        $min = $_ if $_ < $min;\n    }\n    return $min;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x15;\n\t\n\tmy( $c, $m, $x ) = split;\n\t\n\t( $c, $m ) = sort { $b <=> $a } $c, $m;\n\t\n\tmy( $min ) = sort { $a <=> $b } $c, $m, $x;\n\t\n\t$debug and print \"$c, $m, $x\";\n\t\n\tmap $_ -= $min, $c, $m, $x;\n\t\n\t$debug and print \"$c, $m, $x\";\n\t\n\tprint $min + do {\n\t\tif( $x == 0 ){\n\t\t\tint( ( $c + $m ) / 3 );\n\t\t\t}\n\t\telse{\n\t\t\t0;\n\t\t\t}\n\t\t};\n\t}"}], "src_uid": "b18dac401b655c06bee331e71eb3e4de"}
{"source_code": "use strict;\nuse warnings;\nuse integer;\n\n\nmy $q = <>;\nfor (my $i = 0; $i < $q; $i++) {core();};\n\nsub core {\n\tmy ($n, $m) = readpos(); # board sizes\n\tmy ($wx1, $wy1, $wx2, $wy2) = readrect(); # spill white rectangle\n\tmy ($bx1, $by1, $bx2, $by2) = readrect(); # spill black rectangle\n\n\tmy ($white, $black) = aftercolors($m, $n, $wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2);\n\tprint \"$white $black\\n\";\n}\n\nsub readpos {\n\t<> =~ /(\\d+)\\s+(\\d+)/;\n\treturn ($1, $2);\n}\n\nsub readrect {\n\t<> =~ /(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)/;\n\treturn ($1, $2, $3, $4);\n}\n\nsub aftercolors {\n\tmy ($m, $n, $wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2) = @_;\n\tmy $boardwhite    = white(1, 1, $m, $n);\n\tmy $boardblack    = black(1, 1, $m, $n);\n\n\tmy $whiteunderwhitespillarea = white($wx1, $wy1, $wx2, $wy2);\n\tmy $blackunderwhitespillarea = black($wx1, $wy1, $wx2, $wy2);\n\tmy $whiteunderblackspillarea = white($bx1, $by1, $bx2, $by2);\n\tmy $blackunderblackspillarea = black($bx1, $by1, $bx2, $by2);\n\n\tmy ($cx1, $cy1, $cx2, $cy2) = commonargs($wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2);\n\n\tmy $whiteundercommon = white($cx1, $cy1, $cx2, $cy2);\n\tmy $blackundercommon = black($cx1, $cy1, $cx2, $cy2);\n\n\tmy $white = $boardwhite + $blackunderwhitespillarea - $blackundercommon - $whiteunderblackspillarea;\n\tmy $black = $boardblack - $blackunderwhitespillarea + $blackundercommon + $whiteunderblackspillarea;\n\n\treturn ($white, $black);\n}\n\nsub valid {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\treturn $x1 <= $x2 && $y1 <= $y2;\n}\n\nsub commonargs {\n\tmy ($wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2) = @_;\n\treturn (max($wx1, $bx1), max($wy1, $by1), min($wx2, $bx2), min($wy2, $by2));\n}\n\nsub color {\n\tmy ($color, $x1, $y1, $x2, $y2) = @_;\n\tmy $area = area($x1, $y1, $x2, $y2);\n\n\tif ($area % 2 == 0) {\n\t\treturn $area / 2;\n\t} else {\n\t\treturn colorpos($color, $x1, $y1) ? ($area + 1) / 2 : ($area - 1) / 2;\n\t}\n}\n\nsub colorpos {\n\tmy ($color, $x, $y) = @_;\n\tmy $diagonal = $x % 2 == $y % 2;\n\treturn $color eq \"white\" ? $diagonal : !$diagonal;\n}\n\nsub white {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\treturn color(\"white\", $x1, $y1, $x2, $y2);\n}\n\nsub black {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\treturn color(\"black\", $x1, $y1, $x2, $y2);\n}\n\nsub area {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\tif (valid($x1, $y1, $x2, $y2)) {\n\t\tmy $lx = $x2 - $x1 + 1;\n\t\tmy $ly = $y2 - $y1 + 1;\n\t\treturn $lx * $ly;\n\t} else {\n\t\treturn 0;\n\t}\n}\n\n# use List::Util qw[min max];\nsub min {\n\tmy ($a, $b) = @_;\n\treturn $a <= $b ? $a : $b;\n}\nsub max {\n\tmy ($a, $b) = @_;\n\treturn $a <= $b ? $b : $a;\n}\n", "positive_code": [{"source_code": "use strict;\nuse warnings;\nuse integer;\n\n\nmy $q = <>;\nfor (my $i = 0; $i < $q; $i++) {core();};\n\nsub core {\n\tmy ($n, $m) = readpos(); # board sizes\n\tmy ($wx1, $wy1, $wx2, $wy2) = readrect(); # spill white rectangle\n\tmy ($bx1, $by1, $bx2, $by2) = readrect(); # spill black rectangle\n\n\tmy ($white, $black) = aftercolors($m, $n, $wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2);\n\tprint \"$white $black\\n\";\n}\n\nsub readpos {\n\t<> =~ /(\\d+)\\s+(\\d+)/;\n\treturn ($1, $2);\n}\n\nsub readrect {\n\t<> =~ /(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)/;\n\treturn ($1, $2, $3, $4);\n}\n\nsub aftercolors {\n\tmy ($m, $n, $wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2) = @_;\n\tmy ($boardwhite, $boardblack) = colors(1, 1, $m, $n);\n\n\tmy ($whiteunderwhitespillarea, $blackunderwhitespillarea) = colors($wx1, $wy1, $wx2, $wy2);\n\tmy ($whiteunderblackspillarea, $blackunderblackspillarea) = colors($bx1, $by1, $bx2, $by2);\n\n\tmy ($cx1, $cy1, $cx2, $cy2) = commonargs($wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2);\n\tmy ($whiteundercommon, $blackundercommon) = colors($cx1, $cy1, $cx2, $cy2);\n\n\tmy $white = $boardwhite + $blackunderwhitespillarea - $blackundercommon - $whiteunderblackspillarea;\n\tmy $black = $boardblack - $blackunderwhitespillarea + $blackundercommon + $whiteunderblackspillarea;\n\n\treturn ($white, $black);\n}\n\nsub valid {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\treturn $x1 <= $x2 && $y1 <= $y2;\n}\n\nsub commonargs {\n\tmy ($wx1, $wy1, $wx2, $wy2, $bx1, $by1, $bx2, $by2) = @_;\n\treturn (max($wx1, $bx1), max($wy1, $by1), min($wx2, $bx2), min($wy2, $by2));\n}\n\nsub colors {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\tmy $area = area($x1, $y1, $x2, $y2);\n\n\tif ($area % 2 == 0) {\n\t\tmy $halfarea = $area / 2;\n\t\treturn ($halfarea, $halfarea);\n\t} else {\n\t\tmy ($more, $less) = (($area + 1) / 2, ($area - 1) / 2);\n\t\treturn colorpos(\"white\", $x1, $y1) ? ($more, $less) : ($less, $more);\n\t}\n}\n\nsub colorpos {\n\tmy ($color, $x, $y) = @_;\n\tmy $diagonal = $x % 2 == $y % 2;\n\treturn $color eq \"white\" ? $diagonal : !$diagonal;\n}\n\nsub area {\n\tmy ($x1, $y1, $x2, $y2) = @_;\n\tif (valid($x1, $y1, $x2, $y2)) {\n\t\tmy $lx = $x2 - $x1 + 1;\n\t\tmy $ly = $y2 - $y1 + 1;\n\t\treturn $lx * $ly;\n\t} else {\n\t\treturn 0;\n\t}\n}\n\n# use List::Util qw[min max];\nsub min {\n\tmy ($a, $b) = @_;\n\treturn $a <= $b ? $a : $b;\n}\nsub max {\n\tmy ($a, $b) = @_;\n\treturn $a <= $b ? $b : $a;\n}\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\nuse integer;\n\n<>;\nwhile (<>) {\n\t/(\\d+)\\s+(\\d+)/;\n\tmy $r = sumbetween($1, $2);\n\tprint $r, \"\\n\";\n}\n\nsub sumbetween {\n\tmy ($beg, $end) = @_;\n\tmy $all = mount($end);\n\tmy $before = mount($beg - 1);\n\treturn $all - $before;\n}\n\nsub mount {\n\tmy $i = shift(@_);\n\tmy $sign = $i % 2 == 0 ? +1 : -1;\n\t# print \"(\", $sign * upperdiv($i, 2), \")\";\n\treturn $sign * upperdiv($i, 2);\n}\n\nsub upperdiv {\n\tmy ($a, $b) = @_;\n\tmy $r = $a / $b;\n\t$r++ if $a % $b > 0;\n\treturn $r;\n}\n"}], "src_uid": "1c4607c96f7755af09445ff29a54bd08"}
{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ .= <> . <>;\r\n\t\r\n\t@_ = m/ \\K(\\d+)/g;\r\n\t\r\n\tmy $min = ( sort { $a <=> $b } @_ )[ 0 ];\r\n\t\r\n\tprint m/\r\n\t\t\\b(\\d+)[ ](\\d+)\\b\r\n\t\t.*\r\n\t\t\\b(\\d+)[ ](\\d+)\\b\r\n\t\t(??{ ( $2 > $min && $2 == $4 ) ? \"\" : \"(*FAIL)\" })\r\n\t\t/sx ?\r\n\t\tabs( $1 - $3 ) : 0;\r\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nmy $s = sub { shift =~ s/.* //r };\r\n\r\nwhile(<>){\r\n\t@_ = sort { $s->( $a ) <=> $s->( $b ) } $_, ~~<>, ~~<>;\r\n\t\r\n\tprint $s->( $_[ 1 ] ) == $s->( $_[ 2 ] ) ?\r\n\t\tabs( $_[ 1 ] - $_[ 2 ] ) : 0;\r\n\t}"}, {"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t@_ = sort { $a->[ 1 ] <=> $b->[ 1 ] } map [ split ], $_, ~~<>, ~~<>;\r\n\t\r\n\tprint $_[ 1 ][ 1 ] == $_[ 2 ][ 1 ] ?\r\n\t\tabs( $_[ 1 ][ 0 ] - $_[ 2 ][ 0 ] ) : 0;\r\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ .= <> . <>;\r\n\t\r\n\tprint m/\r\n\t\t\\b(\\d+)[ ](\\d+)\\b\r\n\t\t.*\r\n\t\t\\b(\\d+)[ ](\\d+)\\b\r\n\t\t(??{ $2 && $2 == $4 ? \"\" : \"(*FAIL)\" })\r\n\t\t/sx ?\r\n\t\tabs( $1 - $3 ) : 0;\r\n\t}"}], "src_uid": "9f019c3898f27d687c5b3498586644e8"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tprint /(.)(?!\\1)(.)/ ? \"YES\\n$1$2\" : \"NO\";\n\t}", "positive_code": [{"source_code": "<>;\n\nprint <> =~ /(.)(?!\\1)(.)/ ? \"YES\\n$1$2\" : \"NO\";"}], "negative_code": [], "src_uid": "ce4443581d4ee12db6607695cd567070"}
{"source_code": "\n\n($n, $k) = split ' ', <>;\n@a = split ' ', <>;\n\n$ans = 1;\n$sum = 0;\nfor($i = 0; $i < $k; $i++)\n{\n    $sum += $a[$i];\n}\n$min_sum = $sum;\nfor($i = 1; $i < $n - $k  + 1; $i++)\n{\n    $sum -= $a[$i - 1];\n    $sum += $a[$i + $k - 1];\n    if($min_sum > $sum)\n    {\n        $ans = $i + 1;\n        $min_sum = $sum;\n    }\n}\nprint $ans;\n", "positive_code": [{"source_code": "my $input = <STDIN>;\nchomp ($input);\n\nmy @data = split (\" \", $input);\nmy $n = shift (@data);\nmy $k = shift (@data);\n\nmy $input = <STDIN>;\nchomp ($input);\nmy @data = split (\" \", $input);\n\nmy $i = 1;\nmy @h;\nwhile ($i != $n + 1) {\n    $h[$i] = shift (@data);\n    $i++;\n}\n\nif ($n == $k) {\n    print \"1\";\n    exit;\n}\n\nmy @s;\nmy $j = 0;\nmy $z = 0;\n\nwhile ($j != ($n - $k + 1)) {\n    if ($j == 0) {\n        while ($z != $k) { \n            $s[$j+1] = $s[$j+1] + $h[$z+$j+1];\n            $z++;\n        }\n    }else{\n        $s[$j+1] = $s[$j] - $h[$j] + $h[$j+$k];  \n    }\n    $j++;\n}\n\nmy $j = 1;\nmy $index = 1;\nmy $p = $s[1];\nwhile ($j != ($n - $k + 1)) {\n    if (($p < $s[$j+1]) || ($p == $s[$j+1])) {\n    }else{\n        $p = $s[$j+1];\n        $index = $j + 1; \n    }\n    $j++;\n}\n\nprint $index;"}], "negative_code": [{"source_code": "##!/usr/bin/perl\n\n($n, $k) = split ' ', <>;\n@a = split ' ', <>;\n\n$ans = 0;\n$sum = 0;\nfor($i = 0; $i < $k; $i++)\n{\n\t$sum += $a[i];\n}\n$min_sum = $sum;\nfor($i = 1; $i < $n - 1; $i++)\n{\n\t$sum -= $a[$i - 1];\n\t$sum += $a[$i + 1];\n\tif($min_sum > $sum)\n\t{\n\t\t$ans = $i;\n\t\t$min_sum = $sum;\n\t}\n}\nprint $ans;\n\n"}, {"source_code": "##!/usr/bin/perl\n\n($n, $k) = split ' ', <>;\n@a = split ' ', <>;\n\n$ans = 1;\n$sum = 0;\nfor($i = 0; $i < $k; $i++)\n{\n\t$sum += $a[i];\n}\n$min_sum = $sum;\nfor($i = 1; $i < $n - 1; $i++)\n{\n\t$sum -= $a[$i - 1];\n\t$sum += $a[$i + 1];\n\tif($min_sum > $sum)\n\t{\n\t\t$ans = $i + 1;\n\t\t$min_sum = $sum;\n\t}\n}\nprint $ans;\n\n"}, {"source_code": "##!/usr/bin/perl\n\n($n, $k) = split ' ', <>;\n@a = split ' ', <>;\n\n$ans = 1;\n$sum = 0;\nfor($i = 0; $i < $k; $i++)\n{\n    $sum += $a[i];\n}\n$min_sum = $sum;\nfor($i = 1; $i < $n - 2; $i++)\n{\n    $sum -= $a[$i - 1];\n    $sum += $a[$i + 2];\n    if($min_sum > $sum)\n    {\n        $ans = $i + 1;\n        $min_sum = $sum;\n    }\n}\nprint $ans;\n"}, {"source_code": "##!/usr/bin/perl\n\n($n, $k) = split ' ', <>;\n@a = split ' ', <>;\n\n$ans = 1;\n$sum = 0;\nfor($i = 0; $i < $k; $i++)\n{\n    $sum += $a[$i];\n    #print \"a[$i] = $a[$i]\\n\";\n}\n#print (\"$sum\\n\");\n$min_sum = $sum;\nfor($i = 1; $i < $n - 2; $i++)\n{\n    $sum -= $a[$i - 1];\n    $sum += $a[$i + $k - 1];\n    #print (\"$sum\\n\");\n    if($min_sum > $sum)\n    {\n        $ans = $i + 1;\n        $min_sum = $sum;\n    }\n}\nprint $ans;"}, {"source_code": "my $input = <STDIN>;\nchomp ($input);\nmy @data = split (\" \", $input);\nmy $n = shift (@data);\nmy $k = shift (@data);\n\nmy $input = <STDIN>;\nchomp ($input);\nmy @data = split (\" \", $input);\n\nmy $i = 1;\nmy @h;\nwhile ($i != $n + 1) {\n    $h[$i] = shift (@data);\n    $i++;\n}\n\nif ($n == $k) {\n    print $h[1];\n    exit;\n}\n\nmy @s;\nmy $j = 1;\nwhile ($j != $n - 1) {\n    $s[$j] = $h[$j] + $h[$j+1] + $h[$j+2];\n    $j++;\n}\n\nmy $j = 1;\nmy $p = $s[$j];\nmy $index = 0;\nwhile ($j != $n - 2) {\n    if (($p < $s[$j+1]) || ($p == $s[$j+1])) {\n        $x = 0;\n    }else{\n        $p = $s[$j+1];\n        $index = $j + 1;    \n    }\n    $j++;\n}\n\nprint $index;\n"}], "src_uid": "69f4e340b3f6e1d807e0545ebea1fe2f"}
{"source_code": "<>;\n\nprint +( grep { /-/ || ( sqrt ) =~ /\\./ } sort { $b <=> $a } split ' ', <> )[ 0 ]", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tprint +( grep { /-/ || ( sqrt ) =~ /\\./ } sort { $b <=> $a } split ' ', <> )[ 0 ]\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tprint +( grep { ( sqrt ) =~ /\\./ } grep !/-/, sort { $b <=> $a } split ' ', <> )[ 0 ]\n\t}"}], "src_uid": "d46d5f130d8c443f28b52096c384fef3"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 1;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\tmy $s = <>;\n\tmy $t = <>;\n\tchomp $s;\n\tchomp $t;\n\t\n\tmy @C;\n\t\n\twhile( $t =~ /(?=(.{$n}))/g ){\n\t\tmy $T = $1;\n\t\tmy $S = $s;\n\t\tmy @c;\n\t\tfor( my $i = 0; $i < $n; $i ++ ){\n\t\t\t$T =~ s/.//;\n\t\t\tmy $cT = $&;\n\t\t\t$S =~ s/.//;\n\t\t\tmy $cS = $&;\n\t\t\t$cS eq $cT or push @c, $i + 1;\n\t\t}\n\t\tpush @C, @c . \"\\n\" . join ' ', @c;\n\t\t}\n\t\n\tmy $min = ( sort { $a <=> $b } @C )[ 0 ];\n\tprint $min;\n\t\t\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 1;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\tmy $s = <>;\n\tmy $t = <>;\n\tchomp $s;\n\tchomp $t;\n\t\n\tmy @C;\n\t\n\twhile( $t =~ /(?=(.{$n}))/g ){\n\t\tmy $T = $1;\n\t\tmy $S = $s;\n\t\tmy @c;\n\t\tfor( my $i = 0; $i < $n; $i ++ ){\n\t\t\t$T =~ s/.//;\n\t\t\tmy $cT = $&;\n\t\t\t$S =~ s/.//;\n\t\t\tmy $cS = $&;\n\t\t\t$cS eq $cT or push @c, $i + 1;\n\t\t}\n\t\tpush @C, @c . \"\\n\" . join ' ', @c;\n\t\t}\n\t\n\tmy $min = ( sort { $a <=> $b } @C )[ 0 ];\n\tprint $min;\n\t\t\n\t}"}], "negative_code": [], "src_uid": "dd26f45869b73137e5e5cc6820cdc2e4"}
{"source_code": "($a,$b)=<>;\nfor $i('a'..'z'){\n\t$c=()=$a=~/$i/g;\n\t$d=()=$b=~/$i/g;\n\t$f=1 if !$c && $d;\n\t$A += $c < $d ? $c : $d \n}\nprint $A*(1-$f)? $A : -1", "positive_code": [{"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $count = 0;\nmy $line1 = <>;\nchomp($line1);\nmy $line2 = <>;\nchomp($line2);\nmy @n = split(\"\",$line1);\nmy @m = split(\"\",$line2);\nmy %nhash;\nmy %mhash;\nmy $pass = 1;\n\n#make both hashes, key is character in @n,@m\nforeach (@n)\n{\n  $nhash{$_}++;\n}\nforeach (@m)\n{\n  $mhash{$_}++;\n}\n\nforeach my $key (keys %mhash)\n{\n    if(!$nhash{$key})\n    {\n        $pass = 0;\n        last;\n    }\n    if($nhash{$key} > $mhash{$key})\n    {\n      $count += $mhash{$key}\n    }\n    else\n    {\n      $count += $nhash{$key}\n    }\n}\n\nif ($pass)\n{\n  say $count;\n}\nelse\n{\n  say \"-1\";\n}\n"}, {"source_code": "#!perl\n\nchomp ($string1 =<>);\nchomp ($string2 =<>);\n\n@array1 = split('',$string1);\n@array2 = split('',$string2);\n\n%hash1;\n%hash2;\nfor $char (@array1)\n{\n($hash1{$char})++;\n}\n\nfor $char (@array2)\n{\n($hash2{$char})++;\n}\n\n$sum;\nfor (keys(%hash2))\n{\n    if($hash1{$_} == 0) {$fail = 1;}\n    $sum += min($hash1{$_},$hash2{$_});\n}\n\nif (($sum == 0)or $fail)\n{\n print (-1);\n}\nelse\n{\nprint $sum;\n}\n<>;\nsub min ($$)\n{\n    if($_[0] < $_[1])\n    {\n    return $_[0];\n    }\n    else\n    {\n    return $_ [1];\n    }\n}"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t$a=$_;\n\t$b=<>;\n\tchomp $a;\n\tchomp $b;\n\t#a..z\n\t#count a string 1\n\t#count a string 2\n\t#cnt1 <=> cnt 2\n\t\n\t$ans=0;\n\t$f=0;\n\tfor $i('a'..'z'){\n\t\t\n\t\t$cnt1 = count($i,(split//,$a));\n\t\t$cnt2 = count($i,(split//,$b));\n\t\tif (!$cnt1 and $cnt2){$f++}\n\t\t\n\t\tif ($cnt1 < $cnt2){ $ans += $cnt1}\n\t\telse { $ans += $cnt2 }\n\t\t\n\t}\n\tif ($f){print -1;next}\n\tprint $ans? $ans : -1 ;\n\tn();\n\t\n\t}\n\t\n"}], "negative_code": [{"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t$a=$_;\n\t$b=<>;\n\t#a..z\n\t#count a string 1\n\t#count a string 2\n\t#cnt1 <=> cnt 2\n\t\n\t$ans=0;\n\tfor $i('a'..'z'){\n\t\t\n\t\t$cnt1 = count($i,(split//,$a));\n\t\t$cnt2 = count($i,(split//,$b));\n\t\t\n\t\tif ($cnt1 < $cnt2){ $ans += $cnt1}\n\t\telse { $ans += $cnt2 }\n\t\t\n\t}\n\t\n\tprint $ans? $ans : -1 ;\n\tn();\n\t\n\t}\n\t\n"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t$a=$_;\n\t$b=<>;\n\tchomp $a;\n\tchomp $b;\n\t#a..z\n\t#count a string 1\n\t#count a string 2\n\t#cnt1 <=> cnt 2\n\t\n\t$ans=0;\n\tfor $i('a'..'z'){\n\t\t\n\t\t$cnt1 = count($i,(split//,$a));\n\t\t$cnt2 = count($i,(split//,$b));\n\t\t\n\t\tif ($cnt1 < $cnt2){ $ans += $cnt1}\n\t\telse { $ans += $cnt2 }\n\t\t\n\t}\n\t\n\tprint $ans? $ans : -1 ;\n\tn();\n\t\n\t}\n\t\n"}, {"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $count = 0;\nmy $line1 = <>;\nchomp($line1);\nmy $line2 = <>;\nchomp($line2);\nmy @n = split(\"\",$line1);\nmy @m = split(\"\",$line2);\nmy %nhash;\nmy %mhash;\n\n#make both hashes, key is character in @n,@m\nforeach (@n)\n{\n  $nhash{$_}++;\n}\nforeach (@m)\n{\n  $mhash{$_}++;\n}\n\nforeach my $key (keys %mhash)\n{\n    if(!$nhash{$key})\n    {\n        say \"-1\";\n        last;\n    }\n    if($nhash{$key} > $mhash{$key})\n    {\n      $count += $mhash{$key}\n    }\n    else\n    {\n      $count += $nhash{$key}\n    }\n}\n\nif ($count)\n{\n  say $count;\n}\n"}, {"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $count = 0;\nmy $line1 = <>;\nchomp($line1);\nmy $line2 = <>;\nchomp($line2);\nmy @n = split(\"\",$line1);\nmy @m = split(\"\",$line2);\nmy %nhash;\nmy %mhash;\n\n#make both hashes, key is character in @n,@m\nforeach (@n)\n{\n  $nhash{$_}++;\n}\nforeach (@m)\n{\n  $mhash{$_}++;\n}\n\nforeach my $key (keys %mhash)\n{\n    if(!$nhash{$key})\n    {\n        say \"-1\";\n        last;\n    }\n    if($nhash{$key} > $mhash{$key})\n    {\n      $count += $mhash{$key}\n    }\n    else\n    {\n      $count += $nhash{$key}\n    }\n}\n\nif ($count != 0)\n{\n  say $count;\n}\n"}, {"source_code": "#!perl\n\nchomp ($string1 =<>);\nchomp ($string2 =<>);\n\n@array1 = split('',$string1);\n@array2 = split('',$string2);\n\n%hash1;\n%hash2;\nfor $char (@array1)\n{\n($hash1{$char})++;\n}\n\nfor $char (@array2)\n{\n($hash2{$char})++;\n}\n\n$sum;\nfor (keys(%hash2))\n{\n    \n    $sum += min($hash1{$_},$hash2{$_});\n}\n\nif ($sum == 0)\n{\n print (-1);\n}\nelse\n{\nprint $sum;\n}\n<>;\nsub min ($$)\n{\n    if($_[0] < $_[1])\n    {\n    return $_[0];\n    }\n    else\n    {\n    return $_ [1];\n    }\n}"}, {"source_code": "for $i('a'..'z'){\n\t$c=()=<>=~/$i/g;\n\t$d=()=<>=~/$i/g;\n\t$f=1 if !$c && $d;\n\t$A += $c < $d ? $c : $d \n}\nprint $A*(1-$f)? $A : -1"}], "src_uid": "b1e09df7c47dbd04992e64826337c28a"}
{"source_code": "use v5.10;\n\nchomp($n = <>);\n$n&1 and say -1 and exit;\nfor ($i=1,$j=2; $i<=$n; $i+=2,$j+=2) {\n\tprint \"$j $i \";\n}\nsay;", "positive_code": [{"source_code": "use strict;\n\nchomp (my $n = <>);\n\n((print \"-1\\n\") and exit) if ($n % 2);\n\nfor (my $i=1; $i<=$n; $i+=2){\n\tprint $i+1 . \" \" . $i . \" \"; \n}\nprint \"\\n\";"}], "negative_code": [], "src_uid": "204ba74195a384c59fb1357bdd71e16c"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\nuse integer;   ### important!\r\n\r\nmy ($testcase) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $testcase -- > 0 ){\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  $A[2] = $A[6] - $A[0] - $A[1];\r\n  print ( join(' ',@A[0..2]) . \"\\n\" );\r\n}\r\n\r\nexit(0);\r\n\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split;\n\t\n\tif( $_[ 0 ] + $_[ 1 ] == $_[ 2 ] ){\n\t\t$_[ 2 ] = $_[ 3 ];\n\t\t}\n\t\n\tprint \"@_[ 0 .. 2 ]\";\n\t}"}], "negative_code": [], "src_uid": "e0ec0cd81d2ec632ef89d207d80fa8a3"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, m/./g;\n\t\n\tprint 0 + ( length ) + keys %h;\n\t}", "positive_code": [{"source_code": "for(1..<>){$n=<>;$_=<>;$_=~s/(.)(?=.*?\\1)//g;print$n-1+length,\" \"}"}, {"source_code": "for(1..<>){$n=<>;$_=<>;$_=~s/(.)(?=.*?\\1)//g;print$n-1+length,\" \"}"}], "negative_code": [], "src_uid": "66777b8719b1756bf4b6bf93feb2e439"}
{"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n", "positive_code": [{"source_code": "chomp($n=<>);\nchomp($_=<>);\nmy @a = split / /;\n$ans = 0;\n$swap = 0;\nfor $i (0..$n) {\n\tif ($a[$i] == $i) {\n\t\t$ans++;\n\t} elsif ($swap == 0) {\n\t\t$swap = 1 if $a[$a[$i]]==$i;\n\t}\n}\n$ans+=2 if $swap;\n$ans++ if $ans<$n && $swap==0;\nprint \"$ans\\n\";\n\t"}, {"source_code": "#!/usr/bin/perl\nuse 5.010;\n\nsub Solve {\n    my $ret = 0;\n    my $inc = 1;\n    while (($idx, $val) = each(@_)) {\n        $idx == $val && $ret++;\n        $idx != $val && $_[$val] == $idx && ($inc = 2);\n    }\n    return $ret == @_? $ret : $ret + $inc;\n}\n\nwhile (<>) {\n    @line = split /\\s+/, <>;\n    say Solve(@line);\n}\n"}, {"source_code": "<>;\n@a=split/ /,<>;\nfor(@a){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e;"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}, {"source_code": "<>;\n@_=split/ /,<>;\nfor (0..@_-1){\n\tif ($_==$_[$_]){$n++}\n\telsif ($_==$_[$_[$_]]){$k++}\n\t}\n$k and $k=1;\n$n==@_ and $k--;\nprint ($n+(++$k));"}, {"source_code": "my $num = <>;\nchomp $num;\nmy @perm = split ' ', <>;\nmy %perm = map { $_, $perm[$_] } 0..$num-1;\n$count = 0;\nmy $ext = 0;\nfor (0..$num-1) {\n    if ($perm{$_} == $_) {\n        $count++;\n    } elsif (!$ext && $perm{$perm{$_}} == $_) {\n        $ext = 2;\n    }\n}\n$ext = 1 unless $ext == 2 || $count == $num;\n$count += $ext;\nprint $count;"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}, {"source_code": "<>;\nfor(@a=split/ /,<>){\n if($a[$_]==$_){$f++}\n elsif($a[$a[$_]]==$_){$e=2}\n elsif(!$e){$e=1}\n}\nprint $f+$e\n"}], "negative_code": [{"source_code": "chomp($n=<>);\nchomp($_=<>);\nmy @a = split / /;\n$ans = 0;\n$swap = 0;\nfor (0..$n) {\n\tif ($a[$_] == $_) {\n\t\t$ans++;\n\t} elsif ($swap==0) {\n\t\tif ($_+$_ != $n-1) {\n\t\t\tif ($a[$_]==$n-1-$_ && $a[$n-1-$_]==$_) {\n\t\t\t\t$swap = 1;\n\t\t\t}\t\n\t\t}\n\t}\n}\n$ans += 2 if $swap;\n$ans++ if $ans<$n && $swap==0;\nprint \"$ans\\n\";\n\t"}, {"source_code": "chomp($n=<>);\nchomp($i=<>);\nmy @a = split / /;\n$ans = 0;\n$swap = 0;\nfor $i (0..$n) {\n\tif ($a[$i] == $i) {\n\t\t$ans++;\n\t} elsif ($swap==0) {\n\t\tfor $j ($i+1..$n) {\n\t\t\tif ($a[$i]==$j && $a[$j]==$i) {\n\t\t\t\t$swap = 1;\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t}\n}\n$ans += 2 if $swap;\n$ans++ if $ans<$n && $swap==0;\nprint \"$ans\\n\";\n\t"}, {"source_code": "<>;\n@_=split/ /,<>;\nfor (0..@_-1){\n\tif ($_==$_[$_]){$n++}\n\telsif ($_==$_[$_[$_]]){$k++}\n\t}\n@_ > 3 and $n++;\n$k and $k=1;\nprint $n+$k;"}, {"source_code": "<>;\n@_=split/ /,<>;\nfor (0..@_-1){\n\tif ($_==$_[$_]){$n++}\n\telsif ($_==$_[$_[$_]]){$k++}\n\t}\n$k and $k=2;\nprint $n+$k;"}, {"source_code": "<>;\n@_=split/ /,<>;\nfor (0..@_-1){\n\tif ($_==$_[$_]){$n++}\n\telsif ($_==$_[$_[$_]]){$k++}\n\t}\n$k and $k=1;\nprint $n+++$k;"}, {"source_code": "<>;\n@_=split/ /,<>;\nfor (0..@_-1){\n\tif ($_==$_[$_]){$n++}\n\telsif ($_==$_[$_[$_]]){$k++}\n\t}\n$k and $k=1;\n$n==@_ and $k--;\nprint ($n+++$k);"}], "src_uid": "e63de0fffd00b2da103545a7f1e405be"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\nuse integer;   ### important!\r\nmy $mod = 10 ** 9 + 7;\r\n# my $mod = 998244353;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @a = split(//,( '' . $n ));\r\n  my $mx = 1;\r\n  for(my $i=0;$i<=$#a;$i++){\r\n    $mx = $a[$i] - 0 if $a[$i] - 0 > $mx;\r\n  }\r\n  print \"$mx\\n\";\r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "<>;\r\nchomp, print +(sort split'')[-1] . $/ for <>"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\nuse integer;   ### important!\r\nmy $mod = 10 ** 9 + 7;\r\n# my $mod = 998244353;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  \r\n  my $cnt = 0;\r\n  while( $n > 0 ){\r\n    my $ns = '' . $n;\r\n    my $ov = undef;\r\n    my $top = substr($ns,0,1) - 0;\r\n    my $ms = $top;\r\n    for(my $i=1;$i<length($ns);$i++){\r\n      if( $ov ){\r\n        $ms .= $top;\r\n      } else {\r\n        my $j = substr($ns,$i,1) - 0;\r\n        if( $j == $top ){\r\n          $ms .= $top;\r\n        } else {\r\n          $ms .= ( $j > $top ? $top : '0' );\r\n          $ov = 1;\r\n        }\r\n      }\r\n    }\r\n    $n -= ( $ms - 0 );\r\n    $cnt += $top;\r\n  }\r\n  print \"$cnt\\n\";\r\n  \r\n}\r\n\r\nexit(0);\r\n"}], "src_uid": "1a6881aeb197b8ed429f46850eb27b9c"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $w, $h ) = split;\n\t\n\tmy $max_h = 0;\n\tmy $diff;\n\t\n\t@_ = split ' ', <>;\n\tshift @_;\n\t@_ = sort { $b <=> $a } @_;\n\t$diff = $_[ 0 ] - $_[ @_ - 1 ];\n\t$max_h < $diff and $max_h = $diff;\n\t\n\t@_ = split ' ', <>;\n\tshift @_;\n\t@_ = sort { $b <=> $a } @_;\n\t$diff = $_[ 0 ] - $_[ @_ - 1 ];\n\t$max_h < $diff and $max_h = $diff;\n\t\n\t$max_h *= $h;\n\t\n\tmy $max_v = 0;\n\t\n\t@_ = split ' ', <>;\n\tshift @_;\n\t@_ = sort { $b <=> $a } @_;\n\t$diff = $_[ 0 ] - $_[ @_ - 1 ];\n\t$max_v < $diff and $max_v = $diff;\n\t\n\t@_ = split ' ', <>;\n\tshift @_;\n\t@_ = sort { $b <=> $a } @_;\n\t$diff = $_[ 0 ] - $_[ @_ - 1 ];\n\t$max_v < $diff and $max_v = $diff;\n\t\n\t$max_v *= $w;\n\t\n\tprint $max_v > $max_h ? $max_v : $max_h;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tprint +( sort { $b <=> $a } map { &M * $_, &M * $_ } reverse split )[ 0 ];\r\n\t}\r\n\r\nsub M {\r\n\t<> =~ / (\\d+).* (\\d+)/;\r\n\t$2 - $1;\r\n\t}"}, {"source_code": "use bigint;\r\nuse List::Util qw(max min);\r\n\r\nfor ($i = <>; $i > 0; $i--) {\r\n    @wh = split(/\\s/, <>);\r\n    @h1a = split(/ /, <>);\r\n    @h2a = split(/ /, <>);\r\n    @w1a = split(/ /, <>);\r\n    @w2a = split(/ /, <>);\r\n\r\n    $h1 = $h1a[$h1a[0]] - $h1a[1];\r\n    $h2 = $h2a[$h2a[0]] - $h2a[1];\r\n    $maxh = max($h1, $h2);\r\n\r\n    $w1 = $w1a[$w1a[0]] - $w1a[1];\r\n    $w2 = $w2a[$w2a[0]] - $w2a[1];\r\n    $maxw = max($w1, $w2);\r\n\r\n    print max($maxw * $wh[0], $maxh * $wh[1]) . \"\\n\";\r\n}\r\n\r\n"}], "negative_code": [], "src_uid": "2c67ee95eba7ffbbed99cb488abb5f3d"}
{"source_code": "my ($n, $m) = split / /, <>;\nmy @arr = split / /, <>;\nmy $ans = $arr[0];\nfor (my $i = 1; $i < scalar @arr; $i++) {\n    if ($arr[$i] >= $arr[$i - 1]) {\n        $ans += $arr[$i] - $arr[$i - 1];\n    }\n    else {\n        $ans += $n - $arr[$i - 1] + $arr[$i];\n    }\n    # print $ans . \"\\n\";\n}\nprint $ans - 1 . \"\\n\";", "positive_code": [{"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "my ($n, $m) = split \" \", <>;\nmy @d = split \" \", <>;\nmy $t = 0;\nmy $cur = 1;\nfor (@d) {\n    $t += $_ - $cur + $n * ($_ < $cur);\n    $cur = $_;\n}\nprint $t;"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\n($m, $n) = split / /, <>;\n@a = split / /, <>;\n$i = 0;\nwhile ($i < $n) {\n\t++$i;\n\twhile ($i<$n && $a[$i]>=$a[$i-1]) {\n\t\t++$i;\n\t}\n\t$i>=$n and $ans+=$a[$i-1] or $ans+=$m;\n}\nsay $ans-1;\n"}, {"source_code": "use strict;\nuse warnings;\n\n$\\ = \"\\n\";\n\nsub dist {\n    my ($x, $y, $n) = @_;\n    ($y - $x + $n) % $n;\n}\n\nmy ($n, $m) = split ' ', <>;\nmy @tasks = split ' ', <>;\nmy $pos = 1;\nmy $time = 0;\n\nfor my $task (@tasks) {\n    $time += dist($pos, $task, $n);\n    $pos = $task;\n}\n\nprint $time;\n"}, {"source_code": "($n, $m) = split ' ', <>;\n@arr = split ' ', <>;\n$total = 0;\n$last = 1;\nfor (@arr) {\n    if ($_ >= $last) {\n        $total += $_ - $last;\n        $last = $_;\n    } else {\n        $total += $n - ($last - $_);\n        $last = $_;\n    }\n}\nprint $total;\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "#!/usr/bin/perl -w\nuse 5.010;\n\nwhile (<>) {\n    $n = (split /\\s+/)[0];\n    @tasks = split /\\s+/, \"1 \" . <>;\n    $loop = 0;\n    for (my $i = 1; $i < @tasks; $i++) {\n        if ($tasks[$i] < $tasks[$i - 1]) {\n            $loop++;\n        }\n    }\n    $ans = $tasks[-1] - $tasks[0] + $loop * $n;\n    say $ans;\n}\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nuse constant POS_START=>1;  # 開始位置\n\nmain();\n\n\n## main()\n# メイン処理\nsub main {\n    # 標準入力の取得\n    my $line1 = <>;\n    my $line2 = <>;\n    chomp($line1);\n    chomp($line2);\n\n    # 標準入力の解析\n    my ($n, $m) = split(/ /, $line1);\n    my (@a) = split(/ /, $line2);\n    if ($m != $#a+1) {\n        print \"illeagal arguments\\n\";\n        exit -1;\n    }\n\n    my $pos = POS_START;\n    my $cnt_round = 0;\n    foreach(@a) {\n        if ($_ > $n || $_ < 1) {\n            print \"illeagal arguments\\n\";\n            exit -1;\n        }\n        if ($pos > $_) { $cnt_round++; }\n        $pos = $_;\n    }\n    \n    my $time_total = $cnt_round * $n + $pos - POS_START;\n    print \"$time_total\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=split/ /,<>;\nunshift @_,1;\nfor $i(1..@_-1){\n    $_[$i]>=$_[$i-1] ? ($sum+=$_[$i]-$_[$i-1]) : ($sum+= $`+$_[$i]-$_[$i-1]);\n    }\nprint $sum;\n\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "$_=<>;($n,$m,$c,$r)=(split,1,0);$_=<>;for(split){$r+=($_+$n-$c)%$n;$c=$_}print$r\n\n"}], "negative_code": [], "src_uid": "2c9c96dc5b6f8d1f0ddeea8e07640d3e"}
{"source_code": "$_ = <>, chomp;\n\n$c eq 'b' ? $B ++ : map $_ %= 1e9 + 7, $ans += $B, $B <<= 1 while $c = chop;\n\t\nprint $ans", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $MOD = 1e9 + 7;\n\nwhile(<>){\n\tchomp;\n\tmy $c;\n\tmy $ans = 0;\n\tmy $B = 0;\n\t\n\twhile( $c = chop ){\n\t\t\n\t\tif( $c eq 'b' ){\n\t\t\t$B ++;\n\t\t\t}\n\t\telse{\n\t\t\tmap { $_ %= $MOD } $ans += $B, $B <<= 1;\n\t\t\t}\n\t\t}\n\t\t\n\tprint $ans;\n\t}"}], "negative_code": [{"source_code": "$_ = <>;\nchomp;\ns/a+$// while /a$/;\n$a = () = /a/g;\nprint $a * ($a + 1) / 2 % (1e9 + 7);"}], "src_uid": "8f52241c690ec4f9af71a52904fb19a0"}
{"source_code": "$_ = <STDIN>;\nchomp;\n\nif ( $_=~m/[BCDEFGJKLNPQRSZ]/ ){\n    print \"NO\";\n}else{\n    if ( $_ eq (reverse $_)){\n        print \"YES\";\n    }else{\n        print \"NO\";\n    }\n}", "positive_code": [{"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES"}, {"source_code": "use strict;\nuse POSIX;\n\nchomp (my $s = <>);\nmy @s = split '', $s;\nprint \"NO\" and exit if $s=~ m/[BCDEFGJKLNPQRSZ]/;\nmy $f=0;\na:for(0..$#s/2)\n{\nif ($s[$_] ne $s[$#s - $_])\n{\n$f = 2;\nlast a; \n\n};\n}\n$f? print \"NO\":print \"YES\";\n"}, {"source_code": "$st=<>;\nchomp($st);\n$rv=reverse $st;\n($rv ne $st || $st=~/[^AHIOMT-Y]/ )? print \"NO\":print \"YES\";"}, {"source_code": "use integer;\n\nwhile(<>){\n\t\n\tchomp;\n\t$f=0;\n\t\n\t# A H I O U V W T Y X M\n\t# <>\n\t\n\t$le = length;\n\t@_=qw(A H I O U V W T Y X M);\n#\tprint \"@_\\n\";\n\t\n\t/[^AHIOUVWTYXM]/ and $f=1;\n\t\n\t\n\t@a=split//;\n#\tprint 0+@a,\"\\n\";\n\t\n\tif (!$f)\n\t{\n\t\tfor $i(0..(@a/2)){\n\t\t\t\n\t\t\t$a[$i] eq $a[@a-$i-1] or $f=2;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t}\n#\tprint \"$f\\n\";\n\tprint $f? \"NO\\n\":\"YES\\n\";\n\t\n\t}\n\t\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "$_=<>; chomp;\n$r=reverse$_;\nprint /[^AHIOMT-Y]/ || $r ne $_? NO:YES\n"}, {"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $line1 = <>;\nchomp($line1);\n\nif ($line1 =~ m/[BCDEFGJKLNPQRSZ]/)\n{\n  say \"NO\";\n  exit;\n}\nelsif ($line1 eq reverse($line1))\n{\n  say \"YES\";\n  exit;\n}\nelse\n{\n  say \"NO\";\n  exit;\n}\n"}], "negative_code": [{"source_code": "\n$_ = <STDIN>;\nchomp;\n\nif ( $_=~m/[BCDEFGJKLMNPQRSZ]/ ){\n    print \"NO\";\n}else{\n    if ( $_ eq (reverse $_)){\n        print \"YES\";\n    }else{\n        print \"NO\";\n    }\n}"}, {"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $line1 = <>;\nchomp($line1);\n\nif ($line1 =~ m/[BCDEFGJKLNPQRSZ]/)\n{\n  say \"No\";\n  exit;\n}\nelsif ($line1 eq reverse($line1))\n{\n  say \"Yes\";\n  exit;\n}\nelse\n{\n  say \"No\";\n  exit;\n}\n"}, {"source_code": "use strict;\nuse POSIX;\n\nchomp (my $s = <>);\nmy @s = split '', $s;\nprint \"NO\" and exit if $s=~ m/[BCDEFGJKLNPQRS]/;\nmy $f=0;\na:for(0..$#s/2)\n{\nif ($s[$_] ne $s[$#s - $_])\n{\n$f = 2;\nlast a; \n\n};\n}\n$f? print \"NO\":print \"YES\";\n"}, {"source_code": "$st=<>;\nchomp($st);\n$rv=reverse $st;\n($rv eq $st)? print \"YES\":print \"NO\";"}, {"source_code": "$st=<>;\nchomp($st);\n$rv=reverse $st;\n($rt eq $st && length($rt)!=1)? print \"YES\":print \"NO\";"}, {"source_code": "$st=<>;\nchomp($st);\n$rv=reverse $st;\n($rv eq $st&& length($rv)!=1)? print \"YES\":print \"NO\";"}, {"source_code": "$st=<>;\nchomp($st);\n$rv=reverse $st;\n($rv eq $st && length($rv)!=1)? print \"YES\":print \"NO\";"}, {"source_code": "$st=<>;\nchomp($st);\n$rt=reverse $st;\n($rt eq $st && length($rt)!=1)? print \"YES\":print \"NO\";"}, {"source_code": "$st=<>;\nchomp($st);\n$rv=reverse $st;\n($rv ne $st || $st=~/[^AHITOMY]/ )? print \"NO\":print \"YES\";"}], "src_uid": "8135173b23c6b48df11b1d2609b08080"}
{"source_code": "use strict;\n<>;\nmy (@a) = split (' ',<>);\nmy $cop=0;\nmy $ans = 0;\nfor my $event (@a)\n{\n    if($event > 0)\n    {\n        $cop += $event; \n    }\n    else\n    {\n        $ans++ if $cop == 0;\n        $cop-- if $cop > 0;\n    }\n}\nprint $ans;", "positive_code": [{"source_code": "my $n = <>;\nchomp($n);\nmy $in = <>;\nchomp($in);\nmy @A = split ' ', $in;\nmy ($sum, $ans) = (0, 0);\nfor (my $i = 0; $i < $n; ++$i) {\n    $sum += $A[$i];\n    $ans = $sum if $ans > $sum;\n}\nprint abs $ans;\n"}, {"source_code": "my $a = <>;\nmy @b = split \" \", <>;\nmy $m = 0, my $c = 0;\nforeach (@b) {\n    if ($_ < 0) {\n        if ($m > 0) {\n            --$m;\n        } else {\n            ++$c;\n        }\n    } else {\n        $m += $_;\n    }\n}\nprint $c, \"\\n\";"}, {"source_code": "<>;\nmy $n = 0;\nmy $ans = 0;\nforeach(split / /, <>) {\n    $n += int $_;\n    if ($n < 0) {\n        $ans++;\n        $n = 0;\n    }\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "<>;\nmy $n = 0;\nmy $ans = 0;\nforeach(split / /, <>) {\n    $n += int$_ if (int $_ > 0);\n    if (int $_ < 0) {\n        $ans++ if ($n == 0);\n        $n--   if ($n > 0);\n    }\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\n($ans, $tot) = (0, 0);\nforeach (split / /, <>) {\n\t$tot += $_;\n\t$tot<0 and ++$ans and $tot=0;\n}\nsay $ans;"}, {"source_code": "<>;\nmy @events = split ' ', <>;\nmy $free = 0;\nmy $missed = 0;\n\nfor my $event (@events) {\n    $free += $event;\n    while ($free < 0) {\n        $missed++;\n        $free++;\n    }\n}\n\nprint $missed, \"\\n\";\n"}, {"source_code": "$n=<>; $res=0; $sum=0;\n@ar =split/ /,<>;\nchomp(@ar);\nforeach(@ar)\n{\n    if($_ == -1) {if($sum==0){$res--;}else {$sum--;} }\n    else{ $sum+=$_;}  \n}\n( $res < 0 ) ? ($res=$res*(-1)) : ( $res=0); \nprint $res;"}, {"source_code": "<>;$r = 0;$s = 0;\n@_ = split / /, <>;\nforeach (@_) {if ( $_ == -1 ){($s==0)?($r++):( $s--);} else { $s += $_; }}\nprint $r;"}, {"source_code": "<>; $r=0; $s=0;\n@_ =split/ /,<>;\nforeach(@_)\n{\n    if($_ == -1) { if($s==0){$r++;} else {$s--;} }\n    else{ $s+=$_;}  \n}\nprint $r;"}, {"source_code": "<>;\n$r = 0;\n$s = 0;\n@_ = split / /, <>;\n\nforeach (@_) {\n    if ( $_ == -1 ) { ( $s == 0 ) ? ( $r++ ) : ( $s-- ); }\n    else            { $s += $_; }\n}\nprint $r;"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@_=split/ /;\n$n=0;\nfor (@_){\n$sum+=$_;\nif ($sum<0){$sum=0; $n++}\n}\nprint $n;"}], "negative_code": [{"source_code": "$n=<>;\n@ar =split/ /,<>;\nchomp(@ar);\n$res=0; $sum=0;\nforeach(@ar)\n{\n    if($_ == -1) {$res=$res-1+$sum;}\n    else{ $sum+=$_;} \n    \n}\n( $res < 0 ) ? ($res=$res*(-1)) : ( $res=0); \nprint $res;"}, {"source_code": "$n=<>; $res=0; $sum=0;\n@ar =split/ /,<>;\nchomp(@ar);\nforeach(@ar)\n{\n    if($_ == -1) { $sum--;$res=$sum;}\n    else{ $sum+=$_;} \n    \n}\n( $res < 0 ) ? ($res=$res*(-1)) : ( $res=0); \nprint $res;"}, {"source_code": "$n=<>; $res=0; $sum=0;\n@ar =split/ /,<>;\nchomp(@ar);\nforeach(@ar)\n{\n    if($_ == -1) {$res=$res-1+$sum; $sum--;}\n    else{ $sum+=$_;} \n    \n}\n( $res < 0 ) ? ($res=$res*(-1)) : ( $res=0); \nprint $res;\n"}, {"source_code": "$n=<>;\n@ar =split/ /,<>;\nchomp(@ar);\nforeach(@ar)\n{\n    if($_ == -1) {$res=$sum-1;}\n    $sum+=$_; \n    \n}\n( $res < 0 ) ? $res=$res*(-1) :  $res=0; \nprint $res;"}, {"source_code": "$n=<>;\n@ar =split/ /,<>;\nchomp(@ar); $res=0; $sum=0;\nforeach(@ar)\n{\n    if($_ == -1) {$res=$sum-1;}\n    $sum+=$_; \n    \n}\n( $res < 0 ) ? ($res=$res*(-1)) : ( $res=0); \nprint $res;"}], "src_uid": "af47635f631381b4578ba599a4f8b317"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse bignum;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $k, $d, $t ) = split;\n\t\n\twhile( $k > $d ){\n\t\tif( $k % $d == 0 ){ $d = $k; last; }\n\t\tmy $i = int $k / $d;\n\t\t$d = ( $i + 1 ) * $d;\n\t\t}\n\t\n\t$debug and print \"[$k|$d]\";\n\t\n\tmy $c = $k + 0.5 * ( $d - $k );\n\t\n\tprint do {\n\t\t\t\n\t\tif( $k == $d ){\n\t\t\t$t;\n\t\t\t}\n\t\telse{\n\t\t\tmy $i = int $t / $c;\n\t\t\tmy $r = $t - $i * $c;\n\t\t\t\n\t\t\t$debug and print \" <$i|$r>\";\n\t\t\t\n\t\t\t$i * $d + \n\t\t\t\tdo {\n\t\t\t\t\tif( $r <= $k ){\n\t\t\t\t\t\t$r;\n\t\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t$k + 2 * ( $r - $k );\n\t\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\n\t}", "positive_code": [{"source_code": "use bignum;\n\n( $k, $d, $t ) = split ' ', <>;\n\n$k > $d and $d = $k % $d ? ( 1 + int $k / $d ) * $d : $k;\n\t\n$c = 0.5 * ( $d + $k );\n\n$i = int $t / $c;\n$r = $t - $i * $c;\n\nprint $i * $d + ( $r > $k ? $k + 2 * ( $r - $k ) : $r )"}], "negative_code": [{"source_code": "use bignum;\n\n( $k, $d, $t ) = split ' ', <>;\n\t\n$d += ( int $k / $d ) * ( $d - !( $k % $d ) );\n\n$c = 0.5 * ( $d + $k );\n\n$i = int $t / $c;\n$r = $t - $i * $c;\n\nprint $i * $d + ( $r > $k ? $k + 2 * ( $r - $k ) : $r )"}], "src_uid": "9df3a94dfa537cabdc52388a771cd24f"}
{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\ts/\\s//g;\r\n\t\r\n\t$i = 0;\r\n\t\r\n\t1 while m/./ and 0\r\n\t\t|| s/^0+//\r\n\t\t|| s/1$//\r\n\t\t|| ! ++ $i\r\n\t\t|| s/.// + chop\r\n\t\t;\r\n\t\r\n\tprint $i . $/\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $i = 0;\n\t\n\tOUTER:\n\twhile( @_ ){\n\t\twhile( $_[ 0 ] == 0 ){\n\t\t\tshift @_;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\twhile( $_[ @_ - 1 ] == 1 ){\n\t\t\tpop @_;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\t$i ++;\n\t\tshift @_;\n\t\tpop @_;\n\t\t}\n\t\n\tprint $i;\n\t}"}, {"source_code": "#!/usr/bin/perl\nuse Data::Dumper;\nuse integer;   ### important!\nmy $mod = 10 ** 9 + 7;\n# my $mod = 998244353;\n\nmy ($testcase) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nwhile( $testcase -- > 0 ){\n  \n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  \n  my $f1 = -1;\n  my $c0 = 0; my $c1 = 0; my $d0 = 0;\n  for(my $i=0;$i<$n;$i++){\n    $f1 = $i if $f1<0 and $A[$i]==1;\n    $c0++ if $A[$i]==0;\n    $c1++ if $A[$i]==1;\n    $d0++ if $A[$i]==0 and $f1>=0;\n  }\n  if( $c0 == 0 or $c1 == 0 ){\n    print \"0\\n\"; next;\n  }\n  my $res = 0;\n  my $l = 0; my $r = $n-1;\n  while(1){\n    $r-- while $r>=0 && $A[$r]==1;\n    $l++ while $l<$n && $A[$l]==0;\n    last if $r <= $l;\n    $res++;\n    $r--;\n    $l++;\n    last if $r <= $l;\n  }\n  print \"$res\\n\";\n}\n\nexit(0);\n\nsub max {\n  my $r = undef;\n  foreach my $e (@_){  $r = $e if !defined($r) or $e > $r;  }\n  return $r;\n}\nsub min {\n  my $r = undef;\n  foreach my $e (@_){  $r = $e if !defined($r) or $e < $r;  }\n  return $r;\n}\nsub sum {\n  my $r = 0;\n  foreach my $e (@_){ $r += $e; }\n  return $r;\n}\nsub ruisum {   # my @rui = (0); &ruisum(\\@rui,\\@array);\n  my $r = shift; my $ar = shift;\n  $#{$r} = 1+$#{$ar}; $r->[0] = 0; my $rr = 0;\n  for(my $i=0;$i<=$#ar;$i++){ \n    $rr += $ar->[$i];\n    $r->[1+$i] = $rr;\n  }\n}\n"}, {"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\ts/\\s//g;\r\n\t\r\n\tmy $i = 0;\r\n\t\r\n\t1 while m/./ and 0\r\n\t\t|| s/^0+//\r\n\t\t|| s/1$//\r\n\t\t|| ! ++ $i\r\n\t\t|| s/.// + chop\r\n\t\t;\r\n\t\r\n\tprint $i;\r\n\t}"}], "negative_code": [], "src_uid": "c247c7c382c243ab6b991c4a11bfc421"}
{"source_code": "( $n, $k, @_ ) = split ' ', <>.<>;\n\n$z += (int $_ / $k) + !!($_ % $k) for @_;\n\nprint int( $z / 2 ) + $z % 2", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += (int $_ / $k) + !!($_ % $k) for @_;\n\t\n\tprint int( $sum / 2 ) + $sum % 2;\n\t\n\t}"}], "negative_code": [], "src_uid": "3992602be20a386f0ec57c51e14b39c5"}
{"source_code": "<>;\n\n@_ = <>;\nchomp @_;\n\n$f = @_ > 27 ** 2 || grep /(.).*\\1/, @_;\n\nif( !$f ){\n\t\n\t@_ = sort @_;\n\t\t\t\n\t$_ = \"@_\";\n\t\n\t1 while 0 \n\t\t|| !$f *\n\t\t\ts/\n\t\t\t(\\b\\w+)\n\t\t\t(\\w*\\b)\n\t\t\t[ ]\n\t\t\t\\1\n\t\t\t(\\w*\\b)\n\t\t\t/\n\t\t\t$f += !!( $2 && $3 );\n\t\t\t$1 . ( $2 || $3 )\n\t\t\t/egx\n\t\t\t\n\t\t|| !$f * \n\t\t\ts/\n\t\t\t(\\b\\w*?)\n\t\t\t(\\w+)\n\t\t\t(\\w*\\b)\n\t\t\t(.*?)\n\t\t\t(\\b\\w*?)\n\t\t\t\\2\n\t\t\t(\\w*\\b)\n\t\t\t/\n\t\t\t$f += !!( $1 && $5 || $3 && $6 );\n\t\t\t( $1 || $5 ) . $2 . ( $3 || $6 ) . $4\n\t\t\t/ex\n\t}\n\t\nprint $f + /(\\w).*\\1/ ? \"NO\" : join '', sort split", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\tmy $f = 0;\n\t\n\tif( @_ > 27 ** 2 or ( grep 26 < (length), @_ ) or ( grep /(.).*\\1/, @_ ) ){\n\t\t$f ++;\n\t\t}\n\t\n\t$debug and print \"[@_]\";\n\t\n\tif( ! $f ){\n\t\t@_ = sort @_;\n\t\t\n\t\t$debug and print \"[@_]\";\n\t\tmy @unused;\n\t\t\n\t\twhile( @_ > 1 ){\n\t\t\tmy( $A, $B ) = ( shift @_, shift @_ );\n\t\t\t\n\t\t\t$A =~ /./; \n\t\t\tmy $fA = $&;\n\t\t\t$B =~ /./; \n\t\t\tmy $fB = $&;\n\t\t\t\n\t\t\tif( $fA eq $fB ){\n\t\t\t\tmy $left;\n\t\t\t\t\n\t\t\t\tif( $A =~ /$B/ ){\n\t\t\t\t\t$left = $A;\n\t\t\t\t\t}\n\t\t\t\telsif( $B =~ /$A/ ){\n\t\t\t\t\t$left = $B;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$f ++;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tunshift @_, $left;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\tpush @unused, $A;\n\t\t\t\tunshift @_, $B;\n\t\t\t\t}\n\t\t\t\n\t\t\t$f and last;\n\t\t\t}\n\t\t\n\t\tunshift @_, @unused;\n\t\t\n\t\t$_ = \"@_\";\n\t\t\n\t\t$debug and print;\n\t\t\n\t\t1 while 0\n\t\t\t|| !$f * \n\t\t\t\ts/\n\t\t\t\t(\\b\\w*?)\n\t\t\t\t(\\w+)\n\t\t\t\t(\\w*\\b)\n\t\t\t\t(.*?)\n\t\t\t\t(\\b\\w*?)\n\t\t\t\t\\2\n\t\t\t\t(\\w*\\b)\n\t\t\t\t/\n\t\t\t\t$debug and print \"[$1<$2>$3|$4|$5<$2>$6]\";\n\t\t\t\t$f += length( $1 ) * length( $5 ) + length( $3 ) * length( $6 );\n\t\t\t\t( $1 || $5 ) . $2 . ( $3 || $6 ) . $4\n\t\t\t\t/ex;\n\t\t\n\t\t$debug and print;\n\t\t}\n\t\n\t$debug and print;\n\t\n\t$f += /(\\w).*\\1/;\n\t\n\tprint $f ? \"NO\" : ( join '', sort split );\n\t\n\t$debug and print '-' x 20;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\tmy $f = 0;\n\t\n\tif( @_ > 27 ** 2 or ( grep 26 < (length), @_ ) or ( grep /(.).*\\1/, @_ ) ){\n\t\t$f ++;\n\t\t}\n\t\n\t$debug and print \"[@_]\";\n\t\n\tif( ! $f ){\n\t\t@_ = sort @_;\n\t\t\n\t\t$debug and print \"[@_]\";\n\t\tmy @unused;\n\t\t\n\t\twhile( @_ > 1 ){\n\t\t\tmy( $A, $B ) = ( shift @_, shift @_ );\n\t\t\t\n\t\t\t$A =~ /./; \n\t\t\tmy $fA = $&;\n\t\t\t$B =~ /./; \n\t\t\tmy $fB = $&;\n\t\t\t\n\t\t\tif( $fA eq $fB ){\n\t\t\t\tmy $left;\n\t\t\t\t\n\t\t\t\tif( $A =~ /$B/ ){\n\t\t\t\t\t$left = $A;\n\t\t\t\t\t}\n\t\t\t\telsif( $B =~ /$A/ ){\n\t\t\t\t\t$left = $B;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$f ++;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tunshift @_, $left;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\tpush @unused, $A;\n\t\t\t\tunshift @_, $B;\n\t\t\t\t}\n\t\t\t\n\t\t\t$f and last;\n\t\t\t}\n\t\t\n\t\tunshift @_, @unused;\n\t\t\n\t\t$_ = \"@_\";\n\t\t\n\t\t$debug and print;\n\t\t\n\t\t1 while 0\n\t\t\t|| !$f * \n\t\t\t\ts/\n\t\t\t\t(\\b\\w*?)\n\t\t\t\t(\\w+)\n\t\t\t\t(\\w*\\b)\n\t\t\t\t(.*?)\n\t\t\t\t(\\b\\w*?)\n\t\t\t\t\\2\n\t\t\t\t(\\w*\\b)\n\t\t\t\t/\n\t\t\t\t$debug and print \"[$1<$2>$3|$4|$5<$2>$6]\";\n\t\t\t\t$f += length( $1 ) * length( $5 ) + length( $3 ) * length( $6 );\n\t\t\t\t( $1 || $5 ) . $2 . ( $3 || $6 ) . $4\n\t\t\t\t/ex;\n\t\t\n\t\t$debug and print;\n\t\t}\n\t\n\t$debug and print;\n\t\n\tprint $f ? \"NO\" : ( join '', sort split );\n\t\n\t$debug and print '-' x 20;\n\t}"}, {"source_code": "<>;\n\n@_ = <>;\nchomp @_;\n\n$f = @_ > 27 ** 2 || grep /(.).*\\1/, @_;\n\nif( !$f ){\n\t\n\t@_ = sort @_;\n\t\t\t\n\t$_ = \"@_\";\n\t\n\t1 while 0 \n\t\t|| !$f *\n\t\t\ts/\n\t\t\t(\\b\\w+)\n\t\t\t(\\w*\\b)\n\t\t\t[ ]\n\t\t\t\\1\n\t\t\t(\\w*\\b)\n\t\t\t/\n\t\t\t$f .= $2 && $3;\n\t\t\t$1 . ( $2 || $3 )\n\t\t\t/egx\n\t\t\t\n\t\t|| !$f * \n\t\t\ts/\n\t\t\t(\\b\\w*?)\n\t\t\t(\\w+)\n\t\t\t(\\w*\\b)\n\t\t\t(.*?)\n\t\t\t(\\b\\w*?)\n\t\t\t\\2\n\t\t\t(\\w*\\b)\n\t\t\t/\n\t\t\t$f .= $1 && $5 || $3 && $6;\n\t\t\t( $1 || $5 ) . $2 . ( $3 || $6 ) . $4\n\t\t\t/ex\n\t}\n\t\nprint $f + /(\\w).*\\1/ ? \"NO\" : join '', sort split"}], "src_uid": "02fe37c2e31ca4e278d493fc2e3e35e0"}
{"source_code": "for(1..<>){($m,$n)=split/\\s/,<>;print$n*($n-1)/2+$n*$m*($m+1)/2,\"\\n\"}", "positive_code": [{"source_code": "for(1..<>){($m,$n)=split/\\s/,<>;print$n*($n+$m*$m+$m-1)/2,\" \"}"}, {"source_code": "for(1..<>){($m,$n)=split/\\s/,<>;print$n*(($n-1)+$m*($m+1))/2,\" \"}"}, {"source_code": "for(1..<>){($m,$n)=split/\\s/,<>;print $n*($n-1)/2+$n*$m*($m+1)/2,\"\\n\"}"}, {"source_code": "for(1..<>){($m,$n)=split/\\s/,<>;print-1&$n*($n-1)/2+$n*$m*($m+1)/2,\"\\n\"}"}, {"source_code": "for(1..<>){($m,$n)=split/\\s/,<>;print$n*($n-1)/2+$n*$m*($m+1)/2,\" \"}"}], "negative_code": [], "src_uid": "7d774a003d2e3e8ae6fe1912b3998c96"}
{"source_code": "($k, $d) = split(' ', <>);\nif($d == 0 && $k != 1)\n{\n    print 'No solution';\n}\nelse\n{\n    print($d, '0'x($k - 1));\n}\n", "positive_code": [{"source_code": "while(<>){\n\tchomp;\n\t/ /;\n\tif ($`>1 && $'==0) {print \"No solution\\n\"} else {\n\tprint $'.(\"0\"x($`-1));\n\tprint \"\\n\";\n\t}}"}], "negative_code": [{"source_code": "($k, $d) = split(' ', <>);\nprint($d * (10**($k - 1)));"}, {"source_code": "($k, $d) = split(' ', <>);\nif($d == 0 && $k != 1)\n{\n\tprint 'No solution';\n}\nelse\n{\n\tprint($d * (10**($k - 1)));\n}\n"}, {"source_code": "($k, $d) = split(' ', <>);\nif($d == 0 && $k != 1)\n{\n\tprint 'No solution';\n}\nelse\n{\n\tprint($d * (10**($k - 1)));\n}\n"}, {"source_code": "while(<>){\n\tchomp;\n\t/ /;\n\tprint $'.(\"0\"x($`-1));\n\tprint \"\\n\";\n\t}"}], "src_uid": "5dd0d518f315d81204b25e48fea0793a"}
{"source_code": "for(1..<>){$_=<>;print$_&1?\"-1 \":($_/2).\" 0 0 \"}", "positive_code": [{"source_code": "for(1..<>){$n=<>;print$n&1?\"-1 \":($n/2).\" \".($n/2).\" 0 \"}"}, {"source_code": "for(1..<>){$n=<>/2;print$n==int($n)?$n.\" \".$n.\" 0 \":\"-1 \"}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tif( $_ % 2 == 1 ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\t$_ >>= 1;\n\t\n\tif( $_ % 2 == 0 ){\n\t\tprint join ' ', $_ + 1, $_ + 1, 1;\n\t\t}\n\telse{\n\t\tprint join ' ', $_ - 1, $_ - 1, 1;\n\t\t}\n\t\n\t}"}, {"source_code": "for(1..<>){$_=<>;print$_&1?\"-1 \":($_/2).\" 0 0 \"}"}, {"source_code": "for(1..<>){$_=<>;print$_&1?\"-1 \":($_/2).\" 0 0 \"}"}], "negative_code": [{"source_code": "for(1..<>){$n=<>/2;print$n==-1&$n?$n.\" \".$n.\" 0 \":\"-1 \"}"}, {"source_code": "for(1..<>){$n=<>/2;print-1&$n==$n?$n.\" \".$n.\" 0 \":\"-1 \"}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tif( $_ % 2 == 1 ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\t$_ >>= 1;\n\t\n\tprint join ' ', $_ + 1, $_ + 1, 1;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tif( $_ % 2 == 1 ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\t$_ >>= 1;\n\t\n\tprint join ' ', $_, $_ - 1, 1;\n\t}"}], "src_uid": "43041076ddd0bbfac62cd4abf4536282"}
{"source_code": "use strict;\nuse warnings;\n\nuse Data::Dumper;\n\n\nmy $n = <>;\nchomp $n;\n\ndie ('wrong n..') unless $n >= 1;\n\nmy %player_wins;\n$player_wins{Mishka} = 0;\n$player_wins{Chris} = 0;\n\nfor (my $i=0; $i<$n; $i++) {\n    my $in = <>;\n    chomp $in;\n    my ($m , $c) = split(' ', $in);\n\n    if ($m > $c) {\n        $player_wins{Mishka}++;\n    } elsif($c > $m) {\n        $player_wins{Chris}++;\n    }\n}\n\nif ($player_wins{Mishka} > $player_wins{Chris}) {\n    print 'Mishka';\n} elsif($player_wins{Chris} > $player_wins{Mishka}) {\n    print 'Chris';\n} else {\n    print 'Friendship is magic!^^';\n}\n\n", "positive_code": [{"source_code": "<>; for (<>) {\n\ts/ /-/; $r += eval() <=> 0;\n}\n\nprint [\"Friendship is magic!^^\", \"Mishka\", \"Chris\"]->[$r <=> 0];"}, {"source_code": "my $n = <>;\nmy $z = 0;\nfor (1..$n) {\n    my ($m, $c) = split ' ', <>;\n    $z -= ($m <=> $c);\n}\n\n$z = ($z <=> 0);\nmy @words = ('Mishka', 'Friendship is magic!^^', 'Chris');\nprint $words[$z + 1], \"\\n\";\n"}, {"source_code": "# cf703a\nmy $n=<>;\nmy $s;\nforeach (<>) {\n  my ($m,$c)=split(' ',$_);\n  if($m>$c) {++$s;}\n  elsif($m<$c) {--$s;}\n}\n\nprint $s>0 ? 'Mishka' : $s<0 ? 'Chris' : 'Friendship is magic!^^';\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\n# send argument as array, not reference, to function requiring list\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $a = \"Mishka\";\nmy $b = \"Chris\";\nmy $c = \"Friendship is magic!^^\";\n\nmy $n = read_token;\n\nmy $balance = 0;\n\nfor (1..$n) {\n    my $p = read_token;\n    my $q = read_token;\n    $balance++ if $p > $q;\n    $balance-- if $p < $q;\n}\n\nsay $a if $balance > 0;\nsay $b if $balance < 0;\nsay $c if $balance == 0;\n"}], "negative_code": [{"source_code": "<>; $/ = \"\"; $_ = <>; tr/ \\n/-+/;\nprint [\"Friendship is magic!^^\", \"Mishka\", \"Chris\"]->[eval() <=> 0];"}, {"source_code": "use strict;\nuse warnings;\n\nuse Data::Dumper;\n\n\nmy $n = <>;\nchomp $n;\n\ndie ('wrong n..') unless $n >= 1;\n\nmy %player_wins;\n$player_wins{Mishka} = 0;\n$player_wins{Chris} = 0;\n\nfor (my $i=0; $i<$n; $i++) {\n    my $in = <>;\n    chomp $in;\n    my ($m , $c) = split(' ', $in);\n\n    if ($m > $c) {\n        $player_wins{Mishka}++;\n    } else {\n        $player_wins{Chris}++;\n    }\n}\n\nif ($player_wins{Mishka} > $player_wins{Chris}) {\n    print 'Mishka';\n} elsif($player_wins{Chris} > $player_wins{Mishka}) {\n    print 'Chris';\n} else {\n    print 'Friendship is magic!^^';\n}\n\n"}, {"source_code": "use strict;\nuse warnings;\n\n\n\n\nmy $n = <>;\nchomp $n;\n\ndie ('wrong n..') unless $n >= 1;\n\nmy %player_wins;\n$player_wins{Mishka} = 0;\n$player_wins{Chris} = 0;\n$player_wins{draw} = 0;\n\nfor (my $i=0; $i<$n; $i++) {\n    my $in = <>;\n    chomp $in;\n    my ($m , $c) = split(' ', $in);\n\n\n\n    if ($m == $c) {\n        $player_wins{draw}++;\n    } elsif ($m > $c) {\n        $player_wins{Mishka}++;\n    } else {\n        $player_wins{Chris}++;\n    }\n}\n\nmy $max = 'draw';\n\n    if ($player_wins{Mishka} > $player_wins{$max}) {\n        $max = 'Mishka';\n    }\n    if ($player_wins{Chris} > $player_wins{$max}) {\n        $max = 'Chris';\n    }\n    if ($player_wins{Chris} == $player_wins{Mishka}) {\n        $max = 'draw';\n    }\nprint $max;\n"}, {"source_code": "use strict;\nuse warnings;\n\n\n\n\nmy $n = <>;\nchomp $n;\n\ndie ('wrong n..') unless $n >= 1;\n\nmy %player_wins;\n$player_wins{Mishka} = 0;\n$player_wins{Chris} = 0;\n$player_wins{draw} = 0;\n\nfor (my $i=0; $i<$n; $i++) {\n    my $in = <>;\n    chomp $in;\n    my ($m , $c) = split(' ', $in);\n\n\n\n    if ($m == $c) {\n        $player_wins{draw}++;\n    } elsif ($m > $c) {\n        $player_wins{Mishka}++;\n    } else {\n        $player_wins{Chris}++;\n    }\n}\n\nmy $max = 'draw';\n\n    if ($player_wins{Mishka} > $player_wins{$max}) {\n        $max = 'Mishka';\n    }\n    if ($player_wins{Chris} > $player_wins{$max}) {\n        $max = 'Chris';\n    }\n    if ($player_wins{Chris} == $player_wins{Mishka}) {\n        $max = 'draw';\n    }\nmy $out = ($max eq 'draw') ? 'Friendship is magic!^^' : $max;\n\nprint $out;\n"}, {"source_code": "use strict;\nuse warnings;\n\nuse Data::Dumper;\n\n# rows 10\n# per row: 2x2\n# find to seats next to each other...\n\n\nmy $n = <>;\nchomp($n);\n\ndie('wrong number or rows') unless $n >=0 && $n <= 100;\n\n# store input as array with length n * 2\n# loop array, find first seat with OO.\n# found: change 00 to ++\n# exit and print result\n\nmy @buss;\nmy @left;\nmy @right;\nfor (0..$n-1) {\n    my $in = <>;\n    chomp($in);\n    my @seats = split('\\|', $in);\n#    print Dumper \\@seats;\n    push @left, $seats[0];\n    push @right, $seats[1];\n}\n@buss = (@left, @right);\n\nfor (@buss) {\n    if ($_ eq 'OO') {\n        print \"YES\\n\";\n        $_ = '++';\n        print_bus(\\@buss, $n);\n        exit;\n    }\n}\nprint \"NO\\n\";\n\n\nsub print_bus {\n    my ($buss, $n) = @_;\n\n    for (my $i=0; $i<$n; $i++) {\n        my $row = $buss->[$i] . '|' . $buss->[$n + $i];\n        print $row . \"\\n\";\n    }\n}\n\n"}, {"source_code": "use strict;\nuse warnings;\n\n\n\n\nmy $n = <>;\nchomp $n;\n\ndie ('wrong n..') unless $n >= 1;\n\nmy %player_wins;\nfor (my $i=0; $i<$n; $i++) {\n    my $in = <>;\n    chomp $in;\n    my ($m , $c) = split(' ', $in);\n\n    if ($m == $c) {\n        $player_wins{draw}++;\n    } elsif ($m > $c) {\n        $player_wins{Mishka}++;\n    } else {\n        $player_wins{Chris}++;\n    }\n}\n\nmy @sorted = sort { $player_wins{$b} <=> $player_wins{$a} } keys %player_wins;\nmy $winner = shift @sorted;\n\nmy $out = ($winner eq 'draw') ? 'Friendship is magic!^^' : $winner;\n\nprint $out;\n"}], "src_uid": "76ecde4a445bbafec3cda1fc421e6d42"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nmy @sums = split q{ }, read_line();\n\n@sums = sort { $a <=> $b } @sums;\n\nmy $abc = pop @sums;\n\nmy $answer = '';\n\n$answer .= $sums[0] + $sums[1] - $abc;\n$answer .= ' ';\n$answer .= $sums[1] + $sums[2] - $abc;\n$answer .= ' ';\n$answer .= $sums[2] + $sums[0] - $abc;\n\nsay $answer;\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n", "positive_code": [{"source_code": "my $line = <STDIN>;\nchomp $line;\nmy @numbers = split ' ', $line;\n\nmy $max = 0;\nmy $idx = 0;\nfor (@numbers) {\n    $max = $idx if $_ > $numbers[$max];\n    $idx++;\n}\n\nmy @output;\n$idx = 0;\nfor (@numbers) {\n    if ($idx != $max) {\n        push @output, $numbers[$max] - $_;\n    }\n    $idx++;\n}\n\nprint join(' ', @output) . \"\\n\";\n"}, {"source_code": "$\\ = $/;\n\nwhile( <>) {\n    @_ = sort { $a <=> $b } split;\n    \n    print join ' ', map $_[ 3 ] - $_[ $_ ], 0 .. 2;\n}"}], "negative_code": [{"source_code": "my $line = <STDIN>;\nchomp $line;\nmy @numbers = split ' ', $line;\n\nmy $max = -1;\nmy $idx = 0;\nfor (@numbers) {\n    $max = $idx if $_ > $numbers[max];\n    $idx++;\n}\n\nmy @output;\n$idx = 0;\nfor (@numbers) {\n    if ($idx != $max) {\n        push @output, $numbers[$max] - $_;\n    }\n    $idx++;\n}\n\nprint join(' ', @output) . \"\\n\";\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nmy @sums = split q{ }, read_line();\n\n@sums = sort { $a <=> $b } @sums;\n\nsay @sums;\n\nmy $abc = pop @sums;\n\nmy $answer = '';\n\n$answer .= $sums[0] + $sums[1] - $abc;\n$answer .= ' ';\n$answer .= $sums[1] + $sums[2] - $abc;\n$answer .= ' ';\n$answer .= $sums[2] + $sums[0] - $abc;\n\nsay $answer;\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nmy @sums = split q{ }, read_line();\n\n@sums = sort @sums;\n\nmy $abc = pop @sums;\n\nmy $answer = '';\n\n$answer .= $sums[0] + $sums[1] - $abc;\n$answer .= ' ';\n$answer .= $sums[1] + $sums[2] - $abc;\n$answer .= ' ';\n$answer .= $sums[2] + $sums[0] - $abc;\n\nsay $answer;\n\n\n\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n"}, {"source_code": "@_ = sort { $b <=> $a } split '', <>;\n\nprint +( eval join '+', @_ ) - 2 * $_[ 0 ];"}, {"source_code": "@_ = sort { $b <=> $a } split ' ', <>;\n\nprint +( eval join '+', @_ ) - 2 * $_[ 0 ];"}], "src_uid": "cda949a8fb1f158f3c06109a2d33f084"}
{"source_code": "use warnings; use strict;\nmy ($n, $m) = split ' ', scalar<>;\n$n += 0; $m+= 0;\nmy @a = split ' ', scalar <>; $_ += 0 foreach @a;\nmy @b = split ' ', scalar <>; $_ -= 1 foreach @b;\nmy @c = (0) x $n;\nmy @after = (0) x $n;\n$after[$_] = [(0) x $n] foreach (0 .. ($n-1));\nmy $res = 0;\nforeach my $b (@b){\n    $res += $c[$b];\n    #print @{$after[$_]}, \"\\n\" foreach (0 .. ($n-1));\n    #print join ' ', @c;\n    #print \" $res\\n\";\n    foreach (0 .. ($n-1)){\n        $c[$_] += $a[$b] unless $after[$b][$_];\n        }\n    foreach (0 .. ($n-1)){\n        $after[$b][$_] = 1;\n        $after[$_][$b] = 0;\n        }\n    $c[$b] = 0;\n    }\nprint \"$res\\n\";\n", "positive_code": [{"source_code": "use List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nchomp (my ($n, $m) = split /\\s+/, <STDIN>);\nchomp (my (@w) = split /\\s+/, <STDIN>);\nchomp (my (@b) = split /\\s+/, <STDIN>);\n\nmy @order;\nmy %seen;\nforeach (@b) {\n  push @order, $_ if not exists $seen{$_};\n  $seen{$_}++;\n}\n\nmy @arr;\nforeach (@order) {\n  push @arr, $w[$_ - 1];\n}\n\n# printf \"@arr\\n\";\nmy $sum = 0;\nmy $x;\n\nsub findIdx {\n  for (my $i = 0; $i < @order; $i++) {\n    return $i if ($order[$i] == $_[0])\n  }\n}\n\nforeach (@b) {\n  $x = &findIdx($_);\n  $sum += &sum(@arr[0 .. ($x - 1)]) if ($x > 0);\n  unshift @arr, splice @arr, $x, 1;\n  unshift @order, splice @order, $x, 1;\n}\n\nprintf \"$sum\\n\";\n"}], "negative_code": [], "src_uid": "a18edcadb31f76e69968b0a3e1cb7e3e"}
{"source_code": "\n$,=\" \";\nmy $n=<>;\nmy $str=<>;\nchomp($str);\nwhile(1)\n{\n  last if index($str,'><')<0;\n  $str =~ s/>+<+//g;\n}\n\nprint length($str) , \"\\n\";\n", "positive_code": [{"source_code": "<>;\n$_ = <>, chomp;\nif( /^<+/ ){\n\t$ans += length $&;\n\t}\n$_ = reverse;\nif( /^>+/ ){\n\t$ans += length $&;\n\t}\nprint 0 + $ans"}, {"source_code": "\n$,=\" \";\nmy $n=<>;\nmy $str=<>;\nchomp($str);\n$str =~ s/>+<+//g;\n\n\nprint length($str) , \"\\n\";\n"}, {"source_code": "<>;\n$_ = <>;\n$L = length;\n$i = index $_, '>';\n$i < 0 and $i = $L - 1;\n$r = rindex $_, '<';\nprint( $L - $r + $i - 2 )"}], "negative_code": [{"source_code": "\n$,=\" \";\nmy $n=<>;\nmy $str=<>;\nchomp($str);\nwhile(1)\n{\n  last if index($str,'><')<0;\n  $str =~ s/><//g;\n}\n\nprint length($str) , \"\\n\";\n"}, {"source_code": "<>;\n$_ = <>;\nif( /^<+/ ){\n\t$ans += length $&;\n\t}\n$_ = reverse;\nif( /^>+/ ){\n\t$ans += length $&;\n\t}\nprint $ans"}, {"source_code": "<>;\n$_ = <>;\n/^<+/;\n$ans += length $&;\n$_ = reverse;\n/^<+/;\n$ans += length $&;\nprint $ans"}, {"source_code": "<>;\n$_ = <>;\n/^<+/;\n$ans += length $&;\n$_ = reverse;\n/^>+/;\n$ans += length $&;\nprint $ans"}, {"source_code": "<>;\n$_ = <>;\n$L = length;\n$i = index $_, '>';\n$i < 0 and $i = $L;\n$r = rindex $_, '<';\nprint( $L - $r + $i - 1 )"}, {"source_code": "<>;\n$_ = <>, chomp;\nif( /^<+/ ){\n\t$ans += length $&;\n\t}\n$_ = reverse;\nif( /^>+/ ){\n\t$ans += length $&;\n\t}\nprint $ans"}, {"source_code": "print length join '', <>=~/^<+|>+$/g"}], "src_uid": "6b4242ae9a52d36548dda79d93fe0aef"}
{"source_code": "( $n, $k ) = split ' ', <>;\n\n@sA = sort { $a <=> $b } @A = split ' ', <>;\n\n$prev = $sA[ 0 ];\n\nfor $i ( 0 .. @sA - 1 ){\n\t$sA[ $i ] == $prev or $h{ $sA[ $i ] } = $i;\n\t$prev = $sA[ $i ];\n\t}\n\nfor( 1 .. $k ){\n\t( $u, $v ) = split ' ', <>;\n\t$A[ $u - 1 ] == $A[ $v - 1 ] or\n\t\t$B[ $A[ $u - 1 ] > $A[ $v - 1 ] ? $u - 1 : $v - 1 ] --;\n\t}\n\t\nprint join ' ', map { $h{ $_ } + shift @B } @A", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\tmy @A = split ' ', <>;\n\t\n\tmy @sA = sort { $a <=> $b } @A;\n\tmy @B;\n\t\n\tmy $prev = $sA[ 0 ];\n\tmy %h;\n\t\n\tfor my $i ( 0 .. @sA - 1 ){\n\t\tnext if $sA[ $i ] == $prev;\n\t\t$h{ $sA[ $i ] } = $i;\n\t\t$prev = $sA[ $i ];\n\t\t}\n\t\n\t$debug and print \"$_ => $h{ $_ }\" for sort keys %h;\n\t\n\tfor( 1 .. $k ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t$debug and print \"$u|$v||$A[ $u - 1 ]|$A[ $v - 1 ]\";\n\t\tnext if $A[ $u - 1 ] == $A[ $v - 1 ];\n\t\t$B[ $A[ $u - 1 ] > $A[ $v - 1 ] ? $u - 1 : $v - 1 ] --;\n\t\t}\n\t\n\t$debug and print \"$_ => $h{ $_ }\" for sort keys %h;\n\t\n\tprint join ' ', map { ( $h{ $_ } || 0 ) + shift @B } @A;\n\t\n\t$debug and print '-' x 15;\n\t}"}, {"source_code": "# author : Gabriel Hofer\nuse strict;\nuse warnings;\nuse constant NL => qq/\\n/;\nsub max { $_ [ 0 ] > $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nmy %quarrel = ();\nmy ( $n, $k ) = split qq / /, <STDIN>;\nmy @skill = split qq/ /, <STDIN>;\nmy @skill_sorted = sort { $a <=> $b } @skill;\n\nmy %h = ();\nAA: for ( 1 .. $k  ) {\n    my ( $five, $six ) = split qq/ /, <STDIN>;\n    if ( $skill [ $five - 1 ] > $skill [ $six - 1 ] ) { \n        $quarrel { $five } = 0 if not exists $quarrel { $five };\n        $quarrel { $five } += 1; \n        next AA\n    } elsif ( $skill [ $five - 1 ] < $skill [ $six - 1 ] ) { \n        $quarrel { $six } = 0 if not exists $quarrel { $six };\n        $quarrel { $six } += 1; \n        next AA\n    }\n}\n\nAB: for my $j ( 1 .. ($#skill + 1) ) {\n    (not (my $left = 0)) and (my $right = $#skill + 1) and (my $mid);\n    AC: while ( $left < $right ) { \n        $mid = int ( ( $left + $right ) / 2 );\n        if ( $skill_sorted [ $mid ] < ($skill [ $j - 1 ]) ) { ($left = $mid + 1) and next AC }\n        else { ($right = $mid) and next AC }\n    }\n    $mid = int ( ( $left + $right ) / 2 );\n    if ( exists $quarrel { $j } ) { print max ( 0, $mid - $quarrel { $j } ) }\n    else { print $mid }\n    print qq/ /;\n}\nprint NL;\n\n"}], "negative_code": [{"source_code": "# author : Gabriel Hofer\nuse strict;\nuse warnings;\nuse constant NL => qq/\\n/;\nsub max { $_ [ 0 ] > $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nmy %quarrel = ();\nmy ( $n, $k ) = split qq / /, <STDIN>;\nmy @skill = split qq/ /, <STDIN>;\nmy @skill_sorted = sort { $a <=> $b } @skill;\n\nmy %h = ();\nAA: for ( 1 .. $k  ) {\n    my ( $five, $six ) = ( <STDIN> =~ m /(\\d+)\\s(\\d+)/ );\n    my $nine;\n    if ( $skill [ $five - 1 ] > $skill [ $six - 1 ] ) { $nine = $five } \n    else { $nine = $six }\n    $quarrel { $nine } = 0 if not exists $quarrel { $nine };\n    $quarrel { $nine } += 1;\n}\n\nAA: for my $j ( 1 .. ($#skill + 1) ) {\n    (not (my $left = 0)) and (my $right = $#skill + 1) and (my $mid);\n    AB: while ( $left < $right ) { \n        $mid = int ( ( $left + $right ) / 2 );\n        if ( $skill_sorted [ $mid ] < ($skill [ $j - 1 ]) ) { ($left = $mid + 1) and next AB }\n        else { ($right = $mid) and next AB }\n    }\n    $mid = int ( ( $left + $right ) / 2 );\n    if ( exists $quarrel { $j } ) { print $mid - $quarrel { $j } }\n    else { print $mid }\n    print qq/ /;\n}\nprint NL;\n\n\n"}, {"source_code": "# author : Gabriel Hofer\nuse strict;\nuse warnings;\nuse constant NL => qq/\\n/;\nsub max { $_ [ 0 ] > $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nmy %quarrel = ();\nmy ( $n, $k ) = split qq / /, <STDIN>;\nmy @skill = split qq/ /, <STDIN>;\nmy @skill_sorted = sort { $a <=> $b } @skill;\n\nmy %h = ();\nAA: for ( 1 .. $k  ) {\n    my ( $five, $six ) = ( <STDIN> =~ m /(\\d+)\\s(\\d+)/ );\n    my $nine;\n    if ( $skill [ $five - 1 ] > $skill [ $six - 1 ] ) { $nine = $five } \n    else { $nine = $six }\n    $quarrel { $nine } = 0 if not exists $quarrel { $nine };\n    $quarrel { $nine } += 1;\n}\n\nAA: for my $j ( 1 .. ($#skill + 1) ) {\n    (not (my $left = 0)) and (my $right = $#skill + 1) and (my $mid);\n    AB: while ( $left < $right ) { \n        $mid = int ( ( $left + $right ) / 2 );\n        if ( $skill_sorted [ $mid ] < ($skill [ $j - 1 ]) ) { ($left = $mid + 1) and next AB }\n        else { ($right = $mid) and next AB }\n    }\n    $mid = int ( ( $left + $right ) / 2 );\n    if ( exists $quarrel { $j } ) { print max ( 0, $mid - $quarrel { $j } ) }\n    else { print $mid }\n    print qq/ /;\n}\nprint NL;\n\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\tmy @A = split ' ', <>;\n\t\n\tmy @sA = sort { $a <=> $b } @A;\n\tmy @B;\n\t\n\tmy $prev = $sA[ 0 ];\n\tmy %h;\n\t\n\tfor my $i ( 0 .. @sA - 1 ){\n\t\tnext if $sA[ $i ] == $prev;\n\t\t$h{ $sA[ $i ] } = $i;\n\t\t$prev = $sA[ $i ];\n\t\t}\n\t\n\t$debug and print \"$_ => $h{ $_ }\" for sort keys %h;\n\t\n\tfor( 1 .. $k ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t$debug and print \"$u|$v||$A[ $u - 1 ]|$A[ $v - 1 ]\";\n\t\t$B[ $A[ $u - 1 ] > $A[ $v - 1 ] ? $u - 1 : $v - 1 ] --;\n\t\t}\n\t\n\t$debug and print \"$_ => $h{ $_ }\" for sort keys %h;\n\t\n\tprint join ' ', map { ( $h{ $_ } || 0 ) + shift @B } @A;\n\t\n\t$debug and print '-' x 15;\n\t}"}], "src_uid": "4687176445ed1087864b081a181e1840"}
{"source_code": "#\n# Hello World Program in Perl\n#\nuse strict;\n\nmy $count = <>;\nmy (%hf, %hs);\nmy %pair;\nmy %all;\nfor(1..$count)\n{\n    my ($a, $b) = split /\\s/, <>;\n   \n    $hf{$a}++;\n    $hs{$b}++;\n    \n    if($a == $b)\n    {\n        $pair{$a}++;\n    }\n    else\n    {\n        $all{\"[$a][$b]\"}++;\n    }\n}\nmy $ans = 0;\n\nmy @toDel;\nfor(keys(%hf))\n{\n    $ans += f($hf{$_});\n   \n}\n\nfor(keys(%hs))\n{\n    $ans += f($hs{$_});\n   \n}\n\nfor(keys(%pair))\n{\n    $ans -=f($pair{$_});\n}\n\n\nfor(keys(%all))\n{\n    $ans-=f($all{$_});\n}\n\n\n\nprint $ans;\n\n\nsub f($)\n{\n    my $ans = 0;\n    for(1..$_[0]-1)\n    {\n        $ans += $_; \n    }\n    return $ans;\n}\n\n", "positive_code": [{"source_code": "<STDIN>;\nmy $C = [];\nwhile(<STDIN>){\n    chomp $_;\n    my ($x, $y) = split(' ', $_);\n    push @$C, [$x, $y];\n}\n\nmy ($X, $Y, $XY) = ({}, {}, {});\nforeach(@$C){\n    ($X->{$_->[0]} ||= 0)++;\n    ($Y->{$_->[1]} ||= 0)++;\n    ($XY->{\"$_->[0]:$_->[1]\"} ||= 0)++;\n}\n\nmy $ans = 0;\n$ans += &nC2($_) for values %$X;\n$ans += &nC2($_) for values %$Y;\n$ans -= &nC2($_) for values %$XY;\n\nprint(sprintf(\"%d\\n\", $ans));\n\nsub nC2{\n    my $n = shift;\n    return int($n * ($n-1) / 2);\n}"}], "negative_code": [], "src_uid": "bd7b85c0204f6b36dc07f8a96fc36161"}
{"source_code": "use strict;\nuse warnings;\n\n\nmy ($n, $t) = split \" \", <>;\nmy @board;\n\nmy $parse = sub {\n\tmy ($a, $b) = ($_[0][0], $_[0][1]);\n\t#print \"in func - $a, $b\\n\";\n\treturn [$a - $b/2, $a + $b/2];\n};\n\nfor (0..$n-1) {\n\tpush @board, [split \" \", <>]->$parse;\n}\n\n#print \"$board[$_][0], $board[$_][1]\\n\" for (0..$n-1);\n\n@board = sort {$a->[0] <=> $b->[0]} @board;\n\n#print \"$board[$_][0], $board[$_][1]\\n\" for (0..$n-1);\n\nmy $result = 2;\n\nfor (0..$n-2) {\n\tif($board[$_+1][0] - $board[$_][1] > $t) {\n\t\t$result += 2;\n\t} elsif($board[$_+1][0] - $board[$_][1] == $t) {\n\t\t$result += 1;\n\t}\n}\n\nprint $result . \"\\n\";\n\n\n\n", "positive_code": [{"source_code": "($n, $t) = split(/ /, <>);\n$t += $t;\nfor $i (1..$n) {\n    ($x, $a) = split(/ /, <>);\n    $x += $x;\n    push @arr, [$x-$a, $x+$a];\n}\n@arr = sort {$a->[0] <=> $b->[0]} @arr;\n$ans = 2;\nfor $i (1..$n-1) {\n    $pr = $arr[$i-1][1];\n    $cl = $arr[$i][0];\n    $ans += $cl >  $pr+$t ? 2:\n            $cl == $pr+$t ? 1:0;\n}\nprint \"$ans\\n\";\n"}], "negative_code": [{"source_code": "($n, $t) = split(/ /, <>);\n$t += $t;\nfor $i (1..$n) {\n    ($x, $a) = split(/ /, <>);\n    $x += $x;\n    push @arr, [$x-$a, $x+$a];\n}\n@arr = sort {$a[0] cmp $b[0]} @arr;\n$ans = 2;\nfor $i (1..$n-1) {\n    $pr = $arr[$i-1][1];\n    $cl = $arr[$i][0];\n    $ans += $cl >  $pr+$t ? 2:\n            $cl == $pr+$t ? 1:0;\n}\nprint \"$ans\\n\";\n"}], "src_uid": "c31fed523230af1f904218b2fe0d663d"}
{"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-1e-9+1,\"\\n\"}", "positive_code": [{"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-1e-9+1,\"\\n\"}"}, {"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-1e-9+1,\"\\n\"}"}, {"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-1e-9+1,\" \"}"}, {"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&(@a[$n-1]+$t-1)/$t,\"\\n\"}"}, {"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-1e-9+1,\"\\n\"}"}, {"source_code": "use POSIX;$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:ceil(@a[$n-1]/$t),\"\\n\"}\r\n"}], "negative_code": [{"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-1e-15+1,\"\\n\"}"}, {"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$k-$t>1e-9?-1:-1&@a[$n-1]/$t-9e-9+1,\"\\n\"}"}, {"source_code": "$n=<>;@a=split/\\s/,<>;$k=0;for(1..$n){@a[$_-1]+=@a[$_-2]if($_>1);$k=@a[$_-1]/$_ if(@a[$_-1]/$_>$k)};for(1..<>){$t=<>;print$t<$k?-1:-1&@a[$n-1]/$t-9e-9+1,\"\\n\"}\r\n"}], "src_uid": "d7361a43bff124cea280ae8817b807ec"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\t@_ = reverse @_;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tif( $_[ $i] > 0 ){\n\t\t\t$_[ $i + 1 ] < $_[ $i ] - 1 and \n\t\t\t\t$_[ $i + 1 ] = $_[ $i ] - 1;\n\t\t\t$_[ $i ] = 1;\n\t\t\t}\n\t\t}\n\t\n\tif( $_[ @_ - 1 ] > 1 ){\n\t\t$_[ @_ - 1 ] = 1;\n\t\t}\n\t\n\t@_ = reverse @_;\n\t\n\tprint \"@_\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  \r\n  my @B = (); $#B = $n-1;\r\n  my $st = 0;\r\n  for(my $i=$n-1;$i>=0;$i--){\r\n    $st = $A[$i] if $A[$i]>$st;\r\n    $B[$i] = ( ( $st > 0 ) ? 1 : 0 );\r\n    $st--;\r\n  }\r\n  print ( join(\" \",@B) . \"\\n\");\r\n}\r\n\r\nexit(0);\r\n\r\n"}], "negative_code": [], "src_uid": "807c5ec37b0ea83ef40550698f1ff498"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\t@_ = sort { $a <=> $b } @_;\n\t\n\tmy $min = $_[ 0 ];\n\t\n\t@_ = grep { $_ != $min } @_;\n\t\n\tprint 0 + @_;\n\t}", "positive_code": [{"source_code": "<>;\r\nwhile (<>) {\r\n    @_ = sort {$a <=> $b} split $\", <>;\r\n    $min = shift @_;\r\n    while ($_[0] == $min) {\r\n        shift @_\r\n    }\r\n    print 0 + @_, \"\\n\"\r\n}"}], "negative_code": [], "src_uid": "99e5c907b623c310d6f1599f485ca21d"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\nmy $h = read_token;\n\nmy @talls = split q{ }, read_line;\n\nmy $answer = $n;\n\nfor (@talls) {\n    $answer++ if $_ > $h;\n}\n\nsay $answer;\n", "positive_code": [{"source_code": "my (undef, $h) = split ' ', <>;\nmy @a = split ' ', <>;\n\nprint scalar(@a + grep { $_ > $h } @a), \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl \nuse strict;\nmy $data = <STDIN>;\nmy $array =<STDIN>;\nmy @data_p = split(' ',$data);\nmy @array_p=split(' ', $array);\nmy ($n , $h) = @data_p;\nmy $sum = 0;\nforeach my $item (@array_p)\n{\n    if ( $item > $h ) \n    {\n        $sum = $sum + 2 ;\n    }\n    else \n    {\n        $sum = $sum + 1 ;\n    }\n}\nprint $sum; "}, {"source_code": "(undef, $h) = split ' ', <>;\n$sum += 1 + ($_ > $h) for split ' ', <>;\nprint $sum"}], "negative_code": [{"source_code": "(undef, $h) = split ' ', <>;\n$sum += 1 + ($_ * 2 > $h) for split ' ', <>;\nprint $sum"}], "src_uid": "e7ed5a733e51b6d5069769c3b1d8d22f"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tmy %h;\r\n\t\r\n\tmap $h{ $_ } ++, split ' ', <>;\r\n\t\r\n\tprint +( $h{ 1 } and grep $h{ $_ + 1 }, keys %h ) ? \"NO\" : \"YES\";\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\tmy $fail = 0;\n\t\n\tif( $h{ 1 } ){\n\t\t@_ = sort { $a <=> $b } @_;\n\t\tfor my $i ( 0 .. @_ - 2 ){\n\t\t\t$fail |= 1 == $_[ $i + 1 ] - $_[ $i ];\n\t\t\t}\n\t\t\n\t\tprint $fail ? \"NO\" : \"YES\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\tif( $h{ 1 } and $h{ 0 } || $h{ 2 } ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tif( 0 == grep $_ == 1, @_ ){\n\t\tprint \"YES\";\n\t\tnext;\n\t\t}\n\t\n\t@_ = sort { $a <=> $b } @_;\n\t\n\twhile( 1 ){\n\t\twhile( @_ and $_[ 0 ] == 1 ){\n\t\t\tshift @_;\n\t\t\t}\n\t\t\n\t\tlast if not @_;\n\t\t\n\t\tmy $div = $_[ 0 ] - 1;\n\t\t\n\t\t$_ %= $div for @_;\n\t\t\n\t\t@_ = sort { $a <=> $b } @_;\n\t\t\n\t\tif( grep { $_ == 0 || $_ == 2 } @_ ){\n\t\t\tprint \"NO\";\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tprint \"YES\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tif( ( grep $_ == 1, @_ ) and ( grep $_ % 2 == 0, @_ ) ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tif( ( grep $_ == 0, @_ ) and ( grep $_ == 1, @_ ) ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t\n\t\n\t}"}], "src_uid": "c7e4f544ec8b4972291542e66aff5df5"}
{"source_code": "$\\ = $/;\npush @_, scalar <> for 1 .. <>;\ny/ //d for @_;\n#print @_;\n$x[$i++] = 0 + ((sort {$b <=> $a} map length, /1+/g)[0]), $h[$x[$i-1]]++ for @_;\n#print \"<@x>\";\n#@h = (0) x 4;\n\n$i = (substr $_[$_-1], (split)[1]-1, 1), \n(substr $_[$_-1], (split)[1]-1, 1, 1 - $i), \n(@e = $_[$_-1] =~ /1+/g), \n#(print \"[@e]\"), \n$h[ $x[$_-1] ] --,\n$x[$_-1] = (sort {$b <=> $a} map length, @e)[0], \n#(print \"<@x>\"),\n$h[ $x[$_-1] ] ++,\n#(print \"[@h]\"),\n$z = 0,\n(map {$h[$_] > $z and do {$max = $_ }} 0 .. 500),\n(print $max) \nfor <>;\n\n#print @_", "positive_code": [{"source_code": "$\\ = $/;\npush @_, scalar <> for 1 .. <>;\ny/ //d, $h[ $x[$i++] = (sort {$b <=> $a} map length, /1+/g)[0] ]++ for @_;\n\n$i = (substr $_[$_-1], (split)[1] -1, 1), \n     (substr $_[$_-1], (split)[1] -1, 1 , 1 - $i), \n$h[ $x[$_-1] ] --,\n$h[ $x[$_-1] = (sort {$b <=> $a} map length, $_[$_-1] =~ /1+/g)[0]\n             ] ++,\n$z = 0,\n(map {$h[$_] > $z and $max = $_} 0 .. 500),\nprint $max for <>"}], "negative_code": [{"source_code": "$\\ = $/;\npush @_, scalar <> for 1 .. <>;\ny/ //d for @_;\n#print @_;\n$x[$i++] = 0 + ((sort {$b <=> $a} map length, /1+/g)[0]), $h[$x[$i-1]]++ for @_;\n#print \"<@x>\";\n#@h = (0) x 4;\n\n$i = (substr $_[$_-1], (split)[1]-1, 1), \n(substr $_[$_-1], (split)[1]-1, 1, 1 - $i), \n(@e = $_[$_-1] =~ /1+/g), (print \"[@e]\"), \n$h[ $x[$_-1] ] --,\n$x[$_-1] = (sort {$b <=> $a} map length, @e)[0], \n#(print \"<@x>\"),\n$h[ $x[$_-1] ] ++,\n#(print \"[@h]\"),\n$z = 0,\n(map {$h[$_] > $z and do {$max = $_ }} 0 .. 500),\n(print $max) \nfor <>;\n\n#print @_"}], "src_uid": "337b6d2a11a25ef917809e6409f8edef"}
{"source_code": "use strict;\nuse warnings;\n\nmy ($n, $d) = split /\\s+/, <>;\n\nmy $msg_to = {};\nmy $ans = {};\n\nwhile (<>) {\n    chomp;\n    my ($n1, $n2, $t) = split/\\s+/;\n    my $msg12 = \"$n1->$n2\";\n    my $msg21 = \"$n2->$n1\";\n    my $is_ans = 0;\n    for ($msg_to->{$msg21} ? @{$msg_to->{$msg21}} : ()) {\n        if (0 < $t-$_ && $t-$_ <= $d) {\n            $ans->{$n1 gt $n2 ? \"$n1 $n2\" : \"$n2 $n1\"} = 1;\n            $is_ans = 1;\n            last;\n        }\n    }\n    $is_ans or $msg_to->{$msg12} ? (push @{$msg_to->{$msg12}}, $t) : ($msg_to->{$msg12} = [$t]);\n}\n\nmy @k = keys %{$ans};\n$, = \"\\n\";\nprint 0+@k, @k;\n", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nmy ($n, $d) = split /\\s+/, <>;\n\nmy $msg_to = {};\nmy $ans = {};\n\nwhile (<>) {\n    chomp;\n    my ($n1, $n2, $t) = split/\\s+/;\n    my $msg12 = \"$n1->$n2\";\n    my $msg21 = \"$n2->$n1\";\n    my $is_ans = 0;\n    for ($msg_to->{$msg21} ? @{$msg_to->{$msg21}} : ()) {\n        if (0 < $t-$_ && $t-$_ <= $d) {\n            $ans->{$n1 gt $n2 ? \"$n1 $n2\" : \"$n2 $n1\"} = 1;\n            $is_ans = 1;\n            last;\n        }\n    }\n    $is_ans or $msg_to->{$msg12} ? (push @{$msg_to->{$msg12}}, $t) : ($msg_to->{$msg12} = [$t]);\n}\n\nmy @k = keys %{$ans};\n$, = \"\\n\";\nprint 0+@k, @k;"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\nopen STDIN, '<input.txt';\nopen STDOUT, '>output.txt';\n\nmy ($n, $d) = split /\\s+/, <>;\n\nmy $msg_to = {};\nmy $ans = {};\n\nwhile (<>) {\n    chomp;\n    my ($n1, $n2, $t) = split/\\s+/;\n    my $msg12 = \"$n1->$n2\";\n    my $msg21 = \"$n2->$n1\";\n    my $is_ans = 0;\n    for ($msg_to->{$msg21} ? @{$msg_to->{$msg21}} : ()) {\n        if (0 < $t-$_ && $t-$_ <= $d) {\n            $ans->{$n1 gt $n2 ? \"$n1 $n2\" : \"$n2 $n1\"} = 1;\n            $is_ans = 1;\n            last;\n        }\n    }\n    $is_ans or $msg_to->{$msg12} ? (push @{$msg_to->{$msg12}}, $t) : ($msg_to->{$msg12} = [$t]);\n}\n\nmy @k = keys %{$ans};\n$, = \"\\n\";\nprint 0+@k, @k;\n"}], "src_uid": "3cb4c89b174bf5ea51e797b78103e089"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\t@_ = ();\n\tpush @_, scalar <> for 1 .. $n;\n\t@_ = sort {$a <=> $b} @_;\n\t@a = ();\n\tpush @a, (split)[1] for @_;\n\t@b = @a;\n\t\n\t$j = 0;\n\t$max = -1;\n\t$sum = 0;\n\t\n\tfor $i (0 .. @_ -1){\n\t\t\n\t\twhile ($_[$i] - $_[$j] >= $m){\n\t\t\t$j ++;\n\t\t\t$sum -= shift @a;\n\t\t\t}\n\n\t\t$sum += $b[$i];\n\t\t$sum > $max and $max = $sum;\n#\t\tprint \"[$sum|$max]\";\n\t\t\n\t\t}\n\t\n\tprint $max;\n\t}", "positive_code": [{"source_code": "($n, $m) = split ' ', <>;\n\n@_ = sort {$a <=> $b} <>;\n\npush @a, (split)[1] for @_;\n@b = @a;\n\nfor (0 .. @_ -1){\n\t\n\t$j ++, $sum -= shift @a while $_[$_] - $_[$j] >= $m;\n\t\t\n\t( $sum += $b[$_] )\n\t\t> $max and $max = $sum\n\t}\n\nprint $max"}], "negative_code": [{"source_code": "($n, $m) = split ' ', <>;\n\n@_ = sort {$a <=> $b} <>;\n\npush @a, (split)[1] for @_;\n\n@_ = (); # releasing some memory\n\n@b = @a;\n\nfor (0 .. @_ -1){\n\t\n\t$j ++, $sum -= shift @a while $_[$_] - $_[$j] >= $m;\n\t\t\n\t( $sum += $b[$_] )\n\t\t> $max and $max = $sum\n\t}\n\nprint $max"}], "src_uid": "38fe0e19974a7bc60153793b9060369a"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\tmy $n = $_;\n\t\n\t@_ = map { [ split ' ', <> ] } 1 .. $n;\n\t\n\tmy @tm = split ' ', <>;\n\t\n\tmy $prev = 0;\n\tmy $ok;\n\tmy $sum = 0;\n\t\n\tfor my $i ( 0 .. @tm - 1 ){\n\t\t$sum += $_[ $i ][ 0 ] - $prev + $tm[ $i ];\n\t\t$ok = $sum;\n\t\t\n\t\tmy $diff = int 0.5 + ( $_[ $i ][ 1 ] - $_[ $i ][ 0 ] ) / 2;\n\t\t\n\t\tif( $sum + $diff > $_[ $i ][ 1 ] ){\n\t\t\t$sum += $diff;\n\t\t\t}\n\t\telse{\n\t\t\t$sum = $_[ $i ][ 1 ];\n\t\t\t}\n\t\t\n\t\t$prev = $_[ $i ][ 1 ];\n\t\t}\n\t\n\tprint $ok;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @ab = ();\r\n  for(my $i=0;$i<$n;$i++){\r\n    my @ab1 = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n    push(@ab,\\@ab1);\r\n  }\r\n  my @tm = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  \r\n  my @tr = (); $#tr = $#tm;\r\n  for(my $i=0;$i<$n;$i++){\r\n    $tr[$i] = $ab[$i]->[0] - ( $i > 0 ? $ab[$i-1]->[1] : 0 );\r\n  }\r\n  \r\n  my $t = $tr[0] + $tm[0];\r\n  for(my $i=0;$i<$n;$i++){\r\n    my $spd = int(( $ab[$i]->[1] - $ab[$i]->[0] + 1 ) / 2);\r\n    my $dpt = $t + $spd;\r\n    $dpt = $ab[$i]->[1] if $dpt < $ab[$i]->[1];\r\n    last if $i == $n-1;\r\n    $t = $dpt + $tr[1+$i] + $tm[1+$i];\r\n  }\r\n  print \"$t\\n\";\r\n  \r\n}\r\n\r\nexit(0);\r\n"}], "negative_code": [], "src_uid": "42840fc873369e0d0d6a4ad24a43f5a6"}
{"source_code": "($n, $k) = split ' ', <>;\n($L, @_) = reverse map length, <>;\n\n$short = grep { $L > $_ } @_;\n\nprint join ' ', map {\n\t$_ + 5 * int ~- $_ / $k\n\t} $short + 1, $short + grep { $L == $_ } @_", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $k) = split;\n\t@_ = ();\n\tfor (1 .. $n){\n\t\tpush @_, ~~<>;\n\t\t}\n\tchomp(@_);\n\tchomp( $psw = <> );\n\t$len_psw = length $psw;\n\t$short = grep { $len_psw >  length } @_;\n\t$equal = grep { $len_psw == length } @_;\n\t\n\tprint join ' ', map {\n\t\t$_ + 5 * int( ($_-1) / $k)\n\t\t} $short + 1, $short + $equal;\n\t}"}, {"source_code": "($n, $k) = split ' ', <>;\n($L, @_) = reverse map length, <>;\n\nmap { $S += $L > $_; $E += $L == $_ } @_;\n\nprint join ' ', map {\n\t$_ + 5 * int ~- $_ / $k\n\t} map { $S + $_ } 1, $E"}, {"source_code": "($n, $k) = split ' ', <>;\n($L, @_) = reverse map length, <>;\n\nmap ++ $h{ $L <=> $_ }, @_;\n\nprint join ' ', map {\n\t$_ + 5 * int ~- $_ / $k\n\t} map { $h{1} + $_ } 1, $h{0}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $k) = split;\n\t@_ = ();\n\tfor (1 .. $n){\n\t\tpush @_, ~~<>;\n\t\t}\n\tchomp(@_);\n\tchomp( $psw = <> );\n\t$len_psw = length $psw;\n\t$short = grep { $len_psw >  length } @_;\n\t$equal = grep { $len_psw == length } @_;\n\t\n\tprint join ' ', map {\n\t\t$_ + 5 * int $_ / $k\n\t\t} $short + 1, $short + $equal;\n\t}"}], "src_uid": "06898c5e25de2664895f512f6b766915"}
{"source_code": "use 5.016;\n\nmy $n = <>;\nmy @l;\nfor (1..$n) {\n  my ($a, $b) = split ' ', <>;\n  push @l, [$a, $b];\n}\nmy @x = sort { $a->[0] <=> $b->[0] } @l;\nmy $ok = 0;\nfor my $i (1..$#x) {\n  my ($x, $y) = @x[$i - 1, $i];\n  if ($x->[0] < $y->[0] && $x->[1] > $y->[1]) {\n    $ok = 1;\n    last;\n  }\n}\n\nsay $ok ? 'Happy Alex' : 'Poor Alex';\n", "positive_code": [{"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "<>;\n@_=<>;\n(($a,$b)=split/ /,$_),($a!=$b and $f=1) for @_;\nprint $f? \"Happy Alex\":\"Poor Alex\""}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "my ($a, $b, $f) = (0, 0, 0);\nfor(1..<>) {\n    ($a, $b) = split / /, <>;\n    $a != $b and $f = 1;\n}\nprint $f ? \"Happy Alex\" : \"Poor Alex\";\n"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub comp {\n\tif ($a->[0] == $b->[0]) {\n\t\treturn $b->[1] <=> $a->[1];\n\t} else {\n\t\treturn $b->[0] <=> $a->[0];\n\t}\n}\n\nchomp($n = <>);\npush @a, [split / /, <>] foreach (1..$n);\n@a = sort comp @a;\nforeach $i (1..$n-1) {\n\t($a[$i][0]<$a[$i-1][0] && $a[$i][1]>$a[$i-1][1]) and say \"Happy Alex\" and exit;\n}\nsay \"Poor Alex\";"}, {"source_code": "my $T=<>;\nchomp($T);\nmy %DATA;\nwhile($T--){\nmy ($a,$b)=split(/ /,<>);\nchomp($a,$b);\n$DATA{$b}=$a;\n}\nmy @S=map { $DATA{$_} } sort { $a <=> $b } keys %DATA;\nfor(0..@S-2){\nif($S[$_] > $S[$_+1]){\nprint  \"Happy Alex \\n\";\nexit(0);\n}\n}\nprint  \"Poor Alex\\n\";"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [int($1), int($2)]);\n}\n\n@laps = sort {\nif ($a->[0] < $b->[0]) {\n    return -1;\n} elsif ($a->[0] == $b->[0]) {\n    if ($a->[1] < $b->[1]) {\n        return -1;\n    } elsif ($a->[1] == $b->[1]) {\n        return 0;\n    } else {\n        return 1;\n    }\n} else {\n    return 1;\n}\n} @laps;\n\nfor (my $i = 1; $i <= $#laps; $i++) {\n    if ($laps[$i-1]->[1] > $laps[$i]->[1]) {\n            print \"Happy Alex\\n\";\n            exit 0;\n    }\n}\n\nprint \"Poor Alex\\n\";\n"}, {"source_code": "<>;\n/ /, $`==$' or $f=1 for <>;\nprint (($f? Happy:Poor),\" Alex\")\n"}], "negative_code": [{"source_code": "my ($a, $b, $f) = (0, 0, 0);\nfor(1..<>) {\n    ($a, $b) = split / /, <>;\n    $a != $b and $f = 1;\n}\nprint $f ? \"Happy Alex!\" : \"Poor Alex\";\n"}, {"source_code": "my $T=<>;\nchomp($T);\nmy %DATA;\nwhile($T--){\nmy ($a,$b)=split(/ /,<>);\nchomp($a,$b);\n$DATA{$b}=$a;\n}\nmy @S=map { $DATA{$_} } sort { $a <=> $b } keys %DATA;\nfor(0..@S-2){\nif($S[$_] > $S[$_+1]){\nprint  \"Happy Alex \\n\";\nlast;\n}\n}\nprint  \"Poor Alex\\n\";"}, {"source_code": "my $T=<>;\nchomp($T);\nmy %DATA;\nwhile($T--){\nmy ($a,$b)=split(/ /,<>);\nchomp($a,$b);\n$DATA{$b}=$a;\n}\nmy @S=map { $DATA{$_} } sort { $a <=> $b } keys %DATA;\nfor(0..@S-2){\nif($S[$_] > $S[$_+1]){\nprint  \"Happy Alex \\n\";\n}\n}\nprint  \"Poor Alex\\n\";"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [$1, $2]);\n}\n\n@laps = sort { $a->[0] cmp $b->[0] } @laps;\n\nfor (my $i = 0; $i <= $#laps; $i++) {\n    for (my $j = 0; $j < $i; $j++) {\n        if ($laps[$i]->[1] < $laps[$j]->[1]) {\n            print \"Happy Alex\\n\";\n            exit 0;\n        }\n    }\n}\n\nprint \"Poor Alex\\n\";\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [$1, $2]);\n}\n\n@laps = sort { $a->[0] cmp $b->[0] } @laps;\n\nmy $max = $laps[$#laps]->[1];\nmy $cost = $laps[$#laps]->[0];\n\nfor (my $i = $#laps-1; $i >= 0; $i--) {\n    if ($laps[$i]->[0] < $cost && $laps[$i]->[1] > $max) {\n            print \"Happy Alex\\n\";\n            exit 0;\n    }\n}\n\nprint \"Poor Alex\\n\";\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy (@a, @b);\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@a, $1);\n    push(@b, $2);\n}\n\n@a = sort @a;\n@b = sort @b;\n\nfor (my $i = 0; $i <= $#a; $i++) {\n    if ($a[$i] != $b[$i]) {\n        print \"Poor Alex\\n\";\n        exit 0;\n    }\n}\n\nprint \"Happy Alex\\n\";\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [int($1), int($2)]);\n}\n\n@laps = sort {\nif ($a->[0] <= $b->[0]) {\n    if ($a->[1] < $b->[1]) {\n        return 1;\n    } elsif ($a->[1] == $b->[1]) {\n        return 0;\n    } else {\n        return -1;\n    }\n} else {\n    return 1;\n}\n} @laps;\n\nfor (my $i = 1; $i <= $#laps; $i++) {\n    if ($laps[$i-1]->[1] > $laps[$i]->[1]) {\n            print \"Happy Alex\\n\";\n            exit 0;\n    }\n}\n\nprint \"Poor Alex\\n\";\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [$1, $2]);\n}\n\n@laps = sort { $a->[0] cmp $b->[0] } @laps;\n\nfor (my $i = 0; $i <= $#laps; $i++) {\n    for (my $j = $i; $j <= $#laps; $j++) {\n        if ($laps[$i]->[1] > $laps[$j]->[1]) {\n            print \"Happy Alex\\n\";\n            exit 0;\n        }\n    }\n}\n\nprint \"Poor Alex\\n\";\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [int($1), int($2)]);\n}\n\n@laps = sort {\nif ($a->[0] <= $b->[0]) {\n    if ($a->[1] < $b->[1]) {\n        return 1;\n    } elsif ($a->[1] == $b->[1]) {\n        return 0;\n    } else {\n        return -1;\n    }\n} else {\n    return 1;\n}\n} @laps;\n\nmy $max = $laps[$#laps]->[1];\nmy $cost = $laps[$#laps]->[0];\n\nfor (my $i = $#laps-1; $i >= 0; $i--) {\n    if ($laps[$i]->[0] < $cost && $laps[$i]->[1] > $max) {\n            print \"Happy Alex\\n\";\n            exit 0;\n    }\n}\n\nuse Data::Dumper;\nprint Dumper(\\@laps);\n\nprint \"Poor Alex\\n\";\n"}, {"source_code": "#!/usr/bin/env perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @laps;\n\nfor (1..$n) {\n    my $l = <>;\n    chomp $l;\n    $l =~ /^(\\d+) (\\d+)$/;\n\n    push(@laps, [int($1), int($2)]);\n}\n\n@laps = sort {\nif ($a->[0] <= $b->[0]) {\n    if ($a->[1] < $b->[1]) {\n        return 1;\n    } elsif ($a->[1] == $b->[1]) {\n        return 0;\n    } else {\n        return -1;\n    }\n} else {\n    return 1;\n}\n} @laps;\n\nmy $max = $laps[$#laps]->[1];\nmy $cost = $laps[$#laps]->[0];\n\nfor (my $i = $#laps-1; $i >= 0; $i--) {\n    if ($laps[$i]->[0] < $cost && $laps[$i]->[1] > $max) {\n            print \"Happy Alex\\n\";\n            exit 0;\n    }\n}\n\nprint \"Poor Alex\\n\";\n"}], "src_uid": "c21a84c4523f7ef6cfa232cba8b6ee2e"}
{"source_code": "$_ = <>, chomp;\n\nmap $h{ $_ }++, split //;\n\nmap $c += $h{ $_ } & 1, a .. z;\n\nw(  1, a .. z );\nw( -1, reverse a .. z );\n\n$_ = eval join \".\", map \"'$_' x \" . ($h{$_} >> 1) . \" \", sort keys %h;\n\n@r = g( a .. z );\n\nprint \"$_@r\" . reverse;\n\nsub w { \n\tmy $i; \n\t$j = shift; \n\tmap { $i ++< ($c >> 1) and $h{ $_ } += $j } g( @_ )\n\t}\n\t\nsub g { grep $h{ $_ } & 1, @_ }\n", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t%h = ();\n\tmap $h{ $_ }++, split //;\n\t$c = 0;\n\tmap { $h{ $_ } % 2 and $c ++ } a .. z;\n\n\t$i = 0;\n\tmap { $h{ $_ } % 2 and do { $i ++< int $c / 2 and $h{ $_ }++ } } a .. z;\n\n\t$i = 0;\n\tmap { $h{ $_ } % 2 and do { $i ++< int $c / 2 and $h{ $_ }-- } } reverse a .. z;\n\t\n\t$_ = eval join \".\", map { \"'$_' x \" . (int $h{$_} / 2) . \" \" } sort keys %h;\n\t\n\t@r = grep { $h{ $_ } % 2 } a .. z;\n\t\n\tprint $_ . \"@r\" . reverse\n\n\t}"}], "negative_code": [], "src_uid": "f996224809df700265d940b12622016f"}
{"source_code": "print\"2 3\\n262143 131071 0\\n131072 262143 \".<>", "positive_code": [{"source_code": "print\"2 3\\n262143 131071 0\\n131072 262143 \".<>"}], "negative_code": [], "src_uid": "fc0442e5cda2498a1818702e5e3eeec4"}
{"source_code": "<>;\n@_=split/ /,<>;\n$a=0;\n$I=0;\nfor(@_){\n\t$I++;\n\t$m[$_].=\"$I \"\n\t}\nfor (1..10e5){\n\tif ($m[$_]){\n\t\tif ($m[$_]=~/\\S \\d+ \\S/){\n\t\t\tchop $m[$_];\n\t\t\t@n=split/ /,$m[$_];\n\t\t\t$B=0; \n\t\t\t$d=$n[1]-$n[0];\n\t\t\t$dd=shift @n;\n\t\t\tfor $j(@n){\n\t\t\t\tif ($j-$dd!=$d){$B++}\n$B and last;\n\t\t\t\t$dd=$j;\n\t\t\t\t}\n\t\t\t$B or push @ats, \"$_ $d\\n\";\n\t\t\t$B or $a++;\n\t\t\t}\n\t\telsif ($m[$_]=~/^(\\d+) (\\d+)/){\n\t\t\t$d=$2-$1;\n\t\t\tpush @ats, \"$_ $d\\n\";\n\t\t\t$a++;\n\t\t\t}\n\t\telse {\n\t\t\tpush @ats, \"$_ 0\\n\"; $a++\n\t\t\t}\n\t\t}\n\t}\nprint \"$a\\n\";\nprint @ats", "positive_code": [{"source_code": "<>;\n@_=split/ /,<>;\n$a=0;\n$I=0;\nfor(@_){\n\t$I++;\n\t$m[$_].=\"$I \"\n\t}\nfor (1..10e5){\n\tif ($m[$_]){\n\t\tif ($m[$_]=~/\\S \\d+ \\S/){\n\t\t\tchop $m[$_];\n\t\t\t@n=split/ /,$m[$_];\n\t\t\t$B=0; \n\t\t\t$d=$n[1]-$n[0];\n\t\t\t$dd=shift @n;\n\t\t\tfor $j(@n){\n\t\t\t\tif ($j-$dd!=$d){$B++; last}\n\t\t\t\t$dd=$j;\n\t\t\t\t}\n\t\t\t$B or push @ats, \"$_ $d\\n\";\n\t\t\t$B or $a++;\n\t\t\t}\n\t\telsif ($m[$_]=~/^(\\d+) (\\d+)/){\n\t\t\t$d=$2-$1;\n\t\t\tpush @ats, \"$_ $d\\n\";\n\t\t\t$a++;\n\t\t\t}\n\t\telse {\n\t\t\tpush @ats, \"$_ 0\\n\"; $a++\n\t\t\t}\n\t\t}\n\t}\nprint \"$a\\n\";\nprint @ats"}, {"source_code": "<>;\n@_=split/ /,<>;\n$a=0;\n$I=0;\nfor(@_){\n\t$I++;\n\t$m[$_].=\"$I \"\n\t}\nfor (1..10e5){\n\tif ($m[$_]){\n\t\tif ($m[$_]=~/\\S \\d+ \\S/){\n\t\t\tchop $m[$_];\n\t\t\t@n=split/ /,$m[$_];\n\t\t\t$B=0; \n\t\t\t$d=$n[1]-$n[0];\n\t\t\t$dd=shift @n;\n\t\t\tfor $j(@n){\n\t\t\t\tif ($j-$dd!=$d){$B++}\n\t\t\t\t$dd=$j;\n\t\t\t\t}\n\t\t\t$B or $ats.=\"$_ $d\\n\";\n\t\t\t$B or $a++;\n\t\t\t}\n\t\telsif ($m[$_]=~/^(\\d+) (\\d+)/){\n\t\t\t$d=$2-$1;\n\t\t\t$ats.= \"$_ $d\\n\";\n\t\t\t$a++;\n\t\t\t}\n\t\telse {\n\t\t\t$ats.=\"$_ 0\\n\"; $a++\n\t\t\t}\n\t\t}\n\t}\nprint \"$a\\n$ats\";"}, {"source_code": "<>;\n@_=split/ /,<>;\n$a=0;\n$I=0;\nfor(@_){\n\t$I++;\n\t$m[$_].=\"$I \"\n\t}\nfor (1..10e5){\n\tif ($m[$_]){\n\t\tif ($m[$_]=~/\\S \\d+ \\S/){\n\t\t\tchop $m[$_];\n\t\t\t@n=split/ /,$m[$_];\n\t\t\t$B=0; \n\t\t\t$d=$n[1]-$n[0];\n\t\t\t$dd=shift @n;\n\t\t\tfor $j(@n){\n\t\t\t\tif ($j-$dd!=$d){$B++}\n\t\t\t\t$dd=$j;\n\t\t\t\t}\n\t\t\t$B or push @ats, \"$_ $d\\n\";\n\t\t\t$B or $a++;\n\t\t\t}\n\t\telsif ($m[$_]=~/^(\\d+) (\\d+)/){\n\t\t\t$d=$2-$1;\n\t\t\tpush @ats, \"$_ $d\\n\";\n\t\t\t$a++;\n\t\t\t}\n\t\telse {\n\t\t\tpush @ats, \"$_ 0\\n\"; $a++\n\t\t\t}\n\t\t}\n\t}\nprint \"$a\\n\";\nprint @ats"}, {"source_code": "<>;\n@_=split/ /,<>;\n$a=0;\n$I=0;\nfor(@_){\n\t$I++;\n\t$m[$_].=\"$I \"\n\t}\nfor (1..10e5){\n\tif ($m[$_]){\n\t\tif ($m[$_]=~/^(\\d+) (\\d+) (\\d+)/){\n\t\t\tchop $m[$_];\n\t\t\t@n=split/ /,$m[$_];\n\t\t\t$B=0; \n\t\t\t## for $i(@_){$I++;$i==$_ and push @n, $I}\n\t#\t\tprint \" @n\\n\";\n\t\t\t$d=$n[1]-$n[0];\n\t\t\t$dd=shift @n;\n\t\t\tfor $j(@n){\n\t\t\t\tif ($j-$dd!=$d){$B++}\n\t\t\t\t$dd=$j;\n\t\t\t\t}\n\t\t\t$B or $ats.=\"$_ $d\\n\";\n\t\t\t$B or $a++;\n\t\t\t}\n\t\telsif ($m[$_]=~/^(\\d+) (\\d+)/){\n\t\t\t\tchop $m[$_];\n\t\t##\t\t@n=(); $I=0; \n\t\t##\t\tfor $i(@_){$I++;$i==$_ and push @n, $I}\n\t#\t\t\tprint \" @n\\n\";\n\t\t\t\t$d=$2-$1;\n\t\t\t$ats.= \"$_ $d\\n\";\n\t\t\t$a++;\n\t\t\t}\n\t\telse {\n\t\t\t$ats.=\"$_ 0\\n\";\n\t\t\t$a++\n\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t}\nprint \"$a\\n$ats\";"}], "negative_code": [{"source_code": "<>;\n@_=split/ /,<>;\nfor(@_){\n\t$m[$_]++\n\t}\nfor (1..10e5){\n\tif ($m[$_]){\n\t\tif ($m[$_]>2){\n\t\t\t@n=(); $B=0; $I=0;\n\t\t\tfor $i(@_){$I++;$i==$_ and push @n, $I}\n\t#\t\tprint \" @n\\n\";\n\t\t\t$d=$n[1]-$n[0];\n\t\t\t$dd=shift @n;\n\t\t\tfor $j(@n){\n\t\t\t\tif ($j-$dd!=$d){$B++}\n\t\t\t\t$dd=$j;\n\t\t\t\t}\n\t\t\t$B or $ats.=\"$_ $d\\n\";\n\t\t\t$B or $a++;\n\t\t\t}\n\t\telsif ($m[$_]==2){\n\t\t\t\t@n=(); $I=0; \n\t\t\t\tfor $i(@_){$I++;$i==$_ and push @n, $I}\n\t#\t\t\tprint \" @n\\n\";\n\t\t\t\t$d=$n[1]-$n[0];\n\t\t\t$ats.= \"$_ $d\\n\";\n\t\t\t$a++;\n\t\t\t}\n\t\telse {\n\t\t\t$ats.=\"$_ 0\\n\";\n\t\t\t$a++\n\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t}\nprint \"$a\\n$ats\";"}], "src_uid": "097e35b5e9c96259c54887158ebff544"}
{"source_code": "use strict;\nuse warnings;\nmy %hash     = ();\nmy $distinct = 0;\nchomp(my ( $n, $k ) = split( \" \", <STDIN> ));\nchomp(my @array = split( \" \", <STDIN> ));\nfor my $elt (@array) {\n    if ( not exists $hash{$elt} ) {\n        $distinct++;\n        $hash{$elt}++;\n    }\n}\n\nif ( $distinct < $k ) {\n    print \"-1 -1\";\n    exit;\n}\n\nmy $first = $array[0];\n\nmy %hash2     = ($first => 1);\n\n\n\nmy $distinct2 = 1;\nmy $start     = 0;\nmy $end       = 0;\nfor ( my $i = 1 ; $i < @array ; $i++ ) {\n    if ( $distinct2 == $k ) {\n        last;\n    }\n    $end = $i;\n    if ( not exists $hash2{ $array[$i] } ) {\n        $hash2{ $array[$i] }++;\n        $distinct2++;\n    }\n    #print \"d = $distinct2, k = $k, start = $start, end = $end\\n\";\n    \n    if ( $array[$i] == $array[$start] ) {\n        $start++;\n    }\n}\n#print \"$start $end\\n\";\nmy $found = 1;\nwhile ($found) {\n    my $count = 0;\n    for ( my $i = $start ; $i <= $end ; $i++ ) {\n        if ( $i != $start && $array[$i] == $array[$start] ) {\n            $count++;\n            $start++;\n        }\n        if ($i != $end && $array[$i] == $array[$end] ) {\n            $count++;\n            $end--;\n        }\n    }\n    if ( $count == 0 ) { $found = 0; }\n}\n\n$start++;\n$end++;\nprint \"$start $end\";", "positive_code": [{"source_code": "$_ = <>;\n($n, $m) = split;\n$_ = <>;\n@_ = split;\n($l, $r) = (0, 0);\n$_{$_[$r++]} += 1 while $r < @_ && keys %_ < $m;\n\nif (keys %_ < $m) {\n    print '-1 -1';\n} else {\n    $_{$_[$l++]} -= 1 while $_{$_[$l]} > 1;\n    ++$l;\n    print \"$l $r\";\n}\n"}], "negative_code": [{"source_code": "$_ = <>;\n($n, $m) = split;\n$_ = <>;\n@_ = split;\n($l, $r) = (0, 0);\n$_{$_[$r++]} += 1 while $r < @_ && keys %_ < $m;\n\nif ($r == @_) {\n    print '-1 -1';\n} else {\n    $_{$_[$l++]} -= 1 while $_{$_[$l]} > 1;\n    ++$l;\n    print \"$l $r\";\n}\n"}, {"source_code": "use strict;\nuse warnings;\nmy %hash     = ();\nmy $distinct = 0;\nchomp(my ( $n, $k ) = split( \" \", <STDIN> ));\nchomp(my @array = split( \" \", <STDIN> ));\nfor my $elt (@array) {\n    if ( not exists $hash{$elt} ) {\n        $distinct++;\n        $hash{$elt}++;\n    }\n}\n\nif ( $distinct < $k ) {\n    print \"-1 -1\";\n    exit;\n}\n\nmy $first = $array[0];\n\nmy %hash2     = ($first => 1);\n\n\n\nmy $distinct2 = 1;\nmy $start     = 0;\nmy $end       = 0;\nfor ( my $i = 1 ; $i < @array ; $i++ ) {\n    $end = $i;\n    if ( not exists $hash2{ $array[$i] } ) {\n        $hash2{ $array[$i] }++;\n        $distinct2++;\n    }\n    print \"d = $distinct2, k = $k, start = $start, end = $end\\n\";\n    if ( $distinct2 == $k ) {\n        last;\n    }\n    if ( $array[$i] == $array[$start] ) {\n        $start++;\n    }\n}\nprint \"$start $end\\n\";\nmy $found = 1;\nwhile ($found) {\n    my $count = 0;\n    for ( my $i = $start ; $i <= $end ; $i++ ) {\n        if ( $i != $start && $array[$i] == $array[$start] ) {\n            $count++;\n            $start++;\n        }\n        if ($i != $end && $array[$i] == $array[$end] ) {\n            $count++;\n            $end--;\n        }\n    }\n    if ( $count == 0 ) { $found = 0; }\n}\n\n$start++;\n$end++;\nprint \"$start $end\";"}, {"source_code": "use strict;\nuse warnings;\nmy %hash     = ();\nmy $distinct = 0;\nchomp(my ( $n, $k ) = split( \" \", <STDIN> ));\nchomp(my @array = split( \" \", <STDIN> ));\nfor my $elt (@array) {\n    if ( not exists $hash{$elt} ) {\n        $distinct++;\n        $hash{$elt}++;\n    }\n}\n\nif ( $distinct < $k ) {\n    print \"-1 -1\";\n    exit;\n}\n\nmy $first = $array[0];\n\nmy %hash2     = ($first => 1);\n\n\n\nmy $distinct2 = 1;\nmy $start     = 0;\nmy $end       = 0;\nfor ( my $i = 1 ; $i < @array ; $i++ ) {\n    $end = $i;\n    if ( not exists $hash2{ $array[$i] } ) {\n        $hash2{ $array[$i] }++;\n        $distinct2++;\n    }\n    #print \"d = $distinct2, k = $k, start = $start, end = $end\\n\";\n    if ( $distinct2 == $k ) {\n        last;\n    }\n    if ( $array[$i] == $array[$start] ) {\n        $start++;\n    }\n}\n#print \"$start $end\\n\";\nmy $found = 1;\nwhile ($found) {\n    my $count = 0;\n    for ( my $i = $start+1 ; $i <= $end ; $i++ ) {\n        if ( $array[$i] == $array[$start] ) {\n            $count++;\n            $start++;\n        }\n    }\n    if ( $count == 0 ) { $found = 0; }\n}\n\n$start++;\n$end++;\nprint \"$start $end\";"}, {"source_code": "use strict;\nuse warnings;\nmy %hash     = ();\nmy $distinct = 0;\nchomp(my ( $n, $k ) = split( \" \", <STDIN> ));\nchomp(my @array = split( \" \", <STDIN> ));\nfor my $elt (@array) {\n    if ( not exists $hash{$elt} ) {\n        $distinct++;\n        $hash{$elt}++;\n    }\n}\n\nif ( $distinct < $k ) {\n    print \"-1 -1\";\n    exit;\n}\n\nmy $first = $array[0];\n\nmy %hash2     = ($first => 1);\n\n\n\nmy $distinct2 = 1;\nmy $start     = 0;\nmy $end       = 0;\nfor ( my $i = 1 ; $i < @array ; $i++ ) {\n    $end = $i;\n    if ( not exists $hash2{ $array[$i] } ) {\n        $hash2{ $array[$i] }++;\n        $distinct2++;\n    }\n    #print \"d = $distinct2, k = $k, start = $start, end = $end\\n\";\n    if ( $distinct2 == $k ) {\n        last;\n    }\n    if ( $array[$i] == $array[$start] ) {\n        $start++;\n    }\n}\n#print \"$start $end\\n\";\nmy $found = 1;\nwhile ($found) {\n    my $count = 0;\n    for ( my $i = $start ; $i <= $end ; $i++ ) {\n        if ( $i != $start && $array[$i] == $array[$start] ) {\n            $count++;\n            $start++;\n        }\n        if ($i != $end && $array[$i] == $array[$end] ) {\n            $count++;\n            $end--;\n        }\n    }\n    if ( $count == 0 ) { $found = 0; }\n}\n\n$start++;\n$end++;\nprint \"$start $end\";"}, {"source_code": "use strict;\nuse warnings;\nmy %hash     = ();\nmy $distinct = 0;\nchomp(my ( $n, $k ) = split( \" \", <STDIN> ));\nchomp(my @array = split( \" \", <STDIN> ));\nfor my $elt (@array) {\n    if ( not exists $hash{$elt} ) {\n        $distinct++;\n        $hash{$elt}++;\n    }\n}\n\nif ( $distinct < $k ) {\n    print \"-1 -1\";\n    exit;\n}\n\nmy $first = $array[0];\n\nmy %hash2     = ($first => 1);\n\n\n\nmy $distinct2 = 1;\nmy $start     = 0;\nmy $end       = 0;\nfor ( my $i = 1 ; $i < @array ; $i++ ) {\n    $end = $i;\n    if ( not exists $hash2{ $array[$i] } ) {\n        $hash2{ $array[$i] }++;\n        $distinct2++;\n    }\n    #print \"d = $distinct2, k = $k, start = $start, end = $end\\n\";\n    if ( $distinct2 == $k ) {\n        last;\n    }\n    if ( $array[$i] == $array[$start] ) {\n        $start++;\n    }\n}\n#print \"$start $end\\n\";\nmy $found = 1;\nwhile ($found) {\n    my $count = 0;\n    for ( my $i = $start+1 ; $i < $end ; $i++ ) {\n        if ( $array[$i] == $array[$start] ) {\n            $count++;\n            $start++;\n        }\n        if ( $array[$i] == $array[$end] ) {\n            $count++;\n            $end--;\n        }\n    }\n    if ( $count == 0 ) { $found = 0; }\n}\n\n$start++;\n$end++;\nprint \"$start $end\";"}], "src_uid": "4b423274448ff3f0dee7644203706805"}
{"source_code": "\n\n\n\n\nsub count_disjoint_sets {\n\n    my $ds_ref = $_[0];\n    my %count = ();\n    for my $i (values %{ $ds_ref }) {\n\t$count { $i } = 1;\n    }\n    return (scalar (keys %count));\n}\n\n\n\nsub make_disjoint_sets {\n\n    my ($e_ref, $l_ref, $ds_ref,\n\t$v_ref, $person, $id ) = @_;\n\n    # return if we've already visited this person\n    if ( exists $v_ref -> { $person } ) {\n\treturn;\n    }\n    # mark visited\n    $v_ref -> { $person } = 1;\n    # add to dijoint set\n    $ds_ref -> { $person } = $id;\n\n    for my $i ( keys %{ $l_ref -> { $person } } ) {\n\tfor my $j ( keys %{ $e_ref -> { $i } } ) {\n\t    &make_disjoint_sets ( $e_ref, $l_ref, $ds_ref,\n\t\t\t\t  $v_ref, $j, $id );\n\t}}\n}\n\n\n\n\n\n\n\nmy $f = <STDIN>;\nchomp ( $f );\nmy ($n, $m) = split m/ /, $f;\n\nmy %emp_of_langs;\nmy %langs_of_emp;\nmy @lst;\nmy $language_exists = 0;\nmy $val;\nfor my $i (1..$n) {\n    $val = 0;\n    @lst = ();\n    $f = <STDIN>;\n    chomp ( $f );\n    @lst = split m/ /, $f;\n    $val = shift @lst;\n    if ( $val > 0 ) {\n\t$language_exists = 1;\n    }\n    for my $j (@lst) {\n\t$langs_of_emp{ $i }{ $j } = 1;\n\t$emp_of_langs{ $j }{ $i } = 1;\n    }\n}\n\n\n\nmy %ds = ();\nmy %visit = ();\n\n# initialize disjoint set\nfor my $i (1..$n) {\n    $ds { $i } = $i;\n}\n\nfor my $i (1..$n) {\n    &make_disjoint_sets ( \\%emp_of_langs, \\%langs_of_emp, \\%ds,\n\t\t\t  \\%visit, $i, $i );\n}\n\nmy $answer = &count_disjoint_sets ( \\%ds );\n\nif ( not $language_exists ) {\n    print $answer;\n    print \"\\n\";\n}\nelse {\n    print ($answer - 1);\n    print \"\\n\";\n}\n\n", "positive_code": [{"source_code": "$_ = <>;\ns/^\\d+ //;\nchomp;\n$m = $_;\n\nwhile (<>){\n    s/^\\d+ ?//;\n    chomp;\n    if (!$_) {++$sum; next};\n    push @m, $_;\n}\n\nfor $i(1..$m){\n    @a = @b = ();\n    for (@m){\n        if (/\\b$i\\b/){\n            push @a, $_;\n            }\n        else{\n            push @b, $_;\n            }\n        } \n    $a = join\" \",@a;\n    @b? (@m = @b):(@m=());\n    $a and unshift @m, $a\n}\n\n$sum += scalar @m;    \n@m and $sum --;\nprint \"$sum\\n\";"}], "negative_code": [{"source_code": "\n\n\n\n\nsub count_disjoint_sets {\n\n    my $ds_ref = $_[0];\n    my %count = ();\n    for my $i (values %{ $ds_ref }) {\n\t$count { $i } = 1;\n    }\n    return (scalar (keys %count));\n}\n\n\n\nsub make_disjoint_sets {\n\n    my ($e_ref, $l_ref, $ds_ref,\n\t$v_ref, $person, $id ) = @_;\n\n    # return if we've already visited this person\n    if ( exists $v_ref -> { $person } ) {\n\treturn;\n    }\n    # mark visited\n    $v_ref -> { $person } = 1;\n    # add to dijoint set\n    $ds_ref -> { $person } = $id;\n\n    for my $i ( keys %{ $l_ref -> { $person } } ) {\n\tfor my $j ( keys %{ $e_ref -> { $i } } ) {\n\t    &make_disjoint_sets ( $e_ref, $l_ref, $ds_ref,\n\t\t\t\t  $v_ref, $j, $id );\n\t}}\n}\n\n\n\n\n\n\n\nmy $f = <STDIN>;\nchomp ( $f );\nmy ($n, $m) = split m/ /, $f;\n\nmy %emp_of_langs;\nmy %langs_of_emp;\nmy @lst;\nfor my $i (1..$n) {\n    @lst = ();\n    $f = <STDIN>;\n    chomp ( $f );\n    @lst = split m/ /, $f;\n    shift @lst;\n\n    for my $j (@lst) {\n\t$langs_of_emp{ $i }{ $j } = 1;\n\t$emp_of_langs{ $j }{ $i } = 1;\n    }\n}\n\n\n\nmy %ds = ();\nmy %visit = ();\n\n\nfor my $i (1..$n) {\n    &make_disjoint_sets ( \\%emp_of_langs, \\%langs_of_emp, \\%ds,\n\t\t\t  \\%visit, $i, $i );\n}\n\n\nmy $answer = &count_disjoint_sets ( \\%ds );\n\nprint ($answer - 1);\nprint \"\\n\";\n\n\n"}], "src_uid": "e2836276aee2459979b232e5b29e6d57"}
{"source_code": "( $n, $k, $m, $ok ) = split ' ', <>;\n\npush @{ $h{ $_ % $m + 1 } }, $_ for split ' ', <>;\n\n@{ $h{ $_ } } < $k or $ok = $_ for keys %h;\n\nprint $ok ? \"Yes\\n@{ $h{ $ok } }[ 0 .. $k - 1 ]\" : \"No\"", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k, $m ) = split;\n\t@_ = split ' ', <>;\n\tmy %h;\n\t\n\tfor( @_ ){\n\t\tpush @{ $h{ $_ % $m } }, $_;\n\t\t}\n\t\n\tmy $ok = -1;\n\t\n\tfor( keys %h ){\n\t\t@{ $h{ $_ } } >= $k and do {\n\t\t\t$ok = $_;\n\t\t\tlast;\n\t\t\t};\n\t\t}\n\t\n\tprint $ok == -1 ? \"No\" : \"Yes\\n@{ $h{ $ok } }[ 0 .. $k - 1 ]\";\n\t\n\t}"}], "negative_code": [{"source_code": "( $n, $k, $m, $ok ) = split ' ', <>;\n\npush @{ $h{ $_ % $m + 1 } }, $_ for split ' ', <>;\n\n@{ $h{ $_ } } < $k or $ok = $_ for keys %h;\n\nprint $ok ? \"No\" : \"Yes\\n@{ $h{ $ok } }[ 0 .. $k - 1 ]\""}], "src_uid": "55bd1849ef13b52788a0b5685c4fcdac"}
{"source_code": "while (<>){\n    @m=split/ /,<>;\n    @_=();\n    while (@m){\n        $_[shift @m]++\n        }\n    $max=$n=0;\n    for (@_){\n        $_ and $n++;\n        $_>$max and $max=$_;        \n        }\n        \n    print \"$max $n\\n\";\n    }", "positive_code": [{"source_code": "<>;\nmy %hash;\nmy $max  = 0;\nfor(split / /, <>) {\n    $hash{int$_}++;\n    $max = $hash{int$_} if ($hash{int$_} > $max);\n}\nprint ($max . \" \" . scalar keys %hash);\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n$tb{int($_)}++ foreach (split / /, <>);\n@a = keys %tb;\n($mx, $ans) = (0, scalar @a);\n$mx=$mx>$tb{$_} ? $mx:$tb{$_} foreach (@a);\nsay \"$mx $ans\";"}], "negative_code": [], "src_uid": "9a92221c760a3b6a1e9318f948fe0473"}
{"source_code": "#!perl\nsub max\n{\n    my $max = 0; \n    my @a = @{$_[0]};\n    for my $i (@a)\n    {\n        $max = $max < $i ?  $i : $max;\n    }\n    return $max;\n} \n\n$\\ = \"\\n\";\n$n = <>;\n@a = split /\\s/, <>;\n\nfor my $i (0..$#a)\n{\n    $h{@a[$i]} = [] if !$h{@a[$i]};\n    push @{$h{@a[$i]}}, $i;\n} \n\n@keys = sort {$b <=> $a} (keys %h);\n\nfor my $i (0..$#keys)\n{\n    $max = max($h{@keys[$i]});\n    push @a1, [$max, @a[$max]];\n}\n\n@a1 = sort {@{$b}[1] <=> @{$a}[1]} @a1;\n\n$local_max_index = 0;\n@marks = (-1);\npush @marks, @{@a1[0]}[0];\n\nfor my $i (1..$#a1)\n{\n    if (@{@a1[$i]}[0] > @{@a1[$local_max_index]}[0])\n    {\n        $local_max_index = $i; \n        push @marks, @{@a1[$local_max_index]}[0];\n    }\n}\n\nfor my $i (0..$#marks - 1)\n{\n    for my $j (@marks[$i] + 1..@marks[$i + 1])\n    {\n        @a2[$j] = @a[@marks[$i + 1]] - @a[$j];\n        @a2[$j]++ if $j != @marks[$i + 1];\n    }\n}\n\nprint \"@a2\";", "positive_code": [{"source_code": "<>;\nprint join q{ }, reverse\n    map {\n    $_ > ( $m // 0 )\n        ? do { $m = $_; 0 }\n        : ( $m + 1 )\n        - $_\n    }\n    reverse split / /,\n    <>;\n"}, {"source_code": "$n=<>;\n@h=split ' ',<>;\n$el[$n-1]=$h[$n-1];\nfor ($i=$n-2; $i>=0; $i--)\n{\n\tif ($h[$i]>$el[$i+1])\n\t{\n\t\t$el[$i]=$h[$i];\n\t}\n\telse\n\t{\n\t\t$el[$i]=$el[$i+1];\n\t}\n}\nfor ($i=0; $i<$n-1; $i++)\n{\n\tif ($el[$i+1]>=$h[$i])\n\t{\n\t\tprint $el[$i]-$h[$i]+1;\n\t}\n\telse\n\t{\n\t\tprint '0';\n\t}\n\tprint ' ';\n}\nprint '0';"}, {"source_code": "($_ > $max and $max = $_), unshift @a, $max for reverse @_ = split ' ', (<>, <>); \nshift @a;\nprint join ' ', map { (sort {$b <=> $a} ( (shift @a) - $_ + 1, 0) )[0] } @_"}], "negative_code": [{"source_code": "<>;\nprint join q{ }, reverse\n    map { $m = $_ > ( $m // 0 ) ? $_ : $m; $_ >= $m ? 0 : ( $m + 1 ) - $_ }\n    reverse split / /, <>;"}, {"source_code": "#!perl\n$\\ = \"\\n\";\n$n = <>;\n@a = split /\\s/, <>;\n\nfor my $i (0..$#a)\n{\n    push @a1, [$i, @a[$i]];\n} \n\n@a1 = sort {@{$b}[1] <=> @{$a}[1]} @a1;\n\n$local_max_index = 0;\n@marks = (-1);\npush @marks, @{@a1[0]}[0];\n\nfor my $i (1..$#a)\n{\n    if (@{@a1[$i]}[0] > @{@a1[$local_max_index]}[0])\n    {\n        $local_max_index = $i; \n        push @marks, @{@a1[$local_max_index]}[0];\n    }\n}\n\nfor my $i (0..$#marks - 1)\n{\n    for my $j (@marks[$i] + 1..@marks[$i + 1])\n    {\n        @a2[$j] = @a[@marks[$i + 1]] - @a[$j];\n        @a2[$j]++ if @a2[$j] != 0;\n    }\n}\n\nprint \"@a2\";"}, {"source_code": "#!perl\n$\\ = \"\\n\";\n$n = <>;\n@a = split /\\s/, <>;\n\nfor my $i (0..$#a)\n{\n    push @a1, [$i, @a[$i]];\n} \n\n@a1 = sort {@{$b}[1] <=> @{$a}[1]} @a1;\n\n$local_max_index = 0;\n@marks = (-1);\npush @marks, @{@a1[0]}[0];\n\nfor my $i (1..$#a)\n{\n    if (@{@a1[$i]}[0] > @{@a1[$local_max_index]}[0])\n    {\n        $local_max_index = $i; \n        push @marks, @{@a1[$local_max_index]}[0];\n    }\n}\n\nfor my $i (0..$#marks - 1)\n{\n    for my $j (@marks[$i] + 1..@marks[$i + 1])\n    {\n        @a2[$j] = @a[@marks[$i + 1]] - @a[$j] + 1;\n    }\n}\n\nprint \"@a2\";"}], "src_uid": "e544ed0904e2def0c1b2d91f94acbc56"}
{"source_code": "$, = $/;\n($n, $k) = split \" \", <>;\n$_ = reverse 'S' x $n ** 2 . join 'S', ('L') x $k;\npush @_, ++ $i % 2 ? $& : scalar reverse $& while /.{$n}/g and $i < $n;\nprint $k == (() = \"@_\" =~ /L/g) ? ('YES', @_) : 'NO'", "positive_code": [{"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $l = <>;\nchomp $l;\n$l =~ /^(\\d+) (\\d+)$/;\nmy $n = $1;\nmy $k = $2;\n\nmy @res;\nfor (1..$n) {\n  my $line = [];\n  for (1..$n) {\n    push(@{$line}, 'S');\n  }\n  push(@res, $line);\n}\n\nmy ($i, $j) = (0, 0);\nmy $f = 1;\nwhile ($k > 0) {\n  $res[$j][$i] = 'L';\n  $i += 2;\n  $k--;\n  if ($i >= $n) {\n    if ($f == 1) {\n      $i = 1;\n      $f = 0;\n    } else {\n      $i = 0;\n      $f = 1;\n    }\n    $j++;\n    if ($j >= $n) {\n      last;\n    }\n  }\n}\n\nif ($k == 0) {\n  print \"YES\\n\";\n  foreach my $line (@res) {\n    print join('', @{$line}), \"\\n\";\n  }\n} else {\n  print \"NO\\n\";\n}\n\n"}], "negative_code": [{"source_code": "$, = $/;\n($n, $k) = split \" \", <>;\n$_ = reverse 'S' x $n ** 2 . join 'S', ('L') x $k;\npush @_, ++ $i % 2 ? $& : + reverse $& while /.{$n}/g and $i < $n;\nprint $k == (() = \"@_\" =~ /L/g) ? ('YES', @_) : 'NO'"}], "src_uid": "b15bc7ff01f239a7e4377868a7dda0a6"}
{"source_code": "#!/bin/usr/perl\n\nmy $t=<>;\nchomp($t);\nwhile ($t--){\n\tmy $line = <>;\n\tchomp($line);\n\t@numbers = split(\" \",$line);\n\tmy $a = $numbers[0];\n\tmy $b = $numbers[1];\n\tprint($a+$b);\n\tprint(\"\\n\");\n}", "positive_code": [{"source_code": "s# #print$`+$',$/#e for<>"}, {"source_code": "<>;s# #print$`+$',$/#e while<>"}], "negative_code": [], "src_uid": "27ddccc777ef9040284ab6314cbd70e7"}
{"source_code": "$,=\" \";\nmy $n=<>;\nchomp($n);\n$n--;\nmy ($x,$y)=split / /,<>;\nchomp($x,$y);\nmy $amount=$y;\nmy $cost=$x*$amount;\nwhile($n--)\n{\n  ($x,$y)=split / /,<>;\n  chomp($x,$y);\n  if($y<$amount)\n  {\n    $amount=$y;\n  }\n  $cost+=$x*$amount;\n}\nprint $cost , \"\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nmy $n = <>;\nmy $cheapest = 101;\nmy $cost;\nwhile ($n--) {\n\tchomp(my $line = <>);\n\tmy ($a, $p) = split / /, $line;\n\t$cheapest = $p if $p < $cheapest;\n\t$cost += $a * $cheapest;\n}\nprint $cost;\n"}, {"source_code": "<>;\n$min = ~0;\n( $min > (split)[1] and $min = (split)[1] ), $sum += $_ * $min for <>;\nprint $sum"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub argmin {\n  my ($aref) = @_;\n\n  my $argmin = 0;\n  for my $i (1..$#$aref) {\n    if ($aref->[$i] < $aref->[$argmin]) {\n      $argmin = $i;\n    }\n  }\n  $argmin;\n}\n\nsub sum_range {\n  my ($aref, $l, $r) = @_;\n\n  my $sum = 0;\n  for my $i ($l..$r) {\n    $sum += $aref->[$i];\n  }\n  $sum;\n}\n\nmy @eat;\nmy @price;\n\nmy $n = <>;\nfor (1..$n) {\n  my ($eat, $price) = split ' ', <>;\n  push @eat, $eat;\n  push @price, $price;\n}\n\nmy $cost = 0;\n\nwhile (@eat) {\n  my $i = argmin(\\@price);\n  $cost += $price[$i] * sum_range(\\@eat, $i, $#eat);\n  splice @price, $i;\n  splice @eat, $i;\n}\n\nsay $cost;\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    chomp;\n    $n = $_;\n    @p = ();\n    @a = ();\n    \n    for ( 1..$n ) {\n        $line = <>;\n        chomp($line);\n        ($a0, $p0) = split / /, $line;\n        \n        push @a, $a0;\n    \n            if ( ($len = @p) == 0 || $p0 < $p[-1] ) {\n                push @p, $p0;\n            } else {\n                push @p, $p[-1];\n            }\n    \n    }\n    $sum = 0;\n    \n    for ( 0..($n-1) ) {\n        $sum += $a[$_] * $p[$_];\n    }\n    $\\ = $/;    \n    print $sum;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse warnings;\nuse strict;\n\n<>;\nmy $m = 111;\nmy $ans;\nfor(<>)\n{\n    my ($a, $p) = split(' ', $_);\n    $m = ($p < $m) ? $p : $m;\n    \n    $ans += $a * $m;\n}\n\nprint $ans;\n"}, {"source_code": "<>;\n$min = ~0;\n( $min > (split)[1] and $min = (split)[1] ), $sum += $_ * $min for <>;\nprint $sum"}], "negative_code": [], "src_uid": "28e0822ece0ed35bb3e2e7fc7fa6c697"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $n = <STDIN>;\n\nmy @first = split(' ', <STDIN>);\nmy @second = split(' ', <STDIN>);\n\nmy %set;\n\nshift @first;\nshift @second;\nforeach my $level ((@first, @second))\n{\n    unless ($level == 0)\n    {\n        $set{$level} = 1;\n    }\n}\nmy $size = keys %set;\nif ($size == $n) {\n    print \"I become the guy.\";\n}\nelse {\n    print \"Oh, my keyboard!\";\n}", "positive_code": [{"source_code": "my $n = <>;\n($na, @a) = split \" \", <>;\n($nb, @b) = (split \" \", <>);\npush @b, @a;\n\n%k = ();\ngrep { $k{$_} = $_ } @b;\n\nprint scalar keys %k == $n? \"I become the guy.\\n\" : \"Oh, my keyboard!\\n\";"}, {"source_code": "my $n = <>;\nmy %hash;\nmy @a = split \" \", <>;\nmy @b = split \" \", <>;\nshift @a;\nshift @b;\n$hash{$_} = 0 foreach(1..$n);\n$hash{$_} = 1 foreach(@a);\n$hash{$_} = 1 foreach(@b);\nmy $ans = \"I become the guy.\\n\";\nforeach(values %hash) {\n    $ans = \"Oh, my keyboard!\\n\" if ($_ == 0);\n}\nprint $ans;\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\nmy %tb;\n@a = split / /, <>;\n$tb{int($_)}=1 foreach(@a[1..$#a]);\n@a = split / /, <>;\n$tb{int($_)}=1 foreach(@a[1..$#a]);\nscalar(keys %tb)==$n and say \"I become the guy.\" or say \"Oh, my keyboard!\";\n"}, {"source_code": "chomp (my $n = <>);\n\nchomp (my @ps = split / /, <>);\nchomp (my @qs = split / /, <>);\n\nshift @ps;\nshift @qs;\n\nmy %ls;\n\n$ls{$_}++ foreach (@ps, @qs);\n\nif ((scalar keys %ls) == $n) {\n  printf \"I become the guy.\\n\";\n} else {\n  printf \"Oh, my keyboard!\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n#pass array by reference\n\n\nmy $n = <>;\nmy @arr = (0) x $n;\nmy @arr1 = split(' ',<>); shift(@arr1);\nmy @arr2 = split(' ',<>); shift(@arr2);\n\nforeach(@arr1){\n    $arr[$_-1] = 1;\n}\nforeach(@arr2){\n    $arr[$_-1] = 1;\n}\nmy $yes = 1;\nforeach(@arr){\n    if($_ == 0){\n        $yes=0;\n        last;\n    }\n}\nif($yes == 1){\n    print \"I become the guy.\\n\";\n}\nelse{\n    print \"Oh, my keyboard!\\n\";\n}\n"}], "negative_code": [{"source_code": "my $n = <>;\nmy %hash;\nmy @a = split \" \", <>;\npush @a, split \" \", <>;\n$hash{$_} = 0 foreach(1..$n);\n$hash{$_} = 1 foreach(@a);\nmy $ans = \"I become the guy.\\n\";\nforeach(values %hash) {\n    $ans = \"Oh, my keyboard!\\n\" if ($_ == 0);\n}\nprint $ans;"}, {"source_code": "my $n = <>;\n\nmy @ps = split / /, <>;\nmy @qs = split / /, <>;\n\nshift @ps;\nshift @qs;\n\nmy %ls;\n\n$ls{$_}++ foreach (@ps, @qs);\n\nif (scalar keys %ls == $n) {\n  printf \"I become the guy.\\n\";\n} else {\n  printf \"Oh, my keyboard!\\n\";\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n\nmy $n = <>;\nmy @arr = (0) x $n;\nmy @arr1 = split(' ',readline);\nmy @arr2 = split(' ',readline);\n\nforeach(@arr1){\n    $arr[$_-1] = 1;\n}\nforeach(@arr2){\n    $arr[$_-1] = 1;\n}\nmy $yes = 1;\nforeach(@arr){\n    if($_ == 0){\n        $yes=0;\n        last;\n    }\n}\nif($yes == 1){\n    print \"I become the guy.\\n\";\n}\nelse{\n    print \"Oh, my keyboard!\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $n = <STDIN>;\n\nmy @first = split(' ', <STDIN>);\nmy @second = split(' ', <STDIN>);\n\nmy %set;\n\nforeach my $level ((@first, @second))\n{\n    unless ($level != 0)\n    {\n        $set{$level} = 1;\n    }\n}\nmy $size = keys %set;\nif ($size == $n) {\n    print \"I become the guy.\";\n}\nelse {\n    print \"Oh, my keyboard!\";\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $n = <STDIN>;\n\nmy @first = split(' ', <STDIN>);\nmy @second = split(' ', <STDIN>);\n\nmy %set;\n\nforeach my $level ((@first, @second))\n{\n    $set{$level} = 1;\n}\nmy $size = keys %set;\nif ($size == $n) {\n    print \"I become the guy.\";\n}\nelse {\n    print \"Oh, my keyboard!\";\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $n = <STDIN>;\n\nmy @first = split(' ', <STDIN>);\nmy @second = split(' ', <STDIN>);\n\nmy %set;\n\nforeach my $level ((@first, @second))\n{\n    unless ($level == 0)\n    {\n        $set{$level} = 1;\n    }\n}\nmy $size = keys %set;\nif ($size == $n) {\n    print \"I become the guy.\";\n}\nelse {\n    print \"Oh, my keyboard!\";\n}"}], "src_uid": "044ade01d2de1486735742369227ae1d"}
{"source_code": "<>;\n@_ = split ' ', <>;\n\nfor (0 .. @_ - 1){\n\t++ ($_[$_] == $_ + 1 ? $j : $h{ $_[$_] } )\n\t}\n\nprint $j + (keys %h) / 2", "positive_code": [{"source_code": "<>;\n\nmap { \n    ++ ( ++ $i == $_ ? $j : $h{ $_ } ) \n    } <> =~ /\\d+/g;\n\t\nprint $j + (keys %h) / 2"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n#while(<>){\n\t\n\t<>;\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\tmy $j = 0;\n\t\n\tfor my $i (0 .. @_ - 1){\n\t\t$_[$i] == $i + 1 ? $j ++ : ($h{ $_[$i] } = 1);\n\t\t}\n\t\n\tprint $j + (keys %h) / 2;\n\t\n#\t}"}], "negative_code": [], "src_uid": "6d940cb4b54f63a7aaa82f21e4c5b994"}
{"source_code": "@_ = <>;\n\n%h = map { reverse split } grep !/;/, @_;\n\nprint s/(\\S+);\\K/ #$h{ $1 }/r for grep /;/, @_", "positive_code": [{"source_code": "( $n, $m ) = split ' ', <>;\n\n%h = map { reverse split ' ', <> } 1 .. $n;\n\nprint <> =~ s/(\\S+);\\K/ #$h{ $1 }/r for 1 .. $m"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tmy %h;\n\t\n\tmap { my( $name, $ip ) = ( split ' ', <> ); $h{ $ip }{ name } = $name } 1 .. $n;\n\t\n\tfor( 1 .. $m ){\n\t\tmy( $comm, $ip ) = split ' ', <>;\n\t\tchop $ip;\n\t\t\n\t\tprint \"$comm $ip; #$h{ $ip }{ name }\"\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "94501cd676a9214a59943b8ddd1dd31b"}
{"source_code": "<> =~ / /;\n\n@_ = split ' ', <>;\n\nprint +(\n\tsort { $a <=> $b } @_[ -1 .. ( $' == 2 ? 0 : @_ - 2 ) ]\n\t)[ 1 <=> $' ]", "positive_code": [{"source_code": "<> =~ / /;\n\n@_ = split ' ', <>;\n\nprint +( do {\n\tif( $' == 1 ){\n\t\tsort { $a <=> $b } @_\n\t\t}\n\telsif( $' > 2 ){\n\t\tsort { $b <=> $a } @_\n\t\t}\n\telse{\n\t\tsort { $b <=> $a } @_[0,-1]\n\t\t}\n\t}\n\t)[ 0 ]"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t@_ = split ' ', <>;\n\t\n\tprint do {\n\t\tif( $k == 1 ){\n\t\t\t( sort { $a <=> $b } @_ )[ 0 ]\n\t\t\t}\n\t\telsif( $k > 2 ){\n\t\t\t( sort { $b <=> $a } @_ )[ 0 ]\n\t\t\t}\n\t\telse{\n\t\t\t( sort { $b <=> $a } @_[0,-1] )[ 0 ]\n\t\t\t}\n\t\t};\n\t}"}], "negative_code": [{"source_code": "<> =~ / /;\n\t\nprint +(\n\tsort { $a <=> $b } ( @_ = split ' ', <> )[ -1 .. ( $' == 2 ? 0 : @_ - 2 ) ]\n\t)[ 1 <=> $' ]"}, {"source_code": "<> =~ / /;\n\t\nprint +(\n\tsort { $a <=> $b } ( split ' ', <> )[ -1 .. ( $' == 2 ? 0 : @_ - 2 ) ]\n\t)[ 1 <=> $' ]"}, {"source_code": "<> =~ / /;\n\t\nprint +(\n\tsort { $a <=> $b } ( split ' ', <> )[ -1 .. ( $' == 2 ? 0 : 2e5 ) ]\n\t)[ 1 <=> $' ]"}], "src_uid": "ec1a29826209a0820e8183cccb2d2f01"}
{"source_code": "use feature ':all';\n\nwhile(<>){\n\t$sum = 0;\n\t\n\tfor (1 .. $_){\n\t\t$_ = <>, chomp;\n\t\t$n = (() = /C/g);\n\t\t$sum += $n *~- $n / 2;\n\t\t$i = 0; map $A[ $i++ ] .= $_, split //;\n\t\t}\n\t\n\tfor (@A){\n\t\t$n = (() = /C/g);\n\t\t$sum += $n *~- $n / 2;\n\t\t}\n\t\n\tsay $sum\n\t}", "positive_code": [{"source_code": "$n=<>;\nmy @x;\nfor($i=0;$i<$n;$i++) {\n    $x[$i]=0;\n}\n$ans=0;\nfor($i=0;$i<$n;$i++) {\n    $a=<>;\n    $d=0;\n    $e=0;\n    foreach my $c (split '', $a) {\n        if ($c eq 'C') {\n            $e++;\n            $x[$d]++;\n        }\n        $d++;\n    }\n    $ans+=$e*($e-1)/2;\n}\nfor($i=0;$i<$n;$i++) {\n    $ans+=$x[$i]*($x[$i]-1)/2;\n}\nprint \"$ans\\n\";\n"}], "negative_code": [], "src_uid": "7749f37aa9bf88a00013557e14342952"}
{"source_code": "<>; print <> =~ /1/ ? \"YES\\n\" : \"NO\\n\" while <>", "positive_code": [{"source_code": "<>; print <> =~ /1/ ? \"YES\\n\" : \"NO\\n\" while <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $A = grep m/1/, @_;\n\t\n\tprint $A ? 'YES' : 'NO';\n\t}"}, {"source_code": "<>; print <> =~/1/ ? \"YES\\n\" : \"NO\\n\" while<>"}, {"source_code": "<>; print <> =~/1/ ? \"YES\\n\" : \"NO\\n\" while <>"}, {"source_code": "#!/usr/bin/perl\nuse Data::Dumper;\nuse integer;   ### important!\nmy $mod = 10 ** 9 + 7;\n# my $mod = 998244353;\n\nmy ($testcase) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nwhile( $testcase -- > 0 ){\n  \n  my ($n,$k) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  my $c1 = 0; my $c0 = 0;\n  for(my $i=0;$i<$n;$i++){\n    $c1++ if( $A[$i] == 1 );\n    $c0++ if( $A[$i] == 0 );\n  }\n  if( $c0 == 0 ){\n    print \"YES\\n\"; next;\n  }\n  if( $c1 == 0 ){\n    print \"NO\\n\"; next;\n  }\n  if( $k > $n ){\n    print \"NO\\n\"; next;\n  }\n  print \"YES\\n\";\n\n}\n\nexit(0);\n\nsub max {\n  my $r = undef;\n  foreach my $e (@_){  $r = $e if !defined($r) or $e > $r;  }\n  return $r;\n}\nsub min {\n  my $r = undef;\n  foreach my $e (@_){  $r = $e if !defined($r) or $e < $r;  }\n  return $r;\n}\nsub sum {\n  my $r = 0;\n  foreach my $e (@_){ $r += $e; }\n  return $r;\n}\nsub ruisum {   # my @rui = (0); &ruisum(\\@rui,\\@array);\n  my $r = shift; my $ar = shift;\n  $#{$r} = 1+$#{$ar}; $r->[0] = 0; my $rr = 0;\n  for(my $i=0;$i<=$#ar;$i++){ \n    $rr += $ar->[$i];\n    $r->[1+$i] = $rr;\n  }\n}\n"}], "negative_code": [], "src_uid": "95d83cfdb2131f2f23ba5ef005c18b38"}
{"source_code": "<>;for (split(' ',<>)) {\n\t$l+=$_;\n\t$m=$_ if $_>$m;\n};\nprint 2*$m-$l+1;\n", "positive_code": [{"source_code": "sub solve {\n\tmy $n = shift;\n\tmy @a = split(\" \", shift);\n\tmy $s = 0;\n\tfor my $x (@a) {\n\t\t$s += $x;\n\t}\n\tmy $res = 0;\n\tfor my $x (@a) {\n\t\tmy $tmp = 2 * $x - $s;\n\t\tif ($res < $tmp) {\n\t\t\t$res = $tmp;\n\t\t}\n\t}\n\treturn $res + 1;\n};\n\nmy $n = <>;\nmy $input = <>;\nprint solve($n, $input);"}], "negative_code": [], "src_uid": "f00d94eb37c98a449615f0411e5a3572"}
{"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n", "positive_code": [{"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)"}, {"source_code": "<>;\n/G\\**S/ ? ++$d[length $&] : ++$f for <>;\n$_ && $j++ for @d;\nprint $f? -1 : $j"}, {"source_code": "sub uniq{\n\tmy @m=sort @_; my @u;\n\tpush @u, my $i=shift @m;\n\t$i eq $_ or push @u, $i=$_ for @m;\nreturn @u\n}\nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n\nwhile(<>){\n\t($n,$m)=split/ /;\n\t@distance=(); # empty\n\t@end=();\n\t$f=1;\n\tfor $i(1..$n){\n\t\t\n\t\t$_=<>;\n\t\t/G\\**S/ and (($distance[length($&)]++), next);\n\t\t$f=0;\n\t\t}\n\t$j=0;\n\t$_ and $j++ for @distance;\n\tprintf \"%d\\n\", $f? ( $j ) : -1;\n\t\n\t\n\t}\n\t\n"}, {"source_code": "<>;\n/G\\**S/ ? $_[length $&]=1 : ++$f for <>;\nprint $f? -1 : ($D=()=\"@_\"=~/1/g)\n"}], "negative_code": [{"source_code": "sub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n\nwhile(<>){\n\t($n,$m)=split/ /;\n\t@distance=(); # empty\n\t@end=();\n\t$f=1;\n\tfor $i(1..$n){\n\t\t\n\t\t$_=<>;\n\t\t/G\\**S\\*/ and ((push @distance, length($&)-2), next);\n\t\t/G\\**S$/ and ((push @end, length($&)-1), next);\n\t\t$f=0;\n\t\t}\n\tprintf \"%d\\n\", $f? (0+@end? min(@end) : max(@distance) ) : -1;\n\t\n\t\n\t}\n\t\n"}, {"source_code": "sub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n\nwhile(<>){\n\t($n,$m)=split/ /;\n\t@distance=(); # empty\n\t@end=();\n\t$f=1;\n\tfor $i(1..$n){\n\t\t\n\t\tchomp($_=<>);\n\t\t/G\\**S/ ? (push @distance, $d=length($&)-1) : ($f=0);\n\t\t/S$/ and push @end, $d;\n\t\t}\n\tprintf \"%d\\n\", $f? min(max(@distance),min(@end)): -1;\n\t\n\t\n\t}\n\t\n"}, {"source_code": "sub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n\nwhile(<>){\n\t($n,$m)=split/ /;\n\t@distance=(); # empty\n\t$f=1;\n\tfor $i(1..$n){\n\t\t\n\t\t$_=<>;\n\t\t/G\\**S/ ? (push @distance, length($&)-1) : ($f=0);\n\t\t\n\t\t}\n\tprintf \"%d\\n\", $f? max(@distance)-min(@distance)+1: -1;\n\t\n\t\n\t}\n\t\n"}], "src_uid": "9a823b4ac4a79f62cd0c2f88a1c9ef0c"}
{"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n", "positive_code": [{"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}, {"source_code": "$n=<>;\n@info= split ' ',<>;\n$m=0;\n$rez=0;\nwhile ($m<$n)\n{\n\tfor ($i=0; $i<$n; $i++)\n\t{\n\t\tif ($info[$i]<=$m)\n\t\t{\n\t\t\t$m++;\n\t\t\t$info[$i]=$n+1;\n\t\t}\n\t}\n\tlast if $m==$n;\n\t$rez++;\n\tfor ($i=$n-1; $i>=0; $i--)\n\t{\n\t\tif ($info[$i]<=$m)\n\t\t{\n\t\t\t$m++;\n\t\t\t$info[$i]=$n+1;\n\t\t}\n\t}\n\tlast if $m==$n;\n\t$rez++;\n}\nprint $rez;"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i"}, {"source_code": "@_ = split ' ', (<>, <>);\n\t\nwhile (@_){\n\t$i ++;\n\t@a = ();\n\t$_ <= $sum ? $sum ++ : push @a, $_ for @_;\n\t@_ = reverse @a\n\t}\n\t\nprint -- $i\n"}], "negative_code": [{"source_code": "$\\ = $/;\n\nsub solve{\n\t\n\t$sum = 0;\n\t$i = -1;\n\twhile (@_){\n\t\t$i ++;\n\t\t@a = ();\n\t\tfor (@_){\n\t\t\t$_ <= $sum ? $sum ++ : push @a, $_\n\t\t\t}\n\t\t@_ = reverse @a\n\t\t}\n\t$i\n\t\n\t}\n\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tprint ( (sort {$a <=> $b} solve(@_), solve(reverse @_) )[0] )\n\t}"}], "src_uid": "9374728643a1ddbe2200a4a125beef26"}
{"source_code": "$s=<>;\nchomp($s);\n($n,$m)=split ' ',$s;\n$s=<>;\nchomp($s);\n@a=split ' ',$s;\nfor ($i=0; $i<$n; $i++)\n{\n\t$u[$a[$i]-1]++;\n}\nfor ($i=0; $i<$m; $i++)\n{\n\tfor ($j=$i+1; $j<$m; $j++)\n\t{\n\t\t$rez+=$u[$i]*$u[$j];\n\t}\n}\nprint $rez;", "positive_code": [{"source_code": "($n, $m) = split ' ', <>;\n@n = split ' ', <>;\nmap { $A[ $_ ]++ } @n;\nfor $i (1 .. $m){\nfor $j ($i + 1 .. $m){\n$sum += $A[ $i ] * $A[ $j ]\n}\n}\nprint $sum"}], "negative_code": [], "src_uid": "e2ff228091ca476926b8e905f1bc8dff"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n\nwhile (<>){\n\t@a=@m=@sm=@smm=();\n\t$a=$c=\"\";\n\t$n=0;\n\t@_=split/ /,<>;\n\tfor (@_){$m[$_]++}\n\t@sm = sort num_rev @m;\n\tfor $i(@sm){\n\t\t$i>0 and push @smm, $i; \n\t\t}\n#\t\tprint \"@m\\n\";\n#\t\tprint \"@sm\\n\";\n#\t\tprint \"@smm\\n\";\n\tfor $i(@smm){\n\t\t#print \" ...\\n\";\n\t\tfor $j(1..@m-1){\n\t\t\t#print \" $m[$j]==$i\\n\";\n\t\t\tif ($m[$j]==$i){\n\t\t\t\t\n\t\t\t\t$a.=\"$j \"x$m[$j];\n\t\t\t\t$m[$j]=0;\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n\t# print $a; n();\n\t\n\tchop $a;\n\t\n\t$aa=@a=split/ /,$a;\n\tpush @a, @a;\n\n\tfor $i(0..$aa-1){\n\t\t$c.=$a[$i].\" \".$a[$i+$smm[0]].\"\\n\";\n\t\tif ($a[$i]==$a[$i+$smm[0]]){$n++}\n\t\t}\n\tprint @_-$n,\"\\n\";\n\tprint \"$c\\n\";\n\t}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "\nuse List::Util qw(max min);\n\nmy ($n, $m) = split ' ', scalar <>;\nmy @c = sort {$a cmp $b} split ' ', scalar <>;\n\n$n == @c or die \"invalid count\";\n\nmy %cnt = ();\n\nforeach (@c){\n    $cnt{$_}++;\n    }\n\nmy $mcnt = max(values %cnt);\n\nmy @d = @c[( $mcnt..$#c , 0..($mcnt-1) )];\n\nmy $res = min($n, 2*($n - $mcnt));\n\nprint \"$res\\n\";\nfor(my $i = 0; $i < $n; $i++){\n    print \"$c[$i] $d[$i]\\n\"\n    }\n\n1;\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n\nwhile (<>){\n\t@a=@m=@smm=();\n\t$a=$c=\"\";\n\t$n=0;\n\t@_=split/ /,<>;\n\tfor (@_){$m[$_]++}\n\t@sm = sort num_rev @m;\n\tfor $i(@sm){\n\t\t$i>0 and push @smm, $i; \n\t\t}\n\n\tfor $i(@smm){\n\t\tfor $j(1..@m-1){\n\t\t\tif ($m[$j]==$i){\n\t\t\t\t$a.=\"$j \"x$m[$j];\n\t\t\t\t$m[$j]=0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tchop $a;\n\t\n\t$aa=@a=split/ /,$a;\n\tpush @a, @a;\n\n\tfor $i(0..$aa-1){\n\t\t$c.=$a[$i].\" \".$a[$i+$smm[0]].\"\\n\";\n\t\tif ($a[$i]==$a[$i+$smm[0]]){$n++}\n\t\t}\n\tprint @_-$n,\"\\n\";\n\tprint \"$c\\n\";\n\t}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [], "src_uid": "636e9c125197b52c91998bf91ecd8ab1"}
{"source_code": "<>;\nwhile (<>) {\n    $f = $_ =~ /(lala\\.)$/;\n    $r = $_ =~ /(^miao\\.)/;\n    if ($f == $r) {\n        print \"OMG>.< I don't know!\\n\";\n    } elsif ($f) { print \"Freda's\\n\"; } elsif ($r) { print \"Rainbow's\\n\"; }\n}", "positive_code": [{"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile ($eil=<>) {\n\nsub any{print \"OMG>.< I don't know!\\n\"};\n\nwhile (<>){\n    \n    if (/lala\\.$/ and /^miao\\./){any; next}\n    if (/lala\\.$/){print \"Freda's\\n\"; next}\n    if (/^miao\\./){print \"Rainbow's\\n\"; next}\n    any;\n    \n    }\n}"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy $n = <>;\nfor my $i (1..$n) {\n    my $s = <>;\n    chomp($s);\n    my $isFreda = 0;\n    my $isRainbow = 0;\n    if ($s =~ m/^miao\\./) {\n        $isRainbow = 1;\n    }\n    if ($s =~ m/lala\\.$/) {\n        $isFreda = 1;\n    }\n    if ($isFreda && ! $isRainbow) {\n        print \"Freda's\" . \"\\n\";\n    } elsif ($isRainbow && !$isFreda) {\n        print \"Rainbow's\" . \"\\n\";\n    } else {\n        print \"OMG>.< I don't know!\" . \"\\n\";\n    }\n}\n"}, {"source_code": "chomp($n=<STDIN>);\nwhile($n > 0) {\n\tchomp($line=<STDIN>);\n\tif($line =~ /^miao\\..*lala\\.$/) {\n\t\tprint \"OMG>.< I don't know!\\n\";\n\t} elsif ($line =~ /lala\\.$/) {\n\t\tprint \"Freda's\\n\";\n\t} elsif ($line =~ /^miao\\./) {\n\t\tprint \"Rainbow's\\n\";\n\t} else {\n\t\tprint \"OMG>.< I don't know!\\n\";\n\t}\n\t$n--;\n}"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n"}, {"source_code": "#!perl -pl\nINIT{<>}\n@_=(\"Freda's\",\"Rainbow's\",\"OMG>.< I don't know!\");\n$_=$_[/lala\\.$/+2*/^miao\\./-1]\n\n"}], "negative_code": [{"source_code": "$_ = <>;\nwhile (<>) {\n    $f = $_ =~ /(lala\\.)$/;\n    $r = $_ =~ /(^miao\\.)/;\n    if ($f == $r) { print \"OMG>.< I don't know!\\n\"; }\n    if ($f) { print \"Freda's\\n\"; } elsif ($r) { print \"Rainbow's\\n\"; }\n}"}, {"source_code": "<>;\nwhile (<>) {\n    $f = $_ =~ /lala.$/;\n    $r = $_ =~ /^miao./;\n    if ($f == $r) { print \"OMG>.< I don't know!\"; }\n    if ($f) { print \"Freda's\"; } elsif ($r) { print \"Rainbow's\"; }\n}"}, {"source_code": "chomp($n=<STDIN>);\nwhile($n > 0) {\n\tchomp($line=<STDIN>);\n\tif($line eq 'miao\\..*lala\\.') {\n\t\tprint \"OMG>.< I don't know!\\n\";\n\t} elsif ($line =~ /lala\\.$/) {\n\t\tprint \"Freda's\\n\";\n\t} elsif ($line =~ /^miao\\./) {\n\t\tprint \"Rainbow's\\n\";\n\t} else {\n\t\tprint \"OMG>.< I don't know!\\n\";\n\t}\n\t$n--;\n}"}, {"source_code": "chomp($n=<STDIN>);\nwhile($n > 0) {\n\tchomp($line=<STDIN>);\n\tif($line eq 'miao.lala.') {\n\t\tprint \"OMG>.< I don't know!\\n\";\n\t} elsif ($line =~ /lala\\.$/) {\n\t\tprint \"Freda's\\n\";\n\t} elsif ($line =~ /^miao\\./) {\n\t\tprint \"Rainbow's\\n\";\n\t} else {\n\t\tprint \"OMG>.< I don't know!\\n\";\n\t}\n\t$n--;\n}"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy $n = <>;\nfor my $i (1..$n) {\n    my $s = <>;\n    chomp($s);\n    my $isFreda = 0;\n    my $isRainbow = 0;\n    if ($s =~ m/^miao\\./) {\n        $isRainbow = 1;\n    }\n    if ($s =~ m/lala\\.$/) {\n        $isFreda = 1;\n    }\n    print $isFreda . ' ' . $isRainbow . '\\n';\n    if ($isFreda && ! $isRainbow) {\n        print \"Freda's\" . \"\\n\";\n    } elsif ($isRainbow && !$isFreda) {\n        print \"Rainbow's\" . \"\\n\";\n    } else {\n        print \"OMG>.< I don't know!\" . \"\\n\";\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile ($eil=<>) {\n\nwhile (<>){\n    \n    if (/lala\\.$/ and !/miao\\./){print \"Freda's\\n\"; next}\n    if (/miao\\.$/){print \"Rainbow's\\n\"; next}\n    print \"OMG>.< I don't know!\\n\"\n    \n    \n    }\n}"}, {"source_code": "#!/usr/bin/perl\n\nwhile ($eil=<>) {\n\nwhile (<>){\n    \n    if (/lala\\.$/ and !/miao\\./){print \"Freda's\\n\"; next}\n    if (/miao\\.$/ and !/lala\\./){print \"Rainbow's\\n\"; next}\n    print \"OMG>.< I don't know!\\n\"\n    \n    \n    }\n}"}, {"source_code": "#!/usr/bin/perl\n\nwhile ($eil=<>) {\n\nsub any{print \"OMG>.< I don't know!\\n\"};\n\nwhile (<>){\n    \n    if (/lala\\.$/ and /^miao\\./){any; next}\n    if (/miao\\.$/){print \"Rainbow's\\n\"; next}\n    if (/^miao\\./){print \"Freda's\\n\"; next}\n    any;\n    \n    }\n}"}], "src_uid": "ee9ba877dee1a2843e885a18823cbff0"}
{"source_code": "($x[ $_ ], $y[ $_ ]) = split \" \", <> for 0 .. 1;\nfor (1 .. <>){\n\t($a, $b, $c, $r) = split \" \", <>;\n\t$r += 0 <=> $a * $x[ $_ ] + $b * $y[ $_ ] + $c for 0 .. 1;\n\t$r || $A++\n\t}\nprint 0 + $A", "positive_code": [{"source_code": "use warnings;\nuse strict;\n\nmy ($x1, $y1) = map $_+0, split ' ', scalar <>;\nmy ($x2, $y2) = map $_+0, split ' ', scalar <>;\n\n#print \"$x1\\n\";\n\nmy $n = <> + 0;\nmy $cnt = 0;\n\nfor (my $nn = 0; $nn < $n; $nn++){\n    my ($a, $b, $c) = map $_+0, split ' ', scalar <>;\n    ++$cnt if ($a*$x1 + $b*$y1 + $c) * ($a*$x2 + $b*$y2 + $c) < 0\n    }\n\n\nprint \"$cnt\\n\";\n\n\n"}], "negative_code": [{"source_code": "($x1, $y1)=split \" \", <>;\n($x2, $y2)=split \" \", <>;\nfor (1 .. <>){\n\t($a, $b, $c) = split \" \", <>;\n\t( $b ? $y1 <=> (- $a * $x1 - $c) / $b : $x1 <=> 0 ) +\n\t( $b ? $y2 <=> (- $a * $x2 - $c) / $b : $x2 <=> 0 ) || $A++\n\t}\nprint 0 + $A"}, {"source_code": "$\\ = $/;\n($x1, $y1)=split \" \", <>;\n($x2, $y2)=split \" \", <>;\n$ans = 0;\nfor (1 .. <>){\n\t($a, $b, $c) = split \" \", <>;\n\tundef $r;\n\t$r += $y1 <=> ($b ? (- $a * $x1 - $c) / $b :  1e7);\n\t$r += $y2 <=> ($b ? (- $a * $x2 - $c) / $b : -1e7);\n\t$r || $ans++\n\t}\nprint $ans"}, {"source_code": "($x1, $y1)=split \" \", <>;\n($x2, $y2)=split \" \", <>;\nfor (1 .. <>){\n\t($a, $b, $c) = split \" \", <>;\n\t( $y1 <=> ($b ? (- $a * $x1 - $c) / $b : $x1 <=> 0 ) ) +\n\t( $y2 <=> ($b ? (- $a * $x2 - $c) / $b : $y1 <=> 0 ) ) || $A++\n\t}\nprint 0 + $A"}, {"source_code": "($x1, $y1)=split \" \", <>;\n($x2, $y2)=split \" \", <>;\nfor (1 .. <>){\n\t($a, $b, $c) = split \" \", <>;\n\t( $b ? $y1 <=> (- $a * $x1 - $c) / $b : $x1 <=> 0 ) +\n\t( $b ? $y2 <=> (- $a * $x2 - $c) / $b : $y1 <=> 0 ) || $A++\n\t}\nprint 0 + $A"}, {"source_code": "$\\ = $/;\n($x1, $y1)=split \" \", <>;\n($x2, $y2)=split \" \", <>;\n$a = 0;\nfor (1 .. <>){\n\t($a, $b, $c) = split \" \", <>;\n\tundef $r;\n\t$r += $y1 <=> ($b ? (- $a * $x1 - $c) / $b :  1e7);\n\t$r += $y2 <=> ($b ? (- $a * $x2 - $c) / $b : -1e7);\n\t$r || $a++\n\t}\nprint $a"}], "src_uid": "783df1df183bf182bf9acbb99208cdb7"}
{"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\n<>;\nmy @x = split ' ', <>;\nmy $c = 0;\nfor my $i (1..$#x - 1) {\n  $c++ if $x[$i - 1] < $x[$i] && $x[$i] > $x[$i + 1];\n  $c++ if $x[$i - 1] > $x[$i] && $x[$i] < $x[$i + 1];\n}\nsay $c;\n", "positive_code": [{"source_code": "<>;\n\nprint 0 + ( () = <> =~ s/(\\d+) (?=(\\d+))/ qw[ = > < ][ $1 <=> $2 ] x 2 /ger =~ /<>|></g )"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tmy $c = 0;\n\t\n\tfor my $i ( 1 .. @_ - 2 ){\n\t\t$c += (\n\t\t$_[ $i - 1 ] < $_[ $i ] and $_[ $i ] > $_[ $i + 1 ] or\n\t\t$_[ $i - 1 ] > $_[ $i ] and $_[ $i ] < $_[ $i + 1 ] \n\t\t);\n\t\t}\n\t\n\tprint $c;\n\t}"}, {"source_code": "<>, <> =~ /\n\t\\b(\\d+)\n\t[ ]\n\t(?=\t(\\d+)\n\t\t[ ]\n\t\t(\\d+)\\b\n\t)\n\t(??{\n\t\t$c += $1 < $2 && $2 > $3 || $1 > $2 && $2 < $3;\n\t\t'X'\n\t})\n/x;\n\nprint 0 + $c"}, {"source_code": "\n# get input\nmy $a;\nmy $b;\n$a = <STDIN>;\nchomp ( $b = <STDIN> );\nmy @arr = split m/ /, $b;\n\n# variable counts extrema\nmy $extrema = 0;\n\nfor ( my $i = 1; $i < (@arr - 1); $i += 1 ) {\n\n    # if is local min or local max, increment extrema\n    if ( (@arr[ $i ] < @arr[ $i-1 ] && @arr[ $i ] < @arr[ $i+1 ]) ||\n\t (@arr[ $i ] > @arr[ $i-1 ] && @arr[ $i ] > @arr[ $i+1 ]) ) {\n\t$extrema += 1; }}\n\n# print answer\nprint \"$extrema\\n\";\n\n\n"}, {"source_code": "# get input\nmy $a;\nmy $b;\n$a = <STDIN>;\nchomp ( $b = <STDIN> );\nmy @arr = split m/ /, $b;\n\n# variable counts extrema\nmy $extrema = 0;\n\nfor ( my $i = 1; $i < (@arr - 1); $i += 1 ) {\n\n    # if is local min or local max, increment extrema\n    if ( ($arr[ $i ] < $arr[ $i-1 ] && $arr[ $i ] < $arr[ $i+1 ]) ||\n\t ($arr[ $i ] > $arr[ $i-1 ] && $arr[ $i ] > $arr[ $i+1 ]) ) {\n\t$extrema += 1; }}\n\n# print answer\nprint \"$extrema\\n\";\n"}], "negative_code": [{"source_code": "<>, <> =~ /\n\t\\b(\\d+)\n\t[ ]\n\t(?=\t(\\d+)\n\t\t[ ]\n\t\t(\\d+)\\b\n\t)\n\t(??{\n\t\t$c += $1 < $2 && $2 > $3 || $1 > $2 && $2 < $3\n\t})\n/x;\n\nprint 0 + $c"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tmy $c = 0;\n\t\n\tfor my $i ( 1 .. @_ - 2 ){\n\t\t$_[ $i - 1 ] < $_[ $i ] and $_[ $i ] > $_[ $i + 1 ] or\n\t\t$_[ $i - 1 ] > $_[ $i ] and $_[ $i ] < $_[ $i + 1 ] or\n\t\tlast;\n\t\t$c ++;\n\t\t}\n\t\n\tprint $c;\n\t}"}], "src_uid": "67cf9f83ed791a614bd01c5e0310813f"}
{"source_code": "($n,$k)=split/ /,<>;\n@_=<>=~/./g;\nfor (@_){\n$_{$_}++\n}\n@_ = sort {\n$_{$b}<=>$_{$a}\n}\nkeys %_;\nfor (@_){\nif ($_{$_}<=$k){\n$k-=$_{$_};\n$s+=$_{$_}**2;\n}\nelse {\n$s+=$k**2;\n$k=0;\n}\n}\nprint $s", "positive_code": [{"source_code": "($n,$k)=split/ /,<>;\n$_=<>;\nwhile(/./g){\n$_{$&}++\n}\n@_ = sort {\n$_{$b}<=>$_{$a}\n}\nkeys %_;\nfor (@_){\nif ($_{$_}<=$k){\n$k-=$_{$_};\n$s+=$_{$_}**2;\n}\nelse {\n$s+=$k**2;\n$k=0;\n}\n}\nprint $s"}], "negative_code": [], "src_uid": "480defc596ee5bc800ea569fd76dc584"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub say_all {\n    my @args = @_;\n    say join ' ', @args;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n\nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n\nsub sum_of_digits {\n    my $n = shift;\n    my @numbers = split q{}, $n;\n\n    my $sum = 0;\n\n    for (@numbers) {\n        $sum += $_;\n    }\n\n    return $sum;\n}\n\n# solution\n\nmy $n = read_token;\n\nmy @arr = split q{ }, read_line;\n\nmy $pre_number = shift @arr;\nmy $len = 1;\nmy $answer = 0;\n\nfor (@arr) {\n    if ($_ <= $pre_number) {\n        $answer = max($answer, $len);\n        $len = 1;\n        $pre_number = $_;\n        next;\n    }\n    $len++;\n    $pre_number = $_;\n}\n\n$answer = max($answer, $len);\n\nsay $answer;\n", "positive_code": [{"source_code": "    #!/usr/bin/env perl\n        \n    use strict;\n    use warnings;\n    use feature qw/ say /;\n     \n    use Carp;\n     \n    # essential\n    my @tokens = ();\n     \n    sub ceil {\n        my $n = shift;\n        my $in = int($n);\n        return $n if $in == $n;\n        return $in + 1;\n    }\n     \n    sub say_all {\n        my @args = @_;\n        say join ' ', @args;\n    }\n     \n    sub read_line {\n        chomp (my $line = <STDIN>);\n        return $line;\n    }\n        \n    sub read_token {\n        @tokens = split q{ }, read_line() if @tokens == 0;\n        return shift @tokens;\n    }\n        \n    sub min {\n        my @numbers = @_;\n        my $min = shift @numbers;\n        for ( @numbers ) {\n            $min = $min<$_ ? $min : $_;\n        }\n        return $min;\n    }\n        \n    sub max {\n        my @numbers = @_;\n        my $max = shift @numbers;\n        for ( @numbers ) {\n            $max = $max > $_ ? $max : $_;\n        }\n        return $max;\n    }\n        \n    sub sum {\n        my @numbers = @_;\n        my $sum = 0;\n        for (@numbers) {\n            $sum += $_;\n        }\n        return $sum;\n    }\n     \n    sub ref_ref_scalar {\n        my $ref = shift;\n        return 1 if ref($ref) eq 'SCALAR';\n    }\n     \n    sub toggle {\n        my $ref = shift;\n        croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n     \n        $$ref = !$$ref;\n    }\n     \n    sub odd {\n        my $num = shift;\n        return $num % 2 == 1;\n    }\n     \n    sub even {\n        my $num = shift;\n        return $num % 2 == 0;\n    }\n     \n    sub sum_of_digits {\n        my $n = shift;\n        my @numbers = split q{}, $n;\n     \n        my $sum = 0;\n     \n        for (@numbers) {\n            $sum += $_;\n        }\n     \n        return $sum;\n    }\n     \n    # solution\n     \n    my $n = read_token;\n     \n    my @arr = split q{ }, read_line;\n     \n    my $pre_number = shift @arr;\n    my $len = 1;\n    my $answer = 0;\n     \n    for (@arr) {\n        if ($_ <= $pre_number) {\n            $answer = max($answer, $len);\n            $len = 1;\n            $pre_number = $_;\n            next;\n        }\n        $len++;\n        $pre_number = $_;\n\n    }\n     \n    $answer = max($answer, $len);\n     \n    say $answer;\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub say_all {\n    my @args = @_;\n    say join ' ', @args;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n\nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n\nsub sum_of_digits {\n    my $n = shift;\n    my @numbers = split q{}, $n;\n\n    my $sum = 0;\n\n    for (@numbers) {\n        $sum += $_;\n    }\n\n    return $sum;\n}\n\n# solution\n\nmy $n = read_token;\n\nmy $pre_number = read_token;\nmy $len = 1;\nmy $answer = 0;\n\nfor (1..$n-1) {\n    my $num = read_token;\n    if ($num <= $pre_number) {\n        $answer = max($answer, $len);\n        $len = 1;\n        $pre_number = $num;\n        next;\n    }\n    $len++;\n    $pre_number = $num;\n\n}\n\n$answer = max($answer, $len);\n\nsay $answer;\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub say_all {\n    my @args = @_;\n    say join ' ', @args;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n\nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n\nsub sum_of_digits {\n    my $n = shift;\n    my @numbers = split q{}, $n;\n\n    my $sum = 0;\n\n    for (@numbers) {\n        $sum += $_;\n    }\n\n    return $sum;\n}\n\n# solution\n\nmy $n = read_token;\n\nmy $pre_number = read_token;\nmy $len = 1;\nmy $answer = 0;\n\nfor (1..$n-1) {\n    my $num = read_token;\n    if ($num <= $pre_number) {\n        $answer = max($answer, $len);\n        $len = 1;\n        $pre_number = $num;\n        next;\n    }\n    $len++;\n    $pre_number = $num;\n}\n\n$answer = max($answer, $len);\n\nsay $answer;\n"}, {"source_code": "<>;\n\nprint +(sort {$b <=> $a}\n\tmap {\n\t\t$i ++;\n\t\t$_ <= $prev and $i = 1;\n\t\t$prev = $_;\n\t\t$i\n\t\t} (split ' ', <>), 0\n\t)[ 0 ]"}, {"source_code": "# cf702a\nmy $n=<>;\nlocal $/=' ';\nmy $prev;\nmy $l=0;\nmy $max=0;\nforeach (<>) {\n  if($l>0&&$_<=$prev) {\n    $l=0;\n  }\n  ++$l;\n  if($l>$max) {$max=$l;}\n  $prev=$_;\n}\n\nprint $max;\n\n"}], "negative_code": [], "src_uid": "4553b327d7b9f090641590d6492c2c41"}
{"source_code": "@_=<>;\nfor my $i(0..@_-1)\n{ $_[$i]=~s/^ *+(?:[^#\\n].*)?\\n/ $a=$&,$a=~y{\\t }{}d,$a/e and $i and $_[$i-1] !~ /^ *+#/ and chomp $_[$i-1]}\nprint @_", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\n@in = <STDIN>;\nfor ($i = 0; $i < @in; $i++) {\n\t$amp[$i] = ($in[$i] =~ /^\\s*#/);\n}\nfor ($i = 0; $i < @in; $i++) {\n\tif (!$amp[$i]) { $in[$i] =~ s/ //g; }\n\tif ($i < $#in && !$amp[$i] && !$amp[$i+1]) { chomp $in[$i]; }\n}\nprint @in;"}, {"source_code": "use warnings;\nlocal $SIG{__WARN__} = sub {$w = shift};\n\nlocal $/;\n$m = qr/(?:^ *+(?:[^#\\n].*)?$)(?:\\n^ *+(?:[^#\\n].*)?$)*/m, \ns/$m/($a=$&)=~y{\\n \\t}{}d,$a/eg , $w && \ns/$m/($a=$&)=~y{\\n \\t}{}d,$a/eg , print  for <>;"}, {"source_code": "local $/;\n$m = qr/(?:^ *+(?:[^#\\n].*)?$)(?:\\n^ *+(?:[^#\\n].*)?$)*/m, \ns/$m/($a=$&)=~y{\\n \\t}{}d,$a/eg , \ns/$m/($a=$&)=~y{\\n \\t}{}d,$a/eg , print  for <>;"}], "negative_code": [{"source_code": "$_=<>;\nchomp;\n/^\\s*#/ or s/\\s+//g;\nprint;\nprint \"\\n\";\nwhile(<>){\nchomp;\n/^\\s*#/ or s/\\s+//g;\ns/^\\s*#/\\n$&/;\nprint;\n}"}, {"source_code": "$_=<>;\nchomp;\n/^\\s*#/ or s/\\s+//g;\nprint;\nprint \"\\n\";\nwhile(<>){\nchomp;\n/^s*#/ or s/\\s+//g;\ns/^s*#/\\n$1/;\nprint;\n}"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*?)?$)(?:\\n^ *+(?:[^#\\n].*?)?$)*$/$a=$&,$a=~y{\\n}{}d,$a/meg , print  for <>"}, {"source_code": "while(<>){\n/\\s*#/ or s/\\s//g;\nprint\n}"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*)?$)(?>(?:\\n^ *+(?:[^#\\n].*)?$)*)$/$a=$&,$a=~y{\\n \\t}{}d,$a/meg , print  for <>"}, {"source_code": "$_=join\"\",<>;\ns/\\s*([^#])/$1/gm;\nprint\n"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , /\\n$/ && chop, print  for <>"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*?)?$)(?:\\n^ *+(?:[^#\\n].*?)?$)*$/$a=$&,$a=~y{\\n \\t}{}d,$a/meg , print  for <>"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*)?$)(?:(?:\\n^ *+(?:[^#\\n].*)?$){0,32766}+){0,32766}/$a=$&,$a=~y{\\n \\t}{}d,print $a/meg for <>"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , $_.=$e=chop, $e eq \"\\n\" || ($_.=\"\\n\"),print  for <>"}, {"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n#print;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\n#print\" @_\\n\";\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1<=31 and $2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12){\npush @a,$_;\n}\nif($1<=30 and $2==4 or $2==6 or $2==9 or $2==11){\npush @a,$_;\n}\nif($1<=28 and $2==2){\npush @a,$_;\n}\n}\n#print\"  @a\\n\";\n}\nfor(@a){\ns/-//;\ns/-201//;\n#print;\n$m[$_]++;\n}\n# print \"@m\\n\";\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n#print \"  $max\\n\";\nfor$i(0..@m-1){\n$max==$m[$i] and $_=$i;\n}\n#$_=$a[$max];\n#print;\nlength==4 and s/^/0/;\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}, {"source_code": "while(<>){\n/^\\s*#/ or s/\\s//g;\nprint\n}"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , /\\n\\z/ or $_.=$\\,print  for <>"}, {"source_code": "while(<>){\n/^\\s*#/ or s/[ \\t]+//g;\nprint\n}"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*)?$)(?:\\n^ *+(?:[^#\\n].*)?$)*$/$a=$&,$a=~y{\\n \\t}{}d,$a/meg , print  for <>"}, {"source_code": "@_=<>;\nfor my $i(1..@_-1)\n{ $_[$i]=~s/^ *+(?:[^#\\n].*)?\\n/ $a=$&,$a=~y{\\t }{}d,$a/e and $_[$i-1] !~ /^ *+#/ and chomp $_[$i-1]}\nprint @_"}, {"source_code": "$_=<>;\nchomp;\n/^\\s*#/ or s/\\s+//g;\nprint;\nprint \"\\n\";\nwhile(<>){\nchomp;\n/^\\s*#/ or s/\\s+//g;\n/^\\s*#/ and s/$/\\n/;\ns/^\\s*#/\\n$&/;\nprint;\n}"}, {"source_code": "$_=<>;\nchomp;\n/^\\s*#/ or s/\\s+//g;\nprint;\nprint \"\\n\";\nwhile(<>){\nchomp;\n/^\\s*#/ or s/\\s+//g;\ns/^\\s*#/\\n$1/;\nprint;\n}"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*)?$)(?:\\n^ *+(?:[^#\\n].*)?$)*+$/$a=$&,$a=~y{\\n \\t}{}d,$a/meg , print  for <>"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*)?$)(?:(?:\\n *+(?:[^#\\n].*)?$){0,32766}+){0,32766}+/$a=$&,$a=~y{\\n \\t}{}d,$a/meg, print for <>"}, {"source_code": "use warnings;\nlocal $SIG{__WARN__} = sub {$w = shift};\n\nlocal $/;\n$m = qr/(?:^ *+(?:[^#\\n].*)?$)(?:\\n^ *+(?:[^#\\n].*)?$)*/m, \ns/$m/($a=$&)=~y{\\n \\t}{}d, ($w and s{\\n}{}m and undef $w),$a/eg , print  for <>;"}, {"source_code": "local $/;\n$m = qr/(?:^ *+(?:[^#\\n].*)?$)(?:\\n^ *+(?:[^#\\n].*)?$)*/, \ns/$m/($a=$&)=~y{\\n \\t}{}d,$a/meg , \ns/$m/($a=$&)=~y{\\n \\t}{}d,$a/meg , print  for <>;"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , /\\n\\Z/ || s/\\Z/\\n/,print  for <>"}, {"source_code": "local $/;\ns/^ *+(?:[^#\\n].*)?\\n/(print\"[$&]\"),($a=$&)=~y{ \\t}{}d, $a /meg , s/\\n( *+[^#\\n])/$1/meg, print for <>"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , print  for <>"}, {"source_code": "local $/;\ns/(?:^ *+(?:[^#\\n].*?)?$)(?:\\n^ *+(?:[^#\\n].*?)?$)*$/$a=$&,$a=~s{\\s}{}sg,$a/meg , print  for <>"}, {"source_code": "$_=<>;\nchomp;\n/^.*#/ or s/\\s+//g;\nprint;\nprint \"\\n\";\nwhile(<>){\nchomp;\n/^.*#/ or s/\\s+//g;\ns/^.*#/\\n$1/;\nprint;\n}"}, {"source_code": "while(<>){\n/^\\s*#/ or s/[ \\t]+//g;\ns/^\\n$//;\nprint\n}"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , /\\n\\Z/ || s/$/\\n/,print  for <>"}, {"source_code": "$_=<>;\nchomp;\n/^\\s*#/ or s/\\s+//g;\nprint;\nprint \"\\n\";\nwhile(<>){\nchomp;\n/^\\s*#/ or s/\\s+//g;\n/^\\s*#/ and s/$/\\n/;\ns/^\\s*#/\\n$&/;\nprint;\n}\nchomp or print\"\\n\";"}, {"source_code": "@_=<>;\nfor(@_){\n/.*#/ or s/\\s//g;\n}\nprint shift @_;\nfor(@_){\ns/.*#/\\n$&/;\n}\nprint join\"\",@_;"}, {"source_code": "local $/;\ns/^ *+(?:[^#\\n].*)?\\n/($a=$&)=~y{ \\t}{}d, $a /meg , s/\\n( *+[^#\\n])/$1/meg, print for <>"}, {"source_code": "s/^ *+[^#].*/$a=$&,$a=~s{\\s}{}sg,$a/seg || ($i++ && s/^/\\n/),print for <>"}, {"source_code": "local $/;\ns/(^ *+(?:[^#\\n].*)?(\\n|$))( *+#|)/$a=$1,$a=~y{ \\t}{}d,$3 || ($2 && chop $a),$a.$3/meg , /\\n\\z/ || s/$/\\n/,print  for <>"}], "src_uid": "a16bb696858bc592c33dcf0fd99df197"}
{"source_code": "$s+=<>=~/-/?-1:1 for 1..<>;print$s", "positive_code": [{"source_code": "$_=join'',<>;print.5*(s/\\+//g- s/-//g)"}, {"source_code": "<>;\nwhile (<>){/\\+/?($i++):($i--)}\nprint $i"}, {"source_code": "\nmy $n;\nchomp ( $n = <STDIN> );\n\nmy $x = 0;\nmy $str;\nfor ( my $i = 0; $i < $n; $i += 1 ) {\n    chomp ( $str = <STDIN> );\n    if ( $str =~ m/(X\\+\\+)|(\\+\\+X)/ ) {\n\t$x += 1;}\n    if ( $str =~ m/(X--)|(--X)/ ) {\n\t$x -= 1;}\n}\n\nprint \"$x\\n\";\n\n\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse v5.012;\nuse warnings;\n\nmy $cnt = <STDIN>;\n\nmy $x = 0;\nwhile ($cnt--) {\n\tchomp(my $stmt = <STDIN>);\n\t$x++ if $stmt =~ /\\+\\+/;\n\t$x-- if $stmt =~ /\\-\\-/;\n}\nprint $x;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $ans = 0;\n\nwhile($n-- > 0){\n    my $var = <>;\n    if($var =~ /\\+\\+/){\n        $ans++;\n    }elsif($var =~ /--/){\n        $ans--;\n    }\n}\nprint \"$ans\\n\";"}, {"source_code": "chomp($n = <STDIN>);\nwhile ($n--)\n{\n    chomp($_ = <STDIN>);\n    if (/-/)\n    {\n        --$r;\n    }\n    else\n    {\n        ++$r;\n    }\n}\nprint \"$r\\n\";\n"}, {"source_code": "$_=join'',<>;print.5*(s/\\+//g- s/-//g)"}, {"source_code": "\nmy $n = <>;\nmy $ans = 0;\nmy $str;\nfor (1..$n) {\n    $str = <>;\n    chomp $str;\n    $ans++ if ($str eq \"++X\" || $str eq \"X++\");\n    $ans-- if ($str eq \"--X\" || $str eq \"X--\");\n}\nprint $ans . \"\\n\";"}, {"source_code": "#!/usr/bin/env perl\n\nuse 5.010;\n\n@lines = <>;\n$accum = 0;\n\nforeach $line (@lines) {\n\tif ($line =~ /\\+\\+/) {\n\t\t$accum++;\n\t}\n\tif ($line =~ /--/) {\n\t\t$accum--;\n\t}\n}\n\nsay $accum;"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nmy $cnt = 0;\n\nwhile ($n-- > 0){(<>=~/\\+/g)?$cnt++:$cnt--;}\n\nprint $cnt;\n"}, {"source_code": "my $n = <STDIN>;\nmy $x = 0;\nwhile($n--) {\n    my $s = <STDIN>;\n    chomp($x);\n    if(index($s, '++') != -1) {\n        $x++;\n    }\n    elsif(index($s, '--') != -1) {\n        $x--;\n    }\n}\nprint $x;"}, {"source_code": "#!perl\n\nuse strict;\nuse warnings;\n\nchomp( my $n =<STDIN> );\n\nmy $acc_num = 0 ;\nforeach ( 0 .. ($n-1) ){\n    my $readnum = <STDIN> ;\n    \n    if ( $readnum =~ m/\\+\\+/ ){\n        $acc_num++;\n    }else{\n        $acc_num--;\n    }\n}\nprint \"$acc_num\\n\" ;\n"}, {"source_code": "$s+=<>=~/-/?-1:1 for 1..<>;print$s"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\n\n\n$x = 0;\nchomp($n = <>);\nwhile ($n-- > 0) {\n\tchomp($line = <>);\n\tif ((substr $line, 1, 1) eq \"+\") {\n\t\t$x++\n\t} else {\n\t\t$x--;\n\t}\n}\nprint $x;\n"}, {"source_code": "chomp ($n = <STDIN>);\n$x = 0;\nwhile ($n--) {\n\tchomp ($str = <STDIN>);\n\tif ($str =~ /--/) { $x-- } else { $x++}\n}\nprintf \"$x\\n\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp($n);\n\ndie ('n should be between 1 and 150') unless $n >= 1 && $n <= 150;\n\n\nmy $x = 0;\nfor (my $i = 0; $i < $n; $i++) {\n    my $in = <>;\n    chomp($in);\n    if ($in =~ m/\\+\\+/) {\n        $x++;\n    } elsif ($in =~ m/\\-\\-/) {\n        $x--;\n    } else {\n        die ('invalid input');\n    }\n}\n\n\nprint $x;\n"}, {"source_code": "#!/usr/bin/perl\n\n$n = <STDIN>;\n$x = 0;\nfor (my $i = 0; $i < $n; $i++){\n\t$buf = <STDIN>;\n\tif (substr($buf, 1, 1) eq \"+\"){\n\t\t$x++;\n\t} else {\n\t\t$x--;\n\t}\n}\nprint \"$x\\n\";\n"}, {"source_code": "chomp($n=<STDIN>);\n$x = 0;\nwhile($n-- > 0) {\n\tchomp($line = <STDIN>);\n\tif($line =~ /\\+\\+/) {\n\t\t$x++;\n\t} else {\n\t\t$x--;\n\t}\n}\nprint \"$x\\n\";"}, {"source_code": "#!perl\n\n$\\ = \"\\n\";\n\nmy $n = <>;\n\nmy $x = 0;\nfor (1..$n)\n{\n\tmy $s = <>;\n\n\tif($s =~ m/\\+/)\n\t{\n\t\t$x++;\n\t}\n\telse\n\t{\n\t\t$x--;\n\t}\n}\n\nprint $x;"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $x = 0;\nfor (1..$n) {\n    my @term = split '', <>;\n    if ($term[1] eq '+') {\n        $x++;\n    } else {\n        $x--;\n    }\n}\n\nprint \"$x\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp(my $n = <STDIN>);\nmy $x = 0;\nfor (my $i = 0; $i < $n; $i++) {\n    chomp(my $cmd = <STDIN>);\n    if (index($cmd, \"++\") != -1) {\n        $x += 1;\n    } elsif (index($cmd, \"--\") != -1) {\n        $x -= 1;\n    }\n}\nprint $x;"}, {"source_code": "$s+=<>=~/-/?-1:1 for 1..<>;print$s"}, {"source_code": "use strict;\nuse warnings;\nmy $N=<STDIN>;\nmy $X=0;\nfor(my $i=0;$i<$N;$i++){\n   my $s=<STDIN>;\n   if ($s =~ /[X++]{3}/ ){\n      $X+=1;\n   }\n   else {\n      $X-=1;\n   }\n}\nprint STDOUT $X;"}, {"source_code": "import strict;\nimport warnings;\n\nmy @x = (\"++X\", \"X++\");\nmy $_ = <>;\nmy $ans = 0;\nfor($__ = 1 ; $__ <= $_ ; $__++)\n{\n    $s = <>;\n    chomp($s);\n    (($s eq $x[0]) or ($s eq $x[1]) )? $ans ++ : $ans --;\n}\n\nprint \"$ans\";"}, {"source_code": "<STDIN>;\n$x = 0;\n\nwhile(<STDIN>)\n{\n    ($_ =~ /\\+\\+/) ? ++$x : --$x;\n}\n\nprint STDOUT $x;"}, {"source_code": "#!usr/bin/perl\n#use warnings;\nuse 5.012;\nuse 5.010;\nuse 5.014;\n#use strict;\n#use autodie;\nmy($n,$count,$x,$line);\nchomp($n=<STDIN>);\n$count=0;\nwhile($count ne $n)\n{\n    $count++;\n    chomp($line=<STDIN>);\n    if($line=~m/\\+\\+/)\n    {$x++;}\n    else \n    {$x--;}\n}\nsay \"$x\";"}, {"source_code": "my $res = 0;$count = int(<STDIN>); for(1..$count){$_ = <STDIN>; s/x\\+\\+|\\+\\+x/+/i; s/x\\-\\-|\\-\\-x/-/i;chomp; if( $_ eq \"+\"){ $res += 1; }else{ $res -= 1; } } print \"$res\\n\""}, {"source_code": "$s+=<>=~/-/?-1:1 for 1..<>;print$s"}, {"source_code": "$n = <>;\nchomp $n;\n\n$x = 0;\n\nfor (1..$n) {\n    $cmd = <>;\n    chomp $cmd;\n\n    if ($cmd =~ /\\+\\+/) { $x++; }\n    else { $x--; }\n}\n\nprint \"$x\\n\";\n\n"}, {"source_code": "$n = <>;\n$x = 0;\nfor ($i = 0; $i < $n; ++$i) {\n    $str = <>;\n    if ((index $str, '+') != -1) { ++$x; }\n    else { --$x; }\n}\nprint $x;"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n$l = 0;\n\nfor($i=0;$i<$n;$i++)\n{\n\n  $s = <STDIN>;\n  chomp $s;\n  $s =~ s/\\+\\+/X/;\n\n  if( $s eq 'XX' )\n  {\n\n    $l++;\n\n  }\n  else\n  {\n\n    $l--;\n\n  }\n\n}\n\nprint $l;\n"}, {"source_code": "#!/usr/bin/perl;\n\n$x = 0;\n$n = <STDIN>;\n\nfor ($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\t($s eq \"++X\" || $s eq \"X++\") && $x++;\n\t($s eq \"--X\" || $s eq \"X--\") && $x--;\n}\n\nprint $x;\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\n\nmy $n = <STDIN>;\nchomp($n);\n\nmy $x = 0;\n\nforeach (1..$n) {\n\t$_ = <STDIN>;\n\tchomp;\n\tif ($_ eq \"X++\" or $_ eq \"++X\") { $x++; }\n\telse { $x--; }\n}\n\nprint $x;\n"}, {"source_code": "#!/usr/bin/perl\nuse strict; use warnings;\n\nmy $x = 0; <STDIN>;\n/-/ ? --$x : ++$x while <STDIN>;\nprint $x . \"\\n\"\n"}, {"source_code": "$n = <STDIN>;\n@a = undef;\n$result = 0;\nforeach (0..$n - 1) {\n\tchomp ($a[$_] = <STDIN>);\n\t#unshift (@a, <STDIN>)\n}\nforeach $a (@a) {\n\tif (index ($a, '+') >= 0) {\n\t\t$result += 1;\n\t} else {\n\t\t$result -= 1;\n\t}\n}\nprint ($result);"}, {"source_code": "my $n = <>;\n\nmy $i;\n$i += <> =~ /-/ ? -1 : 1 for 1..$n;\n\nprint $i;\n"}, {"source_code": "<>;$i+=0cmp/-/for<>;print$i"}, {"source_code": "<>;\n$i-=.1<=>/\\+/ for <>;\nprint $i"}, {"source_code": "<>;\nwhile (<>){/\\+/?($i++):($i--)}\nprint $i"}, {"source_code": "my $num = <>;\nmy $x;\n<> =~ /\\+/ ? $x++ : $x-- for 1..$num;\nprint $x;"}, {"source_code": "my $len = <STDIN>;\nmy $ans = 0;\n\nfor (1 .. $len) {\n\tmy $middle = substr <STDIN>, 1, 1;\n\n\t$ans += $middle eq \"+\"? 1 : -1;\n}\n\nprint $ans.\"\\n\";\n"}, {"source_code": "my $len = <STDIN>;\nmy $ans = 0;\n\nfor my $val (1 .. $len) {\n\tmy $comm = <STDIN>;\n\tmy $middle = substr $comm, 1, 1;\n\n\t$ans = $middle eq \"+\"? ($ans + 1) : ($ans - 1);\n}\n\nprint $ans.\"\\n\";\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\nmy $N=<STDIN>;\nmy $X=0;\nfor(my $i=0;$i<$N;$i++){\n   my $s=<STDIN>;\n   if ($s == \"X++\" || $s == \"++X\"){\n      $X+=1;\n   }\n   else {\n      $X-=1;\n   }\n}\nprint STDOUT; $X;\n"}, {"source_code": "use strict;\nuse warnings;\nmy $N=<STDIN>;\nmy $X=0;\nfor(my $i=0;$i<$N;$i++){\n   my $s=<STDIN>;\n   if ($s == \"X++\"){\n      $X+=1;\n   }\n   else {\n      $X-=1;\n   }\n}\nprint STDOUT; $X;\n"}, {"source_code": "use strict;\nuse warnings;\nmy $N=<STDIN>;\nmy $X=0;\nfor(my $i=0;$i<$N;$i++){\n   my $s=<STDIN>;\n   if ($s == \"X++\" || $s == \"++X\"){\n      $X+=1;\n   }\n   else {\n      $X-=1;\n   }\n}\nprint STDOUT $X;\n"}, {"source_code": "#!usr/bin/perl\n#use warnings;\nuse 5.012;\nuse 5.010;\nuse 5.014;\n#use strict;\n#use autodie;\nmy($n,$count,$x,$line);\nchomp($n=<STDIN>);\n$count=0;\nwhile($count lt $n)\n{\n    $count++;\n    chomp($line=<STDIN>);\n    if($line=~m/\\+\\+/)\n    {$x+=1;}\n    else \n    {$x-=1;}\n}\nsay \"$x\";"}, {"source_code": "my $n = <>;\nmy $i;\n\n$i += <> =~ /-/ ? -1 : 1 for 1..$n;\nprint $i, '\\n';"}], "src_uid": "f3cf7726739290b280230b562cac7a74"}
{"source_code": "# cf699a\nuse strict;\nmy $n=<>;\nmy @ds=map {getc()} 1..$n;\ngetc();\nmy @cs;\n{\nlocal $/=' ';\n@cs=<>;\n}\nchomp $cs[$#cs];\nmy $mint=-1;\nforeach my $i (0..$n-2) {\n  my $d1=$ds[$i];\n  my $d2=$ds[$i+1];\n  my $c1=$cs[$i];\n  my $c2=$cs[$i+1];\n  if($d1 eq 'R'&&$d2 eq 'L') {\n    my $t=($c2-$c1)/2;\n    if($mint==-1||$t<$mint) {$mint=$t;}\n  }\n}\nprint $mint;\n", "positive_code": [{"source_code": "<>; $_ = <>; @x = split \" \", <>;\npush @v, $x[pos()-1] - $x[pos()-2] while /RL/g;\n@v = sort { $a <=> $b} @v;\nprint $v[0]/2 || -1;\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = reverse ~~<>, chomp;\n\t@_ = split ' ', <>;\n\t\n\t$min = ~0;\n\n\tfor $i (@_){\n\t\t$x = chop;\n\t\t$x eq 'L' ? \n\t\t\t\tdo { $R and $min > $i - $j and $min = $i - $j;\n\t\t\t\t\t$L = 1; $R = 0;\n\t\t\t\t}\n\t\t\t:\n\t\t\t\tdo { $L = 0; $R = 1; $j = $i };\n\t\t\n\t\t}\n\t\n\tprint $min == ~0 ? -1 : $min / 2\n\t}"}], "negative_code": [{"source_code": "<>; $_ = <>; @x = split \" \", <>;\npush(@v, $x[pos()-1] - $x[pos()-2]) while /RL/g;\nprint @v? (sort @v)[0]/2: -1;\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = reverse ~~<>, chomp;\n\t@_ = split ' ', <>;\n\t\n\t$max = 0;\n\t\n\tfor $i (@_){\n\t\t$x = chop;\n\t\t$x eq 'L' ? \n\t\t\t\tdo { $R and $max < $i - $j and $max = $i - $j;\n\t\t\t\t\t$L = 1; $R = 0;\n\t\t\t\t}\n\t\t\t:\n\t\t\t\tdo { $L = 0; $R = 1; $j = $i };\n\t\t\n\t\t}\n\t\n\tprint $max / 2\n\t}"}], "src_uid": "ff0843cbd7c3a07c7d7d0be46b03a700"}
{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my %likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        $likes{$_}++;\n        if ($likes{$_} > $max->{count}) {\n            $max = {id => $_, count => $likes{$_}};\n        }\n    }\n    print $max->{id};\n}\n\nexit 0;\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy $sum = <>;\nmy @like_hist = split \" \", <>;\n@like_hist = map { $like_hist[$_] } 0..$sum-1;\n\nmy $counts = {};\nmy $max = {id => $like_hist[0], count => 1 };\n\nmy $k = 0;\nfor (0..$sum-1) {\n\tmy $id = $like_hist[$_];\n\tmy $count = ++$counts->{$id};\n\t$max = {id => $id, count => $count } if ($count > $max->{count});\n}\n\nprint $max->{id};"}, {"source_code": "<>; $max = ++$h{$_} > $h{$max}? $_: $max for split ' ', <>;\nprint $max;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        my $id = $array[$_];\n        $likes->{$id}++;\n        my $count = $likes->{$id};\n        if ($likes->{$id} > $max->{count}) {\n            $max = {id => $id,\n                    count => $count};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    chomp;\n    my $num = $_;\n    my ($res_key, $res_value) = (0, 0);\n    my %likes;\n    my $line = <>;\n    chomp($line);\n    my @array = split / /, $line;\n    for (@array) {\n        $likes{$_}++;\n        while (my ($key, $value) = each %likes) {\n            if ($value > $res_value) {\n                $res_value = $value;\n                $res_key = $key;\n            }\n        }\n    }\n    print $res_key, \"\\n\";\n}\n\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes = {};\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        my $id = $array[$_];\n        my $count = ++$likes->{$id};\n        $max = {id => $id, count => $count} \n            if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my %likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        my $count = ++$likes{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 6.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:23:29 PM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nmy $sum = <>;\nmy @array = split ' ', <>;\nmy $max = {id => $array[0], count => 1};\nmy %likes;\nfor (0..$sum-1) {\n    my $id = $array[$_];\n    my $count = ++$likes{$id};\n    $max = {id => $id, count => $count} \n      if ($count > $max->{count});\n}\nprint $max->{id}, \"\\n\";\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my %likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        $likes{$array[$_]}++;\n        if ($likes{$array[$_]} > $max->{count}) {\n            $max = {id => $array[$_], count => $likes{$array[$_]}};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my %likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        $likes{$_}++;\n        if ($likes{$_} > $max->{count}) {\n            $max = {id => $_, count => $likes{$_}};\n        }\n    }\n    say $max->{id};\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\n\nwhile (<>) {\n    my ($likes, @array, $max, $count);\n    @array = split ' ', <>;\n    $max = {id => $array[0], count => 1};\n    for (@array) {\n        $count = ++$likes->{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nmy ($likes, @array, $max, $count);\n\nwhile (<>) {\n    @array = split ' ', <>;\n    $max = {id => $array[0], count => 1};\n    for (@array) {\n        $count = ++$likes->{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 6.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:23:29 PM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n\nmy $sum = $_;\nmy @array = split ' ', <>;\nmy $max = {id => $array[0], count => 1};\nmy %likes;\nfor (0..$sum-1) {\n    my $id = $array[$_];\n    my $count = ++$likes{$id};\n    $max = {id => $id, count => $count} \n      if ($count > $max->{count});\n}\nprint $max->{id}, \"\\n\";\n\n}\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        my $count = ++$likes->{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        my $count = ++$likes->{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my %likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        my $id = $array[$_];\n        $likes{$id}++;\n        if ($likes{$id} > $max->{count}) {\n            $max = {id => $id,\n                count => $likes{$id}};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 6.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:23:29 PM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nmy $sum = <>;\nmy @array = split ' ', <>;\n@array = map {$array[$_]} 0..$sum-1;\nmy $max = {id => $array[0], count => 1};\nmy %likes;\nfor (0..$sum-1) {\n    my $id = $array[$_];\n    my $count = ++$likes{$id};\n    $max = {id => $id, count => $count} \n      if ($count > $max->{count});\n}\nprint $max->{id}, \"\\n\";\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my %likes;\n    my $line;\n    chomp($line = <>);\n    my @array = split / /, $line;\n    my ($res_key, $res_value) = ($array[0], 1);\n    for (@array) {\n        $likes{$_}++;\n        if ($likes{$_} > $res_value) {\n            $res_value = $likes{$_};\n            $res_key = $_;\n        }\n    }\n    print $res_key, \"\\n\";\n}\n\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 6.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:23:29 PM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\n#my $sum = <>;\n#my @array = split ' ', <>;\n#@array = map {$array[$_]} 0..$sum-1;\n#my $max = {id => $array[0], count => 1};\n#my %likes;\n#for (0..$sum-1) {\n#    my $id = $array[$_];\n#    my $count = ++$likes{$id};\n#    $max = {id => $id, count => $count} \n#      if ($count > $max->{count});\n#}\n#print $max->{id}, \"\\n\";\n\nmy $sum = <>;\nmy @like_hist = split \" \", <>;\n@like_hist = map { $like_hist[$_] } 0..$sum-1;\n\nmy $counts = {};\nmy $max = {id => $like_hist[0], count => 1 };\n\nmy $k = 0;\nfor (0..$sum-1) {\n\tmy $id = $like_hist[$_];\n\tmy $count = ++$counts->{$id};\n\t$max = {id => $id, count => $count } if ($count > $max->{count});\n}\n\nprint $max->{id};\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my %likes;\n    my $line;\n    my $max;\n    chomp($line = <>);\n    my @array = split / /, $line;\n    $max = {id => $array[0], count => 1};\n    for (@array) {\n        $likes{$_}++;\n        if ($likes{$_} > $max->{count}) {\n            $max = {id => $_, count => $likes{$_}};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        $likes->{$_}++;\n        if ($likes->{$_} > $max->{count}) {\n            $max = {id => $_, count => $likes->{$_}};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my %likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        my $count = ++$likes{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes = {};\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        my $id = $array[$_];\n        $likes->{$id}++;\n        my $count = $likes->{$id};\n        if ($likes->{$id} > $max->{count}) {\n            $max = {id => $id,\n                    count => $count};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        my $id = $array[$_];\n        $likes->{$id}++;\n        if ($likes->{$id} > $max->{count}) {\n            $max = {id => $id,\n                    count => $likes->{$id}};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my $num = $_;\n    my $likes = {};\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (0..$num-1) {\n        my $id = $array[$_];\n        my $count = ++$likes->{$id};\n        if ($likes->{$id} > $max->{count}) {\n            $max = {id => $id,\n                    count => $count};\n        }\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nwhile (<>) {\n    my $likes;\n    my @array = split ' ', <>;\n    my $max = {id => $array[0], count => 1};\n    for (@array) {\n        my $count = ++$likes->{$_};\n        $max = {id => $_, count => $count}\n          if ($count > $max->{count});\n    }\n    print $max->{id}, \"\\n\";\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 6.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:23:29 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use 5.020;\n\n#my $sum = <>;\n#my @array = split ' ', <>;\n#@array = map {$array[$_]} 0..$sum-1;\n#my $max = {id => $array[0], count => 1};\n#my %likes;\n#for (0..$sum-1) {\n#    my $id = $array[$_];\n#    my $count = ++$likes{$id};\n#    $max = {id => $id, count => $count} \n#      if ($count > $max->{count});\n#}\n#print $max->{id}, \"\\n\";\n\nmy $sum = <>;\nmy @like_hist = split \" \", <>;\n@like_hist = map { $like_hist[$_] } 0..$sum-1;\n\nmy $counts = {};\nmy $max = {id => $like_hist[0], count => 1 };\n\nmy $k = 0;\nfor (0..$sum-1) {\n\tmy $id = $like_hist[$_];\n\tmy $count = ++$counts->{$id};\n\t$max = {id => $id, count => $count } if ($count > $max->{count});\n}\n\nprint $max->{id};\n"}, {"source_code": "<>;$_=<>;$m=$i=0;for$x(split){$y=++$c[$x];if($y>$m){$m=$y;$i=$x}}print$i\n"}], "negative_code": [{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    chomp;\n    my $num = $_;\n    my ($res_key, $res_value) = (0, 0);\n    my %likes;\n    my $line = <>;\n    chomp($line);\n    my @array = split / /, $line;\n    for (@array) {\n        #print $_, \" \";\n        $likes{$_}++;\n        while (my ($key, $value) = each %likes) {\n            next if $key == $res_key;\n            if ($value > $res_value) {\n                $res_value = $value;\n                $res_key = $key;\n            }\n        }\n    }\n    print $res_key, \"\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n##!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\n#use 5.014;\n#use List::Util 'max';\n\n#while (<>) {\n$_ = <>;\n    chomp;\n    my $num = $_;\n    my ($res_key, $res_value) = (0, 0);\n    my %likes;\n    my $line = <>;\n    chomp($line);\n    my @array = split / /, $line;\n    for (@array) {\n        #print $_, \" \";\n        $likes{$_}++;\n        while (my ($key, $value) = each %likes) {\n            next if $key == $res_key;\n            if ($value > $res_value) {\n                $res_value = $value;\n                $res_key = $key;\n            }\n        }\n    }\n    print $res_key, \"\\n\";\n#}\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\n#use 5.014;\n\n#while (<>) {\n$_ = <>;\n    chomp;\n    my $num = $_;\n    my ($res_key, $res_value);\n    my %likes;\n    my $line = <>;\n    chomp($line);\n    my @array = split / /, $line;\n    ($res_key, $res_value) = ($array[0], 1);\n    for (@array) {\n        #print $_, \" \";\n        $likes{$_}++;\n        while (my ($key, $value) = each %likes) {\n            next if $key == $res_key;\n            if ($value > $res_value) {\n                $res_value = $value;\n                $res_key = $key;\n            }\n        }\n    }\n    print $res_key, \"\\n\";\n#}\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    my %likes;\n    my @array = split / /, <>;\n    my ($res_key, $res_value) = ($array[0], 1);\n    for (@array) {\n        $likes{$_}++;\n        if ($likes{$_} > $res_value) {\n            $res_value = $likes{$_};\n            $res_key = $_;\n        }\n    }\n    print $res_key, \"\\n\";\n}\n\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\n#use 5.014;\n\nwhile (<>) {\n    chomp;\n    my $num = $_;\n    my ($res_key, $res_value) = (0, 0);\n    my %likes;\n    my $line = <>;\n    chomp($line);\n    my @array = split / /, $line;\n    for (@array) {\n        #print $_, \" \";\n        $likes{$_}++;\n        while (my ($key, $value) = each %likes) {\n            next if $key == $res_key;\n            if ($value > $res_value) {\n                $res_value = $value;\n                $res_key = $key;\n            }\n        }\n    }\n    print $res_key, \"\\n\";\n}\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 11:29:06 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.020;\n\nwhile (<>) {\n    chomp;\n    my $num = $_;\n    my ($res_key, $res_value) = (0, 0);\n    my %likes;\n    my $line = <>;\n    chomp($line);\n    my @array = split / /, $line;\n    for (@array) {\n        #print $_, \" \";\n        $likes{$_}++;\n        while (my ($key, $value) = each %likes) {\n            next if $key == $res_key;\n            if ($value > $res_value) {\n                $res_value = $value;\n                $res_key = $key;\n            }\n        }\n    }\n    print $res_key, \"\\n\";\n}\n\nexit 0;\n"}], "src_uid": "e4a2354159fc4cab7088e016cf17ae6c"}
{"source_code": "$PI = 3.141592653589793;\n($d, $h, $v, $e) = split ' ', <>;\n$now = $d ** 2 / 4 * $PI * $h;\n$up = $e * $d ** 2 / 4 * $PI;\nprint $up > $v ? \"NO\\n\" : \"YES\\n\" . $now / ($v - $up)", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $pi = 3.1415926535897;\n\nsub solve {\n\tmy ($d, $h, $v, $e) = split(\" \", shift);\n\t$e = $e * $pi * ($d ** 2) / 4;\n\tif ($v <= $e) {\n\t\treturn \"NO\";\n\t}\n\treturn \"YES\\n\" . ($h * $pi * ($d ** 2) / 4) / ($v - $e);\n};\n\nmy $input = <>;\nprint solve($input);"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $pi = 3.1415926535897;\n\nsub solve {\n\tmy ($d, $h, $v, $e) = split(\" \", shift);\n\t$e = $e * $pi * ($d ** 2) / 4;\n\tif ($v <= $e) {\n\t\treturn \"NO\";\n\t}\n\treturn ($h * $pi * ($d ** 2) / 4) / ($v - $e);\n};\n\nmy $input = <>;\nprint solve($input);"}], "src_uid": "fc37ef81bb36f3ac07ce2c4c3ec10d98"}
{"source_code": "$\\ = $/;\n\nwhile($n = <>){\n\t@_ = split \" \", $a = <>;\n\t($_ += ($n - $a) % $n * (-1) ** $i ++) %= $n for @_;\n\tprint qw(Yes No)[ !(\"@_\" eq join \" \", 0 .. $n - 1) ]\n\t}", "positive_code": [{"source_code": "use v5.10;\n\nchomp($n = <>);\n@c = (1 .. $n-1, 0);\n@c_ = ($n-1, 0 .. $n-2);\n@a = split / /, <>;\nforeach $i (0 .. $n-1) {\n\t$flag = 0;\n\t$a[$_]!=$_ and $flag=1 and last foreach (0 .. $n-1);\n\t$flag==0 and say \"Yes\" and exit;\n\tforeach (0 .. $n-1) {\n\t\tif ($_ & 1) {\n\t\t\t$a[$_] = $c_[$a[$_]];\n\t\t} else {\n\t\t\t$a[$_] = $c[$a[$_]];\n\t\t}\n\t}\n}\n$a[$_]!=$_ and say \"No\" and exit foreach (0 .. $n-1);\nsay \"Yes\";"}], "negative_code": [], "src_uid": "6c65ca365352380052b0c9d693e6d161"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $v, $h ) = split;\n\t\n\tmy @v = sort { $a <=> $b } map ~~<>, 1 .. $v;\n\tchomp @v;\n\t\n\tpush @v, 1e9 + 0;\n\t\n\tno warnings;\n\tmy @h = sort { $a <=> $b } map { ( split )[ 1 ] } grep $_ == 1, map ~~<>, 1 .. $h;\n\tuse warnings;\n\t\n\t$debug and print \" h: [@h]\";\n\t$debug and print \" v: [@v]\";\n\t\n\tmy $c_h = @h;\n\t\n\tmy @ans;\n\tmy $i = 0;\n\t\n\tfor my $v ( @v ){\n\t\t\n\t\tmy $cnt = 0;\n\t\t\n\t\twhile( @h ){\n\t\t\tmy $h = shift @h;\n\t\t\tif( $v <= $h ){\n\t\t\t\tunshift @h, $h;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t$cnt ++;\n\t\t\t}\n\t\t\n\t\tpush @ans, $c_h - $cnt + $i;\n\t\t\n\t\t$c_h -= $cnt;\n\t\t\n\t\t$i ++;\n\t\t}\n\t\n\t$debug and print \" ans: [@ans]\";\n\t\n\tprint 0 + ( sort { $a <=> $b } @ans )[ 0 ];\n\t}", "positive_code": [{"source_code": "$_ = <>;\n\n@v = sort { $a <=> $b } 1e9, map ~~<>, 1 .. $_;\n\t\n$c = @h = sort { $a <=> $b } map { ( split )[ 1 ] } grep /^1 /, map ~~<>, 1 .. ( split )[ 1 ];\n\n$min = 1e9;\n\nfor( @v ){\n\t\n\twhile( @h ){\n\t\t$_ > $h[ 0 ] ? do { shift @h; $c -- }\n\t\t\t: last\n\t\t}\n\t\n\t$q = $c + $i ++;\n\t\n\t$min > $q and $min = $q;\n\t}\n\t\nprint $min"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $v, $h ) = split;\n\t\n\tmy @v = sort { $a <=> $b } map ~~<>, 1 .. $v;\n\tchomp @v;\n\t\n\tpush @v, 1e9 + 0;\n\t\n\tno warnings;\n\tmy @h = sort { $a <=> $b } map { ( split )[ 1 ] } grep $_ == 1, map ~~<>, 1 .. $h;\n\tuse warnings;\n\t\n\t$debug and print \" h: [@h]\";\n\t$debug and print \" v: [@v]\";\n\t\n\tmy $c_h = @h;\n\t\n\tmy @ans;\n\tmy $i = 0;\n\t\n\tfor my $v ( @v ){\n\t\t\n\t\tmy $cnt = 0;\n\t\t\n\t\twhile( @h ){\n\t\t\tmy $h = shift @h;\n\t\t\tif( $v <= $h ){\n\t\t\t\tunshift @h, $h;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t$cnt ++;\n\t\t\t}\n\t\t\n\t\tpush @ans, $c_h - $cnt + $i;\n\t\t\n\t\t$i ++;\n\t\t}\n\t\n\t$debug and print \" ans: [@ans]\";\n\t\n\tprint 0 + ( sort { $a <=> $b } @ans )[ 0 ];\n\t}"}], "src_uid": "00eb4442eb86ccc7352b63dc23354abf"}
{"source_code": "sub max {\n\tmy $a = shift;\n\tmy $b = (@_ == 1? shift: max(@_));\n\t$a > $b? $a: $b;\n}\n\n$_ = <>; chomp; @char = split //;\nfor $char (@char) {\n\tif ($char eq \"a\") {\n\t\t\t$aba = max($aba, $a, $ab) + 1;\n\t\t\t$a += 1;\n\t} else {\n\t\t$ab = max($a, $ab) + 1;\n\t}\n}\nprint max($a, $ab, $aba);", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t$debug and print \"[$_]\";\n\t\n\tmy $A = () = /a/g;\n\t\n\tmy $from_L = 0;\n\tmy $from_R = 0;\n\tmy $max_L = 0;\n\tmy $max_R = 0;\n\t\n\twhile( /./g ){\n\t\t$from_L += 1 - 2 * ( $& eq 'a' );\n\t\t$from_L < 0 and $from_L = 0;\n\t\t$max_L < $from_L   and $max_L = $from_L;\n\t\t}\n\t\n\tmy $rev = reverse $_;\n\twhile( $rev =~ /./g ){\n\t\t$from_R += 1 - 2 * ( $& eq 'a' );\n\t\t$from_R < 0 and $from_R = 0;\n\t\t$max_R < $from_R and $max_R = $from_R;\n\t\t}\n\t\n\t$debug and print \"max_L: $max_L\";\n\t$debug and print \"max_R: $max_R\";\n\t\n\tprint $A + ( $max_L > $max_R ? $max_L : $max_R );\n\n\t$debug and print '-' x 20;\n\t}"}, {"source_code": "$_ = <>;\n\nfor( split //, $_ . 'a' x 5e3 . reverse ){\n\t\t( $L += $_ cmp 'ab' ) =~ s/-/0 /;\n\t\t$max < $L and $max = $L;\n\t\t}\n\nprint $max + ( () = /a/g )"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 1;\n\nwhile(<>){\n\tmy $max_b = 0;\n\t\n\t/(b*)(??{ $max_b < length $1 and $max_b = length $1; 'X' })/;\n\t\n\tmy $A = () = /a/g;\n\t\n\tprint $max_b + $A;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $max = -~0;\n\t\t\n\t/(a*b*)(?=(a*)(??{ 0 and print \"$1.$2\"; $max < length( $1.$2 ) and $max = length( $1.$2 ); \"X\"}))/;\n\t\n\tprint $max;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 1;\n\nwhile(<>){\n\tchomp;\n\t\t\n\tmy $max_b = length( ( grep length, sort split /a+/ )[ 0 ] );\n\t\n\tmy $A = () = /a/g;\n\t\n\tprint $max_b + $A;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $max = -~0;\n\t\t\n\t/(a*)(?=(b*a*)(??{ 0 and print \"$1.$2\"; $max < length( $1.$2 ) and $max = length( $1.$2 ); \"X\"}))/;\n\t\n\tprint $max;\n\t}"}], "src_uid": "c768f3e52e562ae1fd47502a60dbadfe"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\tmy %h;\n\tmy %w;\n\t\n\tfor (1 .. $m){\n\t\t($c, $v) = split ' ', <>;\n\t\t$h{ $c } //= [];\n\t\tpush @{ $h{ $c } }, $v;\n\t\t$h{ $v } //= [];\n\t\tpush @{ $h{ $v } }, $c;\n\t\t}\n\t\n\tfor (1 .. $n){\n\t\t$w{ $_ } //= 1;\n\t\tfor my $i ( @{ $h{ $_ } } ){\n\t\t\t$w{ $i } //= 1;\n\t\t\t$i > $_ or next;\n\t\t\t$w{ $i } > $w{ $_ } or $w{ $i } = $w{ $_ } + 1;\n\t\t\t}\n\t\t}\n\t\t\n\t$max = 0;\n\tfor (1 .. $n){\n\t\t$mult = $w{ $_ } * @{ $h{ $_ } };\n\t\t$mult > $max and $max = $mult;\n\t\t}\n\t\n\tprint  \n\t\t$max;\n\t}", "positive_code": [{"source_code": "$n = <>;\n\nfor (<>){\n\t($c, $v) = split;\n\tpush @{ $h{ $c } }, $v;\n\tpush @{ $h{ $v } }, $c;\n\t}\n\t\nfor (1 .. $n){\n\tfor $i ( @{ $h{ $_ } } ){\n\t\t$i < $_ or $w{ $i } > $w{ $_ } or $w{ $i } = $w{ $_ } + 1;\n\t\t}\n\t}\n\nprint( (sort {$b <=> $a} map ++ $w{ $_ } * @{ $h{ $_ } }, 1 .. $n )[ 0 ] )"}], "negative_code": [], "src_uid": "2596db1dfc124ea9e14c3f13c389c8d2"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k1, $k2 ) = split;\n\tmy( $W, $B ) = split ' ', <>;;\n\t\n\tif( ( $W < ( $k1 + $k2 ) / 2 or\n\t\t$W == ( $k1 + $k2 ) / 2 and ( $k1 + $k2 ) % 2 == 0 )\n\t\tand \n\t\t( $B < ( ( $n - $k1 ) + ( $n - $k2 ) ) / 2 or\n\t\t$B == ( ( $n - $k1 ) + ( $n - $k2 ) ) / 2  \n\t\tand ( ( $n - $k1 ) + ( $n - $k2 ) ) % 2 == 0 )\n\t\t){\n\t\tprint 'YES';\n\t\t}\n\telse{\n\t\tprint 'NO';\n\t\t}\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nmy ($t) = map {$_ - 0} split(/\\s/o,<STDIN>);\r\nwhile( $t -- > 0 ){\r\n  my ($n,$k1,$k2) = map {$_ - 0} split(/\\s/o,<STDIN>);\r\n  my ($w,$b) = map {$_ - 0} split(/\\s/o,<STDIN>);\r\n  if( $k1 < $k2 ){\r\n    my $tmp = $k1; $k1 = $k2; $k2 = $tmp;\r\n  }\r\n  if( $k2 + int(abs($k1-$k2)/2) >= $w and $n-$k1 + int(abs($k1-$k2)/2) >= $b ){\r\n    print \"YES\\n\";\r\n  } else {\r\n    print \"NO\\n\";\r\n  }\r\n}\r\n\r\n"}], "negative_code": [], "src_uid": "26354d2628f26eb2eff9432bd46400d5"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n,$k) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $r;\r\n  if( $n == $k ){\r\n    $r = 1;\r\n  } elsif( $n > $k ){\r\n    if( $n % $k == 0 ){\r\n      $r = 1;\r\n    } else {\r\n      $r = 2;\r\n    }\r\n  } else { # $n < $k\r\n    $r = int(( $k + ( $n - 1 ) ) / $n);\r\n  }\r\n  print \"$r\\n\";\r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\tif( $n <= $k ){\n\t\tprint 0 + ( int $k / $n ) + !!( $k % $n );\n\t\t}\n\telsif( $n % $k == 0 ){\n\t\tprint 1;\n\t\t}\n\telse{\n\t\tprint 2;\n\t\t}\n\t}"}, {"source_code": "use v5.20;\r\nuse integer;\r\nfor ( 1 .. <> ) {\r\n    my ( $n, $k ) = split ' ', <>;\r\n    say $n < $k ? ( $k + $n - 1 ) / $n : $n % $k ? 2 : 1;\r\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = sort { $b <=> $a } split;\n\t\n\tprint 0 + ( int $n / $k ) + !!( $n % $k );\n\t}"}], "src_uid": "a28b84c9d1a54e322ab2d54bd5ab45c8"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nOUTER:\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\t@_ = sort { $a <=> $b } @_;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_[ $_ ] for 0 .. @_ - 3;\n\t\n\tif( $sum == $_[ @_ - 2 ] ){\n\t\tpop @_ for 1 .. 2;\n\t\tprint \"@_\";\n\t\t}\n\telse{\n\t\tfor my $i ( 0 .. @_ - 2 ){\n\t\t\tif( $_[ @_ - 1 ] == $sum + $_[ @_ - 2 ] - $_[ $i ] ){\n\t\t\t\tprint join ' ', map $_[ $_ ], grep { $_ != $i } 0 .. @_ - 2;\n\t\t\t\tnext OUTER;\n\t\t\t\t}\n\t\t\t}\n\t\tprint -1;\n\t\t}\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @B = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $sm = 0;\r\n  my $mx1 = -1;\r\n  my $mx2 = -1;\r\n  my %chk = ();\r\n  for(my $i=0;$i<$n+2;$i++){\r\n    my $v = $B[$i];\r\n    $sm += $v;\r\n    $chk{$v} ++;\r\n    if( $v > $mx1 ){\r\n      $mx2 = $mx1;\r\n      $mx1 = $v;\r\n    } elsif( $v > $mx2 ){\r\n      $mx2 = $v;\r\n    }\r\n  }\r\n  \r\n  my $sm1 = $sm - $mx1;\r\n  my $xg  = $sm1 - $mx1;\r\n  if( $xg >= 1 and exists($chk{$xg}) ){\r\n    unless( $chk{$xg} == 1 and $xg == $mx1 ){\r\n      my $u_xg = 1; my $u_mx1 = 1;\r\n      my $sp = '';\r\n      for(my $i=0;$i<$n+2;$i++){\r\n        if( $u_xg and $B[$i]==$xg ){\r\n          $u_xg = undef;      next;\r\n        }\r\n        if( $u_mx1 and $B[$i]==$mx1 ){\r\n          $u_mx1 = undef;      next;\r\n        }\r\n        print \"$sp$B[$i]\";\r\n        $sp = ' ';\r\n      }\r\n      print \"\\n\";\r\n      next;\r\n    }\r\n  }\r\n  \r\n  my $sm1 = $sm - $mx2 - $mx1;\r\n  my $xg  = $mx1;\r\n  if( $sm1 == $mx2 ){\r\n    my $u_xg = 1; my $u_mx2 = 1;\r\n    my $sp = '';\r\n    for(my $i=0;$i<$n+2;$i++){\r\n      if( $u_xg and $B[$i]==$xg ){\r\n        $u_xg = undef;      next;\r\n      }\r\n      if( $u_mx2 and $B[$i]==$mx2 ){\r\n        $u_mx2 = undef;      next;\r\n      }\r\n      print \"$sp$B[$i]\";\r\n      $sp = ' ';\r\n    }\r\n    print \"\\n\";\r\n    next;\r\n  }\r\n  print \"-1\\n\";\r\n}\r\n\r\nexit(0);\r\n\r\n"}], "negative_code": [], "src_uid": "ce667a8fb60841c994aebedb35a3b0d8"}
{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\nmy $line = <>;\nchomp $line;\nmy ($N, $K) = split(/ +/, $line);\n\n$line = <>;\nchomp $line;\nmy @A = split(/ +/, $line);\n\nmy @D;\nfor (my $i = 0; $i < $N; ++$i) {\n   push(@D, []);\n}\n\nmy ($level, $col) = (0, 1);\nfor (my $t = 1; $col <= $K; ++$t) {\n   my $new_col = 0;\n   my $none_left = 1;\n   for (my $i = 0; $i < $N; ++$i) {\n      if ($A[$i] > 0) {\n         $A[$i]--;\n         push( @{$D[$i]}, $col);\n         $none_left = 0 if ($A[$i] > 0);\n      }\n      else {\n         $new_col = 1;\n      #  printf \"t = %d  i = %d\\n\", $t, $i;\n      }\n   }\n   last if $none_left;\n   $col++ if $new_col;\n}\n\n#print $col, \"\\n\";\nif ($col > $K) {\n   print \"NO\\n\"\n}\nelse {\n   print \"YES\\n\";\n   for (my $i = 0; $i < $N; ++$i) {\n      for (my $j = 0; $j < @{$D[$i]}; ++$j) {\n         print ' ' if $j > 0;\n         print $D[$i][$j];\n      }\n      print \"\\n\"\n   }\n}", "positive_code": [{"source_code": "$\\ = $/;\n$, = $\";\n$_ = <>;\n@_ = ( 1 .. ( $k = (split)[ 1 ] ) ) x 1e2;\n$_ = <>;\nprint qw (NO YES)[ $f = $k >= eval join '-', (sort {$a <=> $b} split) [-1, 0] ];\nprint @_[0 .. $& - 1] while $f && /\\d+/g"}, {"source_code": "$\\ = $/;\n$, = $\";\nwhile(<>){\n\t(undef, $k) = split;\n\t@_ = (1 .. $k) x 1e2;\n\t$_ = <>;\n\t$f = $k < abs eval join '-', (sort {$a <=> $b} split)[-1, 0];\n\tprint qw(YES NO)[ $f ];\n\t$f && next;\n\tprint @_[0 .. $& - 1] while /\\d+/g;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\nmy $line = <>;\nchomp $line;\nmy ($N, $K) = split(/ +/, $line);\n\n$line = <>;\nchomp $line;\nmy @A = split(/ +/, $line);\n\nmy @F = (1) x $N;\nmy @D;\nfor (my $i = 0; $i < $N; ++$i) {\n   push(@D, []);\n}\n\nmy ($level, $col) = (0, 1);\nfor (my $t = 1; $col <= $K; ++$t) {\n   my $new_col = 0;\n   my $none_left = 1;\n   for (my $i = 0; $i < $N; ++$i) {\n      if ($A[$i] > 0) {\n         $A[$i]--;\n         push( @{$D[$i]}, $col);\n         $none_left = 0;\n      }\n      else {\n         if ($F[$i]) {\n            $F[$i] = 0;\n            $new_col = 1;\n         #  printf \"t = %d  i = %d\\n\", $t, $i;\n         }\n      }\n   }\n   last if $none_left;\n   $col++ if $new_col;\n}\n\n#print $col, \"\\n\";\nif ($col > $K) {\n   print \"NO\\n\"\n}\nelse {\n   print \"YES\\n\";\n   for (my $i = 0; $i < $N; ++$i) {\n      for (my $j = 0; $j < @{$D[$i]}; ++$j) {\n         print ' ' if $j > 0;\n         print $D[$i][$j];\n      }\n      print \"\\n\"\n   }\n}"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\nmy $line = <>;\nchomp $line;\nmy ($N, $K) = split(/ +/, $line);\n\n$line = <>;\nchomp $line;\nmy @A = split(/ +/, $line);\n\nmy @F = (1) x $N;\nmy @D;\nfor (my $i = 0; $i < $N; ++$i) {\n   push(@D, []);\n}\n\nmy ($level, $col) = (0, 1);\nfor (my $t = 1; $col <= $K; ++$t) {\n   my $new_col = 0;\n   my $none_left = 1;\n   for (my $i = 0; $i < $N; ++$i) {\n      if ($A[$i] > 0) {\n         $A[$i]--;\n         push( @{$D[$i]}, $col);\n         $none_left = 0 if $A[$i] > 0;\n      }\n      else {\n         if ($F[$i]) {\n            $F[$i] = 0;\n            $new_col = 1;\n         #  printf \"t = %d  i = %d\\n\", $t, $i;\n         }\n      }\n   }\n   last if $none_left;\n   $col++ if $new_col;\n}\n\n#print $col, \"\\n\";\nif ($col > $K) {\n   print \"NO\\n\"\n}\nelse {\n   print \"YES\\n\";\n   for (my $i = 0; $i < $N; ++$i) {\n      for (my $j = 0; $j < @{$D[$i]}; ++$j) {\n         print ' ' if $j > 0;\n         print $D[$i][$j];\n      }\n      print \"\\n\"\n   }\n}"}, {"source_code": "$\\ = $/;\nwhile(<>){\n\t(undef, $k) = split;\n\t@_ = (1 .. $k) x 1e2;\n\t$_ = <>;\n\t$f = $k < abs eval join '-', (sort {$a <=> $b} split)[-1, 0];\n\tprint qw(YES NO)[ $f ];\n\t$f && next;\n\tprint @_[0 .. $& - 1] while /\\d+/g;\n\t}"}], "src_uid": "e512285d15340343e34f596de2be82eb"}
{"source_code": "<>, $_ = <>;\n\n$an += pos while /[02468]/g;\nprint 0 + $an;\n", "positive_code": [{"source_code": "<>, $_ = <>;\n$as += pos while /[02468]/g;\nprint 0 + $as;\n"}, {"source_code": "<>, $_ = <>;\n$as += pos while /[02468]/g;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprint 0 + $as;\n"}, {"source_code": "<>, $_ = <>;\n$as += pos while /[02468]/g;\n\nprint 0 + $as;\n"}, {"source_code": "<>, $_ = <>;\n$ans += pos while /[02468]/g;\nprint 0 + $ans;\n"}, {"source_code": "<>, $_ = <>;\n$ans += pos while /[02468]/g;\n\nprint 0 + $ans;\n"}, {"source_code": "<>, $_ = <>;\n$an += pos while /[02468]/g;\nprint 0 + $an;\n"}, {"source_code": "<>, $_ = <>;\n\n$as += pos while /[02468]/g;\nprint 0 + $as;\n"}, {"source_code": "<>, $_ = <>;\n\n$ans += pos while /[02468]/g;\nprint 0 + $ans;\n"}, {"source_code": "\n\n<>, $_ = <>;\n$as += pos while /[02468]/g;\nprint 0 + $as;\n"}, {"source_code": "<>, $_ = <>;\n$as += pos while /[02468]/g;\n\n\n\n\nprint 0 + $as;\n"}, {"source_code": "\n<>, $_ = <>;\n$as += pos while /[02468]/g;\nprint 0 + $as;\n"}, {"source_code": "<>, $_ = <>;\n$an += pos while /[02468]/g;\n\nprint 0 + $an;\n"}, {"source_code": "<>, $_ = <>;\n$as += pos while /[02468]/g;\n\n\n\n\n\n\n\n\nprint 0 + $as;\n"}, {"source_code": "<>, <> =~ /[02468](?{ $z += pos })(*F)/;\n\t\nprint 0 + $z"}, {"source_code": "<>, $_ = <>;\n\n$z += pos while /[02468]/g;\n\t\nprint 0 + $z"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tmy $sum = 0;\n\t\n\t/\n\t\t[02468]\n\t\t(?{ $sum += pos })\n\t\t(*F)\n\t/x;\n\t\n\tprint $sum;\n\t}"}], "negative_code": [{"source_code": "<>, $_ = <>;\n$ans += pos while /[02468]/g;\nprint $ans;\n"}, {"source_code": "<>, <> =~ /[02468](?{ $z += pos })(*F)/;\n\t\nprint $z"}], "src_uid": "43a65d1cfe59931991b6aefae1ecd10e"}
{"source_code": "use strict;\nuse POSIX;\nmy ($n,$k)=split(' ',<>);\n$_=<>;\nchomp;\nmy @l = split('',$_);\n$\\ = \"\\n\";\nunshift (@l,\"lal\");\nmy $adfs = 1 if $k == 1;\n\n\n\n\n\n\nif($k >= floor($#l/2)+1)\n{\n    while($k<=$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n                print \"RIGHT\" if  $k++ <$#l;\n    }\n    $k--;\n    \n    goto exit if $adfs;\n    \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        \n        print \"LEFT\" if $k-- >1;\n    }\n}\nelse \n{\n \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"LEFT\" if $k-- >1;\n    }\n    $k++;\n    while($k<=$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"RIGHT\" if  $k++ <$#l;\n       \n    }\n}\nexit", "positive_code": [{"source_code": "$t = <>;\n($n,$k) = split (/ /, $t);\n$n = $n + 0;\n$k = $k + 0;\n$s = <>;\nchomp ($s);\n@s = split (\"\", $s);\nif ($k > $n - $k)\n{\n\twhile ($k < $n)\n\t{\n\t\tprint \"RIGHT\\n\";\n\t\t$k = $k + 1;\n\t}\n\tprint \"PRINT $s[$n - 1]\\n\";\n\t$k = $k - 1;\n\twhile ($k > 0)\n\t{\n\t\t$k = $k - 1;\n\t\tprint \"LEFT\\n\";\n\t\tprint \"PRINT $s[$k]\\n\";\n\t}\n}\nelse\n{\n\twhile ($k > 1)\n\t{\n\t\tprint \"LEFT\\n\";\n\t\t$k = $k - 1;\n\t}\n\tprint \"PRINT $s[0]\\n\";\n\twhile ($k < $n)\n\t{\n\t\tprint \"RIGHT\\n\";\n\t\tprint \"PRINT $s[$k]\\n\";\n\t\t$k = $k + 1;\n\t}\n}\n"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$m)=split/ /;\n\t$_=<>;\n\tchomp;\n\t\n\tif ($n<$m*2){\n\t\tfor $i(1..($n-$m)){\n\t\t\tprint \"RIGHT\\n\"\n\t\t\t}\n\t\t$_=reverse $_;\n\t\ts/.// and print \"PRINT $&\\n\";\n\t\ts/./print \"LEFT\\nPRINT $&\\n\"/ge;\n\t\t\n\t\t}\n\telse {\n\t\tfor $i(1..($m-1)){\n\t\t\tprint \"LEFT\\n\"\n\t\t\t}\t\t\n\t\ts/.// and print \"PRINT $&\\n\";\n\t\ts/./print \"RIGHT\\nPRINT $&\\n\"/ge;\n\t\t\n\t\t\n\t\t}\n\t\n\t\n\t\n\t\n\t}"}, {"source_code": "($n, $k) = split /\\s+/, <>;\n$s = <>;\nchomp $s;\n$l = \"LEFT\\n\";\n$r = \"RIGHT\\n\";\nif($k - 1 > $n - $k){\n    $k = $n - $k + 1;\n    $s = reverse $s;\n    my $t = $l;\n    $l = $r;\n    $r = $t;\n}\nprint $l x ($k - 1);\n@a = map {\"PRINT \".$_.\"\\n\"} split '', $s;\nprint shift @a;\nprint map {$r.$_} @a;\n"}], "negative_code": [{"source_code": "use strict;\nuse POSIX;\nmy ($n,$k)=split(' ',<>);\n$_=<>;\nchomp;\nmy @l = split('',$_);\n$\\ = \"\\n\";\nunshift (@l,\"lal\");\nmy $adfs = 1 if $k == 1;\n\n\n\n\n\n\nif($k>= floor($#l/2))\n{\n    do\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n                print \"RIGHT\" if  $k++ <$#l;\n    }\n    while ($k<=$#l);\n    $k--;\n    \n    while ($k>0 and !$adfs)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        \n        print \"LEFT\" if $k-- >1;\n    }\n}\nelse \n{\n \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"LEFT\" if $k-- >1;\n    }\n    \n    do{\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"RIGHT\" if  $k++ <$#l;\n       \n    }while($k<$#l);\n}\nexit\n"}, {"source_code": "use strict;\nmy ($n,$k)=split(' ',<>);\n$_=<>;\nchomp;\nmy @l = split('',$_);\n$\\ = \"\\n\";\nunshift (@l,\"lal\");\nif($k>= ($#l/2))\n{\n    while($k<$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n                print \"RIGHT\" if  $k++ <$#l;\n    }\n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        \n        print \"LEFT\" if $k-- >1;\n    }\n}\nelse \n{\n \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"LEFT\" if $k-- >1;\n    }\n    while($k<=$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"RIGHT\" if  $k++ <$#l;\n       \n    }\n}\n"}, {"source_code": "use strict;\nuse POSIX;\nmy ($n,$k)=split(' ',<>);\n$_=<>;\nchomp;\nmy @l = split('',$_);\n$\\ = \"\\n\";\nunshift (@l,\"lal\");\nmy $adfs = 1 if $k == 1;\n\n\n\n\n\n\nif($k>= floor($#l/2))\n{\n    while($k<=$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n                print \"RIGHT\" if  $k++ <$#l;\n    }\n    $k--;\n    \n    goto exit if $adfs;\n    \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        \n        print \"LEFT\" if $k-- >1;\n    }\n}\nelse \n{\n \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"LEFT\" if $k-- >1;\n    }\n    while($k<$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"RIGHT\" if  $k++ <$#l;\n       \n    }\n}\nexit\n"}, {"source_code": "use strict;\nuse POSIX;\nmy ($n,$k)=split(' ',<>);\n$_=<>;\nchomp;\nmy @l = split('',$_);\n$\\ = \"\\n\";\nunshift (@l,\"lal\");\nmy $adfs = 1 if $k == 1;\n\n\n\n\n\n\nif($k>= floor($#l/2))\n{\n    while($k<=$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n                print \"RIGHT\" if  $k++ <$#l;\n    }\n    $k--;\n    \n    \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        \n        print \"LEFT\" if $k-- >1;\n    }\n}\nelse \n{\n \n    \n    while ($k>0)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"LEFT\" if $k-- >1;\n    }\n    while($k<$#l)\n    {\n        print \"PRINT $l[$k]\" if defined $l[$k];\n        $l[$k] = undef;\n        print \"RIGHT\" if  $k++ <$#l;\n       \n    }\n}\n"}], "src_uid": "e3a03f3f01a77a1983121bab4218c39c"}
{"source_code": "for (1..<>) {\r\n        chomp (my $in = <>);\r\n        my ($n, $l, $r, $k) = split / /, $in;\r\n        $minprice = $l;\r\n        $maxprice = $r;\r\n        $total_cash = $k;\r\n        chomp (my $in = <>);\r\n        my @a = split / /, $in;\r\n\r\n        @a = sort {$a <=> $b} @a;\r\n        $t = 0;\r\n\r\n        foreach (@a) {\r\n                $_ < $minprice and next;\r\n                $_ > $maxprice and last;\r\n                $t++;\r\n                $k -= $_;\r\n                $k <= 0 and last;\r\n        }\r\n        $k < 0 and $t--;\r\n        print $t, \"\\n\";\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $l, $r, $k ) = split;\n\t@_ = split ' ', <>;\n\t\n\t@_ = grep $_ <= $r, grep $_ >= $l, @_;\n\t\n\t@_ = sort { $a <=> $b } @_;\n\t\n\tmy $cnt = 0;\n\t\n\twhile( @_ and $k >= $_[ 0 ] ){\n\t\t$k -= shift @_;\n\t\t$cnt ++;\n\t\t}\n\t\n\tprint $cnt;\n\t}"}], "negative_code": [], "src_uid": "f577695d39a11e8507681f307677c883"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($a,$b) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  if( $a < $b ){\r\n    print \"1\\n\";\r\n    next;\r\n  }\r\n  my $mn = 10**9;\r\n  my $ans = 0;\r\n  if( $b == 1 ){\r\n    $b++; $ans ++;\r\n  }\r\n  for(my $bb = $b; $bb <= $b+35; $bb++){\r\n    my $cnt = $ans + ($bb-$b);\r\n    my $t = 1;\r\n    while( $bb ** $t <= $a ){\r\n      $t++;\r\n    }\r\n    my $v = $cnt + $t;\r\n    $mn = $v if $v < $mn;\r\n  }\r\n  print \"$mn\\n\";\r\n  \r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B ) = split;\n\t\n\tmy $ans = 0;\n\t\n\t$B == 1 and do { $B ++; $ans ++; };\n\t\n\tmy @cand;\n\t\n\tfor my $i ( 0 .. 10 ){\n\t\tmy $B2 = $B + $i;\n\t\tmy $A2 = $A;\n\t\tmy $ans2 = $ans + $i;\n\t\t\n\t\twhile( $A2 >= 1 ){\n\t\t\t$A2 /= $B2;\n\t\t\t$A2 = int $A2;\n\t\t\t$ans2 ++;\n\t\t\t}\n\t\t\n\t\tpush @cand, $ans2;\n\t\t}\n\t\n\tprint +( sort { $a <=> $b } @cand )[ 0 ];\n\t}"}], "negative_code": [], "src_uid": "2b757fa66ce89046fe18cdfdeafa6660"}
{"source_code": "$_=<>; chomp;\n/^(\\w+@\\w+)+$/ ? (s/(\\w\\@\\w+)(?=\\w\\@)/$1,/g , print) : print \"No solution\"\n", "positive_code": [{"source_code": "$_=<>; chomp;\nif(/^(\\w+@\\w+)+$/) {\n#print \"|$`<$&>$'|\\n\";\n  s/(\\w\\@\\w+)(?=\\w\\@)/$1,/g;\n  print;\n} else {\n  print \"No solution\";#and exit if(/\\@\\w?\\@/ or /^\\@|\\@$/ or $_!~/\\@/);\n}\n"}, {"source_code": "$_=<>;\nchomp;\nprint \"No solution\" and exit if(/\\@\\w?\\@/ or /^\\@|\\@$/ or $_!~/\\@/);\ns/(\\w\\@\\w+)(?=\\w\\@)/$1,/g;\nprint;\n\n"}, {"source_code": "$_=<>; chomp;\n/^(\\w+@\\w+)+$/ ? (s/(\\w\\@\\w+)(?=\\w\\@)/$1,/g , print) : print \"No solution\"\n"}, {"source_code": "$a = <>; chomp $a;\n$k = $a =~ y/@/@/;\nwhile ($a =~ /\\w+\\@\\w+(?!\\@)/g) {\n\tpush @a, $&;\n}\n# print \"@a\\n\";\n$b=join \"\", @a;\nif ($k==@a && $a eq $b) {\n\t$c = join \",\", @a;\n\tprint $c\n} else {\n\tprint \"No solution\"\n}"}, {"source_code": "my $list = <STDIN>;\nif ($list =~ m/^[a-z]+@([a-z]{2,}@)*[a-z]+$/) {\n\twhile($list =~ s/(@[a-z])([a-z]+@)/$1,$2/g) {}\n\tprint $list;\n} else {\n\tprint \"No solution\\n\"\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#\t <>=~/ (\\d+) (\\d+) /;\n\t\nwhile(<>){\n\ts/(@\\w)(\\w+@)/$1,$2/g while /@(\\w)(\\w+)@/;\n\tprint /@\\w?@/||/^@/||/\\@$/||!/@/?\"No solution\\n\":\"$_\";\n\t}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "$_=<>;\nchomp;\nprint \"No solution\" and exit if(/\\@\\w\\@/ or /^\\@|\\@$/);\ns/(\\w\\@\\w)(?=\\w)/$1,/g;\nprint;\n\n"}, {"source_code": "$_=<>; chomp;\n/^(\\w+@\\w+)+$/ ? s/(\\w\\@\\w+)(?=\\w\\@)/$1,/g || print : print \"No solution\"\n"}, {"source_code": "$_=<>; chomp;\n/^(\\w+@\\w+)+$/ ? s/(\\w\\@\\w+)(?=\\w\\@)/$1,/g && print : print \"No solution\"\n"}, {"source_code": "$_=<>;\nchomp;\nprint \"No solution\" and exit if(/\\@\\w\\@/ or /^\\@|\\@$/);\ns/(\\w\\@\\w+)(?=\\w@)/$1,/g;\nprint;\n\n"}, {"source_code": "$_=<>;\nchomp;\nprint \"NO solution\" and exit if(/\\@\\w\\@/ or /^\\@|\\@$/);\ns/(\\w\\@\\w)(?=\\w)/$1,/g;\nprint;\n\n"}, {"source_code": "$_=<>;\nchomp;\nprint \"No solution\" and exit if(/\\@\\w\\@/ or /^\\@|\\@$/ or $_!~/@/);\ns/(\\w\\@\\w+)(?=\\w@)/$1,/g;\nprint;\n\n"}, {"source_code": "$a = <>; chomp $a;\n$c = $a =~ y/@/@/;\nwhile ($a =~ /[^\\@]\\@[^\\@]/g) {\n\tpush @a, $&;\n}\n$b=join \"\", @a;\nif ($a eq $b) {\n\t$c = join \",\", @a;\n\tprint $c\n} else {\n\tprint \"No solution\"\n}"}, {"source_code": "$a = <>;\n$c = $a =~ y/@/@/;\nwhile ($a =~ /[^\\@]\\@[^\\@]/g) {\n\tpush @a, $&;\n}\n$b=join \"\", @a;\nif ($a eq $b) {\n\t$c = join \",\", @a;\n\tprint $c\n} else {\n\tprint \"No solution\"\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#\t <>=~/ (\\d+) (\\d+) /;\n\t\nwhile(<>){\n\ts/(@\\w)(\\w+@)/$1,$2/g while /@(\\w)(\\w+)@/;\n\tprint /@\\w?@/||/^@/||/\\@$/?\"No solution\\n\":\"$_\";\n\t}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "71b4674e91e0bc5521c416cfc570a090"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $x ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy @cum;\n\t\n\tpush @cum, ( sort { $b <=> $a } @_ )[ 0 ];\n\t\n\tmy @sums = @_;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\t\n\t\tmy $max = -~0;\n\t\tfor my $j ( $i .. $n - 1 ){\n\t\t\t( $sums[ $j - $i ] += $_[ $j ] ) > $max and $max = $sums[ $j - $i ];\n\t\t\t}\n\t\tpush @cum, $max;\n\t\t}\n\t\n\tfor my $i ( reverse 0 .. @cum - 2 ){\n\t\t$cum[ $i ] = $cum[ $i ] > $cum[ $i + 1 ] ? \n\t\t\t$cum[ $i ] : $cum[ $i + 1 ];\n\t\t}\n\t\n\tunshift @cum, $cum[ 0 ];\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] += $x * $i;\n\t\t}\n\t\n\t$cum[ 0 ] < 0 and $cum[ 0 ] = 0;\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] = $cum[ $i ] > $cum[ $i - 1 ] ? \n\t\t\t$cum[ $i ] : $cum[ $i - 1 ];\n\t\t}\n\t\n\tprint \"@cum\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $x ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy @max;\n\t\n\tpush @max, ( sort { $b <=> $a } @_ )[ 0 ];\n\t\n\tmy @sums = @_;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\tshift @_;\n\t\tpop @sums;\n\t\t\n\t\tmy $max = -1_000_000_000;\n\t\tfor my $j ( 0 .. @sums - 1 ){\n\t\t\t$sums[ $j ] += $_[ $j ]; \n\t\t\t$sums[ $j ] > $max and $max = $sums[ $j ];\n\t\t\t}\n\t\tpush @max, $max;\n\t\t}\n\t\n\tmy @cum = @max;\n\t\n\tfor my $i ( reverse 0 .. @cum - 2 ){\n\t\t$cum[ $i ] = $cum[ $i ] > $cum[ $i + 1 ] ? \n\t\t\t$cum[ $i ] : $cum[ $i + 1 ];\n\t\t}\n\t\n\tunshift @cum, $cum[ 0 ];\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] += $x * $i;\n\t\t}\n\t\n\t$cum[ 0 ] < 0 and $cum[ 0 ] = 0;\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] = $cum[ $i ] > $cum[ $i - 1 ] ? \n\t\t\t$cum[ $i ] : $cum[ $i - 1 ];\n\t\t}\n\t\n\tprint \"@cum\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $x ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy @max;\n\t\n\tpush @max, ( sort { $b <=> $a } @_ )[ 0 ];\n\t\n\tmy @sums = @_;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\tshift @_;\n\t\tpop @sums;\n\t\t\n\t\tmy $max = -~0;\n\t\tfor my $j ( 0 .. @sums - 1 ){\n\t\t\t$sums[ $j ] += $_[ $j ]; \n\t\t\t$sums[ $j ] > $max and $max = $sums[ $j ];\n\t\t\t}\n\t\tpush @max, $max;\n\t\t}\n\t\n\tmy @cum = @max;\n\t\n\tfor my $i ( reverse 0 .. @cum - 2 ){\n\t\t$cum[ $i ] = $cum[ $i ] > $cum[ $i + 1 ] ? \n\t\t\t$cum[ $i ] : $cum[ $i + 1 ];\n\t\t}\n\t\n#\tprint \"@cum\";\n\t\n\tunshift @cum, $cum[ 0 ];\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] += $x * $i;\n\t\t}\n\t\n\t$cum[ 0 ] < 0 and $cum[ 0 ] = 0;\n\t\n#\tprint \"@cum\";\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] = $cum[ $i ] > $cum[ $i - 1 ] ? \n\t\t\t$cum[ $i ] : $cum[ $i - 1 ];\n\t\t}\n\t\n\tprint \"@cum\";\n\t\n#\tmy @ans;\n\t\n#\tmy $max = 0;\n#\t$max < $_ and $max = $_ for @max;\n\t\n#\tpush @ans, $max;\n\t\n#\tfor my $i ( 1 .. $n ){\n#\t\tmy $max = $ans[ @ans - 1 ];\n\t\t\n#\t\tfor my $j ( $i - 1 .. $n - 1 ){\n#\t\t\t$max[ $j ] += $x;\n\t\t\t\n#\t\t\t$max < $max[ $j ] and $max = $max[ $j ];\n#\t\t\t}\n\t\t\n#\t\tpush @ans, $max;\n#\t\t}\n\t\n#\tprint \"@ans\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# array\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $x ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy @cum;\n\t\n\tpush @cum, ( sort { $b <=> $a } @_ )[ 0 ];\n\t\n\tmy @sums = @_;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\t\n\t\tmy $max = -~0;\n\t\tfor my $j ( $i .. $n - 1 ){\n\t\t\t( $sums[ $j - $i ] += $_[ $j ] ) > $max and $max = $sums[ $j - $i ];\n\t\t\t}\n\t\tpush @cum, $max;\n\t\t}\n\t\n\tmy $cum = sub {\n\t\tfor my $i ( 1 .. @{ $_[ 0 ] } - 1 ){\n\t\t\t$_[ 0 ][ $i ] = $_[ 0 ][ $i ] > $_[ 0 ][ $i - 1 ] ? \n\t\t\t\t$_[ 0 ][ $i ] : $_[ 0 ][ $i - 1 ];\n\t\t\t}\n\t\t};\n\t\n\t@cum = reverse @cum;\n\t$cum->( \\@cum );\n\t@cum = reverse @cum;\n\t\n\tunshift @cum, $cum[ 0 ];\n\t\n\tfor my $i ( 1 .. @cum - 1 ){\n\t\t$cum[ $i ] += $x * $i;\n\t\t}\n\t\n\t$cum[ 0 ] < 0 and $cum[ 0 ] = 0;\n\t\n\t$cum->( \\@cum );\n\t\n\tprint \"@cum\";\n\t}\n"}], "negative_code": [], "src_uid": "a5927e1883fbd5e5098a8454f6f6631f"}
{"source_code": "$n=<>;\n@_=split/ /,<>;\n$k=0;\nfor $i(1..($n-1)){\n\nif ($_[$i-1]>$_[$i] ){\n$k++;\n$ii=$i;\n}\n\n}\n\nif ($k==0){\nprint 0\n}\nelsif ($k>1 or $_[0]<$_[$n-1]){\nprint -1\n}\nelse {\nprint $n-$ii\n}", "positive_code": [{"source_code": "chomp($n=<>);\nchomp($c=<>);\n@a = split(\" \", $c);\nuse List::Util qw(min);\n$v = min @a;\n$i = $#a;\n--$i until $a[$i] == $v;\n$i-- while $i && $a[$i - 1] == $v;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)] if $i;\nfor(1..$#a){ $bad = 1 if $a[$_] < $a[$_-1] }\n$i = $n if $i == 0;\nprint $bad ? -1 : $n - $i; \n"}, {"source_code": "$n = <>;\n@a = split(\" \", <>);\nuse List::Util qw(min);\n$v = min @a;\n$i = $#a;\n--$i until $a[$i] == $v;\n$i-- while $i && $a[$i - 1] == $v;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)] if $i;\nfor(1..$#a){ $bad = 1 if $a[$_] < $a[$_-1] }\n$i = $n if $i == 0;\nprint $bad ? -1 : $n - $i; \n"}, {"source_code": "$n = <>;\n@a = split(\" \", <>);\nuse List::Util qw(min);\n$i = $#a;\n$v = min @a;\n--$i until $a[$i] == $v;\n$i-- while $i && $a[$i - 1] == $v;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)] if $i;\nfor(1..$#a){ $bad = 1 if $a[$_] < $a[$_-1] }\n$i = $n if $i == 0;\nprint $bad ? -1 : $n - $i; \n"}, {"source_code": "chomp($n=<>);\nchomp($c=<>);\n@a = split(\" \", $c);\nuse List::Util qw(min);\n$v = min @a;\n$i = $#a;\n--$i until $a[$i] == $v;\nwhile($i && $a[$i-1] == $v){$i--};\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)] if $i;\nfor(1..$#a){\n    $ok = 1 if $a[$_] < $a[$_-1];\n}\nprint -1 if $ok;\n$i = $n if $i == 0;\nprint ($n - $i)  if !$ok;\n#print \"\\n@a k=$ok i=$i\\n\";\n"}, {"source_code": "<>;\n($a,@_)=split/ /,<>;\n$A=$a;\n\nfor (@_){\n\t$k++, $ii=@_-$i if $a>$_;\n\t$i++;\n\t$a=$_\n}\n\nprint $k>1 || $A<$_[@_-1] && $k? -1:0+$ii"}], "negative_code": [{"source_code": "chomp($n=<>);\nchomp($c=<>);\n@a = split(\" \", $c);\nuse List::Util qw(min);\n$v = min @a;\n$i = $#a;\n--$i until $a[$i] == $v;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)];\nfor(1..$#a){\n    $ok = 1 if $a[$_] < $a[$_-1];\n}\nprint -1 if $ok;\n$i = $n if $i == 0;\nprint ($n - $i)  if !$ok;\n"}, {"source_code": "chomp($n=<>);\nchomp($c=<>);\n@a = split(\" \", $c);\nuse List::Util qw(min);\n$v = min @a;\n++$i until $a[$i] == $v;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)];\nfor(1..$#a){\n    $ok = 1 if $a[$_] < $a[$_-1];\n}\nprint -1 if $ok;\n$i = $n if $i == 0;\nprint ($n - $i)  if !$ok;\n"}, {"source_code": "chomp($n=<>);\nchomp($c=<>);\n@a = split(\" \", $c);\nuse List::Util qw(min);\n$v = min @a;\n$i = $#a;\n\n--$i until $a[$i] == $v;\n--$i until $a[$i] != $v;\n$i++;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)];\nfor(1..$#a){\n    $ok = 1 if $a[$_] < $a[$_-1];\n}\nprint -1 if $ok;\n$i = $n if $i == 0;\nprint ($n - $i)  if !$ok;\n"}, {"source_code": "chomp($n=<>);\nchomp($c=<>);\n@a = split(\" \", $c);\nuse List::Util qw(min);\n$v = min @a;\n$i = $#a;\n\n--$i until $a[$i] == $v;\n--$i until $i == 0 || $a[$i] != $v;\n$i++;\nsplice @a, 0, $n, @a[$i..$#a], @a[0..($i-1)];\nfor(1..$#a){\n    $ok = 1 if $a[$_] < $a[$_-1];\n}\nprint -1 if $ok;\n$i = $n if $i == 0;\nprint ($n - $i)  if !$ok;\n"}, {"source_code": "<>;\n($A=$a,@_)=split/ /,<>;\n\nfor (@_){\n\t$k++, $ii=@_-$i if $a>$_;\n\t$i++;\n\t$a=$_\n}\n\nprint $k>1 || $A<$_[@_-1] && $k? -1:0+$ii"}, {"source_code": "$n=<>;\n@_=split/ /,<>;\n$k=0;\nfor $i(1..($n-1)){\n\nif ($_[$i-1]>$_[$i] ){\n$k++;\n$ii=$i;\n}\n\n}\n\nif ($k==0){\nprint 0\n}\nelsif ($k>1){\nprint -1\n}\nelse {\nprint $ii\n}"}, {"source_code": "$n=<>;\n@_=split/ /,<>;\n$k=0;\nfor $i(1..($n-1)){\n\nif ($_[$i-1]>$_[$i] ){\n$k++;\n$ii=$i;\n}\n\n}\n\nif ($k==0){\nprint 0\n}\nelsif ($k>1 or $_[0]<$_[$n-1]){\nprint -1\n}\nelse {\nprint $ii\n}"}], "src_uid": "c647e36495fb931ac72702a12c6bfe58"}
{"source_code": "use strict;\n#open STDIN, '<input.txt';\n#open STDOUT, '>output.txt';\nmy $n = <>;\nmy @a = split(' ', <>);\nmy $buf1 = 0;\nmy $buf2 = 0;\nfor(my $i = 0; $i < $n; $i++){\n  if($a[$i] == 0){\n    $buf1++;\n  }\n  else{\n    $buf2++;\n  }\n}\nmy $ans = 0;\nmy $i = 0;\nwhile($buf1 > 0 && $buf2 > 0){\n  if($a[$i] == 0){\n    $buf1--;\n    $ans++;\n  }\n  else{\n    $buf2--;\n    $ans++;\n  }\n  $i++;\n}\nprint $ans;\n", "positive_code": [{"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in = *STDIN;\n    # open(my $in, '<:encoding(UTF-8)', *STDIN);\n    # open(my $out, '>:encoding(UTF-8)', './out.txt');\n\n    my $r= <$in>; chomp($r);\n    my $n= $r;\n\n    $r= <$in>;\n    my @d= split(' ', $r);\n\n    my $dl= 0;\n    my $dr= 0;\n\n    for my $door (@d) {\n        ($door eq 1) ? $dr++ : $dl++;\n    }\n\n    my $lc= 0;\n    my $rc= 0;\n    my $c= 0;\n    for my $door (@d) {\n        ($door eq 1) ? $rc++ : $lc++;\n        $c++;\n\n        if($rc >= $dr || $lc >= $dl) {\n            print $c;\n            # print $out $c;\n            return;\n        }\n    }\n\n\n}\n\nmain() unless caller();\n"}, {"source_code": "use strict;\n#open STDIN, '<input.txt';\n#open STDOUT, '>output.txt';\nmy $n = <>;\nmy @a = split(' ', <>);\nmy $buf1 = 0;\nmy $buf2 = 0;\nsub solve{\n  my ($a, $n) = @_;\nfor(my $i = 0; $i < $n; $i++){\n  if($a[$i] == 0){\n    $buf1++;\n  }\n  else{\n    $buf2++;\n  }\n}\nmy $ans = 0;\nmy $i = 0;\nwhile($buf1 > 0 && $buf2 > 0){\n  if($a[$i] == 0){\n    $buf1--;\n    $ans++;\n  }\n  else{\n    $buf2--;\n    $ans++;\n  }\n  $i++;\n}\nprint $ans;\n}\nsolve(\\@a, $n);\n"}, {"source_code": "use strict;\n#open STDIN, '<input.txt';\n#open STDOUT, '>output.txt';\nmy $n = <>;\nmy @a = split(' ', <>);\nmy %h;\nfor(my $i = 0; $i < $n; $i++){\n  $h{$a[$i]}++;\n}\nmy $ans = 0;\nfor(my $i = 0; $i < $n; $i++){\n  $h{$a[$i]}--;\n  $ans++;\n  if($h{$a[$i]} == 0){\n    print $ans;\n    exit(0);\n  }\n}\nprint $ans;\n"}, {"source_code": "<>;\n\n$A = <> =~ s/\\s//gr;\n\nprint 1 + ( sort { $a <=> $b } map { rindex $A, $_ } 0, 1 )[ 0 ];"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\ty/ //d;\n\t\n\tmy $len = length;\n\t\n\t$_ = reverse;\n\t\n\tprint /^0++(?=1)|^1++(?=0)/ ? $len - length $& : 0;\n\t}"}], "negative_code": [{"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    open(my $in, '<:encoding(UTF-8)', './in.txt');\n    # open(my $out, '>:encoding(UTF-8)', './out.txt');\n\n    my $r= <$in>; chomp($r);\n    my $n= $r;\n\n    $r= <$in>;\n    my @d= split(' ', $r);\n\n    my $dl= 0;\n    my $dr= 0;\n\n    for my $door (@d) {\n        ($door eq 1) ? $dr++ : $dl++;\n    }\n\n    my $lc= 0;\n    my $rc= 0;\n    my $c= 0;\n    for my $door (@d) {\n        ($door eq 1) ? $rc++ : $lc++;\n        $c++;\n\n        if($rc >= $dr || $lc >= $dl) {\n            print $c;\n            # print $out $c;\n            return;\n        }\n    }\n\n\n}\n\nmain() unless caller();\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\ty/ //d;\n\t\n\tmy $len = length;\n\t\n\t$_ = reverse;\n\t\n\tprint /^(.)\\1*+\\B/ ? $len - length $& : 0;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\ty/ //d;\n\t\n\tmy $len = length;\n\t\n\t$_ = reverse;\n\t\n\t/(.)\\1*/;\n\t\n\tprint $len - length $&;\n\t}"}], "src_uid": "653455bb6762effbf7358d75660a7689"}
{"source_code": "$format = <>; @time = split /:/, <>;   \nwhile($time[1] > 59) { $time[1] -= 10; };    \nif ($format == 12) { if($time[0] > $format) { while($time[0] > $format) { $time[0] -= 10; }; if (($time[0] >= 0) && ($time[0] < 10)) { substr($time[0], 0, 0, '0'); }; }; if($time[0] == '00') { $time[0] = '01'; }; } \nelse { if($time[0] >= $format) { while($time[0] >= $format) { $time[0] -= 10; }; if (($time[0] >= 0) && ($time[0] < 10)) { substr($time[0], 0, 0, '0'); }; }; };\nprint $time[0], ':', $time[1];", "positive_code": [{"source_code": "print +( <> =~ /^2/ + 0 * ($_ = <>) ?\n\t\ts/^[3-9]/0/r =~\n\t\ts/^2\\K[4-9]/0/r\n\t:\n\t\ts/^1\\K[3-9]/0/r =~\n\t\ts/^0\\K0/1/r =~\n\t\ts/^\\K([2-9])(.)/$2 ? \"0$2\":10 /er\n\t)\n\t=~ s/:\\K[6-9]/0/r"}, {"source_code": "$/ = $\\;\n$_ = <>;\n\ns/12\\n1\\K[3-9]/0/,\ns/12\\n0\\K0/1/,\ns/12\\n\\K([2-9])(.)/$2 ? \"0$2\":10 /e,\ns/24\\n\\K[3-9]/0/,\ns/24\\n2\\K[4-9]/0/,\ns/:\\K[6-9]/0/,\ns/.*\\n//,\n\nprint"}, {"source_code": "\n$,=\"\";\nmy $f=<>;\nchomp($f);\nmy ($h,$m)=split /\\:/,<>;\nchomp($h,$m);\nif($f==12)\n{\n  if($h>12 or $h eq \"00\")\n  {\n    if(substr($h,1,1) eq \"0\")\n    {\n      $h=\"10\";\n    }\n    else\n    {\n      $h=\"0\".substr($h,1,1);\n    }\n  }\n}\nif($f==24)\n{\n  if($h>23)\n  {\n    {\n      $h=\"0\".substr($h,1,1);\n    }\n  }\n}\nif($m>59)\n{\n$m=\"0\".substr($m,1,1);\n}\n\nprint $h,':',$m,\"\\n\";\n"}, {"source_code": "\nmy $base = <>;\nmy $time = <>;\n$time =~ /(\\d)(\\d)\\:(\\d)(\\d)/;\nmy $H = $1;\nmy $h = $2;\nmy $M = $3;\nmy $m = $4;\n\nif ($base =~ /12/) {\n\tif ($h eq '0') {\n\t\t$H = '1';\n\t}\n\telsif ($h eq '1' or $h eq '2'){\n\t\tif ($H ne '1') {\n\t\t\t$H = '0';\n\t\t}\n\t}\n\telse {\n\t\t$H = '0';\n\t}\n}\nelse {\n\tif ($h eq '0' or $h eq '1' or $h eq '2' or $h eq '3') {\n\t\tif ($H ne '1' and $H ne '2' ) {\n\t\t\t$H = '0';\n\t\t}\n\t}\n\telse {\n\t\tif ($H ne '1') {\n\t\t\t$H = '0';\n\t\t}\n\t}\n}\n\nif ($M >= 6) {\n\t$M = 0;\n}\n\n\nprint \"$H$h:$M$m\\n\";\n\n"}], "negative_code": [{"source_code": "\n$,=\"\";\nmy $f=<>;\nchomp($f);\nmy ($h,$m)=split /\\:/,<>;\nchomp($h,$m);\nif($f==12)\n{\n  if($h>12 or $h eq \"00\")\n  {\n    if(substr($h,1,1) eq \"0\")\n    {\n      $h=\"10\";\n    }\n    else\n    {\n      $h=\"0\".substr($h,1,1);\n    }\n  }\n}\nif($f==24)\n{\n  if($h>23)\n  {\n    {\n      $h=\"0\".substr($h,1,1);\n    }\n  }\n}\nif($m>59)\n{\n$m=\"0\".substr($h,1,1);\n}\n\nprint $h,':',$m,\"\\n\";\n"}, {"source_code": "\n$,=\"\";\nmy $f=<>;\nchomp($f);\nmy ($h,$m)=split /\\:/,<>;\nchomp($h,$m);\nif($f==12)\n{\n  if($h>12)\n  {\n    if(substr($h,1,1) eq \"0\")\n    {\n      $h=\"10\";\n    }\n    else\n    {\n      $h=\"0\".substr($h,1,1);\n    }\n  }\n}\nif($f==24)\n{\n  if($h>23)\n  {\n    {\n      $h=\"0\".substr($h,1,1);\n    }\n  }\n}\nif($m>59)\n{\n$m=\"0\".substr($h,1,1);\n}\n\nprint $h,':',$m,\"\\n\";\n"}, {"source_code": "$format = <>; @time = split /:/, <>;   \nwhile($time[1] > 59) { $time[1] -= 10; };    \nif ($format == 12) { if($time[0] > $format) { while($time[0] > $format) { $time[0] -= 10; }; substr($time[0], 0, 0, '0'); }; if($time[0] == '00') { $time[0] = '01'; }; } \nelse { if($time[0] >= $format) { while($time[0] >= $format) { $time[0] -= 10; }; if (($time[0] >= 0) && ($time[0] < 10)) { substr($time[0], 0, 0, '0'); }; }; };\nprint $time[0], ':', $time[1];"}, {"source_code": "$format = <>; @time = split /:/, <>;   \nwhile($time[1] > 59) { $time[1] -= 10; };    \nif ($format == 12) { while($time[0] > $format) { $time[0] -= 10; }; if($time[0] == '00') { $time[0] = '01'; }; } \nelse { while($time[0] >= $format) { $time[0] -= 10; }; };\nprint $time[0], ':', $time[1];"}, {"source_code": "$format = <>; @time = split /:/, <>;   \nwhile($time[1] > 59) { $time[1] -= 10; };    \nif ($format == 12) { if($time[0] > $format) { while($time[0] > $format) { $time[0] -= 10; }; substr($time[0], 0, 0, '0'); }; if($time[0] == '00') { $time[0] = '01'; }; } \nelse { if($time[0] >= $format) { while($time[0] >= $format) { $time[0] -= 10; }; if (($time[0] >= 0) || ($time[0] < 10)) { substr($time[0], 0, 0, '0'); }; }; };\nprint $time[0], ':', $time[1];"}, {"source_code": "$/ = $\\;\n$_ = <>;\n\ns/12\\n1\\K[3-9]/0/,\ns/12\\n0\\K0/1/,\ns/12\\n\\K([2-9])(.)/$2 ? \"0$2\":10 /e,\ns/24\\n[3-9]/0/,\ns/24\\n2\\K[4-9]/0/,\ns/:\\K[6-9]/0/,\ns/.*\\n//,\n\nprint"}, {"source_code": "print +( <> =~ /^2/ * ($_ = <>) ?\n\t\ts/^[3-9]\\K./0/r =~\n\t\ts/^2\\K[4-9]/0/r\n\t:\n\t\ts/^1\\K[3-9]/0/r =~\n\t\ts/^0\\K0/1/r =~\n\t\ts/^\\K([2-9])(.)/$2 ? \"0$2\":10 /er\n\t)\n\t=~ s/:\\K[6-9]/0/r"}, {"source_code": "$/ = $\\;\n$_ = <>;\n\ns/12\\n1\\K[3-9]/0/,\ns/12\\n0\\K0/1/,\ns/12\\n\\K([2-9])(.)/$2 ? \"0$2\":10 /e,\ns/24\\n[3-9]\\K./0/,\ns/24\\n2\\K[4-9]/0/,\ns/:\\K[6-9]/0/,\ns/.*\\n//,\n\nprint"}, {"source_code": "print +( <> =~ /^2/ * ($_ = <>) ?\n\t\ts/^[3-9]/0/r =~\n\t\ts/^2\\K[4-9]/0/r\n\t:\n\t\ts/^1\\K[3-9]/0/r =~\n\t\ts/^0\\K0/1/r =~\n\t\ts/^\\K([2-9])(.)/$2 ? \"0$2\":10 /er\n\t)\n\t=~ s/:\\K[6-9]/0/r"}], "src_uid": "88d56c1e3a7ffa94354ce0c70d8e958f"}
{"source_code": "<>; \n\nmap { \n\t\n\t$i = 0;\n\t$max = -1;\n\t\n\tmap {\n\t\t$i ++;\n\t\t$_ > $max and do { $max = $_ ; $m = $i }\n\t\t\t\n\t\t\t\n\t\t} split;\n\t\t\n\t$h{ $m } ++\n\t\n\t} <>;\n\nprint 0 + (sort { $h{ $b } <=> $h{ $a } || $a <=> $b } keys %h)[ 0 ]", "positive_code": [{"source_code": "<>;\nmap {\n    $n = 0;\n    $m = -1;\n    map {\n        $n++;\n        $_ > $m and do { $m = $_; $f = $n }\n    } split;\n    $r->{$f}++\n} <>;\n\nprint 0\n    + ( sort { $r->{$b} <=> $r->{$a} || $a <=> $b } keys %{$r} )[0]"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp($_ = <>);\nmy ($n, $m) = split;\nmy %votes;\nmy ($v_max, $v_candidate) = (0,1);\n\nfor my $i (0..$m-1) {\n    chomp($_ = <>);\n    my @city_votes = split;\n    my ($max, $candidate) = (0, 1);\n    my $len = @city_votes;\n    for my $j (0..$len-1) {\n        if($max < $city_votes[$j]) {\n            $max = $city_votes[$j];\n            $candidate = $j + 1;\n        }\n    }\n\n    $votes{$candidate} += 1;\n    if($votes{$candidate} > $v_max) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n    elsif($votes{$candidate} == $v_max && $v_candidate > $candidate) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n}\n\nprint $v_candidate, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\nuse List::Util;\n\n($n, $m) = split / /, <>;\n@c = (0) x $n;\nforeach my $i (1..$m) {\n\t($mx, $v) = (-1, 0);\n\t@a = split / /, <>;\n\tforeach (0..$n-1) {\n\t\tif ($a[$_] > $mx) {\n\t\t\t$mx = $a[$_];\n\t\t\t$v = $_;\n\t\t}\n\t}\n\t++$c[$v];\n}\n($mx, $v) = (-1, 0);\nforeach (0..$n-1) {\n\tif ($c[$_] > $mx) {\n\t\t$mx = $c[$_];\n\t\t$v = $_;\n\t}\n}\nsay $v+1;"}, {"source_code": "sub max {\n    my $max = 0;\n    for my $i(1..$#_) {\n        $max = $i if ($_[$i] > $_[$max]);\n    }\n    return $max;\n}\nmy ($n, $m) = split / /, <>;\nmy @arr = (0) x $n;\nfor (0..$m-1) {\n    $arr[max(split / /, <>)]++;\n}\nprint max(@arr) + 1\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp($_ = <>);\nmy ($n, $m) = split;\nmy %votes;\nmy ($v_max, $v_candidate) = (0, 0);\n\nfor my $i (0..$m) {\n    chomp($_ = <>);\n    my @city_votes = split;\n    my ($max, $candidate) = (0, 0);\n    my $len = length(@city_votes);\n    for my $j (0..$len) {\n        if($max < $city_votes[$j]) {\n            $max = $city_votes[$j];\n            $candidate = $j + 1;\n        }\n    }\n\n    $votes{$candidate} += 1;\n    if($votes{$candidate} > $v_max) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n    elsif($votes{$candidate} == $v_max && $v_candidate > $candidate) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n}\n\nprint $v_candidate, \"\\n\";"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp($_ = <>);\nmy ($n, $m) = split;\nmy %votes;\nmy ($v_max, $v_candidate) = (0, 0);\n\nfor my $i (0..$m-1) {\n    chomp($_ = <>);\n    my @city_votes = split;\n    my ($max, $candidate) = (0, 0);\n    my $len = @city_votes;\n    for my $j (0..$len-1) {\n        if($max < $city_votes[$j]) {\n            $max = $city_votes[$j];\n            $candidate = $j + 1;\n        }\n    }\n\n    $votes{$candidate} += 1;\n    if($votes{$candidate} > $v_max) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n    elsif($votes{$candidate} == $v_max && $v_candidate > $candidate) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n}\n\nprint $v_candidate, \"\\n\";"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp($_ = <>);\nmy ($n, $m) = split;\nmy %votes;\nmy ($v_max, $v_candidate) = (0, 0);\n\nfor my $i (0..$m-1) {\n    chomp($_ = <>);\n    my @city_votes = split;\n    my ($max, $candidate) = (0, 0);\n    my $len = length(@city_votes);\n    for my $j (0..$len-1) {\n        if($max < $city_votes[$j]) {\n            $max = $city_votes[$j];\n            $candidate = $j + 1;\n        }\n    }\n\n    $votes{$candidate} += 1;\n    if($votes{$candidate} > $v_max) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n    elsif($votes{$candidate} == $v_max && $v_candidate > $candidate) {\n        $v_max = $votes{$candidate};\n        $v_candidate = $candidate;\n    }\n}\n\nprint $v_candidate, \"\\n\";"}, {"source_code": "<>;\nmap {\n    $n = 0;\n    $m = -1;\n    map {\n        $n++;\n        $_ > $m and do { $m = $_; $f = $n }\n    } split;\n    $r->{$f}++\n} <>;\n\nprint 0\n    + ( sort { $r->{$a} <=> $r->{$b} || $a <=> $b } keys %{$r} )[0]\n"}, {"source_code": "<>;\nwhile (<>) {\n    @_ = split / /, $_;\n    map { $a[$_] += $_[$_] } 0 .. $#_;\n}\nmap { $m = $_ > ( $m // 0 ) ? $_ : $m } @a;\nprint ++$_ for (sort {$a <=> $b} grep { $a[$_] == $m } 0 .. $#a)[0];\n"}, {"source_code": "<>;\nmap {\n    $n = 0;\n    $m = 0;\n    map {\n        $n++;\n        $_ > $m and do { $m = $_; $f = $n }\n    } split;\n    $r->{$f}++\n} <>;\n\nprint 0 + ( sort { $a <=> $b } keys %{$r} )[0];\n"}, {"source_code": "<>;\nmap {\n    $n = 0;\n    $m = -1;\n    map {\n        $n++;\n        $_ > $m and do { $m = $_; $f = $n }\n    } split;\n    $r->{$f}++\n} <>;\n\nprint 0 + ( sort { $a <=> $b } keys %{$r} )[0]"}, {"source_code": "$\\ = $/;\n\n<>; \n\nmap { \n\t\n\t$i = 0;\n\t$max = 0;\n\t\n\tmap {\n\t\t$i ++;\n\t\t$_ > $max and do { $max = $_ ; $m = $i }\n\t\t\t\n\t\t\t\n\t\t} split;\n\t\t\n\t$h{ $m } ++\n\t\n\t} <>;\n\t\nprint %h;\n\nprint 0 + (sort { $h{ $b } <=> $h{ $a } || $a <=> $b } keys %h)[ 0 ]"}, {"source_code": "$\\ = $/;\n\n<>; \n\nmap { \n\t\n\t$i = 0;\n\t$max = 0;\n\t\n\tmap {\n\t\t$i ++;\n\t\t$_ > $max and do { $max = $_ ; $m = $i }\n\t\t\t\n\t\t\t\n\t\t} split;\n\t\t\n\t$h{ $m } ++\n\t\n\t} <>;\n\nprint 0 + (sort { $h{ $b } <=> $h{ $a } || $a <=> $b } keys %h)[ 0 ] || 1"}, {"source_code": "$\\ = $/;\n\n<>; \n\nmap { \n\t\n\t$i = 0;\n\t$max = 0;\n\t\n\tmap {\n\t\t$i ++;\n\t\t$_ > $max and do { $max = $_ ; $m = $i }\n\t\t\t\n\t\t\t\n\t\t} split;\n\t\t\n\t$h{ $m } ++\n\t\n\t} <>;\n\nprint 0 + (sort { $h{ $b } <=> $h{ $a } || $a <=> $b } keys %h)[ 0 ]"}], "src_uid": "b20e98f2ea0eb48f790dcc5dd39344d3"}
{"source_code": "<>;print$_-10**(-2+length),\" \"for(<>)", "positive_code": [{"source_code": "<>;print$_-10**(-2+length),\" \"for(<>)"}, {"source_code": "<>;for(<>){print$_-10**(-2+length),\" \"}"}, {"source_code": "<>;for(<>){print$_-10**(length($_)-2),\" \"}"}, {"source_code": "<>;print$_-10**(-2+length),\" \"for(<>)"}, {"source_code": "<>;print$_-10**(-2+length),\" \"for(<>)\r\n"}, {"source_code": "<>;print $_-10**(-2+length),\" \"for(<>)"}], "negative_code": [], "src_uid": "5312a505bd59b55a6c5487f67a33d81a"}
{"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";", "positive_code": [{"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "use strict;\n\nuse List::Util qw(sum min);\n\nchomp(my $n = <>);\nchomp($_ = <>);\nmy @a = split;\n\nmy %occurence = ();\n++$occurence{$_} for @a;\n\nmy $sum = sum map { min $_, 2 } values %occurence;\nmy $x = int($sum / 2);\nmy $y = $sum - $x;\n\nprint $x * $y, \"\\n\";\n\nmy %pos = ();\npush @{$pos{$a[$_]}}, $_ for 0 .. $#a;\n\nmy @res = (0) x (2 * $n);\nmy @one = ();\nmy @rest = ();\nmy @h1 = ();\nmy @h2 = ();\nwhile (my ($k, $v) = each %pos) {\n    if (@$v == 1) {\n        push @one, @$v;\n    } else {\n        push @h1, shift @$v;\n        push @h2, shift @$v;\n        push @rest, @$v;\n    }\n}\nwhile (@one) {\n    push @h1, shift @one;\n    push @h2, shift @one if @one;\n}\nwhile (@rest) {\n    if (@h1 < $n) {\n        push @h1, shift @rest;\n    } else {\n        push @h2, shift @rest;\n    }\n}\n$res[$_] = 1 for @h1;\n$res[$_] = 2 for @h2;\nprint \"@res\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}, {"source_code": "$n=<>;\n$a=$_=<>;\n$a=~s/\\d{2}/push @a, ++$m[$&]/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\n\t$m=$n*2-$f;\n\t$m%2?($m=($m+1)*($m-1)/4):($m**=2,$m/=4);\n\tprint \"$m\\n\";\ns/\\d{2}/$m[$&]>1?($i++):($a[$i++]+=2)/ge;\nfor $j(@a){\n\t$j>2 and $j=$f++%2?1:2;\n\t}\nprint \"@a\\n\";\n"}], "negative_code": [{"source_code": "use strict;\n\nuse List::Util qw(sum min);\n\nchomp(my $n = <>);\nchomp($_ = <>);\nmy @a = split;\n\nmy %occurence = ();\n++$occurence{$_} for @a;\n\nmy $sum = sum map { min $_, 2 } values %occurence;\nmy $x = int($sum / 2);\nmy $y = $sum - $x;\n\nprint $x * $y, \"\\n\";\n\nmy %pos = ();\npush @{$pos{$a[$_]}}, $_ for 0 .. $#a;\n\nmy @res = (0) x (2 * $n);\nmy @one = ();\nmy @rest = ();\nmy @h1 = ();\nmy @h2 = ();\nwhile (my ($k, $v) = each %occurence) {\n    if (@{$pos{$k}} == 1) {\n        push @one, @{$pos{$k}};\n    } else {\n        push @h1, shift @{$pos{$k}};\n        push @h2, shift @{$pos{$k}};\n        push @rest, @{$pos{$k}};\n    }\n}\nwhile (@one) {\n    push @h1, shift @one;\n    push @h2, shift @one if @one;\n}\nfor (@rest) {\n    if (@h1 < $n) {\n        push @h1, shift @rest;\n    } else {\n        push @h2, shift @rest;\n    }\n}\n$res[$_] = 1 for @h1;\n$res[$_] = 2 for @h2;\nprint \"@res\\n\";\n"}, {"source_code": "use strict;\n\nuse List::Util qw(sum min);\n\nchomp(my $n = <>);\nchomp($_ = <>);\nmy @a = split;\n\nmy %occurence = ();\n++$occurence{$_} for @a;\n\nmy $sum = sum map { min $_, 2 } values %occurence;\nmy $x = int($sum / 2);\nmy $y = $sum - $x;\n\nprint $x * $y, \"\\n\";\n\nmy %pos = ();\npush @{$pos{$a[$_]}}, $_ for 0 .. $#a;\n\nmy @res = (0) x (2 * $n);\nmy @one = ();\nmy @rest = ();\nwhile (my ($k, $v) = each %occurence) {\n    if (@{$pos{$k}} == 1) {\n        push @one, @{$pos{$k}};\n    } else {\n        $res[shift @{$pos{$k}}] = 1;\n        $res[shift @{$pos{$k}}] = 2;\n        push @rest, @{$pos{$k}};\n        --$x;\n        --$y;\n    }\n}\nwhile (@one) {\n    $res[shift @one] = 1;\n    --$x;\n    if (@one) {\n        $res[shift @one] = 2;\n        --$y;\n    }\n}\nfor (@rest) {\n    if ($x > 0) {\n        $res[shift @rest] = 1;\n        --$x;\n    } else {\n        $res[shift @rest] = 2;\n        --$y;\n    }\n}\nprint \"@res\\n\";\n"}], "src_uid": "080287f34b0c1d52eb29eb81dada41dd"}
{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse integer;\n\n<>;\n\nmy $bline = <>;\nchomp $bline;\n\nmy @bseq = split /\\s+/, $bline;\n\nmy ($low, $up) = (0, shift @bseq);\n\nmy @from_front = ($low);\nmy @from_back = ($up);\n\nforeach my $b (@bseq) {\n\tmy $sum = $low + $up;\n\tmy $err = abs($sum - $b);\n\t$low+= $err if $sum < $b;\n\t$up -= $err if $sum > $b;\n\tpush @from_front, $low;\n\tpush @from_back , $up ;\n}\n\nprint \"@from_front\";\nprint \" \";\nmy @revd = reverse @from_back;\nprint \"@revd\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy @L;\n\tmy @R;\n\t\n\tmy $max = shift @_;\n\tunshift @L, 0;\n\tunshift @R, $max;\n\t\n\tfor( @_ ){\n\t\tmy $sum = $L[ 0 ] + $R[ 0 ];\n\t\tif( $sum == $_ ){\n\t\t\tunshift @L, $L[ 0 ];\n\t\t\tunshift @R, $R[ 0 ];\n\t\t\t}\n\t\telsif( $sum < $_ ){\n\t\t\tunshift @L, $_ - $R[ 0 ];\n\t\t\tunshift @R, $R[ 0 ];\n\t\t\t}\n\t\telsif( $sum > $_ ){\n\t\t\tunshift @R, $_ - $L[ 0 ];\n\t\t\tunshift @L, $L[ 0 ];\n\t\t\t}\n\t\t}\n\t\n\tprint join ' ', ( reverse @L ), @R;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = reverse split ' ', <>;\n\t\n\tmy @L;\n\tmy @R;\n\t\n\tmy $max = shift @_;\n\tunshift @L, 0;\n\tunshift @R, $max;\n\t\n\tfor( @_ ){\n\t\tmy $sum = $L[ 0 ] + $R[ 0 ];\n\t\tif( $sum == $_ ){\n\t\t\tunshift @L, $L[ 0 ];\n\t\t\tunshift @R, $R[ 0 ];\n\t\t\t}\n\t\telsif( $sum < $_ ){\n\t\t\tunshift @L, $_ - $R[ 0 ];\n\t\t\tunshift @R, $R[ 0 ];\n\t\t\t}\n\t\telsif( $sum > $_ ){\n\t\t\tunshift @R, $_ - $L[ 0 ];\n\t\t\tunshift @L, $L[ 0 ];\n\t\t\t}\n\t\t}\n\t\n\tprint join ' ', ( reverse @L ), @R;\n\t}"}], "src_uid": "4585419ab2b7200770cfe1e607161e9f"}
{"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n", "positive_code": [{"source_code": "$\\=$/;\nwhile(<>){\n\t$_ = <>;\n\tchomp;\n\t@_ = split //;\n\t$j = 1;\n\t%h = ();\n\t$ans = 0;\n\tfor $i (@_){\n\t\tif ($j++ % 2) {\n#\t\t\tprint $i;\n\t\t\t$h{$i} ++;\n\t\t\t\n\t\t\t}\n\t\telse{\n\t\t\t$h{ lc($i) } ? ( $h{ lc($i) }-- ) : ( $ans++ );\n\t\t\t\n\t\t\t;\n\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\t}\n\tprint $ans;\n\t\n\t\n\t}"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n"}, {"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $rc = <>;\nmy $a;\nmy @rooms;\nmy @keys;\nmy %hk;\nfor (0 .. $rc - 2)\n{\n    \n    read(STDIN, $keys[$_], 1);\n    read(STDIN, $rooms[$_], 1);\n    \n    $keys[$_] = uc($keys[$_]);\n    $rooms[$_] = uc($rooms[$_]);\n    $hk{$rooms[$_]} = 0;\n    $hk{$keys[$_]} = 0;\n    \n}\nmy $ans = 0;\nfor (0 .. $#rooms)\n{\n    $hk{$keys[$_]}++;\n    if($hk{$rooms[$_]} <= 0)\n    {\n        $ans ++;\n    }\n    else\n    {\n        $hk{$rooms[$_]}--;\n    }\n    \n}\nprint $ans;"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split //, <>;\n($ans, $len) = (0, $n + $n);\n@c = (0) x 26;\nforeach (0 .. $n-2) {\n\t$j = (ord $a[$_*2]) - (ord 'a');\n\t$k = (ord $a[$_*2+1]) -( ord 'A');\n\t# say \"$j $k\";\n\t$c[$j]++;\n\t$c[$k]>0 and $c[$k]-- or ++$ans;\n}\nsay $ans;"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n    ++ $j % 2 ?\n        $h{ $_ } ++\n        :\n        $h{ (lc) } ? $h{ (lc) } -- : $ans ++\n    }\nprint 0 + $ans"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ $_ } ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $rc = <>;\nmy $a;\nmy @rooms;\nmy @keys;\nfor (0 .. $rc - 2)\n{\n    read(STDIN, $rooms[$_], 1);\n    $rooms[$_] = uc($rooms[$_]);\n    read(STDIN, $keys[$_], 1);\n}\nmy %hk;\nmy $ans = 0;\nfor (0 .. ($rc) / 2 + 1)\n{\n    $hk{$keys[$_]}++;\n    if(!defined($hk{$rooms[$_]}) or $hk{$rooms[$_]} <= 0)\n    {\n        $ans ++;\n    }\n    else\n    {\n        $hk{$rooms[$_]}--;\n    }\n}\nprint $ans;"}, {"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $rc = <>;\nmy $a;\nmy @rooms;\nmy @keys;\nmy %hk;\nfor (0 .. $rc - 2)\n{\n    read(STDIN, $rooms[$_], 1);\n    $rooms[$_] = uc($rooms[$_]);\n    read(STDIN, $keys[$_], 1);\n    $keys[$_] = uc($keys[$_]);\n    $hk{$rooms[$_]} = 0;\n    $hk{$keys[$_]} = 0;\n    \n}\n\nmy $ans = 0;\nfor (0 .. $#rooms)\n{\n    $hk{$keys[$_]}++;\n    if($hk{$rooms[$_]} <= 0)\n    {\n        $ans ++;\n    }\n    else\n    {\n        $hk{$rooms[$_]}--;\n    }\n    \n}\nprint $ans;"}, {"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $rc = <>;\nmy $a;\nmy @rooms;\nmy @keys;\nfor (0 .. $rc - 2)\n{\n    read(STDIN, $rooms[$_], 1);\n    $rooms[$_] = uc($rooms[$_]);\n    read(STDIN, $keys[$_], 1);\n}\nmy %hk;\nmy $ans = 0;\nfor (0 .. $#rooms)\n{\n    $hk{$keys[$_]}++;\n    if(!defined($hk{$rooms[$_]}) or $hk{$rooms[$_]} <= 0)\n    {\n        $ans ++;\n    }\n    else\n    {\n        $hk{$rooms[$_]}--;\n    }\n}\nprint $ans;"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{$i} ++\n\t\t:\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++\n\t}\nprint 0 + $ans"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{ (lc) } ? $h{ (lc) } -- : $ans ++ \n\t\t:\n\t\t$h{$i} ++\n\t}\nprint 0 + $ans"}, {"source_code": "<>;\n$_ = <>, chomp;\nfor (split //){\n\t++ $j % 2 ?\n\t\t$h{$i} ++\n\t\t:\n\t\t( $h{ (lc) } ? $h{ (lc) } -- : $ans ++ )\n\t}\nprint 0 + $ans"}], "src_uid": "80fdb95372c1e8d558b8c8f31c9d0479"}
{"source_code": "$n=<>;$e=$n**2;$,=' ';for(1..$n){print++$s,$e--,\"\"for(1..$n/2);print\"\\n\";}", "positive_code": [{"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "$n=<>**2;print $n--,\" $s\\n\" while($n>$s++)"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "use strict;\n\nmy $n = <>;\n\nmy $counter = 1;\nforeach my $i  (1..$n) { \n\tprint $i.' ';\n\t\n\tmy $number = $i;\n\tfor my $j (1..$n - 1) {\n\t\tif ($number % $n == 0) {\n\t\t\t$counter = 1;\n\t\t}\n\t\telse {\n\t\t\t$counter = $n + 1;\n\t\t}\n\t\t$number = $counter + $number;\n\t\tprint $number.' ';\n\t\t\n\t\t\n\t\t#my $counter = $n + 2 - $;\n\t\t#my $number = $i;\n\t\t\n\t}\n\tprint \"\\n\";\n}"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "$_=<>;\nchomp;\nfor $i(1..$_){\n    @j=();\n    ++$k;\n    for $j(1..$_){\n        push @j, (($j * $_) - ++$k % $_ )\n        }\n    print \"@j\\n\";\n    }"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "$l=<>**2;print$l--.\" $_ \"for(1..$l/2)\n"}, {"source_code": "my $n = int<>**2;\nprint $n-- . \" $_\\n\" for(1..$n / 2);"}], "negative_code": [{"source_code": "my $n = int<>;\nfor(my $i = 1; $i <= 2 * $n; $i += $n/2) {\n    print ((join \" \", ($i..$i+$n/2-1)) . \" \");\n    print ((join \" \", ($n*$n-$i..$n*$n-$i+$n/2-1)) . \"\\n\");\n}\n"}, {"source_code": "my $n = int<>;\nprint ($_ . \" \" . ($n * $n - $_ + 1) . \"\\n\") for(1..$n);\n"}, {"source_code": "use strict;\n\nmy $n = 5;\n\nmy $counter = 1;\nforeach my $i  (1..$n) { \n\tprint $i.' ';\n\t\n\tmy $number = $i;\n\tfor my $j (1..$n - 1) {\n\t\tif ($number % $n == 0) {\n\t\t\t$counter = 1;\n\t\t}\n\t\telse {\n\t\t\t$counter = $n + 1;\n\t\t}\n\t\t$number = $counter + $number;\n\t\tprint $number.' ';\n\t\t\n\t\t\n\t\t#my $counter = $n + 2 - $;\n\t\t#my $number = $i;\n\t\t\n\t}\n\tprint \"\\n\";\n}"}], "src_uid": "0ac2a0954fe43d66eac32072c8ea5070"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\t@_ = sort { $a <=> $b } split ' ', <>;\n\tmy $min = $_[0];\n\tmy $max = $_[-1];\n\t\n\tmy $cnt = 0;\n\t\n\t$_ != $min and $_ != $max and $cnt ++ for @_;\n\t\n\tprint $cnt;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy $num = <>;\nchomp($num);\nmy $line2 = <>;\nchomp($line2);\nmy @tokens = split (\" \", $line2);\nmy @array = sort { $a <=> $b } @tokens;\nmy $min = $array[0];\nmy $max = $array[-1];\nmy $output = 0 ;\nfor (my $i=0;$i < $num;$i++) {\n                #print \"$tokens[$i] -- $min -- $max\\n\";\n        if ($tokens[$i] > $min && $tokens[$i] < $max) {\n                $output++;\n        }       \n}       \nprint \"$output\\n\";\n                                                                 \n"}, {"source_code": "print 0 + grep $_ > $_[0] && $_ < $_[-1], @_ = sort { $a <=> $b } split ' ', (<>,<>)"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nmy $num = <>;\nchomp($num);\nmy $line2 = <>;\nchomp($line2);\nmy @tokens = split (\" \", $line2);\nmy @array = sort { $a <=> $b } @tokens;\nmy $min = $array[0];\nmy $max = $array[-1];\nmy $output = 0 ;\nfor (my $i=1;$i < $num-1;$i++) {\n                #print \"$tokens[$i] -- $min -- $max\\n\";\n        if ($tokens[$i] > $min && $tokens[$i] < $max) {\n                $output++;\n        }\n}\nprint \"$output\\n\";\n"}], "src_uid": "acaa8935e6139ad1609d62bb5d35128a"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = ();\n\t\n\tpush @_, grep !($_ % 2), 1 .. $_;\n\tpush @_, grep $_ % 2, 1 .. $_;\n\tpush @_, grep !($_ % 2), 1 .. $_;\n\t\n\tprint ~~ @_;\n\tprint \"@_\";\n\t}", "positive_code": [{"source_code": "$_ = join( \n\t' ' . ( join ' ', grep    $_ % 2 , 1 .. $_ ) . ' ',\n\t      ( join ' ', grep !( $_ % 2), 1 .. $_ ) x 2\n\t),\n\nprint +( split ) . \"\\n$_\" for <>"}, {"source_code": "@_ = (\n\t\t( grep !( $_ % 2), 1 .. $_ ),\n\t\t( grep    $_ % 2 , 1 .. $_ ),\n\t\t( grep !( $_ % 2), 1 .. $_ )\n\t),\n\nprint @_ . \"\\n@_\" for <>"}, {"source_code": "$_ = join( \n\t' ' . ( join ' ', grep    $_ % 2 , 1 .. $_ ) . ' ',\n\t      ( join ' ', grep !( $_ % 2), 1 .. $_ ) x 2\n\t),\n\t\nprint +( split ) . \"$/$_\" for <>"}], "negative_code": [], "src_uid": "c40cb0a89c2b604aa7384476b57e96b3"}
{"source_code": "$n = <STDIN>;\n@a = split( \" \", <STDIN> );\n@b = sort {$a <=> $b} @a; \n$cnt = 0;\nfor( $i=0;$i<$n;$i++ ){\n    if( $a[$i] != $b[$i] )\n    {\n        $cnt++;\n    }\n}\nif( $cnt < 3 )\n{\n    print \"YES\";\n} else\n{\n    print \"NO\";\n}", "positive_code": [{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nsub main {\n    my $n = int <STDIN>;\n    my @arr = map int, split /\\D/, <STDIN>;\n    my @sorted_arr = sort { $a <=> $b } @arr;\n    my $count = 0;\n    for (0 .. $#arr) {\n\tif ($arr[$_] != $sorted_arr[$_]) {\n\t    $count++;\n\t}\n    }\n    if ($count <= 2) {\n\tprint 'YES';\n    } else {\n\tprint 'NO';\n    }\n}\n\nmain();\n\n__END__\n"}], "negative_code": [{"source_code": "$n = <STDIN>;\n@a = split( \" \", <STDIN> );\n@b = sort @a;\n$cnt = 0;\nfor( $i=0;$i<$n;$i++ ){\n    if( $a[$i] != $b[$i] )\n    {\n        $cnt++;\n    }\n}\nif( $cnt < 3 )\n{\n    print \"YES\";\n} else\n{\n    print \"NO\";\n}"}, {"source_code": "$n = <STDIN>;\n@a = split( \" \", <STDIN> );\n@b = sort $a;\n$cnt = 0;\nfor( $i=0;$i<$n;$i++ ){\n    if( $a[$i] != $b[$i] )\n    {\n        $cnt++;\n    }\n}\nif( $cnt < 3 )\n{\n    print \"YES\";\n} else\n{\n    print \"NO\";\n}"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nsub badElems {\n    my @a = @_;\n    my @indexes;\n    for my $i (1 .. $#a) {\n\tif ($a[$i] < $a[$i - 1]) {\n\t    push(@indexes, $i);\n\t}\n    }\n    return @indexes;\n}\n\nsub check {\n    my ($i1, $i2, @a) = @_;\n    ($a[$i1], $a[$i2]) = ($a[$i2], $a[$i1]);\nreturn ( (($i1 == 0) || ($a[$i1-1] <= $a[$i1])) &&\n\t ($a[$i1] <= $a[$i1+1]) &&\n\t ($a[$i2-1] <= $a[$i2]) &&\n\t (($i2 == $#a) || ($a[$i2] <= $a[$i2+1])));\n}\n\nsub findFirstToSwap {\n    my ($i2, @a) = @_;\n    my $i = $i2-1;\n    my $ai = $a[$i];\n    do {\n\t$i--;\n    } while (($i > 0) && ($a[$i] = $ai));\n    return $i;\n}\n\nsub isGood {\n    my @a = @_;\n    my @indexes = badElems(@a);\n    if (! @indexes) {\n\treturn 1;\n    } elsif (@indexes > 2) {\n\treturn 0;\n    } else { \n\tif (@indexes == 1) {\n\t    unshift(@indexes, findFirstToSwap($indexes[0], @a));\n\t} else {\n\t    $indexes[0]--;\n\t}\n\treturn check(@indexes, @a);\n    }\n}\n\nsub main {\n    my $n = int(<STDIN>);\n    my @a = map(int, split(/\\D/, <STDIN>));\n    if (isGood(@a)) {\n\tprint 'YES';\n    } else {\n\tprint 'NO';\n    }\n}\n\nmain();\n\n__END__\n\n4\n2 2 2 1\n"}, {"source_code": "<>;\n@a = <>;\n@r = sort {$a <= $b} @a;\n$k = 0;\nfor (0 .. $#a) {\n    $k++ if ($a[$_] != $b[$_]);\n}\nif ($k < 2) {\n    print 'YES';\n} else {\n    print 'NO';\n}\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nsub badElems {\n    my @a = @_;\n    my @indexes;\n    for my $i (1 .. $#a) {\n\tif ($a[$i] < $a[$i - 1]) {\n\t    push(@indexes, $i);\n\t}\n    }\n    return @indexes;\n}\n\nsub check {\n    my ($i1, $i2, @a) = @_;\n    ($a[$i1], $a[$i2]) = ($a[$i2], $a[$i1]);\nreturn ( (($i1 == 0) || ($a[$i1-1] <= $a[$i1])) &&\n\t ($a[$i1] <= $a[$i1+1]) &&\n\t ($a[$i2-1] <= $a[$i2]) &&\n\t (($i2 == $#a) || ($a[$i2] <= $a[$i2+1])));\n}\n\nsub isGood {\n    my @a = @_;\n    my @indexes = badElems(@a);\n    if (! @indexes) {\n\treturn 1;\n    } elsif (@indexes > 2) {\n\treturn 0;\n    } else { \n\tif (@indexes == 1) {\n\t    unshift(@indexes, $indexes[0] - 1);\n\t} else {\n\t    $indexes[0]--;\n\t}\n\treturn check(@indexes, @a);\n    }\n}\n\nsub main {\n    my $n = int(<STDIN>);\n    my @a = map(int, split(/\\D/, <STDIN>));\n    if (isGood(@a)) {\n\tprint 'YES';\n    } else {\n\tprint 'NO';\n    }\n}\n\nmain();\n\n__END__\n\n"}], "src_uid": "541fde3a3c40926cbd1edb6017b83e52"}
{"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n", "positive_code": [{"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}, {"source_code": "use v5.10;\n\nchomp($line = <>);\n@a = split //, $line;\n$n = scalar @a;\n$x = $a[$#a];\nforeach $i (0 .. $n-1) {\n\t$a[$i]&1 and next;\n\tif ($a[$i] < $x) {\n\t\t$p = $i;\n\t\tlast;\n\t} elsif ($a[$i] > $x) {\n\t\t$p = $i;\n\t}\n}\n\nif (defined $p) {\n\tforeach $i (0 .. $n-2) {\n\t\tif ($i == $p) {\n\t\t\t$ans .= $x;\n\t\t} else {\n\t\t\t$ans .= $a[$i];\n\t\t}\n\t}\n\t$ans .= $a[$p];\n\tsay $ans;\n} else {\n\tsay -1;\n}"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}, {"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp;\n\t$e = chop;\n\t@e = split//;\n\t$f = /[02468]/;\n\tundef $j;\n\tfor $i (@e){\n\t\tif ($i % 2 == 0){ $k = $i }\n\t\tif ($i % 2 == 0 and $i < $e){\n\t\t\t$j = $i; \n\t\t\t$i = $e;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t\n\t$j // $f && do { substr $_, (rindex $_, $k), 1, $e; @e = split//; $j = $k };\n\tprint $f ? (@e, $j) : -1\n\n\t}"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&"}, {"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d](?=[^@d]*$)|$e|||--$f;\nprint $f || $_ . $&\n"}], "negative_code": [{"source_code": "$_ = <>, chomp;\n$e = chop;\n@w = grep $_ < $e, @d = qw(0 2 4 6 8);\ns|[@w]|$e|||s|[@d]|$e|||--$f;\nprint $f || $_ . $&"}], "src_uid": "bc375e27bd52f413216aaecc674366f8"}
{"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n", "positive_code": [{"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $line1 = <>;\nchomp($line1);\nmy @nk = split(\" \",$line1);\nmy $n = $nk[0]; #computers\nmy $k = $nk[1]; #participants\n\nmy $line2 = <>;\nchomp($line2);\nmy @a = split(\" \",$line2); #max data transfer speed on ith computer\n\nmy @sorted = sort{ $b <=> $a } @a;\n\n#n is basically useless, use k for index\n\nsay $sorted[$k-1];\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}, {"source_code": "use strict;\nuse POSIX;\nmy ($n,$k)=split(' ',<>);\nmy @l = split (' ',<>);\n@l = sort{$b<=>$a} @l;\nprint  $l[$k-1];\n\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}, {"source_code": "($n, $k) = split /\\s+/, <>;\n@a = sort{$a <=> $b} split /\\s+/, <>;\nprint $a[$n - $k].\"\\n\";\n"}, {"source_code": "<>=~/ /;\nprint ((sort{$b<=>$a}(split/ /,<>))[$'-1]);\n"}], "negative_code": [{"source_code": "use strict;\nuse POSIX;\nmy ($n,$k)=split(' ',<>);\nmy @l = split (' ',<>);\n@l = sort @l;\n\nprint $l[$k-1]\n"}], "src_uid": "6eca08d7cc2dec6f4f84d3faa9a8a915"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n,$k) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @h = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $mx_h = -1;\r\n  for(my $i=0;$i<$n;$i++){\r\n    $mx_h = $h[$i] if $h[$i] > $mx_h;\r\n  }\r\n  my $fill = 0;\r\n  for(my $i=0;$i<$n;$i++){\r\n    $fill += ( $mx_h - $h[$i] );\r\n  }\r\n  if( $n==1 or $k > $fill ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  \r\n  my $w = 0;\r\n  my $last_stop = -1;\r\n  for(my $i=0;$i<$k;$i++){\r\n    for(my $i=0;$i<$n-1;$i++){\r\n      if( $h[$i] >= $h[$i+1] ){\r\n        if( $i == $n-2 ){\r\n          $w = 1;\r\n        }\r\n      } else {\r\n        $h[$i] ++;\r\n        $last_stop = $i;\r\n        last;\r\n      }\r\n    }\r\n  }\r\n  if( $w == 1 ){\r\n    print \"-1\\n\";\r\n  } else {\r\n    $last_stop ++;\r\n    print \"$last_stop\\n\";\r\n  }\r\n}\r\n\r\nexit(0);\r\n\r\n", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $n, $k, @_, $F, $P ) = split ' ', $_ . <>;\r\n\t\r\n\twhile( $k -- ){\r\n\t\t$ok = 0;\r\n\t\t\r\n\t\tfor( 0 .. @_ - 2 ){\r\n\t\t\tif( $_[ $_ ] < $_[ $_ + 1 ] ){\r\n\t\t\t\t$_[ $_ ] += $ok = 1;\r\n\t\t\t\t$P = $_ + 1;\r\n\t\t\t\tlast\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\r\n\t\t$ok or $F = 1 and last\r\n\t\t}\r\n\t\r\n\tprint $F ? -1 : $P\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $fail = 0;\n\tmy $pos = 0;\n\t\n\twhile( $k -- ){\n\t\tmy $ok = 0;\n\t\t\n\t\tfor my $i ( 0 .. @_ - 2 ){\n\t\t\tif( $_[ $i ] < $_[ $i + 1 ] ){\n\t\t\t\t$_[ $i ] ++;\n\t\t\t\t$pos = $i + 1;\n\t\t\t\t$ok = 1;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$ok or $fail = 1;\n\t\tlast if $fail;\n\t\t}\n\t\n\tprint $fail ? -1 : $pos;\n\t}"}], "negative_code": [], "src_uid": "32855bb8ba33973178fde7c3d0beb2ce"}
{"source_code": "$\\ = $/;\n\nwhile ($t = <>){\n\t\n\tfor (1 .. $t){\n\t\t\n\t\t$w = <>;\n\t\t\n\t\t@_[ 0 .. 2 ] = map scalar <>, 0 .. 2;\n\t\t\n\t\t$i = -1;\n\t\t$i ++, /^s/ and $s = $i for @_;\n\t\ts/.// for @_;\n\t\ts/$/....../ for @_;\n\n\t\t$f = 0;\n\t\t\n\t\t@try = ($s);\n\t\t\n\t\tfor $i (0 .. $w / 3){\n\t\t\t\n\t\t\t@three = map { s/...//; $& } @_;\n\t\t\tundef @new;\n\t\t\t\n\t\t\tfor $k (@try){\n\t\t\t\t\n\t\t\t\tnext if $three[$k] =~ /^\\w/; \n\t\t\t\t\n\t\t\t\tfor $r (grep /^[012]/, map $k + $_, -1 .. 1){\n\t\t\t\t\t$three[$r] =~ /\\.{3}/ and $new[$r] = $r;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t@try = grep defined, @new \n\t\t\t\tor $f = 1;\n\t\t\t}\n\t\t\t\n\t\tprint qw(YES NO)[ $f ];\n\t\t}\n\t\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n@regexes = split /^$/m, join '', <DATA>;\n\nwhile ($t = <>){\n\t\n\tfor (1 .. $t){\n\t\t\n\t\t($length, undef) = split ' ' , <>;\n\t\t\n\t\t@_[ 0 .. 2 ] = map scalar <>, 0 .. 2;  # main array\n\t\t\n\t\t$i = -1;\n\t\t$i ++, /^s/ and $s = $i for @_;\n\t\t@test_lines = ($s);\n\t\t\n\t\ts/.// for @_;\n\t\ts/$/....../ for @_;\n\n\t\t$fail = 0;\n\t\t\n\t\tfor $i (0 .. $length / 3){\n\t\t\t\n\t\t\t$_3x3 = join '', map { s/...//; $& } @_;\n\t\t\t\n\t\t\t$new_test_lines = '';\n\t\t\tfor $k (@test_lines){\n\t\t\t\t\n\t\t\t\t$k == 0 and $_3x3 =~ /$regexes[0]/x and $new_test_lines .= 0;\n\t\t\t\t$k == 0 and $_3x3 =~ /$regexes[1]/x and $new_test_lines .= 1;\n\t\t\t\t\n\t\t\t\t$k == 1 and $_3x3 =~ /$regexes[2]/x and $new_test_lines .= 0;\n\t\t\t\t$k == 1 and $_3x3 =~ /$regexes[3]/x and $new_test_lines .= 1;\n\t\t\t\t$k == 1 and $_3x3 =~ /$regexes[4]/x and $new_test_lines .= 2;\n\t\t\t\t\n\t\t\t\t$k == 2 and $_3x3 =~ /$regexes[5]/x and $new_test_lines .= 1;\n\t\t\t\t$k == 2 and $_3x3 =~ /$regexes[6]/x and $new_test_lines .= 2;\n\n\t\t\t\t}\n\t\t\t$new_test_lines = join '', sort split //, $new_test_lines;\n\t\t\t$new_test_lines =~ y///cs;  # sqeeze\n\t\t\t@test_lines = split //, $new_test_lines;\n\t\t\t@test_lines or $fail = 1 and last;\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\tprint qw(YES NO)[ $fail ];\n\t\t}\n\t\n\t}\n\t\n__DATA__\n \\. \\. \\.\n  .  .  .\n  .  .  .\n\n \\.  .  .\n \\. \\. \\.\n  .  .  .\n\n \\. \\. \\.\n \\.  .  .\n  .  .  .\n\n  .  .  .\n \\. \\. \\.\n  .  .  .\n\n  .  .  .\n \\.  .  .\n \\. \\. \\.\n\n  .  .  .\n \\. \\. \\.\n \\.  .  .\n\n  .  .  .\n  .  .  .\n \\. \\. \\.\n"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile ($t = <>){\n\t\n\tfor (1 .. $t){\n\t\t\n\t\t($w, $c) = split ' ' , <>;\n\t\t\n\t\t@_[ 0 .. 2 ] = map scalar <>, 0 .. 2;\n\t\t\n\t\t$i = -1;\n\t\t$i ++, /^s/ and $s = $i for @_;\n\t\ts/.// for @_;\n\t\ts/$/.../ for @_;\n\t\t\n\t\t$f = 0;\n\t\t\n\t\t%h = qw(0 01 01 012 012 012 1 012 12 012 2 12 02 012);\n\t\t\n\t\t@wa = ($s);\n\t\t\n\t\tfor $i (0 .. $w / 3){\n\t\t\t\n\t\t\t@three = map { s/...//; $& } @_;\n\t\t\tfor $k (@wa){\n\t\t\t\t$three[$k] =~ /^\\./ or next;\n\t\t\t\t$wa = $h{ $k };\n\t\t\t\t$aw = '';\n\t\t\t\t$j = -1;\n\t\t\t\tmap { $j ++; $wa =~ /$j/ and /^\\.{3}/ and $aw .= $j } @three;\n\t\t\t\t}\n\t\t\t$aw = join '', sort split //, $aw;\n\t\t\t$aw =~ y///cs;\n\t\t\t@wa = split //, $aw;\n\t\t\t@wa or $f = 1;\n\t\t\t$aw = '';\n\t\t\t}\n\t\t\t\n\t\tprint qw(YES NO)[ $f ];\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile ($t = <>){\n\t\n\tfor (1 .. $t){\n\t\t\n\t\t($w, $c) = split ' ' , <>;\n\t\t$w --;\n\t\t$w ++ while $w % 3;\n\t\t\n\t\t@_[ 0 .. 2 ] = map scalar <>, 0 .. 2;\n\t\t\n\t\t$i = -1;\n\t\t$i ++, /^s/ and $s = $i for @_;\n\t\ts/.// for @_;\n\n\t\t$f = 0;\n\t\t\n\t\t@wa = ($s);\n\t\t\n\t\tfor $i (1 .. $w / 3){\n\t\t\t\n\t\t\t$three = join '', map { s/...//; $& } @_;\n\t\t\t\n\t\t\t$aw = '';\n\t\t\tfor $k (@wa){\n\t\t\t\t$k == 0 and $three =~ /^\\.\\.\\./ and $aw .= 0;\n\t\t\t\t$k == 1 and $three =~ /^...\\.\\.\\./ and $aw .= 1;\n\t\t\t\t$k == 2 and $three =~ /^......\\.\\.\\./ and $aw .= 2;\n\t\t\t\t$k == 0 and $three =~ /^\\...\\.\\.\\./ and $aw .= 1;\n\t\t\t\t$k == 1 and $three =~ /^\\.\\.\\.\\.../ and $aw .= 0;\n\t\t\t\t$k == 1 and $three =~ /^...\\...\\.\\.\\./ and $aw .= 2;\n\t\t\t\t$k == 2 and $three =~ /^...\\.\\.\\.\\.../ and $aw .= 1;\n\t\t\t\t}\n\t\t\t$aw = join '', sort split //, $aw;\n\t\t\t$aw =~ y///cs;\n\t\t\t@wa = split //, $aw;\n\t\t\t@wa or $f = 1;\n\t\t\t}\n\t\t\t\n\t\tprint qw(YES NO)[ $f ];\n\t\t}\n\t\n\t\n\t\n\t\n\t}"}], "src_uid": "5c1707b614dc3326a9bb092e6ca24280"}
{"source_code": "local $/; ($n, $h, $k, @a) = split \" \", <>;\nwhile ($i < $n) {\n\twhile ($l + $a[$i] <= $h) {\n\t\t$l += $a[$i]; \n\t\t$i++;\n\t\tlast if $i == $n;\n\t}\n\tif ($l > $k) {\n\t\t$t = int($l/$k);\n\t} else {\n\t\t$t = 1;\n\t}\n\t$l -= $k * $t;\n\t$l = 0 if $l < 0;\n\t$T += $t;\n} \n$T += int(($l + $k - 1)/$k);\nprint $T", "positive_code": [{"source_code": "$\\ = $/;\nwhile(<>){\n\t($n, $h, $k) = split;\n\t@_ = split ' ', <>;\n\t$sec = 0;\n\t$stack = 0;\n\twhile( @_ or $stack ){\n\t\twhile( @_ and $stack + $_[0] <= $h ){\n\t\t\t$stack += shift @_;\n\t\t\t}\n\t\t\n\t\tint( $stack / $k ) or do { $stack = 0; $sec ++ };\n\t\t$sec += int( $stack / $k );\n\t\t$stack %= $k;\n\t\t}\n\tprint 0 + $sec\n}"}], "negative_code": [{"source_code": "$\\ = $/;\nwhile(<>){\n\t($n, $h, $k) = split;\n\t@_ = split ' ', <>;\n\t$sec = 0;\n\t$stack = 0;\n\twhile( @_ ){\n\t\twhile( @_ and $stack + $_[0] <= $h ){\n\t\t\t$stack += shift @_;\n\t\t\t}\n\t\t\n\t\t$stack -= $k;\n\t\t$stack < 0 and $stack = 0;\n\t\t$sec ++;\n\t\t}\n\tprint ++ $sec\n}"}], "src_uid": "5099a9ae62e82441c496ac37d92e99e3"}
{"source_code": "($x,$k)=split/ /,<>;\n@_=(0)x$x;\n$_=join\"\",<>;\ns/ (\\d+)/$_[$1]++/gem;\n$_=join\"\",@_;\ns/.//;\n$b=()=/0/g;\ns/00/0/g;\n$b=(()=/0/g).\" $b\";\nprint \"$b\\n\";\n", "positive_code": [{"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}, {"source_code": "use integer;\n\nwhile(<>){\n\t\n\t($x,$k)=split/ /;\n\tchomp $k;\n\t@_=(0)x($x);\n\tfor $i(1..$k){\n\t\t$_=<>;\n\t\t@num=split/ /;\n\t\tshift @num;\n\t\twhile (@num){\n\t\t\t$_[pop @num]++;\n\t\t\t}\n\t\t\n\t\t}\n#\tprint \"@_\\n\";\n\tshift @_;\n\t$_=join\"\",@_;\n\t$a=$_;\n\t$sum=0;\n\ts#0+#$sum+=((length$&)/2+((length$&)%2?1:0))#eg;\n\t$_=$a;\n\tprint \"$sum \";\n\tprint ($b=()=/0/g);\n\tprint \"\\n\";\n\t}\n\t\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n"}, {"source_code": "@_=(0)x<>;\ns/ (\\d+)/$_[$1]++/ge for <>;\n$_=join\"\",@_;\ns/.//;\nprint ((()=/00|0/g).\" \".(()=/0/g))\n\n"}], "negative_code": [], "src_uid": "fb77c9339250f206e7188b951902a221"}
{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: little_elephant.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 05/26/2015 07:38:44 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\nchomp(my $n = <STDIN>);\nprint join(\" \", ($n, 1..($n-1)));\nprint \"\\n\";\n\n", "positive_code": [{"source_code": "$n = <STDIN>;\nprint $n;\nfor( $i=1;$i<$n;$i++ ){\n    print \" \".$i;\n}"}, {"source_code": "#!/bin/perl\nuse strict;\nuse warnings;\n\nsub main () {\n\tmy $n = int <STDIN>;\n\tprint \"$n\";\n\tfor ( 1 .. $n - 1 ) {\n\t\tprint \" $_\";\n\t}\n\tprint \"\\n\";\n\texit 0;\n}\n\nmain();\n\n__END__\n\n"}, {"source_code": "@_=(1..<>);\nprint pop @_; \n@_ and print \" @_\""}, {"source_code": "#!perl -p\n@_=1..$_-1;$_.=\"@_\"\n"}, {"source_code": "#!perl -p\n@_=1..$_-1;$_=\"$_ @_\";\n"}], "negative_code": [{"source_code": "#!perl -p\n@_=2..$_;$_=\"@_ 1\";\n"}, {"source_code": "@_=(2..<>,1); \nprint \"@_\""}], "src_uid": "d9ba1dfe11cf3dae177f8898f3abeefd"}
{"source_code": "$\\ = $/;\nwhile($n = <>){\n\t\n\t@_ = sort {$a <=> $b} split \" \", <>;\n\t$ans = 1;\n\t$sum = $_[ 0 ];\n\t$e = 10e9;\n\tfor $i (1 .. @_ - 1){\n\t\t$ans += $a = $sum <= $_[ $i ];\n\t\t$a and $sum += $_[ $i ];\n\t\t$sum > $e and last;\n\t\t}\n\t\t\n\tprint $ans;\n\t\n}", "positive_code": [{"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "use v5.10;\n\nchomp($n = <>);\n@a = sort {$a <=> $b} split / /, <>;\n($ans, $tot) = (0, 0);\n$tot<=$_ and ++$ans and $tot+=$_ foreach (@a);\nsay $ans;"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a"}, {"source_code": "<>;\n\t$_ < $z or ($z += $_, ++ $a)\n\tfor sort {$a <=> $b} split \" \", <>;\nprint $a\n"}], "negative_code": [{"source_code": "use v5.10;\n\nchomp($n = <>);\n@a = sort {$a <=> $b} split / /, <>;\n($ans, $tot) = (0, 0);\nforeach (@a) {\n\t$tot <= $_ and ++$ans;\n\t$tot += $_;\n}\nsay $ans;"}, {"source_code": "$\\ = $/;\nwhile($n = <>){\n\t\n\t@_ = sort {$a <=> $b} split \" \", <>;\n\t$i = 0;\n\tpush @a, $i += $_ for @_;\n\tshift @_;\n\t$ans = 1;\n\t$e = 10e9;\n\t(($a = shift @a) > $e and last) , $ans += $_ >= $a for @_;\n\t\n\tprint $ans;\n}"}], "src_uid": "08c4d8db40a49184ad26c7d8098a8992"}
{"source_code": "my $numberlines = <STDIN>; \nmy $numeros;\n@arrayradios = split(/\\s+/, $numberlines);\n$R = $arrayradios[0]; \n$r = $arrayradios[1];\nmy $contador=0;\n@arraydistancias=();\n@radiosp=();\nmy $N= <STDIN>;\n$l = $N-1;\nfor($i=$l;$l>=0;$l--)\n{\n\t$numeros = <STDIN>;\n\t@arraynumeros = split(/\\s+/, $numeros);\n\t$disteucl = sqrt(($arraynumeros[0] **2)+($arraynumeros[1] **2));\n\tpush (@arraydistancias, $disteucl);\n\tpush (@radiosp, $arraynumeros[2]);\n}\nfor($i=$N-1;$N>=0;$N--)\n{\n\tif ((($arraydistancias[$N] + $radiosp[$N]) <= $R) && (($arraydistancias[$N]-$radiosp[$N]) >= $R - $r)) {\n\t\t$contador = $contador+ 1;\n\t}\n}\n\nprint $contador;", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $r, $d ) = split;\n\tmy @A = map { [ split ' ', <> ] } 1 .. <>;\n\tmy $cnt = 0;\n\t\n\tfor ( @A ){\n\t\tmy $min = $r - $d + $_->[2];\n\t\tmy $max = $r - $_->[2];\n\t\t$debug and print \"min:[$min], max:[$max]\";\n\t\tmy $R = $_->[0] ** 2 + $_->[1] ** 2;\n\t\tif( $min ** 2 <= $R and $R <= $max ** 2 ){\n\t\t\t$cnt ++;\n\t\t\t}\n\t\t}\n\t\n\tprint $cnt;\n\t}"}, {"source_code": "#!/usr/bin/perl\n$line = <STDIN>; \n@radios = split(/\\s+/, $line);\n$r = $radios[0]; \n$d = $radios[1];\nmy $N= <STDIN> - 1;\n$dat = $N;\n@distan=();\n@rad=();\nwhile ($dat >= 0){\n\t$ent = <STDIN>;\n\t@datos = split(/\\s+/, $ent);\n\t$Tempd = sqrt(($datos[0] * $datos[0])+($datos[1] * $datos[1]));\n\tpush (@distan, $Tempd);\n\tpush (@rad, $datos[2]);\n\t$dat = $dat-1;\n#\tprint \"@distan\\n\";\n#\tprint \"@rad\\n\";\n}\n$c=0;\nwhile ($N >= 0){\n#\tprint $distan[$N].\"\\n\";\n#\tprint $rad[$N].\"\\n\";\n\tif ((($distan[$N] + $rad[$N]) <= $r) && (($distan[$N]-$rad[$N]) >= $r - $d)) {\n\t\t$c = $c + 1;\n\t}\n\t$N = $N-1;\n}\nprint $c.\"\\n\";"}, {"source_code": "( $r, $d ) = split ' ', <>; <>;\n\nfor ( <> ){\n\t( $x, $y, $r2 ) = split;\n\t$R = $x ** 2 + $y ** 2;\n\t$c += ( ($r - $d + $r2) ** 2 <= $R and $R <= ($r - $r2) ** 2 );\n\t}\n\t\nprint $c"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n$line = <STDIN>; \n@radios = split(/\\s+/, $line);\n$R = $radios[0]; \n$r = $radios[1];\nmy $N= <STDIN> - 1;\n$dat = $N;\n@distan=();\n@rad=();\nwhile ($dat >= 0){\n\t$ent = <STDIN>;\n\t@datos = split(/\\s+/, $ent);\n\t$Tempd = sqrt(($datos[0] * $datos[0])+($datos[1] * $datos[1]));\n\tpush (@distan, $Tempd);\n\tpush (@rad, $datos[2]);\n\t$dat = $dat-1;\n#\tprint \"@distan\\n\";\n#\tprint \"@rad\\n\";\n}\n$c=0;\nwhile ($N >= 0){\n#\tprint $distan[$N].\"\\n\";\n#\tprint $rad[$N].\"\\n\";\n\tif ((($distan[$N] + $rad[$N]) <= $R) && (($distan[$N]-$rad[$N]) >= $r)) {\n\t\t$c = $c + 1;\n\t}\n\t$N = $N-1;\n}\nprint $c.\"\\n\";"}, {"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\n\n\nmy $m;\nmy $i;\nmy $j;\nmy $valor;\nmy @m1;\nmy @m2;\nmy $contador=0;\nmy $outside;\nmy $main;\n\n\nprint \"Ingrese R:\";\nmy $R = <STDIN>;\nchomp $R;\nprint \"R es '$R'\\n\";\n\nprint \"Ingrese r:\";\nmy $r = <STDIN>;\nchomp $r;\nprint \"r es '$r'\\n\";\n\nprint \"ingrese los puntos:\";\n$m=<STDIN>;\nchop($m);\n\nfor($i=0;$i<$m;$i++)\n{\n   for($j=0;$j<3;$j++)\n   {$valor=<STDIN>;\n   \tchop($valor);\n   \t$m1[$i][$j]=$valor;\n   }\n}\nfor($i=0;$i<$m;$i++)\n{\n\tfor($j=0;$j<=3;$j++)\n\t{\n\t\t$m2[$i][$j]=sqrt($m1[$i][$j]**2+$m1[$i][$j+1]**2);\n\t}\n\tprint \"\\n\";\n}\n\nfor($i=0;$i<$m;$i++)\n{\n   for($j=0;$j<1;$j++)\n   {\n   \tif($m2[$i][$j]+$r<=$R)\n   \t{\n   \t\t$contador=$contador+1;\n   \t}\n   }\n   print \"\\n\";\n}\nprint $contador;"}, {"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\n\n\nmy $m;\nmy $i;\nmy $j;\nmy $valor;\nmy @m1;\nmy @m2;\nmy $contador=0;\nmy $outside;\nmy $main;\n\nmy $R = <STDIN>;\nchomp $R;\n\nmy $r = <STDIN>;\nchomp $r;\n\n$m=<STDIN>;\nchop($m);\n\nfor($i=0;$i<$m;$i++)\n{\n   for($j=0;$j<3;$j++)\n   {$valor=<STDIN>;\n   \tchop($valor);\n   \t$m1[$i][$j]=$valor;\n   }\n}\nfor($i=0;$i<$m;$i++)\n{\n\tfor($j=0;$j<=3;$j++)\n\t{\n\t\t$m2[$i][$j]=sqrt($m1[$i][$j]**2+$m1[$i][$j+1]**2);\n\t}\n}\nfor($i=0;$i<$m;$i++)\n{\n   for($j=0;$j<1;$j++)\n   {\n   \tif($m2[$i][$j]+$r<=$R)\n   \t{\n   \t\t$contador=$contador+1;\n   \t}\n   }\n}\nprint $contador;"}, {"source_code": "( $r, $d ) = split ' ', <>;\n\nfor ( <> ){\n\t( $x, $y, $r2 ) = split;\n\t$R = $x ** 2 + $y ** 2;\n\t$c += ( ($r - $d + $r2) ** 2 <= $R and $R <= ($r - $r2) ** 2 );\n\t}\n\t\nprint $c"}], "src_uid": "fce9d78ad7d4ea01be1704f588e42d37"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t@odd  = map { $_ % 2 ? $_ : $_ + 1 } @_;\n\t@even = map { $_ % 2 ? $_ + 1 : $_ } @_;\n#\tprint \"[@odd]\";\n#\tprint \"[@even]\";\n\t\n\tpush @odd, -1;\n\tpush @even, -1;\n\t\n\t@ans = ();\n\t\n\t$seq = 0;\n\t$max = 0;\n\t\n\tfor $i (1 .. @odd -1){\n\t\t$odd[ $i ] == $odd[ $i -1 ] ? \n\t\t\tdo { $seq ++ }\n\t\t:\n\t\t\tdo { $seq > $max and $max = $seq; $seq = 0 }\n\t\t}\n\tpush @ans, \"$max\";\n\t\n\t$seq = 0;\n\t$max = 0;\n\t\n\tfor $i (1 .. @even -1){\n\t\t$even[ $i ] == $even[ $i -1 ] ? \n\t\t\tdo { $seq ++ }\n\t\t:\n\t\t\tdo { $seq > $max and $max = $seq; $seq = 0 }\n\t\t}\n\tpush @ans, \"$max\";\n\t\n\tprint 1 + (sort {$b <=> $a} @ans)[ 0 ]\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n@_ = split ' ', (<>,<>);\n\n$MAX = 0;\n\nfor $i (0 .. 1){\n\t\n\t@A = map { $_ += $_ % 2 == $i ? 1 : 0 } @A = @_, -1;\n\n\t$seq = 0;\n\t$max = 0;\n\t\n\tfor (1 .. @A -1){\n\t\t$A[ $_ ] == $A[ $_ -1 ] ? \n\t\t\t++ $seq : do { $seq > $max and $max = $seq; $seq = 0 }\n\t\t}\n\t\n\t$MAX < $max and $MAX = $max\n\t}\n\t\nprint 1 + $MAX"}, {"source_code": "@_ = split ' ', (<>,<>);\n\nfor $i (0 .. 1){\n\t\n\t@A = map $_ += $_ % 2 == $i, @A = @_, -1;\n\n\tmy ($seq, $max);\n\t\n\tfor (1 .. @A -1){\n\t\t$A[ $_ ] == $A[ $_ -1 ] ? \n\t\t\t++ $seq : do { push @B, $seq; $seq = 0 }\n\t\t}\n\t}\n\t\nprint 1 + (sort {$b <=> $a} @B)[ 0 ]"}], "negative_code": [{"source_code": "@_ = split ' ', (<>,<>);\n\nfor $i (0 .. 1){\n\t$_ .= ' ' . join ' ', map $_ += $_ % 2 == $i, @A = @_, -1;\n\t}\n\t\nprint + ( sort {$b <=> $a} map 0 + split, /( (\\b \\d+ ) (?: [ ] \\2)* )/gx )[ 0 ]"}, {"source_code": "@_ = split ' ', (<>,<>);\n\nfor $i (0 .. 1){\n\t$_ .= ' ' . join ' ', map $_ += $_ % 2 == $i, @A = @_, -1;\n\t}\n\nprint \"[$_]\";\nprint + ( sort {$b <=> $a} map 0 + split, /( (\\b \\d+ ) (?: [ ] \\2 \\b)* )/gx )[ 0 ]\n"}, {"source_code": "@_ = split ' ', (<>,<>);\n\nfor $i (0 .. 1){\n\t$_ .= ' ' . join ' ', map $_ += $_ % 2 == $i, @A = @_, -1;\n\t}\n\nprint + ( sort {$b <=> $a} map 0 + split, /( (\\b \\d+ ) (?: [ ] \\2 \\b){0,1e6} )/gx )[ 0 ]"}, {"source_code": "@_ = split ' ', (<>,<>);\n\nfor $i (0 .. 1){\n\t$_ .= ' ' . join ' ', map $_ += $_ % 2 == $i, @A = @_, -1;\n\t}\n\nprint \"[$_]\";\nprint + ( sort {$b <=> $a} map 0 + split, /( (\\b \\d+ ) (?: [ ] \\2 \\b){0,1e6} )/gx )[ 0 ]"}, {"source_code": "@_ = split ' ', (<>,<>);\n\nfor $i (0 .. 1){\n\t$_ .= ' ' . join ' ', map $_ += $_ % 2 == $i, @A = @_, -1;\n\t}\n\nprint + ( sort {$b <=> $a} map 0 + split, /( (\\b \\d+ ) (?: [ ] \\2 \\b)* )/gx )[ 0 ]"}], "src_uid": "b784cebc7e50cc831fde480171b9eb84"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tmy $z = () = m/0/g;\n\tmy $o = () = m/1/g;\n\t\n\tmy( $max ) = sort { $b <=> $a } map length, split /(?<=0)(?=1)|(?<=1)(?=0)/;\n\t\n\tprint $z * $o > $max ** 2 ? $z * $o : $max ** 2;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>, chomp;\r\n\t\r\n\t$z = () = m/0/g;\r\n\t$o = () = m/1/g;\r\n\t\r\n\t( $m ) = sort { $b <=> $a } map length, m/0+|1+/g;\r\n\t\r\n\tprint $z * $o > $m ** 2 ? $z * $o : $m ** 2;\r\n\t}"}], "negative_code": [], "src_uid": "9070e0d4f8071d1ee8df5189b7c17bfa"}
{"source_code": "<>;\n$_ = 0 x 350;\n\tfor $e ( <> ){\n\t\t\twhile ( $s < $e ){\n\t\t\t\ts/[0-8](?=9*$)/ $s - $e < -10 ? ( $s += 9 - $&, 9 ) : ( $s++ , $&+1 )/e;\n\t\t\t\t}\n\t\t\tif ( $s > $e ){\n\t\t\t\twhile ($s > $e){\n\t\t\t\t\ts/[1-9](?=0*$)/ $s - $e > 10 ? ($s -= $&, 0) : ( $s--, $&-1 )/e;\n\t\t\t\t\t}\n\t\t\t\ts/([0-8])(9*)([1-9])(0*)$/ $1+1 . $4 . ($3-1) . $2 /e;\n\t\t\t\t}\n\t\t\t\n\t\t/^0+/;\n\t\tprint $'.$/;\n\t\ts/[0-8](9*)$/($a=$&)=~y!0-9!1-90!,$a/e;\n\t\t$s -= -1 + 9 * length $1;\n\t\t}", "positive_code": [{"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 350;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/([0-8])(?=9*$)/ $s - $e < -10 ? ( $s += 9 - $1 - 1 , 9 ) : $1+1 /e;\n\t\t\t\t$s ++;\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\twhile ($s > $e){\n\t\t\t\t\twhile ($s - $e > 30){\n\t\t\t\t\t\ts/([1-9]{3})(?=0*$)/000/e;\n\t\t\t\t\t\t$s -= $1;\n\t\t\t\t\t\t}\n\t\t\t\t\twhile ($s - $e > 10){\n\t\t\t\t\t\ts/([1-9])(?=0*$)/0/e;\n\t\t\t\t\t\t$s -= $1;\n\t\t\t\t\t\t}\n\t\t\t\t\ts/([1-9])(?=0*$)/$1-1/e;\n\t\t\t\t\t$s --;\n\t\t\t\t\t}\n\t\t\t\ts/([0-8])(9*)([1-9])(0*)$/ $1+1 . $4 . ($3-1) . $2 /e;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/([0-8]9*)$/($a=$1)=~y!0-89!1-90!,$a/e;\n\t\t$s ++;\n\t\t$s -= 9 * ( - 1 + length $1);\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 350;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/[0-8](?=9*$)/ $s - $e < -10 ? ( $s += 9 - $& - 1 , 9 ) : $&+1 /e;\n\t\t\t\t$s ++;\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\twhile ($s > $e){\n\t\t\t\t\twhile ($s - $e > 30){\n\t\t\t\t\t\ts/[1-9]{3}(?=0*$)/000/e;\n\t\t\t\t\t\t$s -= $&;\n\t\t\t\t\t\t}\n\t\t\t\t\twhile ($s - $e > 10){\n\t\t\t\t\t\ts/[1-9](?=0*$)/0/e;\n\t\t\t\t\t\t$s -= $&;\n\t\t\t\t\t\t}\n\t\t\t\t\ts/[1-9](?=0*$)/$&-1/e;\n\t\t\t\t\t$s --;\n\t\t\t\t\t}\n\t\t\t\ts/([0-8])(9*)([1-9])(0*)$/ $1+1 . $4 . ($3-1) . $2 /e;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/[0-8]9*$/($a=$&)=~y!0-89!1-90!,$a/e;\n\t\t$s ++;\n\t\t$s -= 9 * ( - 1 + length $&);\n\t\t}\n\t\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 350;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/[^9](?=9*$)/$&+1/e;\n\t\t\t\t$s ++;\n\t#\t\t\tprint \"+[\".(0+$_).\"]\";\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\ts/[^9]9*$/($a=$&)=~y!0-9!1-90!,$a/e;\n\t\t\t\t$s ++;\n\t\t\t\t$s -= 9 * ( - 1 + length $&);\n\t#\t\t\t\t\t\t\tprint \"-[\".(0+$_).\"]\";\n\n\t\t\t\t\twhile ($s > $e){\n\t\t\t\t\t\ts/([0-8])(9*)([1-9])(0*)$/$1+1 . 0 x(length $2) . 0 . $4/e;\n\t\t\t\t\t\t$s ++;\n\t\t\t\t\t\t$s -= $3;\n\t\t\t\t\t\t$s -= 9 x(length $2)\n\t#\t\t\t\t\t\t\t\t\tprint \":[\".(0+$_).\"]\";\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/[^9]9*$/($a=$&)=~y!0-89!1-90!,$a/e;\n\t\t$s ++;\n\t\t$s -= 9 * ( - 1 + length $&);\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 3e2;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/[^9](?=9*$)/$&+1/e;\n\t\t\t\t$s ++;\n\t#\t\t\tprint \"+[\".(0+$_).\"]\";\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\ts/[^9]9*$/($a=$&)=~y!0-9!1-90!,$a/e;\n\t\t\t\t$s ++;\n\t\t\t\t$s -= 9 * ( - 1 + length $&);\n\t#\t\t\t\t\t\t\tprint \"-[\".(0+$_).\"]\";\n\n\t\t\t\t\twhile ($s > $e){\n\t\t\t\t\t\ts/(.)([1-9])(0*)$/$1+1 . 0 . $3/e;\n\t\t\t\t\t\t$s ++;\n\t\t\t\t\t\t$s -= $2;\n\t#\t\t\t\t\t\t\t\t\tprint \":[\".(0+$_).\"]\";\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/[^9]9*$/($a=$&)=~y!0-89!1-90!,$a/e;\n\t\t$s ++;\n\t\t$s -= 9 * ( - 1 + length $&);\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 350;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/[^9](?=9*$)/$&+1/e;\n\t\t\t\t$s ++;\n\t#\t\t\tprint \"+[\".(0+$_).\"]\";\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\ts/[^9]9*$/($a=$&)=~y!0-9!1-90!,$a/e;\n\t\t\t\t$s ++;\n\t\t\t\t$s -= 9 * ( - 1 + length $&);\n\t#\t\t\t\t\t\t\tprint \"-[\".(0+$_).\"]\";\n\n\t\t\t\t\twhile ($s > $e){\n\t\t\t\t\t\ts/(.)([1-9])(0*)$/$1+1 . 0 . $3/e;\n\t\t\t\t\t\t$s ++;\n\t\t\t\t\t\t$s -= $2;\n\t#\t\t\t\t\t\t\t\t\tprint \":[\".(0+$_).\"]\";\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/[^9]9*$/($a=$&)=~y!0-89!1-90!,$a/e;\n\t\t$s ++;\n\t\t$s -= 9 * ( - 1 + length $&);\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 3e2;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/[^9](?=9*$)/$&+1/e;\n\t\t\t\t$s ++;\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\ts/[^9]9*$/($a=$&)=~y!0-9!1-90!,$a/e;\n\t\t\t\t$s ++;\n\t\t\t\t$s -= 9 * ( - 1 + length $&);\n\t\t\t\t\twhile ($s > $e){\n\t\t\t\t\t\ts/(.)([1-9])(0*)$/$1+1 . 0 . $3/e;\n\t\t\t\t\t\t$s ++;\n\t\t\t\t\t\t$s -= $2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/[^9](?=9*$)/$&+1/e;\n\t\t$s ++;\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\nwhile( $n = <> ){\n\t$s = 0;\n\t$_ = 0 x 80;\n\tfor $i ( 1 .. $n ){\n\t\tchomp( $e = <> );\n\t\twhile ( $s != $e ){\n\t\t\tif ( $s < $e ){\n\t\t\t\ts/[^9](?=9*$)/$&+1/e;\n\t\t\t\t$s ++;\n\t\t\t\t}\n\t\t\telsif ( $s > $e ){\n\t\t\t\twhile ($s > $e){\n\t\t\t\t\tif ($s - $e > 10){\n\t\t\t\t\t\ts/[1-9](?=0*$)/0/e;\n\t\t\t\t\t\t$s -= $&;\n\t\t\t\t\t\t}\n\t\t\t\t\ts/[1-9](?=0*$)/$&-1/e;\n\t\t\t\t\t$s --;\n\t\t\t\t\t}\n\t\t\t\ts/([0-8])(9*)([1-9])(0*)$/ $1+1 . $4 . ($3-1) . $2 /e;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t($a = $_) =~ s/^0+//;\n\t\tprint $a;\n\t\ts/[^9]9*$/($a=$&)=~y!0-89!1-90!,$a/e;\n\t\t$s ++;\n\t\t$s -= 9 * ( - 1 + length $&);\n\t\t}\n\t\n\t}"}], "src_uid": "4577a9b2d96110966ad95a960ef7ec20"}
{"source_code": "#!/usr/bin/perl\n\n($n, $m, $k) = split(/\\s/, <STDIN>);\n($mCount, $kCount) = ($m, $k);\n@a = split(/\\s/, <STDIN>);\n$answer = 0;\n\nforeach $item (@a) {\n  if( $item == 1 ) {\n    if( $mCount > 0 ) {\n      $mCount--;\n    }\n    else {\n      $answer++;\n    }\n  }\n  else {\n    if( $kCount > 0 ) {\n      $kCount--;\n    }\n    else {\n      if( $mCount > 0 ) {\n\t$mCount--;\n      }\n      else {\n\t$answer++;\n      }\n    }\n  }\n}\n\nprint $answer, \"\\n\";", "positive_code": [{"source_code": "($n, $m, $k) = split / /, <>;\n@line = split / /, <>;\n# =pod\n@arr = (0,0,0);\n@arr[$_]++ for @line;\nif ($m >= $arr[1]) {\n\t$ans = $arr[2]-$m+$arr[1]-$k;\n\t$ans = 0 if $ans < 0;\n\t# =pod\n\t# if ($ans < 0) {\n\t\t# $ans = 0;\n\t# }\n\t# =cut\n} else {\n\t$ans = $arr[1] - $m;\n\t$tmp = $arr[2] - $k;\n\t$tmp = 0 if $tmp < 0;\n\t$ans += $tmp;\n}\nprint $ans,\"\\n\";\n# =cut"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($ans, $k, $n, $m) = (0, split / /, <>);\nforeach (split / /, <>) {\n\tif ($_ == 1) {\n\t\t($n>0 and $n--) or ++$ans;\n\t} else {\n\t\t($m>0 and $m--) or ($n>0 and $n--) or ++$ans;\n\t}\n}\nsay $ans;"}, {"source_code": "#!/usr/bin/perl\nuse bignum;\n\n($n, $m, $k) = split(/\\s/, <STDIN>);\n($mCount, $kCount) = ($m, $k);\n@a = split(/\\s/, <STDIN>);\n$answer = 0;\n\nforeach $item (@a) {\n  if( $item == 1 ) {\n    if( $mCount > 0 ) {\n      $mCount--;\n    }\n    else {\n      $answer++;\n    }\n  }\n  else {\n    if( $kCount > 0 ) {\n      $kCount--;\n    }\n    else {\n      if( $mCount > 0 ) {\n\t$mCount--;\n      }\n      else {\n\t$answer++;\n      }\n    }\n  }\n}\n\nprint $answer, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\n\n$input = <>;\n($n, $m, $k)=split(/\\s/, $input);\n$input = <>;\n@a = split(/\\s/, $input);\n$bowl = $m;\n$plate = $k;\n$total = @a;\n\nforeach $i (@a){\n    if($i == 1){\n\tif($bowl > 0){\n\t$bowl--;\n\t$total--;\n    }\n\telse{\n\t    break;\n\t}\n\t\n    }\n    else{\n\tif($plate > 0 ){\n\t    $plate--;\n\t    $total--;\n\t}\n\telsif($bowl > 0){\n\t    $bowl--;\n\t    $total--;\n\t}\n\telse{\n\tbreak;\n    }\n\n    }\n}\nprint $total;\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile(<>){\n\t($n, $m, $k) = split/ /;\n#\tprint \" $n $m $k\";\n\t@_=split/ /,<>;\n\t$ats=0;\n\t\n\tfor (@_){\n\t\tif ($_==1){\n\t\t\t$m--;\n\t\t\t$m<0 and $ats++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\t$k--;\n\t\t\t\t$k<0 and $m--;\n\t\t\t\t$k<0 and $m<0 and $ats++;\n\t\t\t\t}\n\n\t\t}\n\tprint \"$ats\\n\";\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nwhile(<>){\n\t($n, $m, $k) = split/ /;\n#\tprint \" $n $m $k\";\n\t@_=split/ /,<>;\n\t$ats=0;\n\t\n\tfor (@_){\n\t\tif ($_==1){\n\t\t\t$m--;\n\t\t\t$m<0 and $ats++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\t$k--;\n\t\t\t\t$k<0 and $m--;\n\t\t\t\t$m<0 and $ats++;\n\t\t\t\t}\n\n\t\t}\n\tprint \"ats: $ats\\n\";\n}"}, {"source_code": "#!/usr/bin/perl\n\nwhile(<>){\n\t($n, $m, $k) = split/ /;\n#\tprint \" $n $m $k\";\n\t@_=split/ /,<>;\n\t$ats=0;\n\t\n\tfor (@_){\n\t\tif ($_==1){\n\t\t\t$m--;\n\t\t\t$m<0 and $ats++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\t$k--;\n\t\t\t\t$k<0 and $m--;\n\t\t\t\t$m<0 and $ats++;\n\t\t\t\t}\n\n\t\t}\n\tprint \"$ats\\n\";\n}"}], "src_uid": "4ed5b8055ce48b5ad4e43ed4b06d1b07"}
{"source_code": "#!/usr/bin/perl\n\nmy $inp = <STDIN>;\nmy @ar = split(' ', $inp);\n\nmy $i;\nmy $h;\nmy $f = 0;\nmy $f_ans = -1;\n\nfor ($i = 1; $i <= $ar[1]; $i += 1) {\n  my $tmp = <STDIN>;\n  my $ans = $tmp % $ar[0];\n  if ($h{$ans} == 2) {\n    if ($f == 0) {\n        $f = 1;\n        $f_ans = $i;\n    }\n  } else {\n    $h{$ans} = 2;\n  }\n}\n\nprint $f_ans;", "positive_code": [{"source_code": "\n# get first line as a string\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $p, $n;\n($p, $n) = split m/ /, $f;\n\nmy %h;\nmy $collison = 0;\n\nfor ( my $i =0 ; $i < $n; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n    if ( exists $h{ $f % $p } ) {\n\tprint (($i + 1) . \"\\n\");\t\t# print answer\n\t$i = $n; \t\t# exit the loop \n\t$collision = 1;\n    }\n    $h{ $f % $p } = 1;\n}\n\nif ( not $collision ) {\n    print \"-1\\n\"; }\n    \n    \n\n\n\n\n\n\n"}, {"source_code": "\n# get first line as a string\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $p, $n;\n($p, $n) = split m/ /, $f;\n\nmy %h;\nmy $colliison = 0;\n\nfor ( my $i =0 ; $i < $n; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n    if ( exists $h{ $f % $p } ) {\n\tprint (($i + 1) . \"\\n\");\t\t# print answer\n\t$i = $n; \t\t# exit the loop \n\t$collision = 1;\n    }\n    $h{ $f % $p } = 1;\n}\n\nif ( not $collision ) {\n    print \"-1\\n\"; }\n    \n    \n\n\n\n\n\n\n"}, {"source_code": "use strict ;\nuse warnings ;\n\nmy @array = split(/ /,<STDIN>) ;\n\nmy $p = $array[0] ;\nmy $n = $array[1] ;\n\nmy @x ;\n\nfor(my $j = 0 ; $j < $n ; $j++){\n\t$x[$j] = <STDIN> ;\n}\n\nmy %hash ;\n\nfor(my $i = 0 ; $i < $n ; $i++ ) {\n\tmy $value = $x[$i] ;\n\tmy $remainder = $value % $p ;\n\t\n\tif(exists $hash{$remainder}){\n\t\tprint $i + 1 ;\n\t\texit ;\n\t}else{\n\t\t$hash{$remainder} = 1 ;\n\t}\n}\n\nprint -1 ;"}, {"source_code": "chomp ($line = <>);\n($p, $n) = split ' ', $line;\nfor(1..$n)\n{\n    chomp($x = <>);\n    print \"$_\\n\" and exit if $seen{$x % $p};\n    $seen{$x % $p} = 1;\n}\nprint \"-1\\n\";\n"}], "negative_code": [{"source_code": "\n# get first line as a string\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $p, $n;\n($p, $n) = split m/ /, $f;\n\nprint \"two\\n\";\n\nmy %h;\nmy $colliison = 0;\n\nfor ( my $i =0 ; $i < $n; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n    if ( exists $h{ $f } ) {\n\tprint \"$i\\n\";\t\t# print answer\n\t$i = $n; \t\t# exit the loop \n\t$collision = 1;\n    }\n    $h{ $f } = 1;\n}\n\nif ( not $collision ) {\n    print \"-1\\n\"; }\n    \n    \n\n\n\n\n\n\n"}, {"source_code": "\n# get first line as a string\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $p, $n;\n($p, $n) = split m/ /, $f;\n\nmy %h;\nmy $colliison = 0;\n\nfor ( my $i =0 ; $i < $n; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n    if ( exists $h{ $f } ) {\n\tprint \"$i\\n\";\t\t# print answer\n\t$i = $n; \t\t# exit the loop \n\t$collision = 1;\n    }\n    $h{ $f } = 1;\n}\n\nif ( not $collision ) {\n    print \"-1\\n\"; }\n    \n    \n\n\n\n\n\n\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $inp = <STDIN>;\nmy @ar = split(' ', $inp);\n\nmy $i;\nmy $h;\nmy $f = 0;\nmy $f_ans = -1;\n\nfor ($i = 1; $i <= $ar[1]; $i += 1) {\n  my $tmp = <STDIN>;\n  my $ans = $tmp % $ar[0];\n  if ($h{$ans} == 2) {\n    $f = 1;\n    my $f_ans = $i;\n  } else {\n    $h{$ans} = 2;\n  }\n}\n\nprint $f_ans;"}, {"source_code": "#!/usr/bin/perl\n\nmy $inp = <STDIN>;\nmy @ar = split(' ', $inp);\n\nmy $i;\nmy $h;\nmy $f = 0;\nmy $f_ans = -1;\n\nfor ($i = 1; $i <= $ar[1]; $i += 1) {\n  my $tmp = <>;\n  my $ans = $tmp % $ar[0];\n  if ($h{$ans} == 2) {\n    $f = 1;\n    my $f_ans = $i;\n  } else {\n    $h{$ans} = 2;\n  }\n}\n\nprint $f_ans;"}], "src_uid": "5d5dfa4f129bda46055fb636ef33515f"}
{"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t$t=0;\n\t\n\tif ($k > 2){\n\t\ts/(.)\\1(?=(.|))/$t++,\n\t\t\t($1 ne A && $+ ne A and $y = A) ||\n\t\t\t($1 ne B && $+ ne B and $y = B) ||\n\t\t\t($1 ne C && $+ ne C and $y = C),\n\t\t\t$1.$y/ge\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$t = (length) - ($AB > $BA ? $AB : $BA);\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $t,$/,$_,$/\n\t}", "positive_code": [{"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t$t=0;\n\t\n\tif ($k > 2){\n\t\t$_.=Z;\n\t\ts/(.)\\1(?=(.))/$t++,\n\t\t\t($1 ne A && $+ ne A and $y = A) ||\n\t\t\t($1 ne B && $+ ne B and $y = B) ||\n\t\t\t($1 ne C && $+ ne C and $y = C),\n\t\t\t$1.$y/ge;\n\t\tchop\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$t = (length) - ($AB > $BA ? $AB : $BA);\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $t,$/,$_,$/\n\t}"}], "negative_code": [{"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t$t=0;\n\t\n\tif ($k > 2){\n\t\ts/(.)\\1(?=(.))/$t++,\n\t\t\t($1 ne A && $+ ne A and $y = A) ||\n\t\t\t($1 ne B && $+ ne B and $y = B) ||\n\t\t\t($1 ne C && $+ ne C and $y = C),\n\t\t\t$1.$y/ge\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$t = (length) - ($AB > $BA ? $AB : $BA);\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $t,$/,$_,$/\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t$t=0;\n\t\n\tif ($k > 2){\n\t\t$m=A;\n\t\tfor $i(1..$k){\n\t\t\t$d= $m;\n\t\t\t$d++;\n\t\t\t$d gt (A..Z)[$k-1] and $d = A;\n\t\t\t$e= $d;\n\t\t\t$e++;\n\t\t\t$e gt (A..Z)[$k-1] and $e = A;\n\t\t\t$qm = qr/$m$m(?=$d|$)/;\n\t\t\t$t += s/$qm/$m$e/g;\n\t\t\t$qm = qr/$m$m(?=[^$d])/;\n\t\t\t$t += s/$qm/$m$d/g;\n\t\t\t$m++;\n\t\t\t}\n\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$t = (length) - ($AB > $BA ? $AB : $BA);\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $t,$/,$_,$/\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t\n\tif ($k > 2){\n\t\ts/(.)\\1(?=(.|))/$p=$1,$r='ABC',$r=~s{$p|$+}{}g,$r=~m{.},(print \"[$&]\"),$p.$&/ge\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $_,$/\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t\n\tif ($k > 2){\n\t\ts/(.)\\1(?=(.|))/$p=$1,$r='ABC',$r=~s{$p|$+}{}g,$r=~m{.},$p.$&/ge\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $_,$/\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_ = split//;\n\t$AB = $BA = @ab = @ba = ();\n\t$t=0;\n\t\n\tif ($k > 2){\n\t\t$m=A;\n\t\tfor $i(1..$k){\n\t\t\t$d= $m;\n\t\t\t$d++;\n\t\t\t$d gt (A..Z)[$k-1] and $d = A;\n\t\t\t$e= $d;\n\t\t\t$e++;\n\t\t\t$e gt (A..Z)[$k-1] and $e = A;\n\t\t\t$qm = qr/$m$m(?=$d)/;\n\t\t\t$t += s/$qm/$m$e/g;\n\t\t\t$qm = qr/$m$m(?=[^$d]|$)/;\n\t\t\t$t += s/$qm/$m$d/g;\n\t\t\t$m++;\n\t\t\t}\n\n\t\t}\n\telse {\n\t\t@ab = (A, B) x ($n / 2);\n\t\t$n % 2 and push @ab, A;\n\t\t@ba = (B, A) x ($n / 2);\n\t\t$n % 2 and push @ba, B;\n\t\tfor ($i = 0; $i < length ; $i++){\n\t\t\t$AB += $_[$i] eq $ab[$i];\n\t\t\t$BA += $_[$i] eq $ba[$i];\n\t\t\t}\n\t\t$t = (length) - ($AB > $BA ? $AB : $BA);\n\t\t$_ = join'', ($AB > $BA? @ab : @ba );\n\t\t}\n\tprint $t,$/,$_,$/\n\t}"}], "src_uid": "0ecf60ea733eba71ef1cc1e736296d96"}
{"source_code": "#!/usr/bin/perl\nuse 5.010;\n\n$s = <STDIN>;\nchomp($s);\n\nmy %mp;\n\nforeach $c ( split //, $s )\n{\n\t$char = \"\".$c;\n\t\n\t#print $char.\"\\n\";\n\tif( exists $mp{$char} ){\n\t\tmy $val = $mp{$char};\n\t\t$mp{$char} = $val + 1;\n\t}\n\telse{\n\t\t$mp{$char}= 1;\n\t\t\n\t}\n\t\n\t\n}\n\n\nmy $count = keys %mp;\nmy @v = values %mp;\nmy $cnt = 0;\nfor $val (@v){\n\t\t\tif($val>1){\n\t\t\t\t$cnt++;\n\t\t\t}\n}\n#print $count;\n\nif( $count == 2 ){\t\n\t\tsay( ($cnt==2) ? \"Yes\" : \"No\" );\n}\nelsif( $count == 3 ) {\n\t\tsay( ($cnt>=1) ? \"Yes\" : \"No\" );\n}\nelsif ( $count ==4 ) {\n\tsay(\"Yes\");\n}\nelse{\n\tsay (\"No\");\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split //;\n\t\n\tmy @values = values %h;\n\t\n\tprint do { \n\t\tif( 4 < keys %h ){\n\t\t\t'No';\n\t\t\t}\n\t\telsif( 4 == keys %h ){\n\t\t\t'Yes';\n\t\t\t}\n\t\telsif( 3 == keys %h ){\n\t\t\t( 3 < length ) ? 'Yes' : 'No';\n\t\t\t}\n\t\telsif( 2 == keys %h ){\n\t\t\tdo {\n\t\t\t\tif( $values[ 0 ] > 1 and $values[ 1 ] > 1 ){\n\t\t\t\t\t'Yes';\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t'No';\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\telse{\n\t\t\t'No';\n\t\t\t}\n\t\t};\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse 5.010;\n\n$s = <STDIN>;\nchomp($s);\n\nmy %mp;\n\nforeach $c ( split //, $s )\n{\n\t$char = \"\".$c;\n\t\n\t#print $char.\"\\n\";\n\tif( exists $mp{$char} ){\n\t\tmy $val = $mp{$char};\n\t\t$mp{$char} = $val + 1;\n\t}\n\telse{\n\t\t$mp{$char}= 1;\n\t\t\n\t}\n\t\n\t\n}\n\n\nmy $count = keys %mp;\nmy @v = values %mp;\nmy $cnt = 0;\nfor $val (@v){\n\t\t\tif($val>1){\n\t\t\t\t$cnt++;\n\t\t\t}\n}\nprint $count;\n\nif( $count == 2 ){\t\n\t\tsay( ($cnt==2) ? \"Yes\" : \"No\" );\n}\nelsif( $count == 3 ) {\n\t\tsay( ($cnt>=1) ? \"Yes\" : \"No\" );\n}\nelsif ( $count ==4 ) {\n\tsay(\"Yes\");\n}\nelse{\n\tsay (\"No\");\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse 5.010;\n\n$s = <STDIN>;\nchomp($s);\n\n\nforeach $char ( split //, $s )\n{\n\t$char = \"\".$char;\n\tif( exists $mp{$char} ){\n\t\t$mp[$char] = $mp[$char]+1;\n\t}\n\telse{\n\t\t$mp[$char] = 1;\n\t}\n}\n\nmy $count = keys %mp;\nmy @v = values %mp;\nmy $cnt = 0;\nfor $val (@v){\n\t\t\tif($val>1){\n\t\t\t\t$cnt++;\n\t\t\t}\n}\n\n\nif( $count == 2 ){\t\n\t\tsay( ($cnt==2) ? \"Yes\" : \"No\" );\n}\nelsif( $count == 3 ) {\n\t\tsay( ($cnt>=1) ? \"Yes\" : \"No\" );\n}\nelsif ( $count ==4 ) {\n\tsay(\"Yes\");\n}\nelse{\n\tsay (\"No\");\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\t\n\t\n\t\n\t}"}], "src_uid": "6190db9007f8f5eba095a6fcfc3652fc"}
{"source_code": "#use Time::HiRes qw(gettimeofday tv_interval);\n#$t=[gettimeofday];\n\n$fh=\\*STDIN;\n# open($fh,\"<\",\"t\\\\l\")||die;\n\n$n=<$fh>; \n$s=<$fh>; chomp $s;\n\n$inspect = 1;\n$eq_len = 1;\n\nsub z {\n\tif ($inspect = 1 && $eq_len > 1) {\n    \t$eq_count++;\n    \tif ($eq_len == 2 && $eq_count == 1) {\n    \t\t$add = 1;\n    \t}\n    \telsif ($eq_len > 2 || $eq_count > 1) {\n    \t\t$add = 2;\n    \t\t$inspect = 0;\n    \t}\n    \t$eq_len = 1;\n\t}\n}\n\nfor ($i=0; $i<length($s); $i++) {\n\t$ch = substr($s, $i, 1);\n\t# print \"ch=$ch\\n\";\n  \tif ($prev ne $ch)  {\n  \t\t$prev = $ch;\n  \t\t$count++;\n  \t\tz();\n  \t} else {\n  \t\t$eq_len++;\n  \t}\n}\nz();\n\n$count+=$add;\nprint $count;\n\n# print tv_interval($t),\"\\n\";", "positive_code": [{"source_code": "$_ = (<>, <>);\nprint + (() = /0+|1+/g) + ( /111/ || /000/ || /00.*00/ || /00.*11/ || /11.*00/ || /11.*11/ ) + /00|11/ "}, {"source_code": "$_ = (<>, <>), chomp;\n$L = length( y/01//sr );\nprint $L + ( (length) - $L < 2 ? (length) - $L : 2)"}, {"source_code": "$n = -1;\n<>; $x =<>; chomp($x);\n@c = split('', $x);\n\nforeach(@c)\n{\n\t$a ++ if $n == -1 or $n != $_;\n\t$s ++ if $n == $_ and $n != -1;\n\t$n = $_;\n}\n\n$s = $s > 2 ? 2 : $s;\nprint $a + $s;\n\n"}, {"source_code": "$_ = (<>, <>), chomp;\n@_ = split /\\b/, y/1/,/r;\nprint @_\n+ ( ( 1 < grep 1 < length, @_ ) || ( !! grep 2 < length, @_ ) )\n+ !! grep 1 < length, @_"}], "negative_code": [{"source_code": "$inspect = 1;\n$eq_len = 1;\n\nsub z {\n\tif ($inspect = 1 && $eq_len > 0) {\n    \t$eq_count++;\n    \tif ($eq_len == 2 && $eq_count == 1) {\n    \t\t$add = 1;\n    \t}\n    \telsif ($eq_len > 2 || $eq_count > 1) {\n    \t\t$add = 2;\n    \t\t$inspect = 0;\n    \t}\n    \t$eq_len = 1;\n\t}\n}\n\n$skip = 1;\nwhile (($n = sysread(STDIN, $s, 1000)) > 0) {\n\tfor ($i=0; $i<length($s); $i++) {\n\t\t$ch = substr($s, $i, 1);\n\t\t# print \"ch=$ch\\n\";\n\t\tif ($skip == 1) {\n\t\t\tif ($ch eq chr(10)) {\n\t\t\t\t$skip = 0;\n\t\t\t}\t\t\t\n\t\t} else {\n    \t\tif ($prev ne $ch)  {\n    \t\t\t$prev = $ch;\n    \t\t\t$count++;\n    \t\t\tz();\n    \t\t} else {\n    \t\t\t$eq_len++;\n    \t\t}\n\t\t}\n\t}\n}\nz();\n\n# print \"count=$count\\n\";\n# print \"add=$add\\n\";\n$count+=$add;\nprint $count;"}, {"source_code": "#use Time::HiRes qw(gettimeofday tv_interval);\n#$t=[gettimeofday];\n\n$fh=\\*STDIN;\n# open($fh,\"<\",\"t\\\\l\")||die;\n\n$n=<$fh>; \n$s=<$fh>; chomp $s;\n\n$inspect = 1;\n$eq_len = 1;\n\nsub z {\n\tif ($inspect = 1 && $eq_len > 0) {\n    \t$eq_count++;\n    \tif ($eq_len == 2 && $eq_count == 1) {\n    \t\t$add = 1;\n    \t}\n    \telsif ($eq_len > 2 || $eq_count > 1) {\n    \t\t$add = 2;\n    \t\t$inspect = 0;\n    \t}\n    \t$eq_len = 1;\n\t}\n}\n\nfor ($i=0; $i<length($s); $i++) {\n\t$ch = substr($s, $i, 1);\n\t# print \"ch=$ch\\n\";\n  \tif ($prev ne $ch)  {\n  \t\t$prev = $ch;\n  \t\t$count++;\n  \t\tz();\n  \t} else {\n  \t\t$eq_len++;\n  \t}\n}\nz();\n\n$count+=$add;\nprint $count;\n\n# print tv_interval($t),\"\\n\";"}, {"source_code": "$_ = (<>, <>);\nprint + (() = /(.)\\1*/g) + (2 * ( /111/ || /000/ || /11.*00/ || /00.*11/ ) || (1 * ( /^11/ || /00$/)) )"}, {"source_code": "$_ = (<>, <>);\nprint + (() = /(.)\\1*/g) + ( /(.)\\1\\1/ || /(.)\\1.*\\1\\1/ ) + /(.)\\1/"}, {"source_code": "$n = -1;\n<>;\n@c = split('', <>);\nchomp(@c);\nforeach(@c)\n{\n\t$a ++ if $n == -1 or $n != $_;\n\t$s ++ if $n == $_;\n\t$n = $_;\n}\n\n$s = $s > 2 ? 2 : $s;\nprint $a + $s - 1;\n\n"}, {"source_code": "$_ = (<>, <>);\nprint + (() = /(.)\\1*/g) + 2 * (/^11/ || /00$/ || /111/ || /000/ || /11.*00/ || /00.*11/ )"}, {"source_code": "$_ = <>;\nprint + (() = /(.)\\1*/g) + ( /(.)\\1\\1/ || /(.)\\1.*\\1\\1/ ) + /(.)\\1/"}, {"source_code": "$_ = (<>, <>);\nprint + (() = /(.)\\1*/g) + (2 * ( /111/ || /000/ || /00.*00/ || /00.*11/ || /11.*00/ || /11.*11/ ) || (1 * /(.)\\1/ ) )"}, {"source_code": "$_ = (<>, <>);\nprint + (() = /(.)\\1*/g) + /(.)\\1\\1|(.)\\2.*(.)\\3/ + /(.)\\1/"}], "src_uid": "7b56edf7cc71a1b3e39b3057a4387cad"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy $time = 0;\n\t\n\t$time += $_ for @A;\n\t\n\twhile( @B > 1 ){\n\t\tif( $B[ 0 ] < $B[ @B - 1 ] ){\n\t\t\t$time += $B[ 0 ];\n\t\t\tshift @B;\n\t\t\t}\n\t\telse{\n\t\t\t$time += $B[ @B - 1 ];\n\t\t\tpop @B;\n\t\t\t}\n\t\t}\n\tprint $time;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tprint eval join '+', ( split ' ', <> ), \r\n\t\tdo { my @B = sort { $a <=> $b } split ' ', <>; pop @B; @B }\r\n\t}"}], "negative_code": [], "src_uid": "5c75658faf6dda4d7e21e1dcf39b350a"}
{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy %donor = ();\nmy $n = <>;\nmy @a = split ' ', <>;\n$donor{$a[$_ - 1]} = $_ for 1..$n;\nprint join ' ', map { $donor{$_} } sort { $a <=> $b } keys %donor;\nprint \"\\n\";\n", "positive_code": [{"source_code": "$n = <>;\n$_ = <>;\n@a = (0, split);\nfor (0 .. $n) {\n    $b[$a[$_]] = $_;\n}\nprint \"@b[1 .. $n]\";\n"}, {"source_code": "my $n = <>;\nmy @arr = split \" \", <>;\nmy @ans = (0) x $n;\nfor (0..$n-1) {\n    $ans[$arr[$_]] = $_ + 1;\n}\nshift @ans;\nprint \"@ans\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n=<>);\n@ans = (0) x ($n+1);\n$i = 1;\n$ans[$_]=$i++ foreach(split / /, <>);\n1+shift @ans and say join ' ', @ans;"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @p = split ' ', <>;\nmy @a = map { $_ - 1 } @p;\nmy %h;\nfor my $i (0..$n-1) {\n    $h{ $a[$i] } = $i;\n}\nfor (keys %h) {\n    $h{$_}++;\n}\nfor my $i (0..$n-1) {\n    print \"$h{$i} \";\n}\n"}, {"source_code": "<STDIN>;\nchomp($s = <STDIN>);\n@arr = split(/ /, $s);\n\nfor($i = 0; $i <= $#arr; ++$i) {\n    $result[$arr[$i] - 1] = $i + 1;\n}\nprint \"@result\";"}, {"source_code": "use strict;\nmy $n = <>;\nmy @a = split(' ', <>);\nmy @b;\nfor(my $i = 0; $i <= $#a; $i++){\n  $b[$a[$i]] = $i + 1;\n}\nforeach my $i (@b){\n  print $i, ' ';\n}\n"}, {"source_code": "<stdin>; chomp($_=<stdin>);my @arr=split(\" \"); my $i = 0; my %hash = map {++$i => $_} @arr; %hash = reverse %hash; print \"$hash{$_} \" for (1..@arr-1); print \"$hash{@arr}\\n\""}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\nmy @numbers = split q{ }, read_line;\n\nmy @answer = ();\n\nfor (1..$n) {\n    my $i = shift @numbers;\n    $answer[$i] = $_;\n}\n\nshift @answer;\n\nsay \"@answer\";\n"}, {"source_code": "<>;\n@_=split/ /,<>;\nfor (1..@_){\n$a[(shift@_)-1]=$_;\n}\nprint\"@a\""}, {"source_code": "my $num = <>;\nchomp $num;\nmy $index = <>;\nchomp $index;\nmy @index = split / /, $index;\nmy @new;\nfor $n(1..$num) {\n    my $count=1;\n    $count++ while ($n != $index[$count-1]);\n    push @new, $count;\n}\nprint join \" \", @new;"}], "negative_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy %donor = ();\nmy $n = <>;\nmy @a = split ' ', <>;\n$donor{$a[$_ - 1]} = $_ for 1..$n;\nprint join ' ', map { $donor{$_} } sort keys %donor;\nprint \"\\n\";\n"}, {"source_code": "<STDIN>;\nchomp($s = <STDIN>);\n@arr = split(/ /, $s);\n\nfor($i = 0; $i <= $#arr; ++$i) {\n    $result[$arr[$i] - 1] = $i + 1;\n}\nprint @result;"}], "src_uid": "48bb148e2c4d003cad9d57e7b1ab78fb"}
{"source_code": "my $n = <STDIN>;\nmy @c = split(/\\s/, <STDIN>);\nmy @p = split(/\\s/, <STDIN>);\nmy @b = (0,0,0,0,0);\nmy $t = 0;\n\nsub find {\n  my $i = shift;\n  my $j;\n  \n  if($i >= $p[4]){\n    return 4;\n  }elsif($i >= $p[3]){\n    return 3;\n  }elsif($i >= $p[2]){\n    return 2;\n  }elsif($i >= $p[1]){\n    return 1\n  }else{\n    return 0;\n  }  \n}\n\nforeach my $c(@c){\n  $t += $c;\n  \n  if($t >= $p[0]){\n    my $v = &find($t);\n    while($t >= $p[0]){\n      $x = int($t/$p[$v]);\n      $t = $t - $x*$p[$v];\n      $b[$v]+=$x;\n      $v = &find($t);\n    }\n  }\n}\n\nmap { print $_.\" \" } @b;\nprint \"\\n$t\";\n\n\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nchomp($n);\n\nmy $line = <>;\nchomp($line);\nmy @points = split(/\\s/, $line);\n\n$line = <>;\nchomp($line);\nmy @prize = split(/\\s/, $line);\nmy $min_prize = $prize[0];\n\nmy $point = 0;\n\nmy @ans = (0,0,0,0,0);\nfor (@points) {\n    $point += $_;\n    if ($point >= $min_prize) {\n        get_prize();\n    }\n}\n\nprint join(\" \", @ans), \"\\n\";\nprint $point;\n\n\nsub get_prize {\n    for (my $i=4; $i>=0; $i--) {\n        if ($point >= $prize[$i]) {\n            my $tmp = int($point / $prize[$i]);\n            $ans[$i] += $tmp;\n            $point -= $prize[$i] * $tmp;\n        }\n    }\n}\n"}], "negative_code": [], "src_uid": "1ae2942b72ebb7c55359c41e141900d7"}
{"source_code": "($n, $m) = split \" \", <>;\nfor (1 .. $m){\n($d2, $h2) = split \" \", <>;\n!$d1 ? ($T = $h2 + $d2 - 1) : do {\n$H = ($h2 > $h1 ? $h2 : $h1);\n$D = $d2 - $d1 - abs($h1 - $h2);\n$f += $D < 0;\n$T = $H + ($D >> 1);\n};\npush @x, $H, $T;\n($d1, $h1) = ($d2, $h2);\n}\npush @x, $h1 + $n - $d1;\nprint $f ? \"IMPOSSIBLE\" : (sort {$b <=> $a} @x)[0]", "positive_code": [{"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n!defined $d1 ? do {$top = $h2 + $d2 - 1} : do {\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$higher > $max and $max = $higher;\n};\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}], "negative_code": [{"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= -$d2;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= -$d2;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$higher > $max and $max = $higher;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= -$d2;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2) * 2;\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= 1;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$higher > $max and $max = $higher;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= 0;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$higher > $max and $max = $higher;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= -$d2;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2) * 2;\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= -d2 + 2;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$higher > $max and $max = $higher;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "use integer;\n$\\ = $/;\nwhile(<>){\n($n, $m) = split;\nundef $d1;\nundef $h1;\n$f = 0;\n$max = 0;\nfor $i (1 .. $m){\n($d2, $h2) = split \" \", <>;\n$d1 //= -$d2 + 2;\n$h1 //= 0;\n$higher = ($h2 > $h1 ? $h2 : $h1);\n$diff = ($d2 - $d1) - abs($h1 - $h2);\n$diff < 0 and $f++;\n$top = $higher + $diff / 2;\n$higher > $max and $max = $higher;\n$top > $max and $max = $top;\n($d1, $h1) = ($d2, $h2);\n}\n$top = $h1 + ($n - $d1);\n$top > $max and $max = $top;\nprint $f ? \"IMPOSSIBLE\" : $max;\n}"}, {"source_code": "($n, $m) = split \" \", <>;\nfor (1 .. $m){\n($d2, $h2) = split \" \", <>;\n!$d1 ? ($top = $h2 + $d2 - 1) : do {\n$H = ($h2 > $h1 ? $h2 : $h1);\n$D = $d2 - $d1 - abs($h1 - $h2);\n$f += $D < 0;\n$T = $H + ($D >> 1);\n};\npush @x, $H, $T;\n($d1, $h1) = ($d2, $h2);\n}\npush @x, $h1 + $n - $d1;\nprint $f ? \"IMPOSSIBLE\" : (sort {$b <=> $a} @x)[0]"}], "src_uid": "77b5bed410d621fb56c2eaebccff5108"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>;\nwhile (<>=~/ /){\n\tpush @i,$`;\n\tpush @j,$'+0;\n\t}\n$i=min(@i);\n$j=max(@j);\n\nfor $k(0..@i-1){\n\t$i[$k]==$i && $j[$k]==$j and print ($k+ ++$p);\n\t}\n\n$p or print -1;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse List::Util qw(max min);\n\nchomp(my $n = <>);\nmy @l = ();\nmy @r = ();\n\nfor my $i (1 .. $n) {\n    chomp($_ = <>);\n    my ($left, $right) = split;\n    push @l, $left;\n    push @r, $right;\n}\n\nmy $min_low = min @l;\nmy $max_high = max @r;\nmy $find = 0;\n\nfor my $i (0 .. $n - 1) {\n    if ($l[$i] == $min_low && $r[$i] == $max_high) {\n        print $i + 1, \"\\n\";\n        $find = 1;\n        last;\n    }\n}\nunless ($find) {\n    print \"-1\\n\";\n}\n"}], "negative_code": [], "src_uid": "e702594a8e993e135ea8ca78eb3ecd66"}
{"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>;\n\nmy $rB = [];\n\n$rB->[0]->[0] = \"W\";\nmy @q = (1,2,-1, 2,-2, 1, -1, -2);\nmy @p = (2,1, 2,-1, 1,-2, -2, -1);\n\nmy $changed = 1;\nwhile ( $changed eq 1 ) {\n$changed = 0;\nfor my $i ( 0 .. $n - 1 ) {\nfor my $j ( 0 .. $n - 1 ) {\n  for my $u ( 0 .. $#q ) {\n    next if ( $j+$p[$u] < 0 or $j+$p[$u] > $n - 1 );\n    next if ( $i+$q[$u] < 0 or $i+$q[$u] > $n - 1 );\n\n    if ( not defined $rB->[$i]->[$j] ) {\n       if ( defined $rB->[$i+$q[$u]]->[$j+$p[$u]] ) {\n          if ( $rB->[$i+$q[$u]]->[$j+$p[$u]] eq \"W\") {\n             $rB->[$i]->[$j] = \"B\"; $changed = 1;\n          }\n          if ( $rB->[$i+$q[$u]]->[$j+$p[$u]] eq \"B\") {\n             $rB->[$i]->[$j] = \"W\"; $changed = 1;\n          }\n          #print \"$i $j $u\\n\";\n          #prnt();\n       }\n    }\n  }\n}\n}\n}\n\nprnt();\n\nsub prnt {\n\nfor my $i ( 0 .. $n - 1 ) {\nfor my $j ( 0 .. $n - 1 ) {\n my $v = defined $rB->[$i]->[$j] ? $rB->[$i]->[$j] : \"B\";\n print $v;\n}\nprint \"\\n\";\n}\n#print \"\\n\";\n\n}\n", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile( <> ){\n\tchomp;\n\t\n\t( 'WB' x $_ ) =~ /\n\t\t\\B (?= (.{$_}) )\n\t\t(?{ print $1 })\n\t\t(*F)\n\t\t/x;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <> ){\n\tchomp $n;\n\t\n\t$_ = 'WB' x $n;\n\t\n\t@_ = ();\n\t\n\tfor my $i ( 1 .. $n ){\n\t\tpush @_, substr $_, $i % 2, $n;\n\t\t}\n\t\n\tprint for @_;\n\t}"}], "negative_code": [], "src_uid": "09991e8e16cd395c7ce459817a385988"}
{"source_code": "for(1..<>) {\r\n        chomp(my $in = <>);\r\n        my ($l, $r, $k) = split / /, $in;\r\n        $l == $r && $l > 1 and print \"YES\\n\" and next;\r\n        $sn = $l%2 == 0 && $r%2 == 0 ? ($r-$l)/2 : int(($r-$l)/2) + 1;\r\n        print $k >= $sn ? \"YES\\n\" : \"NO\\n\";\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $l, $r, $k ) = split;\n\t\n\tif( $l == $r and $l > 1 ){\n\t\tprint 'YES';\n\t\tnext;\n\t\t}\n\t\n\t$l % 2 or $l ++;\n\t$r % 2 or $r --;\n\t\n\tmy $odds = ( $r - $l + 2 >> 1 );\n\t\n\tprint $odds > $k ? 'NO' : 'YES';\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $l, $r, $k ) = split;\n\t\n\tif( $l == $r and $l > 1 ){\n\t\tprint 'YES';\n\t\tnext;\n\t\t}\n\t\n\tmy $odds = ( $r - $l >> 1 ) + ( $l % 2 );\n\t\n\tprint $odds > $k ? 'NO' : 'YES';\n\t}"}], "src_uid": "9363df0735005832573ef4d17b6a8302"}
{"source_code": "($n, $m) = split \" \", <>;\n\t$r = $_ % 4,\n\t$_ = '#' x $m,\n\t( eval qw(s/(?<!^)#/./g 1 s/#(?!$)/./g 1)[$r % 4] ),\n\tprint $_.$/\n\tfor 1 .. $n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\nuse strict;\n\n$\\ = \"\\n\";\n\nmy ($n, $m) = split ' ', <>;\nfor my $i (1..$n) {\n    if ($i % 2 == 1) {\n        print '#' x $m;\n    } elsif ($i % 4 == 0) {\n        print '#', '.' x ($m - 1);\n    } else {\n        print '.' x ($m - 1) . '#';\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n, my $m;\n($n, $m) = split ' ',readline;\n\nmy @matrix;\nfor(my $i = 0; $i < $n; $i++){\n    $matrix[$i] = [('.') x $m];\n}\nmy $r=0; my $c = 0; my $d = 1;\nwhile($r < $n){\n    $matrix[$r][$c] = '#';\n    $c += $d;\n    if($c < 0 || $c >= $m){\n        $c -= $d;\n        $r++;\n        if($r >= $n) { last; }\n        $matrix[$r][$c] = '#';\n        $r++;\n        $d *= -1;\n    }\n}\nfor(my $i = 0; $i < $n; $i++){\n    for(my $j = 0; $j < $m; $j++){\n        print $matrix[$i][$j];\n    }\n    print \"\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\nuse v5.18;\nuse integer;\n\nmy ($n, $m) = split(' ', <>);\n\nsay('#' x $m);\n\nmy $left = 0;\n\nforeach (1..(($n-1) / 2))\n{\n    if ($left) {\n        say('#' . '.' x ($m - 1));\n    }\n    else\n    {\n        say('.' x ($m - 1) . '#');\n    }\n    $left = !$left;\n    say '#' x $m;\n}\n"}, {"source_code": "$\\=$/;\nwhile(<>){\n    ($n, $m) = split;\n    $s = '#' x $m;\n    for $i (1 .. $n){\n    $_ = $s;\n    if (not $i % 2){\n    s/#/./g;\n    $i % 4? s/.$/#/ : s/./#/;\n    }\n    print\n    }\n    }"}, {"source_code": "($n, $m) = split \" \", <>;\n\t$q = qw(. .$)[$_ % 4 / 2],\n\t$_ = qw(. #)[$_ % 2] x $m,\n\ts/$q/#/,\n\tprint $_.$/\n\tfor 1 .. $n"}, {"source_code": "my ($n, $m) = split \" \", <>;\nfor my $i(1..$n) {\n    if ($i % 2) {\n        print '#' x $m, \"\\n\";\n    }\n    else {\n        if ($i % 4 == 0) {\n            print '#', '.' x int($m-1) , \"\\n\";\n        }\n        else {\n            print '.' x int($m-1) , \"#\\n\";\n        }\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\n($n, $m) = split / /, <>;\nforeach my $i (1..$n) {\n\tif ($i%2 == 1) {\n\t\tsay '#' x $m;\n\t} elsif ($i/2%2 == 1) {\n\t\tsay '.' x ($m-1) . '#';\n\t} else {\n\t\tsay '#' . '.' x ($m-1);\n\t}\n}"}], "negative_code": [{"source_code": "    $\\=$/;\n    while(<>){\n    ($n, $m) = split;\n    $s = '#' x $m;\n    for $i (1 .. $n){\n    $_ = $s;\n    if (not $i % 2){\n    s/#/./g;\n    $i % 4? s/.$/#/ : s/./#/;\n    }\n    print\n    }\n    print'--'\n    }"}], "src_uid": "2a770c32d741b3440e7f78cd5670d54d"}
{"source_code": "<>; @a = split \" \", <>; $h{$_}++ for @a;\n@b = sort {$a <=> $b} keys %h;\nfor $p (map 1<<$_, 1..30) {\n\tfor $b1 (@b) {\n\t\t$b2 = $p - $b1;\n\t\t$h{$b2} and do { \n\t\t\t$c += $b1 == $b2? $h{$b1} * ($h{$b1} - 1):  $h{$b1} * $h{$b2} \n\t\t};\n\t}\n}\nprint $c/2, \"\\n\";\n", "positive_code": [{"source_code": "<>; $h{$_}++ for split \" \", <>;\nfor $p (map 1<<$_, 1..30) {\n\tfor $b1 (keys %h) {\n\t\t$b2 = $p - $b1;\n\t\t$h{$b2} and do { \n\t\t\t$c += $b1 == $b2? $h{$b1} * ($h{$b1} - 1):  $h{$b1} * $h{$b2} \n\t\t};\n\t}\n}\nprint $c/2, \"\\n\";\n"}], "negative_code": [], "src_uid": "b812d2d3a031dadf3d850605d2e78e33"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @p = ();\r\n  my @s = ();\r\n  for(my $i=0;$i<$n;$i++){\r\n    my $s1 = <STDIN>;\r\n    for(my $j=0;$j<$n;$j++){\r\n      my $c1 = substr($s1,$j,1);\r\n      if( $c1 eq '*' ){\r\n        push(@p,+[$i,$j]);\r\n      }\r\n    }\r\n    push(@s,$s1);\r\n  }\r\n  my %r = (); my %c = ();\r\n  foreach my $p1 (@p){\r\n    $r{$p1->[0]} = 1;\r\n    $c{$p1->[1]} = 1;\r\n  }\r\n  my @r = map { $_ - 0 } sort keys %r;\r\n  my @c = map { $_ - 0 } sort keys %c;\r\n  if( $#c == 0 ){\r\n    for(my $i=0;$i<$n;$i++){\r\n      if( $c[0] != $i ){\r\n        push(@c,$i);\r\n        last;\r\n      }\r\n    }\r\n  }\r\n  if( $#r == 0 ){\r\n    for(my $i=0;$i<$n;$i++){\r\n      if( $r[0] != $i ){\r\n        push(@r,$i);\r\n        last;\r\n      }\r\n    }\r\n  }\r\n  foreach my $r1 (@r){\r\n    foreach my $c1 (@c){\r\n      substr($s[$r1],$c1,1) = '*';\r\n    }\r\n  }\r\n  for(my $i=0;$i<$n;$i++){\r\n    print $s[$i];\r\n  }\r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\tmy( $two_stars ) = grep m/\\*.*\\*/, @_;\n\t\n\tif( defined $two_stars ){\n\t\tfor( @_ ){\n\t\t\t$_ ne $two_stars and do {\n\t\t\t\t$_ = $two_stars;\n\t\t\t\tlast;\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\telse{\n\t\tmy @lines = grep m/\\*/, @_;\n\t\t\n\t\tif( $lines[ 0 ] eq $lines[ 1 ] ){\n\t\t\tm/\\*/ and s/\\./*/ for @_;\n\t\t\t}\n\t\telse{\n\t\t\tmy @idx = map { index $_, '*' } @lines;\n\t\t\tfor( @_ ){\n\t\t\t\tnext if not m/\\*/;\n\t\t\t\tsubstr $_, $idx[ 0 ], 1, '*';\n\t\t\t\tsubstr $_, $idx[ 1 ], 1, '*';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint for @_;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tchomp;\r\n\t@_ = map ~~<>, 1 .. $_;\r\n\tchomp @_;\r\n\t\r\n\ty/.*/01/ for @_;\r\n\t\r\n\tmy( $two ) = grep m/1.*1/, @_;\r\n\t\r\n\tif( $two ){\r\n\t\tfor( @_ ){\r\n\t\t\tm/1/ or $_ = $two and last;\r\n\t\t\t}\r\n\t\t}\r\n\telse{\r\n\t\tmy @L = grep m/1/, @_;\r\n\t\t\r\n\t\tif( $L[ 0 ] eq $L[ 1 ] ){\r\n\t\t\tm/1/ and s/0/1/ for @_;\r\n\t\t\t}\r\n\t\telse{\r\n\t\t\tmy $B = sprintf \"%0${_}b\",\r\n\t\t\t\teval join '|', map eval,\r\n\t\t\t\tmap '0b' . $_, @L;\r\n\t\t\t\t\r\n\t\t\tm/1/ and $_ = $B for @_;\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\ty/01/.*/ for @_;\r\n\t\r\n\tprint for @_;\r\n\t}"}], "src_uid": "d8fb3822b983b8a8ffab341aee74f56f"}
{"source_code": "#!/usr/bin/perl\n\nmy ($t) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nfor( my $t_loop=0; $t_loop<$t; $t_loop++ ){\n  \n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  if( $n % 2 == 1 ){\n    my $nn = 1 + (($n - 1)/2);\n    print \"$nn\\n\";\n  } else {\n    my $nn = 1 + ($n / 2);\n    print \"$nn\\n\";\n  }\n  \n}\n\nexit(0);\n\n", "positive_code": [{"source_code": "use v5.20;\nsub { \n    &{sub { say int <> / 2 + 1 }}\n        while ($_[0]--);\n} -> (my $t = <>);"}], "negative_code": [{"source_code": "&{sub { \n    sub { print int <> / 2 + 1 } -> ()\n        while ($_[0]--);\n}}(<>);"}], "src_uid": "eb39ac8d703516c7f81f95a989791b21"}
{"source_code": "$_ = <>;\n\n$m = $_ % 3 == 2;\n\nprint join ' ', $_ - 2 - $m, 1, 1 + $m", "positive_code": [{"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;chomp($n);\nmy $m=$n%3;my $out;\nif($m==0){\n    if($n%9==0){\n\t$out=($n/3+4).\" \".($n/3-2).\" \".($n/3-2).\"\\n\";\n    }\n    else{\n\t$out=($n/3).\" \".($n/3).\" \".($n/3).\"\\n\";\n    }\n}\nelsif($m==1){\n    $out=($n/3+4).\" \".($n/3-2).\" \".($n/3-1).\"\\n\" if($n/3%3==0);\n    $out=($n/3).\" \".($n/3).\" \".($n/3+1).\"\\n\" if($n/3%3==1);\n    $out=($n/3).\" \".($n/3-1).\" \".($n/3+2).\"\\n\" if($n/3%3==2);\n}\nelse{\n    $out=($n/3+4).\" \".($n/3-1).\" \".($n/3-1).\"\\n\" if($n/3%3==0);\n    $out=($n/3).\" \".($n/3).\" \".($n/3+2).\"\\n\" if($n/3%3==2);\n    $out=($n/3).\" \".($n/3-2).\" \".($n/3+4).\"\\n\" if($n/3%3==1);\n}\n$out=\"1 2 2\\n\" if($n==5);\nprint $out;"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\t@_ = ( $_ - 2, 1, 1 );\n\t\n\t$debug and print \"@_\";\n\t\n\tif( $_[ 0 ] % 3 == 0 ){\n\t\t$_[ 0 ] --;\n\t\t$_[ 1 ] ++;\n\t\t}\n\t\n\tprint \"@_\";\n\t\n\t$debug and print '-' x 10;\n\t}"}], "negative_code": [{"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;chomp($n);\nmy $m=$n%3;my $out;\nif($m==0){\n    if($n%9==0){\n\t$out=($n/3+4).\" \".($n/3-2).\" \".($n/3-2).\"\\n\";\n    }\n    else{\n\t$out=($n/3).\" \".($n/3).\" \".($n/3).\"\\n\";\n    }\n}\nelsif($m==1){\n    $out=($n/3+4).\" \".($n/3-2).\" \".($n/3-1).\"\\n\" if($n/3%3==0);\n    $out=($n/3).\" \".($n/3).\" \".($n/3+1).\"\\n\" if($n/3%3==1);\n    $out=($n/3).\" \".($n/3-1).\" \".($n/3+2).\"\\n\" if($n/3%3==2);\n}\nelse{\n    $out=($n/3+4).\" \".($n/3-1).\" \".($n/3-1).\"\\n\" if($n/3%3==0);\n    $out=($n/3).\" \".($n/3).\" \".($n/3+2).\"\\n\" if($n/3%3==2);\n    $out=($n/3).\" \".($n/3-2).\" \".($n/3+4).\"\\n\" if($n/3%3==1);\n}\nprint $out;"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;chomp($n);\nmy $m=$n%3;my $out;\nif($m==0){\n    if($n%9==0){\n\t$out=($n/3+4).\" \".($n/3-2).\" \".($n/3-2).\"\\n\";\n    }\n    else{\n\t$out=($n/3).\" \".($n/3).\" \".($n/3).\"\\n\";\n    }\n}\nelsif($m==1){\n    $out=($n/3+4).\" \".($n/3-2).\" \".($n/3-1).\"\\n\" if($n/3%3==0);\n    $out=($n/3).\" \".($n/3).\" \".($n/3+1).\"\\n\" if($n/3%3!=0);\n}\nelse{\n    $out=($n/3+4).\" \".($n/3-1).\" \".($n/3-1).\"\\n\" if($n/3%3==0);\n    $out=($n/3).\" \".($n/3).\" \".($n/3+2).\"\\n\" if($n/3%3!=0);\n}\nprint $out;"}], "src_uid": "91d5147fb602298e08cbdd9f86d833f8"}
{"source_code": "$\\ = $/;\n<>; ($n,$m) = split,\n$h{$n} =~/./ ? ($h{$m} = $h{$n}, delete $h{$n}): ($h{$m} = $n) while <>;\nprint 0 + (keys %h);\nprint \"$v $k\" while ($k,$v) = each %h", "positive_code": [{"source_code": "$\\ = $/;\n<>;\nundef %h;\nwhile(<>){\n\t($n,$m)=split;\n\tdefined $h{$n} ? ($h{$m} = $h{$n}, delete $h{$n}): ($h{$m} = $n);\n\t}\n$, = $\";\nprint scalar keys %h;\nwhile (($k,$v) = each %h){\n\tprint $v,$k\n\t}"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 2.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 01/14/2015 11:18:24 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\nchomp(my $n = <STDIN>);\n\nmy %name;\nwhile ( $n-- ) {\n\tchomp($_ = <STDIN>);\n\tmy ($old, $new) = split(/ /);\n\tif ( exists($name{$old}) ) {\n\t\tmy $origin = $name{$old};\n\t\tdelete $name{$old};\n\t\t$name{$new} = $origin;\n\t}\n\telse {\n\t\t$name{$new} = $old;\n\t}\n}\nmy $size = keys %name;\nprint \"$size\\n\";\nfor my $key (keys %name) {\n\tprint \"$name{$key} $key\\n\";\n}\n"}], "negative_code": [{"source_code": "$\\ = $/;\n<>; ($n,$m) = split,\n$h{$n} ? ($h{$m} = $h{$n}, delete $h{$n}): ($h{$m} = $n) while <>;\nprint 0 + %h;\nprint \"$v $k\" while ($k,$v) = each %h"}, {"source_code": "$\\ = $/;\n<>; ($n,$m) = split,\n$h{$n} ? ($h{$m} = $h{$n}, delete $h{$n}): ($h{$m} = $n) while <>;\nprint 0 + (keys %h);\nprint \"$v $k\" while ($k,$v) = each %h"}], "src_uid": "bdd98d17ff0d804d88d662cba6a61e8f"}
{"source_code": "chomp($n = <>);\n@a = split / /, <>;\nchomp @a;\n$L = 0;\nchomp $a[$#a];\n$L++ until $a[$L] > $a[$L+1];\nif($L == $#a){\n    print \"yes\\n1 1\\n\";\n}else {\n    #print \"current L = $L\\n\";\n    $R = $L++;\n    $R++ while $a[$R] > $a[$R+1] && $R < $#a;\n    if($R == $#a){\n        print $a[$#a] > $a[$L - 2] || $L == 1 ? \"yes\\n$L $n\" : \"no\";\n    }else{\n        $p = $R++;\n        $p++ while $a[$p] < $a[$p+1] && $p < $#a;\n        print $p == $#a && $a[$R] > $a[$L-1] && $a[$R-1] < $a[$L-1] ? \"yes\\n$L $R\" : \"no\";\n    }\n}\n", "positive_code": [{"source_code": "chomp($n = <>);\n@c = split / /, <>;\nchomp @c;\n$L = $R = 0;\n$L++ while $c[$L] < $c[$L+1] && $L < $#c;\n$R = $L;\n$R++ while $c[$R] > $c[$R+1] && $R < $#c;\n@d = @c[0..($L-1)] if $L > 0;\npush @d, reverse @c[$L..$R];\npush @d, @c[($R+1)..$#c] if $R < $#c;\n$L++; $R++;\n@c = sort { $a <=> $b } @d;\nprint @c ~~ @d ? \"yes\\n$L $R\\n\" : \"no\";\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\npush @b, [$_, $a[$_]] foreach (0 .. $n-1);\n@b = sort {$a->[1] <=> $b->[1]} @b;\n@id = (0) x $n;\n$id[$_]=$b[$_]->[0] foreach (0 .. $n-1);\n($l, $r) = (0, 0);\n($cnt, $i) = (0, 0);\nwhile ($i < $n) {\n\tif ($id[$i] != $i) {\n\t\t$cnt>0 and say \"no\" and exit;\n\t\t++$cnt;\n\t\tif ($i < $id[$i]) {\n\t\t\t($l, $r) = ($i, $id[$i]);\n\t\t} else {\n\t\t\t($r, $l) = ($i, $id[$i]);\n\t\t}\n\t\tfor (my ($j,$k)=($l,$r); $j<=$r; ++$j,--$k) {\n\t\t\t$id[$j]!=$k and say \"no\" and exit;\n\t\t}\n\t\t$i = $r;\n\t}\n\t++$i;\n}\n++$l and ++$r;\nsay \"yes\\n$l $r\";"}, {"source_code": "<>;\n($a,@_)=split/ /,<>;\n$a[0]=$a;\n\nfor $b(@_,10**10){\n\t$i++;\n\tif ($b<$a && !$e){$e=$i}\n\tif ($b<$a && !$f){push @b,$b} \n\telse {\n\t\tif (@b && !$f++){@b=reverse @b; push @b, pop @a; push @a, @b}; \n\t\tpush @a,$b\n\t\t}\n\t$a=$b;\n\t}\n\n$a=shift @a;\t\nfor (@a){\n\tif ($_<$a){$g++}\n\t$a=$_\n\t}\nif ($g){\n\tprint \"no\\n\"\n\t}\nelse {\n\tprint \"yes\\n\";\n\tprint $e? ($e,\" \",$e+@b-1):(\"1 1\")\n\t}"}, {"source_code": "chomp($n = <>);\n@a = split / /, <>;\nchomp @a;\n$L = 0;\nchomp $a[$#a];\n$L++ until $a[$L] > $a[$L+1];\nif($L == $#a){\n    print \"yes\\n1 1\\n\";\n}else {\n    #print \"current L = $L\\n\";\n    $R = $L++;\n    $R++ while $a[$R] > $a[$R+1] && $R < $#a;\n    if($R == $#a){\n        if($a[$#a] > $a[$L - 2] || $L == 1) {\n            #print \"$a[$#a]| $a[$L-2] | $L\\n\";\n            print \"yes\\n$L $n\\n\";\n        }else {\n            print \"no\";\n        }\n    }else{\n        $p = $R++;\n        $p++ while $a[$p] < $a[$p+1] && $p < $#a;\n        print $p == $#a && $a[$R] > $a[$L-1] && $a[$R-1] < $a[$L-1] ? \"yes\\n$L $R\" : \"no\";\n    }\n}\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\npush @b, [$_, $a[$_]] foreach (0 .. $n-1);\n@b = sort {$a->[1] <=> $b->[1]} @b;\n@id = (0) x $n;\n$id[$_]=$b[$_][0] foreach (0 .. $n-1);\n($l, $r) = (0, 0);\nwhile ($i < $n) {\n\tif ($id[$i] != $i) {\n\t\t$cnt++>0 and say \"no\" and exit;\n\t\tif ($i < $id[$i]) {\n\t\t\t($l, $r) = ($i, $id[$i]);\n\t\t} else {\n\t\t\t($r, $l) = ($i, $id[$i]);\n\t\t}\n\t\tfor (my ($j,$k)=($l,$r); $j<$k; ++$j,--$k) {\n\t\t\t$id[$j]!=$k and say \"no\" and exit;\n\t\t}\n\t\t$i = $r;\n\t}\n\t++$i;\n}\n++$l and ++$r;\nsay \"yes\\n$l $r\";"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\npush @b, [$_, $a[$_]] foreach (0 .. $n-1);\n@b = sort {$a->[1] <=> $b->[1]} @b;\n@id = (0) x $n;\n$id[$_]=$b[$_][0] foreach (0 .. $n-1);\n($l, $r) = (0, 0);\nwhile ($i < $n) {\n\tif ($id[$i] != $i) {\n\t\t$cnt++>0 and say \"no\" and exit;\n\t\t($l, $r) = ($i, $id[$i]);\n\t\t$l>$r and ($l, $r)=($r, $l);\n\t\tfor (my ($j,$k)=($l,$r); $j<$k; ++$j,--$k) {\n\t\t\t$id[$j]!=$k and say \"no\" and exit;\n\t\t}\n\t\t$i = $r;\n\t}\n\t++$i;\n}\n++$l and ++$r;\nsay \"yes\\n$l $r\";"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\npush @b, [$_, $a[$_]] foreach (0 .. $n-1);\n@b = sort {$a->[1] <=> $b->[1]} @b;\n@id = (0) x $n;\n$id[$_]=$b[$_][0] foreach (0 .. $n-1);\n($l, $r) = (0, 0);\n($cnt, $i) = (0, 0);\nwhile ($i < $n) {\n\tif ($id[$i] != $i) {\n\t\t$cnt>0 and say \"no\" and exit;\n\t\t++$cnt;\n\t\tif ($i < $id[$i]) {\n\t\t\t($l, $r) = ($i, $id[$i]);\n\t\t} else {\n\t\t\t($r, $l) = ($i, $id[$i]);\n\t\t}\n\t\tfor (my ($j,$k)=($l,$r); $j<=$k; ++$j,--$k) {\n\t\t\t$id[$j]!=$k and say \"no\" and exit;\n\t\t}\n\t\t$i = $r;\n\t}\n\t++$i;\n}\n++$l and ++$r;\nsay \"yes\\n$l $r\";"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\npush @b, [$_, $a[$_]] foreach (0 .. $n-1);\n@b = sort {$a->[1] <=> $b->[1]} @b;\n@id = (0) x $n;\n$id[$_]=$b[$_][0] foreach (0 .. $n-1);\n($l, $r) = (0, 0);\nwhile ($i < $n) {\n\tif ($id[$i] != $i) {\n\t\t$cnt++>0 and say \"no\" and exit;\n\t\t($l, $r) = ($i, $id[$i]);\n\t\tfor (my ($j,$k)=($l,$r); $j<$k; ++$j,--$k) {\n\t\t\t$id[$j]!=$k and say \"no\" and exit;\n\t\t}\n\t\t$i = $r;\n\t}\n\t++$i;\n}\n++$l and ++$r;\nsay \"yes\\n$l $r\";"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\npush @b, [$_, $a[$_]] foreach (0 .. $n-1);\n@b = sort {$a->[1] <=> $b->[1]} @b;\n@id = (0) x $n;\n$id[$_]=$b[$_][0] foreach (0 .. $n-1);\n($l, $r) = (1, 0, 0);\nwhile ($i < $n) {\n\tif ($id[$i] != $i) {\n\t\t$cnt++>0 and say \"no\" and exit;\n\t\t($l, $r) = ($i, $id[$i]);\n\t\tfor (my ($j,$k)=($l,$r); $j<$k; ++$j,--$k) {\n\t\t\t$id[$j]!=$k and say \"no\" and exit;\n\t\t}\n\t\t$i = $r;\n\t}\n\t++$i;\n}\n++$l and ++$r;\nsay \"yes\\n$l $r\";"}, {"source_code": "chomp($n = <>);\n@a = split / /, <>;\n$L = 0;\n$L++ until $a[$L] > $a[$L+1];\nif($L == $#a){\n    print \"yes\\n1 1\\n\";\n}else {\n    #print \"current L = $L\\n\";\n    $R = $L++;\n    $R++ while $a[$R] > $a[$R+1] && $R < $#a;\n    if($R == $#a && ($a[$#a] < $a[$L - 1] || $L == 1)){\n        print \"yes\\n$L $n\\n\";\n    }else{\n        $p = $R++;\n        $p++ while $a[$p] < $a[$p+1] && $p < $#a;\n        print $p == $#a && $a[$R] > $a[$L-1] && $a[$R-1] < $a[$L-1] ? \"yes\\n$L $R\" : \"no\";\n    }\n}\n"}, {"source_code": "chomp($n = <>);\n@a = split / /, <>;\n$L = 0;\n$L++ until $a[$L] > $a[$L+1];\nif($L == $#a){\n    print \"yes\\n1 1\\n\";\n}else {\n    #print \"current L = $L\\n\";\n    $R = $L++;\n    $R++ while $a[$R] > $a[$R+1] && $R < $#a;\n    if($R == $#a && $a[$#a] < $a[$L]){\n        print \"yes\\n$L $n\\n\";\n    }else{\n        $p = $R++;\n        $p++ while $a[$p] < $a[$p+1] && $p < $#a;\n        print $p == $#a && $a[$R] > $a[$L-1] && $a[$R-1] < $a[$L-1] ? \"yes\\n$L $R\" : \"no\";\n    }\n}\n"}, {"source_code": "chomp($n = <>);\n@a = split / /, <>;\n$L = 0;\n$L++ until $a[$L] > $a[$L+1];\nif($L == $#a){\n    print \"yes\\n1 1\\n\";\n}else {\n    #print \"current L = $L\\n\";\n    $R = $L++;\n    $R++ while $a[$R] > $a[$R+1] && $R < $#a;\n    if($R == $#a){\n        print \"yes\\n$L $n\\n\";\n    }else{\n        $p = $R++;\n        $p++ while $a[$p] < $a[$p+1] && $p < $#a;\n        print $p == $#a && $a[$R] > $a[$L-1] ? \"yes\\n$L $R\" : \"no\";\n    }\n}\n"}], "src_uid": "c9744e25f92bae784c3a4833c15d03f4"}
{"source_code": "<>;\nchomp($_=<>);\ns/ //g;\ns/./$&?($i++):($j++)/ge;\nprint ($j?($i>8?(\"5\"x($i-$i%9).\"0\"x$j):(\"0\")):(\"-1\"));", "positive_code": [{"source_code": "chomp($n=<>);\nforeach (split / /, <>) {\n\t$five++ if $_==5;\n}\n$zero = $n-$five;\nprint \"-1\\n\" and exit if $zero==0;\nprint \"0\\n\" and exit if $five<9;\nprint \"5\" x ($five-$five%9) . \"0\"x$zero . \"\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@c = (0) x 6;\n$c[$_]++ foreach (split / /, <>);\n$n5 = $c[5] - $c[5]%9;\n$c[0]==0 and say -1 and exit;\n$n5==0 and say 0 and exit;\nsay( ('5' x $n5) . ('0' x $c[0]) );"}, {"source_code": "<>;\nchomp($_=<>);\ns/ //g;\ns/./$&?($i++):($j++)/ge;\nprint ($j?($i>8?(\"5\"x($i-$i%9).\"0\"x$j):(\"0\")):(\"-1\"));"}, {"source_code": "my $n = <>;\nchomp $n;\nmy $d = my $f = <> =~ y/5//;\n$d-- while $d%9;\n$_ = '5' x $d . '0' x ($n-$f);\n$_ =~ s/^0+/0/;\nprint $f==$n? -1 : $_;"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@c = (0) x 6;\n$c[$_]++ foreach (split / /, <>);\n$n5 = $c[5] - $c[5]%9;\n$n5==0 and ($c[0]==0 and say -1 or say 0) and exit;\nsay( ('5' x $n5) . ('0' x $c[0]) );"}, {"source_code": "<>;\nchomp($_=<>);\ns/ //g;\ns/./$&?($i++):($j++)/ge;\nprint ($i>8 && $j?(\"5\"x($i-$i%9).\"0\"x$j):(-1));"}], "src_uid": "409b27044d5ec97b5315c92d4112376f"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\nwhile (/31|21|32/){\nwhile (/31/) {s/31/13/g};\nwhile (/21/) {s/21/12/g};\nwhile (/32/) {s/32/23/g};\n}\n\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\n# while (/31|21|32/){s/31|21|32/reverse $&/eg}\n\ns#\\d+#join\"\",(sort {$a <=> $b} (split//,$&))#eg;\n# print; n();\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\nwhile (/31|21|32/){\ns/31|21|32/reverse $&/eg;\n}\n\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\ns#\\d+#join\"\",(sort (split//,$&))#eg;\n# print; n();\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\nwhile (/31|21|32/){\ns/31/13/g;\ns/21/12/g;\ns/32/23/g;\n}\n\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\ns#\\d+#join\"\",(sort (split//,$&))#eg;\n# print; n();\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(1{$j})/(push @T,$1) and \"$1\"/ieg;\n# print; n();\n# print \"@T\\n\";\ns/1//g;\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(2{$j})/(push @P,$1) and \"$1\"/ieg;\n# print; n();\n# print \"@P\\n\";\ns/2//g;\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(3{$j})/(push @M,$1) and \"$1\"/ieg;\n# print; n();\n# print \"@M\\n\";\ns/3//g;\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ / /;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\ns#\\d+#join\"\",(sort (split//,$&))#eg;\n# print; n();\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(1{$j})/(push @T,$1) and \"$1\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(2{$j})/(push @P,$1) and \"$1\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(3{$j})/(push @M,$1) and \"$1\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=<>;\nchomp @_;\nshift @_;\n\ns/-//g for @_;\n\nfor (@_){\n\tif (/^\\d{6}$/){\n\t\t@n=split//;\n\t\t$f=shift @n;\n\t\t$nT=$nP=0;\n\t\tfor $i(@n){\n\t\t\t$f!=$i and $nT++;\n\t\t\t$i>=$f and $nP++;\n\t\t\t$f=$i;\n\t\t\t}\n\t\t$nT && $nP and $_=3;\n\t\t$nT && !$nP and $_=2;\n\t\t!$nT && $nP and $_=1; \n\t\t}\n\t\n\t}\n\t\n# print \"@_\\n\";\n\nfor (@_){\n\ts/^\\d+ //;\n\t}\n\n$_=join\"\",@_;\n# print; n();\n\n$j=0;\nfor $i(1..100){\n\t/1{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?1{$j})/(push @T,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@T\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/2{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?2{$j})/(push @P,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@P\\n\";\n\n$j=0;\nfor $i(1..100){\n\t/3{$i}/ and $j++;\n\t}\ns/([a-z]+)(\\d*?3{$j})/(push @M,$1) and \"$1\".\"$2\"/ieg;\n# print; n();\n# print \"@M\\n\";\n\nprint \"If you want to call a taxi, you should call: \",(join\", \",@T),\".\\n\";\nprint \"If you want to order a pizza, you should call: \",(join\", \",@P),\".\\n\";\nprint \"If you want to go to a cafe with a wonderful girl, you should call: \",(join\", \",@M),\".\\n\";\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "4791a795119c185b3aec91b6f8af8f03"}
{"source_code": "chomp($_=<>);\n($n,$m)=split/ /;\n\n$n or print \"0 1\\n0 $m\\n0 0\\n0 \".($m-1);\n$m+0 or print \"1 0\\n$n 0\\n0 0\\n\".($n-1).\" 0\";\n\n$n && $m or exit;\n\npush @a, \n\tsqrt(($n-1)**2+$m**2)*2,\n\tsqrt($n**2+($m-1)**2)*2,\n\tsqrt($n**2+$m**2)+$m,\n\tsqrt($n**2+$m**2)+$n;\n\npush @b, \n\t($n-1).\" $m\\n0 0\\n$n $m\\n1 0\",\n\t\"$n \".($m-1).\"\\n0 0\\n$n $m\\n0 1\",\n\t\"$n $m\\n0 0\\n0 $m\\n$n 0\",\n\t\"$n $m\\n0 0\\n$n 0\\n0 $m\";\n\t\n$i++,$max<$_ and ($max=$_,$j=$i) for @a;\n\nprint $b[--$j]", "positive_code": [{"source_code": "while(<>){\n\tchomp;\n\t($n,$m)=split/ /;\n\t\n\t$n or print \"0 1\\n\".\"0 $m\\n\".\"0 0\\n\".\"0 \".($m-1);\n\t$m or print \"1 0\\n\".\"$n 0\\n\".\"0 0\\n\".($n-1).\" 0\";\n\t\n\t$n or next;\n\t$m or next;\n\t\n#\t$n==1 and $m==1 and print \"1 1\\n0 0\\n1 0\\n0 1\";\n#\t$n==1 and $m>1 and print \"$n $m\\n0 0\\n0 $m\\n$n 0\";\n#\t$n>1 and $m==1 and print \"$n $m\\n0 0\\n$n 0\\n0 $m\";\n\t\n\t@a=();\n\tpush @a, sqrt(($n-1)**2+$m**2)*2;\n\tpush @a, sqrt($n**2+($m-1)**2)*2;\n\tpush @a, sqrt($n**2+$m**2)+$m;\n\tpush @a, sqrt($n**2+$m**2)+$n;\n\t\n\t@b=();\n\tpush @b, (($n-1).\" $m\\n\".\"0 0\\n\".\"$n $m\\n\".\"1 0\");\n\tpush @b, (\"$n \".($m-1).\"\\n0 0\\n\".\"$n $m\\n\".\"0 1\");\n\tpush @b, \"$n $m\\n0 0\\n0 $m\\n$n 0\";\n\tpush @b, \"$n $m\\n0 0\\n$n 0\\n0 $m\";\n\t\n\t$max=0;\n\t$max<$_ and $max=$_ for @a;\n\t\n\tfor $i(0..3){\n\t\tif ($max==$a[$i]){\n\t\t\t$j=$i;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t\n\tprint $b[$j];\n\t\n#\t$n>=$m and $n>1 and $m>1 and print (\"$n \".($m-1).\"\\n0 0\\n\".\"$n $m\\n\".\"0 1\");\n#\t$n<$m  and $n>1 and $m>1 and print (($n-1).\" $m\\n\".\"0 0\\n\".\"$n $m\\n\".\"1 0\");\n\n\tprint \"\\n\"\n\t}"}], "negative_code": [{"source_code": "while(<>){\n\tchomp;\n\t($n,$m)=split/ /;\n\t\n\t$n or print \"0 1\\n\".\"0 $m\\n\".\"0 0\\n\".\"0 \".($m-1);\n\t$m or print \"1 0\\n\".\"$n 0\\n\".\"0 0\\n\".($n-1).\" 0\";\n\t$n and $m and print \"$n $m\\n\".\"0 0\\n\".\"$n 0\\n\".\"0 $m\";\n\t\n\tprint \"\\n\"\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$m)=split/ /;\n\t\n\t$n or print \"0 1\\n\".\"0 $m\\n\".\"0 0\\n\".\"0 \".($m-1);\n\t$m or print \"1 0\\n\".\"$n 0\\n\".\"0 0\\n\".($n-1).\" 0\";\n\t$n>=$m and $n and $m and print \"$n $m\\n\".\"0 0\\n\".\"$n \".($m-1).\"\\n0 \".($m==2? 2:1);\n\t$n<$m  and $n and $m and print \"$n $m\\n\".\"0 0\\n\".($n-1).\" $m\\n\".($n==2? 2:1).\" 0\";\n\n\tprint \"\\n\"\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$m)=split/ /;\n\t\n\t$n or print \"0 1\\n\".\"0 $m\\n\".\"0 0\\n\".\"0 \".($m-1);\n\t$m or print \"1 0\\n\".\"$n 0\\n\".\"0 0\\n\".($n-1).\" 0\";\n\t$n>=$m and $n and $m and print \"$n $m\\n\".\"0 0\\n\".\"$n 0\\n\".\"0 $m\";\n\t$n<$m  and $n and $m and print \"$n $m\\n\".\"0 0\\n\".\"0 $m\\n\".\"$n 0\";\n\n\tprint \"\\n\"\n\t}"}], "src_uid": "78d54d76cb113cf74ea89fb77471859b"}
{"source_code": "while(<>){\n\t\n\t($a,$b)=split/ /;\n\tif ($a>$b){$tmp=$a; $a=$b; $b=$tmp}\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=($x*$b)/$a;\n\t\t$z=($y*$b)/$a;\n\t\t\n\t\t$v =~/\\./ and next;\n\t\t$ok++ or last;\n\t\t}\n\t\n\n\t\t\n\tif (!$ok){print \"NO\\n\"; next}\n\telse {\n\t\t\n\t\tif ($y==$v){$tmp=$x; $x=$y; $y=$tmp; $tmp=$v; $v=$z; $z=$tmp}\n\t\t\n\t\tprint \"YES\\n\";\n\t\tprint (\"0 0\\n\");\n\t\tprint (-$x,\" \",$y,\"\\n\");\n\t\tprint ($z,\" \",$v,\"\\n\");\n\t\t\n\t\t}\n\t\n\t}", "positive_code": [{"source_code": "\nwhile(<>){\n\t\n\t($a,$b)=split/ /;\n\tif ($a>$b){$tmp=$a; $a=$b; $b=$tmp}\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=($x*$b)/$a;\n\t\t$z=($y*$b)/$a;\n\t\t\n\t\t$v =~/\\./ and next;\n\t\t$ok++ or last;\n\t\t}\n\t\n\n\t\t\n\tif (!$ok){print \"NO\\n\"; next}\n\telse {\n\t\t\n\t\tif ($y==$v){$tmp=$x; $x=$y; $y=$tmp; $tmp=$v; $v=$z; $z=$tmp}\n\t\t\n\t\tprint \"YES\\n\";\n\t\tprint (\"0 0\\n\");\n\t\tprint (-$x,\" \",$y,\"\\n\");\n\t\tprint ($z,\" \",$v,\"\\n\");\n\t\t\n\t\t}\n\t\n\t}\n\t\n"}, {"source_code": "\nwhile(<>){\n\t\n\t($a,$b)=split/ /;\n\t$t=$a, $a=$b, $b=$t if $a>$b;\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ && next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=$x*$b/$a;\n\t\t$z=$y*$b/$a;\n\t\t\n\t\t$v =~/\\./ && next;\n\t\t$ok++ or last;\n\t\t}\n\t\n\t$t=$x, $x=$y, $y=$t, $t=$v, $v=$z, $z=$t if $y==$v;\n\tprint $ok ? (\"YES\\n0 0\\n\",-$x,\" $y\\n$z $v\") : NO\n\t\n\t}\n\t\n"}], "negative_code": [{"source_code": "\nwhile(<>){\n\t\n\t($a,$b)=split/ /;\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=($x*$b)/$a;\n\t\t$z=($y*$b)/$a;\n\t\t$v =~/\\./ and last;\n\t\t$ok++\n\t\t}\n\t\n\n\t\t\n\tif (!$ok){print \"NO\\n\"; next}\n\telse {\n\t\t\n\t\tif ($x==$v){$tmp=$v; $v=$z; $z=$tmp}\n\t\tif ($y==$z){$tmp=$v; $v=$z; $z=$tmp}\n\t\t\n\t\tprint \"YES\\n\";\n\t\tprint (\"0 0\\n\");\n\t\tprint (-$x,\" \",$y,\"\\n\");\n\t\tprint ($v,\" \",$z,\"\\n\");\n\t\t\n\t\t}\n\t\n\t}\n\t\n"}, {"source_code": "\t($a,$b)=split/ /;\n\t$t=$a, $a=$b, $b=$t if $a>$b;\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ && next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=$x*$b/$a;\n\t\t$z=$y*$b/$a;\n\t\t\n\t\t$v =~/\\./ && next;\n\t\t$ok++ or last;\n\t\t}\n\t\n\t$t=$x, $x=$y, $y=$t, $t=$v, $v=$z, $z=$t if $y==$v;\n\tprint $ok ? (\"YES\\n0 0\\n\",-$x,\" $y\\n$z $v\") : NO"}, {"source_code": "\t($a,$b)=split/ /;\n\t$t=$a, $a=$b, $b=$t if $a>$b;\n\t\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ && next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=$x*$b/$a;\n\t\t$z=$y*$b/$a;\n\t\t\n\t\t$v =~/\\./ && next;\n\t\t$ok++ or last\n\t\t}\n\t\n\tif ($y==$v){$t=$x; $x=$y; $y=$t; $t=$v; $v=$z; $z=$t}\n\tprint $ok ? (\"YES\\n0 0\\n\",-$x,\" $y\\n$z $v\") : NO\n\n\t\n"}, {"source_code": "\nwhile(<>){\n\t\n\t($a,$b)=split/ /;\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=($x*$b)/$a;\n\t\t$v =~/\\./ and last;\n\t\t$ok++\n\t\t}\n\t\n\n\t\t\n\tif (!$ok){print \"NO\\n\"; next}\n\telse {\n\t\t\n\t\tprint \"YES\\n\";\n\t\tprint (\"0 0\\n\");\n\t\tprint (-$x,\" \",$y,\"\\n\");\n\t\tprint (($y*$b)/$a,\" \",$v,\"\\n\");\n\t\t\n\t\t}\n\t\n\t}\n\t\n"}, {"source_code": "\nwhile(<>){\n\t\n\t($a,$b)=split/ /;\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$ok++;\n\t\t$x= $i; $y = $ab;\n\t\t}\n\t\n\tfor $i(1..$b-1){\n\t\t$ab = sqrt($b**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$ok++;\n\t\t$v= $i; $z = $ab;\n\t\t}\n\t\t\n\tif ($ok<2){print \"NO\\n\"; next}\n\telse {\n\t\t\n\t\tif ($x==$v){$tmp=$v; $v=$z; $z=$tmp}\n\t\tif ($y==$z){$tmp=$v; $v=$z; $z=$tmp}\n\t\t\n\t\tprint \"YES\\n\";\n\t\tprint (\"0 0\\n\");\n\t\tprint (-$x,\" \",$y,\"\\n\");\n\t\tprint ($v,\" \",$z,\"\\n\");\n\t\t\n\t\t}\n\t\n\t}\n\t\n"}, {"source_code": "\nwhile(<>){\n\t\n\t($a,$b)=split/ /;\n\t\n\t$ok=0;\n\tfor $i(1..$a-1){\n\t\t$ab = sqrt($a**2 - $i**2);\n\t\t$ab =~/\\./ and next;\n\t\t$x= $i; $y = $ab;\n\t\t\n\t\t$v=($x*$b)/$a;\n\t\t$z=($y*$b)/$a;\n\t\t$v =~/\\./ and last;\n\t\t$ok++\n\t\t}\n\t\n\n\t\t\n\tif (!$ok){print \"NO\\n\"; next}\n\telse {\n\t\t\n\t\tif ($y==$v){$tmp=$x; $x=$y; $y=$tmp; $tmp=$v; $v=$z; $z=$tmp}\n\t\t\n\t\tprint \"YES\\n\";\n\t\tprint (\"0 0\\n\");\n\t\tprint (-$x,\" \",$y,\"\\n\");\n\t\tprint ($z,\" \",$v,\"\\n\");\n\t\t\n\t\t}\n\t\n\t}\n\t\n"}], "src_uid": "a949ccae523731f601108d4fa919c112"}
{"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n", "positive_code": [{"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}\n"}, {"source_code": "<>;\nwhile(<>){\n\t$j=++$i%2;\n\ts/./$j++,$&eq\".\"?($j%2?W:B):$&/ge;\n\tprint\n\t}"}], "negative_code": [], "src_uid": "dc31adef80f06897ea2f5ef76854bcf1"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$ats=0; $i=1;\n<>;\nwhile(<>){\n\tchomp;\n\t($a,$b)=split/ /;\n\t$b or push @_,$a;\n\t$b and ($ats+=$a,$i+=$b-1);\n\t}\n@_=sort num @_;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$ats=0; $i=1;\n<>;\nwhile(<>=~/ /){\n\t$'+0 or push @_,$`;\n\t$'+0 and ($ats+=$`,$i+=$'-1);\n\t}\n@_=sort num @_;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$ats=0; $i=1;\n<>;\nwhile(<>){\n\tchomp;\n\t($a,$b)=split/ /;\n\t$b? ($ats+=$a,$i+=$b-1):(push @_,$a);\n\t}\n@_=sort {$a <=> $b} @_;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$ats=0; $i=1;\n<>;\nwhile(<>){\n\tchomp;\n\t($a,$b)=split/ /;\n\t$b? ($ats+=$a,$i+=$b-1):(push @_,$a);\n\t}\n@_=sort num @_;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$ats=0; $i=1;\n<>;\nwhile(<>=~/ /){\n\t$'+0 or push @_,$`;\n\t$'+0 and ($ats+=$`,$i+=$');\n\t}\n@_=sort num @_;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$ats=0; \n<>;\nwhile(<>=~/ /){\n\t$'+0 or push @_,$`;\n\t$'+0 and ($ats+=$`,$i+=$');\n\t}\n@_=sort num @_;\n$i or $i++;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>;\nwhile(<>=~/ /){\n\t$'+0 or push @_,$`;\n\t$'+0 and ($ats+=$`,$i+=$');\n\t}\n@_=sort num @_;\nwhile ($i--){$ats+=pop@_}\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "4abdd16670a796be3a0bff63b9798fed"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\tmy $i = 0;\n\tmy @ans;\n\t\n\tfor( @_ ){\n\t\tif( exists $h{ $_ } ){\n\t\t\tif( $h{ $_ }[ 0 ] ){\n\t\t\t\t$h{ $_ }[ 0 ] --;\n\t\t\t\tpush @ans, $h{ $_ }[ 1 ];\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$h{ $_ } = [ @_ - $_, ++ $i ];\n\t\t\t\tredo;\n\t\t\t\t}\n\t\t\t}\n\t\telse{\n\t\t\t$h{ $_ } = [ @_ - $_, ++ $i ];\n\t\t\tredo;\n\t\t\t}\n\t\t}\n\t\n\tmy %c;\n\t\n\tfor( @ans ){\n\t\t$c{ $_ } ++;\n\t\t}\n\t\n\tmy $fail = 0;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\t$fail ++ if $_[ $i ] != @_ - $c{ $ans[ $i ] };\n\t\t}\n\t\n\tprint $fail ? \"Impossible\" : \"Possible\\n@ans\";\n\t}", "positive_code": [{"source_code": "<>;\n\n@_ = split ' ', <>;\n\nfor( @_ ){\n\tif( $h{ $_ }[ 0 ] ){\n\t\t$h{ $_ }[ 0 ] --;\n\t\tpush @A, $h{ $_ }[ 1 ];\n\t\t}\n\telse{\n\t\t$h{ $_ } = [ @_ - $_, ++ $i ];\n\t\tredo;\n\t\t}\n\t}\n\n$c{ $_ } ++ for @A;\n\nfor $i ( 0 .. @_ - 1 ){\n\t$F += $_[ $i ] != @_ - $c{ $A[ $i ] };\n\t}\n\nprint $F ? \"Impossible\" : \"Possible\\n@A\""}], "negative_code": [], "src_uid": "f49667ef00cd0da6a6fad67a19d92f1e"}
{"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n", "positive_code": [{"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\n($ans, $i) = (0) x 2;\n++$i while ($i<$n && $a[$i]==0);\n$i>=$n and say 0 and exit;\n$ans = 1;\nwhile ($i < $n) {\n\t$j = $i++;\n\t++$i while ($i<$n && $a[$i]==0);\n\t$i>=$n and last;\n\t$i-$j==1 and ++$ans or $ans+=2;\n}\nsay $ans;"}, {"source_code": "chomp($n=<>);\nchomp($_=<>);\n@a = split / /;\nforeach (@a) {\n\tif ($_) {\n\t\t++$ans && !$flag && ++$ans;\n\t\t$flag = 1;\n\t} else {\n\t\t$flag = 0;\n\t}\n}\nprint \"0\\n\" if !$ans;\nprint $ans-1,\"\\n\" if $ans;"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\n\nmy @mail = split / /, <>;\n\nmy $ans = 0;\nmy $reading = 0;\nfor $i (@mail) {\n\tif (($i == 1) || ($reading)) {\n\t\t$ans++;\n\t}\n\t$reading = $i;\n};\n\nif (($mail[-1] == 0) && ($ans > 0)) {\n\t$ans--;\n};\n\nprint $ans;\n"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}, {"source_code": "$_=0*<>.<>;\ns/ //g;\ns/01/11/g;\ns/0//g;\nprint /1/?(-2+length):0"}, {"source_code": "$_=0*<>.<>;\ns/0 ?1/1 1/g && s/1//;\nprint 0+(()=/1/g)"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>"}, {"source_code": "<>;\n$_=<>;\ns/ //g;\ns/(?<=1)0+(?=1)/1/g;\ns/0//g;\nprint -1+ length"}, {"source_code": "<>;\n$_=<>;\ns/\\s//g;\ns/0+/0/g;\ns/^0|0$//g;\nprint length"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}, {"source_code": "<>; print 0+(@_=/1|(?<=1) 0.+?(?=1)/g) for <>\n"}], "negative_code": [{"source_code": "<>;\n$_=<>;\ns/ //g;\ns/0+/0/g;\ns/^0|0$//g;\nprint length"}, {"source_code": "<>;\n$_=<>;\ns/1 0/1 1/g;\ns/[0 ]//g;\nprint -1+ length"}, {"source_code": "<>;\n$_=<>;\ns/1 0/1 1/g && s/1//;\ns/[0 ]//g;\nprint -1+ length"}], "src_uid": "0fbc306d919d7ffc3cb02239cb9c2ab0"}
{"source_code": "while(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy( %h, %g, %i, $i, @A, $A );\n\t\n\tfor ( 0 .. 1 ){\n\t\t$i = -1;\n\t\tmap { $h{ $_ }{ $_[ ++ $i ] } ++ } split ' ', <>;\n\t\t}\n\t\n\t<>;\n\t\n\tfor my $C ( 1 .. 3 ){\n\t\t@{ $g{ $C } } = sort { $a <=> $b } keys %{ $h{ $C } };\n\t\t\n\t\t$i{ $C }{ $_ } = 0 for 1 .. 3;\n\t\t}\n\t\n\tfor my $C ( split ' ', <> ){\n\t\t\n\t\t$i = \\$i{ $C }{ $C };\n\t\t\n\t\twhile( \n\t\t\t$g{ $C }[ $$i ] =~ / / ){\n\t\t\t$$i ++;\n\t\t\t}\n\t\t\n\t\tpush @A, do { \n\t\t\tif( $A = $g{ $C }[ $$i ] ){\n\t\t\t\t$g{ $C }[ $$i ++ ] .= ' ';\n\t\t\t\t\n\t\t\t\tfor ( 1 .. 3 ){\n\t\t\t\t\tnext if /$C/;\n\t\t\t\t\t\n\t\t\t\t\t$i = \\$i{ $C }{ $_ };\n\t\t\t\t\t\n\t\t\t\t\twhile( $g{ $_ }[ $$i ] and \n\t\t\t\t\t\t$g{ $_ }[ $$i ] < $A ){\n\t\t\t\t\t\t$$i ++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif( \n\t\t\t\t\t\t$g{ $_ }[ $$i ] == $A ){\n\t\t\t\t\t\t$g{ $_ }[ $$i ++ ] .= ' ';\n\t\t\t\t\t\tlast;\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$A;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\t-1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint \"@A\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\tmy $i;\n\t\n\tfor ( 0 .. 1 ){\n\t\t$i = -1;\n\t\tmap { $i ++; $h{ $_ }{ $_[ $i ] } ++ } split ' ', <>;\n\t\t}\n\t\n\t<>;\n\t\n\tmy %g;\n\tmy %i;\n\t\n\tfor my $color ( 1 .. 3 ){\n\t\t@{ $g{ $color } } = sort { $a <=> $b } keys %{ $h{ $color } };\n\t\t$debug and print \"@{ $g{ $color } }\";\n\t\tfor my $clr ( 1 .. 3 ){\n\t\t\t$i{ $color }{ $clr } = 0;\n\t\t\t}\n\t\t}\n\t\n\tmy @ans;\n\tmy $ans;\n\t\n\tfor my $color ( split ' ', <> ){\n\t\t\n\t\twhile( $g{ $color }->[ $i{ $color }{ $color } ] and \n\t\t\t$g{ $color }->[ $i{ $color }{ $color } ] =~ / / ){\n\t\t\t$i{ $color }{ $color } ++;\n\t\t\t}\n\t\t\n\t\tif( $g{ $color }->[ $i{ $color }{ $color } ] ){\n\t\t\tpush @ans, $ans = $g{ $color }->[ $i{ $color }{ $color } ];\n\t\t\t$g{ $color }->[ $i{ $color }{ $color } ] .= ' ';\n\t\t\t$i{ $color }{ $color } ++;\n\t\t\t\n\t\t\tfor my $clr ( 1 .. 3 ){\n\t\t\t\tnext if $clr == $color;\n\t\t\t\t\n\t\t\t\twhile( $g{ $clr }->[ $i{ $color }{ $clr } ] and \n\t\t\t\t\t$g{ $clr }->[ $i{ $color }{ $clr } ] < $ans ){\n\t\t\t\t\t$i{ $color }{ $clr } ++;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif( $g{ $clr }->[ $i{ $color }{ $clr } ] and \n\t\t\t\t\t$g{ $clr }->[ $i{ $color }{ $clr } ] == $ans ){\n\t\t\t\t\t$g{ $clr }->[ $i{ $color }{ $clr } ] .= ' ';\n\t\t\t\t\t$i{ $color }{ $clr } ++;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\telse {\n\t\t\tpush @ans, -1;\n\t\t\t}\n\t\t\n\t\t}\n\t\n\tprint \"@ans\";\n\t}"}], "negative_code": [{"source_code": "while(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy( %h, %g, %i, $i, @A, $A );\n\t\n\tfor ( 0 .. 1 ){\n\t\t$i = -1;\n\t\tmap { $h{ $_ }{ $_[ $i ++ ] } ++ } split ' ', <>;\n\t\t}\n\t\n\t<>;\n\t\n\tfor my $C ( 1 .. 3 ){\n\t\t@{ $g{ $C } } = sort { $a <=> $b } keys %{ $h{ $C } };\n\t\t\n\t\t$i{ $C }{ $_ } = 0 for 1 .. 3;\n\t\t}\n\t\n\tfor my $C ( split ' ', <> ){\n\t\t\n\t\t$i = \\$i{ $C }{ $C };\n\t\t\n\t\twhile( \n\t\t\t$g{ $C }[ $$i ] =~ / / ){\n\t\t\t$$i ++;\n\t\t\t}\n\t\t\n\t\tpush @A, do { \n\t\t\tif( $A = $g{ $C }[ $$i ] ){\n\t\t\t\t$g{ $C }[ $$i ++ ] .= ' ';\n\t\t\t\t\n\t\t\t\tfor ( 1 .. 3 ){\n\t\t\t\t\tnext if /$C/;\n\t\t\t\t\t\n\t\t\t\t\t$i = \\$i{ $C }{ $_ };\n\t\t\t\t\t\n\t\t\t\t\twhile( $g{ $_ }[ $$i ] and \n\t\t\t\t\t\t$g{ $_ }[ $$i ] < $A ){\n\t\t\t\t\t\t$$i ++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif( \n\t\t\t\t\t\t$g{ $_ }[ $$i ] == $A ){\n\t\t\t\t\t\t$g{ $_ }[ $$i ++ ] .= ' ';\n\t\t\t\t\t\tlast;\n\t\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$A;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\t-1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint \"@A\";\n\t}"}], "src_uid": "d5ead5b6be04cd9389a70e9e420039a6"}
{"source_code": "#!perl\nuse v5.20;\nuse strict;\nuse warnings;\nuse Class::Struct;\nstruct (\n  Interval => [\n    length => '$',\n    cntShip => '$',\n    endPos => '$'\n  ]\n);\nwhile (<>) {\n  my ($n, $aa, $bb, $k) = split ' ';\n  my ($s, @str);\n  chomp($s = <>);\n  @str = split '', $s;\n  my ($cnt, $i, @room);\n  $cnt = 0;\n  for $i ( 0..$#str ) {\n    if (!$str[$i]) {\n      ++$cnt;\n    }\n    else {\n      if ($cnt) {\n        push @room, Interval->new(\n          length => $cnt,\n          cntShip => int($cnt/$bb),\n          endPos => $i-1\n          );\n      }\n      $cnt = 0;\n    }\n  }\n  if ($cnt) {\n      push @room, Interval->new(\n        length => $cnt,\n        cntShip => int($cnt/$bb),\n        endPos => $#str\n        );\n  }\n  @room = sort { $a->length <=> $b->length } @room;\n\n  #for $i ( 0..$#room ) {\n  #  say '(', $room[$i]->length,\n  #  ' ', $room[$i]->cntShip,\n  #  ' ', $room[$i]->endPos, ')';\n  #}\n\n  my ($result, @postSum, $sum);\n  $sum = 0;\n  for ($i = $#room; $i >= 0; --$i) {\n    $sum += $room[$i]->cntShip;\n    $postSum[$i] = $sum;\n  }\n  my (@positions);\n  for $i ( 0..$#room ) {\n    if ($i != $#room && $postSum[$i+1] >= $aa) {\n    #// remaining is enough.\n      my $start = $room[$i]->endPos - ($room[$i]->length - 1);\n      my $pos = $room[$i]->endPos;\n      while ($pos >= $start + $bb - 1) {\n      #say \"start= \", $start, \" pos= \", $pos;\n        $pos -= ($bb - 1);\n        push @positions, $pos+1;\n        $pos--;\n      }\n    }\n    elsif ($i != $#room && $postSum[$i+1] < $aa) {\n    #// remaining is not enough, current interval is the last.\n      my $remaining = $aa - $postSum[$i+1];\n      my $cnt = $room[$i]->cntShip - $remaining + 1;\n      my $pos = $room[$i]->endPos;\n      while ($cnt--) {\n        $pos -= ($bb - 1);\n        push @positions, $pos+1;\n        $pos--;\n      }\n      last;\n    }\n    else {\n      my $cnt = $room[$i]->cntShip - $aa + 1;\n      my $pos = $room[$i]->endPos;\n      while ($cnt--) {\n        $pos -= ($bb - 1);\n        push @positions, $pos+1;\n        $pos--;\n      }\n    }\n  }\n  say scalar @positions;\n  say join ' ', @positions;\n}\n", "positive_code": [{"source_code": "#!perl\nuse strict;\nuse warnings;\nuse v5.18;\nwhile (<>) {\n\tmy ($n, $a, $b, $k) = split;\n\tmy $s = <>; chomp $s;\n\t$s = '1' . $s . '1';\n\tmy @str = split '', $s;\n\tmy @positions;\n\tmy $q;\n\tfor ( my $i = 0; $i < $#str; $i = $q ) {\n\t\tmy $j = $i;\n\t\twhile ($j < $#str && 1 == $str[$j]) { $j++; }\n\t\t$q = $j;\n\t\twhile ($q < $#str && 0 == $str[$q]) { $q++; }\n\t\tfor (my $pos = $j - 1 + $b; $pos < $q; $pos += $b) {\n\t\t\tif ($a == 1) { push @positions, $pos }\n\t\t\telse { $a--; }\n\t\t}\n\t}\n\tsay scalar @positions;\n\tsay join ' ', @positions;\n}\n"}], "negative_code": [{"source_code": "#!perl\nuse v5.20;\nuse strict;\nuse warnings;\nuse Class::Struct;\nstruct (\n  Interval => [\n    length => '$',\n    cntShip => '$',\n    endPos => '$'\n  ]\n);\nwhile (<>) {\n  my ($n, $aa, $bb, $k) = split ' ';\n  my ($s, @str);\n  chomp($s = <>);\n  @str = split '', $s;\n  my ($cnt, $i, @room);\n  $cnt = 0;\n  for $i ( 0..$#str ) {\n    if (!$str[$i]) {\n      ++$cnt;\n    }\n    else {\n      if ($cnt) {\n        push @room, Interval->new(\n          length => $cnt,\n          cntShip => int($cnt/$bb),\n          endPos => $i-1\n          );\n      }\n      $cnt = 0;\n    }\n  }\n  if ($cnt) {\n      push @room, Interval->new(\n        length => $cnt,\n        cntShip => int($cnt/$bb),\n        endPos => $#str\n        );\n  }\n  @room = sort { $a->length <=> $b->length } @room;\n\n  #for $i ( 0..$#room ) {\n  #  say '(', $room[$i]->length,\n  #  ' ', $room[$i]->cntShip,\n  #  ' ', $room[$i]->endPos, ')';\n  #}\n\n  my ($result, @postSum, $sum);\n  $sum = 0;\n  for ($i = $#room; $i >= 0; --$i) {\n    $sum += $room[$i]->cntShip;\n    $postSum[$i] = $sum;\n  }\n  my (@positions);\n  for $i ( 0..$#room ) {\n    if ($i != $#room && $postSum[$i+1] >= $aa) {\n    #// remaining is enough.\n      my $start = $room[$i]->endPos - ($room[$i]->length - 1);\n      my $pos = $room[$i]->endPos;\n      while ($pos >= $start + $bb - 1) {\n      #say \"start= \", $start, \" pos= \", $pos;\n        $pos -= ($bb - 1);\n        push @positions, $pos+1;\n        $pos--;\n      }\n    }\n    elsif ($i != $#room && $postSum[$i+1] < $aa) {\n    #// remaining is not enough, current interval is the last.\n      my $remaining = $aa - $postSum[$i+1];\n      my $cnt = $room[$i]->cntShip - $remaining + 1;\n      my $pos = $room[$i]->endPos;\n      while ($cnt--) {\n        $pos -= ($bb - 1);\n        push @positions, $pos+1;\n      }\n      last;\n    }\n    else {\n      my $cnt = $room[$i]->cntShip - $aa + 1;\n      my $pos = $room[$i]->endPos;\n      while ($cnt--) {\n        $pos -= ($bb - 1);\n        push @positions, $pos+1;\n      }\n    }\n  }\n  say scalar @positions;\n  say join ' ', @positions;\n}\n"}], "src_uid": "d50bb59298e109b4ac5f808d24fef5a1"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m, $ok ) = ( split, 0 );\n\t\n\tchomp( @_ = map ~~<>, 1 .. $n );\n\t\n\tpaint( \\@_ );\n\t\n\trotate( \\@_ );\n\n\tpaint( \\@_ );\n\t\n\t$ok ||= /T\\.*S/i || /S\\.*T/i for @_;\n\t\n\trotate( \\@_ );\n\n\t$ok ||= /T\\.*S/i || /S\\.*T/i for @_;\n\t\n\tprint $ok ? \"YES\" : \"NO\";\n\t}\n\nsub paint {\n\t\n\tfor( @{ shift() } ){\n\t\t/S/ && s/\\.*(?=S)/ 's' x length $& /e,\n\t\t/S/ && s/S\\K\\.*/ 's' x length $& /e,\n\t\t/T/ && s/\\.*(?=T)/ 't' x length $& /e,\n\t\t/T/ && s/T\\K\\.*/ 't' x length $& /e,\n\t\t}\n\t\n\t}\n\t\nsub rotate {\n\t$_ = shift;\n\tmy @tmp;\n\t\n\tfor my $i ( 1 .. length $_->[0] ){\n\t\t$tmp[ $i - 1 ] .= chop for @$_;\n\t\t}\n\t\n\t@$_ = @tmp;\n\t}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\tmy $ok = 0;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\tchomp @_;\n\t\n\tfor( @_ ){\n\t\t/S/ && s/\\.*(?=S)/ 's' x length $& /e,\n\t\t/S/ && s/S\\K\\.*/ 's' x length $& /e,\n\t\t/T/ && s/\\.*(?=T)/ 't' x length $& /e,\n\t\t/T/ && s/T\\K\\.*/ 't' x length $& /e,\n\t}\n\t\n\t@_ = rot( $n, $m, @_ );\n\n\tfor( @_ ){\n\t\t/S/ && s/\\.*(?=S)/ 's' x length $& /e,\n\t\t/S/ && s/S\\K\\.*/ 's' x length $& /e,\n\t\t/T/ && s/\\.*(?=T)/ 't' x length $& /e,\n\t\t/T/ && s/T\\K\\.*/ 't' x length $& /e,\n\t}\n\t\n\tfor( @_ ){\n\t\t$ok += /T\\.*S/i + /S\\.*T/i;\n\t\t}\n\t\n\t@_ = rot( $n, $m, @_ );\n\n\tfor( @_ ){\n\t\t$ok += /T\\.*S/i + /S\\.*T/i;\n\t\t}\n\t\n\tprint $ok ? \"YES\" : \"NO\";\n\t}\n\nsub rot {\n\tmy( $n, $m, @A ) = ( shift, shift );\n\t\n\tfor my $i ( 0 .. $m - 1 ){\n\t\t$A[ $i ] .= chop for @_;\n\t\t}\n\t\n\t@A;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m, $ok ) = ( split, 0 );\n\t\n\tchomp( @_ = map ~~<>, 1 .. $n );\n\t\n\tpaint( \\@_ );\n\t\n\trotate( \\@_ );\n\n\tpaint( \\@_ );\n\t\n\t$ok ||= /T\\.*S/i || /S\\.*T/i for @_;\n\t\n\trotate( \\@_ );\n\n\t$ok ||= /T\\.*S/i || /S\\.*T/i for @_;\n\t\n\tprint $ok ? \"YES\" : \"NO\";\n\t}\n\nsub paint {\n\t\n\tfor( @{ shift() } ){\n\t\t/S/ && s/\\.*(?=S)|(?<=S)\\.*/ 's' x length $& /eg,\n\t\t/T/ && s/\\.*(?=T)|(?<=T)\\.*/ 't' x length $& /eg,\n\t\t}\n\t\n\t}\n\t\nsub rotate {\n\t$_ = shift;\n\tmy @tmp;\n\t\n\tfor my $i ( 1 .. length $_->[0] ){\n\t\t$tmp[ $i - 1 ] .= chop for @$_;\n\t\t}\n\t\n\t@$_ = @tmp;\n\t}\n"}], "negative_code": [], "src_uid": "16a1c5dbe8549313bae6bca630047502"}
{"source_code": "<>;\n\nprint sort { $a . $b cmp $b . $a } map s/\\n//r, <>\n", "positive_code": [{"source_code": "<>;\n\nprint sort {\n\t\t($A, $B) = ($a, $b);\n\t\t$max = length $A > length $B ? $A : $B;\n\t\tmap { $_ x= 50; substr $_, 0, $max } $A, $B;\n\t\t$A cmp $B\n\t} map s/\\n//r, <>;"}, {"source_code": "<>;\n\nprint sort { $a . $b cmp $b . $a } map s/\\n//r, <>"}], "negative_code": [{"source_code": "<>;\n\nprint join '+', sort {\n\t\t($A, $B) = ($a, $b);\n\t\t$max = length $A > length $B ? $A : $B;\n\t\tmap { $_ x= 50; substr $_, 0, $max } $A, $B;\n\t\t$A cmp $B\n\t} map s/\\n//r, <>;"}, {"source_code": "<>;\n\n%h = map { chomp; $_ => 1 } @_ = <>;\n\nfor (sort map $_ .= (chop) x (52 - length), @_){\n\tfor $i (reverse 1 .. 50){\n\t\t$s = substr $_, 0, $i;\n\t\t$h{ $s } and do { $_ = $s ; delete $h{ $s }; last }\n\t\t}\n\tprint\n\t}"}, {"source_code": "<>;\n\nprint map y/~//dr, sort map s/\\n//r . '~', <>;"}, {"source_code": "<>;\n\n%h = map { chomp; $_ => 1 } @_ = <>;\n\nfor (sort map { $_ x= 50; $_ = substr $_, 0, 50 } @_){\n\tfor $i (reverse 1 .. 50){\n\t\t$s = substr $_, 0, $i;\n\t\t$h{ $s } and do { $_ = $s ; delete $h{ $s }; last }\n\t\t}\n\tprint\n\t}"}], "src_uid": "930365b084022708eb871f3ca2f269e4"}
{"source_code": "$\\ = $/, <>;\n\nm!\\b(?:/.*)?$!, ++ $h{ $` }{ $& } for <>;\n\npush @{ $g{ join ' ', sort keys %{ $h{ $_ } }  } }, $_ for keys %h;\n@ans = grep / /, map { join ' ', @{ $g{ $_ } }  } keys %g;\n\nmap { print } ~~ @ans, @ans", "positive_code": [{"source_code": "$_ = <>, chomp, m!http://[\\w.]+!, undef $h{ $& }{ $' } for 1 .. <>;\n\npush @{ $g{ join ' ', sort keys %{ $h{ $_ } }  } }, $_ for keys %h;\npush @ans, grep / /, join ' ', @{ $g{ $_ } } for keys %g;\n\nprint join $/, ~~ @ans, @ans"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\n\nmy $N = <> + 0;\n\nmy $npaths = 0;\nmy %map_paths = ();\n\nmy %host_paths = ();\n\nfor (my $i = 0; $i < $N; ++$i) {\n   my $url = <>;\n   chomp $url;\n   $url =~ m{http://([.a-z]+)(.*)};\n   my ($hostname, $path) = ($1, $2);\n   #print $hostname, ' ', $path, \"\\n\";\n\n   my $id;\n   if ( not exists $map_paths{ $path } ) {\n      $id = $map_paths{ $path } = $npaths++\n   }\n   else {\n      $id = $map_paths{ $path }\n   }\n   $host_paths{ $hostname }{$id} = 1\n}\n\nmy %paths_hosts = ();\nwhile (my ($key, $path_set) = each %host_paths) {\n   my $paths = join(':', sort keys %$path_set);\n   #print $key, ' ', $paths, \"\\n\";\n   push( @{$paths_hosts{ $paths }}, $key )\n}\n\nmy @res;\nwhile (my ($key, $list) = each %paths_hosts) {\n   next if @$list <= 1;\n   push(@res, join(' ', map('http://' . $_, @$list)))\n}\n\nprint scalar @res, \"\\n\";\nprint join(\"\\n\", @res), \"\\n\"\n"}, {"source_code": "use strict;\n\nchomp (my $n = <STDIN>);\n\nmy $data;\n\nwhile (<>) {\n  chomp;\n  # if (m#http://([a-z.0-9]+)(/[a-z./]*)?$#) {\n  if (m#http://([a-z.]+)(/[a-z./]*)?$#) {\n    if (length $2) {\n      $data->{$1}->{$2}++\n    } else {\n      $data->{$1}->{'-'}++\n    }\n    # } else {\n    # die;\n  }\n}\n\nmy $hoq;\n\nforeach (keys %{$data}) {\n  $hoq->{join \"|\", sort keys %{$data->{$_}}}->{$_}++;\n}\n\nmy @sol;\n\nforeach (keys %{$hoq}) {\n  push @sol, join \" \", map {\"http://\" . $_} keys %{$hoq->{$_}} if ((scalar keys %{$hoq->{$_}}) > 1);\n}\n\nprint sprintf \"%d\\n%s\", (scalar @sol), (join \"\\n\", @sol);\n"}, {"source_code": "use warnings;\nuse strict;\n\nmy %host2path;\nmy %path2host;\n\nmy $n = <>;\nchomp $n;\n$n += 0;\n\nfor (my $i = 0; $i < $n; $i++){\n    my $url = <>;\n    $url =~ m!^(http://[\\w\\.]+)(/[\\w\\./]*)?\\n$! or die \"bad url\";\n    my $host = $1;\n    my $path = $2 || '';\n    #print STDERR \"host = \\'$host\\' path = \\'$path\\'\\n\";\n    if ($host2path{$host}) {\n        ${$host2path{$host}}{$path} = undef;\n        }\n    else {\n        $host2path{$host} = { $path => undef };\n        }\n    }\n\nwhile (my ($host, $pathes) = each %host2path){\n    my $ppp = join '#', sort keys %$pathes;\n    #print STDERR \"ppp = \\'$ppp\\' host = \\'$host\\'\\n\";\n    if ($path2host{$ppp}){\n        push @{$path2host{$ppp}}, $host;\n        }\n    else {\n        $path2host{$ppp} = [ $host ]\n        }\n    }\n    \nmy @res = ();\nwhile (my ($ppp, $hosts) = each %path2host){\n    push @res, $hosts if (scalar(@$hosts) > 1);\n    }\n\nprint scalar(@res), \"\\n\";\nprint join(' ', @$_), \"\\n\" foreach (@res);\n\nexit(0);\n"}, {"source_code": "$\\ = $/, <>;\n\nm!\\b(?:/.*)?$!, ++ $h{ $` }{ $& } for <>;\n\npush @{ $g{ join ' ', sort keys %{ $h{ $_ } }  } }, $_ for keys %h;\n@ans = grep / /, map { join ' ', @{ $g{ $_ } }  } keys %g;\n\nmap { print } ~~ @ans, @ans\n"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\n\nmy $N = <> + 0;\n\nmy $npaths = 0;\nmy %map_paths = ();\n\nmy %host_paths = ();\n\nfor (my $i = 0; $i < $N; ++$i) {\n   my $url = <>;\n   chomp $url;\n   $url =~ m{http://([.a-z]+)(.*)};\n   my ($hostname, $path) = ($1, $2);\n   #print $hostname, ' ', $path, \"\\n\";\n\n   my $id;\n   if ( not exists $map_paths{ $path } ) {\n      $id = $map_paths{ $path } = $npaths++\n   }\n   else {\n      $id = $map_paths{ $path }\n   }\n   push( @{$host_paths{ $hostname }}, $id )\n}\n\nmy %paths_hosts = ();\nwhile (my ($key, $list) = each %host_paths) {\n   my $paths = join(':', sort @$list);\n#  print $key, ' ', $paths, \"\\n\"\n   push( @{$paths_hosts{ $paths }}, $key )\n}\n\nmy @res;\nwhile (my ($key, $list) = each %paths_hosts) {\n   next if @$list <= 1;\n   push(@res, join(' ', map('http://' . $_, @$list)))\n}\n\nprint scalar @res, \"\\n\";\nprint join(\"\\n\", @res), \"\\n\"\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\tmy %h;\n\tmy %g;\n\tmy @ans;\n\t\n\tfor (1 .. $_){\n\t\t$_ = <>, chomp;\n\t\tm!/\\K[\\w.]+!;\n\t\tundef $h{ $& }{ $' };\n\t\t}\n\t\n\tpush @{ $g{ join ' ', sort keys %{ $h{ $_ } } } }, $_ for keys %h;\n\t@{ $g{ $_ } } > 1 and push @ans, join ' ', @{ $g{ $_ } } for keys %g;\n\t\n\tprint ~~  @ans;\n\tprint for @ans;\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\tmy %h;\n\tmy %g;\n\tmy @ans;\n\t\n\tfor (1 .. $_){\n\t\t$_ = <>, chomp;\n\t\tm!/\\K[\\w.]+!;\n\t\tundef $h{ $& }{ $' };\n\t\t}\n\t\n\tpush @{ $g{ join ' ', sort keys %{ $h{ $_ } } } }, $_ for keys %h;\n\t@{ $g{ $_ } } > 1 and push @ans, join ' ', @{ $g{ $_ } } for keys %g;\n\t\n\tprint ~~  @ans;\n\tprint s!\\b(?=\\w)!http://!gr for @ans;\n\t}"}], "src_uid": "9b35f7df9e21162858a8fac8ee2837a4"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tprint 0 + eval join '|', @_;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n \n<>;\n \nprint eval <> =~ y/ /|/r while <>"}, {"source_code": "$\\ = $/;\r\n \r\n<>;\r\n \r\nprint eval <> =~ y/ /|/r while <>"}], "negative_code": [], "src_uid": "7fca54a73076ddfeb30b921b9e341f26"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tmy $H = 0;\n\t\n\t$_ = join '', \n\tmap { $_->[ 0 ] }\n\tsort { $a->[ 1 ] <=> $b->[ 1 ] } \n\tmap { \n\t\t$s = () = /s/g;\n\t\t$H += $h = () = /h/g;\n\t\t$debug and print \"  [s:$s|h:$h]\";\n\t\t$debug and print \"  \", $h / ( $s || 1 / ~0 );\n\t\t[ $_ => $h / ( $s || 1 / ~0 ) ]\n\t\t} @_;\n\t\n\t$debug and print;\n\t\t\n\t$sum = 0;\n\t\n\t$& eq 'h' ? $H -- : ( $sum += $H ) while /./g;\n\t\n\tprint $sum;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\t$_ = join '', \n\tmap { $_->[ 0 ] }\n\tsort { $a->[ 1 ] <=> $b->[ 1 ] } \n\tmap { \n\t\tmy $s = () = /s/g;\n\t\tmy $h = () = /h/g;\n\t\t$debug and print \"  [s:$s|h:$h]\";\n\t\t$debug and print \"  \", $h / ( $s || 1 / ~0 );\n\t\t[ $_ => $h / ( $s || 1 / ~0 ) ]\n\t\t} @_;\n\t\n\t$debug and print;\n\t\n\tmy $h = () = /h/g;\n\t\n\tmy $sum = 0;\n\t\n\twhile( /./g ){\n\t\t$& eq 'h' ? do {\n\t\t\t\t$h --;\n\t\t\t}\n\t\t\t: do {\n\t\t\t\t$sum += $h;\n\t\t\t\t}\n\t\t\n\t\t}\n\t\n\tprint $sum;\n\t}"}, {"source_code": "<>;\n\n$_ = join '', \nsort { $a <=> $b } \nmap { \n\t$H += $h = () = /h/g;\n\t$h / ( ( () = /s/g ) || 1 / ~0 ) . \" $_\"\n\t} <>;\n\ns/[^sh]//g;\n\n$& eq 'h' ? $H -- : ( $s += $H ) while /./g;\n\nprint 0 + $s"}], "negative_code": [], "src_uid": "f88cf470095f250ffeb57feae7697e36"}
{"source_code": "#!/usr/bin/perl\n($n,$m) = split /\\D/, <>;\nflag:for (1..$n) {\n    chomp($str = <>);\n    @arr = split(//, $str);\n    @arr = sort { $a <=> $b } @arr;\n    if ($arr[0] == $arr[$#arr]) {\n        $color = $arr[0];\n        if (!defined $colors{$color}) {\n            $colors{$color} = $color;\n            if ( (keys %colors) > 10) {\n                print \"NO\";\n                goto end;\n            } \n        }\n        if (defined $pcolor) {\n            if ($pcolor eq $color) {\n                print \"NO\";\n                goto end;\n            }\n        }\n        $pcolor = $color;\n    } else {\n        print \"NO\";\n        goto end;\n    }\n}\nprint \"YES\";\nend:\n__END__", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\nwhile(<>=~/ /){\n \t$t=-1; $f=0;\n\tfor $i(1..$`+0){\n\t\t$_=<>;\n\t\tchomp;\n\t\t/./;\n\t\t$t==$& and $f++;\n\t\t$t=$&;\n\t\ts/(.)\\1*//;\n\t\t$_ and $f++;\n\t\t}\n\tprint ($f?\"NO\\n\":\"YES\\n\");\n\t}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n($n,$m) = split /\\D/, <>;\nflag:for (1..$n) {\n    chomp($str = <>);\n    @arr = split(//, $str);\n    @arr = sort { a <=> b } @arr;\n    if ($arr[0] == $arr[$#arr]) {\n        $color = $arr[0];\n        if (!defined $colors{$color}) {\n            $colors{$color} = $color;\n            if ( (keys %colors) > 10) {\n                print \"NO\";\n                goto end;\n            } \n        }\n        if (defined $pcolor) {\n            if ($pcolor eq $color) {\n                print \"NO\";\n                goto end;\n            }\n        }\n        $pcolor = $color;\n    } else {\n        print \"NO\";\n        goto end;\n    }\n}\nprint \"YES\";\nend:\n__END__"}], "src_uid": "80d3da5aba371f4d572ea928025c5bbd"}
{"source_code": "<>;\n\n@_ = split ' ', <>;\n\n$_ = join '', map 0 + ( $_[ $_ ] < $_[ $_ + 1 ] ), 0 .. @_ - 2;\n\nmy @cand = map 1 + length, /1+/g;\n\nwhile( / 1+ () 0 (?= (1+) ) /xg ){\n\t\n\tif( grep $_[ $-[ 1 ] - 1 + $_ ] < $_[ $-[ 1 ] + 1 + $_ ], 0, 1 ){\n\t\tpush @cand, length $& . $2;\n\t\t}\n\t}\n\nprint +( sort { $b <=> $a } 1, @cand )[ 0 ]", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $B;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tif( $_[ $i ] >= $_[ $i + 1 ] ){\n\t\t\t$B .= 0;\n\t\t\t}\n\t\telse{\n\t\t\t$B .= 1;\n\t\t\t}\n\t\t}\n\t\n\tmy @cand = map 1 + length, $B =~ /1+/g;\n\t\n\twhile( $B =~ / 1+ (0) (?= (1+) ) /xg ){\n\t\t\n\t\tif( $_[ $-[ 1 ] - 1 ] < $_[ $-[ 1 ] + 1 ] or $_[ $-[ 1 ] - 0 ] < $_[ $-[ 1 ] + 2 ] ){\n\t\t\tpush @cand, length $& . $2;\n\t\t\t}\n\t\t}\n\t\n\tprint +( sort { $b <=> $a } 1, @cand )[ 0 ];\n\t}"}], "negative_code": [{"source_code": "<>;\n\n@_ = split ' ', <>;\n\n$_ = join '', map $_[ $_ ] < $_[ $_ + 1 ], 0 .. @_ - 2;\n\nmy @cand = map 1 + length, /1+/g;\n\nwhile( / 1+ 0 (?= 1+ ) /xg ){\n\t\n\tif( grep $_[ ( pos ) - 2 + $_ ] < $_[ ( pos ) + 0 + $_ ], 0, 1 ){\n\t\tpush @cand, length $&;\n\t\t}\n\t}\n\nprint +( sort { $b <=> $a } 1, @cand )[ 0 ]"}, {"source_code": "<>;\n\n@_ = split ' ', <>;\n\n$_ = join '', map $_[ $_ ] < $_[ $_ + 1 ], 0 .. @_ - 2;\n\nmy @cand = map 1 + length, /1+/g;\n\nwhile( / 1+ 0 (?= (1+) ) /xg ){\n\t\n\tif( grep $_[ ( pos ) - 2 + $_ ] < $_[ ( pos ) + 0 + $_ ], 0, 1 ){\n\t\tpush @cand, length $& . $1;\n\t\t}\n\t}\n\nprint +( sort { $b <=> $a } 1, @cand )[ 0 ]"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $B;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tif( $_[ $i ] >= $_[ $i + 1 ] ){\n\t\t\t$B .= 0;\n\t\t\t}\n\t\telse{\n\t\t\t$B .= 1;\n\t\t\t}\n\t\t}\n\t\n\tmy @cand = map 1 + length, $B =~ /1+/g;\n\t\n\twhile( $B =~ / 1+ (0) ( (?=1+) ) /xg ){\n\t\t\n\t\tif( $_[ $-[ 1 ] - 1 ] < $_[ $-[ 1 ] + 1 ] or $_[ $-[ 1 ] - 0 ] < $_[ $-[ 1 ] + 2 ] ){\n\t\t\tpush @cand, 1 + length $& . $2;\n\t\t\t}\n\t\t}\n\t\n\tprint +( sort { $b <=> $a } @cand )[ 0 ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $B;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tif( $_[ $i ] >= $_[ $i + 1 ] ){\n\t\t\t$B .= 0;\n\t\t\t}\n\t\telse{\n\t\t\t$B .= 1;\n\t\t\t}\n\t\t}\n\t\n\tmy @cand = map 1 + length, $B =~ /1+/g;\n\t\n\twhile( $B =~ / 1+ (0) ( (?=1+) ) /xg ){\n\t\t\n\t\tif( $_[ $-[ 1 ] - 1 ] < $_[ $-[ 1 ] + 1 ] or $_[ $-[ 1 ] - 0 ] < $_[ $-[ 1 ] + 2 ] ){\n\t\t\tpush @cand, 1 + length $& . $2;\n\t\t\t}\n\t\t}\n\t\n\tprint +( sort { $b <=> $a } 1, @cand )[ 0 ];\n\t}"}], "src_uid": "87b8dccfc0e5a63cd209c37cf8aebef0"}
{"source_code": "while (<>){\n    @m=();\n    @n=();\n    $i=0;\n    ($n, $k) = split/ /,$_;\n    \n    for (1..$n-$k-1){\n        $m[$i++]=$_ ;\n        \n        }\n    \n    $i=0;\n    for ($n-$k..$n){\n        $n[$i++]=$_;\n        \n        }\n    @n = reverse @n;\n    \n    print \"@m\";\n    print \" \" if @m;\n    print \"@n\\n\";\n    }", "positive_code": [{"source_code": "$in = <>; chomp $in;\n$in =~ /(\\d+) (\\d+)/;\n$n = $1; $k = $2;\n\n$i = $n;\n\nfor (1..($k)) {\n    print \"$i \";\n    $i--;\n}\n$i = 1;\nfor ($k..($n-1)) {\n    print \"$i \";\n    $i++;\n}\n\nprint \"\\n\";\n"}], "negative_code": [{"source_code": "$in = <>; chomp $in;\n$in =~ /(\\d+) (\\d+)/;\n$n = $1; $k = $2;\n\n$i = $n;\n\nfor (1..($k)) {\n    print \"$i \";\n    $i--;\n}\nfor ($k..($n-1)) {\n    print \"$i \";\n}\n\nprint \"\\n\";\n"}], "src_uid": "75cc5b55c51217966cbdd639a68f0724"}
{"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp;\n@_ = \n(\n\t(grep $_ % 2 == 0, 1 .. $_)\n,\n\t(grep $_ % 2 == 1, 1 .. $_)\n)\n;\n$_ = \"@_\";\ns/\\b2 (?=1\\b)//;\n\t($n, $m) = split;\nprint 0 + split;\n\tprint\n\t\n\t\n\t}", "positive_code": [{"source_code": "\nmy $n = int<>;\n\nif ($n >= 5) {\n    print \"$n\\n\";\n    print join ' ', map {2 * $_ - 1} (1..int(($n+1)/2));\n    print ' ';\n    print join ' ', map {2 * $_} (1..int(($n)/2));\n} else {\n    if ($n == 4) {\n        print \"4\\n3 1 4 2\";\n    } elsif ($n == 3) {\n        print \"2\\n1 3\";\n    } else {\n        print \"1\\n1\";\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\nuse integer;\n\nchomp($n = <>);\n$n<=2 and say \"1\\n1\" and exit;\n$n==3 and say \"2\\n1 3\" and exit;\n$n==4 and say \"4\\n3 1 4 2\" and exit;\nsay $n;\nfor ($i=1; $i<=$n; $i+=2) {\n\tprint \"$i \";\n}\nfor ($i=2; $i<=$n; $i+=2) {\n\tprint \"$i \";\n}"}, {"source_code": "#!perl\n\n$n = <>;\nchomp $n;\n\n$,= \"\\n\";\n$\\= \"\\n\";\n\nif($n == 1 || $n == 2)\n{\n    print 1, 1; \n}\nelsif($n == 3)\n{\n    print 2, \"1 3\";\n}\nelse\n{\n    map {$_%2 == 0 ? push @a, $_ : push @b, $_} (1..$n); \n    \n    print   $n, \"@a @b\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\n$n = int($n);\n\nif ($n == 1 || $n == 2) {\n  print \"1\\n\";\n  print \"1\\n\";\n} elsif ($n == 3) {\n  print \"2\\n\";\n  print \"1 3\\n\";\n} elsif ($n == 4) {\n  print \"4\\n\";\n  print \"3 1 4 2\\n\";\n} else {\n  print \"$n\\n\";\n  print \"1\";\n  for (my $odds = 3; $odds <= $n; $odds += 2) {\n    print \" $odds\";\n  }\n  for (my $evens = 2; $evens <= $n; $evens += 2) {\n    print \" $evens\";\n  }\n  print \"\\n\";\n}\n\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = \n\t(\n\t\t(grep 1 - $_ % 2, 1 .. $_)\n\t,\n\t\t(grep     $_ % 2, 1 .. $_)\n\t)\n\t;\n\t$_ = \"@_\";\n\ts/^2 1/1/;\n\t\n\tprint 0 + split;\n\tprint\n}"}], "negative_code": [{"source_code": "my $n = int<>;\n\nif ($n >= 5) {\n    print join ' ', map {2 * $_ - 1} (1..int(($n+1)/2));\n    print ' ';\n    print join ' ', map {2 * $_} (1..int(($n)/2));\n} else {\n    if ($n == 4) {\n        print \"3 1 4 2\";\n    } elsif ($n == 3) {\n        print \"1 3\";\n    } else {\n        print \"1\";\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\nuse integer;\n\nchomp($n = <>);\n$n<=2 and say \"1\\n1\" and exit;\n$n==3 and say \"2\\n1 3\" and exit;\n$n==4 and say \"3\\n1 4 2\" and exit;\nsay $n;\nfor ($i=1; $i<=$n; $i+=2) {\n\tprint \"$i \";\n}\nfor ($i=2; $i<=$n; $i+=2) {\n\tprint \"$i \";\n}"}, {"source_code": "#!perl\n\n$n = <>;\n\n$,= \"\\n\";\n$\\= \"\\n\";\n\nif($n == 1 || $n == 2)\n{\n    print 1, 1; \n}\nelsif($n == 3)\n{\n    print 2, \"1 3\";\n}\nelse\n{\n    map {$_%2 == 0 ? push @a, $_ : push @b, $_} (1..$n); \n    \n    print  \"@a @b\";\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\n$n = int($n);\n\nif ($n == 1 || $n == 2) {\n  print \"1\\n\";\n  print \"1\\n\";\n} elsif ($n == 3) {\n  print \"2\\n\";\n  print \"1 3\\n\";\n} elsif ($n == 4) {\n  print \"3\\n\";\n  print \"1 4 2\\n\";\n} else {\n  print \"$n\\n\";\n  print \"1\";\n  for (my $odds = 3; $odds <= $n; $odds += 2) {\n    print \" $odds\";\n  }\n  for (my $evens = 2; $evens <= $n; $evens += 2) {\n    print \" $evens\";\n  }\n  print \"\\n\";\n}\n\n"}], "src_uid": "a52ceb8a894809b570cbb74dc5ef76e1"}
{"source_code": "@x = qw(500 1000 1500 2000 2500);\n@m = split / +/, <>;\n@w = split / +/, <>;\n($hs,$hu) = split / +/, <>;\n\nsub max {\n\tmy ($a,$b)=@_;\n\t$a>$b? $a: $b;\n}\n\nfor (0..4) {\n\t$s += max(0.3*$x[$_], $x[$_]-$x[$_]/250*$m[$_]-50*$w[$_]);\n}\n$s += 100*$hs;\n$s -= 50*$hu;\n\nprint $s, \"\\n\";", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nsub max {\n    return $_[0] > $_[1] ? $_[0]: $_[1];\n}\n\n@m = split(' ', <STDIN>);\n@w = split(' ', <STDIN>);\n@h = split(' ', <STDIN>);\n$i = 1;\n$sum = 0;\nforeach (@m) {\n    $a = 0.3 * 500 * $i;\n    $b = (500 - 2 * $m[$i-1]) * $i - 50 * $w[$i-1];\n    $t = max($a, $b);\n    $i ++;\n    $sum += $t;\n}\n\n$sum += $h[0] * 100 - $h[1] * 50;\nprint $sum . \"\\n\";\n\n"}, {"source_code": "@m = split ' ', <>;\n@f = split ' ', <>;\n($s, $u) = split ' ', <>;\n\n$sum += (sort {$b <=> $a} 0.3 * 500 * ++ $x, 500 * $x - (shift @m) * $x * 2 - 50 * shift @f)[ 0 ] while @m;\n\t\nprint $sum + $s * 100 - $u * 50"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@mins = split;\n\t@fails = split ' ', <>;\n\t($sh, $uh) = split ' ', <>;\n\t\n\t$x = 0;\n\t$sum = 0;\n\t\n\tfor (@mins){\n\t\t$x ++;\n\t\t$sum += (sort {$b <=> $a} 0.3 * 500 * $x, $x * 500 - $_ * $x * 2 - 50 * $fails[ $x - 1 ])[ 0 ];\n\t\t}\n\t\n\tprint $sum + $sh * 100 - $uh * 50;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nsub max {\n    return $_[1] > $_[2] ? $_[1]: $_[2];\n}\n\n@m = split(' ', <STDIN>);\n@w = split(' ', <STDIN>);\n@h = split(' ', <STDIN>);\n$i = 1;\n$sum = 0;\nforeach (@m) {\n    $a = 0.3 * 500 * $i;\n    $b = (1 - $_ / 250) * 500 * $i - 50 * $w[$i];\n    $t = max($a, $b);\n    $i ++;\n    $sum += $t;\n}\n\n$sum += $h[0] * 100 - $h[1] * 50;\nprint $sum . \"\\n\";\n\n"}, {"source_code": "#!/usr/bin/perl\n\nsub max {\n    return $_[1] > $_[2] ? $_[1]: $_[2];\n}\n\n@m = split(' ', <STDIN>);\n@w = split(' ', <STDIN>);\n@h = split(' ', <STDIN>);\n$i = 1;\n$sum = 0;\nforeach (@m) {\n    $a = 0.3 * 500 * $i;\n    $b = (1 - $m[$i-1] / 250) * 500 * $i - 50 * $w[$i-1];\n    $t = max($a, $b);\n    $i ++;\n    $sum += $t;\n}\n\n$sum += $h[0] * 100 - $h[1] * 50;\nprint $sum . \"\\n\";\n\n"}], "src_uid": "636a30a2b0038ee1731325a5fc2df73a"}
{"source_code": "chomp($_=<>);\n@a=split//;\n$_[ord $_]++ for @a;\n$a+=$_**2 for @_;\nprint $a", "positive_code": [{"source_code": "map {$_[ord $_]++} split//,<>;\n$_ && $i++ and $a+=$_**2 for @_;\nprint $a"}, {"source_code": "map {/./ && $_[ord $_]++} split//,<>;\n$a+=$_**2 for @_;\nprint $a"}, {"source_code": "#!perl -nl\n++$h{$_} for split'',$_;\n$a+=$h{$_}**2 for keys %h;\nprint $a;\n"}, {"source_code": "while(<>){\n\t$a=@_=();\n\tchomp;\n\ts/./$_[ord($&)]++/ge;\n\t$a+=$_**2 for @_;\n\tprint \"$a\\n\";\n\t}"}], "negative_code": [{"source_code": "map {$_[ord $_]++} split//,<>;\n$a+=$_**2 for @_;\nprint $a"}], "src_uid": "6bb2793e275426eb076972fab69d0eba"}
{"source_code": "$input = <STDIN>;\n$input =~ s{ \\. (\\d{3}) } [$1]gx;\n\nwhile ($input =~ /[\\d+\\.]+/g) {\n\t$sum += $&;\n}\n\n$sum = sprintf \"%.02f\", $sum;\n$sum =~ s/\\.00$//;\nwhile ( $sum =~ s{ (\\d+) (\\d{3}) (\\.|$) } [$1\\.$2$3]gx ) {};\n\nprint $sum; ", "positive_code": [{"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/\\.([0-9][0-9][0-9])/$1/g;\nprint STDERR $s. \"\\n\";\n$s =~ s/[a-z]+/,/g;\nprint STDERR $s. \"\\n\";\nmy $sum = 0;\nmy @temp=split /,/, $s;\nprint STDERR scalar(@temp). \"\\n\";\nfor(@temp)\n{\n  $sum+=$_ if($_);\n}\nprint STDERR  $s , \"\\n\";\nmy @f=split /\\./,$sum;\nprint STDERR \"@f \\n\";\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$f[0] = reverse join '.', @c;\nif($f[1])\n{\n  if(length($f[1])==1)\n  {\n    $f[1]=$f[1].\"0\";\n  }\n}\nmy $ans = join \".\",@f;\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::_;\nuse v5.10;\nuse strict;\n#use warnings;\n\nsub min{my($a,$b)=@_;if($a<$b){return$a;}else{return$b;}}\nsub max{my($a,$b)=@_;if($a>$b){return$a;}else{return$b;}}\n\nsub solve {\n    my @p = (<> =~ m/([\\d\\.]+)/gx);\n    my $r = 0;\n    foreach my $c (@p) {\n        $c =~ s/(?:(?=\\.\\d{3})\\.|)//gx;\n        $r += $c;\n    }\n    $r = sprintf(\"%.02f\", $r);\n    $r =~ s/\\.00$//;\n    while ($r =~ s/(\\d+)(\\d{3})/$1\\.$2/gx)\n        {};\n    print \"$r\\n\";\n}\n\nsub main {\n    my $t = 1;\n#    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main(@ARGV));\n"}, {"source_code": "print ~~ reverse(\n\t\n\t( reverse eval join ' + ', map s/\\.(?=\\d{3})//gr, <> =~ /[.\\d]+/g\n\t)\n\t\t=~ s/\\d{3}\\K(?!$)/./gr\n\t\t\n) =~ s/\\..\\K$/0/r"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::_;\nuse v5.10;\nuse strict;\n#use warnings;\n\nsub min{my($a,$b)=@_;if($a<$b){return$a;}else{return$b;}}\nsub max{my($a,$b)=@_;if($a>$b){return$a;}else{return$b;}}\n\nsub solve {\n    my @p = (<> =~ m/([\\d\\.]+)/g);\n    my $r = 0;\n    foreach my $c (@p) {\n         $c =~ s/(?:(?=\\.\\d{3})\\.|)//g;\n         $r += $c;\n    }\n    $r =~ s/(\\d+)(\\d{3})/$1\\.$2/g;\n    print \"$r\\n\";\n}\n\nsub main {\n    my $t = 1;\n#    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main(@ARGV));\n"}, {"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::_;\nuse v5.10;\nuse strict;\n#use warnings;\n\nsub min{my($a,$b)=@_;if($a<$b){return$a;}else{return$b;}}\nsub max{my($a,$b)=@_;if($a>$b){return$a;}else{return$b;}}\n\nsub solve {\n    my @p = (<> =~ m/([\\d\\.]+)/gx);\n    my $r = 0;\n    foreach my $c (@p) {\n        $c =~ s/(?:(?=\\.\\d{3})\\.|)//gx;\n        $r += $c;\n    }\n    while ($r =~ s/(\\d+)(\\d{3})/$1\\.$2/gx)\n        {};\n    print \"$r\\n\";\n}\n\nsub main {\n    my $t = 1;\n#    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main(@ARGV));\n"}, {"source_code": "$input = <STDIN>;\n$input =~ s{ \\. (\\d{3}) }{$1}x;\n\nwhile ($input =~ /[\\d+\\.]+/g) {\n\t$sum += $&;\n}\n\n$sum = sprintf \"%.02f\", $sum;\n$sum =~ s/\\.00$//;\n$sum =~ s{ (\\d+) (\\d{3}) (\\.|$) } [$1\\.$2$3]x;\n\nprint $sum; "}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/\\.([0-9][0-9][0-9])/$1/g;\nprint STDERR $s. \"\\n\";\n$s =~ s/[a-z]+/,/g;\nprint STDERR $s. \"\\n\";\nmy $sum = 0;\nmy @temp=split /,/, $s;\nprint STDERR scalar(@temp). \"\\n\";\nfor(@temp)\n{\n  $sum+=$_ if($_);\n}\nprint STDERR  $s , \"\\n\";\nmy @f=split /\\./,$sum;\nprint STDERR \"@f \\n\";\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$f[0] = reverse join '.', @c;\nmy $ans = join \".\",@f;\nprint $ans . \"\\n\";\n"}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/.([0-9][0-9][0-9])/$1/g;\nmy $sum = 0;\n#print $s , \"\\n\";\nmap {$sum += $_ } split /[a-z]+/,$s;\nmy @f=split /\\./,$sum;\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$sum = reverse join '.', @c;\n$sum =$sum . '.' .$f[1];\nprint $sum , \"\\n\";\n"}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/.([0-9][0-9][0-9])/$1/g;\nmy $sum = 0;\nmap {$sum += $_ if($_) } split /[a-z]+/,$s;\nprint STDERR  $sum , \"\\n\";\nmy @f=split /\\./,$sum;\nprint STDERR \"@f \\n\";\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$f[0] = reverse join '.', @c;\nmy $ans = join \".\",@f;\nprint $ans . \"\\n\";\n"}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/.([0-9][0-9][0-9])/$1/g;\nmy $sum = 0;\nmap {$sum += $_ if($_) } split /[a-z]+/,$s;\nmy @f=split /\\./,$sum;\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$f[0] = reverse join '.', @c;\n$f[0] =$f[0] . '.' .$f[1] if($f[1]);\nprint $f[0] , \"\\n\";\n"}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/.([0-9][0-9][0-9])/$1/g;\nmy $sum = 0;\nmap {$sum += $_ } split /[a-z]+/,$s;\nmy @f=split /\\./,$sum;\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$sum = reverse join '.', @c;\n$sum =$sum . '.' .$f[1] if($f[1]);\nprint $sum , \"\\n\";\n"}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/\\.([0-9][0-9][0-9])/$1/g;\nprint STDERR $s. \"\\n\";\n$s =~ s/[a-z]+/,/g;\nprint STDERR $s. \"\\n\";\nmy $sum = 0;\nmy @temp=split /,/, $s;\nprint STDERR scalar(@temp). \"\\n\";\nfor(@temp)\n{\n  $sum+=$_ if($_);\n}\nprint STDERR  $s , \"\\n\";\nmy @f=split /\\./,$sum;\nprint STDERR \"@f \\n\";\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$f[0] = reverse join '.', @c;\nif($f[1])\n{\n  $f[1]=sprintf(\"%.02d\",$f[1]);\n}\nmy $ans = join \".\",@f;\nprint $ans . \"\\n\";\n"}, {"source_code": "$,=\" \";\nmy $s=<>;\nchomp($s);\n$s =~ s/.([0-9][0-9][0-9])/$1/g;\n$s =~ s/[a-z]+/,/g;\nmy $sum = 0;\nmy @temp=split /,/, $s;\nprint STDERR scalar(@temp). \"\\n\";\nfor(@temp)\n{\n  $sum+=$_ if($_);\n}\nprint STDERR  $s , \"\\n\";\nmy @f=split /\\./,$sum;\nprint STDERR \"@f \\n\";\nmy @c = unpack(\"(A3)*\", reverse $f[0]);\n$f[0] = reverse join '.', @c;\nmy $ans = join \".\",@f;\nprint $ans . \"\\n\";\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t$_ .= 'a';\n\t@_ = map y/./_/r, grep length, split /[a-z]+/;\n\t@kop = grep  /_..$/, @_;\n\t@rub = grep !/_..$/, @_;\n\t\n\t@kop = map s/_(..)$/.$1/r, @kop;\n\t\n\t$sum = 0 + eval join ' + ', @kop, @rub;\n\tprint scalar reverse( (reverse $sum) =~ s/(\\d{3})(?!$)/$1./gr );\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t$_ .= 'a';\n\t@_ = map y/./_/r, grep length, split /[a-z]+/;\n\t@kop = grep  /_..$/, @_;\n\t@rub = grep !/_..$/, @_;\n\t\n\t@kop = map s/_(..)$/.$1/r, @kop;\n\t\n\t$sum = 0 + eval join ' + ', @kop, @rub;\n\tprint scalar reverse( (reverse $sum) =~ s/(?<=\\d{3})(?!$)/./gr );\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t$_ .= 'a';\n\t@_ = map y/./_/r, grep length, split /[a-z]+/;\n\t@kop = grep  /_..$/, @_;\n\t@rub = grep !/_..$/, @_;\n\t\n\t@kop = map s/_(..)$/.$1/r, @kop;\n\t\n\t$sum = 0 + eval join ' + ', @kop, @rub;\n\tprint scalar reverse( (reverse $sum) =~ s/(?<=\\d{3})(?!$)/./r );\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t$_ .= 'a';\n\t@_ = map y/./_/r, grep length, split /[a-z]+/;\n\t@kop = grep  /_..$/, @_;\n\t@rub = grep !/_..$/, @_;\n\t\n\t@kop = map s/_(..)$/.$1/r, @kop;\n\t\n\t$sum = 0 + eval join ' + ', @kop, @rub;\n\tprint scalar reverse( (reverse $sum) =~ s/(?<=\\d{3})/./r );\n\t}"}], "src_uid": "8da703549a3002bf9131d6929ec026a2"}
{"source_code": "\n$\\=$/;\n\n$path=\"/\";\n$n=<STDIN>;\nmy @paths;\nmy $temp;\nforeach $i(1 .. $n){\n    ($comm,$temp)=split(\" \",<STDIN>);\n    #print (index $temp,\"/\").\"\\n\".$temp;\n    if ($comm eq \"cd\"){\n        if ((index $temp,\"/\") eq 0){\n            $path=\"/\";\n            #print \"absolute path\\n\";\n        }\n            @paths=split(\"/\",$temp);\n            foreach $dir (@paths){\n                if ($dir eq \"..\"){\n                    #print \"step out\\n\";\n                    substr($path,rindex($path,\"/\"))=\"\";\n                    substr($path,rindex($path,\"/\"))=\"/\";\n                }else{\n                    #print \"adding path\\ndir=$dir\\n\";\n                    $path.=$dir.\"/\" if ($dir =~/[a-z]/);\n                }\n            }\n        \n    }else{\n        #$ans.=$path;\n        print $path;\n    }\n}\n#print $ans;\n", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @curpath = ();\n\nfor (1..$n) {\n    my $cmd = <>;\n    chomp $cmd;\n    if ($cmd =~ s/^cd //) {\n        my @dirs = split(/\\//, $cmd);\n        if ($dirs[0] eq \"\") {\n            @curpath = ();\n            shift @dirs;\n        }\n        foreach my $dir (@dirs) {\n            if ($dir eq \"..\") {\n                pop @curpath\n            } else {\n                push @curpath, $dir;\n            }\n        }\n    } elsif ($cmd =~ s/^pwd//) {\n        if (scalar @curpath == 0) {\n            print \"/\\n\";\n        } else {\n            print \"/\", join(\"/\", @curpath), \"/\\n\";\n        }\n    }\n}\n\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $curr = '/';\n\nwhile (<>) {\n    chomp;\n    print \"$curr\\n\" and next if $_ eq 'pwd';\n    $_ =~ s/cd\\s+//;\n    my @d = split '/';\n    unless ($d[0]) { $curr = '/'; shift @d; }\n    for (@d) {\n        $_ eq '..' ? ($curr =~ s|\\w+/$||) : ($curr .= \"$_/\");\n    }\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @curr = ();\nmy @tmp = ();\n\nsub print_ans {\n    print '/' . (join '/', @curr) . (0+@curr ? \"/\" : \"\"). \"\\n\";\n}\n\n\nsub get_curr {\n    @curr = ();\n    $_ eq '..' ? (pop @curr and next) : (push @curr, $_) for @tmp;\n}\n\nwhile (<>) {\n    chomp;\n    print_ans and next if $_ =~ 'pwd';\n    $_ =~s/cd\\s+//;\n    if ($_ =~ '^/') {\n        @tmp = split '/';\n        shift @tmp;\n    } else {\n        @tmp = (@curr, split '/');\n    }\n    get_curr;\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $curr = '/';\n\nwhile (<>) {\n    chomp;\n    print \"$curr\\n\" and next if $_ eq 'pwd';\n    $_ =~ s/cd\\s+//;\n    my @d = split '/';\n    unless ($d[0]) { $curr = '/' ; shift @d; };\n    $_ eq '..' ? ($curr =~ s|\\w+/$||) : ($curr .= \"$_/\") for @d;\n}\n"}, {"source_code": "use warnings;\nuse strict;\n\nuse feature ':5.10';\n\nmy $n = <STDIN>;\nmy $cd = '/';\n\nfor(my $i = 0; $i < $n; ++$i) {\n    my $cmd = <STDIN>;\n    chomp $cmd;\n    if ($cmd eq 'pwd') { say $cd }\n    else {\n        my ($dummy, $path) = split / /, $cmd;\n        if ($path =~ m&^/&) { $cd = $path.'/' }\n        else { $cd .= $path.'/' }\n        $cd =~ s&/[a-z]+/\\.\\.&&g  while( $cd =~ m&\\.\\.&);\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n$n = <STDIN>;\n@pol;\n@pol = (\"\");\n$i=0;\n$b=1;\n$j=0;\nfor ($i=0; $i<$n; $i++)\n{\n\tchomp($a = <STDIN>);\n\tif ($a =~ s/^cd (\\/?)/\\//)\n\t{\n\t\t@mas = split /[\\/]/, $a;\n\t\t$sla=$1;\n\t\tif ($sla=~/\\//)\n\t\t{\n\t\t\t@pol = (\"\");\n\t\t\t$b=1;\n#\t\t\tprint \"1\";\n\t\t\t$sla='';\n\t\t}\n\t\t$q = @mas;\n\n\t\tfor ($j=1; $j<$q; $j++)\n\t\t{\t\n\t\t\tif (($mas[$j] =~ /^\\.\\.$/))\n\t\t\t{\n\t\t\t\t\n\t\t\t\t$b-=1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\t\n\t\t\t\t\n\t\t\t\t$pol[$b+1]= $mas[$j];\n\t\t\t\t$b++;\n\t\t\t\t\n\t\t\t}\n\t\t};\n\t\t\n\t}\n\n\tif ($a =~ /^pwd/)\n\t{\n\n\t\t\n\t#\tprint \"/\";\n\t\tfor ($j = 1; $j<=$b; $j++)\n\t\t{\n\t\t\tprint \"$pol[$j]\\/\";\n\t\t}\n\t\tprint \"\\n\";\n\t}\n\t\n};\n"}, {"source_code": "<>;\n$p = '/';\ns!.* (/?)(.*)$/!($1||$p).\"$2/\"!e ? do{ 0 while s|//+|/|||s|\\w+/\\.+|| ; $p = $_} : print $p.$/ for <>"}, {"source_code": "<>;\n$p = '/';\nchomp, s!^cd !! ? do{ $p .= \"/$_/\", m!^/! and $p = \"$_/\"; 0 while $p =~ s!//+!/!g || $p =~ s!\\w+/\\.\\.!! } : print $p.$/ for <>"}, {"source_code": "<>;\n$p = '/';\ns!^cd (/?)(.*)\\n!($1?$1:$p).\"$2/\"!e ? do{ 0 while s!//+!/!g || s!\\w+/\\.\\.!! ; $p = $_} : print $p.$/ for <>"}, {"source_code": "#!/usr/bin/perl\n\nmy $n=4;\nmy @command;\nchomp($n=<>);\nfor (my $i=0;$i<$n;$i++)\n{\n  chomp($command[$i]=<>);\n}\nmy $pwd=\"/\";\n\nfor (my $i=0;$i<$n;$i++)\n{\n        if ($command[$i]=~m/^cd/)#sd\n        {\n                $command[$i]=~s/\\n//g;\n                $command[$i]=~s/^cd //g;\n                if ($command[$i]=~m/^\\//)\n                {\n                        $pwd=\"/\";\n                        $command[$i]=~s/^\\///g;\n                }\n                #\n                #comment\n                #\n                my @temp=split(/\\//,$command[$i]);\n                for (my $j=0;$j<=$#temp;$j++)\n                {\n                        if ($temp[$j] eq \"..\")\n                        {\n                                if ($pwd ne \"/\") {$pwd=~s/\\w{1,}\\/$//g;}\n                        } else\n                        {\n                                $pwd=\"$pwd$temp[$j]/\";\n                        }\n                }\n        } elsif ($command[$i]=~m/^pwd/)\n        {\n                print \"$pwd\\n\";\n        }\n}"}, {"source_code": "#!/usr/bin/perl\n\nmy $n=4;\nmy @command;\nchomp($n=<>);\nfor (my $i=0;$i<$n;$i++)\n{\n  chomp($command[$i]=<>);\n}\nmy $pwd=\"/\";\n\nfor (my $i=0;$i<$n;$i++)\n{\n        if ($command[$i]=~m/^cd/)#sd\n        {\n                $command[$i]=~s/\\n//g;\n                $command[$i]=~s/^cd //g;\n                if ($command[$i]=~m/^\\//)\n                {\n                        $pwd=\"/\";\n                        $command[$i]=~s/^\\///g;\n                }\n                #s\n                #comment\n                #\n                my @temp=split(/\\//,$command[$i]);\n                for (my $j=0;$j<=$#temp;$j++)\n                {\n                        if ($temp[$j] eq \"..\")\n                        {\n                                if ($pwd ne \"/\") {$pwd=~s/\\w{1,}\\/$//g;}\n                        } else\n                        {\n                                $pwd=\"$pwd$temp[$j]/\";\n                        }\n                }\n        } elsif ($command[$i]=~m/^pwd/)\n        {\n                print \"$pwd\\n\";\n        }\n}"}, {"source_code": "# http://codeforces.com/problemset/problem/158/C\n\n\n\nmy $n = <STDIN>;\nchomp ( $n );\n\nmy @path;\n\nmy $f;\nmy @arr;\nmy $cd, $what;\nmy $str;\nfor ( my $i = 0; $i < $n ; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n\n    if ( $f eq \"pwd\" ) {\t# print current path\n\tif ( @path ) {\t\t# \n\t    $str = \"/\" . (join \"/\", @path) . \"/\\n\";\n\t    if ( $str =~ s/(\\/+)(.*)/\\/$2/ ) {}\n\t    print $str;\n\t}\n\telse {\t\t\t# if path is empty ( at root )\n\t    print \"/\\n\"; }\n    }\n    else {\n\t($cd, $what) = split m/ /, $f; # parse line of input \n\t@arr = split m/\\//, $what;     # what == path\n\n\tif ( $what =~ m/\\A\\// ) {\n\t    @path = (); }\n\n\twhile ( @arr > 0 ) {\n\t    if ( $arr[ 0 ] eq \"..\" ) {\n\t\tpop @path;\n\t\tshift @arr;\n\t    }\n\t    else {\n\t\tmy $top = (shift @arr);\n\t\tpush @path, $top;\n\t    }\n\t}\n    }\n}\n\n\n"}, {"source_code": "#!perl\nour $cwd = [];\nsub cd{\n\tmy($cd) = @_;\n\t@cd = $cd eq \"/\" ? (\"\") : split '/', $cd;\n\tfor (my $i = 0; $i <= $#cd; $i++) {\n\t\t$_ = $cd[$i];\n\t\tif ($i == 0 && $_ eq \"\") {\n\t\t\t$#$cwd = -1;\n\t\t} elsif ($_ eq \"..\") {\n\t\t\tpop @$cwd;\n\t\t} else {\n\t\t\tpush @$cwd, $_;\n\t\t}\n\t}\n}\nsub pwd{\n\tif($#$cwd < 0){\n\t\tprint \"/\\n\";\n\t\treturn;\n\t}\n\tprint \"/\" . join(\"/\", @$cwd) . \"/\\n\";\n}\n%sh = (\n\tcd => \\&cd,\n\tpwd => \\&pwd\n);\nmy $k = int <STDIN>;\nwhile ($k--) {\n\t$_ = <STDIN>;\n\ts/[\\r\\n]$//g;\n\tmy ($cmd, $prm, $h) = split / +/, $_, 2;\n\tnext if !$cmd;\n\tif (($h = $sh{$cmd})) {\n\t\t$h->($prm);\n\t} else {\n\t\tdie \"unknown command '$cmd'\\n\";\n\t}\n}\n"}, {"source_code": "chomp($n = <STDIN>);\nwhile ($n--)\n{\n    chomp($_ = <STDIN>);\n    push @commands, $_;\n}\n\nforeach (@commands)\n{\n    if (/^pwd/)\n    {\n        print \"/\";\n        print \"$_/\" foreach (@dir);\n        print \"\\n\";\n    }\n    if (/^cd/)\n    {\n        s#^cd\\s+?##;\n        @dir = () if s#^/##;\n        @cd = split /\\//, $_;\n        foreach (@cd)\n        {\n            pop @dir if /\\.\\./;\n            push @dir, $_ unless /\\.\\./;\n        }\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n=4;\nmy @list;\nchomp($n=<>);\nfor (my $i=0;$i<$n;$i++) {chomp($list[$i]=<>);}\nmy $dir=\"/\";\nfor (my $i=0;$i<$n;$i++) {\n\tif ($list[$i]=~m/^cd/) {\n\t\t$list[$i]=~s/\\n//g;\n\t\t$list[$i]=~s/^cd //g;\n\t\tif ($list[$i]=~m/^\\//) {\n\t\t\t$dir=\"/\";\n\t\t\t$list[$i]=~s/^\\///g;\n\t\t}\n\t\tmy @temp=split(/\\//,$list[$i]);\n\t\tfor (my $j=0;$j<=$#temp;$j++) {\n\t\t\tif ($temp[$j] eq \"..\") {\n\t\t\t\tif ($dir ne \"/\") {$dir=~s/\\w{1,}\\/$//g;}\n\t\t\t} else {\n\t\t\t\t$dir=\"$dir$temp[$j]/\";\n\t\t\t}\n\t\t}\n\t} elsif ($list[$i]=~m/^pwd/) {\n\t\tprint \"$dir\\n\";\n\t}\n}\n"}, {"source_code": "use strict;\n\nmy $n = <>;\nmy $x = '/';\n\nwhile (<>) {\n  chomp;\n\n  if ($_ eq 'pwd') {\n\n    print $x, \"\\n\";\n\n  } else {\n\n    $_ = substr $_, 3;\n\n    if (index ($_, '/') == 0) {\n      $x = '/';\n      $_ = substr $_, 1;\n    }\n\n    my @a = split /\\//;\n\n    for (@a) {\n      if ($_ eq '..') {\n        $x =~ s#\\w*/$##;\n      } else {\n        $x .= $_ . '/';\n      }\n    }\n\n  }\n}"}, {"source_code": "chomp(my $n = <STDIN>);\nmy @path = ();\n\nforeach (1 .. $n) {\n    $_ = <STDIN>;\n    my @arg = split;\n\n    if ($arg[0] eq 'cd') {\n\tif ($arg[1] =~ /\\A\\//) {\n\t    @path = ();\n\t    $arg[1] = substr $arg[1], 1\n\t}\n\n\t@arg = split('/', $arg[1]);\n\n\tforeach (@arg) {\n\t    if ($_ eq '..') {\n\t\tpop @path;\n\t    } else {\n\t\tpush @path, $_;\n\t    }\n\t}\n    } else {\n\tforeach (@path) {\n\t    print \"/\" . $_;\n\t}\n\n\tprint \"/\\n\";\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n=4;\nmy @command;\nchomp($n=<>);\nfor (my $i=0;$i<$n;$i++) {chomp($command[$i]=<>);}\nmy $pwd=\"/\";\n\nfor (my $i=0;$i<$n;$i++) {\n    if ($command[$i]=~m/^cd/) {\n        $command[$i]=~s/\\n//g;\n        $command[$i]=~s/^cd //g;\n        if ($command[$i]=~m/^\\//) {\n            $pwd=\"/\";\n            $command[$i]=~s/^\\///g;\n        }\n        my @temp=split(/\\//,$command[$i]);\n        for (my $j=0;$j<=$#temp;$j++) {\n            if ($temp[$j] eq \"..\") {\n                if ($pwd ne \"/\") {$pwd=~s/\\w{1,}\\/$//g;}\n            } else {\n                $pwd=\"$pwd$temp[$j]/\";\n            }\n        }\n    } elsif ($command[$i]=~m/^pwd/) {\n        print \"$pwd\\n\";\n    }\n}\n"}, {"source_code": "use strict;\nuse warnings;\n#open STDIN, '<input.txt';\n#open STDOUT, '>output.txt';\n\nmy $n = <>;\nmy @curr = ();\nmy @tmp = ();\n\nsub print_ans {\n\tprint '/' . (join '/', @curr) . (0+@curr ? \"/\" : \"\"). \"\\n\";\n}\n\n\nsub get_curr {\n\t@curr = ();\n\t$_ eq '..' ? (pop @curr and next) : (push @curr, $_) for @tmp;\n}\n\nwhile (<>) {\n\tchomp;\n\tprint_ans and next if $_ =~ 'pwd';\n\t$_ =~s/cd\\s+//;\n\tif ($_ =~ '^/') {\n\t\t@tmp = split '/';\n\t\tshift @tmp;\n\t} else {\n\t\t@tmp = (@curr, split '/');\n\t}\n\tget_curr;\n}\n"}, {"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\nsub func($) {\n\twhile($_[0] =~ s/[a-z][a-z]*\\/\\.\\.//) {\n\t\t$_[0] =~ s/\\/\\//\\//; # удалить двойные слеши\n\t}\n\t$_[0] =~ s/^\\///;\n\t$_[0] =~ s/\\/$//;\n\treturn $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif($s =~ s/^cd //) {\n\t\tlabel: if( $s =~ m/\\.\\./ ) {\n\t\t\tif( $s =~ s/^\\///) {\n\t\t\t\t$s = '/'.func($s);\n\t\t\t\t$s =~ s/\\/\\//\\//g; #govnokod:)\n\t\t\t}\n\t\t\telse {\n\t\t\t\t$s = func($s);\n\t\t\t}\n\t\t\t#print($s);\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\n\t\t\t     goto label; #govnokod2:)\n\n\t\t\t}\n\t\t}\n\n\n\t\tif( $s =~ m/^\\// ) { \n\t\t\t$PATH = $s;\n\t\t}\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//g;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "#!/usr/bin/perl\n# Codeforces Practice\n\nuse warnings;\nuse strict;\n\nmy $n = <STDIN>;\nchomp($n);\n\nmy @currPath = ();\nmy $currCmd = \"\";\n\nfor(1..$n){\n    $currCmd = <STDIN>;\n    if($currCmd eq \"pwd\\n\"){\n        if (@currPath == 0){print \"/\\n\";}\n        else{\n        my $printPath = join(\"/\",@currPath);\n        print \"/$printPath/\\n\";}\n    } else {\n        my @cdPath = split(\"/\",(split(/\\s+/,$currCmd))[1]);\n        foreach my $dir (@cdPath){\n            if($dir eq \"\"){\n                @currPath = ();\n            } elsif ($dir eq \"..\") {\n                pop(@currPath);\n            } else {\n                push(@currPath,$dir);\n            }\n        }\n    }\n}"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse Data::Dumper;\n\nmy $n = <>;\nmy @wd = ();\n\nfor (1 .. $n) {\n    my ($cmd, $arg) = split ' ', <>;\n    if ($cmd eq 'pwd') {\n        print '/', (map { $_ . '/' } @wd), \"\\n\";\n    } else {\n        if ($arg =~ m|^/|) {\n            @wd = ();\n            $arg = substr $arg, 1;\n        }\n        for (split '/', $arg) {\n            push @wd, $_;\n        }\n        my @work = ();\n        for (@wd) {\n            if ($_ eq '..') {\n                pop @work;\n            } else {\n                push @work, $_;\n            }\n        }\n        @wd = @work;\n    }\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings;\n\nmy $n = <>;\nmy $path = '/';\nwhile ($n--) {\n  chomp( $_ = <> );\n  given ($_) {\n    when ( 'pwd' ) { say $path }\n    when ( m|^cd (/.*)| ) { $path = $1 }\n    when ( m|^cd (.*)| ) { $path .= $1 }\n  }\n  $path =~ s,^//,/,;\n  1 while $path =~ s,/\\w+/\\.\\.,, ;\n  $path .= '/' unless $path =~ m|/$|;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n=4;\nmy @command;\nchomp($n=<>);\nfor (my $i=0;$i<$n;$i++)\n{\n  chomp($command[$i]=<>);\n}\nmy $pwd=\"/\";\n\nfor (my $i=0;$i<$n;$i++)\n{\n        if ($command[$i]=~m/^cd/)\n        {\n                $command[$i]=~s/\\n//g;\n                $command[$i]=~s/^cd //g;\n                if ($command[$i]=~m/^\\//)\n                {\n                        $pwd=\"/\";\n                        $command[$i]=~s/^\\///g;\n                }\n                my @temp=split(/\\//,$command[$i]);\n                for (my $j=0;$j<=$#temp;$j++)\n                {\n                        if ($temp[$j] eq \"..\")\n                        {\n                                if ($pwd ne \"/\") {$pwd=~s/\\w{1,}\\/$//g;}\n                        } else\n                        {\n                                $pwd=\"$pwd$temp[$j]/\";\n                        }\n                }\n        } elsif ($command[$i]=~m/^pwd/)\n        {\n                print \"$pwd\\n\";\n        }\n}"}, {"source_code": "$n = <>;\n$path = \"\\/\";\nfor($i=0;$i<$n;$i++) {\n    $_ = <>;\n    if(/^pwd$/) {\n        1while($path =~ s/[a-z]+\\/\\.\\.\\///g);\n        $path =~ s/^\\/\\.\\.//g;\n        print $path , \"\\n\";\n    } else {\n        s/^cd //;\n        s/\\r|\\n//g;\n        $_.=\"\\/\"unless(/\\/$/);\n        if(/^\\//) {\n            $path = $_\n        } else {\n            $path .= $_\n        }\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n$root->{'..'} = '';\n$root->{''} = \\%root;\n$root->{'.'} = '/';\n$current_dir = $root;\n\nfor (1..<>) {\n    chomp($s = <>);\n    ($cmd, $dir) = split(/ /, $s);\n    if ($cmd eq 'pwd') {\n        @name = ();\n        $temp_dir = $current_dir;\n        while ($temp_dir->{'.'}) {\n            push @name, $temp_dir->{'.'};\n            $temp_dir = $temp_dir->{'..'}; # Not a HASH reference\n        }\n        print ( (reverse @name), \"\\n\");\n    } else {\n        if ($dir =~ m/^\\//) {\n            $current_dir = $root;\n        }\n        $dir =~ s/^\\///s;\n        $dir =~ s/\\/$//s;\n        @dirs = split(/\\//, $dir);\n        for $dir (@dirs) {\n            if (!defined $current_dir->{$dir}) {\n                $current_dir->{$dir}->{'.'} = \"$dir\\/\";\n                $current_dir->{$dir}->{'..'} = $current_dir;\n                $current_dir->{$dir}->{''} = $current_dir->{$dir};\n            }\n            $current_dir = $current_dir->{$dir};\n        }\n    }            \n}\n\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\n\nmy @cmd;\npush @cmd, <> for ($n);\n\nmy $curdir = \"/\";\nmy @dirstack = ();\n\nsub pwd() { print $curdir, \"\\n\"; }\n\nsub cd($) {\n    my @path = split '/', shift;\n\n    $#dirstack = -1 if (!@path[0]);\n\n    foreach my $dir (@path)\n    {\n        pop @dirstack if ($dir eq \"..\");\n        push @dirstack, $dir if ($dir ne \"..\");\n    }\n\n    $curdir = (join \"/\", @dirstack) . \"/\";\n    $curdir = \"/$curdir\" if ((substr $curdir,0,1) ne \"/\");\n}\n\nforeach (@cmd)\n{\n    my ($cmd, $arg) = split /\\s/, $_;\n\n    cd ($arg) if ($cmd eq \"cd\");\n    pwd() if ($cmd eq \"pwd\");\n}\n"}], "negative_code": [{"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif(length($s) > 3) {\n\t\t$s =~ s/cd //;\n\t\tif( $s =~ m/\\.\\./ ) {\n\t\t\twhile($s =~ s/[a-z]*\\/\\.\\.//) {\n\t\t\t\t$s =~ s/\\/\\//\\//g;\n\t\t\t\t$s =~ s/^\\///g;\n\t\t\t}\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\t\t\t}\n\t\t}\n\n\n\t\tif( $s =~ m/^\\// ) { $PATH = $s; }\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//g;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif(length($s) > 3) {\n\t\t$s =~ s/cd //;\n\t\tif( $s =~ m/\\.\\./ ) {\n\t\t\tif($s =~ s/[a-z]*\\/\\.\\.//g) {\n\t\t\t\t$s =~ s/^\\///g;\n\t\t\t}\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\t\t\t}\n\t\t}\n\n\n\t\tif( $s =~ m/^\\// ) { $PATH = $s; }\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//g;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\nsub func($) {\n\twhile($_[0] =~ s/[a-z]*\\/\\.\\.//) {\n\t\t$_[0] =~ s/\\/\\//\\//; # удалить двойные слеши\n\t}\n\treturn $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif(length($s) > 3) {\n\t\t$s =~ s/cd //;\n\t\tif( $s =~ m/\\.\\./ ) {\n\t\t\tif( $s =~ s/^\\///) {\n\t\t\t\t$s = '/'.func($s);\n\t\t\t\t$s =~ s/\\/\\//\\//g; #govnokod:)\n\t\t\t}\n\t\t\telse {\n\t\t\t\t$s = func($s);\n\t\t\t}\n\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\t\t\t}\n\t\t}\n\n\n\t\tif( $s =~ m/^\\// ) { \n\t\t\t$PATH = $s;\n\t\t}\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//g;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif(length($s) > 3) {\n\t\t$s =~ s/cd //;\n\t\tif( $s =~ m/\\.\\./ ) {\n\t\t\t$s =~ s/^\\/// if $s =~ s/[a-z]*\\/\\.\\.//g;\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\t\t\t     #\n\t\t\t}\n\t\t}\n\t\tif( $s =~ m/^\\// ) { $PATH = $s; }\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\nsub func($) {\n\twhile($_[0] =~ s/[a-z]*\\/\\.\\.//) {\n\t\t$_[0] =~ s/\\/\\//\\//; # удалить двойные слеши\n\t}\n\t$_[0] =~ s/^\\///;\n\t$_[0] =~ s/\\/$//;\n\treturn $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif($s =~ s/^cd //) {\n\t\tif( $s =~ m/\\.\\./ ) {\n\t\t\tif( $s =~ s/^\\///) {\n\t\t\t\t$s = '/'.func($s);\n\t\t\t\t$s =~ s/\\/\\//\\//g; #govnokod:)\n\t\t\t}\n\t\t\telse {\n\t\t\t\t$s = func($s);\n\t\t\t}\n\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\t\t\t}\n\t\t}\n\n\n\t\tif( $s =~ m/^\\// ) { \n\t\t\t$PATH = $s;\n\t\t}\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//g;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "sub parent($) {\n    $_[0] =~ s/\\/[a-z]*$//;\n    return $_[0];\n}\n\n$n = <STDIN>;\nchomp($n);\n$PATH = '/';\nfor($i = 0; $i < $n; $i++) {\n\t$s = <STDIN>;\n\tchomp($s);\n\tif(length($s) > 3) {\n\t\t$s =~ s/cd //;\n\t\tif( $s =~ m/\\.\\./ ) {\n\t\t\tif($s =~ s/[a-z]*\\/\\.\\.//g) {\n\t\t\t\t$s =~ s/^\\/*[^\\/]//;\n\t\t\t}\n\t\t\tif($s =~ s/^\\.\\.//) {\n\t\t\t     $p = parent($PATH);\n\t\t\t     $s = $p.$s;\n\t\t\t}\n\t\t}\n\n\n\t\tif( $s =~ m/^\\// ) { $PATH = $s; }\n\t\telse { \n\t\t\t$PATH =~ s/\\/$//g;\n\t\t\t$PATH = $PATH.'/'.$s; \n\t\t}\n\t}\n\telse {\n\t\t$PATH =~ s/\\/$//;\n\t\tprint($PATH.\"/\\n\");\n\t}\n}\n"}, {"source_code": "#!/usr/bin/perl\n# Codeforces Practice\n\nuse warnings;\nuse strict;\n\nmy $n = <STDIN>;\nchomp($n);\n\n\nmy @currPath;\nmy $currCmd = \"\";\n\nfor(1..$n){\n    $currCmd = <STDIN>;\n    if($currCmd eq \"pwd\"){\n        my $printPath = join(\"/\",@currPath);\n        print \"/$printPath/\\n\";\n    } else {\n        my @cdPath = split(\"/\",(split(/\\s+/,$currCmd))[1]);\n        foreach my $dir (@cdPath){\n            if($dir eq \"\"){\n                @currPath = ();\n            } elsif ($dir eq \"..\") {\n                pop(@currPath);\n            } else {\n                push(@currPath,$dir);\n            }\n        }\n    }\n}"}, {"source_code": "$\\=$/;\n\n$path=\"/\";\n$n=<STDIN>;\nmy @paths;\nmy $temp;\nforeach $i(1 .. $n){\n    ($comm,$temp)=split(\" \",<STDIN>);\n    #print (index $temp,\"/\").\"\\n\".$temp;\n    if ($comm eq \"cd\"){\n        if ((index $temp,\"/\") eq 0){\n            $path=$temp.\"/\";\n            #print \"absolute path\\n\";\n        }else{\n            @paths=split(\"/\",$temp);\n            foreach $dir (@paths){\n                if ($dir eq \"..\"){\n                    #print \"step out\\n\";\n                    substr($path,rindex($path,\"/\"))=\"\";\n                    substr($path,rindex($path,\"/\"))=\"/\";\n                }else{\n                    #print \"adding path\\n\";\n                    $path.=$dir.\"/\";\n                }\n            }\n        }\n    }else{\n        #$ans.=$path;\n        print $path;\n    }\n}\n#print $ans;\n"}, {"source_code": "$n = <>;\n$path = \"\\/\";\nfor($i=0;$i<$n;$i++) {\n    $_ = <>;\n    if(/^pwd$/) {\n        $path =~ s/[a-z]+\\/\\.\\.\\///g;\n        $path =~ s/^\\/\\.\\.//g;\n        print $path , \"\\n\";\n    } else {\n        s/^cd //;\n        s/\\r|\\n//g;\n        $_.=\"\\/\"unless(/\\/$/);\n        if(/^\\//) {\n            $path = $_\n        } else {\n            $path .= $_\n        }\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\n\nmy @cmd;\npush @cmd, <> for ($n);\n\nmy $curdir = \"/\";\nmy @dirstack = ();\n\nsub pwd() { print $curdir, \"\\n\"; }\n\nsub cd($) {\n    my @path = split '/', shift;\n\n    foreach my $dir (@path)\n    {\n        pop @dirstack if ($dir eq \"..\");\n        push @dirstack, $dir if ($dir ne \"..\");\n    }\n\n    $curdir = join \"/\", @dirstack;\n}\n\nforeach (@cmd)\n{\n    my ($cmd, $arg) = split /\\s/, $_;\n\n    cd ($arg) if ($cmd eq \"cd\");\n    pwd() if ($cmd eq \"pwd\");\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\n\nmy @cmd;\npush @cmd, <> for ($n);\n\nmy $curdir = \"/\";\nmy @dirstack = ();\n\nsub pwd() { print $curdir, \"\\n\"; }\n\nsub cd($) {\n    my @path = split '/', shift;\n\n    foreach my $dir (@path)\n    {\n        pop @dirstack if ($dir eq \"..\");\n        push @dirstack, $dir if ($dir ne \"..\");\n    }\n\n    $curdir = (join \"/\", @dirstack) . \"/\";\n    $curdir = \"/$curdir\" if ((substr $curdir,0,1) ne \"/\");\n}\n\nforeach (@cmd)\n{\n    my ($cmd, $arg) = split /\\s/, $_;\n\n    cd ($arg) if ($cmd eq \"cd\");\n    pwd() if ($cmd eq \"pwd\");\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\n\nmy @cmd;\npush @cmd, <> for ($n);\n\nmy $curdir = \"/\";\nmy @dirstack = ();\n\nsub pwd() { print $curdir, \"\\n\"; }\n\nsub cd($) {\n    my @path = split '/', shift;\n\n    foreach my $dir (@path)\n    {\n        pop @dirstack if ($dir eq \"..\");\n        push @dirstack, $dir if ($dir ne \"..\");\n    }\n\n    $curdir = (join \"/\", @dirstack) . \"/\";\n}\n\nforeach (@cmd)\n{\n    my ($cmd, $arg) = split /\\s/, $_;\n\n    cd ($arg) if ($cmd eq \"cd\");\n    pwd() if ($cmd eq \"pwd\");\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @curpath = (\"\");\n\nfor (1..$n) {\n    my $cmd = <>;\n    chomp $cmd;\n    if ($cmd =~ s/^cd //) {\n        my @dirs = split(/\\//, $cmd);\n        if ($dirs[0] eq \"\") {\n            @curpath = @dirs;\n        } else {\n            foreach my $dir (@dirs) {\n                if ($dir eq \"..\") {\n                    pop @curpath\n                } else {\n                    push @curpath, $dir;\n                }\n            }\n        }\n    } elsif ($cmd =~ s/^pwd//) {\n        if (scalar @curpath == 1) {\n            print \"/\\n\";\n        } else {\n            print join(\"/\", @curpath), \"/\\n\";\n        }\n    }\n}\n\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @curpath = ();\n\nfor (1..$n) {\n    my $cmd = <>;\n    chomp $cmd;\n    if ($cmd =~ s/^cd //) {\n        my @dirs = split(/\\//, $cmd);\n        if ($dirs[0] eq \"\") {\n            @curpath = ();\n        }\n        foreach my $dir (@dirs) {\n            if ($dir eq \"..\") {\n                pop @curpath\n            } else {\n                push @curpath, $dir;\n            }\n        }\n    } elsif ($cmd =~ s/^pwd//) {\n        if (scalar @curpath == 0) {\n            print \"/\\n\";\n        } else {\n            print join(\"/\", @curpath), \"/\\n\";\n        }\n    }\n}\n\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @curr = ();\nmy @tmp = ();\n\nsub print_ans {\n    print '/' . (join '/', @curr) . \"/\\n\";\n}\n\n\nsub get_curr {\n    @curr = ();\n    $_ eq '..' ? (pop @curr and next) : (push @curr, $_) for @tmp;\n}\n\n\nwhile (<>) {\n    chomp;\n    print_ans and next if $_ =~ 'pwd';\n    $_ =~s/cd\\s+//;\n    if ($_ =~ '^/') {\n        @tmp = split '/';\n        shift @tmp;\n    } else {\n        @tmp = (@curr, split '/');\n    }\n    get_curr;\n}\n"}, {"source_code": "use warnings;\nuse strict;\n\nuse feature ':5.10';\n\nmy $n = <STDIN>;\nmy $cd = '/';\n\nfor(my $i = 0; $i < $n; ++$i) {\n    my $cmd = <STDIN>;\n    chomp $cmd;\n    if ($cmd eq 'pwd') { say $cd }\n    else {\n        my ($dummy, $path) = split / /, $cmd;\n        if ($path =~ m&^/&) { $cd = $path }\n        else { $cd .= '/'.$path }\n        $cd =~ s&/[a-z]+/\\.\\.&&g\n    }\n}"}, {"source_code": "use warnings;\nuse strict;\n\nuse feature ':5.10';\n\n#my $n = <STDIN>;\n#my $cd = '/';\n#\n#for(my $i = 0; $i < $n; ++$i) {\n#    my $cmd = <STDIN>;\n#    chomp $cmd;\n#    if ($cmd eq 'pwd') { say $cd }\n#    else {\n#        my ($dummy, $path) = split / /, $cmd;\n#        if ($path =~ m&^/&) { $cd = $path }\n#        else { $cd .= '/'.$path }\n#        $cd =~ s&/[a-z]+/\\.\\.&&g\n#    }\n#}\n\nsay '/\n/home/vasya/\n/home/\n/home/petya/'"}, {"source_code": "#!/usr/bin/perl\n$n = <STDIN>;\n@pol;\n@pol = (\"\");\n$i=0;\n$b=1;\n$j=0;\nfor ($i=0; $i<$n; $i++)\n{\n\tchomp($a = <STDIN>);\n\tif ($a =~ s/^cd (\\/?)/\\//)\n\t{\n\t\t@mas = split /[\\/]/, $a;\n\t\t$sla=$1;\n\t\tif ($sla=~/\\//)\n\t\t{\n\t\t\t@pol = (\"\");\n\t\t\t$b=1;\n#\t\t\tprint \"1\";\n\t\t\t$sla='';\n\t\t}\n\t\t$q = @mas;\n#\t\tprint \"0 - $mas[0], 1 - $mas[1], 2 - $mas[2]\";\n\t\tfor ($j=1; $j<$q; $j++)\n\t\t{\t\n\t\t\tif (($mas[$j] =~ /^..$/))\n\t\t\t{\n#\t\t\t\tprint \"2\\n\";\n\t\t\t\t$b-=1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\t\n#\t\t\t\tprint \"3\\n\";\n\t\t\t\t$pol[$b+1]= $mas[$j];\n\t\t\t\t$b++;\n\t\t\t\t\n\t\t\t}\n\t\t};\n\t\t\n\t}\n#\tprint @mas;\n\tif ($a =~ /^pwd/)\n\t{\t\n\t#\tprint \"/\";\n\t\tfor ($j = 1; $j<=$b; $j++)\n\t\t{\n\t\t\tprint \"$pol[$j]\\/\";\n\t\t}\n\t\tprint \"\\n\";\n\t}\n\t\n};\n\n\n"}, {"source_code": "<>;\ns!.* (/?)(.*)$/!($1?'':$p).\"$2/\"!e ? do{ 0 while s|//+|/|||s|\\w+/\\.+|| ; $p = $_} : print \"/$p$/\" for <>"}, {"source_code": "<>;\n$p = '/';\nchomp, s/^cd // ? do{ $p .= \"/$_\"; 0 while $p =~ s!//+!/!g || $p =~ s!\\w+/\\.\\.!! } : print $p.$/ for <>"}, {"source_code": "<>;\n$a=\"/\";\nwhile(<>){\n\tchomp;\nif (/^pwd/){print $a,\"\\n\"}\nelse{\ns/\\w+ +//,\n$a.=$_.\"/\";\nwhile ($a=~m|\\w+/+\\.\\.|){$a=~s|\\w+/+\\.\\.||,\n$a=~s|/+|/|\n}\n$a=~s|/+|/|g;\n}\n\n}"}, {"source_code": "<>;\n$p = '/';\nchomp, s/^cd // ? do{ $p .= \"/$_/\"; 0 while $p =~ s!//+!/!g || $p =~ s!\\w+/\\.\\.!! } : print $p.$/ for <>"}, {"source_code": "# http://codeforces.com/problemset/problem/158/C\n\n\n\nmy $n = <STDIN>;\nchomp ( $n );\n\nmy @path;\n\nmy $f;\nmy @arr;\nmy $cd, $what;\nmy $str;\nfor ( my $i = 0; $i < $n ; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n\n    if ( $f eq \"pwd\" ) {\t# print current path\n\tif ( @path ) {\t\t# \n\t    $str = \"/\" . (join \"/\", @path) . \"/\\n\";\n\t    if ( $str =~ s/\\A(\\/+)(.*)/\\/$2/ ) {}\n\t    print $str;\n\t}\n\telse {\t\t\t# if path is empty ( at root )\n\t    print \"/\\n\"; }\n    }\n    else {\n\t($cd, $what) = split m/ /, $f; # parse line of input \n\t@arr = split m/\\//, $what;     # what == path\n\n\tif ( $what =~ m/\\A\\// ) {\t# absolute path\n\t    @path = @arr;\t\t# \n\t}\n\telse {\t\t\t# relative path\n\t    while ( @arr > 0 ) {\n\t\tif ( $arr[ 0 ] eq \"..\" ) {\n\t\t    pop @path;\n\t\t    shift @arr;\n\t\t}\n\t\telse {\n\t\t    my $top = (shift @arr);\n\t\t    push @path, $top;\n\t\t}}\n\t}\n    }\n}\n\n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/158/C\n\n\n\nmy $n = <STDIN>;\nchomp ( $n );\n\nmy @path;\n\nmy $f;\nmy @arr;\nmy $cd, $what;\nmy $str;\nfor ( my $i = 0; $i < $n ; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n\n    if ( $f eq \"pwd\" ) {\t# print current path\n\tif ( @path ) {\t\t# \n\t    $str = \"/\" . (join \"/\", @path) . \"/\\n\";\n\t    if ( $str =~ s/\\A(\\/+)(.*)/\\/$2/ ) {}\n\t    print $str;\n\t}\n\telse {\t\t\t# if path is empty ( at root )\n\t    print \"/\\n\"; }\n    }\n    else {\n\t($cd, $what) = split m/ /, $f; # parse line of input \n\t@arr = split m/\\//, $what;     # what == path\n\n\twhile ( @arr > 0 ) {\n\t    if ( $arr[ 0 ] eq \"..\" ) {\n\t\tpop @path;\n\t\tshift @arr;\n\t    }\n\t    else {\n\t\tmy $top = (shift @arr);\n\t\tpush @path, $top;\n\t    }\n\t}\n    }\n}\n\n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/158/C\n\n\n\nmy $n = <STDIN>;\nchomp ( $n );\n\nmy @path;\n\nmy $f;\nmy @arr;\nmy $cd, $what;\nmy $str;\nfor ( my $i = 0; $i < $n ; $i += 1 ) {\n    $f = <STDIN>;\n    chomp ( $f );\n\n    if ( $f eq \"pwd\" ) {\t# print current path\n\tif ( @path ) {\t\t# \n\t    $str = \"/\" . (join \"/\", @path) . \"/\\n\";\n\t    if ( $str =~ s/(\\/+)(.*)/\\/$2/ ) {}\n\t    print $str;\n\t}\n\telse {\t\t\t# if path is empty ( at root )\n\t    print \"/\\n\"; }\n    }\n    else {\n\t($cd, $what) = split m/ /, $f; # parse line of input \n\t@arr = split m/\\//, $what;     # what == path\n\n\twhile ( @arr > 0 ) {\n\t    if ( $arr[ 0 ] eq \"..\" ) {\n\t\tpop @path;\n\t\tshift @arr;\n\t    }\n\t    else {\n\t\tmy $top = (shift @arr);\n\t\tpush @path, $top;\n\t    }\n\t}\n    }\n}\n\n\n"}, {"source_code": "#!perl\nour $cwd = [];\nsub cd{\n\tmy($cd) = @_;\n\t@cd = $cd eq \"/\" ? (\"\") : split '/', $cd;\n\tfor (my $i = 0; $i <= $#cd; $i++) {\n\t\t$_ = $cd[$i];\n\t\tif ($i == 0 && $_ eq \"\") {\n\t\t\t$#$cwd = -1;\n\t\t} elsif ($_ eq \"..\") {\n\t\t\tpop @$cwd;\n\t\t} else {\n\t\t\tpush @$cwd, $_;\n\t\t}\n\t}\n}\nsub pwd{\n\tprint \"/\" . join(\"/\", @$cwd) . \"\\n\";\n}\n%sh = (\n\tcd => \\&cd,\n\tpwd => \\&pwd\n);\nmy $k = int <STDIN>;\nwhile ($k--) {\n\t$_ = <STDIN>;\n\ts/[\\r\\n]$//g;\n\tmy ($cmd, $prm, $h) = split / +/, $_, 2;\n\tnext if !$cmd;\n\tif (($h = $sh{$cmd})) {\n\t\t$h->($prm);\n\t} else {\n\t\tdie \"unknown command '$cmd'\\n\";\n\t}\n}\n"}, {"source_code": "#!perl\nour $cwd = [];\nsub cd{\n\tmy($cd) = @_;\n\t@cd = $cd eq \"/\" ? (\"\") : split '/', $cd;\n\tfor (my $i = 0; $i <= $#cd; $i++) {\n\t\t$_ = $cd[$i];\n\t\tif ($i == 0 && $_ eq \"\") {\n\t\t\t$#$cwd = -1;\n\t\t} elsif ($_ eq \"..\") {\n\t\t\tpop @$cwd;\n\t\t} else {\n\t\t\tpush @$cwd, $_;\n\t\t}\n\t}\n}\nsub pwd{\n\tprint \"/\" . join(\"/\", @$cwd) . \"/\\n\";\n}\n%sh = (\n\tcd => \\&cd,\n\tpwd => \\&pwd\n);\nmy $k = int <STDIN>;\nwhile ($k--) {\n\t$_ = <STDIN>;\n\ts/[\\r\\n]$//g;\n\tmy ($cmd, $prm, $h) = split / +/, $_, 2;\n\tnext if !$cmd;\n\tif (($h = $sh{$cmd})) {\n\t\t$h->($prm);\n\t} else {\n\t\tdie \"unknown command '$cmd'\\n\";\n\t}\n}\n"}, {"source_code": "chomp($n = <STDIN>);\nwhile ($n--)\n{\n    chomp($_ = <STDIN>);\n    push @commands, $_;\n}\n\nforeach (@commands)\n{\n    if (/^pwd/)\n    {\n        print \"/\";\n        print \"$_/\" foreach (@dir);\n        print \"\\n\";\n    }\n    if (/^cd/)\n    {\n        s#^cd\\s+?/?##;\n        @cd = split /\\//, $_;\n        foreach (@cd)\n        {\n            pop @dir if /\\.\\./;\n            push @dir, $_ unless /\\.\\./;\n        }\n    }\n}\n"}, {"source_code": "use strict;\nuse warnings;\nopen STDIN, '<input.txt';\nopen STDOUT, '>output.txt';\n\nmy $n = <>;\nmy @curr = ();\nmy @tmp = ();\n\nsub print_ans {\n\tprint '/' . (join '/', @curr) . (0+@curr ? \"/\" : \"\"). \"\\n\";\n}\n\n\nsub get_curr {\n\t@curr = ();\n\t$_ eq '..' ? (pop @curr and next) : (push @curr, $_) for @tmp;\n}\n\nwhile (<>) {\n\tchomp;\n\tprint_ans and next if $_ =~ 'pwd';\n\t$_ =~s/cd\\s+//;\n\tif ($_ =~ '^/') {\n\t\t@tmp = split '/';\n\t\tshift @tmp;\n\t} else {\n\t\t@tmp = (@curr, split '/');\n\t}\n\tget_curr;\n}\n"}], "src_uid": "494ac937ba939db1dbc4081e518ab54c"}
{"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n", "positive_code": [{"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}, {"source_code": "$n=<>;\nsub dfs {my $u=shift;$D[$u]=shift; for my $v (@{$g[$u]}) {&dfs($v,$D[$u]+1) unless defined $D[$v];}}\nwhile (<>) {chomp; ($u,$v)=split / /; push(@{$g[$u]},$v); push(@{$g[$v]},$u);}\n&dfs(1,0); $pr+=1.0/(1+$_) for (@D[1..$#D]); print \"$pr\\n\";\n\n"}], "negative_code": [], "src_uid": "85b78251160db9d7ca1786e90e5d6f21"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = split ' ', <>;\n\t\n\t$debug and print \"[@_]\";\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tnext if $_[ $i ] =~ /_/;\n\t\t\n\t\tmy $j = $i;\n\t\tmy @chain = $j;\n\t\t\n\t\tmy $cnt = 1;\n\t\t\n\t\twhile( $_[ $j ] != $i + 1 ){\n\t\t\t$cnt ++;\n\t\t\t$j = $_[ $j ] - 1;\n\t\t\tpush @chain, $j;\n\t\t\t}\n\t\t\n\t\tfor( @chain ){\n\t\t\t$_[ $_ - 0 ] = \"_$cnt\";\n\t\t\t}\n\t\t\n\t\t$debug and print \" [@_]\";\n\t\t}\n\t\n\ts/_// for @_;\n\t\n\tprint \"@_\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = split ' ', <>;\n\t\n\t$debug and print \"[@_]\";\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tnext if $_[ $i ] =~ /_/;\n\t\t\n\t\tmy $j = $i;\n\t\tmy @chain = $j;\n\t\t\n\t\tmy $cnt = 1;\n\t\t\n\t\twhile( $_[ $j ] != $i + 1 ){\n\t\t\t$cnt ++;\n\t\t\t$j = $_[ $j ] - 1;\n\t\t\tpush @chain, $j;\n\t\t\t}\n\t\t\n\t\tfor( @chain ){\n\t\t\t$_[ $_ - 0 ] = \"_$cnt\";\n\t\t\t}\n\t\t\n\t\t$debug and print \" [@_]\";\n\t\t}\n\t\n\ts/_// for @_;\n\t\n\tprint \"@_\";\n\t}"}], "negative_code": [], "src_uid": "345e76bf67ae4342e850ab248211eb0b"}
{"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}", "positive_code": [{"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\n \r\nwhile(<>){\r\n\tmap ~~<>, 1 .. reverse;\r\n\t\r\n\tprint m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\";\r\n\t}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\n\r\nwhile(<>){\r\n\tmap ~~<>, 1 .. reverse;\r\n\t\r\n\tprint m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\";\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tmap ~~<>, 1 .. $m;\n\t\n\tprint $n == $m ? \"NO\" : \"YES\";\n\t}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}, {"source_code": "<>;\r\nwhile(<>){map ~~<>, 1 .. reverse;print m/(.) \\1/ ? \"NO\\n\" : \"YES\\n\"}"}], "negative_code": [], "src_uid": "856b71ffb53f186bccd66c890ed0e099"}
{"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;", "positive_code": [{"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nwhile (<STDIN>) {\n    chomp;\n    s/(.*)/($1)/ if s/^-//;\n    s/^(\\(*)/$1\\$/;\n    s/(\\d+)(\\D*)/$1.$2/ unless m/\\./;\n    s/\\.(\\d*)/\\.${1}00/;\n    s/(\\.\\d{2})\\d*/$1/;\n    0 while s/(\\d)(\\d{3}[\\.,])/$1,$2/;\n    s/(.*)/$1\\n/;\n    print;\n}\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "#! perl -p\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n\n"}, {"source_code": "$_=<>;chomp;\ns/(\\d+)(\\.\\d+)?/\"$1\".($2?(length$2<3?(\"${2}0\"):(substr $2,0,3)):(\".00\"))/e;\ns/(\\d)(\\d{3}[.,])/$1,$2/ while /\\d{4}[.,]/;\ns/-// and s/^/(/,s/$/)/;\ns/\\d/'$'.$&/e;\nprint;"}], "negative_code": [{"source_code": "#! perl -p\n1 while s/([0-9])([0-9][0-9][0-9])($|\\.|,)/$1,$2$3/;\ns/$/./ unless /\\./;\ns/$/00/;\ns/\\...\\K.*//;\ns/-(.*)/($1)/;\ns/([0-9])/\\$$1/;\n"}, {"source_code": "$_=<>;chomp;\ns/(\\d+)(\\.\\d+)?/\"$1\".($2?(length$2<3?(\"${2}0\"):(substr $2,0,3)):(\"\"))/e;\ns/(\\d)(\\d{3}[.,])/$1,$2/ while /\\d{4}[.,]/;\ns/-// and s/^/(/,s/$/)/;\nprint;"}], "src_uid": "c704c5fb9e054fab1caeab534849901d"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = sort {$a <=> $b} split ' ', <>;\n\n\tfor (1 .. 1e5 + 1){\n\t\t$i = $_;\n\t\t@_ or last;\n\t\t$f = shift @_;\n\t\t$_ > $f and redo;\n\t\t}\n\t\n\tprint $i\n\t}", "positive_code": [{"source_code": "sub numbers { $a <=> $b };\n$n = <>; @a = split(' ', <>); @a = sort numbers @a;\nfor $a (@a) {\n\t$a > $c || next;\n\t$c++;\n}\nprint ++$c, \"\\n\""}], "negative_code": [{"source_code": "sub numbers { $a <=> $b };\n$n = <>; @a = split(' ', <>); @a = sort(numbers, @a);\nfor $a (@a) {\n\t$a > $c || next;\n\t$c++;\n}\nprint ++$c, \"\\n\""}], "src_uid": "482b3ebbbadd583301f047181c988114"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tif( $_[ 0 ] < $_[ @_ - 1 ] ){\n\t\tprint \"YES\";\n\t\t}\n\telse{\n\t\tprint \"NO\";\n\t\t}\n\t\n\t\n\t}", "positive_code": [{"source_code": "$t = <>;\nwhile ($t--) {\n    <>;\n    @a = split(\" \", <>);\n    print(($a[0] < $a[-1]) ? \"YES\" : \"NO\");\n    print \"\\n\";\n}\n"}], "negative_code": [{"source_code": "$t = <>;\nwhile ($t--) {\n    @a = split(\" \", <>);\n    print(($a[0] < $a[-1]) ? \"YES\" : \"NO\");\n    print \"\\n\";\n}"}], "src_uid": "192f181cfc74bef5b0b5a192964d9760"}
{"source_code": "$_ = <>;\n\nmap $h{ $_ } ++, split ' ', <>;\n\t\nprint $_ - ( sort { $b <=> $a } values %h )[ 0 ]", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\tmy $max = ( sort { $b <=> $a } values %h )[ 0 ];\n\t\n\tprint $_ - $max;\n\t}"}], "negative_code": [{"source_code": "<>;\n\nmap $h{ $_ } ++, split ' ', <>;\n\t\nprint $_ - ( sort { $b <=> $a } values %h )[ 0 ]"}], "src_uid": "eaa768dc1024df6449e89773234cc0c3"}
{"source_code": "while (<>){\n    chomp;\n    @_=();\n    for (1..$_){\n        push @_,\"\".<>;\n        \n        }\n    chomp @_;\n #   print \"@_\\n\";\n    @n=();\n    for (@_){\n        \n        @m=split/ /;\n        $sum=0;\n        for $i(@m){$sum+=$i}\n        push @n, $sum;\n        \n        }\n    @m=@_;\n    for $i(1..@m){\n        @k=();\n        for (@m){\n            s/(\\d+) ?//;\n            push @k,$1          \n            }\n        $a=join\" \",@k;\n        push @K, $a;\n        }\n        \n    for (@K){\n        \n        @m=split/ /;\n        $sum=0;\n        for $i(@m){$sum+=$i}\n        push @N, $sum;\n        \n        }\n    \n    $z=0;\n    for $i(@n){\n        for $j(@N){\n            $j>$i and $z++\n            \n            \n            }\n        \n        \n        }\n    print \"$z\\n\"\n    }\n    \n    ", "positive_code": [{"source_code": "while (<>){\n    @_=();\n    for (1..$_){push @_,\"\".<>}\n    chomp @_;\n    @n=();\n    \n    sub suma{\n        @A=@_;\n        @SUM=();\n        for (@A){\n            @m=split/ /;\n            $sum=0;\n            for $i(@m){$sum+=$i}\n            push @SUM, $sum;\n        }\n        return @SUM\n    }\n    \n    @i=suma (@_);\n    \n    @m=@_;\n    @_=();\n    for $i(1..@m){\n        @k=();\n        for (@m){\n            s/(\\d+) ?//;\n            push @k,$1          \n            }\n        push @_, (join\" \",@k);\n        }\n        \n    @j=suma (@_);\n    \n    $z=0;\n    for $i(@i){\n        for $j(@j){\n            $j>$i and $z++\n            }\n        }\n    print \"$z\\n\"\n    }\n    \n    "}], "negative_code": [], "src_uid": "6e7c2c0d7d4ce952c53285eb827da21d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\t$k and s/^.$/0/ and $k --;\n\t$k and s/^[2-9]/1/ and $k --;\n\t\n\ts/\n\t\t(?(?{ ! $k }) (*FAIL) )\n\t\t\\B[^0]\n\t\t(?{ $k -- })\n\t\t/\n\t\t0\n\t\t/gex;\n\t\t\n\tprint;\n\t}", "positive_code": [{"source_code": "( $n, $k, $_ ) = split ' ', <> . <>;\n\n$k and $k -= s/^.$/0/;\n$k and $k -= s/^[2-9]/1/;\n\nprint s/\n\t(?(?{ ! $k }) (?!) )\n\t\\B[1-9]\n\t(?{ $k -- })\n\t/0/gexr"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nmy ($n, $k) = split q{ }, $line;\n    \nchomp (my $s = <STDIN>);\n    \nif ( $k == 0 ) {\n    say $s;\n    exit(0);\n}\n\nif ( $n == 1 ) {\n    if ( $k > 0 ) {\n        say 0;\n    }\n    else {\n        say $s;\n    }\n    exit(0);\n}\n\nmy @srr = split q{}, $s;\nif ( $srr[0] != 1 ) {\n    $srr[0] = 1;\n    $k--;\n}\nmy $i = 1;\nwhile ( $k && $i < $n ) {\n    if ( $srr[$i] != 0 ) {\n        $srr[$i] = 0;\n        $k--;\n    }\n    $i++;\n}\nsay @srr;\n"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nmy ($n, $k) = split q{ }, $line;\n    \nchomp (my $s = <STDIN>);\n    \nif ( $k == 0 ) {\n    say $s;\n    exit(0);\n}\n\nif ( $n == 1 ) {\n    if ( $k > 0 ) {\n        say 0;\n    }\n    else {\n        say $s;\n    }\n    exit(0);\n}\n\nmy @srr = split q{}, $s;\nif ( $srr[0] != 1 ) {\n    $srr[0] = 1;\n    $k--;\n}\nmy $i = 1;\nwhile ( $k && $i < $n ) {\n    if ( $srr[$i] != '0' ) {\n        $srr[$i] = 0;\n    }\n    $i++;\n    $k--;\n}\nsay @srr;\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nchomp (my $line = <STDIN>);\n\nmy ($n, $k) = split q{ }, $line;\n\nchomp (my $s = <STDIN>);\n\nif ( $n == 1 and $k == 1 ) {\n    say 0;\n}\nelsif ( $k == 0 ) {\n    say $s;\n}\nelse {\n    my @srr = split q{}, $s;\n    if ( $srr[0] != 1 ) {\n        $srr[0] = 1;\n        $k--;\n    }\n    my $i = 1;\n    while ( $k-- ) {\n        $srr[$i++] = 0;\n    }\n    say @srr;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nmy ($n, $k) = split q{ }, $line;\n    \nchomp (my $s = <STDIN>);\n    \nif ( $k == 0 ) {\n    say $s;\n    exit(0);\n}\n\nif ( $n == 1 and $k >= 1 ) {\n    say 0;\n    exit(0);\n}\n\nelse {\n    my @srr = split q{}, $s;\n    if ( $srr[0] != 1 ) {\n        $srr[0] = 1;\n        $k--;\n    }\n    my $i = 1;\n    while ( $k-- && $i < $n ) {\n        $srr[$i++] = 0;\n    }\n    say @srr;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nmy ($n, $k) = split q{ }, $line;\n    \nchomp (my $s = <STDIN>);\n    \nif ( $n == 1 and $k == 1 ) {\n    say 0;\n}\nelsif ( $k == 0 ) {\n    say $s;\n}\nelse {\n    my @srr = split q{}, $s;\n    if ( $srr[0] != 1 ) {\n        $srr[0] = 1;\n        $k--;\n    }\n    my $i = 1;\n    while ( $k-- && $i < $n ) {\n        $srr[$i++] = 0;\n    }\n    say @srr;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nchomp (my $line = <STDIN>);\n    \nmy ($n, $k) = split q{ }, $line;\n    \nchomp (my $s = <STDIN>);\n    \nif ( $k == 0 ) {\n    say $s;\n    exit(0);\n}\n\nif ( $n == 1 and $k >= 1 ) {\n    say 0;\n    exit(0);\n}\n\nmy @srr = split q{}, $s;\nif ( $srr[0] != 1 ) {\n    $srr[0] = 1;\n    $k--;\n}\nmy $i = 1;\nwhile ( $k && $i < $n ) {\n    if ( $srr[$i] != '0' ) {\n        $srr[$i] = 0;\n    }\n    $i++;\n    $k--;\n}\nsay @srr;\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\t$k and s/[^1]/1/ and $k --;\n\t\n\ts/\n\t\t(?(?{ ! $k }) (*FAIL) )\n\t\t\\B[^0]\n\t\t(?{ $k -- })\n\t\t/\n\t\t0\n\t\t/gex;\n\t\n\t$k and s/^1$/0/;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\t$k and s/^[^1]/1/ and $k --;\n\t\n\ts/\n\t\t(?(?{ ! $k }) (*FAIL) )\n\t\t\\B[^0]\n\t\t(?{ $k -- })\n\t\t/\n\t\t0\n\t\t/gex;\n\t\n\t$k and s/^1$/0/;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\t$k and s/^[2-9]/1/ and $k --;\n\t\n\ts/\n\t\t(?(?{ ! $k }) (*FAIL) )\n\t\t\\B[^0]\n\t\t(?{ $k -- })\n\t\t/\n\t\t0\n\t\t/gex;\n\t\n\t$k and s/^1$/0/;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\tsubstr $_, 0, $k, 0 x $k;\n\t\n\ts/00/10/;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\t$k and s/^[^1]/1/ and $k --;\n\t\n\t@_ = split //;\n\t\n\tfor( @_[ 1 .. @_ - 1 ] ){\n\t\t$k and s/[^0]/0/ and $k --;\n\t\t}\n\t\n#\ts/\n#\t\t(?(?{ ! $k }) (*FAIL) )\n#\t\t\\B[^0]\n#\t\t(*SKIP)\n#\t\t(?(?{ ! $k }) (*FAIL) )\n#\t\t(?{ $k -- })\n#\t\t/\n#\t\t0\n#\t\t/gex;\n\t\n\t$_ = join '', @_;\n\t\n\t$k and s/^1$/0/;\n\t\n\tprint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\t$k and s/^[^1]/1/ and $k --;\n\t\n\ts/\n\t\t(?(?{ ! $k }) (*FAIL) )\n\t\t\\B[^0]\n\t\t(*SKIP)\n\t\t(?(?{ ! $k }) (*FAIL) )\n\t\t(?{ $k -- })\n\t\t/\n\t\t0\n\t\t/gex;\n\t\n\t$k and s/^1$/0/;\n\t\n\tprint;\n\t}"}], "src_uid": "0515ac888937a4dda30cad5e2383164f"}
{"source_code": "$m = 3e4;\r\n\r\n( 1 x $m ) =~ /^(1{2,$m})\\1{1,$m}(?{ $_[ pos ] = 1 })0/;\r\n$A .=- -$_ for @_;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n    $_ --,\r\n    \r\n\t$A =~ /00.{$_,}?(0).{$_,}?0/,\r\n\t\r\n\tprint $-[1] *~- $+[0] . $/\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\nmy $debug = 0;\r\n\r\nmy $max = 2e4 + 100;\r\n\r\nmy %h = map { +$_, 0 } 2 .. $max;\r\n\r\n$_ = 1 x $max;\r\n\r\n/^\r\n(1{2,$max}?)\\1{1,$max}?\r\n(?{\r\n    delete $h{ ( pos ) };\r\n    })\r\n(*F)\r\n/x;\r\n\r\n$debug and print join \" \", sort { $a <=> $b } keys %h;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$debug and print '-' x 15;\r\n\tchomp;\r\n\t\r\n\tmy $d = $_;\r\n\tmy $find = $d + 1;\r\n\t\r\n\t$find ++ while not exists $h{ $find };\r\n\t\r\n\tmy $find2 = $find + $d;\r\n\t\r\n\t$find2 ++ while not exists $h{ $find2 };\r\n\t\r\n\tprint $find * $find2;\r\n}"}, {"source_code": "$\\ = $/;\r\n\r\n$m = 3e4;\r\n\r\n( 1 x $m ) =~ /^ (1{2,$m})\\1{1,$m} (?{ $h[ pos ] = 1 }) 0 /x;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$i = $_ + 1;\r\n\t\r\n\t0 while $h[ $i ++ ];\r\n\t\r\n\t$j = -- $i + $_;\r\n\t\r\n\t0 while $h[ $j ++ ];\r\n\t\r\n\tprint $i * -- $j;\r\n}"}], "negative_code": [], "src_uid": "648ec67565c506c3e2ffd007ad44e8c3"}
{"source_code": "#! /usr/bin/perl\nuse strict; use warnings;\nuse Data::Dumper;\nuse feature 'say';\n\nsub min { return $_[0] < $_[1] ? $_[0] : $_[1] };\nsub max { return $_[0] > $_[1] ? $_[0] : $_[1] };\n\nmy ($n, $k) = split ' ', <>;\nmy $grid;\nfor (1..$n) {\n\tpush @$grid, [ split //, <> ];\n}\n\nmy $DP;\nsub dp {\n\tmy ($x, $y, $dir) = @_;\n\treturn 0 if ($x < 0 || $y < 0 || $x >= $n || $y >= $n) || ($grid->[$x][$y] eq '#');\n\treturn $DP->{$x}{$y}{$dir} if exists $DP->{$x}{$y}{$dir};\n\tmy ($xx, $yy) = ($x, $y);\n\t$x -= 1 if $dir == 0;\n\t$y += 1 if $dir == 1;\n\t$x += 1 if $dir == 2;\n\t$y -= 1 if $dir == 3;\n\treturn $DP->{$xx}{$yy}{$dir} = min($k, 1 + dp($x, $y, $dir));\n}\n\nsub count_ships {\n\tmy ($x, $y, $leftright) = @_;\n\tmy $dots = ($leftright ? dp($x, $y, 1) + dp($x, $y, 3) : dp($x, $y, 0) + dp($x, $y, 2)) - 1;\n\treturn max(0, $dots - $k + 1);\n}\n\nmy $max_hits = 0;\nmy ($x, $y) = (1, 1);\nfor my $i (1..$n) {\n\tfor my $j (1..$n) {\n\t\tmy $hits = count_ships($i - 1, $j - 1, 1);\n\t\t$hits += count_ships($i - 1, $j - 1, 0);\n\t\t($x, $y, $max_hits) = ($i, $j, $hits) if $max_hits < $hits;\n\t}\n}\n\nprint \"$x $y\\n\";\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t@_ = map { \n\t\t$_ = <>, chomp;\n\t\t[ map { ; { 'v' => $_, 'L' => 0, 'R' => 0, 'U' => 0, 'D' => 0, 'M' => 0 } } split // ] \n\t\t} 1 .. $n;\n\t\n\t### horizontal:\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'v' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = 0;\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\tif( $_[ $i ][ $j ]{ 'v' } eq '.' ){\n\t\t\t\t$_[ $i ][ $j ]{ 'L' } = $cnt;\n\t\t\t\t$cnt ++;\n\t\t\t\t$cnt >= $k and $cnt = $k - 1;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$cnt = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'L' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = 0;\n\t\tfor my $j ( reverse 0 .. @_ - 1 ){\n\t\t\tif( $_[ $i ][ $j ]{ 'v' } eq '.' ){\n\t\t\t\t$_[ $i ][ $j ]{ 'R' } = $cnt;\n\t\t\t\t$cnt ++;\n\t\t\t\t$cnt >= $k and $cnt = $k - 1;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$cnt = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'R' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\tif( $_[ $i ][ $j ]{ 'v' } eq '.' ){\n\t\t\t\tmy( $L, $R ) = sort { $a <=> $b } \n\t\t\t\t\t$_[ $i ][ $j ]{ 'L' }, $_[ $i ][ $j ]{ 'R' };\n\t\t\t\t$_[ $i ][ $j ]{ 'M' } += ( sort { $b <=> $a } \n\t\t\t\t\t0, ( sort { $a <=> $b } $L + 1, $L + $R + 1 - $k + 1 )[ 0 ] )[ 0 ];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'M' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\t### vertical:\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = 0;\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\tif( $_[ $j ][ $i ]{ 'v' } eq '.' ){\n\t\t\t\t$_[ $j ][ $i ]{ 'U' } = $cnt;\n\t\t\t\t$cnt ++;\n\t\t\t\t$cnt >= $k and $cnt = $k - 1;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$cnt = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'U' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = 0;\n\t\tfor my $j ( reverse 0 .. @_ - 1 ){\n\t\t\tif( $_[ $j ][ $i ]{ 'v' } eq '.' ){\n\t\t\t\t$_[ $j ][ $i ]{ 'D' } = $cnt;\n\t\t\t\t$cnt ++;\n\t\t\t\t$cnt >= $k and $cnt = $k - 1;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$cnt = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'D' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\tif( $_[ $j ][ $i ]{ 'v' } eq '.' ){\n\t\t\t\tmy( $L, $R ) = sort { $a <=> $b } \n\t\t\t\t\t$_[ $j ][ $i ]{ 'U' }, $_[ $j ][ $i ]{ 'D' };\n\t\t\t\t$_[ $j ][ $i ]{ 'M' } += ( sort { $b <=> $a } \n\t\t\t\t\t0, ( sort { $a <=> $b } $L + 1, $L + $R + 1 - $k + 1 )[ 0 ] )[ 0 ];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_->{ 'M' } } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\t### end vertical;\n\t\n\tmy $max = 0;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\tnext if $_[ $i ][ $j ]{ 'v' } eq '#';\n\t\t\t$_[ $i ][ $j ]{ 'M' } > $max and $max = $_[ $i ][ $j ]{ 'M' };\n\t\t\t}\n\t\t}\n\t\n\tmy $ans = \"1 1\";\n\t\n\tANS:\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\tnext if $_[ $i ][ $j ]{ 'v' } eq '#';\n\t\t\tnext if $_[ $i ][ $j ]{ 'M' } == 0;\n\t\t\t$_[ $i ][ $j ]{ 'M' } == $max and do {\n\t\t\t\t$ans = join ' ', map $_ + 1, $i, $j;\n\t\t\t\tlast ANS;\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\tprint $ans;\n\t\n\t$debug and print '-' x 15;\n\t}"}], "negative_code": [{"source_code": "#! /usr/bin/perl\nuse strict; use warnings;\nuse Data::Dumper;\nuse feature 'say';\n\nsub min { return $_[0] < $_[1] ? $_[0] : $_[1] };\nsub max { return $_[0] > $_[1] ? $_[0] : $_[1] };\n\nmy ($n, $k) = split ' ', <>;\nmy $grid;\nfor (1..$n) {\n\tpush @$grid, [ split //, <> ];\n}\n\nmy $DP;\nsub dp {\n\tmy ($x, $y, $dir) = @_;\n\treturn 0 if ($x < 0 || $y < 0 || $x >= $n || $y >= $n) || ($grid->[$x][$y] eq '#');\n\treturn $DP->{$x}{$y}{$dir} if exists $DP->{$x}{$y}{$dir};\n\tmy ($xx, $yy) = ($x, $y);\n\t$x -= 1 if $dir == 0;\n\t$y += 1 if $dir == 1;\n\t$x += 1 if $dir == 2;\n\t$y -= 1 if $dir == 3;\n\treturn $DP->{$xx}{$yy}{$dir} = min($k, 1 + dp($x, $y, $dir));\n}\n\nsub count_ships {\n\tmy ($x, $y, $leftright) = @_;\n\tmy $dots = ($leftright ? dp($x, $y, 1) + dp($x, $y, 3) : dp($x, $y, 0) + dp($x, $y, 2)) - 1;\n\treturn max(0, $dots - $k + 1);\n}\n\nmy $max_hits = 0;\nmy ($x, $y) = (0, 0);\nfor my $i (1..$n) {\n\tfor my $j (1..$n) {\n\t\tmy $hits = count_ships($i - 1, $j - 1, 1);\n\t\t$hits += count_ships($i - 1, $j - 1, 0);\n\t\t($x, $y, $max_hits) = ($i, $j, $hits) if $max_hits < $hits;\n\t}\n}\n\nprint \"$x $y\\n\";"}, {"source_code": "#! /usr/bin/perl\nuse strict; use warnings;\nuse Data::Dumper;\nuse feature 'say';\n\nsub min { return $_[0] < $_[1] ? $_[0] : $_[1] };\nsub max { return $_[0] > $_[1] ? $_[0] : $_[1] };\n\nmy ($n, $k) = split ' ', <>;\nmy $grid;\nfor (1..$n) {\n\tpush @$grid, [ split //, <> ];\n}\n\nmy $DP;\nsub dp {\n\tmy ($x, $y, $dir) = @_;\n\treturn 0 if ($x < 0 || $y < 0 || $x >= $n || $y >= $n) || ($grid->[$x][$y] eq '#');\n\treturn $DP->{$x}{$y}{$dir} if exists $DP->{$x}{$y}{$dir};\n\tmy ($xx, $yy) = ($x, $y);\n\t$x -= 1 if $dir == 0;\n\t$y += 1 if $dir == 1;\n\t$x += 1 if $dir == 2;\n\t$y -= 1 if $dir == 3;\n\treturn $DP->{$xx}{$yy}{$dir} = min($k, 1 + dp($x, $y, $dir));\n}\n\nprint dp(0, 0, 1);\n\nsub count_ships {\n\tmy ($x, $y, $leftright) = @_;\n\tmy $dots = ($leftright ? dp($x, $y, 1) + dp($x, $y, 3) : dp($x, $y, 0) + dp($x, $y, 2)) - 1;\n\treturn max(0, $dots - $k + 1);\n}\n\nmy $max_hits = 0;\nmy ($x, $y) = (1, 1);\nfor my $i (1..$n) {\n\tfor my $j (1..$n) {\n\t\tmy $hits = count_ships($i - 1, $j - 1, 1);\n\t\t$hits += count_ships($i - 1, $j - 1, 0);\n\t\t($x, $y, $max_hits) = ($i, $j, $hits) if $max_hits < $hits;\n\t}\n}\n\nprint \"$x $y\\n\";\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\tmy @A = map ~~<>, 1 .. $n;\n\tchomp @A;\n\t\n\tmy @lengths;\n\t\n\t@_ = @A;\n\t\n\tfor( @_ ){\n\t\ts!\n\t\t\t(\\.{$k,})\n\t\t!\n\t\t\tmy $len = length $1;\n\t\t\t'>' x ( $len % 2 + int $len / 2 ) .\n\t\t\t'<' x ( int $len / 2 )\n\t\t!gex;\n\t\t}\n\t\n\t$debug and print for @_;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\twhile( $_[ $i ] =~ /(>+)/g ){\n\t\t\tmy $len = length $1;\n\t\t\tpush @lengths, [ $len, $i + 1, pos $_[ $i ] ];\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \" @{ $_ }\" for @lengths;\n\t\n\t@_ = ( '' ) x @A;\n\t\n\tfor( @A ){\n\t\tmy $i = 0;\n\t\tmap { $_[ $i ++ ] .= $_ } split //;\n\t\t}\n\t\n\tfor( @_ ){\n\t\ts!\n\t\t\t(\\.{$k,})\n\t\t!\n\t\t\tmy $len = length $1;\n\t\t\t'>' x ( $len % 2 + int $len / 2 ) .\n\t\t\t'<' x ( int $len / 2 )\n\t\t!gex;\n\t\t}\n\t\n\t$debug and print for @_;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\twhile( $_[ $i ] =~ /(>+)/g ){\n\t\t\tmy $len = length $1;\n\t\t\tpush @lengths, [ $len, pos $_[ $i ], $i + 1 ];\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \" @{ $_ }\" for @lengths;\n\t\n\tprint !@lengths ? \"1 1\" : join ' ', map { $_->[ 1 ], $_->[ 2 ] } \n\t\t( sort { $b->[ 0 ] <=> $a->[ 0 ] } @lengths )[ 0 ];\n\t\n\t$debug and print '-' x 15;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\tmy @A = map ~~<>, 1 .. $n;\n\tchomp @A;\n\t\n\tmy @lengths;\n\t\n\t@_ = @A;\n\t\n\tfor( @_ ){\n\t\ts!\n\t\t\t(\\.{$k,})\n\t\t!\n\t\t\tmy $len = length $1;\n\t\t\t'>' x ( $len % 2 + int $len / 2 ) .\n\t\t\t'<' x ( int $len / 2 )\n\t\t!gex;\n\t\t}\n\t\n\t$debug and print for @_;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\twhile( $_[ $i ] =~ /(>+)/g ){\n\t\t\tmy $len = length $1;\n\t\t\tpush @lengths, [ $len, $i + 1, pos $_[ $i ] ];\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \" @{ $_ }\" for @lengths;\n\t\n\t@_ = ( '' ) x @A;\n\t\n\tfor( @A ){\n\t\tmy $i = 0;\n\t\tmap { $_[ $i ++ ] .= $_ } split //;\n\t\t}\n\t\n\tfor( @_ ){\n\t\ts!\n\t\t\t(\\.{$k,})\n\t\t!\n\t\t\tmy $len = length $1;\n\t\t\t'>' x ( $len % 2 + int $len / 2 ) .\n\t\t\t'<' x ( int $len / 2 )\n\t\t!gex;\n\t\t}\n\t\n\t$debug and print for @_;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\twhile( $_[ $i ] =~ /(>+)/g ){\n\t\t\tmy $len = length $1;\n\t\t\tpush @lengths, [ $len, pos $_[ $i ], $i + 1 ];\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \" @{ $_ }\" for @lengths;\n\t\n\tprint join ' ', map { $_->[ 1 ], $_->[ 2 ] } \n\t\t( sort { $b->[ 0 ] <=> $a->[ 0 ] } @lengths )[ 0 ];\n\t\n\t$debug and print '-' x 15;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t@_ = map { $_ = <>, chomp; [ map s/\\./$k * 2/er, split // ] } 1 .. $n;\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_ } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = $k;\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\t$_[ $i ][ $j ] =~ s/(-?\\d+)/ $cnt --; $cnt < 0 and $cnt = 0;\n\t\t\t\t$1 - $cnt \n\t\t\t\t/e or do {\n\t\t\t\t\t$cnt = $k;\n\t\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_ } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = $k;\n\t\tfor my $j ( reverse 0 .. @_ - 1 ){\n\t\t\t$_[ $i ][ $j ] =~ s/(-?\\d+)/ $cnt --; $cnt < 0 and $cnt = 0;\n\t\t\t\t$1 - $cnt \n\t\t\t\t/e or do {\n\t\t\t\t\t$cnt = $k;\n\t\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_ } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = $k;\n\t\tfor my $j ( 0 .. @_ - 1 ){\n\t\t\t$_[ $j ][ $i ] =~ s/(-?\\d+)/ $cnt --; $cnt < 0 and $cnt = 0;\n\t\t\t\t$1 - $cnt \n\t\t\t\t/e or do {\n\t\t\t\t\t$cnt = $k;\n\t\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_ } @{ $_ } for @_;\n\t\n\t$debug and print '-' x 5;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tmy $cnt = $k;\n\t\tfor my $j ( reverse 0 .. @_ - 1 ){\n\t\t\t$_[ $j ][ $i ] =~ s/(-?\\d+)/ $cnt --; $cnt < 0 and $cnt = 0;\n\t\t\t\t$1 - $cnt \n\t\t\t\t/e or do {\n\t\t\t\t\t$cnt = $k;\n\t\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\t$debug and print join ' ', map { sprintf \"%2s\", $_ } @{ $_ } for @_;\n\t\n\tmy $max = 0;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tfor my $j ( reverse 0 .. @_ - 1 ){\n\t\t\tnext if $_[ $i ][ $j ] eq '#';\n\t\t\t$_[ $i ][ $j ] > $max and $max = $_[ $i ][ $j ];\n\t\t\t}\n\t\t}\n\t\n\tmy $ans;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tfor my $j ( reverse 0 .. @_ - 1 ){\n\t\t\tnext if $_[ $i ][ $j ] eq '#';\n\t\t\tnext if $_[ $i ][ $j ] eq '0';\n\t\t\t$_[ $i ][ $j ] == $max and do {\n\t\t\t\t$ans = join ' ', map $_ + 1, $i, $j;\n\t\t\t\tlast;\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\tprint defined $ans ? $ans : \"1 1\";\n\t\n\t$debug and print '-' x 15;\n\t}"}], "src_uid": "6fb20914525715af737d81f3a5d98636"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\t\r\n\t@c = ci( @_ );\r\n\t\r\n\t@A = @_;\r\n\t\r\n\tfor $i ( 0 .. @A - 1 ){\r\n\t\tif( ! $A[ $i ] ){\r\n\t\t\t$A[ $i ] = 1;\r\n\t\t\tlast;\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tpush @c, ci( @A );\r\n\t\r\n\t@A = @_;\r\n\t\r\n\tfor $i ( reverse 0 .. @A - 1 ){\r\n\t\tif( $A[ $i ] ){\r\n\t\t\t$A[ $i ] = 0;\r\n\t\t\tlast;\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tpush @c, ci( @A );\r\n\t\r\n\tprint +( sort { $b <=> $a } @c )[ 0 ];\r\n\t}\r\n\r\nsub ci {\r\n\t$cz = grep !$_, @_;\r\n\t\r\n\t$Z = 0;\r\n\t\r\n\tfor $i ( 0 .. @_ - 1 ){\r\n\t\t$_[ $i ] ? $Z += $cz : $cz --;\r\n\t\t}\r\n\t\r\n\t$Z\r\n\t}", "positive_code": [{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\t\r\n\tprint +( sort { $b <=> $a }\r\n\tmap {\r\n\t\t$cz = () = /0/g;\r\n\t\t\r\n\t\t$Z = 0;\r\n\t\t\r\n\t\t/\\d(?{ $& ? $Z += $cz : $cz -- })(*F)/;\r\n\t\t\r\n\t\t$Z\r\n\t\t} $_, s/0/1/r, s/1(?!.*?1)/0/r\r\n\t\t)[ 0 ] . $/\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\n#use strict;\n\n<>;\n\nwhile(<>){\n\t$_ = <>;\n\t\n\tprint +( sort { $b <=> $a }\n\tmap {\n\t\t$cz = () = /0/g;\n\t\t\n\t\t$Z = 0;\n\t\t\n\t\t/\\d(?{ $& ? $Z += $cz : $cz -- })(*F)/;\n\t\t\n\t\t$Z\n\t\t} $_, s/0/1/r, s/1(?!.*?1)/0/r\n\t\t)[ 0 ] . $/\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy @cand;\n\t\n\tpush @cand, count_inversions( @_ );\n\t\n\tmy @A = @_;\n\t\n\tfor my $i ( 0 .. @A - 1 ){\n\t\tif( $A[ $i ] == 0 ){\n\t\t\t$A[ $i ] = 1;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tpush @cand, count_inversions( @A );\n\t\n\t@A = @_;\n\t\n\tfor my $i ( reverse 0 .. @A - 1 ){\n\t\tif( $A[ $i ] == 1 ){\n\t\t\t$A[ $i ] = 0;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tpush @cand, count_inversions( @A );\n\t\n\tprint +( sort { $b <=> $a } @cand )[ 0 ];\n\t}\n\nsub count_inversions {\n\tmy $cz = grep !$_, @_;\n\t\n\tmy $Z = 0;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tif( $_[ $i ] == 1 ){\n\t\t\t$Z += $cz;\n\t\t\t}\n\t\telse{\n\t\t\t$cz --;\n\t\t\t}\n\t\t}\n\t\n\treturn $Z;\n\t}"}], "negative_code": [], "src_uid": "0657ce4ce00addefc8469381c57294fc"}
{"source_code": "use strict;\nuse warnings;\n\n\nmy ($n,$x)=split / /,<>;\nchomp($n,$x);\n\nmy @data=split / /,<>;\nchomp(@data);\nmy %k;\nfor(my $i=0;$i<$n;$i++){\n\tpush(@{$k{$data[$i]}},$i);\n}\nmy $ans=0;\n\nif($x==0){\nfor my $dd (keys %k){\n\tmy $ff=scalar(@{$k{$dd}});\n\t$ans+=($ff)*($ff-1)/2;\n}\nprint $ans . \"\\n\";\n}\nelse{\nfor my $dd (keys %k){\n\tmy $t= int($x)^int($dd);\n\tif(defined $k{$t}){\n\t\t$ans+=scalar(@{$k{$dd}}) * scalar(@{$k{$t}});\n\t}\n}\n$ans/=2;\nprint $ans . \"\\n\";\n}\n\n\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $x ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy $j = 0;\n\tfor my $i (0 .. 20){\n\t\t$j = $i;\n\t\t$x < 2 ** $i and last;\n\t\t}\n\t\n\t$debug and print \"j: $j\";\n\t\n\tmy %h;\n\t\n\t$h{$_} ++ for @_;\n\t\n\t$debug and print \"$_ -> $h{$_}\" for keys %h;\n\t\n\tmy $sum = 0;\n\t\n\tfor (@_){\n\t\t$h{$_} --;\n\t\t\n\t\tmy $rem = $_ % 2 ** $j;\n\t\tmy $st = $_ - $rem;\n\t\t\n\t\t$debug and print \"^: \", $rem ^ $x;\n\t\t\n\t\t$sum += $h{ $st + ($rem ^ $x) } || 0;\n\t\t\n\t\t}\n\t\n\tprint $sum;\n\t\n\t}"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\n\n\nmy ($n,$x)=split / /,<>;\nchomp($n,$x);\n\nmy @data=split / /,<>;\nchomp(@data);\nmy %k;\nmap {$k{$_}=1} @data;\nmy $ans=0;\nfor my $val (@data){\n\tmy $t= int($x)^int($val);\n\tif(defined $k{$t}){\n\t\t$ans++;\n\t}\n}\n$ans/=2;\nprint $ans . \"\\n\";\n\n\n"}, {"source_code": "use strict;\nuse warnings;\n\n\nmy ($n,$x)=split / /,<>;\nchomp($n,$x);\n\nmy @data=split / /,<>;\nchomp(@data);\nmy %k;\nfor(my $i=0;$i<$n;$i++){\n\tpush(@{$k{$data[$i]}},$i);\n}\nmy $ans=0;\n\nif($x==0){\nfor my $dd (keys %k){\n\t$ans+=2*scalar(@{$k{$dd}});\n}\n}\nelse{\nfor my $dd (keys %k){\n\tmy $t= int($x)^int($dd);\n\tif(defined $k{$t}){\n\t\t$ans+=scalar(@{$k{$dd}}) * scalar(@{$k{$t}});\n\t}\n}\n}\n$ans/=2;\nprint $ans . \"\\n\";\n\n\n"}, {"source_code": "use strict;\nuse warnings;\n\n\nmy ($n,$x)=split / /,<>;\nchomp($n,$x);\n\nmy @data=split / /,<>;\nchomp(@data);\nmy %k;\nfor(my $i=0;$i<$n;$i++){\n\tpush(@{$k{$data[$i]}},$i);\n}\nmy %indexes;\n\n\nmy $ans=0;\nfor my $dd (keys %k){\n\tmy $t= int($x)^int($dd);\n\tif(defined $k{$t}){\n\t\t$ans+=scalar(@{$k{$dd}}) * scalar(@{$k{$t}});\n\t}\n}\n$ans/=2;\nprint $ans . \"\\n\";\n\n\n"}], "src_uid": "daabf732540e0f66d009dc211c2d7b0b"}
{"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";", "positive_code": [{"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "<>;\nmy $ans = \"YES\\n\";\nmy ($tt, $ff) = (0, 0);\nfor (split / /, <>) {\n    $tt++    if($_ == 25);\n    $ff++, $tt-- if($_ == 50);\n    if ($_ == 100) {\n        if ($ff && $tt) {\n            $ff--;\n            $tt--;\n        }\n        else {\n            $tt -= 3;\n        }\n    }\n    if ($tt < 0 || $ff < 0) {\n        $ans = \"NO\\n\";\n        last;\n    }\n}\nprint $ans;\n"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n($n25, $n50) = (0) x 2;\nforeach (split / /, <>) {\n\tif ($_ == 25) {\n\t\t++$n25;\n\t} elsif ($_ == 50) {\n\t\t$n25==0 and say \"NO\" and exit;\n\t\t--$n25;\n\t\t++$n50;\n\t} else {\n\t\tif ($n50>0 && $n25>0) {\n\t\t\t--$n50;\n\t\t\t--$n25;\n\t\t} elsif ($n25 >= 3) {\n\t\t\t$n25 -= 3;\n\t\t} else {\n\t\t\tsay \"NO\" and exit;\n\t\t}\n\t}\n}\nsay \"YES\";"}, {"source_code": "$n = <>;\n$hundred = 0;\n$fifty = 0;\n$twentytwo = 0;\n$ans = 'YES';\n@queue = split ' ', <>;\nforeach $a (@queue)\n{\n\tif($a == 25)\n\t{\n\t\t$twentytwo++;\n\t}\n\telsif($a == 50)\n\t{\n\t\t$fifty++;\n\t\t$twentytwo--;\n\t}\n\telse\n\t{\n\t\tif($fifty && $twentytwo)\n\t\t{\n\t\t\t$fifty--;\n\t\t\t$twentytwo--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$twentytwo -= 3;\n\t\t}\n\t\t$hundred++;\n\t}\n\tif($twentytwo < 0 || $fifty < 0)\n\t{\n\t\t$ans = 'NO';\n\t\tlast;\n\t}\n}\nprint $ans;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         STDIN: cinema_line.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 05/25/2015 10:29:48 PM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\n#open STDIN, \"in.txt\";\nmy (@a, %num);\nwhile(<STDIN>) {\n    chomp($_ = <STDIN>);\n    undef %num;\n    undef @a;\n    @a = split;\n    $num{25} = $num{50} = $num{100} = 0;\n    my $mark = 0;\n    for my $i (@a) {\n        if ($i == 25) {\n            $num{25}++;\n        }\n        elsif ($i == 50 && $num{25} >= 1) {\n            $num{25}--;\n            $num{50}++;\n        }\n        elsif ($i == 100) {\n            if ($num{50} >= 1 && $num{25} >= 1) {\n                $num{50}--;\n                $num{25}--;\n            }\n            elsif ($num{25} >= 3) {\n                $num{25} -= 3;\n            }\n            else {\n                print \"NO\\n\";\n                $mark = 1;\n                last;\n            }\n        }\n        else {\n            print \"NO\\n\";\n            $mark = 1;\n            last;\n        }\n    }\n    print \"YES\\n\" if $mark == 0;\n}\n\n\n"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "#!/usr/bin/perl -w\nuse 5.010;\n\nsub Solve {\n    my %change = ();\n    foreach $p (@_) {\n        given ($p) {\n            when (25) {\n                $change{25}++;\n            }\n            when (50) {\n                $change{25} || return 0;\n                $change{25}--, $change{50}++;\n            }\n            when (100) {\n                $change{25} || return 0;\n                $change{50} || $change{25} >= 3 || return 0;\n                if ($change{50}) {\n                    $change{50}--, $change{25}--, $change{100}++;\n                } else {\n                    $change{25} -= 3;\n                    $change{100}++;\n                }\n            }\n        }\n    }\n    return 1;\n}\n\nwhile (<>) {\n    @queue = split /\\s+/, <>;\n    say &Solve(@queue)? 'YES' : 'NO';\n}\n"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}, {"source_code": "<>;\n\n$_=<>;\ns/25|50|1/$&==25?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";"}, {"source_code": "<>;\n\n$_=<>;\ns/2|50|1/$&==2?($i++):($&==1?($j>0?($j--,$i--):($i-=3)):($i--,$j++)),($i<0||$j<0)?($f++):()/eg;\n\nprint $f?\"NO\":\"YES\";\n"}], "negative_code": [{"source_code": "<>;\nmy $change = 0;\nfor (split / /, <>) {\n    if (int($_-=25) > $change) {\n        $change = -1;\n        last;\n    }\n    $change += 25;\n}\nprint $change == -1 ? \"NO\\n\" : \"YES\\n\";\n"}, {"source_code": "<>;\nmy $change = 0;\nfor (split / /, <>) {\n    if (int$_ == 25) {\n        $change += 25;\n    }\n    elsif (int($_ -= 25) <= $change) {\n        $change += $_;\n    }\n    else {\n        $change = -1;\n        last;\n    }\n}\nprint $change == -1 ? \"NO\\n\" : \"YES\\n\";\n"}, {"source_code": "<>;\nmy $change = 0;\nmy $ans = \"YES\\n\";\nfor (split / /, <>) {\n    $change += 25, next  if(int$_ == 25);\n    $change -= $_, next  if($_-=25 <= $change);\n    $ans = \"NO\\n\";\n    last;\n}\nprint $ans;\n"}, {"source_code": "$n = <>;\n$hundred = 0;\n$fifty = 0;\n$twentytwo = 0;\n$ans = 'YES';\n@queue = split ' ', <>;\nforeach $a (@queue)\n{\n\tif($a == 25)\n\t{\n\t\t$twentytwo++;\n\t}\n\telsif($a == 50)\n\t{\n\t\t$fifty++;\n\t\t$twentytwo--;\n\t}\n\telse\n\t{\n\t\tif($fifty && $twentytwo)\n\t\t{\n\t\t\t$fifty++;\n\t\t\t$twentytwo--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$twentytwo -= 3;\n\t\t}\n\t\t$hundred++;\n\t}\n\tif($twentytwo < 0 || $fifty < 0)\n\t{\n\t\t$ans = 'NO';\n\t\tlast;\n\t}\n}\nprint $ans;\n"}, {"source_code": "<>;\n\n$_=<>;\ns/[120]/$&==2?($i++):($&==0?($i--):($i-=2)),$i<0 and $f++/eg;\n\nprint $f?\"NO\":\"YES\";"}], "src_uid": "63b20ab2993fddf2cc469c4c4e8027df"}
{"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n$cnt = 0;\n\nfor($i=0;$i<$n;$i++)\n{\n\n  $s = <STDIN>;\n  chomp $s;\n\n  ($a, $b) = split / +/, $s;\n\n  if( ( $b - $a ) >= 2 )\n  {\n\n    $cnt++;\n\n  }\n\n}\n\nprint $cnt;\n", "positive_code": [{"source_code": "my $n = <>;\nmy ($a, $b, $ans) = (0, 0, 0);\nfor (1..$n) {\n    ($a, $b) = split \" \", <>;\n    $ans++ if ($b - $a >= 2);\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "use strict;\nmy $t = <>;\nmy $cnt = 0;\nwhile($t --) {\n\n\tchomp (my $line = <>) ;\n\tmy ($a,$b) = split / /, $line;\n\t$cnt += $a + 2 <= $b;\n}\nprint \"$cnt\\n\";\n"}, {"source_code": "#!/perl -w\n\nuse strict ;\n\nchomp ( my $n = <STDIN> );\n\nmy $canlive = 0 ;\nwhile ($n--){\n    my($cu_people,$all_people) = split /\\s+/s , <STDIN> ;\n    $canlive++  if ( $all_people - $cu_people >= 2 ) ;\n\n}\n\nprint $canlive,\"\\n\" ;"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\nmy $ans = 0;\nwhile ($n-- > 0) {\n\t($p, $q) = split / /, <>;\n\t$p+2<=$q and $ans++;\n}\nsay $ans;"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy $c = 0;\nfor (1 .. $n) {\n    my ($p, $q) = split ' ', <>;\n    $c++ if $p + 2 <= $q;\n}\nprint \"$c\\n\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $cnt = 0;\nfor (1..$n) {\n    my ($a, $b) = split ' ', <>;\n    $cnt++ if ($a < $b - 1);\n}\nprint $cnt.\"\\n\";\n"}, {"source_code": "<stdin>;$res = 0; while(<stdin>){chomp; my ($x, $n) = split(\" \"); $res += 1 if $x <= $n-2; } print \"$res\\n\""}, {"source_code": "\n\nmy $a = <>;\nmy $cnt = 0;\nforeach (0 .. $a)\n{\n    ($b, $c) = split \" \", <>;\n    ++$cnt unless $b + 2 > $c;\n}\nprint $cnt;"}, {"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nmy $n = <>;\nmy $cnt = 0;\nwhile ($n--) {\n\tmy ($p, $q) = split / /, <>;\n\t$cnt++ if $q - $p >= 2;\n}\nprint $cnt;\n"}, {"source_code": "my $a = <>;\nmy $cnt = 0;\nforeach (0 .. $a)\n{\n    ($b, $c) = split \" \", <>;\n    ++$cnt unless $b + 2 > $c;\n}\nprint $cnt;"}, {"source_code": "$n = <>;\n$ans = 0;\nwhile ($n--) {\n    ($p, $q) = split(/\\s+/, <>);\n    if ($q - $p >= 2) {\n        ++$ans;\n    }\n}\nprint $ans;"}, {"source_code": "chomp ($n = <>);\n$ans = 0;\nforeach (1..$n) {\n\t($a, $b) = split (' ', <>);\n\tif ($b - $a >= 2) {\n\t\t$ans++;\n\t}\n}\nprint ($ans);"}, {"source_code": "<>;\n(($p,$q)=split/ /,$_),$q-$p>1 and $a++ for<>;\nprint 0+$a"}], "negative_code": [{"source_code": "use strict;\nmy $t = <>;\nmy $cnt = 0;\nwhile($t --) {\n\n\tchomp (my $line = <>) ;\n\tmy ($a,$b) = split / /, $line;\n\t$cnt += $a < $b;\n}\nprint \"$cnt\\n\";\n"}], "src_uid": "2a6c457012f7ceb589b3dea6b889f7cb"}
{"source_code": "#perl\n$_ = <STDIN>;\n@p = split(/\\D/,<STDIN>);\n$a = $b = 0;\nforeach $i (@p) {\n\tif ($i &1 ) {\n\t\t$a++;\n\t} else {\n\t\t$b++;\n\t}\n}\n$ans = ($a &1)? $a: $b;\nprint $ans;", "positive_code": [{"source_code": "#!perl\n$_ = <STDIN>;\n$scookies = <STDIN>;\n@cookies = split(/\\D/,$scookies);\n$odd = $even = 0;\nforeach $i (@cookies) {\n\tif ($i % 2) {\n\t\t$odd++;\n\t} else {\n\t\t$even++;\n\t}\n}\n$result = ($odd % 2)? $odd: $even;\nprint $result;\n"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@_=/\\d+/g;\n$i=$j=0;\nfor(@_){\n$_%2?($i++):($j++);\n}\nprint $i%2?($i):($j)"}], "negative_code": [{"source_code": "#!perl\n$scookies = <STDIN>;\n@cookies = split(/\\D/,$scookies);\n$odd = $even = 0;\nforeach $i (@cookies) {\n\tif ($i % 2) {\n\t\t$odd++;\n\t} else {\n\t\t$even++;\n\t}\n}\n$result = ($odd % 2)? $odd: $even;\nprint $result;\n"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@_=/\\d+/g;\n$i=$j=0;\nfor(@_){\n$_%2?($i++):($j++);\n}\nprint $j%2?($i):($j)"}, {"source_code": "<>;\nfor(split/ /,<>){\n$_%2?($i++):($j++);\n}\nprint $j%2?($i):($j)"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@_=split/ /;\n$i=$j=0;\nfor(@_){\n$_%2?($i++):($j++);\n}\nprint $j%2?($i):($j)"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@_=/\\d+/g;\n$i=$j=0;\nfor(@_){\n$_%2?($i++):($j++);\n}\nprint $j%2?($j):($i)"}], "src_uid": "4c59b4d43b59c8659bf274f3e29d01fe"}
{"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length", "positive_code": [{"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t$_=<>; #line\n\t\n\ts/^\\.*L//; #regexp\n\ts/R(\\.*)L/ ((length($1))%2)? 1:0 /ge;\n\ts/R\\.*//;\n\t\n\t$cnt=0;\n\t$cnt+=count(\".\",(split//,$_)); #ok\n\t$cnt+=count(\"1\",(split//,$_));\n\tprint $cnt;\n\tn();\n\t\n\t}"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t$_=<>; #line\n\tchomp;\n\t\n\ts/^\\.*L//; #regexp\n\ts/RL//g;\n\ts/R\\.*L/ ((length($&))%2)? '.':'' /ge;\n\ts/R\\.*$//;\n\t\n\tprint length;\n\t#print \" $_\";\n\tn();\n\t\t\n\t}\n\t\n"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length"}, {"source_code": "<>;\n$_=<>;\ns/^\\.*L|R\\.*$//g;\ns/R\\.*L/length($&)%2?1:''/ge;\nprint -1+length\n"}], "negative_code": [{"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t$_=<>; #line\n\t\n\ts/\\.*L//; #regexp\n\ts/R(\\.*)L/ ((length($1))%2)? 1:0 /ge;\n\ts/R\\.*//;\n\t\n\t$cnt=0;\n\t$cnt+=count(\".\",(split//,$_)); #ok\n\t$cnt+=count(\"1\",(split//,$_));\n\tprint $cnt;\n\tn();\n\t\n\t}\n\t\n"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t$_=<>; #line\n\tchomp;\n\t\n\ts/^\\.*L//; #regexp\n\ts/RL//g;\n\ts/R\\.*L/ ((length($&))%2)? '.':'' /ge;\n\ts/R\\.*$//;\n\t\n\tprint length;\n\tprint \" $_\";\n\tn();\n\t\t\n\t}\n\t\n"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t$_=<>; #line\n\t\n\ts/\\.*L//; #regexp\n\ts/RL//g;\n\ts/R(\\.*)L/ ((length($1))%2)? 1:0 /ge;\n\ts/R\\.*//;\n\t\n\t$cnt=0;\n\t$cnt+=count(\".\",(split//,$_)); #ok\n\t$cnt+=count(\"1\",(split//,$_));\n\tprint $cnt;\n\tn();\n\t\n\t#thinking...\n\t\n\t}\n\t\n"}, {"source_code": "sub n{print \"\\n\"}\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t$_=<>; #line\n\t\n\ts/\\.*L//; #regexp\n\ts/RL//g;\n\ts/R\\.*L/ ((length($&))%2)? 1:0 /ge;\n\ts/R\\.*//;\n\t\n\t$cnt=0;\n\t$cnt+=count(\".\",(split//,$_)); #ok\n\t$cnt+=count(\"1\",(split//,$_));\n\tprint $cnt;\n\tn();\n\t\t\n\t}\n\t\n"}], "src_uid": "54c748dd983b6a0ea1af1153d08f1c01"}
{"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n", "positive_code": [{"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}, {"source_code": "\n\n($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_"}, {"source_code": "($n,$m,$k)=split/ /,<>;\nfor $i(1..$n){\n\tfor $j(1..$m){\n\t\tpush @_, \" $i \". ($i % 2 ? $j : $m-$j+1)\n\t\t}\n\t}\nfor $z(2..$k){$a.=\"2\".(shift @_).(shift @_).\"\\n\"}\nprint $a,$n*$m-$k*2+2,@_\n"}], "negative_code": [], "src_uid": "779e73c2f5eba950a20e6af9b53a643a"}
{"source_code": "use feature \":all\";\n\nwhile(<>){\n\t($n, $p, $q) = split;\n\t$_ = <>;\n\n\tsay !/^\n\t\t( (?: (.{$p}) )* )\n\t\t( (?: (.{$q}) )* )\n\t\t$/x\n\t?\n\t\t\n\t\t-1\n\t:\n\t\tscalar do {\n\t\t\t($_1, $_3) = ($1, $3),\n\t\t\t@_ = (\n\t\t\t\t$_1 =~ /.{$p}/g,\n\t\t\t\t$_3 =~ /.{$q}/g,\n\t\t\t),\n\t\t\tjoin \"\\n\", 0 + @_, @_\n\t\t}\n\t\n\t}", "positive_code": [{"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $input = <>;\nchomp($input);\nmy $string = <>;\n\nmy @npq = split(\" \",$input);\nmy $n = $npq[0];\nmy $p = $npq[1];\nmy $q = $npq[2];\n\nfor (my $var = 0; $var * $p <= $n ; $var++)\n{\n  if(($n - ($var* $p)) % $q == 0)\n  {\n      my $var2 = ($n - ($var * $p)) / $q;\n      my $sub = 0;\n\n      say $var + $var2;\n\n      for (my $k = 0; $k < $var; $k++)\n      {\n        print substr($string, $sub, $p) . \"\\n\";\n        $sub = $sub + $p;\n      }\n      for (my $k = 0; $k < $var2; $k++)\n      {\n        print substr($string, $sub, $q) . \"\\n\";\n        $sub = $sub + $q;\n      }\n\n      exit;\n  }\n}\n\nsay \"-1\";\n"}, {"source_code": "($n,$p,$q)=split(' ',<>);\n$ch=<>;\nchomp$ch;\n$ok=0;\nfor($i=0;$i<=$n;$i+=$p){\nfor($j=0;$j<=$n;$j+=$q){\n\nif($i+$j==$n){\n\n$ok=1;\nlast;\n}\n}\nif($ok){\nlast;\n}\n}\nif(!$ok){\nprint\"-1\";\n}\nelse{\n$var1=$i/$p;\n$var2=$j/$q;\n$var= $var1+$var2;\nprint\"$var\\n\";\n$pos=0;\nwhile($var1--){\nprint substr($ch,$pos,$p);\nprint\"\\n\";\n$pos+=$p;\n}\n\nwhile($var2--){\nprint substr($ch,$pos,$q);\nprint\"\\n\";\n$pos+=$q;\n}\n\n\n\n\n\n\n\n\n}"}], "negative_code": [{"source_code": "#Scott Heinrich - A01273823\nuse strict;\nuse warnings;\nuse 5.010;\n\nmy $input = <>;\nchomp($input);\nmy $string = <>;\nchomp($string);\n\nmy @npq = split(\" \",$input);\nmy $n = $npq[0];\nmy $p = $npq[1];\nmy $q = $npq[2];\n\nfor (my $var = 0; $var * $p <= $n ; $var++)\n{\n  if(($n - ($var* $p)) % $q == 0)\n  {\n      my $var2 = ($n - ($var * $p)) / $q;\n      my $sub = 0;\n\n      for (my $k = 0; $k < $var; $k++)\n      {\n        print substr($string, $sub, $p) . \"\\n\";\n        $sub = $sub + $p;\n      }\n      for (my $k = 0; $k < $var2; $k++)\n      {\n        print substr($string, $sub, $q) . \"\\n\";\n        $sub = $sub + $q;\n      }\n\n      exit;\n  }\n}\n\nsay \"-1\";\n"}, {"source_code": "($n,$p,$q)=split(' ',<>);\n$ch=<>;\nchomp$ch;\n$ok=0;\nfor($i=0;$i<=$n;$i+=$p){\nfor($j=0;$j<=$n;$j+=$q){\n\nif($i+$j==$n){\n\n$ok=1;\nlast;\n}\n}\nif($ok){\nlast;\n}\n}\nif(!$ok){\nprint\"-1\";\n}\nelse{\n$var1=$i/$p;\n$var2=$j/$q;\n$var= $var1+$var2;\nprint\"$var\\n\";\n$pos=0;\nwhile($var1--){\nprint substr($ch,$pos,$p);\nprint\"\\n\";\n$pos+=$p;\n}\n$pos=0;\nwhile($var2--){\nprint substr($ch,$pos,$q);\nprint\"\\n\";\n$pos+=$q;\n}\n\n\n\n\n\n\n\n\n}"}, {"source_code": "use feature \":all\";\n\nwhile(<>){\n\t($n, $p, $q) = split;\n\t$_ = <>;\n\n\tsay !/^\n\t\t( (?: (.{$p}) )* )\n\t\t( (?: (.{$q}) )* )\n\t\t$/x\n\t?\n\t\t\n\t\t-1\n\t:\n\t\tscalar do { ($_1, $_3) = ($1, $3),\n\t\tjoin \"\\n\",\n\t\t\t( $_1 =~ /.{$p}/g ),\n\t\t\t( $_3 =~ /.{$q}/g ),\n\t\t}\n\t\n\t}"}], "src_uid": "c4da69789d875853beb4f92147825ebf"}
{"source_code": "$t = <> =~ s/\\d+ //r;\n\n$i += $t > 0, $t += $_ - 86400 for split ' ', <>;\n\nprint $i", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $t ) = split;\n\t@_ = map { 86400 - $_ } split ' ', <>;\n\t\n\tmy $i = 0;\n\t\n\tfor( @_ ){\n\t\t$i ++;\n\t\t$t -= $_;\n\t\t$t <= 0 and last;\n\t\t}\n\t\n\tprint $i;\n\t}"}], "negative_code": [], "src_uid": "8e423e4bec2d113612a4dc445c4b86a9"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = map ~~<>, 1 .. 2;\n\tchomp @_;\n\t\n\t$debug and print for @_;\n\t\n\ty/1-6/223/ for @_;\n\t\t\n\t$debug and print for @_;\n\t\n\t$_[ 1 ] = reverse $_[ 1 ];\n\t\n\t$_ = '';\n\t\n\twhile( $_[ 0 ] =~ /./g ){\n\t\t$_ .= $& . chop $_[ 1 ];\n\t\t}\n\t\n\t$debug and print \"[$_]\";\n\t\n\tmy $fail = 0;\n\t\n\tmy $switch = 0;\n\t\n\twhile( /(.)(.)/g ){\n\t\tif( $& == 33 ){\n\t\t\t$switch ++;\n\t\t\t$switch %= 2;\n\t\t\t}\n\t\telsif( $switch == 0 and $& == 32 ){\n\t\t\t$fail = 1;\n\t\t\t}\n\t\telsif( $switch == 1 and $& == 23 ){\n\t\t\t$fail = 1;\n\t\t\t}\n\t\t}\n\t\n\tprint $fail || $switch == 0 ? \"NO\" : \"YES\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. 2;\n\tchomp @_;\n\t\n\t$_ = zip_strings( @_ );\n\t\n\tmy $row = 0;\n\t\n\tprint m/\n\t\t\t(?:\n\t\t\t\t(*FAIL)\n\t\t\t|\t[3-6][3-6] (?{ ( $row += 1 ) %= 2; })\n\t\t\t|\t[3-6][1-2] (?(?{ $row == 0 }) (*ACCEPT) )\n\t\t\t|\t[1-2][3-6] (?(?{ $row == 1 }) (*ACCEPT) )\n\t\t\t|\t..\n\t\t\t|\t$  (?(?{ $row == 0 }) (*ACCEPT) ) # at end of the string\n\t\t\t)\n\t\t\t(*SKIP)\n\t\t\t(*FAIL)\n\t\t\t/x ? \"NO\" : \"YES\";\n\t}\n\nsub zip_strings {\n\t$_[ 1 ] = reverse $_[ 1 ];\n\t\n\tmy $zipped = '';\n\t\n\twhile( $_[ 0 ] =~ /./g ){\n\t\t$zipped .= $& . chop $_[ 1 ];\n\t\t}\n\t\n\treturn $zipped;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. 2;\n\t\n\ty/1-6/223/ for @_;\n\t\n\tmy $fail = 0;\n\tmy $row = 0;\n\t\n\twhile( 1 ){\n\t\t$_ = '';\n\t\t\n\t\t$_[ 0 ] =~ /./gc or last;\n\t\t$_ .= $&;\n\t\t\n\t\t$_[ 1 ] =~ /./gc;\n\t\t$_ .= $&;\n\t\t\t\n\t\t/\n\t\t\t(*F)\n\t\t|\t33 (?{ ( $row += 1 ) %= 2; })\n\t\t|\t32 (?{ $fail += $row == 0; })\n\t\t|\t23 (?{ $fail += $row == 1; })\n\t\t|\t..\n\t\t\t/x;\n\t\t}\n\t\n\tprint $fail || $row == 0 ? \"NO\" : \"YES\";\n\t}"}, {"source_code": "$\\ = $/;\n\n<>;\n \nwhile(<>){\n\t@_ = map <> =~ y/1-6/223/r, 1 .. 2;\n\t\n\t$F = 0;\n\t$row = 0;\n\t\n\twhile( $_[ 0 ] =~ /./gc ){\n\t\t$_ = $&;\n\t\t\n\t\t$_[ 1 ] =~ /./gc;\n\t\t$_ .= $&;\n\t\t\n\t\t/\n\t\t\t33 (?{ $row = 1 - $row })\n\t\t|\t32 (?{ $F += ! $row })\n\t\t|\t23 (?{ $F +=   $row })\n\t\t|\t..\n\t\t\t/x;\n\t\t}\n\t\n\tprint $F || ! $row ? \"NO\" : \"YES\";\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = map ~~<>, 1 .. 2;\n\tchomp @_;\n\t\n\ts/1/2/g for @_;\n\ts/[56]/3/g for $_[ 0 ];\n\ts/[34]/5/g for $_[ 1 ];\n\t\n\t$debug and print for @_;\n\t\n\tmy $fail = 0;\n\t\n\t$_[ 0 ] =~ s/ ^ 2* [34] //gx or $fail = 1;\n\t\n\tmy $del = -1 + length $&;\n\t\n\t$_[ 1 ] =~ s/.{$del}//;\n\t\n\tmy $switch = 0;\n\t\n\twhile( 1 ){\n\t\tlast if $fail;\n\t\t\n\t\t$switch ++;\n\t\t$switch %= 2;\n\t\t\n\t\t$debug and print \"$switch: [$_]\" for @_;\n\t\t\n\t\t$switch == 1 and do {\n\t\t\tif( $_[ 1 ] =~ s/ ^ [56] 2* [56] //xg ){\n\t\t\t\tmy $del = -2 + length $&;\n\t\t\t\t$_[ 0 ] =~ s/.{$del}//;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$fail = 1;\n\t\t\t\t}\n\t\t\t};\n\t\t\n\t\t$switch == 0 and do {\n\t\t\tif( $_[ 0 ] =~ s/ ^ [34] 2* [34] //xg ){\n\t\t\t\tmy $del = -2 + length $&;\n\t\t\t\t$_[ 1 ] =~ s/.{$del}//;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$fail = 1;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\n\tprint do { \n\t\t\tif( $_[ 1 ] =~ / ^ [56] 2* $ /x ){\n\t\t\t\t\"YES\";\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t\"NO\";\n\t\t\t\t}\n\t\t};\n\t}"}, {"source_code": "<>;\n\nwhile(<>){\n\t@_ = map <> =~ y/1-6/223/r, 1 .. 2;\n\t\n\t$F = 0;\n\t$row = 0;\n\t\n\twhile( $_[ 0 ] =~ /./gc ){\n\t\t$_ = $&;\n\t\t\n\t\t$_[ 1 ] =~ /./gc;\n\t\t$_ .= $&;\n\t\t\n\t\t/\n\t\t\t33 (?{ $row = 1 - $row })\n\t\t|\t32 (?{ $F += ! $row })\n\t\t|\t23 (?{ $F +=   $row })\n\t\t|\t..\n\t\t\t/x;\n\t\t}\n\t\n\tprint $F || ! $row ? \"NO\" : \"YES\";\n\t}"}], "src_uid": "f34cff4302e047b1e3bfc2c79aa57be3"}
{"source_code": "$n = <>; chomp $n;\nprint $n, scalar reverse $n;", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\nmy $thiswontwork = <>;\nchomp $thiswontwork;\nprint $thiswontwork;\nmy $ff = reverse $thiswontwork;\nprint $ff;\nprint \"\\n\";\n"}, {"source_code": "$a = <>;\nchomp($a);\nprint $a.reverse($a);"}, {"source_code": "$_ = <>, chomp, print $_ . reverse"}], "negative_code": [], "src_uid": "bcf75978c9ef6202293773cf533afadf"}
{"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $n = <STDIN>);\n    \nchomp (my $line = <STDIN>);\n\nmy @chips = split q{ }, $line;\n\nmy $odd = 0;\nmy $even = 0;\nfor (@chips) {\n    $odd++ if $_ % 2 == 1;\n    $even++ if $_ % 2 == 0;\n}\n\nsay min($odd, $even);\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ % 2 } ++, 0, 1, @_;\n\t\n\tprint -1 + ( sort { $a <=> $b } values %h )[ 0 ];\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ % 2 } ++, @_;\n\t\n\tprint 0 + ( sort { $a <=> $b } values %h )[ 0 ];\n\t}"}], "src_uid": "a0a6cdda2ce201767bf5418f445a44eb"}
{"source_code": "map {\n\t( $u, $v ) = split ' ', <>;\n\t$h{ $u }{ $v } ++;\n\t$h{ $v }{ $u } ++;\n\t} 2 .. <>;\n\t\n$d --;\ngo( 0, 1, 1 );\n\nprint $sum;\n\t\t\nsub go {\n\tmy( $p, $t, $pbb ) = @_;\n\t$d ++;\n\t\n\tmy @K = grep $_ != $p, keys %{ $h{ $t } };\n\t\n\t@K or $sum += $pbb * $d;\n\t\n\tgo( $t, $_, $pbb / @K ) for @K;\n\t\n\t$d --;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\nmy $sum;\nmy $depth;\nmy %h;\n\nwhile(<>){\n\t%h = ();\n\t\n\tmap {\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t$h{ $u }{ $v } ++;\n\t\t$h{ $v }{ $u } ++;\n\t\t} 1 .. $_ - 1;\n\t\t\n\t$sum = 0;\n\t$depth = -1;\n\tgo( 0, 1, 1 );\n\t\n\t$debug and print \"-------ANS:\";\n\tprint $sum;\n\t\n\t}\n\t\n\tsub go {\n\t\tmy( $prev, $try, $pbb ) = @_;\n\t\t$depth ++;\n\t\t$debug and print \"$depth|@_|$sum\";\n\t\t\n\t\tmy @keys = grep { $_ != $prev } keys %{ $h{ $try } };\n\t\t\n\t\tif( ! @keys ){\n\t\t\t$sum += $pbb * $depth;\n\t\t\t$debug and print \" sum: $sum\";\n\t\t\t}\n\t\t\n\t\tfor my $key ( @keys ){\n\t\t\t\n\t\t\tgo( $try, $key, $pbb / @keys );\n\t\t\t\n\t\t\t}\n\t\t\n\t\t$depth --;\n\t\t}"}], "negative_code": [], "src_uid": "adaae163882b064bf7257e82e8832ffb"}
{"source_code": "#!/usr/bin/perl -w \nuse feature \":5.20.1\";\n\n$t = <>;\nwhile($t--){\n    chomp($line = <>);\n    ($x, $y, $a, $b) = split \" \", $line;\n    $div = ($y - $x)/($a + $b);\n    $piso = int($div);\n    print $div == $piso ? \"$div\\n\" : \"-1\\n\";\n}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n\nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n\n# solution\n\nmy $n = read_token;\n\nfor (1..$n) {\n    my ($x, $y, $a, $b) = split q{ }, read_line;\n\n    my $gap = $y - $x;\n\n    my $sum = sum($a, $b);\n\n    if ($gap % $sum == 0) {\n        say $gap / $sum;\n    }\n    else {\n        say -1;\n    }\n}\n"}], "negative_code": [], "src_uid": "9afcf090806cc9c3b87120b1b61f8f17"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@A = grep $_, split ' ', <>;\n\t@B = grep $_, split ' ', <>;\n\t\n\t$re_A = \"@A\";\n\tprint( ( join ' ', (\"@B\") x 2) =~ /$re_A/ ? 'YES' : 'NO' )\n\t}", "positive_code": [{"source_code": "\tsub c { chomp @_; shift =~ s/\\b0 | 0//r }\n\t<>;\n\tprint -~ index( ( join ' ', (c(~~<>)) x 2 ), c(~~<>) ) ? 'YES' : 'NO'"}, {"source_code": "print -~ index( ( join ' ', (grep $_, split ' ', (<>,<>) ) x 2 ), (join ' ', grep $_, split ' ', <>) ) ? 'YES' : 'NO'\n"}], "negative_code": [], "src_uid": "846681af4b4b6b29d2c9c450a945de90"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@plus = ();\n\t@minus = ();\n\t\n\tfor (1 .. $_){\n\t\t($x, $y) = split ' ', <>;\n\t\t$plus[$x + $y]++;\n\t\t$minus[1010 + $x - $y]++;\n\t\t}\n\t\t\n\t$sum = 0;\n\tfor (@plus, @minus){\n\t\t$_ or next;\n\t\t$sum += $_ * ($_-1) / 2\n\t\t}\n\t\n\tprint $sum\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n$\\ = $/;\n\nwhile (<>) {\n    my (%hsh1, %hsh2);\n    while ($_ --) {\n        my ($x, $y) = split / /, <>;\n        $hsh1{$x + $y}++;\n        $hsh2{$x - $y}++;\n     }\n    my $sum;\n    $sum += ($_ * ($_ - 1)) / 2 for (values %hsh1);\n    $sum += ($_ * ($_ - 1)) / 2 for (values %hsh2);\n    print $sum;\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nwhile(<>) {\n  my (%r,%l);\n  for(1..$_) {\n    my ($x,$y) = split \" \", <>;\n    $r{$x+$y}++;\n    $l{$x-$y}++;\n  }  \n  my $res = 0; \n  $res += $_ * ($_-1)/2 foreach values %r;\n  $res += $_ * ($_-1)/2 foreach values %l;\n  print \"$res\\n\";\n}"}], "negative_code": [], "src_uid": "eb7457fe1e1b571e5ee8dd9689c7d66a"}
{"source_code": "<>;\r\nprint~~(++$_/10),\"\\n\"for<>", "positive_code": [{"source_code": "<>;\r\nprint~~(++$_/10),\"\\n\"for<>"}], "negative_code": [{"source_code": "print~~((<>+1)/10)"}], "src_uid": "8e4194b356500cdaacca2b1d49c2affb"}
{"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\t@_ =<>=~ /./g;\n\n\t$A[$x][$y] = 1;\n\t@ans = (1);\n\tfor (@_){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\n\t\t$x < 1  and $x ++;\n\t\t$x > $X and $x --;\n\t\t$y < 1  and $y ++;\n\t\t$y > $Y and $y --;\n\n\t\tpush @ans, $A[$x][$y] ? 0 : scalar ($A[$x][$y] = 1, 1);\n\t}\n\n\t$ans[$#ans] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\\n\"\n\t}", "positive_code": [{"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}, {"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\n\t@ans = ( $A[$x][$y] = 1 );\n\n\tfor (<>=~ /./g){\n\t\t$x += /D/ - /U/;\n\t\t$y += /R/ - /L/;\n\t\t$x += ($x < 1) - ($x > $X);\n\t\t$y += ($y < 1) - ($y > $Y);\n\t\tpush @ans, 0 + ! $A[$x][$y] ++;\n\t}\n\n\t@ans[-1] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}\n"}], "negative_code": [{"source_code": "while(<>){\n\t($X, $Y, $x, $y) = split;\n\t@_ =<>=~ /./g;\n\n\t@ans = (1);\n\tfor (@_){\n\t\tpush @ans, scalar do { if (0) { ; }\n\t\t\telsif (/D/) { $x + /D/ <= $X ? ($x ++, 1) : 0 }\n\t\t\telsif (/U/) { $x - /U/ >   0 ? ($x --, 1) : 0 }\n\t\t\telsif (/R/) { $y + /R/ <= $Y ? ($y ++, 1) : 0 }\n\t\t\telsif (/L/) { $y - /L/ >   0 ? ($y --, 1) : 0 }\n\t\t}\n\t}\n\n\t$ans[$#ans] += $X * $Y - grep $_, @ans;\n\tprint \"@ans\"\n\t}"}], "src_uid": "22bebd448f93c0ff07d2be91e873521c"}
{"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t@_=();\n\t$k-1 or @_=(1..$n) and (print \"@_\\n\") and next;\n\tfor ($k+1..$n){ push @_, $_}\n\t$j=0;\n\tfor (1..$k / 2){ ++$j; push @_, $j, $k-$j+1} \n\t$k % 2 and push @_, ++$j;\n\tprint \"@_\\n\";\n\t}", "positive_code": [{"source_code": "use v5.10;\n\n($n, $k) = split / /, <>;\n($b, $e) = (1, $n);\nwhile ($k > 0) {\n\tif ($k == 1) {\n\t\tfor ($i=$b; $i<=$e; ++$i) {\n\t\t\tpush @ans, $i;\n\t\t}\n\t\tlast;\n\t} else {\n\t\tpush @ans, $b++;\n\t}\n\t--$k;\n\tif ($k == 1) {\n\t\tfor ($i=$e; $i>=$b; --$i) {\n\t\t\tpush @ans, $i;\n\t\t}\n\t\tlast;\n\t} else {\n\t\tpush @ans, $e--;\n\t}\n\t--$k;\n}\nsay join \" \", @ans;\n"}], "negative_code": [{"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t@_=();\n\tfor ($k..$n){ push @_, $_}\n\t$j=1;\n\tfor (1..$k-1){ ++$j; push @_, ($j % 2 ? $n+1 : 0)+(-1)**$j*$_}\n\tprint \"@_\\n\";\n\t}"}], "src_uid": "18b3d8f57ecc2b392c7b1708f75a477e"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nmy $samount = <STDIN>;\nmy $sessions = <STDIN>;\nmy @sessions = split( ' ', $sessions );\nmy $pairs = 0;\nmy $impossible = 0;\nmy %temp;\nforeach ( @sessions )\n{\n\tif ( $_ != 0 ) {\n\t    if ( $temp{ $_ } ) { $temp{ $_ } = $temp{ $_ } + 1 } else { $temp{ $_ } = 1 };\n\t    if ( $temp{ $_ } > 2 ) { $impossible = 1; }\n\t    elsif ( $temp{ $_ } == 2 ) { $pairs++; }\n\t}\n}\nprint ($impossible ? '-1' : $pairs).\"\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse warnings;\nuse utf8;\nuse strict;\n\nmy $n = <STDIN>;\nchomp ($n = <STDIN>);\n\nmy %calls;\n\nmy @data = split(' ', $n);\n\nforeach (@data) {\n\tif ($_ != 0) {\n\t\t$calls{$_}++;\n\t}\n}\n\nmy $total = 0;\n\nforeach (values %calls) {\n\tif ($_ > 2) {\n\t\tprint \"-1\\n\";\n\t\texit(0);\n\t} if ($_ == 2) {\n\t\t$total++;\n\t}\n}\n\nprint \"$total\\n\";\n\n"}, {"source_code": "$n=<>;\n@n=split ' ',<>;\n$a{$_}++ for (@n);\n$i=0;\nundef $a{0};\nfor (values %a) {\nif ($_>2) {\nprint -1;\nexit 0;\n}\n$i++ if ($_==2);\n}\nprint $i;"}], "negative_code": [], "src_uid": "45e51f3dee9a22cee86e1a98da519e2d"}
{"source_code": "#!/bin/perl\n\nmy ($n) = split /\\s/, <>;\nmy @in = split /\\s/, <>;\nmy @first, @second;\n@in = sort {$a <=> $b} @in;\npush @in, @in[-1];\nfor (my $i = 0; $i < $n; ++$i) {\n    my $k = @in[$i];\n    push @first, $k;\n    if (@in[$i] == @in[$i + 1]) {\n        push @second, $k;\n        while ($i < $n && @in[$i] == @in[$i + 1]) {\n            ++$i;\n        }\n    }\n}\n@second = reverse @second;\nshift @second if @second && @second[0] == @first[-1];\nprint @first + @second . \"\\n\" . join(\" \", (@first, @second)) . \"\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nmy $m=<STDIN>;\nchomp($m);\nmy $in=<STDIN>;\nchomp($in);\nmy @arr=split(' ',$in);\n@arr=sort {$a<=>$b}@arr;\nmy @output;\n@arr=reverse(@arr);\nmy $a=$b=$arr[0];\npush @output,$arr[0];\nfor my $i (1..$m-1){\n\tif($arr[$i]<$a){\n\tunshift @output,$arr[$i];\n\t$a=$arr[$i];\n\t}\n\telsif($arr[$i]<$b)\n\t{\n\tpush @output,$arr[$i];\n\t$b=$arr[$i];\n\t}\n}\nmy $sz=scalar(@output);\nprint \"$sz\\n\";\nfor my $i (0..$sz-1)\n{\nprint \"$output[$i] \";\n}\nprint \"\\n\";\nexit;\n"}, {"source_code": "#!/usr/bin/perl\n\n#方針\n#多少処理が遅くてもいいので、\n#パッと見てわかるプログラムを目指す。\n#perl -e '<>;@d=sort{$b<=>$a}split(\" \",<>);@v=($d[0]);map{($_<$v[$#v]&&push(@v,$_))or$_<$v[0]&&unshift(@v,$_)}@d;$n=@v;print $n,\"\\n\",\"@v\",\"\\n\"'\n\nuse strict;\nuse warnings;\n\nmy $num = <>;\nmy $line = <>;\nchomp($line);\n\nmy @vals = split \" \", $line;\n\n#降順でソート\n@vals = sort{$b <=> $a} @vals;\n\n#初期化。一番大きい値だけを持つ配列を作る。\nmy $val = shift @vals;\nmy @answer = ($val);\n\n#値を大きい順に検索し、\n#右端より小さければ右端に結合、\n#左端より小さければ左端に結合を繰り返す。\nforeach $val (@vals){\n    if($val < $answer[$#answer]){\n        push(@answer, $val);\n    }elsif($val < $answer[0]){\n        unshift(@answer, $val);\n    }\n}\n\n$num = @answer;\nprint $num,\"\\n\";\nprint \"@answer\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $line1 = <>;\nmy $line2 = <>;\nchomp($line1);\nchomp($line2);\n\nmy $m = $line1;\nmy @cards = split(/ /, $line2);\n\nmy $max_value = 0;\nmy $res_num = $m;\nmy @cards_num = ();\n\nforeach (@cards) {\n    if (defined($cards_num[$_])) {\n        $cards_num[$_]++;\n        if ($cards_num[$_] > 2) { $res_num--; }\n    } else {\n        $cards_num[$_] = 1;\n    }\n    if ($_ > $max_value) { $max_value = $_; }\n}\n\nif ($cards_num[$max_value] > 1) { $res_num--; };\n$cards_num[$max_value] = 1;\n\nprint \"$res_num\\n\";\n$cards_num[$max_value] = 1;\nfor (my $i = 1; $i <= $max_value; $i++) {\n    if (defined($cards_num[$i])) {\n        print \"$i\";\n        if ($res_num > 1) {\n            print \" \";\n            $res_num--;\n        } else {\n            print \"\\n\";\n            exit;\n        }\n        if ($cards_num[$i] == 1) { $cards_num[$i] = (undef); }\n    }\n}\nfor (my $i = $max_value; $i >= 1; $i--) {\n    if (defined($cards_num[$i])) {\n        print \"$i\";\n        if ($res_num > 1) {\n            print \" \";\n            $res_num--;\n        } else {\n            print \"\\n\";\n            exit;\n        }\n    }\n}"}], "negative_code": [{"source_code": "#!/bin/perl\n\nmy ($n) = split / /, <>;\nmy @in = split / /, <>;\nmy @first, @second;\n@in = sort @in;\npush @in, @in[-1];\nfor (my $i = 0; $i < $n; ++$i) {\n    my $k = @in[$i];\n    push @first, $k;\n    if (@in[$i] == @in[$i + 1]) {\n        push @second, $k;\n        while ($i < $n && @in[$i] == @in[$i + 1]) {\n            ++$i;\n        }\n    }\n}\n@second = reverse @second;\nshift @second if @second && @second[0] == @first[-1];\nprint @first + @second . \"\\n\" . join(\" \", (@first, @second)) . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $line1 = <>;\nmy $line2 = <>;\nchomp($line1);\nchomp($line2);\n\nmy $m = $line1;\nmy @cards = split(/ /, $line2);\n\nmy $max_value = 0;\nmy $res_num = $m;\nmy @cards_num = ();\n\nforeach (@cards) {\n    if (defined($cards_num[$_])) {\n        if ($cards_num[$_] > 2) { $res_num--; }\n        else { $cards_num[$_] ++; }\n    } else {\n        $cards_num[$_] = 1;\n    }\n    if ($_ > $max_value) { $max_value = $_; }\n}\nif ($cards_num[$max_value] > 1) {\n    $res_num--;\n    $cards_num[$max_value] = 1;\n}\n\nprint \"$res_num\\n\";\nfor (my $i = 1; $i <= $max_value; $i++) {\n    if (defined($cards_num[$i])) {\n        print \"$i\";\n        if ($res_num > 1) {\n            print \" \";\n            $res_num--;\n        } else {\n            print \"\\n\";\n            exit;\n        }\n        if ($cards_num[$i] == 1) { $cards_num[$i] = (undef); }\n    }\n}\nfor (my $i = $max_value; $i >= 1; $i--) {\n    if (defined($cards_num[$i])) {\n        print \"$i\";\n        if ($res_num > 1) {\n            print \" \";\n            $res_num--;\n        } else {\n            print \"\\n\";\n            exit;\n        }\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse Data::Dumper;\n\nmy $line1 = <>;\nmy $line2 = <>;\nchomp($line1);\nchomp($line2);\n\nmy $m = $line1;\nmy @cards = split(/ /, $line2);\n\nmy $max_value = 0;\nmy $res_num = $m;\nmy @cards_num = ();\n\nforeach (@cards) {\n    if (defined($cards_num[$_])) {\n        $cards_num[$_]++;\n    } else {\n        $cards_num[$_] = 1;\n    }\n    if ($_ > $max_value) { $max_value = $_; }\n}\n$res_num = $#cards_num * 2 - 1;\n\nprint \"$res_num\\n\";\n$cards_num[$max_value] = 1;\nfor (my $i = 1; $i <= $max_value; $i++) {\n    if (defined($cards_num[$i])) {\n        print \"$i\";\n        if ($res_num > 1) {\n            print \" \";\n            $res_num--;\n        } else {\n            print \"\\n\";\n            exit;\n        }\n        if ($cards_num[$i] == 1) { $cards_num[$i] = (undef); }\n    }\n}\nfor (my $i = $max_value; $i >= 1; $i--) {\n    if (defined($cards_num[$i])) {\n        print \"$i\";\n        if ($res_num > 1) {\n            print \" \";\n            $res_num--;\n        } else {\n            print \"\\n\";\n            exit;\n        }\n    }\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nmy $m=<STDIN>;\nmy @arr;\nfor my $i (0..$m-1)\n{\n        $arr[$i]=<STDIN>;\n       chomp($arr[$i]);\n}\n@arr=sort {$a<=>$b}@arr;\nmy @output;\n@arr=reverse(@arr);\nmy $a=$b=$arr[0];\npush @output,$arr[0];\nfor my $i (1..$m-1){\n        if($arr[$i]<$a){\n        unshift @output,$arr[$i];\n        $a=$arr[$i];\n        }\n        elsif($arr[$i]<$b)\n        {\n        push @output,$arr[$i];\n        $b=$arr[$i];\n        }\n}\nmy $sz=scalar(@output);\nprint \"$sz\\n\";\nfor my $i (0..$sz-1)\n{\nprint \"$output[$i] \";\n}\nprint \"\\n\";\nexit;\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nmy $m=<STDIN>;\nmy @arr;\nfor my $i (0..$m-1)\n{\n        $arr[$i]=<STDIN>;\n       chomp($arr[$i]);\n}\n@arr=sort {$a<=>$b}@arr;\nmy @output;\n@arr=reverse(@arr);\nmy $a=$b=$arr[0];\npush @output,$arr[0];\nfor my $i (1..$m-1){\n        if($arr[$i]<$a){\n        unshift @output,$arr[$i];\n        $a=$arr[$i];\n        }\n        elsif($arr[$i]<$b)\n        {\n        push @output,$arr[$i];\n        $b=$arr[$i];\n        }\n}\nmy $sz=@output;\nprint \"$sz\\n\";\nmy $sz=@output;\nprint \"$sz\\n\";\nfor my $i (0..$#output)\n{\nprint \"$output[$i] \";\n}\nprint \"\\n\";\nexit;\n"}], "src_uid": "5c63f91eb955cb6c3172cb7c8f78976c"}
{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp(my $n = <>);\nmy @a = (0, 0);\nmy @b = (0, 0);\nfor (1 .. $n) {\n    chomp($_ = <>);\n    my ($server, $succ, $fail) = split;\n    $a[$server - 1] += $succ;\n    $b[$server - 1] += 10;\n}\nfor my $i (0 .. 1) {\n    my $res = $a[$i] * 2 >= $b[$i] ? 'LIVE' : 'DEAD';\n    print $res, \"\\n\";\n}\n", "positive_code": [{"source_code": "while (<>){\n    $a=$b=$A=$B=0;\n    for (1..$_){\n        <>=~/ (\\d+) /;\n        $`-1 and ++$b and $B+=$1;\n        $`-1 and next;\n        ++$a and $A+=$1\n        }\n    print $a*5 <= $A ?\"LIVE\\n\":\"DEAD\\n\";\n    print $b*5 <= $B ?\"LIVE\\n\":\"DEAD\\n\"\n    }"}], "negative_code": [], "src_uid": "1d8870a705036b9820227309d74dd1e8"}
{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\t\r\n\tprint 3 * ( 10 - @_ ) * ( 9 - @_ ) . $/\r\n\t}", "positive_code": [{"source_code": "<>; $i ++ & 1 && print 3 * ( 10 - split ) * ( 9 - split ) . $/ for <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy @A = '0000' .. '9999';\n@A = grep { m/(.)(.)\\1\\2/ || m/(.)(.)\\2\\1/ || m/(.)\\1(.)\\2/ } @A;\n@A = grep !m/(.)\\1{3}/, @A;\n\nprint for @_;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tprint 0 + grep { !m/[@_]/ } @A;\n\t}"}, {"source_code": "for(1..<>){$_=10-<>;print$_*3*($_-1),\" \";<>}"}, {"source_code": "for(1..<>){$_=10-<>;print$_*3*($_-1),\" \";<>}"}, {"source_code": "for(1..<>){$_=10-<>;print$_*3*($_-1),\" \";<>}"}, {"source_code": "for(1..<>){$_=10-<>;print$_*3*($_-1),\" \";<>}"}, {"source_code": "for(1..<>){$_=10-<>;print$_*3*($_-1),\" \";<>}"}, {"source_code": "for(1..<>){$_=10-<>;print$_*3*($_-1),\" \";<>}"}], "negative_code": [], "src_uid": "33e751f5716cbd666be36ab8f5e3977e"}
{"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    \n    chomp;\n    $i=0;\n    @m=split//;\n    for (1..@m){\n        if ($m[$_] eq $m[$_-1]) {\n            $m[$_-1]=$i++;\n            }\n        else{\n            $m[$_-1]=$i;\n        }\n    }\n    \n    for (1..<>){\n        $_=<>;\n        / /;\n        print $m[$'-1]-$m[$`-1],\"\\n\";\n        \n        }\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($line = <>);\n$len = length $line;\n@dp = (0) x ($len+1);\n@a = split //, 'x' . $line . 'x';\n$a[$_] eq $a[$_+1] and $dp[$_]=$dp[$_-1]+1 or $dp[$_]=$dp[$_-1]  foreach (1 .. $len);\nchomp($q = <>);\nwhile ($q-- > 0) {\n\t($l, $r) = split / /, <>;\n\tsay ($dp[$r-1] - $dp[$l-1]);\n}"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nchomp (my $s = <>);\n\nmy @eq = (0);\n\nfor my $i (0..length($s) - 2) {\n  push @eq, $eq[-1] + (substr($s, $i, 1) eq substr($s, $i + 1, 1) ? 1 : 0);\n}\n\nmy $m = <>;\nfor (1..$m) {\n  my ($l, $r) = split ' ', <>;\n  say $eq[$r - 1] - $eq[$l - 1];\n}\n"}, {"source_code": "use warnings;\nuse strict;\n\nmy @a = split //, <>;\nmy @s;\nfor (0..@a-2) {\n  $s[$_] = 0;\n  $s[$_] += 1 if $a[$_] eq $a[$_+1];\n  $s[$_] += $s[$_-1] if $_;\n}\npush @s, 0;\n\nfor (1..int <>) {\n  my ($l, $r) = map {int $_-1} split (/\\s/, <>);\n  print $s[$r-1] - $s[$l-1], \"\\n\";\n}\n"}], "negative_code": [], "src_uid": "b30e09449309b999473e4be6643d68cd"}
{"source_code": "for(1..<>){print\"$_ \"for(2..<>);print\"1 \"}", "positive_code": [{"source_code": "for(1..<>){print\"$_ \"for(2..<>);print\"1 \"}"}, {"source_code": "for(1..<>){print\"$_ \"for(2..<>);print\"1 \"}"}, {"source_code": "$\\ = $/;\r\n\r\n<>; print join ' ', 2 .. $_, 1 for <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tprint join ' ', 1, reverse 2 .. $_;\n\t}"}], "negative_code": [{"source_code": "for(1..<>){print\"$_ \"for(2..<>);print\"1\"}"}], "src_uid": "6fced7d8ac3dd58b1791430ada53332d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t$_ --;\n\t\n\t\n\tif( $_ == 2 ){\n\t\tprint '1 0 2';\n\t\tnext;\n\t\t}\n\t\n\tmy $i = 1;\n\t\n\twhile( $i * 2 < $_ + 1 ){\n\t\t$i *= 2;\n\t\t}\n\t\n\tprint join ' ', 1 .. $i - 1, 0, $i .. $_;\n\t}", "positive_code": [{"source_code": "for(1..<>) {\r\n        chomp (my $n = <>);\r\n        my $i = 0;\r\n        while(2**$i < $n){$i++;}\r\n        $x = 2**($i-1);\r\n        for (my $i = 1; $i < $x; $i++) {\r\n                print \"$i \";\r\n        }\r\n        print \"0 \";\r\n        for (my $i = $x; $i < $n; $i++) {\r\n                print \"$i \";\r\n        }\r\n        print \"\\n\";\r\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t$_ --;\n\t\n\t\n\tif( $_ == 2 ){\n\t\tprint '1 0 2';\n\t\tnext;\n\t\t}\n\t\n\tmy $i = 1;\n\t\n\twhile( $i * 2 < $_ ){\n\t\t$i *= 2;\n\t\t}\n\t\n\tprint join ' ', 1 .. $i - 1, 0, $i .. $_;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t$_ --;\n\t\n\t\n\tif( $_ == 2 ){\n\t\tprint '0 2 1';\n\t\tnext;\n\t\t}\n\t\n\tmy $i = 1;\n\t\n\twhile( $i * 2 < $_ ){\n\t\t$i *= 2;\n\t\t}\n\t\n\tprint join ' ', 1 .. $i - 1, 0, $i .. $_;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t$_ --;\n\t\n\tmy $i = 1;\n\t\n\twhile( $i * 2 < $_ ){\n\t\t$i *= 2;\n\t\t}\n\t\n\tprint join ' ', 1 .. $i - 1, 0, $i .. $_;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tif( $_ == 2 ){\n\t\tprint '0 1';\n\t\tnext;\n\t\t}\n\t\n\tmy $i = 1;\n\t\n\twhile( $i * 2 < $_ ){\n\t\t$i *= 2;\n\t\t}\n\t\n\tprint join ' ', 1 .. $i - 1, 0, $i .. $_;\n\t}"}], "src_uid": "b6e758c75d0e3037a1500bbe652f6126"}
{"source_code": "$\\ = $/;\nwhile(<>){\n    ($n, $m, $k) = split;\n    $a = 0;\n    undef *A;\n    for $_ (1 .. $k){\n    ($i, $j) = split \" \", <>;\n    $A[ $i ][ $j ] = 1;\n    (\n    $A[ $i-1 ][ $j ] and $A[ $i ][ $j-1 ] and $A[ $i-1 ][ $j-1 ] or\n    $A[ $i+1 ][ $j ] and $A[ $i ][ $j+1 ] and $A[ $i+1 ][ $j+1 ] or\n    $A[ $i-1 ][ $j ] and $A[ $i ][ $j+1 ] and $A[ $i-1 ][ $j+1 ] or\n    $A[ $i+1 ][ $j ] and $A[ $i ][ $j-1 ] and $A[ $i+1 ][ $j-1 ]\n    )\n    and $a ||= $_\n    }\n    print $a\n   }", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($n, $m, $k) = split / /, <>;\n\nsub judge {\n\tmy ($x, $y) = (shift, shift);\n\treturn $x>=0 && $x<$n && $y>=0 && $y<$m;\n}\n\npush @M, [(0) x ($m+2)] foreach (0 .. $n+1);\nforeach $i (1 .. $k) {\n\t($x, $y) = split / /, <>;\n\t$M[$x][$y] = 1;\n\t$M[$x][$y] and $M[$x-1][$y] and $M[$x][$y-1] and $M[$x-1][$y-1] and say $i and exit;\n\t$M[$x][$y] and $M[$x-1][$y] and $M[$x][$y+1] and $M[$x-1][$y+1] and say $i and exit;\n\t$M[$x][$y] and $M[$x+1][$y] and $M[$x][$y+1] and $M[$x+1][$y+1] and say $i and exit;\n\t$M[$x][$y] and $M[$x+1][$y] and $M[$x][$y-1] and $M[$x+1][$y-1] and say $i and exit;\n}\nsay 0;"}, {"source_code": "($n, $m, $k) = split \" \", <>;\nfor (<>){\n    ($i, $j) = split;\n    $v++;\n    $A[ $i ][ $j ] = 1;\n    $A = 0;\n    \t$ii = $i + (.5 <=> $_ % 2),\n    \t$jj = $j + (.5 <=> $_ % 3),\n    \t$A ||=\n    \t$A[ $ii ][ $j ] &&\n    \t$A[ $i ][ $jj ] && \n    \t$A[ $ii ][ $jj ]\n    \tfor 0 .. 3;\n    $A and $a //= $v\n    }\nprint 0 + $a"}], "negative_code": [], "src_uid": "0dc5469831c1d5d34aa3b7b172e3237b"}
{"source_code": "$\\ = $/;\n\n$_ = <>;\n\nfor $i ( 0 .. $_ ** 2 - 1 ){\n\tpush @{ $_[ 4 * int( $i / ( 4 * $_ ) ) + $i % 4 ] }, $i;\n\t}\n\nprint \"@{ $_ }\" for @_", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile( my $n = <> ){\n\t$debug and print '-' x 15;\n\tchomp $n;\n\t\n\tmy $s = 0;\n\t\n\t@_ = ();\n#\tmy @xhor = ();\n#\tmy @xver = ();\n\t\n#\tfor my $i ( 0 .. $n ** 2 - 1 ){\n#\t\tpush @{ $_[ $i / $n ] }, sprintf \"%0${n}b\", $s;\n#\t\t$xhor[ $i / $n ] ^= $i;\n#\t\t$xver[ $i % $n ] ^= $i;\n#\t\t$s ++;\n#\t\t}\n\t\n\tfor my $i ( 0 .. $n ** 2 - 1 ){\n\t#\tpush @{ $_[ 4 * int( $i / ( 4 * $n ) ) + $i % 4 ] }, sprintf \"%0${n}b\", $s;\n\t\tpush @{ $_[ 4 * int( $i / ( 4 * $n ) ) + $i % 4 ] }, $s;\n\t#\t$xhor[ $i / $n ] ^= $i;\n\t#\t$xver[ $i % $n ] ^= $i;\n\t\t$s ++;\n\t\t}\n\t\n#\t$debug and print \"@{ $_ }\" for @_;\n\t\n#\t$debug and print \"@xhor\";\n#\t$debug and print join \" \", map { sprintf \"%0${n}b\", $_ } @xhor;\n#\t$debug and print \"@xver\";\n#\t$debug and print join \" \", map { sprintf \"%0${n}b\", $_ } @xver;\n\t\n\tprint \"@{ $_ }\" for @_;\n\t}"}], "negative_code": [{"source_code": "$_ = <>;\n\nfor $i ( 0 .. $n ** 2 - 1 ){\n\tpush @{ $_[ 4 * int( $i / ( 4 * $n ) ) + $i % 4 ] }, $i;\n\t}\n\nprint join \"\\n\", @_"}], "src_uid": "38ee7fc4cd2d019aa9e5b33d8bea4a2f"}
{"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3", "positive_code": [{"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}, {"source_code": "$\\ = $/;\n\n$n = 1e3;\n\nprint 2 * $n;\n\nprint join \" \", $_, 1, $_, 2 for 1 .. $n, reverse 1 .. $n"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3"}, {"source_code": "print 2e3, $/, map \"$_ 1 $_ 2\\n\", 1 .. 1e3, reverse 1 .. 1e3\n"}], "negative_code": [{"source_code": "$\\ = $/;\n\nprint 2000;\n\nprint join $/, (join $\", $_, 1, $_, 2) x 2 for 1 .. 1000"}], "src_uid": "19190fd248eb2c621ac2c78b803049a8"}
{"source_code": "<>;\n\n$_ = <>, chomp;\n\t\n$e = '.';\n\nwhile( $_ ){\n\t$i++ % 2 ? $e =~ s/(?=\\.)/chop/e : $e =~ s/\\.\\K/chop/e;\n\t\n\t}\n\nprint $e =~ y/.//dr", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\t$e = '.';\n\t$i = 0;\n\t\n\twhile( $_ ){\n\t\t$i++ % 2 ? $e =~ s/(?=\\.)/chop $_/e : $e =~ s/\\.\\K/chop $_/e;\n\t\t\n\t\t}\n\t\n\t\n\tprint $e =~ y/.//dr\n\t}"}, {"source_code": "<>;\n\n$_ = chop( $e = <> );\n\ns/\\n\\K/chop $e/e, s/$/chop $e/em while $e;\n\nprint split"}, {"source_code": "<>;\n\nchomp($e = <>);\n\t\n$_ = '.';\n\ns/\\.\\K/chop $e/e, s/(?=\\.)/chop $e/e while $e;\n\nprint y/.//dr"}, {"source_code": "<>;\n\n$_ = chop( $e = <> );\n\ns/\\n\\K/chop $e/e, s/(?=\\n)/chop $e/e while $e;\n\nprint split"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\t$e = '';\n\t\n\twhile( $_ ){\n\t\t$e .= substr $_, (length) / 2, 1, '';\n\t\t\n\t\t\n\t\t}\n\t\n\t\n\tprint $e\n\t}"}, {"source_code": "<>;\n\nchomp($e = <>);\n\t\n$_ = '.';\n\ns/(?=\\.)/chop $e/e, $_ = reverse while $e;\n\nprint y/.//dr"}], "src_uid": "2a414730d1bc7eef50bdb631ea966366"}
{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\n#1\n\n#my ($a, $b) = split /\\D/, <>;\n#my $n = $b - $a * 2;\n#print $a - $n;\n\n# 2\n\n<>;\nmy @arr = split /\\D/, <>;\nfor my $i ( 0 .. @arr - 1 ) {\n\tmy $len = $arr[$i];\n\tprint lcm( $len + 1, $len * 4 ) / ( $len + 1 ) + 1, \"\\n\";\n}\n\nsub lcm {\n\tmy ( $a, $b ) = @_;\n\treturn $a / gcd( $a, $b ) * $b;\n}\n\nsub gcd {\n\tmy ( $a, $b ) = @_;\n\tmy $g = $b;\n\twhile ( $a > 0 ) {\n\t\t$g = $a;\n\t\t$a = $b % $a;\n\t\t$b = $g;\n\t}\n\treturn $g;\n}\n\n", "positive_code": [{"source_code": "<>;\n$_=<>;\ns/\\d+/($&+1)%4?(($&+1)%2?($&*4+1):($&*2+1)):($&+1)/eg;\ns/ /\\n/g;\nprint"}], "negative_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n#my ($a, $b) = split /\\D/, <>;\n#my $n = $b - $a * 2;\n#print $a - $n;\n\nmy $n = <>;\nmy @arr = split /\\D/, <>;\nfor my $i (0..@arr-1) {\n\tprint 5 + 4 * ($arr[$i]-1), \"\\n\";\n} "}, {"source_code": "<>;\n$_=<>;\ns/\\d+/$&*4+1/eg;\ns/ /\\n/g;\nprint"}], "src_uid": "168dbc4994529f5407a440b0c71086da"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$n=<>;\n@_=<>;\n$_=pop @_;\nchomp;\nchomp(@_);\n$s=join\"<3\",@_;\n$s=\"<3\".$s.\"<3\";\n@_=split//,$s;\n@a=split//,$_;\nfor $i(@_){\n\t@a or $F++;\n\twhile (@a){\n\t\t$p=shift @a;\n\t\t$i eq $p and last;\n\t\t}\n\t}\n\nprint $F?\"no\":\"yes\";", "positive_code": [{"source_code": "<>;\n@_=<>;\nchomp(@_);\n$t=pop @_;\n$s='<3'.(join'<3',@_).'<3';\n@s=split'',$s;\n@t=split'',$t;\nfor(@s) {\n  @t or $F++ or last;\n  while(@t){\n    $_ eq shift @t and last;\n  }\n}\nprint $F?'no':'yes';\n"}, {"source_code": "<>;@_=<>;chomp(@_);\n@t=split'',pop @_;\nfor(split'','<3'.(join'<3',@_).'<3'){\n  @t or $F++ or last;\n  while(@t){\n    $_ eq shift @t and last;\n  }\n}\nprint $F?'no':'yes';\n"}, {"source_code": "$n=<>;\nwhile($n--){\n  $_=<>;\n  chomp;\n  $s.='<3'.$_;\n}\n$s.='<3';\n$t=<>;\n#print \"s->$s<\\n\";\n@s=split '',$s;\n@t=split '',$t;\nfor($i=0,$j=0;$i<@s;++$i) {\n  for(;$j<@t;++$j) {\n    if($s[$i]eq$t[$j]) {\n      ++$j;\n      ++$cnt;\n      last;\n    }\n  }\n}\n#print \"lens=\",scalar @s,\"\\n\";\nprint $cnt==@s?'yes':'no';\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$n=<>;\n@_=<>;\n$_=pop @_;\nchomp;\nchomp(@_);\n$s=join\"<3\",@_;\n$s=\"<3\".$s.\"<3\";\n@_=split//,$s;\n@a=split//,$_;\nfor $i(@_){\n\t@a or $F++ or last;\n\t\twhile (@a){\n\t\t$p=shift @a;\n\t\t$i eq $p and last;\n\t\t}\n\t}\n\nprint $F?\"no\":\"yes\";"}], "negative_code": [{"source_code": "$n=<>;\nwhile($n--){\n  $_=<>;\n  chomp;\n  push @a,$_;\n}\n$s='<3'.(join '<3',@a).'<3';\n$t=<>;\n#print \"$s\\n\";\n@s=split '',$s;\n@t=split '',$t;\nfor($i=0,$j=0;$i<@s;++$i) {\n  for(;$j<@t;++$j) {\n    if($s[$i]eq$t[$j]) {\n      ++$cnt;\n      last;\n    }\n  }\n}\nprint $cnt==@s?'yes':'no';\n"}], "src_uid": "36fb3a01860ef0cc2a1065d78e4efbd5"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\nuse integer;   ### important!\r\nmy $mod = 10 ** 9 + 7;\r\n# my $mod = 998244353;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my @s = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @x = ();\r\n  for(my $i=0;$i<4;$i++){\r\n    push(@x,+[$s[$i],$i]);\r\n  }\r\n  my @sa = sort { $a->[0] <=> $b->[0] } @x;\r\n  if( $sa[0]->[1] / 2 == $sa[1]->[1] / 2 ){\r\n    print \"NO\\n\";\r\n  } else {\r\n    print \"YES\\n\";\r\n  }\r\n  \r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "use List::Util qw (max);\r\nfor (1..<>) {\r\n        chomp (my $in = <>);\r\n        my ($p, $q, $c, $d) = split / /, $in;\r\n        my @z = split / /, $in;\r\n        @z = sort {$a <=> $b} @z;\r\n\r\n        $x = max($p, $q);\r\n        $y = max($c, $d);\r\n        if (($x == @z[2] && $y == @z[3]) || ($x == @z[3] && $y == @z[2])) {\r\n                print \"YES\\n\";\r\n        } else {\r\n                print \"NO\\n\";\r\n        }\r\n}"}], "negative_code": [], "src_uid": "cb24509580ff9b2f1a11103a0e4cdcbd"}
{"source_code": "#!usr/bin/perl -w\nuse strict;\n\nmy ($n,$k)=split/ /,<STDIN>;chomp($k);\nmy $t=<STDIN>;chomp($t);\nmy @f;my $j=0;\nmy @g=split//,$t;\n$f[0]=0;\nmy $i=1;\nwhile($i<$n){\n    while($i<$n&&$g[$i] eq $g[$j]){\n\tpush @f,++$j;\n\t$i++;\n    }\n    if($j==0){\n\tpush @f,0;\n\t$i++;\n    }\n    $j=$f[$j-1] if($j!=0);\n}\nmy $out=$t;\n$out.=substr($t,$f[-1],$n)x($k-1);\nprint \"$out\\n\";", "positive_code": [{"source_code": "$/ = \"\"; $_ = <>; ($x, $k, $_) = split;\n$x = substr($_, ++$i) until /^$x/;\nprint $x, $' x $k;"}], "negative_code": [{"source_code": "$/ = \"\"; $_ = <>; ($n, $k, $t) = split;\n$f = \"\\xff\";\n$s = $f x $n;\n$i = $t;\nwhile ($k) {\n\tif (($s & $i) =~ /$t$/) {\n\t\t$s &= $i;\n\t\t$k--;\n\t}\n\t$s = $s . $f;\n\t$i = $f . $i;\n}\t\n$s =~ s/$f//g;\nprint $s;\n"}, {"source_code": "($x, $k) = split \" \", <>; $_ = <>;\n$x = substr($_, ++$i) until /^$x/;\nprint $x, $' x $k;\n"}], "src_uid": "34dd4c8400ff7a67f9feb1487f2669a6"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tprint +( () = /N/g ) - 1 ? \"YES\" : \"NO\";\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tprint do {\n\t\tif( m/^E+N$/ || m/^NE+$/ || m/^E+NE+$/ ){\n\t\t\t\"NO\";\n\t\t\t}\n\t\telse{\n\t\t\t\"YES\";\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "e744184150bf55a30568060cca69de04"}
{"source_code": "for(1..<>){<>;$s=<>;$s=~s/\\s.*//;print$s}", "positive_code": [{"source_code": "for(1..<>){<>;@a=split/\\s/,<>;print@a[0],\" \"}"}, {"source_code": "for(1..<>){<>;print\" \",split/\\s.*/,<>}"}], "negative_code": [], "src_uid": "329ac6671e26b73ab70749ca509f5b09"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n$_==1 and say -1 and exit foreach (split / /, <>);\nsay 1;", "positive_code": [{"source_code": "<>;\nprint ((<> =~ /\\b1\\b/) ? \"-1\\n\" : \"1\\n\");"}, {"source_code": "<>;\n$min = 10000000;\nfor (split / /, <>)\n{\n    $min = $_ if ($_ < $min)\n}\nprint (qw/1 -1/[$min == 1]);"}, {"source_code": "#!perl\n\n$n = <>;\n\n@a = split / /, <>;\n\nif (grep {$_ == 1} @a) \n{\n    print -1;\n}\nelse\n{\n    print 1;\n}"}, {"source_code": "<>;\n@a = sort (split(' ', <>));\nif($a[0] == 1){\n\tprint -1;}\nelse{\nprint 1;}"}, {"source_code": "<>;\n@a = split(/ /g, <>);\n@a = sort { $a <=> $b } @a;\nprint $a[0] == 1 ? -1 : 1;"}, {"source_code": "print .5 <=> (a.<>.<>) =~ /\\b1\\b/"}], "negative_code": [{"source_code": "<>;\nprint ((<> =~ /\\b1\\b/) ? \"1\\n\" : \"-1\\n\");"}, {"source_code": "$min = 10000000;\nfor (split / /, <>)\n{\n    $min = $_ if ($_ < $min)\n}\nprint (qw/1 -1/[$min == 1]);"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n$==1 and say -1 and exit foreach (split / /, <>);\nsay 1;"}, {"source_code": "<>;\n@a = sort (split(' ', <>));\n$s = 0;\nfor $i(@a){\n\tif($i > $s + 1){\n\t\tprint $s + 1;\n\t\texit;}\n\t$s += $i}\nprint -1;"}, {"source_code": "<>;\n@a = split(/ /g, <>);\nsort { $a <=> $b } @a;\nprint $a[0] == 1 ? -1 : 1;"}], "src_uid": "df94080c5b0b046af2397cafc02b5bdc"}
{"source_code": "chomp($n=<>);\nchomp($line=<>);\n@nums = split(\" \",$line);\n@F = (0) x $n;\n@L = (0) x $n;\n@R = (0) x $n;\n$p = $q = $c = $ans = 0;\nfor $i(0..$#nums){\n    $F[$i] = 1 if !$i or $nums[$i] > $nums[$i-1];\n    $L[$i] += $p;\n    $p = $F[$i] ? $p + 1 : 1;\n}\nfor $i(reverse(0..$#nums)){\n    $R[$i] += $q;\n    $q = $i + 1 < $n && $nums[$i] < $nums[$i + 1] ? $q + 1 : 1;\n}\nfor $i(0..$#nums)\n{\n    if(!$i or $i + 1 == $n or $nums[$i + 1] - $nums[$i - 1] >= 2){\n        $c = $L[$i] + $R[$i] + 1;\n    }else {\n        $c = $R[$i] > $L[$i] ? $R[$i] + 1 : $L[$i] + 1;\n    }\n    $ans = $c if $c > $ans;\n}\nprint \"$ans\\n\";\n\n", "positive_code": [{"source_code": "chomp($n=<>);\nchomp($line=<>);\n@nums = split(\" \",$line);\n@F = (0) x $n;\n@L = (0) x $n;\n@R = (0) x $n;\n$p = $q = $c = $ans = 0;\nfor $i(0..$#nums){\n    $F[$i] = 1 if !$i or $nums[$i] > $nums[$i-1];\n    $L[$i] += $p;\n    $p = $F[$i] ? $p + 1 : 1;\n}\nfor $i(reverse(0..$#nums)){\n    $R[$i] += $q;\n    #$q = $F[$i] ? $q + 1 : 1;\n    $q = $i + 1 < $n && $nums[$i] < $nums[$i + 1] ? $q + 1 : 1;\n}\nfor $i(0..$#nums)\n{\n    if(!$i or $i + 1 == $n or $nums[$i + 1] - $nums[$i - 1] >= 2){\n        $c = $L[$i] + $R[$i] + 1;\n    }else {\n        $c = $R[$i] > $L[$i] ? $R[$i] + 1 : $L[$i] + 1;\n    }\n    $ans = $c if $c > $ans;\n}\nprint \"$ans\\n\";\n\n"}, {"source_code": "chomp($n=<>);\nchomp($line=<>);\n@nums = split(\" \",$line);\n@F = (0) x $n;\n@L = (0) x $n;\n@R = (0) x $n;\n$p = $q = $c = $ans = 0;\nfor $i(0..$#nums){\n    $F[$i] = 1 if !$i or $nums[$i] > $nums[$i-1];\n    $L[$i] += $p;\n    $p = $F[$i] ? $p + 1 : 1;\n}\nfor $i(reverse(0..$#nums)){\n    $R[$i] += $q;\n    #$q = $F[$i] ? $q + 1 : 1;\n    $q = $i + 1 < $n && $nums[$i] < $nums[$i + 1] ? $q + 1 : 1;\n}\n#print \"@F\\n@L\\n@R\\n\";\n\nfor $i(0..$#nums)\n{\n    if(!$i or $i + 1 == $n or $nums[$i + 1] - $nums[$i - 1] >= 2){\n        $c = $L[$i] + $R[$i] + 1;\n    }else {\n        $c = $R[$i] > $L[$i] ? $R[$i] + 1 : $L[$i] + 1;\n    }\n    $ans = $c if $c > $ans;\n    #print \"cur ans = $ans\\n\";\n}\nprint \"$ans\\n\";\n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/446/A\n# http://codeforces.com/blog/entry/13036\n\n\nmy $n = <STDIN>;\nmy $f = <STDIN>;\nchomp ( $n, $f );\nmy @seq = split m/ /, $f;\n\n\n\nmy @left, @right;\nmy $cnt = 1;\n$left[0] = 1;\n\nfor ( my $i = 1; $i < @seq; $i += 1 ) {\n    if ( $seq[ $i-1 ] < $seq[ $i ] ) {\n\t$cnt += 1;\n\t$left[ $i ] = $cnt; }\n    else { \n\t$cnt = 1;\n\t$left[ $i ] = $cnt; }}\n\n$right[ @seq-1 ] = 1;\n$cnt = 1;\nfor ( my $i = @seq-2; $i >= 0; $i -= 1 ) {\n    if ( $seq[ $i ] < $seq[ $i+1 ] ) {\n\t$cnt += 1;\n\t$right[ $i ] = $cnt; }\n    else { \n\t$cnt = 1;\n\t$right[ $i ] = $cnt; }}\n\nmy $mx = 0;\nfor ( my $i = 0; $i < @seq-2; $i += 1 ) {\n    if ( $seq[ $i ] + 1 < $seq[ $i+2 ] ) {\n\tif ( $left[ $i ] + 1 + $right[ $i+2 ] > $mx ) {\n\t    $mx = $left[ $i ] + 1 + $right[ $i+2 ]; }}}\n\n\n\nmy $ww = 0;\nfor (@left) {\n    if ( $_ > $ww ) {\n\t$ww = $_; }}\nif ( $ww < @left ) {\n    $ww += 1; }\nif ( $ww > $mx ) { $mx = $ww; }\n\n\n\nif ( $n < 3 ) { print \"$n\\n\"; }\nelse {\nprint $mx;\nprint \"\\n\"; }\n\n\n\n"}], "negative_code": [{"source_code": "# http://codeforces.com/problemset/problem/446/A\n# http://codeforces.com/blog/entry/13036\n\n\nmy $n = <STDIN>;\nmy $f = <STDIN>;\nchomp ( $n, $f );\nmy @seq = split m/ /, $f;\nmy @left, @right;\nmy $cnt = 1;\n$left[0] = 1;\n\nfor ( my $i = 1; $i < @seq; $i += 1 ) {\n    if ( $seq[ $i-1 ] < $seq[ $i ] ) {\n\t$cnt += 1;\n\t$left[ $i ] = $cnt; }\n    else { \n\t$cnt = 1;\n\t$left[ $i ] = $cnt; }}\n\n$right[ @seq-1 ] = 1;\n$cnt = 1;\nfor ( my $i = @seq-2; $i >= 0; $i -= 1 ) {\n    if ( $seq[ $i ] < $seq[ $i+1 ] ) {\n\t$cnt += 1;\n\t$right[ $i ] = $cnt; }\n    else { \n\t$cnt = 1;\n\t$right[ $i ] = $cnt; }}\n\nmy $mx = 0;\nfor ( my $i = 0; $i < @seq-2; $i += 1 ) {\n    if ( $seq[ $i ] + 1 < $seq[ $i+2 ] ) {\n\tif ( $left[ $i ] + 1 + $right[ $i ] > $mx ) {\n\t    $mx = $left[ $i ] + 1 + $right[ $i ]; }}}\n\nif ( $n < 3 ) { print \"$n\\n\"; }\nelse {\nprint $mx;\nprint \"\\n\"; }\n\n"}, {"source_code": "chomp($n=<>);\nchomp($line=<>);\n@nums = split(\" \",$line);\n@F = (0) x $n;\n@L = (0) x $n;\n@R = (0) x $n;\n$p = $q = $c = $ans = 0;\nfor $i(0..$#nums){\n    $F[$i] = 1 if !$i or $nums[$i] > $nums[$i-1];\n    $L[$i] += $p;\n    $p = $F[$i] ? $p + 1 : 1;\n}\nfor $i(reverse(0..$#nums)){\n    $R[$i] += $q;\n    $q = $F[$i] ? $q + 1 : 1;\n}\n#print \"F = @F L = @L \\n R = @R\\n\";\nfor $i(0..$#nums)\n{\n    $c = $L[$i] + $R[$i] + 1 if $F[$i] or !$i or $i + 1 == $n or $nums[$i + 1] - $nums[$i - 1] >= 2;\n    $ans = $c if $c > $ans;\n    #print \"cur ans = $ans\\n\";\n}\nprint \"$ans\\n\";\n\n"}, {"source_code": "chomp($n=<>);\nchomp($line=<>);\n@nums = split(\" \",$line);\n@F = (0) x $n;\n@L = (0) x $n;\n@R = (0) x $n;\nfor $i(0..$#nums){\n    $F[$i] = 1 if !$i or $nums[$i] > $nums[$i-1];\n    $L[$i] += $p;\n    $p = $F[$i] ? $p + 1 : 1;\n}\nfor $i(reverse(0..$#nums)){\n    $R[$i] += $q;\n    $q = $F[$i] ? $q + 1 : 1;\n}\n#print \"F = @F L = @L \\n R = @R\\n\";\nfor $i(0..$#nums)\n{\n    $c = $L[$i] + $R[$i] + 1 if $F[$i] or !$i or $i + 1 == $n or $nums[$i + 1] - $nums[$i - 1] >= 2;\n    $ans = $c if $c > $ans;\n    #print \"cur ans = $ans\\n\";\n}\nprint \"$ans\\n\";\n\n"}, {"source_code": "chomp($n=<>);\nchomp($line=<>);\n@nums = split(\" \",$line);\n@F = (0) x $n;\n@L = (0) x $n;\n@R = (0) x $n;\n$p = $q = $c = $ans = 0;\nfor $i(0..$#nums){\n    $F[$i] = 1 if !$i or $nums[$i] > $nums[$i-1];\n    $L[$i] += $p;\n    $p = $F[$i] ? $p + 1 : 1;\n}\nfor $i(reverse(0..$#nums)){\n    $R[$i] += $q;\n    #$q = $F[$i] ? $q + 1 : 1;\n    $q = $i + 1 < $n && $nums[$i] < $nums[$i + 1] ? $q + 1 : 1;\n}\nprint \"@F\\n@L\\n@R\\n\";\n\nfor $i(0..$#nums)\n{\n    if(!$i or $i + 1 == $n or $nums[$i + 1] - $nums[$i - 1] >= 2){\n        $c = $L[$i] + $R[$i] + 1;\n    }else {\n        $c = $R[$i] > $L[$i] ? $R[$i] + 1 : $L[$i] + 1;\n    }\n    $ans = $c if $c > $ans;\n    #print \"cur ans = $ans\\n\";\n}\nprint \"$ans\\n\";\n\n"}], "src_uid": "9e0d271b9bada1364dfcb47297549652"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <>){\n\t\t\n\tmy $L = 2;\n\t\n\tmy @re = split ' ', join '', map ~~<>, 1 .. 2;\n\t\t\n\tmy $l = join '', 'a' .. 'c';\n\t\n\tmy $p = ',';\n\t\n\t$_ = join '', map $p . $_, ( $l ) x $L;\n\t\n\tmy $m = ( $p . join \"([^$p])\", ( \".*\" ) x 2 ) x $L;\n\t\n\tmy %s;\n\t\n\t/\n\t\t$m\n\t\t(?{ $s{ join '', map { eval \"\\$$_\" } 1 .. $L } ++ })\n\t\t(*F)\n\t\t/x;\n\t\n\tmy %v;\n\t\n\tfor my $s ( grep !/(.).*\\1/, keys %s ){\n\t\tmy( $l3 ) = $l =~ s/[$s]//gr;\n\t\t$v{ join '', map { $_ x $n } $s, $l3 } ++;\n\t\t$v{ join '', map { $_ x $n } $l3, $s } ++;\n\t\t$v{ ( $s . $l3 ) x $n } ++;\n\t\t}\n\t\n\tmy $x;\n\t\n\tfor my $v ( keys %v ){\n\t\tmy $ok = 1;\n\t\tfor my $re ( @re ){\n\t\t\t$v =~ /$re/ and $ok = 0;\n\t\t\t}\n\t\t\n\t\tlast if $ok and $x = $v;\n\t\t}\n\t\n\tprint \"YES\\n$x\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\tchomp;\n\t\n\tmy $n = $_;\n\t\n\tmy $length = 2;\n\t\n\tmy @re = split ' ', join '', map ~~<>, 1 .. $length;\n\t\n\t$debug and print \"\\$n: $n, \\@re: @re\";\n\t\n\tmy $letters = join '', 'a' .. 'c';\n\t\n\tmy $prependent = ',';\n\t\n\tmy $str = join '', map \"${prependent}$_\", ( $letters ) x $length;\n\t\n\t$debug and print $str;\n\t\n\tmy $match_one_letter = \"${prependent}.*([^$prependent]).*\";\n\t\n\tmy $match_letters = $match_one_letter x $length;\n\t\n\t$debug and print \"$match_letters\";\n\t\n\tmy %strings;\n\t\n\t$str =~ /\n\t\t$match_letters\n\t\t(?{ $strings{ $1 . $2 } ++ })\n\t\t(*F)\n\t\t/x;\n\t\n\t/(.).*\\1/ and delete $strings{ $_ } for sort keys %strings;\n\t\n\t$debug and print join ' ', sort keys %strings;\n\t\n\tmy %variants;\n\t\n\tfor my $string ( sort keys %strings ){\n\t\tmy( $third_letter ) = $letters =~ s/[$string]//gr;\n\t\t$variants{ join '', map { $_ x $n } $string, $third_letter } ++;\n\t\t$variants{ join '', map { $_ x $n } $third_letter, $string } ++;\n\t\t$variants{ scalar( $string . $third_letter ) x $n } ++;\n\t\t}\n\t\n\t$debug and print for sort keys %variants;\n\t\n\tmy $find;\n\t\n\tfor my $variant ( sort keys %variants ){\n\t\tmy $ok = 1;\n\t\tfor my $re ( @re ){\n\t\t\t$variant =~ /$re/ and $ok = 0;\n\t\t\t}\n\t\t\n\t\tlast if $ok and $find = $variant;\n\t\t}\n\t\n\tprint defined $find ? \"YES\\n$find\" : \"NO\";\n\t}"}], "negative_code": [], "src_uid": "7f45fba2c06fe176a2b634e8988076c2"}
{"source_code": "$\\ = $/;\r\n$/ x= 2;\r\n<>;\r\n\r\nprint /R{8}/ ? R:B for <>", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. 8;\n\t\n\tif( grep m/^R+$/, @_ ){\n\t\tprint 'R';\n\t\t}\n\telse{\n\t\tprint 'B';\n\t\t}\n\t}"}, {"source_code": "$\\ = $/;\r\n$/ x= 2;\r\n<>;\r\n\r\nprint /R{8}/ ? R:B for <>"}, {"source_code": "$\\ = $/;\r\n$/ x= 2;\r\n<>;\r\n \r\nprint /R{8}/ ? R:B for <>"}], "negative_code": [], "src_uid": "2c7add49d423de44a2bc09de56ffacf1"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\t\n\tmy @A = map { [ split //, <> =~ s/\\n//r ] } 1 .. $n;\n\t\n\t$debug and print \"@{$_}\" for @A;\n\t\n\tmy $sx;\n\tmy $sy;\n\t\n\tOUT:\n\tfor my $i ( 0 .. $n - 1 ){\n\t\tfor my $j ( 0 .. $m - 1 ){\n\t\t\t$A[ $i ][ $j ] eq 'S' and do {\n\t\t\t\t$sx = $i; $sy = $j;\n\t\t\t\t$A[ $i ][ $j ] = '.';\n\t\t\t\tlast OUT;\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\n\t$debug and print '-' x 5;\n\t$debug and print \"@{$_}\" for @A;\n\t$debug and print \"[$sx|$sy]\";\n\t\n\tmy @dirs = split //, <> =~ s/\\n//r;\n\t\n\t$debug and print \"[@dirs]\";\n\t\n\tmy @v = qw( U D L R );\n\tmy $vars = 0;\n\t\n\tfor my $i1 ( @v ){\n\t\tfor my $i2 ( @v ){\n\t\t\tfor my $i3 ( @v ){\n\t\t\t\tfor my $i4 ( @v ){\n\t\t\t\t\tnext if \"$i1$i2$i3$i4\" =~ /(.).*\\1/;\n\t\t\t\t\tmy @i = split //, \"$i1$i2$i3$i4\";\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tmy $ssx = $sx;\n\t\t\t\t\tmy $ssy = $sy;\n\t\t\t\t\t\n\t\t\t\t\tmy $fail = 0;\n\t\t\t\t\t\n\t\t\t\t\tfor my $j ( @dirs ){\n\t\t\t\t\t\tmy( $dx, $dy ) = ( 0, 0 );\n\t\t\t\t\t\t$i[ $j ] eq 'D' and $dy += 1;\n\t\t\t\t\t\t$i[ $j ] eq 'U' and $dy -= 1;\n\t\t\t\t\t\t$i[ $j ] eq 'L' and $dx -= 1;\n\t\t\t\t\t\t$i[ $j ] eq 'R' and $dx += 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\t$ssx += $dx;\n\t\t\t\t\t\t$ssy += $dy;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif( $ssx < 0 || $ssx >= $n || $ssy < 0 || $ssy >= $m ||\n\t\t\t\t\t\t\t$A[ $ssx ][ $ssy ] eq '#'\n\t\t\t\t\t\t\t){\n\t\t\t\t\t\t\t$fail = 1;\n\t\t\t\t\t\t\tlast;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif( $A[ $ssx ][ $ssy ] eq 'E' ){\n\t\t\t\t\t\t\t$vars ++;\n\t\t\t\t\t\t\tlast;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint $vars;\n\t\n\t$debug and print '-' x 20;\n\t}", "positive_code": [{"source_code": "( $n, $m ) = split ' ', <>;\n\nfor $i ( 0 .. $n - 1 ){\n\t$_ = <>; chomp;\n\t/S/ and ( $sx = $i, $sy = index $_, 'S' );\n\t$A[ $i ] = [ split // ];\n\t}\n\t\n$D = <>;\n\nfor( grep /0/ * /1/ * /2/ * /3/, '0000' .. '3333' ){\n\t@i = split //;\n\t\n\t( $X, $Y ) = ( $sx, $sy );\n\t\n\tfor( split /\\B/, $D ){\n\t\t\t\t\t\n\t\t( $i[ $_ ] % 2 ? $X : $Y ) += $i[ $_ ] <=> 1.5;\n\t\t\n\t\t$_ = $A[ $X ][ $Y ];\n\t\t\n\t\tlast if $X < 0 || $X >= $n || $Y < 0 || $Y >= $m ||\n\t\t\t/#/ || /E/ && ++ $V;\n\t\t}\n\t}\n\nprint 0 + $V"}], "negative_code": [], "src_uid": "8a1799f4ca028d48d5a12e8ac4b8bee1"}
{"source_code": "$_=<>;\n$a=tr/aeiou//;\n$_=<>;\n$b=tr/aeiou//;\n$_=<>;\n$c=tr/aeiou//;\nif($a==5 && $b==7 && $c==5){\n  print \"YES\";\n}else{\n  print \"NO\";\n}", "positive_code": [{"source_code": "$s.=tr/aeiou// while <>;\nprint \"575\" eq $s?\"YES\":\"NO\""}, {"source_code": "$_=<>;\n$a=tr/aeiou//;\n$_=<>;\n$b=tr/aeiou//;\n$_=<>;\n$c=tr/aeiou//;\nprintf \"%s\", ($a==5 && $b==7 && $c==5) ? 'YES' : 'NO';"}, {"source_code": "while(<>){\n  $x=tr/aeiou//;\n  $s.=\" $x\";\n}\nprint \" 5 7 5\" eq $s?\"YES\":\"NO\""}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\nmy $line1 = <>;\nmy $line2 = <>;\nmy $line3 = <>;\n\n$line1 =~ s/[^aeiou]//g;\n$line2 =~ s/[^aeiou]//g;\n$line3 =~ s/[^aeiou]//g;\n\nprintf \"%s\\n\", ((length($line1) == 5 &&\n                 length($line2) == 7 &&\n                 length($line3) == 5) ? 'YES' : 'NO');\n\n"}, {"source_code": "sub occ{\n@arr=@_;\n@one=grep{$_ eq \"a\" or $_ eq \"i\" or $_ eq \"u\" or $_ eq \"o\" or $_ eq \"e\" }@arr;\n$size=@one;\nreturn $size;\n}\n@arr=split('',<>);\n@arr1=split('',<>);\n@arr2=split('',<>);\nif(occ(@arr)==5 and occ(@arr1)==7 and occ(@arr2)==5){\nprint \"YES\";\n}\nelse{\nprint \"NO\";\n}\n"}, {"source_code": "while(<>){s/[aeiou]/$i++/eg; $s=~s/$/ $i/}\nprint \" 5 12 17\" eq $s?\"YES\\n\":\"NO\\n\""}], "negative_code": [{"source_code": "while(<>) {\n  chomp;\n  $s.=$_;\n}\nprint $s=~tr/aeiou// == 17?\"YES\":\"NO\""}], "src_uid": "46d734178b3acaddf2ee3706f04d603d"}
{"source_code": "<>;\n$m = <>;\n@n = sort {$b <=> $a} <>;\nfor (@n){\n    $i ++;\n    $m -= $_, $m <= 0 and last;\n}\nprint $i", "positive_code": [{"source_code": "use strict;\nmy $n = <>;\nmy $m = <>;\nmy @a;\nfor(my $i = 0; $i < $n; $i++){\n   $a[$i] = <>;\n}\n @a = sort{\n  $a <=> $b;\n} @a;\nmy $ans = 0;\nmy $j = $#a;\n\nwhile($m > 0){\n  $m -= $a[$j];\n  $ans++;\n  $j--;\n}\nprint $ans;\n"}, {"source_code": "chomp($n = <>);\nchomp($m = <>);\nchomp($a[$_] = <>) for 0..$n - 1;\n@a = sort {$b <=> $a} @a;\nfor (@a) {\n\t$i++;\n\t$s += $_;\n\tlast if $s >= $m;\n}\nprint $i, \"\\n\";\n"}], "negative_code": [{"source_code": "use strict;\nmy $n = <>;\nmy $m = <>;\nmy @a;\nfor(my $i = 0; $i < $n; $i++){\n   $a[$i] = <>;\n}\n@a = sort @a;\nmy $ans = 0;\nmy $j = $#a;\n\nwhile($m > 0 && $j >= 0){\n  $m -= $a[$j];\n  $ans++;\n  $j--;\n}\nprint $ans;\n"}, {"source_code": "use strict;\nmy $n = <>;\nmy $m = <>;\nmy @a;\nfor(my $i = 0; $i < $n; $i++){\n   $a[$i] = <>;\n}\n@a = sort{\n  my $a <=> $b;\n} @a;\nmy $ans = 0;\nmy $j = $#a;\n\nwhile($m > 0){\n  $m -= $a[$j];\n  $ans++;\n  $j--;\n}\nprint $ans;\n"}, {"source_code": "use strict;\nmy $n = <>;\nmy $m = <>;\nmy @a;\nfor(my $i = 0; $i < $n; $i++){\n   $a[$i] = <>;\n}\n@a = sort @a;\nmy $ans = 0;\nmy $j = $#a;\n\nwhile($m > 0){\n  $m -= $a[$j];\n  $ans++;\n  $j--;\n}\nprint $ans;\n"}, {"source_code": "use strict;\nopen STDIN, '<input.txt';\nopen STDOUT, '>output.txt';\nmy $n = <>;\nmy $m = <>;\nmy @a;\nfor(my $i = 0; $i < $n; $i++){\n   $a[$i] = <>;\n}\n@a = sort @a;\nmy $ans = 0;\nmy $j = $#a;\n\nwhile($m > 0 && $j >= 0){\n  $m -= $a[$j];\n  $ans++;\n  $j--;\n}\nprint $ans;\n"}], "src_uid": "a02a9e37a4499f9c86ac690a3a427466"}
{"source_code": "print<>/2-2", "positive_code": [{"source_code": "print(<>/2-2)"}, {"source_code": "chomp (my $n = <STDIN>);\n\nmy ($x, $y, $xp, $yp);\n\nchomp (($xp, $yp) = split /\\s+/, <STDIN>);\nchomp (($xp, $yp) = split /\\s+/, <STDIN>);\n\nmy $prevDir = 'N';\nmy $curDir = 'N';\n\nmy $ans = 0;\nfor (my $i = 1; $i < $n; $i++) {\n  chomp (($x, $y) = split /\\s+/, <STDIN>);\n\n  $curDir = 'N' if ($y > $yp);\n  $curDir = 'E' if ($x > $xp);\n  $curDir = 'W' if ($x < $xp);\n  $curDir = 'S' if ($y < $yp);\n\n  $ans++ if (\n    (($prevDir eq 'N') && ($curDir eq 'W')) ||\n    (($prevDir eq 'E') && ($curDir eq 'N')) ||\n    (($prevDir eq 'W') && ($curDir eq 'S')) ||\n    (($prevDir eq 'S') && ($curDir eq 'E'))\n  );\n\n  $prevDir = $curDir;\n  ($xp, $yp) = ($x, $y);\n}\n\nprintf \"$ans\\n\";\n"}, {"source_code": "print((<>-4)/2)"}, {"source_code": "print(<>/2-2)"}, {"source_code": "print<>/2-2\n"}, {"source_code": "print<>/2-2"}, {"source_code": "$_ = join '', <>;\n\nwhile( /(?=((\\s\\S+){6}))\\n/g ){\n\t@_ = split ' ', $1;\n\t$C += ( $_[0] == $_[2] && ( $_[2] > $_[4] && $_[1] < $_[3] ||\n\t                            $_[2] < $_[4] && $_[1] > $_[3] ));\n\t$C += ( $_[1] == $_[3] && ( $_[3] < $_[5] && $_[0] < $_[2] ||\n\t                            $_[3] > $_[5] && $_[0] > $_[2] ));\n\t}\n\nprint $C"}], "negative_code": [], "src_uid": "0054f9e2549900487d78fae9aa4c2d65"}
{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw /say/;\n\nmy ($n, $t) = split q{ }, <STDIN>;\nmy $idx;\n\nmy @time_and_gap = ( (undef)x$n );\nfor ( @time_and_gap ) {\n    $_ = [ split q{ }, <STDIN> ];\n}\n\nmy $time;\nmy $gap;\nmy $s;\nmy $mod;\nmy $div;\nmy $min = 1000000;\nmy $min_i = 101;\nmy $i = 0;\nfor ( @time_and_gap ) {\n    $i++;\n    $time = $_->[0];\n    $gap = $_->[1];\n\n    if ( $time < $t ) {\n        $s = $t - $time;\n        $mod = $s % $gap;\n        $div = int ( $s/$gap );\n        if ( $mod ) {\n            $div++;\n        }\n        $time += $div * $gap;\n    }\n    \n    if ( $time < $min ) {\n        $min = $time;\n        $min_i = $i;\n    }\n\n}\n\nsay $min_i;", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw /say/;\n\nmy ($n, $t) = split q{ }, <STDIN>;\nmy $idx;\n\nmy @time_and_gap = ( (undef)x$n );\nfor ( @time_and_gap ) {\n    $_ = [ split q{ }, <STDIN> ];\n}\n\nmy $time;\nmy $gap;\nmy $s;\nmy $div;\nmy $min = 1000000;\nmy $min_i = 101;\nmy $i = 0;\nfor ( @time_and_gap ) {\n    $i++;\n    $time = $_->[0];\n    $gap = $_->[1];\n\n    if ( $time < $t ) {\n        $s = $t - $time;\n        $div = int ( $s/$gap );\n        $time += $div * $gap;\n    }\n    if ( $time < $t ) {\n        $time += $gap;\n    }\n    if ( $time < $t ) {\n        next;\n    }\n    \n    if ( $time < $min ) {\n        $min = $time;\n        $min_i = $i;\n    }\n\n}\n\nsay $min_i;"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw /say/;\n\nmy ($n, $t) = split q{ }, <STDIN>;\nmy $idx;\n\nmy @time_and_gap = ( (undef)x$n );\nfor ( @time_and_gap ) {\n    $_ = [ split q{ }, <STDIN> ];\n}\n\nmy $time;\nmy $gap;\nmy $s;\nmy $div;\nmy $min = 1000000;\nmy $min_i = 101;\nmy $i = 0;\nfor ( @time_and_gap ) {\n    $i++;\n    $time = $_->[0];\n    $gap = $_->[1];\n\n    \n    while ( $time < $t ) {\n        $time += $gap;\n    }\n    \n    if ( $time < $min ) {\n        $min = $time;\n        $min_i = $i;\n    }\n\n}\n\nsay $min_i;"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw /say/;\n\nmy ($n, $t) = split q{ }, <STDIN>;\n\nmy @time_and_gap = ( (undef)x$n );\nfor ( @time_and_gap ) {\n    $_ = [ split q{ }, <STDIN> ];\n}\n\nsub canTake {\n    my $t = $_[0];\n    my $idx = 1;\n    for ( @time_and_gap ) {\n        $_->[0] += $_->[1] if $_->[0] < $t;\n        if ( $_->[0] == $t ) {\n            return $idx;\n        }\n        $idx++;\n    }\n    canTake($t+1);\n}\n\nsay canTake($t);"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw /say/;\n\nmy ($n, $t) = split q{ }, <STDIN>;\n\nmy @time_and_gap = ( (undef)x$n );\nfor ( @time_and_gap ) {\n    $_ = [ split q{ }, <STDIN> ];\n}\n\nsub canTake {\n    my $t = $_[0];\n    my $idx = 1;\n    for ( @time_and_gap ) {\n        $_->[0] += $_->[1] if $_->[0] < $t;\n        if ( $_->[0] == $t ) {\n            say $t;\n            say $_->[0];\n            return $idx;\n        }\n        $idx++;\n    }\n    canTake($t+1);\n}\n\nsay canTake($t);"}], "src_uid": "71be4cccd3b8c494ad7cc2d8a00cf5ed"}
{"source_code": "#!perl\nchomp($t=<>);\nwhile ($t--) {\n\tchomp($n=<>);\n\t$a=2**$n; $b=0;\n\tforeach my $i (1..$n-1) {\n\t\tif ($i*2 < $n) {\n\t\t\t$a += 2**$i;\n\t\t}\n\t\telse {\n\t\t\t$b += 2**$i;\n\t\t}\n\t}\n\t$ans=abs($a-$b);\n\tprint \"$ans\\n\";\n}", "positive_code": [{"source_code": "$t = <STDIN>;\nchomp $t;\n@test = <STDIN>;\nchomp @test;\n\nforeach (@test) {\n    #print $_;\n$loop = $_/2;\n@coins = ();\n$coins[0] = 2;\nfor ($i=1;$i<$_;$i = $i + 1) {\n    push (@coins, $coins[$i-1]*2);\n}\n#foreach $coin (@coins) {\n#    print \"\\n $coin\";\n#}\n#print $loop;\n$sum1 = 0;\n$sum2 = 0;\nif ($loop == 1) {\n    $ans = $coins[1]-$coins[0];\n    print \"$ans\\n\";\n}else{\n    for ($j=0;$j<=$loop-2;$j=$j+1) {\n        $sum1 = $sum1  + $coins[$j];\n    }\n    $sum1 = $sum1 + $coins[$_-1];\n        for ($k=$loop-1;$j<=$_-2;$j=$j+1) {\n        $sum2 = $sum2  + $coins[$j];\n    }\n    $ans = $sum1 - $sum2;\n    #print \"$sum1 $sum2\";\n    print \"$ans\\n\";\n}\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $left = 0;\n\t\n\t$left += $_ for map { 2 ** $_ } 1 .. $_ / 2 - 1, $_;\n\t\n\tmy $right = 0;\n\t\n\t$right += $_ for map { 2 ** $_ } $_ / 2 .. $_ - 1;\n\t\n\tprint $left - $right;\n\t}"}], "negative_code": [{"source_code": "$n = <STDIN>;\nchomp $n;\n$loop = $n/2;\n@coins = ();\n$coins[0] = 2;\nfor ($i=1;$i<$n;$i = $i + 1) {\n    push (@coins, $coins[$i-1]*2);\n}\n#foreach (@coins) {\n#    print \"\\n $_\";\n#}\n#print $loop;\n#$sum1 = 0;\nif ($loop == 1) {\n    print $coins[1]-$coins[0];\n}else{\n    for ($j=0;$j<=$loop-2;$j=$j+1) {\n        $sum1 = $sum1  + $coins[$j];\n    }\n    $sum1 = $sum1 + $coins[$n-1];\n    for ($k=$loop-1;$j<=$n-2;$j=$j+1) {\n        $sum2 = $sum2  + $coins[$j];\n    }\n    print $sum1-$sum2;\n}"}], "src_uid": "787a45f427c2db98b2ddb78925e0e0f1"}
{"source_code": "chomp($_ = <STDIN>);\n@nums = split / /;\n$x = $nums[1];\nchomp($_ = <STDIN>);\n@nums = split / /;\n@nums = sort {$a <=> $b} @nums;\n$r = 0;\nforeach $n (@nums) {\n\t$r += $x*$n;\n\tif ($x > 1) {\n\t\t$x--;\n\t}\n}\nprint $r;", "positive_code": [{"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "use v5.10;\n\n($n, $x) = split / /, <>;\n@c = sort {$a <=> $b} split / /, <>;\nforeach (@c) {\n\t$ans += $_ * $x;\n\t$x>1 and --$x;\n}\nsay $ans;\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$x)=split/ /;\n\t$_=<>;\n\tchomp;\n\t@_=split/ /;\n\t@_=sort {$a<=>$b} @_;\n\t$sum=0;\n\tfor (@_){\n\t\t\n\t\t$sum+=$_*$x;\n\t\t$x==1 or $x--;\n\t\t\n\t\t}\n\tprint \"$sum\\n\";\n\t\n\t}"}, {"source_code": "($n,$x)=split/ /,<>;\n@_=sort {$a<=>$b} (split/ /,<>);\n$U+=$_*$x, $x-1 && $x-- for @_;\nprint $U\n"}], "negative_code": [], "src_uid": "ce27e56433175ebf9d3bbcb97e71091e"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy @L;\n\tmy @N;\n\t\n\tfor( @_ ){\n\t\tif( $_ % 2 == 0 ){\n\t\t\tpush @L, $_;\n\t\t\t}\n\t\telse{\n\t\t\tpush @N, $_;\n\t\t\t}\n\t\t}\n\t\n\t@L = sort { $b <=> $a } @L;\n\t@N = sort { $b <=> $a } @N;\n\t\n\tmy $A = 0;\n\tmy $B = 0;\n\t\n\tmy $move = 0;\n\t\n\twhile( @L or @N ){\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $move == 0 ){\n\t\t\tif( @L and @N ){\n\t\t\t\tif( $L[ 0 ] > $N[ 0 ] ){\n\t\t\t\t\t$A += shift @L;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tshift @N;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telsif( @L ){\n\t\t\t\t$A += shift @L;\n\t\t\t\t}\n\t\t\telsif( @N ){\n\t\t\t\tshift @N;\n\t\t\t\t}\n\t\t\t}\n\t\telsif( $move == 1 ){\n\t\t\tif( @L and @N ){\n\t\t\t\tif( $L[ 0 ] < $N[ 0 ] ){\n\t\t\t\t\t$B += shift @N;\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tshift @L;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telsif( @L ){\n\t\t\t\tshift @L;\n\t\t\t\t}\n\t\t\telsif( @N ){\n\t\t\t\t$B += shift @N;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$move = 1 - $move;\n\t\t}\n\t\n\tprint qw( Tie Alice Bob )[ $A <=> $B ];\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\n# Alice Bob Tie\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  $#A = $n - 1;\r\n  my @sa = sort { $b <=> $a } @A;\r\n  my @ev = grep { $_ % 2 == 0 } @sa;\r\n  my @od = grep { $_ % 2 == 1 } @sa;\r\n  my $i_e = 0; $i_o = 0;\r\n  \r\n  my $a_sc = 0; my $b_sc = 0;\r\n  for(my $i=0;$i<$n;$i++){\r\n    my $v = $sa[$i];\r\n    if( $i % 2 == 0 ){\r\n      $a_sc += $v if $v % 2 == 0;\r\n    } else {\r\n      $b_sc += $v if $v % 2 == 1;\r\n    }\r\n  }\r\n  print ($a_sc > $b_sc ? \"Alice\\n\" : ( $a_sc < $b_sc ? \"Bob\\n\" : \"Tie\\n\" ));\r\n  next;\r\n  \r\n  my $min_idx = &min( $#ev, $#od );\r\n  \r\n  my $a_es = 0;\r\n  my $b_es = 0;\r\n  for(my $i=0;$i<=$min_idx;$i++){\r\n    $a_es += $ev[$i];\r\n    $b_es += $od[$i];\r\n  }\r\n  \r\n  \r\n  \r\n  for(my $i=0;$i<$n;$i++){\r\n    my $v = undef;\r\n    if( $i_e > $#ev or $i_o > $#od ){\r\n      $v = $ev[$i_e++] if $i_e <= $#ev;\r\n      $v = $od[$i_o++] if $i_o <= $#od;\r\n      if( $i % 2 == 0 ){\r\n        $a_sc += $v if $v % 2 == 0;\r\n      } else {\r\n        $b_sc += $v if $v % 2 == 1;\r\n      }\r\n      next;\r\n    }\r\n    my $tu = ( $i_o < $#od ? $od[$i_o] - $od[$i_o+1] : $od[$i_o] );\r\n    my $so = ( $i_e < $#ev ? $ev[$i_e] - $ev[$i_e+1] : $ev[$i_e] );\r\n    if( $i % 2 == 0 ){\r\n      if( $tu >= $so ){\r\n        $v = $od[$i_o++];\r\n      } else {\r\n        $v = $ev[$i_e++];\r\n      }\r\n      $a_sc += $v if $v % 2 == 0;\r\n    } else {\r\n      #B\r\n      if( $so >= $tu ){\r\n        $v = $ev[$i_e++];\r\n      } else {\r\n        $v = $od[$i_o++];\r\n      }\r\n      $b_sc += $v if $v % 2 == 1;\r\n    }\r\n  }\r\n  print ($a_sc > $b_sc ? \"Alice\\n\" : ( $a_sc < $b_sc ? \"Bob\\n\" : \"Tie\\n\" ));\r\n}\r\n\r\nexit(0);\r\n\r\nsub min {\r\n  my ($x,$y) = @_;\r\n  return ( ( $x < $y ) ? $x : $y );\r\n}\r\n\r\nsub max {\r\n  my ($x,$y) = @_;\r\n  return ( ( $x > $y ) ? $x : $y );\r\n}\r\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\n# Alice Bob Tie\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  $#A = $n - 1;\r\n  my @ev = sort { $b <=> $a } grep { $_ % 2 == 0 } @A;\r\n  my @od = sort { $b <=> $a } grep { $_ % 2 == 1 } @A;\r\n  my $i_e = 0; $i_o = 0;\r\n  \r\n  my $a_sc = 0; my $b_sc = 0;\r\n  for(my $i=0;$i<$n;$i++){\r\n    my $v = undef;\r\n    if( $i_e > $#ev or $i_o > $#od ){\r\n      $v = $ev[$i_e++] if $i_e <= $#ev;\r\n      $v = $od[$i_o++] if $i_o <= $#od;\r\n      if( $i % 2 == 0 ){\r\n        $a_sc += $v if $v % 2 == 0;\r\n      } else {\r\n        $b_sc += $v if $v % 2 == 1;\r\n      }\r\n      next;\r\n    }\r\n    my $tu = ( $i_o < $#od ? $od[$i_o] - $od[$i_o+1] : $od[$i_o] );\r\n    my $so = ( $i_e < $#ev ? $ev[$i_e] - $ev[$i_e+1] : $ev[$i_e] );\r\n    if( $i % 2 == 0 ){\r\n      if( $tu >= $so ){\r\n        $v = $od[$i_o++];\r\n      } else {\r\n        $v = $ev[$i_e++];\r\n      }\r\n      $a_sc += $v if $v % 2 == 0;\r\n    } else {\r\n      #B\r\n      if( $so >= $tu ){\r\n        $v = $ev[$i_e++];\r\n      } else {\r\n        $v = $od[$i_o++];\r\n      }\r\n      $b_sc += $v if $v % 2 == 1;\r\n    }\r\n  }\r\n  print ($a_sc > $b_sc ? \"Alice\\n\" : ( $a_sc < $b_sc ? \"Bob\\n\" : \"Tie\\n\" ));\r\n}\r\n\r\nexit(0);\r\n\r\n"}], "src_uid": "b1e911fbc33fb031b2398cdd545f502a"}
{"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub min {\n  my $min = shift;\n  for my $x (@_) {\n    $min = $x if $x < $min;\n  }\n  $min;\n}\n\nmy %last;\nmy %max_dist;\n\nchomp (my $s = <>);\nfor my $i (0..length($s) - 1) {\n  my $c = substr $s, $i, 1;\n\n  my $dist = $i - ($last{$c} // -1);\n  $max_dist{$c} = $dist if !exists $max_dist{$c} || $dist > $max_dist{$c};\n\n  $last{$c} = $i;\n}\n\nfor my $c (keys %max_dist) {\n  my $dist = length($s) - $last{$c};\n  $max_dist{$c} = $dist if $dist > $max_dist{$c};\n}\n\nsay min(values %max_dist);\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t@_ = ();\n\t\n\tfor my $c ( 'a' .. 'z' ){\n\t\t\n\t\t/$c/ and push @_, 1 + ( sort { $b <=> $a } map length, grep $_, split $c )[ 0 ];\n\t\t}\n\t\n\tprint 0 + ( sort { $a <=> $b } @_ )[ 0 ];\n\t}"}, {"source_code": "$_ = <>, chomp;\n\n$m = ~0;\n\t\nfor $c ( 'a' .. 'z' ){\n\t( $q ) = sort { $b <=> $a } map length, split $c;\n\t$q < $m and $m = $q;\n\t}\n\nprint 1 + $m"}, {"source_code": "\n\n# read input\nmy $str = <STDIN>;\nchomp ( $str );\n\n# insert each character into an index in the array\nmy @arr = split m//, $str;\n\n# insert the keys and initial values into the hashes\nmy %prev;\nmy %max;\nfor (@arr) {\n    $prev{ $_ } = $max{ $_ } = -1; }\n\n# iterate through the string\nfor ( my $j = 0; $j < (@arr); $j += 1 ) {\n    if ( $j - $prev{ $arr[ $j ] } > $max{ $arr[ $j ] } ) {\n\t$max{ $arr[ $j ] } = $j - $prev{ $arr[ $j ] };}\n    $prev{ $arr[ $j ] } = $j;}\n\n# don't forget the last substrings\nfor ( my $i = 0; $i < (@arr); $i += 1 ) {\n    if ( (@arr) - $prev{ $arr[ $i ] } > $max{ $arr[ $i ] } ) {\n\t$max{ $arr[ $i ] } = @arr - $prev{ $arr[ $i ] }; }}\n\n# find the minimum maximum value\nmy $min = 100000000;\nfor (@arr) {\n    if ( $max{ $_ } < $min && $max{ $_ } > 0 ) {\n\t$min = $max{ $_ }; }}\n\n# print answer\nprint \"$min\\n\";\n\n\n"}], "negative_code": [{"source_code": "\n\n# read input\nmy $str = <STDIN>;\nchomp ( $str );\n\n# insert each character into an index in the array\nmy @arr = split m//, $str;\n\n# insert the keys and initial values into the hashes\nmy %prev;\nmy %max;\nfor (@arr) {\n    $prev{ $_ } = $max{ $_ } = -1; }\n\n# iterate through the string\nfor ( my $j = 0; $j < (@arr); $j += 1 ) {\n    if ( $j - $prev{ $arr[ $j ] } > $max{ $arr[ $j ] } ) {\n\t$max{ $arr[ $j ] } = $j - $prev{ $arr[ $j ] };}\n    $prev{ $arr[ $j ] } = $j;}\n\n# don't forget the last substrings\nfor ( my $i = 0; $i < (@arr); $i += 1 ) {\n    if ( (@arr-1) - $prev{ $arr[ $i ] } > $max{ $arr[ $i ] } ) {\n\t$max{ $arr[ $i ] } = @arr - 1 - $prev{ $arr[ $i ] }; }}\n\n\n# find the minimum maximum value\nmy $min = 100000000;\nfor (@arr) {\n    if ( $max{ $_ } < $min && $max{ $_ } > 0 ) {\n\t$min = $max{ $_ }; }}\n\n# print answer\nprint \"$min\\n\";\n\n\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub min {\n  my $min = shift;\n  for my $x (@_) {\n    $min = $x if $x < $min;\n  }\n  $min;\n}\n\nmy %last;\nmy %max_dist;\n\nchomp (my $s = <>);\nfor my $i (0..length($s) - 1) {\n  my $c = substr $s, $i, 1;\n\n  my $dist = $i - ($last{$c} // 0);\n  $max_dist{$c} = $dist if !exists $max_dist{$c} || $dist > $max_dist{$c};\n\n  $last{$c} = $i;\n}\n\nfor my $c (keys %max_dist) {\n  my $dist = length($s) - $last{$c};\n  $max_dist{$c} = $dist if $dist > $max_dist{$c};\n}\n\nsay min(values %max_dist);\n"}], "src_uid": "81a558873e39efca5066ef91a9255f11"}
{"source_code": "use strict;\n\nmy $try = <>;\n\nwhile($try--)\n{\n    my $n = <>;\n    my $v = int($n/4);\n    $v += 1 if ($n % 4) > 0;\n    for(my $i = 1; $i <= $n-$v; $i++){\n        print \"9\";\n    }\n    for(my $i = 1; $i <= $v; $i++){\n        print \"8\";\n    }\n    print \"\\n\";\n}", "positive_code": [{"source_code": "use bigint;\nchomp(my $t = <STDIN>);\nforeach (1..$t)\n{\n    chomp (my $n = <STDIN>);\n    my $c = ($n + 3) / 4;\n    print '9' x ($n - $c) . '8' x $c, \"\\n\";\n}"}], "negative_code": [{"source_code": "use strict;\n\nmy $try = <>;\n\nwhile($try--)\n{\n\tmy $n = <>;\n\tfor(my $i = 0; $i < $n-1; $i++){\n\t\tprint \"9\";\n        }\n\tprint \"8\\n\";\n}"}], "src_uid": "80c75a4c163c6b63a614075e094ad489"}
{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $min1 = 1000000000;\nmy $min2 = 1000000000;\nmy $max1 = 0;\nmy $max2 = 0;\n\nmy $n = <>;\n$n =~ s/\\s+$//;\n\nsub min {\n    my $ans = $_[0];\n    for my $x (@_) {\n        if ($ans > $x) {\n            $ans = $x;\n        }\n    }\n    return $ans;\n}\n\nsub max {\n    my $ans = $_[0];\n    for my $x (@_) {\n        if ($ans < $x) {\n            $ans = $x;\n        }\n    }\n    return $ans;\n}\n\nfor my $i (1 .. $n) {\n    my $tmp = <>;\n    $tmp =~ s/\\s+$//;\n    my @tmp = split /\\s+/, $tmp;\n    $min1 = min($min1, $tmp[1]);\n    $max1 = max($max1, $tmp[0]);\n}\n\nmy $m = <>;\n$m =~ s/\\s+$//;\n\nfor my $i (1 .. $m) {\n    my $tmp = <>;\n    $tmp =~ s/\\s+$//;\n    my @tmp = split /\\s+/, $tmp;\n    $min2 = min($min2, $tmp[1]);\n    $max2 = max($max2, $tmp[0]);\n}\n\nprint max(0, $max1 - $min2, $max2 - $min1);\n\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(!eof){\n\tmy $left = 1e9;\n\tmy $right = 0;\n\tmy $left_2 = 1e9;\n\tmy $right_2 = 0;\n\tmy $n = <>;\n\tfor my $i (1 .. $n){\n\t\tmy( $l, $r )= split ' ', <>;\n\t\t$r < $left and $left = $r;\n\t\t$l > $right_2 and $right_2 = $l;\n\t\t}\n\tmy $m = <>;\n\tfor my $i (1 .. $m){\n\t\tmy( $l, $r )= split ' ', <>;\n\t\t$r < $left_2 and $left_2 = $r;\n\t\t$l > $right and $right = $l;\n\t\t}\n\t\n\tprint +( sort { $a <=> $b } 0, $right - $left, $right_2 - $left_2 )[ 2 ];\n\t\n\t}"}, {"source_code": "sub iter($) {\n\t$n = shift;\n\t$rmin = 2e9; $lmax = 0;\n\twhile ($n--) {\n\t\t($l, $r) = split \" \", <>;\n\t\tif ($r < $rmin) { $rmin = $r }\n\t\tif ($l > $lmax) { $lmax = $l }\n\t}\n\t($rmin, $lmax)\n}\n\n@a = iter <>;\n@b = iter <>;\n$a = $b[1] - $a[0];\n$b = $a[1] - $b[0];\n$ans = $a > $b? $a: $b;\n$ans = $ans > 0? $ans: 0;\nprint $ans;"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $min1 = 1000000000;\nmy $min2 = 1000000000;\nmy $max1 = 0;\nmy $max2 = 0;\n\nmy $n = <>;\n$n =~ s/\\s+$//;\n\nsub min {\n    my $ans = $_[0];\n    for my $x (@_) {\n        if ($ans > $x) {\n            $ans = $x;\n        }\n    }\n    return $ans;\n}\n\nsub max {\n    my $ans = $_[0];\n    for my $x (@_) {\n        if ($ans < $x) {\n            $ans = $x;\n        }\n    }\n    return $ans;\n}\n\nfor my $i (1 .. $n) {\n    my $tmp = <>;\n    $tmp =~ s/\\s+$//;\n    my @tmp = split /\\s+/, $tmp;\n    if ($tmp[1] < $min1) {\n        $min1 = $tmp[1];\n    }\n    if ($tmp[0] > $max1) {\n        $max1 = $tmp[0];\n    }\n}\n\nmy $m = <>;\n$m =~ s/\\s+$//;\n\nfor my $i (1 .. $m) {\n    my $tmp = <>;\n    $tmp =~ s/\\s+$//;\n    my @tmp = split /\\s+/, $tmp;\n    if ($tmp[1] < $min2) {\n        $min2 = $tmp[1];\n    }\n    if ($tmp[0] > $max2) {\n        $max2 = $tmp[0];\n    }\n}\n\nprint max(0, $max1 - $min2, $max2 - $min1);\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(!eof){\n\tmy $left = 3e5;\n\tmy $right = 0;\n\tmy $left_2 = 3e5;\n\tmy $right_2 = 0;\n\tmy $n = <>;\n\tfor my $i (1 .. $n){\n\t\tmy( $l, $r )= split ' ', <>;\n\t\t$r < $left and $left = $r;\n\t\t$l > $right_2 and $right_2 = $l;\n\t\t}\n\tmy $m = <>;\n\tfor my $i (1 .. $m){\n\t\tmy( $l, $r )= split ' ', <>;\n\t\t$r < $left_2 and $left_2 = $r;\n\t\t$l > $right and $right = $l;\n\t\t}\n\t\n\tprint +( sort { $a <=> $b } 0, $right - $left, $right_2 - $left_2 )[ 2 ];\n\t\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(!eof){\n\tmy $left = 3e5;\n\tmy $right = 0;\n\tmy $n = <>;\n\tfor my $i (1 .. $n){\n\t\tmy $r = ( split ' ', <> )[ 1 ];\n\t\t$r < $left and $left = $r;\n\t\t}\n\tmy $m = <>;\n\tfor my $i (1 .. $m){\n\t\tmy $l = ( split ' ', <> )[ 0 ];\n\t\t$l > $right and $right = $l;\n\t\t}\n\t\n\tprint +( sort { $a <=> $b } 0, $right - $left )[ 1 ];\n\t\n\t}"}], "src_uid": "4849a1f65afe69aad12c010302465ccd"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map { eval join '/', split } map ~~<>, 1 .. $n;\n\t\n\tprint $m * ( sort { $a <=> $b } @_ )[ 0 ];\n\t}", "positive_code": [{"source_code": "print +( split )[ 1 ] * ( sort { $a <=> $b } map { eval s! !/!r } <> )[ 0 ] while <>"}], "negative_code": [{"source_code": "print +( split )[ 1 ] * ( sort { $a <=> $b } map { eval s! !/!r } <> )[ 0 ] for <>"}, {"source_code": "print +( split ) * ( sort { $a <=> $b } map { eval s! !/!r } <> )[ 0 ] for <>"}, {"source_code": "print +( split ) * ( sort { $b <=> $a } map { eval s! !/!r } <> ) while <>"}], "src_uid": "3bbe48918a7bf3faf01c74cb7296f6e0"}
{"source_code": "\nuse strict;\nuse warnings;\nmy $totalNum =  <STDIN>;\nmy %finResults;\nmy @hisResults;\n\nmy @inputs;\n\n#calc final score and keep historic record.\nfor(my $i = 0; $i < $totalNum; $i++){\n    my $input = <STDIN>;\n    @inputs = split( \" \", $input);\n    $finResults{$inputs[0]} += $inputs[1];\n    my @record = ($inputs[0], $finResults{$inputs[0]} );\n    push @hisResults, \\@record;         \n}\n#Sort based on final score to find candidate winners.\nmy @finals = sort {$finResults{$a} <=> $finResults{$b} } keys %finResults;\nif (scalar @finals == 1){  #if there is only one candidate, he is the winner.\n    return $finals[0];\n}\nmy $finalScore = $finResults{ $finals[scalar @finals - 1] };\nmy %candidateWiners;\n$candidateWiners{$finals [scalar @finals - 1]} = 1;\nfor(my $i = scalar @finals -2; $i >= 0; $i--){\n    if($finResults{ $finals[$i] } < $finalScore){\n        last;\n    }\n    else{\n        $candidateWiners{$finals[$i] } = 1;\n    }    \n}\n\n#Check the historic data to find the final winner.\nforeach my $hisRes (@hisResults){\n    if ($hisRes->[1] >= $finalScore &&  exists($candidateWiners{$hisRes->[0]})){        \n        print $hisRes->[0];        \n        last; \n    }\n}\n\n\n", "positive_code": [{"source_code": "$n=<STDIN>;\n%hash;\n@list;\n$i=0;\n$max=-99999999999999;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        if($hash{$name})\n        {\n            $hash{$name}+=$score;\n        }\n        else\n        {\n            $hash{$name}=$score;\n        }\n        $list[$i++]=$name;\n        $list[$i++]=$hash{$name};\n}\n#print $max,\"\\n\";\n$flag=1;\nforeach $key (%hash)\n        {\n    #        print $hash{$key},\"\\n\";\n            if($hash{$key}>$max)\n            {\n                $max=$hash{$key};\n                $winner=$key;\n            }\n        }\n\nfor($j=0;$j<$i && $flag;$j+=2)\n{\n    #print \"$list[$j] $list[$j+1] $hash{$list[$j]} $max\\n\";\n    if($list[$j+1]>=$max && $hash{$list[$j]}==$max && $flag)\n    {\n        print $list[$j];\n        $flag=0;\n    }\n}"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nmy $totalNum =  <STDIN>;\nmy %finResults;\nmy @hisResults;\n\nmy @inputs;\nfor(my $i = 0; $i < $totalNum; $i++){\n    my $input = <STDIN>;\n    @inputs = split( \" \", $input);\n    $finResults{$inputs[0]} += $inputs[1];\n    my @record = ($inputs[0], $finResults{$inputs[0]} );\n    push @hisResults, \\@record;\n#    if (! exists $hisResults{$inputs[0]}){\n#        $hisResults{$inputs[0]} = [$inputs[1]];        \n#    }\n#    else{\n#        my $arrayRef = $hisResults{$inputs[0]};\n#        if($$arrayRef[$#$arrayRef] < $finResults{$inputs[0]} ){\n#            push @$arrayRef, $finResults{$inputs[0]};                      \n#        }    \n#        \n#    }         \n}\n\nmy @finals = sort {$finResults{$a} <=> $finResults{$b} } keys %finResults;\n\nif (scalar @finals == 1){\n    return $finals[0];\n}\nmy $finalScore = $finResults{ $finals[scalar @finals - 1] };\nmy %candidateWiners;\n$candidateWiners{$finals [scalar @finals - 1]} = 1;\nfor(my $i = scalar @finals -2; $i >= 0; $i--){\n    if($finResults{ $finals[$i] } < $finalScore){\n#        print \"UUUUUUUUUU: $i,  NNNNN: $finResults{ $finals[$i]}\\n\"; \n        last;\n    }\n    else{\n        $candidateWiners{$finals[$i] } = 1;\n    }    \n}\n#print Dumper \\@finals ;\n#\n#\n#\n#print Dumper \\%candidateWiners;\n#print \"HHHHHH: finalScore $finalScore \\n\";\n#print Dumper \\%finResults ;\n#print Dumper \\@hisResults;\n\n\nforeach my $hisRes (@hisResults){\n    if ($hisRes->[1] >= $finalScore &&  exists($candidateWiners{$hisRes->[0]})){        \n        print $hisRes->[0];        \n        last; \n    }\n}\n\n\n#foreach my $candidate (sort {$finResults{$a} cmp $finResults{$b} }\n#           keys %finResults)\n#{\n#     print \"$candidate $finResults{$candidate} \\n\";\n#}\n\n#print Dumper \\%hisResults;"}, {"source_code": "<>;\n@_=<>;\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n}\n\n$max= (sort {$b<=>$a} values %n)[0];\n\nwhile(($k,$v)=each %n){\n$v==$max and $m{$k}++\n}\n\nundef %n;\n\nfor(@_){\n($a,$b)=split/ /;\n$m{$a} // next;\n$n{$a}+=$b;\nif ($max <= $n{$a}) {$ans=$a; last }\n}\n\nprint $ans"}, {"source_code": "<>;\n@_=<>;\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n}\n\n$max= (sort {$b<=>$a} values %n)[0];\n\nfor(@_){\n($a,$b)=split/ /;\n$m{$a}+=$b;\nif ($max == $n{$a} && $max <= $m{$a}) {$ans=$a; last }\n}\n\nprint $ans"}, {"source_code": "my $n = <>;\nmy (@name, @point);\nmy @table = [];\nmy ($ans, $max) = (0, 0);\nmy %hash;\nfor my $i (1..$n) {\n    ($name[$i], $point[$i]) = split \" \", <>;\n    $hash{$name[$i]} = 0 if(not exists $hash{$name[$i]});\n    $hash{$name[$i]} += $point[$i];\n    push @table, [$name[$i], $hash{$name[$i]}];\n}\n$max = $_ > $max ? $_ : $max foreach(values %hash);\n# print \"\\n-----------\\n\";\nfor my $i (1..$n) {\n    if ($hash{$name[$i]} == $max && $table[$i][1] >= $max) {\n        print $name[$i] .\"\\n\";\n        last;\n    }\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $players = {};\nmy $score_log = [];\n\nmy $n_inputs = <>;\n\nfor ( 1 .. $n_inputs ) {\n  my $line = <>;\n  my ( $name, $score, @rest ) = split /\\s+/s, $line;\n\n  if ( not exists $players->{$name} ) {\n    $players->{$name} = 0;\n  }\n  my $new_score = $players->{$name} + $score;\n  push @{ $score_log }, { name => $name, score => $new_score };\n  $players->{ $name } = $new_score;\n}\nmy %winning_players;\nmy ( $winning_score, ) = sort { $b <=> $a } values %{ $players };\nfor ( grep { $winning_score == $players->{$_} } keys %{ $players } ) {\n  $winning_players{ $_ } = 1;\n}\nfor my $entry ( @{ $score_log } ) {\n  next unless exists $winning_players{ $entry->{name} };\n  next unless $entry->{score} >= $winning_score;\n  printf \"%s\\n\", $entry->{name};\n  exit 0;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy @round;\nmy %score;\n\nfor (my $i = 0; $i < $n; $i++) {\n    my $line = <>;\n    chomp $line;\n    push @round, $line;\n    my @tuple = split ' ', $round[$i];\n    if (not defined($score{$tuple[0]})) {\n        $score{$tuple[0]} = $tuple[1];\n    } else {\n        $score{$tuple[0]} += $tuple[1];\n    }\n}\n\nmy $max = 0;\nforeach (keys(%score)) {\n    $max = $score{$_} if ($score{$_} > $max);\n}\n\nmy %t;\nfor (my $i = 0; $i < $n; $i++) {\n    my @tuple = split ' ', $round[$i];\n    if (not defined($t{$tuple[0]})) {\n        $t{$tuple[0]} = $tuple[1];\n    } else {\n        $t{$tuple[0]} += $tuple[1];\n    }\n\n    if ($score{$tuple[0]} == $max and $t{$tuple[0]} >= $max) {\n        print $tuple[0];\n        last;\n    }\n}\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $name;\nmy $point;\nmy $ans;\nmy $max = 0;\nmy %hash;\nfor (1..$n) {\n    ($name, $point) = split \" \", <>;\n    if (exists $hash{$name}) {\n        $hash{$name} += $point;\n    }\n    else {\n        $hash{$name} = $point;\n    }\n    if ($hash{$name} > $max) {\n        $max = $hash{$name};\n        $ans = $name;\n    }\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "my $n = <>;\nmy (@name, @point);\nmy @table = [];\nmy ($ans, $max) = (0, 0);\nmy %hash;\nfor my $i (1..$n) {\n    ($name[$i], $point[$i]) = split \" \", <>;\n    $hash{$name[$i]} = 0 if(not exists $hash{$name[$i]});\n    $hash{$name[$i]} += $point[$i];\n    push @table, [$name[$i], $point[$i]];\n}\n$max = $_ > $max ? $_ : $max foreach(values %hash);\n# print \"\\n-----------\\n\";\nfor my $i (1..$n) {\n    if ($hash{$name[$i]} == $max && $table[$i][1] >= $max) {\n        print $name[$i] .\"\\n\";\n        last;\n    }\n}\n"}, {"source_code": "my $n = <>;\nmy @name;\nmy @point;\nmy $ans;\nmy $max = 0;\nmy %hash;\nfor my $i (1..$n) {\n    ($name[$i], $point[$i]) = split \" \", <>;\n    next if ($point[$i] < 0);\n    $hash{$name[$i]} = 0 if(not exists $hash{$name[$i]});\n    $hash{$name[$i]} += $point[$i];\n    $max = $hash{$name[$i]} if ($hash{$name[$i]} > $max);\n}\nfor my $i (1..$n) {\n    if ($point[$i] >= $max) {\n        print $name[$i] .\"\\n\";\n        last;\n    }\n}"}, {"source_code": "my $n = <>;\nmy @name;\nmy @point;\nmy $ans;\nmy $max = 0;\nmy %hash;\nmy %table;\nfor my $i (1..$n) {\n    ($name[$i], $point[$i]) = split \" \", <>;\n    $hash{$name[$i]} = 0 if(not exists $hash{$name[$i]});\n    $hash{$name[$i]} += $point[$i];\n}\n$max = $_ > $max ? $_ : $max foreach(values %hash);\n# print \"\\n-----------\\n\";\nfor my $i (1..$n) {\n    next if ($point[$i] < 0);\n    $table{$name[$i]} = 0 if(not exists $table{$name[$i]});\n    $table{$name[$i]} += $point[$i];\n    # print \"$hash{$name[$i]} $table{$name[$i]}\\n\";\n    if ($hash{$name[$i]} == $max && $table{$name[$i]} >= $max) {\n        print $name[$i] .\"\\n\";\n        last;\n    }\n}"}, {"source_code": "\nmy $n = <>;\nmy $name;\nmy $point;\nmy $ans;\nmy $max = 0;\nmy %hash;\nfor (1..$n) {\n    ($name, $point) = split \" \", <>;\n    if ($point < 0) {\n        $hash{$name} = -1000;\n        next;\n    }\n    if (exists $hash{$name} and $hash{$name} > 0) {\n        $hash{$name} += $point;\n    }\n    else {\n        $hash{$name} = $point;\n    }\n    if ($hash{$name} > $max) {\n        $max = $hash{$name};\n        $ans = $name;\n    }\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "\nmy $n = <>;\nmy @name;\nmy @point;\nmy $ans;\nmy $max = 0;\nmy %hash;\nfor my $i (1..$n) {\n    ($name[$i], $point[$i]) = split \" \", <>;\n    next if ($point[$i] < 0);\n    $hash{$name[$i]} = 0 if(not exists $hash{$name[$i]});\n    $hash{$name[$i]} += $point[$i];\n    $max = $hash{$name[$i]} if ($hash{$name[$i]} > $max);\n}\n\nundef %hash;\nfor my $i (1..$n) {\n    next if ($point[$i] < 0);\n    $hash{$name[$i]} = 0 if(not exists $hash{$name[$i]});\n    $hash{$name[$i]} += $point[$i];\n    if ($hash{$name[$i]} >= $max) {\n        print $name[$i] .\"\\n\";\n        last;\n    }\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $players = {};\nmy $score_log = [];\n\nmy $n_inputs = <>;\n\nfor ( 1 .. $n_inputs ) {\n  my $line = <>;\n  my ( $name, $score, @rest ) = split /\\s+/s, $line;\n\n  if ( not exists $players->{$name} ) {\n    $players->{$name} = 0;\n  }\n  my $new_score = $players->{$name} + $score;\n  push @{ $score_log }, { name => $name, score => $new_score };\n  $players->{ $name } = $new_score;\n}\nmy %winning_players;\nmy ( $winning_score, ) = sort { $b <=> $a } values %{ $players };\nfor ( grep { $winning_score == $players->{$_} } keys %{ $players } ) {\n  $winning_players{ $_ } = 1;\n}\nfor my $entry ( @{ $score_log } ) {\n  next unless exists $winning_players{ $entry->{name} };\n  next unless $entry->{score} > $winning_score;\n  printf \"%s\\n\", $entry->{name};\n  exit 0;\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $scores = {};\nmy $players = {};\n\nmy $n_inputs = <>;\n\nfor ( 1 .. $n_inputs ) {\n  my $line = <>;\n  my ( $name, $score, @rest ) = split /\\s+/s, $line;\n\n  if ( not exists $players->{$name} ) {\n    $players->{$name} = 0;\n  }\n  my $new_score = $players->{$name} + $score;\n  $scores->{ $new_score } = $name unless exists $scores->{ $new_score };\n  $players->{ $name } = $new_score;\n}\nmy ( $winning_score, ) = sort { $b <=> $a } values %{ $players };\n\nprintf \"%s\\n\", $scores->{ $winning_score };\n"}, {"source_code": "$n=<STDIN>;\n%hash;\n$max=0;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        $hash{$name}+=$score;\n      #  print \"# $max\\n\";\n        if($max<$hash{$name}){\n     #       print \"2 $name\\n\";\n            $max=$hash{$name};\n    #        print \"$max\\n\";\n            $winner=$name;\n        }\n}\nprint $winner;"}, {"source_code": "$n=<STDIN>;\n%hash;\n$max=-99999999999999;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        if($hash{$name})\n        {\n            $hash{$name}+=$score;\n        }\n        else\n        {\n            $hash{$name}=$score;\n        }\n}\n#print $max,\"\\n\";\n$flag=1;\nforeach $key (%hash)\n        {\n  #          print $hash{$key},\"\\n\";\n            if($hash{$key}>$max)\n            {\n                $max=$hash{$key};\n                $winner=$key;\n            }\n        }\nprint $winner;"}, {"source_code": "$n=<STDIN>;\n%hash;\n$max=-99999999999999;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        if($hash{$name})\n        {\n            $hash{$name}+=$score;\n        }\n        else\n        {\n            $hash{$name}=$score;\n        }\n      #  print \"# $max\\n\";\n        if($max<$hash{$name}){\n     #       print \"2 $name\\n\";\n            $max=$hash{$name};\n    #        print \"$max\\n\";\n            $winner=$name;\n        }\n}\nprint $winner;"}, {"source_code": "$n=<STDIN>;\n%hash;\n@list;\n$i=0;\n$max=-99999999999999;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        if($hash{$name})\n        {\n            $hash{$name}+=$score;\n        }\n        else\n        {\n            $hash{$name}=$score;\n        }\n        $list[$i++]=$name;\n        $list[$i++]=$hash{$name};\n}\n#print $max,\"\\n\";\n$flag=1;\nforeach $key (%hash)\n        {\n    #        print $hash{$key},\"\\n\";\n            if($hash{$key}>$max)\n            {\n                $max=$hash{$key};\n                $winner=$key;\n            }\n        }\n\nfor($j=0;$j<$i;$j+=2)\n{\n   # print \"$list[$j] $list[$j+1] $max\\n\";\n    if($list[$j+1]==$max && $flag)\n    {\n        print $list[$j];\n        $flag=0;\n    }\n}"}, {"source_code": "$n=<STDIN>;\n%hash;\n$max=-99999999999999;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        $hash{$name}+=$score;\n      #  print \"# $max\\n\";\n        if($max<$hash{$name}){\n     #       print \"2 $name\\n\";\n            $max=$hash{$name};\n    #        print \"$max\\n\";\n            $winner=$name;\n        }\n}\nprint $winner;"}, {"source_code": "$n=<STDIN>;\n%hash;\n$max=-99999999999999;\n$winner;\nwhile($n--)\n{\n        $tmp=<STDIN>;\n        @tmp2=split(\" \",$tmp);\n        $name=$tmp2[0]; $score=$tmp2[1];\n        if($hash{$name})\n        {\n            $hash{$name}+=$score;\n        }\n        else\n        {\n            $hash{$name}=$score;\n        }\n      #  print \"# $max\\n\";\n        if($max<$hash{$name}){\n     #       print \"2 $name\\n\";\n            $max=$hash{$name};\n    #        print \"$max\\n\";\n            $winner=$name;\n        }\n}\n$flag=1;\nforeach $key (%hash)\n        {\n            if($hash{$key}>=$max && $key==$winner && $flag)\n            {\n                print $key,\"\\n\";\n                $flag=0;\n            }\n        }\n#print $winner;"}, {"source_code": "use strict;\nuse warnings;\nuse Data::Dumper;\nmy $totalNum =  <STDIN>;\nmy %finResults;\nmy @hisResults;\nmy @inputs;\nfor(my $i = 0; $i < $totalNum; $i++){\n    my $input = <STDIN>;\n    @inputs = split( \" \", $input);\n    $finResults{$inputs[0]} += $inputs[1];\n    my @record = ($inputs[0], $finResults{$inputs[0]} );\n    push @hisResults, \\@record;\n}\nmy @finals = sort {$a <=> $b} values %finResults;\nmy $finalScore = $finals[scalar @finals - 1];\nforeach my $hisRes (@hisResults){\n    if ($hisRes->[1] >= $finalScore){\n        print $hisRes->[0];        \n        last; \n    }\n}\n\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nmy $totalNum =  <STDIN>;\nmy %finResults;\nmy @hisResults;\n\nmy @inputs;\nfor(my $i = 0; $i < $totalNum; $i++){\n    my $input = <STDIN>;\n    @inputs = split( \" \", $input);\n    $finResults{$inputs[0]} += $inputs[1];\n    my @record = ($inputs[0], $finResults{$inputs[0]} );\n    push @hisResults, \\@record;\n#    if (! exists $hisResults{$inputs[0]}){\n#        $hisResults{$inputs[0]} = [$inputs[1]];        \n#    }\n#    else{\n#        my $arrayRef = $hisResults{$inputs[0]};\n#        if($$arrayRef[$#$arrayRef] < $finResults{$inputs[0]} ){\n#            push @$arrayRef, $finResults{$inputs[0]};                      \n#        }    \n#        \n#    }         \n}\n\nmy @finals = sort {$a <=> $b} values %finResults;\n\n#print Dumper \\@finals ;\n\nmy $finalScore = $finals[scalar @finals - 1];\n#print \"HHHHHH: finalScore $finalScore \\n\";\n#print Dumper \\%finResults ;\n#print Dumper \\@hisResults;\n\n\nforeach my $hisRes (@hisResults){\n    if ($hisRes->[1] >= $finalScore){\n        print $hisRes->[0];\n        last; \n    }\n}\n\n\n#foreach my $candidate (sort {$finResults{$a} cmp $finResults{$b} }\n#           keys %finResults)\n#{\n#     print \"$candidate $finResults{$candidate} \\n\";\n#}\n\n#print Dumper \\%hisResults;"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nmy $totalNum =  <STDIN>;\nmy %finResults;\nmy @hisResults;\n\nmy @inputs;\nfor(my $i = 0; $i < $totalNum; $i++){\n    my $input = <STDIN>;\n    @inputs = split( \" \", $input);\n    $finResults{$inputs[0]} += $inputs[1];\n    my @record = ($inputs[0], $finResults{$inputs[0]} );\n    push @hisResults, \\@record;\n#    if (! exists $hisResults{$inputs[0]}){\n#        $hisResults{$inputs[0]} = [$inputs[1]];        \n#    }\n#    else{\n#        my $arrayRef = $hisResults{$inputs[0]};\n#        if($$arrayRef[$#$arrayRef] < $finResults{$inputs[0]} ){\n#            push @$arrayRef, $finResults{$inputs[0]};                      \n#        }    \n#        \n#    }         \n}\n\nmy @finals = sort {$finResults{$a} <=> $finResults{$b} } keys %finResults;\n\n#print Dumper \\@finals ;\n\nmy $finalScore = $finals[scalar @finals - 1];\n#print \"HHHHHH: finalScore $finalScore \\n\";\n#print Dumper \\%finResults ;\n#print Dumper \\@hisResults;\n\n\nforeach my $hisRes (@hisResults){\n    if ($hisRes->[1] >= $finResults{$finalScore} && $hisRes->[0] eq $finalScore){\n        print $hisRes->[0];        \n        last; \n    }\n}\n\n\n#foreach my $candidate (sort {$finResults{$a} cmp $finResults{$b} }\n#           keys %finResults)\n#{\n#     print \"$candidate $finResults{$candidate} \\n\";\n#}\n\n#print Dumper \\%hisResults;"}, {"source_code": "<>;\n@_=<>;\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n}\n\n$max= (sort {$b<=>$a} values %n)[0];\n\nundef %n;\n\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\nif ($max == $n{$a}) {$ans=$a; last }\n}\n\nprint $ans"}, {"source_code": "<>;\n@_=<>;\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n}\n\n$max= (sort {$b<=>$a} values %n)[0];\n\nundef %n;\n\nwhile(($k,$v)=each %n){\n$v==$max and $m{$k}++\n}\n\nfor(@_){\n($a,$b)=split/ /;\n$m{$a} // next;\n$n{$a}+=$b;\nif ($max == $n{$a}) {$ans=$a; last }\n}\n\nprint $ans"}, {"source_code": "<>;\n@_=<>;\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n}\n\n$max= (sort {$b<=>$a} values %n)[0];\n\nwhile(($k,$v)=each %n){\n$v==$max and $m{$k}++\n}\n\nundef %n;\n\nfor(@_){\n($a,$b)=split/ /;\n$m{$a} // next;\n$n{$a}+=$b;\nif ($max >= $n{$a}) {$ans=$a; last }\n}\n\nprint $ans"}, {"source_code": "<>;\nwhile(<>){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n$n{$a}>$max and $max=$n{$a}, $ans=$a;\n}\nprint $ans"}, {"source_code": "<>;\n@_=<>;\nfor(@_){\n($a,$b)=split/ /;\n$n{$a}+=$b;\n}\n\n$max= (sort {$b<=>$a} values %n)[0];\n\nwhile(($k,$v)=each %n){\n$v==$max and $m{$k}++\n}\n\nundef %n;\n\nfor(@_){\n($a,$b)=split/ /;\n$m{$a} // next;\n$n{$a}+=$b;\nif ($max == $n{$a}) {$ans=$a; last }\n}\n\nprint $ans"}], "src_uid": "c9e9b82185481951911db3af72fd04e7"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tmy( $L ) = reverse sort split '';\n\t\n\tmy $A = 'a';\n\t\n\tmy $ans;\n\t\n\tfor my $i ( 1 .. 26 ){\n\t\tif( $A eq $L ){\n\t\t\t$ans = $i;\n\t\t\tlast;\n\t\t\t}\n\t\t$A ++;\n\t\t}\n\t\n\tprint $ans;\n\t}", "positive_code": [{"source_code": "<>;\r\n\r\nprint -96 + ord +( sort split '', <> )[ -1 ], $/ while <>"}, {"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\t\r\n\t$A = a;\r\n\t\r\n\tfor $i ( 1 .. 26 ){\r\n\t\t/$A/ and $B = $i;\r\n\t\t$A ++;\r\n\t\t}\r\n\t\r\n\tprint $B . $/\r\n\t}"}], "negative_code": [], "src_uid": "4841cbc3d3ef29929690b78e30fbf22e"}
{"source_code": "use 5.020;\nuse warnings;\nuse utf8;\n\n#下面列举出几个特别难搞的东西,这里出错的几率很大\n# 6 6 3 -1 3 4 3 3\n# 5 3 2 5 4 -1 10 9\n# 1 -1 2 -1 3 -1 4 -1 5 -1 6 -1 7 -1 8 -1 24\n# 1  2  3  4  5  6  7  8 -1 24\nsub readNext {\n    my $line = <STDIN>;\n    chomp($line);\n    return $line;\n}\n\nmy $count = int( &readNext() );\nmy $index = 0;\n\nREAD: while ($count) {\n\n    $index++;\n\n    &readNext();\n    my @array = split /\\s+/, &readNext();\n\n    # if ( $index == 369 ) {\n    #     say join( \" \", @array );\n    # }\n\n    my @adjacentArray = ();\n    my @presentArray  = ();\n\n    my $lastNumber;\n    my $lastIndex        = -1;\n    my $lastPushedIndex  = -1;\n    my $boolLastIsAbsent = 0;\n    my $mForArray        = 0;\n\n    for my $i ( 0 .. $#array ) {\n\n        my $item = int( $array[$i] );\n\n        if ( $item == -1 ) {\n\n            if (   defined($lastNumber)\n                && $lastNumber != -1\n                && !$boolLastIsAbsent\n                && $lastPushedIndex != $lastIndex )\n            {\n                push( @adjacentArray, $lastNumber );\n                $lastPushedIndex = $lastIndex;\n\n            }\n\n            $boolLastIsAbsent = 1;\n        }\n        else {\n            if ( $boolLastIsAbsent && $lastPushedIndex != $i ) {\n                push( @adjacentArray, $item );\n                $lastPushedIndex = $i;\n            }\n            $boolLastIsAbsent = 0;\n\n            if ( defined($lastNumber) && $lastNumber != -1 ) {\n                my $gap = abs( $lastNumber - $item );\n                if ( $gap > $mForArray ) {\n                    $mForArray = $gap;\n                }\n            }\n        }\n\n        $lastNumber = $item;\n        $lastIndex  = $i;\n    }\n\n    if (@adjacentArray) {\n\n        # say join( \",\", @adjacentArray );\n\n        @adjacentArray = sort { $a <=> $b } @adjacentArray;\n\n        my $k =\n          int(\n            ( $adjacentArray[0] + $adjacentArray[$#adjacentArray] ) / 2 + 0.5 );\n\n        # say \"the k is $k\";\n\n        my $mforK = (\n            (\n                ( $k - $adjacentArray[0] ) >\n                  ( $adjacentArray[$#adjacentArray] - $k )\n            )\n            ? ( $k - $adjacentArray[0] )\n            : ( $adjacentArray[$#adjacentArray] - $k )\n        );\n\n        # say \"mfork $mforK   mForArray $mForArray\";\n\n        my $m = $mforK > $mForArray ? $mforK : $mForArray;\n\n        say $m. \" \" . $k;\n    }\n    else {\n        say \"0 0\";\n    }\n\n    $count--;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t$_ = <>, chomp;\n\t\n\t$debug and print \"[$_]\";\n\t\n\t0 while s/-1\\K( -1)+//g;\n\t\n\t$debug and print \"[$_]\";\n\t\n\t@_ = split;\n\t\n\tif( ! grep { $_ != -1 } @_ ){\n\t\tprint \"0 42\";\n\t\tnext;\n\t\t}\n\t\n\tmy @A;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tnext if $_[ $i ] != -1;\n\t\t\n\t\tpush @A, $_[ $i - 1 ] if $i - 1 >= 0;\n\t\tpush @A, $_[ $i + 1 ] if $i + 1 <= @_ - 1;\n\t\t}\n\t\n\t$debug and print \"A:[@A]\";\n\t\n\tmy $undef;\n\t\n\tif( @A ){\n\t\tmy( $min, $max ) = ( sort { $a <=> $b } @A )[ 0, -1 ];\n\t\tmy $diff = $max - $min;\n\t\t\n\t\t$undef = $min + ( $diff >> 1 );\n\t\t}\n\t\n\tif( not defined $undef ){\n\t\t( $undef ) = grep { $_ != -1 } @_;\n\t\t}\n\t\n\t$_ == -1 and $_ = $undef for @_;\n\t\n\t$debug and print \"_:[@_]\";\n\t\n\tmy @B;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tpush @B, abs( $_[ $i ] - $_[ $i + 1 ] );\n\t\t}\n\t\n\tmy $max_diff = ( sort { $b <=> $a } @B )[ 0 ] // 0;\n\t\n\tprint \"$max_diff $undef\";\n\t}"}], "negative_code": [{"source_code": "use 5.020;\nuse warnings;\nuse utf8;\n\n# 6 6 3 -1 3 4 3 3 这个情况很难,确定相邻的问题\nsub readNext {\n    my $line = <STDIN>;\n    chomp($line);\n    return $line;\n}\n\nmy $count = int( &readNext() );\nmy $index = 0;\nREAD: while ($count) {\n\n    $index++;\n\n    &readNext();\n    my @array = split / /, &readNext();\n\n    if ( $index == 369 ) {\n        say join( \"-\", @array );\n    }\n\n    my $min;\n    my $max;\n\n    my $minIndex;\n    my $maxIndex;\n\n    my $lastNumber;\n    my $lastGap;\n    my $lastIndex;\n\n    for my $i ( 0 .. $#array ) {\n\n        my $item = int( $array[$i] );\n\n        if ( $item == -1 ) {\n            next;\n        }\n\n        if ( defined($lastIndex) ) {\n            if ( ( $i - $lastIndex ) == 1 ) {\n                my $gap = abs( $item - $lastNumber );\n                if ( defined($lastGap) ) {\n                    $lastGap = $gap > $lastGap ? $gap : $lastGap;\n                }\n                else {\n                    $lastGap = $gap;\n                }\n            }\n        }\n\n        if ( defined($min) ) {\n\n            if ( $item < $min ) {\n                $min      = $item;\n                $minIndex = $i;\n            }\n\n            if ( $item > $max ) {\n                $max      = $item;\n                $maxIndex = $i;\n            }\n        }\n        else {\n            $min = $item;\n            $max = $item;\n\n            $minIndex = $i;\n            $maxIndex = $i;\n        }\n\n        $lastIndex  = $i;\n        $lastNumber = $item;\n    }\n\n    # say(\"max gap :$lastGap, min:$minIndex, max:$maxIndex\");\n\n    if ( defined($min) ) {\n\n        if ( $minIndex == $maxIndex ) {\n            say \"0 $min\";\n        }\n\n        elsif ( abs( $maxIndex - $minIndex ) == 1 ) {\n            say( $lastGap . \" \" . $min );\n        }\n        else {\n            my $k = int( ( $max + $min ) / 2 + 0.999 );\n            my $m =\n                ( ( $max - $k ) > ( $k - $min ) )\n              ? ( $max - $k )\n              : ( $k - $min );\n            if ( defined($lastGap) ) {\n                say( ( ( $lastGap > $m ) ? $lastGap : $m ) . \" \" . $k );\n            }\n            else {\n                say $m. \" \" . $k;\n            }\n        }\n    }\n    else {\n        say \"0 0\";\n    }\n\n    $count--;\n}\n"}, {"source_code": "use 5.020;\nuse warnings;\nuse utf8;\n\n# 6 6 3 -1 3 4 3 3 这个情况很难,确定相邻的问题\nsub readNext {\n    my $line = <STDIN>;\n    chomp($line);\n    return $line;\n}\n\nmy $count = int( &readNext() );\n\nREAD: while ($count) {\n    &readNext();\n    my @array = split / /, &readNext();\n\n    my $min;\n    my $max;\n\n    my $minIndex;\n    my $maxIndex;\n\n    my $lastNumber;\n    my $lastGap;\n    my $lastIndex;\n    for my $i ( 0 .. $#array ) {\n\n        my $item = int( $array[$i] );\n\n        if ( $item == -1 ) {\n            next;\n        }\n\n        if ( defined($lastIndex) ) {\n            if ( ( $i - $lastIndex ) == 1 ) {\n                my $gap = abs( $item - $lastNumber );\n                if ( defined($lastGap) ) {\n                    $lastGap = $gap > $lastGap ? $gap : $lastGap;\n                }\n                else {\n                    $lastGap = $gap;\n                }\n            }\n        }\n\n        if ( defined($min) ) {\n\n            if ( $item < $min ) {\n                $min      = $item;\n                $minIndex = $i;\n            }\n\n            if ( $item > $max ) {\n                $max      = $item;\n                $maxIndex = $i;\n            }\n        }\n        else {\n            $min = $item;\n            $max = $item;\n\n            $minIndex = $i;\n            $maxIndex = $i;\n        }\n\n        $lastIndex  = $i;\n        $lastNumber = $item;\n    }\n\n    # say(\"max gap :$lastGap, min:$minIndex, max:$maxIndex\");\n\n    if ( defined($min) ) {\n\n        if ( $minIndex == $maxIndex ) {\n            say \"0 $min\";\n        }\n\n        elsif ( abs( $maxIndex - $minIndex ) == 1 ) {\n            say( $lastGap . \" \" . $min );\n        }\n\n        else {\n            my $k = int( ( $max + $min ) / 2 + 0.9 );\n\n            if ( defined($lastGap) ) {\n                say $lastGap. \" \" . $k;\n            }\n            else {\n                my $m =\n                    ( ( $max - $k ) > ( $k - $min ) )\n                  ? ( $max - $k )\n                  : ( $k - $min );\n                say $m. \" \" . $k;\n            }\n        }\n    }\n    else {\n        say \"0 0\";\n    }\n\n    $count--;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t$_ = <>, chomp;\n\t\n\t$debug and print \"[$_]\";\n\t\n\t0 while s/-1\\K( -1)+//g;\n\ts/^-1 //;\n\ts/ -1$//;\n\t\n\t$debug and print \"[$_]\";\n\t\n\t@_ = split;\n\t\n\tif( ! grep { $_ != -1 } @_ ){\n\t\tprint \"0 42\";\n\t\tnext;\n\t\t}\n\t\n\tmy @A;\n\t\n\tfor my $i ( 1 .. @_ - 2 ){\n\t\tnext if $_[ $i ] != -1;\n\t\t\n\t\tpush @A, $_[ $i - 1 ], $_[ $i + 1 ];\n\t\t}\n\t\n\t$debug and print \"A:[@A]\";\n\t\n\tmy $undef;\n\t\n\tif( @A ){\n\t\tmy( $min, $max ) = ( sort { $a <=> $b } @A )[ 0, -1 ];\n\t\tmy $diff = $max - $min;\n\t\t\n\t\t$undef = $min + ( $diff >> 1 );\n\t\t}\n\t\n\tif( not defined $undef ){\n\t\t( $undef ) = grep { $_ != -1 } @_;\n\t\t}\n\t\n\t$_ == -1 and $_ = $undef for @_;\n\t\n\t$debug and print \"_:[@_]\";\n\t\n\tmy @B;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tpush @B, abs( $_[ $i ] - $_[ $i + 1 ] );\n\t\t}\n\t\n\tmy $max_diff = ( sort { $b <=> $a } @B )[ 0 ] // 0;\n\t\n\tprint \"$max_diff $undef\";\n\t}"}, {"source_code": "use 5.020;\nuse warnings;\nuse utf8;\n\nsub readNext {\n    my $line = <STDIN>;\n    chomp($line);\n    return $line;\n}\n\nmy $count = int( &readNext() );\n\nREAD: while ($count) {\n    &readNext();\n    my @array = split / /, &readNext();\n\n    my $min;\n    my $max;\n\n    my $minIndex;\n    my $maxIndex;\n\n    for my $i ( 0 .. $#array ) {\n\n        my $item = int( $array[$i] );\n\n        if ( $item == -1 ) {\n            next;\n        }\n\n        if ( defined($min) ) {\n\n            if ( $item < $min ) {\n                $min      = $item;\n                $minIndex = $i;\n            }\n\n            if ( $item > $max ) {\n                $max      = $item;\n                $maxIndex = $i;\n            }\n        }\n        else {\n            $min = $item;\n            $max = $item;\n\n            $minIndex = $i;\n            $maxIndex = $i;\n        }\n    }\n\n    if ( defined($min) ) {\n        if ( $minIndex == $maxIndex ) {\n            say \"0 $min\";\n        }\n        elsif ( abs( $maxIndex - $minIndex ) == 1 ) {\n            say( ( $max - $min ) . \" \" . $min );\n        }\n        else {\n            my $k = int( ( $max + $min ) / 2 + 0.9 );\n            my $m =\n              ( ( $max - $k ) > ( $k - $min ) ) ? ( $max - $k ) : ( $k - $min );\n            say $m. \" \" . $k;\n        }\n    }\n    else {\n        say \"0 0\";\n    }\n\n    $count--;\n}\n"}, {"source_code": "use 5.020;\nuse warnings;\nuse utf8;\n\n# 6 6 3 -1 3 4 3 3 这个情况很难,确定相邻的问题\nsub readNext {\n    my $line = <STDIN>;\n    chomp($line);\n    return $line;\n}\n\nmy $count = int( &readNext() );\n\nREAD: while ($count) {\n    &readNext();\n    my @array = split / /, &readNext();\n\n    my $min;\n    my $max;\n\n    my $minIndex;\n    my $maxIndex;\n\n    my $lastNumber;\n    my $lastGap;\n    my $lastIndex;\n    for my $i ( 0 .. $#array ) {\n\n        my $item = int( $array[$i] );\n\n        if ( $item == -1 ) {\n            next;\n        }\n\n        if ( defined($lastIndex) ) {\n            if ( ( $i - $lastIndex ) == 1 ) {\n                my $gap = abs( $item - $lastNumber );\n                if ( defined($lastGap) ) {\n                    $lastGap = $gap > $lastGap ? $gap : $lastGap;\n                }\n                else {\n                    $lastGap = $gap;\n                }\n            }\n        }\n\n        if ( defined($min) ) {\n\n            if ( $item < $min ) {\n                $min      = $item;\n                $minIndex = $i;\n            }\n\n            if ( $item > $max ) {\n                $max      = $item;\n                $maxIndex = $i;\n            }\n        }\n        else {\n            $min = $item;\n            $max = $item;\n\n            $minIndex = $i;\n            $maxIndex = $i;\n        }\n\n        $lastIndex  = $i;\n        $lastNumber = $item;\n    }\n\n    # say(\"max gap :$lastGap, min:$minIndex, max:$maxIndex\");\n\n    if ( defined($min) ) {\n\n        if ( $minIndex == $maxIndex ) {\n            say \"0 $min\";\n        }\n\n        elsif ( abs( $maxIndex - $minIndex ) == 1 ) {\n            say( $lastGap . \" \" . $min );\n        }\n        else {\n            my $k = int( ( $max + $min ) / 2 + 0.9 );\n            my $m =\n                ( ( $max - $k ) > ( $k - $min ) )\n              ? ( $max - $k )\n              : ( $k - $min );\n            if ( defined($lastGap) ) {\n                say( ( ( $lastGap > $m ) ? $lastGap : $m ) . \" \" . $k );\n            }\n            else {\n                say $m. \" \" . $k;\n            }\n        }\n    }\n    else {\n        say \"0 0\";\n    }\n\n    $count--;\n}\n"}], "src_uid": "8ffd80167fc4396788b745b53068c9d3"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy @pairs;\n\nwhile(<>){\t\n\tmy $i = 0;\n\t\n\t@_ = map { [ ++ $i, split ' ', <> ] } 1 .. $_;\n\t\n\t@pairs = ();\n\t\n\tmy @V = 1 .. 3;\n\t\n\tfor( 1 .. 3 ){\n\t\t_grep( \\@_, @V[ 0, 1 ], @V );\n\t\t_grep( \\@_, @V[ 0, 0 ], @V );\n\t\tpush @V, shift @V;\n\t\t}\n\t\n\twhile( @_ ){\n\t\tpush @pairs, join ' ', map $_->[ 0 ], splice @_, 0, 2;\n\t\t}\n\t\n\tprint for @pairs;\n\t}\n\nsub _grep {\n\tmy( $A, $eq1, $eq2, @S ) = @_;\n\t\n\t@{ $A } = sort {\n\t\t$a->[ $S[ 0 ] ] <=> $b->[ $S[ 0 ] ] ||\n\t\t$a->[ $S[ 1 ] ] <=> $b->[ $S[ 1 ] ] ||\n\t\t$a->[ $S[ 2 ] ] <=> $b->[ $S[ 2 ] ]\n\t\t} @{ $A };\n\t\n\tfor( my $i = 0; $i < @{ $A } - 1; $i ++ ){\n\t\tif( $A->[ $i ][ $eq1 ] == $A->[ $i + 1 ][ $eq1 ] and $A->[ $i ][ $eq2 ] == $A->[ $i + 1 ][ $eq2 ] ){\n\t\t\tpush @pairs, join ' ', $A->[ $i ][ 0 ], $A->[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $A->[ $i ][ 0 ], $A->[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t@{ $A } = grep { $_->[ 0 ] } @{ $A };\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy $i = 0;\n\t\n\t@_ = map { [ ++ $i, split ' ', <> ] } 1 .. $_;\n\t\n\tmy @pairs;\n\t\n\t####### BEGIN: x+y, x+z, y+z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\t$debug and print 'init: ', join ' ', map $_->[ 0 ], @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] and $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] and $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] and $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t####### END: x+y, x+z, y+z\n\t\n\t####### BEGIN: x, y, z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\t$debug and print 'init: ', join ' ', map $_->[ 0 ], @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t####### END: x, y, z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\tprint for @pairs;\n\t\n\twhile( @_ ){\n\t\tprint join ' ', map $_->[ 0 ], shift @_, shift @_;\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nmy @pairs;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy $i = 0;\n\t\n\t@_ = map { [ ++ $i, split ' ', <> ] } 1 .. $_;\n\t\n\t@pairs = ();\n\t\n#\t_grep( \\@_, 1, 2, 1, 2, 3 );\n#\t_grep( \\@_, 2, 3, 2, 3, 1 );\n#\t_grep( \\@_, 3, 1, 3, 1, 2 );\n\t\n#\t_grep( \\@_, 1, 1, 1, 2, 3 );\n#\t_grep( \\@_, 2, 2, 2, 3, 1 );\n#\t_grep( \\@_, 3, 3, 3, 1, 2 );\n\t\n\t_grep( \\@_, 1, 2, 1, 2, 3 );\n\t_grep( \\@_, 1, 1, 1, 2, 3 );\n\t\n\t_grep( \\@_, 2, 3, 2, 3, 1 );\n\t_grep( \\@_, 2, 2, 2, 3, 1 );\n\t\n\t_grep( \\@_, 3, 1, 3, 1, 2 );\n\t_grep( \\@_, 3, 3, 3, 1, 2 );\n\t\n\twhile( @_ ){\n\t\tpush @pairs, join ' ', map $_->[ 0 ], shift @_, shift @_;\n\t\t}\n\t\n\tprint for @pairs;\n\t}\n\nsub _grep {\n\tmy( $ref_arr, $eq1, $eq2, @sort_seq ) = @_;\n\t\n\t@{ $ref_arr } = sort {\n\t\t$a->[ $sort_seq[ 0 ] ] <=> $b->[ $sort_seq[ 0 ] ] ||\n\t\t$a->[ $sort_seq[ 1 ] ] <=> $b->[ $sort_seq[ 1 ] ] ||\n\t\t$a->[ $sort_seq[ 2 ] ] <=> $b->[ $sort_seq[ 2 ] ]\n\t\t} @{ $ref_arr };\n\t\n\tfor( my $i = 0; $i < @{ $ref_arr } - 1; $i ++ ){\n\t\tif( $ref_arr->[ $i ][ $eq1 ] == $ref_arr->[ $i + 1 ][ $eq1 ] and $ref_arr->[ $i ][ $eq2 ] == $ref_arr->[ $i + 1 ][ $eq2 ] ){\n\t\t\tpush @pairs, join ' ', $ref_arr->[ $i ][ 0 ], $ref_arr->[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $ref_arr->[ $i ][ 0 ], $ref_arr->[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@{ $ref_arr } = grep { $_->[ 0 ] } @{ $ref_arr };\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @{ $ref_arr };\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy $i = 0;\n\t\n\t@_ = map { [ ++ $i, split ' ', <> ] } 1 .. $_;\n\t\n\tmy @pairs;\n\t\n\t####### BEGIN: x+y, x+z, y+z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\t$debug and print 'init: ', join ' ', map $_->[ 0 ], @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] and $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] and $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] and $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t####### END: x+y, x+z, y+z\n\t\n\t####### BEGIN: x, y, z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\t$debug and print 'init: ', join ' ', map $_->[ 0 ], @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t####### END: x, y, z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\twhile( @_ ){\n\t\tpush @pairs, join ' ', map $_->[ 0 ], shift @_, shift @_;\n\t\t}\n\t\n\tprint for @pairs;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy $i = 0;\n\t\n\t@_ = map { [ ++ $i, split ' ', <> ] } 1 .. $_;\n\t\n\tmy @pairs;\n\t\n\t####### BEGIN: x+y, x+z, y+z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\t$debug and print 'init: ', join ' ', map $_->[ 0 ], @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] and $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] and $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] and $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t####### END: x+y, x+z, y+z\n\t\n\t####### BEGIN: x, y, z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\t$debug and print 'init: ', join ' ', map $_->[ 0 ], @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 1 ] == $_[ $i + 1 ][ 1 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 2 ] == $_[ $i + 1 ][ 2 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t@_ = sort {\n\t\t$a->[ 3 ] <=> $b->[ 3 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 1 ] <=> $b->[ 1 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( $_[ $i ][ 3 ] == $_[ $i + 1 ][ 3 ] ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@pairs: [@pairs]\";\n\t\n\t@_ = grep { $_->[ 0 ] } @_;\n\t\n\t$debug and print 'left: ', join ' ', map $_->[ 0 ], @_;\n\t\n\t####### END: x, y, z\n\t\n\t@_ = sort {\n\t\t$a->[ 1 ] <=> $b->[ 1 ] ||\n\t\t$a->[ 2 ] <=> $b->[ 2 ] ||\n\t\t$a->[ 3 ] <=> $b->[ 3 ] \n\t\t} @_;\n\t\n\tfor( my $i = 0; $i < @_ - 1; $i ++ ){\n\t\tif( 1 ){\n\t\t\tpush @pairs, join ' ', $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$_ = 0 for $_[ $i ][ 0 ], $_[ $i + 1 ][ 0 ];\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n#\twhile( @_ ){\n#\t\tpush @pairs, join ' ', map $_->[ 0 ], shift @_, shift @_;\n#\t\t}\n\t\n\tprint for @pairs;\n\t}"}], "negative_code": [], "src_uid": "3d92a54be5c544b313f1e87f7b9cc5c8"}
{"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n", "positive_code": [{"source_code": "$s=<>;\n$t=<>;\nchomp($s,$t);\n@s=split '',$s;\nmap {$h{$_}++} split '',$t;\n$y=$w=0;                                                                        \nfor(0..@s) {\n  if($h{$s[$_]}) {\n    --$h{$s[$_]};\n    ++$y;\n    delete $s[$_];\n  }\n}\nfor(@s) {\n  $_=$_ eq uc$_?lc:uc;\n  if($h{$_}) {\n    --$h{$_};\n    ++$w;\n  }\n}\nprint \"$y $w\\n\";"}, {"source_code": "$s=<>;                                                                          \n$t=<>;\nchomp($s,$t);\n@s=split '',$s;\nmap {$h{$_}++} split '',$t;\n$y=$w=0;\nfor(@s) {\n  --$h{$_},++$y,$_='*' if $h{$_};\n}\nfor(@s) {\n  $_=$_ eq uc$_?lc:uc;\n  --$h{$_},++$w if $h{$_};\n}\nprint \"$y $w\\n\";"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}, {"source_code": "chomp (my @s = split /\\s*/, <STDIN>);\nchomp (my @t = split /\\s*/, <STDIN>);\n\nmy (%tCnt);\n$tCnt{$_} = 0 foreach ('a' .. 'z', 'A' .. 'Z');\n$tCnt{$_}++ foreach (@t);\n\nmy ($yCnt, $wCnt) = (0, 0);\nforeach (0 .. $#s) {\n  $x = $s[$_];\n  if ($tCnt{$x}) {\n    $yCnt++;\n    $tCnt{$x}--;\n    delete $s[$_];\n  }\n}\nforeach (0 .. $#s) {\n  $x = $s[$_];\n  $x = (uc($x) eq $x) ? lc($x) : uc($x);\n  if ($tCnt{$x}) {\n    $wCnt++;\n    $tCnt{$x}--;\n    delete $s[$_];\n  }\n}\n\nprintf \"$yCnt $wCnt\\n\";"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}, {"source_code": "while(<>){\n\tchomp;\n\t@a = split//;\n\t$_ = <>, chomp;\n\t@b = split//;\n\tundef %h;\n\tfor (@b){\n\t\t$h{$_}++;\n\t\t}\n\t$c = $d = 0;\n\tfor (@a){\n\t\tif ($h{$_} ){\n\t\t\t$h{$_}--;\n\t\t\t$c++;\n\t\t\t$_ = aa;\n\t\t\t}\n\t\t}\n\tfor (@a){\n\t\tif ($h{(lc)} + $h{(uc)})\n\t\t{ $d++ ; $h{(lc)} and $h{(lc)}--; $h{(uc)} and $h{(uc)}--}\n\t\t}\n#\t$d -= $c;\n#\t$d < 0 and $d = 0;\n\tprint \"$c $d\\n\";\n\t\n\t}"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d"}, {"source_code": "chomp(@_ = <>);\n@a = split//, $_[0];\n$h{$_}++ for split//, pop @_;\n$h{$_} && ($h{$_}--, $c++, $_ = _) for @a;\n( ($h{(lc)} && $h{(lc)}--) || ($h{(uc)} && $h{(uc)}--) ) && $d++ for @a;\nprint 0+$c, \" \", 0+$d\n"}], "negative_code": [{"source_code": "chomp (my @s = split /\\s*/, <STDIN>);\nchomp (my @t = split /\\s*/, <STDIN>);\n\nmy (%tCnt);\n$tCnt{$_} = 0 foreach ('a' .. 'z', 'A' .. 'Z');\n$tCnt{$_}++ foreach (@t);\n\nmy ($yCnt, $wCnt) = (0, 0);\nforeach (@s) {\n  if ($tCnt{$_}) {\n    $yCnt++;\n    $tCnt{$_}--;\n  } else {\n    $_ = (uc($_) eq $_) ? lc($_) : uc($_);\n    \n    if ($tCnt{$_}) {\n        $wCnt++;\n        $tCnt{$_}--;\n    }\n  }\n}\n\nprintf \"$yCnt $wCnt\\n\";"}, {"source_code": "chomp (my @s = split /\\s*/, <STDIN>);\nchomp (my @t = split /\\s*/, <STDIN>);\n\nsub incs {\n  foreach (reverse (0 .. $#s)) {\n    $s[$_] = chr (1 + ord ($s[$_]));\n    if ($s[$_] eq '{') {\n      $s[$_] = 'a';\n    } else {\n      return;\n    }\n  }\n}\n\n&incs;\n\nmy $sum = 0;\nforeach (0 .. $#s) {\n  $sum += (ord ($t[$_])) - (ord ($s[$_]));\n  last if ($sum > 0);\n}\n\nif ($sum > 0) {\n  printf \"%s\\n\", join \"\", @s;\n} else {\n  printf \"No such string\\n\";\n}"}, {"source_code": "chomp (my @s = split /\\s*/, <STDIN>);\nchomp (my @t = split /\\s*/, <STDIN>);\n\nmy (%tCnt);\n$tCnt{$_} = 0 foreach ('a' .. 'z', 'A' .. 'Z');\n$tCnt{$_}++ foreach (@t);\n\nmy ($yCnt, $wCnt) = (0, 0);\nforeach (@s) {\n  if ($tCnt{$_}) {\n    $yCnt++;\n    $tCnt{$_}--;\n  } else {\n    $_ = (uc($_) eq $_) ? lc($_) : uc($_);\n    \n    if ($tCnt{$_}) {\n        $wCnt++;\n        $tCnt{$_}--;\n    }\n  }\n}\n\nprintf \"$yCnt $wCnt\\n\";\n"}, {"source_code": "while(<>){\n\tchomp;\n\t@a = split//;\n\t$_ = <>, chomp;\n\t@b = split//;\n\tundef %h;\n\tfor (@b){\n\t\t$h{$_}++;\n\t\t}\n\t$c = $d = 0;\n\tfor (@a){\n\t\tif ($h{$_} ){\n\t\t\t$h{$_}--;\n\t\t\t$c++\n\t\t\t}\n\t\t}\n\tfor (@a){\n\t\tif ($h{(lc)} + $h{(uc)}){ $d++ }\n\t\t}\n\t$d -= $c;\n\t$d < 0 and $d = 0;\n\tprint \"$c $d\\n\";\n\t\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t@a = split//;\n\t$_ = <>, chomp;\n\t@b = split//;\n\tundef %h;\n\tfor (@b){\n\t\t$h{$_}++;\n\t\t}\n\t$c = $d = 0;\n\tfor (@a){\n\t\tif ($h{$_} ){\n\t\t\t$h{$_}--;\n\t\t\t$c++;\n\t\t\t$_ = aa;\n\t\t\t}\n\t\t}\n\tfor (@a){\n\t\tif ($h{(lc)} + $h{(uc)}){ $d++ }\n\t\t}\n#\t$d -= $c;\n#\t$d < 0 and $d = 0;\n\tprint \"$c $d\\n\";\n\t\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t@a = split//;\n\t$_ = <>, chomp;\n\t@b = split//;\n\tundef %h;\n\tfor (@b){\n\t\t$h{$_}++;\n\t\t}\n\t$c = $d = 0;\n\tfor (@a){\n\t\tif ($h{$_} ){\n\t\t\t$h{$_}--;\n\t\t\t$c++\n\t\t\t}\n\t\t\telsif ($h{(lc)} + $h{(uc)}){\n\t\t\t\t$d++\n\t\t\t\t}\n\t\t}\n\tprint \"$c $d\\n\";\n\t\n\t}"}], "src_uid": "96e2ba997eff50ffb805b6be62c56222"}
{"source_code": "$a=0;\nwhile(<STDIN>)\n{\n\tchomp;\n\t$a+=$_;\n}\n\nif ($a % 2 == 1) {\n    print \"7\";\n\t$a-=3;\n} else {\n\tprint \"1\";\n\t$a-=2;\n}\n\nwhile($a > 0) {\n\tprint \"1\";\n\t$a-=2;\n}", "positive_code": [{"source_code": "$a = <>;\n$ans = '';\nif ($a%2==1)\n{\n$ans = '7';\n$a-=3;\n}\nprint $ans;\nfor(my $i=0;$i<$a;$i+=2){\nprint '1';\n}"}, {"source_code": "$a = <STDIN>;\n\nif ($a % 2 == 0) {\n    print '1';\n}\nelse {\n    print '7';\n}\nprint '1' x ($a / 2 - 1)\n"}, {"source_code": "chomp($n=<STDIN>);\nif ($n % 2 == 1){\n  print 7;\n  $n -= 3;\n}\nwhile ($n > 0){\n  print 1;\n  $n -= 2;\n}"}, {"source_code": "$a = <STDIN>;\n\nif($a%2==1){\n\t$s = \"7\";\n\t$a-=3;\n}\n\nwhile($a>0){\n\t$s=$s.\"1\";\n\t$a-=2;\n}\t\n\nprint \"$s\\n\"\n"}, {"source_code": "$n=<STDIN>;\nchomp($n);\nif($n % 2 ==1) {\n  print 7;\n  $n=$n-3\n}\nwhile($n>0) {\n  print 1;\n  $n=$n-2;\n}\n\n"}, {"source_code": "$_ = <STDIN>; my ($n) = split;\nif ($n % 2 == 0) {\n    for (my $i = 0; 2 * $i < $n; $i++) {\n        print \"1\";\n    }\n}\nelse {\n    print \"7\";\n    $n = $n - 3;\n    for (my $i = 0; 2 * $i < $n; $i++) {\n        print \"1\";\n    }\n}\nprint \"\\n\";"}, {"source_code": "#use strict;\nuse warnings;\n\n$n=<STDIN>;\nif($n%2==1) {\n    print \"7\";\n}\nprint \"1\"x(($n-$n%2*3)/2);"}, {"source_code": "$_ = <STDIN>; my ($n) = split;\nif ($n % 2 == 0) {\n    while ($n) {\n        print(1);\n        $n -= 2;\n    }\n} else {\n    print(7);\n    $n -= 3;\n    while ($n) {\n        print(1);\n        $n -= 2;\n    }\n}\nprint(\"\\n\");"}, {"source_code": "  $amount=<STDIN>;\n  $one = $amount/2;\n  if ($amount%2!=0){\n   print(7);\n   $one--;\n  }\n  for($i= 1;$i<=$one;$i++){\n    print (1);\n  }"}, {"source_code": "#!/usr/bin/perl -w\nmy $x = <STDIN>;\nmy $a = '';\nmy $b = 2;\nmy $t = 3;\nif ($x % $b != 0){\n    $x = $x - $t;\n    print '7';\n}\nwhile ($x > 0){\n    $x = $x - $b;\n    print '1';\n}"}, {"source_code": "my $n = <STDIN>;\n\nif ($n % 2 == 1) {\n    print '7';\n    $n -= 3;\n}\n\nprint '1' x ($n/2);"}], "negative_code": [{"source_code": "$a = <STDIN>;\n\nwhile ($a >= 6) {\n    print \"9\";\n    $a -= 6;\n}\n\nif ($a >= 3) {\n    print \"7\";\n}\nelsif ($a >= 2) {\n    print \"1\";\n}\n"}, {"source_code": "$a = <STDIN>;\n\nif ($a % 2 == 0) {\n    print '1' x ($a / 2 - 1) . '1';\n}\nelse {\n    print '1' x ($a / 2 - 1) . '7';\n}\n"}, {"source_code": "$a = <STDIN>;\n\nif($a%2==1){\n\t$s = \"7\";\n\t$a-=3;\n}\n\nfor($a>0){\n\t$s=$s.\"1\";\n\t$a-=2;\n}\t\n\nprint \"$s\\n\"\n"}, {"source_code": "$a = <STDIN>;\n\nif($a%2==1){\n\t$s = \"7\";\n\t$a-=3;\n\t$s=$s.\"1\";\n\t$a-=2;\n}\n\nfor($a>0){\n\t$s=$s.\"1\";\n\t$a-=2;\n}\t\n\nprint \"$s\\n\"\n"}, {"source_code": "#use strict;\nuse warnings;\n\n$n=<STDIN>;\nif($n>=6) {\n    print 9;\n} else {\n    if($n>=3) {\n        print \"7\";\n    } else {\n        if($n>=2) {\n            print \"1\";\n        }\n    }\n}"}, {"source_code": "#use strict;\nuse warnings;\n\n$n=<STDIN>;\nif($n>=6)\n{\n    print \"9\\n\";\n} else {\n    if($n>=3) {\n        print \"7\\n\";\n    } else {\n        if($n>=2) {\n            print \"1\\n\";\n        }\n    }\n}"}, {"source_code": "#use strict;\nuse warnings;\n\n$n=<STDIN>;\nif($n>=6)\n{\n    print \"9\";\n} else {\n    if($n>=3) {\n        print \"7\";\n    } else {\n        if($n>=2) {\n            print \"1\";\n        }\n    }\n}"}, {"source_code": "  $amount=<STDIN>;\n  $nine = $amount/6;\n  $amount = $amount%6;\n  $seven = $amount/3;\n  $amount = $amount%3;\n  $one = $amount/2;\n  for($i= 1;$i<=$nine;$i++){\n    print (9);\n  }\n  for($i= 1;$i<=$seven;$i++){\n    print(7);\n  }\n  for($i= 1;$i<=$one;$i++){\n    print (1);\n  }"}], "src_uid": "4ebea3f56ffd43efc9e1496a0ef7fa2d"}
{"source_code": "<STDIN>;\nmy @arr;\nforeach $line ( <STDIN> ) {\n    chomp( $line );\n    my @values = split(':', $line);\n    push(@arr, $values[0]*60 + $values[1]);\n}\n\nmy @sorterArr = sort {$a <=> $b} @arr;\n\nmy $prev = 0;\nmy @diff;\n\nforeach $time (@sorterArr) {\n    push(@diff, $time - $prev);\n    $prev = $time;\n}\n\nmy $res = $diff[0] + 24*60-$prev-1;\nforeach $x (@diff) {\n    if ($res < $x-1) {\n        $res = $x-1;\n    }\n}\nmy $hour = $res/60;\nmy $mins = $res%60;\nprintf(\"%02d:%02d\\n\",$hour,$mins);", "positive_code": [{"source_code": "my $n = <STDIN>;\n@arr = ();\nfor (my $i=0; $i < $n; $i++) {\n    my $line = <STDIN>;\n    chomp $line;\n    ($a,$b)= split /:/, $line;\n    $a = 60*$a + 1*$b;\n    push(@arr, $a);\n}\n\nfor (my $i=0; $i < $n-1; $i++) {\n    for (my $j=$i+1; $j < $n; $j++) {\n        if ($arr[$i] > $arr[$j]) {\n            ($arr[$i], $arr[$j]) = ($arr[$j], $arr[$i]);\n        }\n    }\n}\nmy $max = 0;\nfor (my $i=1; $i < $n; $i++) {\n    if ($arr[$i] - $arr[$i-1] - 1 > $max) {\n        $max = $arr[$i] - $arr[$i-1] - 1;\n    }\n}\nif (24*60 - $arr[$n-1] + $arr[0] - 1 > $max) {\n    $max = 24*60 - $arr[$n-1] + $arr[0] - 1;\n}\nmy $h = int($max / 60);\nmy $m = $max - $h*60;\nif ($h < 10){\n    print 0;\n}\nprint $h . \":\";\nif ($m < 10) {\n    print 0;\n}\nprint $m;"}], "negative_code": [], "src_uid": "c3b0b7194ce018bea9c0b9139e537a09"}
{"source_code": "<>;while(<>){$a=0;map{$a|=$_}split;$b+=$a}print$b\n\n", "positive_code": [{"source_code": "<>;while(<>){$a=0;map{$a|=$_}split;$b+=$a}print$b\n"}], "negative_code": [], "src_uid": "475239ff4ae3675354d2229aba081a58"}
{"source_code": "$\\ = $/;\n\n<>;\n@_ = split \" \", <>;\n$h{$_}++ for @_;\n\n@deg = sort {$h{$b} <=> $h{$a}} keys %h;\n\n@cand = grep $h{$deg[0]} == $h{$_}, @deg;\n\n$i = 0;\n++ $i, $L{$_} //= $i, $R{$_} = $i for @_;\n\n$min = ~0;\n\nfor (@cand){\n$R{$_} - $L{$_} < $min and ($min = $R{$_} - $L{$_}, $p = \"$L{$_} $R{$_}\")\n}\n\nprint $p", "positive_code": [{"source_code": "<>; ++ $h{$_} for @_ = split \" \", <>;\n\n$R{$_} = ++ $i, $L{$_} //= $i for @_;\n\n$min = ~0;\n\n($r, $l) = ($R{$_}, $L{$_}), $r - $l < $min and ($min = $r - $l, $p = \"$l $r\") \n\tfor grep { ( $j //= $h{$_} ) == $h{$_} } sort {$h{$b} <=> $h{$a}} keys %h;\n\nprint $p"}], "negative_code": [], "src_uid": "ecd9bbc05b97f3cd43017dd0eddd014d"}
{"source_code": "chomp(my $n = <>);\nmy %procs;\nfor(1..$n) {\n  my ($name, $params) = (<> =~ /void\\s+(\\w+)\\s*\\(([^\\)]*)\\)/);\n  my (@params) = ($params =~ /\\w+/g);\n  $procs{$name}{join(\"\\f\", @params)} = undef;\n}\nchomp(my $m = <>);\nmy %vars;\nfor(1..$m) {\n  my ($type, $name) = (<> =~ /(\\w+)\\s+(\\w+)/);\n  $vars{$name} = $type;\n}\nchomp(my $k = <>);\nfor(1..$k) {\n  my ($name, $params) = (<> =~ /(\\w+)\\s*\\(([^\\)]*)\\)/);\n  my (@params) = map { $vars{$_} } ($params =~ /(\\w+)/g);\n  if (exists $procs{$name}) {\n    my (@temps) = keys %{ $procs{$name} };\n    my $res = 0;\n    for my $temp (@temps) {\n      my @temp_params = split /\\f/, $temp;\n      (scalar @params) eq (scalar @temp_params) or next;\n      my $b = 1;\n      for (my $i = 0; $i < @params; $i++) {\n        ($temp_params[$i] eq 'T') || ($temp_params[$i] eq $params[$i]) or ($b = 0);\n      }\n      $res += $b;\n    }\n    print $res . \"\\n\";\n  } else {\n    print \"0\\n\";\n  }\n}", "positive_code": [{"source_code": "chomp(my $n = <>);\nmy %procs;\nfor(1..$n) {\n  my ($name, $params) = (<> =~ /void\\s+(\\w+)\\s*\\(([^\\)]*)\\)/);\n  my (@params) = ($params =~ /\\w+/g);\n  $procs{$name}{join(\"\\f\", @params)} = undef;\n}\n\nchomp(my $m = <>);\nmy %vars;\nfor(1..$m) {\n  my ($type, $name) = (<> =~ /(\\w+)\\s+(\\w+)/);\n  $vars{$name} = $type;\n}\n\nchomp(my $k = <>);\nfor(1..$k) {\n  my ($name, $params) = (<> =~ /(\\w+)\\s*\\(([^\\)]*)\\)/);\n  my (@params) = map { $vars{$_} } ($params =~ /(\\w+)/g);\n  if (exists $procs{$name}) {\n    my (@temps) = keys %{ $procs{$name} };\n    my $res = 0;\n    for my $temp (@temps) {\n      my @temp_params = split /\\f/, $temp;\n      (scalar @params) eq (scalar @temp_params) or next;\n      my $b = 1;\n      for (my $i = 0; $i < @params; $i++) {\n        ($temp_params[$i] eq 'T') || ($temp_params[$i] eq $params[$i]) or ($b = 0);\n      }\n      $res += $b;\n    }\n    print $res . \"\\n\";\n  } else {\n    print \"0\\n\";\n  }\n}"}], "negative_code": [], "src_uid": "d5e3136b236f0e84ed6b88e43acd4205"}
{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $n = $_;\n    my  @array = sort split ' ', <>;\n    my $len = @array;\n    my @brrby;\n    my $cnt = 0;\n    for (1..$#array) {\n        $brrby[$cnt]++;\n        $cnt++ unless ($array[$_] == $array[$_-1]);\n    }\n    $brrby[$cnt]++;\n    my $sum = 0;\n    my $max = $brrby[0];\n    for (1..$cnt) {\n        if ($brrby[$_] > $max) {\n            $sum += $max;\n            $max = $brrby[$_];\n        } else {$sum += $brrby[$_];}\n    }\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n", "positive_code": [{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $ar = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$ar;\n    #@$ar = (1..1000);\n    my @myvalues = sort {$b <=> $a} values %{$h};\n    print @$ar - $myvalues[0];\n#    if (@$ar == 1000) {\n#        my @myvalues = sort {$b <=> $a} values %{$h};\n#        print \"print myvalues\";\n#        print \"@myvalues\";\n#        \n#    } else {\n#        print @$ar - (sort {$b <=> $a} values %{$h})[0];\n#    }\n\n#    my @array = split ' ', $_;\n#    my $sum = 0;\n#    $sum += $_ for @array;\n#    print $sum;\n#    print $sum - $array[0];\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $ar = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$ar;\n#    my @myvalues = sort {$b <=> $a} values %{$h};\n#    print @$ar - $myvalues[0];\n#     print @$ar - (sort {$b <=> $a} values %{$h})[0];\n#    my @array = (1..100);\n#    my @brrby = (1..20);\n#    $brrby[$#brrby] = 30;\n#    print @array - (sort {$b <=> $a} @brrby)[0];\n        print @$ar - (sort {$b <=> $a} values %{$h})[0];\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n#use List::Util qw(max);\n$\\ = $/;\nwhile (<>) {\n    $n = $_; $h->{$_}++ for split ' ', <>;\n    print $n - (sort {$b <=> $a} values %{$h})[0];\n}\n\nexit 0;\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $ar = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$ar;\n#    my @myvalues = sort {$b <=> $a} values %{$h};\n#    print @$ar - $myvalues[0];\n     print @$ar - (sort {$b <=> $a} values %{$h})[0];\n#    my @array = (1..100);\n#    my @brrby = (1..20);\n#    $brrby[$#brrby] = 30;\n#    print @array - (sort {$b <=> $a} @brrby)[0];\n#        print @$ar - (sort {$b <=> $a} values %{$h})[0];\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "<>; @a = split ' ', <>;\nwhile (@a) {\n    my (%h, @b);\n    for $a (@a) {\n    \tpush(@b, $a) if $h{$a};\n    \t$h{$a} = 1;\n    }\n    $c += keys(%h) - 1;\n    @a = @b;\n}\nprint $c;"}, {"source_code": "<STDIN>;\nmy $A = [split ' ', <STDIN>];\nmy ($h, $c, $ans) = ({}, {}, 0);\n($h->{$_} ||= 0)++ for @$A;\n\nforeach my $k (keys %$h){\n    my $v = $h->{$k};\n    for(my $i=1; $i<=$v; $i++){\n        ($c->{$i} ||= 0)++;\n    }\n}\n\n$ans += $_ - 1 for values %$c;\nprint sprintf(\"%d\\n\", $ans);\n"}, {"source_code": "$\\ = $/;\nwhile (<>) {\n    $n = $_; $h->{$_}++ for split ' ', <>;\n    print $n - (sort {$b <=> $a} values %{$h})[0];\n}"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $n = $_;\n    my  @array = sort split ' ', <>;\n    my $len = @array;\n    my @brrby;# = map 0, (0..$len);\n    my $cnt = 0;\n    for (1..$#array) {\n        $brrby[$cnt]++;\n        $cnt++ unless ($array[$_] == $array[$_-1]);\n    }\n    $brrby[$cnt]++;\n    my $sum = 0;\n    my $max = $brrby[0];\n    for (1..$cnt) {\n        if ($brrby[$_] > $max) {\n            $sum += $max;\n            $max = $brrby[$_];\n        } else {$sum += $brrby[$_];}\n    }\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $n = $_;\n    my  @array = sort split ' ', <>;\n    my %ash;\n    for (@array) {\n        $ash{$_}++;\n    }\n    @array = uniq @array;\n    my $sum = 0;\n    my $max = $ash{$array[0]};\n    shift @array;\n    for (@array) {\n        my $tmp = $ash{$_};\n        if ($tmp > $max) {\n            $sum += $max;\n            $max = $tmp;\n        } else {\n            $sum += $tmp;\n        }\n    }\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\nuse List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $n = $_;\n    my  @array = sort split ' ', <>;\n    my %ash;\n    for (@array) {\n        $ash{$_}++;\n    }\n    @array = uniq @array;\n    my $sum = 0;\n    my $max = $ash{$array[0]};\n    shift @array;\n    for (@array) {\n        my $tmp = $ash{$_};\n        if ($tmp > $max) {\n            $sum += $max;\n            $max = $tmp;\n        } else {\n            $sum += $tmp;\n        }\n    }\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "$\\ = $/;\n\nwhile (<>) {\n    $n = $_;\n    $h->{$_}++ for split ' ', <>;\n    print $n - (sort {$b <=> $a} values %{$h})[0];\n}\n"}], "negative_code": [{"source_code": "<STDIN>;\nmy $A = [split ' ', <STDIN>];\nmy ($h, $ans) = ({}, undef);\n$h->{$_} = 1 for @$A;\n$ans = scalar(keys %$h);\nprint sprintf(\"%d\\n\", $ans);\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    print @$a - (sort {$a <=> $b} values %{$h})[0];\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    if (@a == 1000) {\n        my @values = sort {$b <=> $a} values %{$h};\n        print \"@values\";\n    } else {\n        print @$a - (sort {$b <=> $a} values %{$h})[0];\n    }\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $n = $_;\n    my  @array = split ' ', <>;\n    @array = sort @array;\n    my ($cnt, $pos) = (0, 0);\n\n    for (1..$n) {\n        if ($array[$pos] < $array[$pos+1]) {\n            ++$cnt; shift @array;\n        } elsif ($array[$pos] == $array[$pos+1]) {\n            if ($array[$pos] == $array[$#array]) {\n                last;\n            } else {\n                ++$cnt; pop @array; shift @array;\n            }\n        }\n        last if (@array == 1 or @array == 0);\n    }\n    print $cnt;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    print @$a - (sort {$b <=> $a} values %{$h})[0];\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    my @values = sort {$a <=> $b} values %{$h};\n    pop @values;\n    my $sum = 0;\n    $sum += $_ for @values[0..$#values];\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $ar = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$ar;\n    #@$ar = (1..1000);\n    if (@$ar == 1000) {\n        my @myvalues = sort {$b <=> $a} values %{$h};\n        print \"print myvalues\";\n        print \"@myvalues\";\n    } else {\n        print @$ar - (sort {$b <=> $a} values %{$h})[0];\n    }\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    my @values = sort values %{$h};\n    pop @values;\n    my $sum = 0;\n    $sum += $_ for @values[0..$#values];\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    my @values = sort values %{$h};\n    shift @values;\n    my $sum = 0;\n    $sum += $_ for @values[0..$#values];\n    print $sum;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: 2.pl\n#\n#  DESCRIPTION: B. Beautiful Paintings\n#\n#        FILES: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: Lpaste (yesterday2young.github.io), liuxueyang457@163.com\n# ORGANIZATION: Solution 1.\n#      VERSION: 1.0\n#      CREATED: 2016/03/17 21时31分48秒\n#     REVISION: ---\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use List::MoreUtils qw(uniq);\n#use 5.020;\n$\\ = $/;\n\nwhile (<>) {\n    my $a = [split ' ', <>];\n    my $h;\n    $h->{$_}++ for @$a;\n    print @$a - (sort {$b <=> $a} values %{$h})[0];\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of strings\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (str_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_in_array_of_array\n#      PURPOSE: find if an array is equal to one of a array of arrays\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if find an equal array, 0 otherwise\n#  DESCRIPTION: all arrays are array of numbers\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_in_array_of_array {\n    my ($small_ar, $ar_ar) = @_;\n    my $mark = 0;\n    for (@{$ar_ar}) {\n        $mark = 1;\n        unless (num_array_cmp($small_ar, $_)) {\n            $mark = 0;\n            next;\n        }\n        last if $mark;\n    }\n    $mark;\n}\n\n#===  FUNCTION  ================================================================\n#         NAME: str_array_cmp\n#      PURPOSE: compare two array of strings\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub str_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] eq $_[1][$_]); }\n    return 1;\n} ## --- end sub str_array_cmp\n\n#===  FUNCTION  ================================================================\n#         NAME: num_array_cmp\n#      PURPOSE: compare two array of numbers\n#   PARAMETERS: two array reference\n#      RETURNS: return 1 if two array are equal, 0 otherwise\n#  DESCRIPTION: ????\n#       THROWS: no exceptions\n#     COMMENTS: none\n#     SEE ALSO: n/a\n#===============================================================================\nsub num_array_cmp {\n    return 0 if @{$_[0]} != @{$_[1]};\n    my $len = @{$_[0]};\n    for (0..$len-1) { return 0 unless ($_[0][$_] == $_[1][$_]); }\n    return 1;\n} ## --- end sub num_array_cmp\n\nexit 0;\n\n\n"}], "src_uid": "30ad5bdc019fcd8a4e642c90decca58f"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split //;\n\t\n\t$_ = join '', sort grep { $h{ $_ } == 1 } keys %h;\n\t\n\t$_ .= join '', sort grep { $h{ $_ } == 2 } keys %h;\n\t$_ .= join '', sort grep { $h{ $_ } == 2 } keys %h;\n\t\n\tprint;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nprint sort m/./g while <>"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m, $r, $c ) = split;\n\t\n\t$debug and print \"[$n, $m, $r, $c]\";\n\t\n\tmy %row;\n\tmy %col;\n\t\n\tmy $ans;\n\t\n\tfor my $i ( 0 .. $n - 1 ){\n\t\t$_ = <>, chomp;\n\t\t\n\t\tnext if defined $ans;\n\t\t\n\t\tm/B/ and $row{ $i } = 1;\n\t\t\n\t\twhile( m/B/g ){\n\t\t\t$col{ $-[ 0 ] } = 1;\n\t\t\t\n\t\t\tif( $r - 1 == $i and $-[ 0 ] == $c - 1 ){\n\t\t\t\t$ans = 0;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tif( defined $ans ){\n\t\tprint $ans;\n\t\t}\n\telsif( %row or %col ){\n\t\tif( $row{ $r - 1 } or $col{ $c - 1 } ){\n\t\t\tprint 1;\n\t\t\t}\n\t\telse{\n\t\t\tprint 2;\n\t\t\t}\n\t\t}\n\telse{\n\t\tprint -1;\n\t\t}\n\t}"}], "src_uid": "28102f75e0798960740e5a2625393c8f"}
{"source_code": "@_ = sort {$a <=> $b} (split ' ', (<>, <>) ), map \"$_=\", @B = split ' ', <>;\n\nmap $h{ $_ } = $i +=!/=/, @_;\n\t\nprint join ' ', map $h{ \"$_=\" }, @B;", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@A = split ' ', <>;\n\t@B = split ' ', <>;\n\t@C = sort {$a <=> $b} @A, map \"${_}_\", @B;\n\t\n\t%h = ();\n\t$i = 0;\n\tfor (@C){\n\t\t/_/ or $i ++;\n\t\t$h{ $_ } = $i;\n\t\t}\n\t\n\tprint join ' ', map $h{ \"${_}_\" }, @B;\n\t}"}], "negative_code": [], "src_uid": "e9a519be33f25c828bae787330c18dd4"}
{"source_code": "$n = <>;\n@n = sort {$a <=> $b} split ' ', <>;\n$sum += $_ for @n;\n$small = int($sum / $n);\n$bigger = $sum % $n;\n@w = ( ($small) x ($n - $bigger), ($small + 1) x $bigger );\n$sum = 0;\nfor (@n){\n$sum += abs($_ - shift @w)\n}\nprint $sum >> 1", "positive_code": [{"source_code": "\n\n\n\n\nmy $n = <STDIN>;\nchomp ( $n );\nmy $f = <STDIN>;\nchomp ( $f );\nmy @arr = split m/ /, $f;\n\nmy $sum = 0;\nfor (@arr) {\n    $sum += $_; }\n@arr = sort { $a <=> $b } @arr;\n\nmy $lower = $n - ($sum % $n);\nmy $upper = ($sum % $n);\nmy $avg = int ($sum / $n);\n\nmy $seconds = 0;\nfor ( my $i = 0; $i < $lower; $i += 1 ) {\n    $seconds += abs ((shift @arr) - $avg);}\n\nfor ( my $j = 0; $j < $upper; $j += 1 ) {\n    $seconds += abs ((shift @arr) - ($avg+1));}\n\n$seconds /= 2;\nprint \"$seconds\\n\";\n\n\n\n\n"}, {"source_code": "sub floor{\n\tmy ($x,$y)=@_;\n\tmy $t=$x%$y;\n\treturn ($x-$t)/$y;\n}\nsub ceil\n{\n\tmy ($x,$y)=@_;\n\tmy $t=$x%$y;\n\t$t=$y-$t if ($t!=0);\n\treturn ($x+$t)/$y;\n}\nsub max\n{\n\tmy ($x,$y)=@_;\n\tif ($x>$y)\n\t{\n\t\treturn $x;\n\t}\n\telse\n\t{\n\t\treturn $y;\n\t}\n}\n$n=<>;\nchomp($n);\n$s=<>;\nchomp($s);\n@a=split ' ',$s;\nmap\n{\n\t$t+=$_;\n}@a;\n$e=floor($t,$n);\n$f=ceil($t,$n);\nfor ($i=0; $i<$n; $i++)\n{\n\t$q+=$e-$a[$i] if $a[$i]<$e;\n\t$w+=$a[$i]-$f if $a[$i]>$f;\n}\n$rez=max($q,$w);\nif ($rez>0)\n{\n\tprint $rez;\n}\nelse\n{\n\tprint 0;\n}"}], "negative_code": [{"source_code": "\n\n\n\n\n\nmy $n = <STDIN>;\nchomp ( $n );\nmy $f = <STDIN>;\nchomp ( $n );\nmy @arr = split m/ /, $f;\n\nmy $sum = 0;\nfor (@arr) {\n    $sum += $_; }\n@arr = sort @arr;\n\n\nmy $lower = $n - ($sum % $n);\nmy $upper = ($sum % $n);\nmy $avg = int ($sum / $n);\n\nmy $seconds = 0;\nfor (1..$lower) {\n    $seconds += abs ((shift @arr) - $avg);}\n\nfor (1..$upper) {\n    $seconds += abs ((shift @arr) - ($avg+1));}\n\n$seconds /= 2;\nprint \"$seconds\\n\";\n\n\n    \n\n\n\n\n\n\n\n\n\n"}, {"source_code": "sub floor{\n\tmy ($x,$y)=@_;\n\tmy $t=$x%$y;\n\treturn ($x-$t)/$y;\n}\nsub ceil\n{\n\tmy ($x,$y)=@_;\n\tmy $t=$x%$y;\n\t$t=$y-$t if ($t!=0);\n\treturn ($x+$t)/$y;\n}\nsub max\n{\n\tmy ($x,$y)=@_;\n\tif ($x>$y)\n\t{\n\t\treturn $x;\n\t}\n\telse\n\t{\n\t\treturn $y;\n\t}\n}\n$n=<>;\nchomp($n);\n$s=<>;\nchomp($s);\n@a=split ' ',$s;\nmap\n{\n\t$t+=$_;\n}@a;\n$e=floor($t,$n);\n$f=ceil($t,$n);\nfor ($i=0; $i<$n; $i++)\n{\n\t$q+=$e-$a[$i] if $a[$i]<$e;\n\t$w+=$a[$i]-$f if $a[$i]>$f;\n}\nprint max($q,$w);"}, {"source_code": "$n = <>;\n@n = sort {$a <=> $b} split ' ', <>;\n$sum += $_ for @n;\n$small = int($sum / $n);\n$bigger = $sum % $n;\n@w = ( ($small) x ($n - $bigger), ($small + 1) x $bigger );\nfor (@n){\n$sum += abs($_ - shift @w)\n}\nprint $sum >> 1"}], "src_uid": "c0c29565e465840103a4af884f951cda"}
{"source_code": "map { <> !~ /^(\\d+) \\1$/ ? ( $R = 2 ) : push @_, $1 } 1 .. <>;\n\n@s = sort { $b <=> $a } @_;\n\nprint qw( unrated maybe rated )[ $R || \"@s\" eq \"@_\" ]", "positive_code": [{"source_code": "$p = ~-0;\n\nmap { <> !~ /^(\\d+) \\1$/ ? ( $R = 2 ) : ( $f ||= $1 > $p, $p = $1 ) } 1 .. <>;\n\nprint qw( unrated maybe rated )[ $R || !$f ]"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = ();\n\tmy $R = 0;\n\t\n\tmap { \n\t\tmy( $A, $B ) = split ' ', <>;\n\t\t$A != $B ? $R ++ : push @_, $A;\n\t\t} 1 .. $_;\n\t\n\tmy @s = sort { $b <=> $a } @_;\n\t\n\tprint $R ? 'rated' :\n\t\t\"@s\" eq \"@_\" ? 'maybe' :\n\t\t'unrated';\n\t}"}], "negative_code": [], "src_uid": "88686e870bd3bfbf45a9b6b19e5ec68a"}
{"source_code": "<>;\n\nprint qw(YES NO)[ \n        !! join '', \n            map { \n                s/.*?.\\s/ $& % 2 /reg =~ s/\\s//gr =~ s/00//gr =~ s/11//gr =~ y/0//dr =~ s/11//gr\n            } split /\\b0/, <>\n    ]", "positive_code": [{"source_code": "<>;\n\nprint qw(YES NO)[ \n\t\t!! join '', \n\t\t\tmap { \n\t\t\t\t( join '', map $_ % 2, split ) =~ s/00//gr =~ s/11//gr =~ y/0//dr =~ s/11//gr\n\t\t\t} split /\\b0/, <>\n\t]"}, {"source_code": "<>;\n\nprint qw(YES NO)[ \n        !! ( ( join '', map { $_ &&= 1 + (1 - $_ % 2) } split ' ', <> )\n             =~ s/12*1//gr =~ /1/ )\n    ]"}, {"source_code": "<>;\n\nprint qw(YES NO)[ \n        1 & ( join '', map { $_ &&= 1 + (1 - $_ % 2) } split ' ', <> )\n             =~ s/22//gr =~ s/11//gr =~ y/2//dr =~ s/11//gr =~ y/0//dr \n    ]"}], "negative_code": [{"source_code": "\tprint qw(YES NO)[ \n\t\t\t!! join '', \n\t\t\t\tmap { \n\t\t\t\t\t( join '', map $_ % 2, split ) =~ s/00//gr =~ s/11//gr =~ y/0//dr =~ s/11//gr\n\t\t\t\t} split /\\b0/, <>\n\t\t]"}, {"source_code": "<>;\n\tprint qw(YES NO)[ \n\t\t\t!! join '', \n\t\t\t\tmap { \n\t\t\t\t\tjoin '', \n\t\t\t\t\t\tmap {\n\t\t\t\t\t\t\tmap s/11//gr, \n\t\t\t\t\t\t\t\tmap y/0//dr, \n\t\t\t\t\t\t\t\t\tsplit /11/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmap { split /00/ } \n\t\t\t\t\t\t\t\tjoin '', \n\t\t\t\t\t\t\t\t\tmap $_ % 2, split \n\t\t\t\t} split /\\b0/, <>\n\t\t]"}, {"source_code": "print qw(YES NO)[ \n\t\t\t!! join '', \n\t\t\t\tmap { \n\t\t\t\t\tjoin '', \n\t\t\t\t\t\tmap {\n\t\t\t\t\t\t\tmap s/11//gr, \n\t\t\t\t\t\t\t\tmap y/0//dr, \n\t\t\t\t\t\t\t\t\tsplit /11(?!0)/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmap { split /00(?!1)/ } \n\t\t\t\t\t\t\t\tjoin '', \n\t\t\t\t\t\t\t\t\tmap $_ % 2, split \n\t\t\t\t} split /\\b0/, <>\n\t\t]"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = split /\\b0/, <>;\n\n\t$f = 0;\n\tfor (@_){\n\t\t$_ = join '', map { $_ % 2 } split;\n\t\t$f += grep $_, map { (length) % 2 } map y/0//dr, map { split /11/ } split /00/;\n\t\t}\n\tprint $f ? 'NO' : 'YES';\n\t}"}, {"source_code": "print qw(YES NO)[ \n\t\t!! join '', \n\t\t\tmap { \n\t\t\t\t( join '', map $_ % 2, split ) =~ s/00//gr =~ s/11//gr =~ y/0//dr =~ s/11//gr\n\t\t\t} split /\\b0/, <>\n\t]"}, {"source_code": "<>;\n\nprint qw(YES NO)[ \n\t\t!! join '', \n\t\t\tmap { \n\t\t\t\ts/.*?.\\s?/ $& % 2 /regex =~ s/00//gr =~ s/11//gr =~ y/0//dr =~ s/11//gr\n\t\t\t} split /\\b0/, <>\n\t]"}, {"source_code": "\tprint qw(YES NO)[ \n\t\t\t!! join '', \n\t\t\t\tmap { \n\t\t\t\t\tjoin '', \n\t\t\t\t\t\tmap {\n\t\t\t\t\t\t\tmap s/11//gr, \n\t\t\t\t\t\t\t\tmap y/0//dr, \n\t\t\t\t\t\t\t\t\tsplit /11/\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmap { split /00/ } \n\t\t\t\t\t\t\t\tjoin '', \n\t\t\t\t\t\t\t\t\tmap $_ % 2, split \n\t\t\t\t} split /\\b0/, <>\n\t\t]"}, {"source_code": "<>;\n\nprint qw(YES NO)[ \n        !! join '', \n            map { \n                s/.*?.\\s/ $& % 2 /reg =~ y/ //dr =~ s/00//gr =~ s/11//gr =~ y/0//dr =~ s/11//gr\n            } split /\\b0/, <>\n    ]"}], "src_uid": "97697eba87bd21ae5c979a5ea7a81cb7"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak '$ref does not reference to scalar' if !ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n\nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n\n# solution\n\nmy $n = read_token;\n\n\nfor (1..$n) {\n    my ($a, $b) = split q{ }, read_line;\n    if ($a == $b) {\n        say 0;\n        next;\n    }\n    if ($a > $b) {\n        if (even($a - $b)) {\n            say 1;\n        }\n        else {\n            say 2;\n        }\n    }\n    else {\n        if (odd($b - $a)) {\n            say 1;\n        }\n        else {\n            say 2;\n        }\n    }\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B ) = split;\n\t\n\tif( $A == $B ){\n\t\tprint 0;\n\t\t}\n\t\t\n\telsif( $A % 2 == 0 and $B % 2 == 1 and $A < $B ){\n\t\tprint 1;\n\t\t}\n\telsif( $A % 2 == 0 and $B % 2 == 0 and $A < $B ){\n\t\tprint 2;\n\t\t}\n\telsif( $A % 2 == 1 and $B % 2 == 1 and $A < $B ){\n\t\tprint 2;\n\t\t}\n\telsif( $A % 2 == 1 and $B % 2 == 0 and $A < $B ){\n\t\tprint 1;\n\t\t}\n\t\n\telsif( $A % 2 == 0 and $B % 2 == 1 and $A > $B ){\n\t\tprint 2;\n\t\t}\n\telsif( $A % 2 == 0 and $B % 2 == 0 and $A > $B ){\n\t\tprint 1;\n\t\t}\n\telsif( $A % 2 == 1 and $B % 2 == 1 and $A > $B ){\n\t\tprint 1;\n\t\t}\n\telsif( $A % 2 == 1 and $B % 2 == 0 and $A > $B ){\n\t\tprint 2;\n\t\t}\n\t\n\t}"}], "negative_code": [], "src_uid": "fcd55a1ca29e96c05a3b65b7a8103842"}
{"source_code": "<>;\n@a=<>;\nchomp @a;\n\nwhile(1){\n@A=reverse @a;\n$f=0;\n\n$A[$_] ne $a[$_] and $f=1 for 0..@A-1;\n\nif (@a%2 or $f){print 0+@a; exit}\n@a=@a[0..@a/2-1]\n}", "positive_code": [{"source_code": "\nwhile(<>){\n\t\n\tchomp;\n\t($n,$m)=split/ /;\n\t@a=();\n\tfor $i(1..$n){push @a, \"\".<>;}\n\tchomp @a;\n\t\n#\tprint \"--@a\\n\";\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n#\tprint \"-@A\\n\";\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t($A[$i] ne $a[$i]) and $f=1;\n#\t\tprint \"=$A[$i] $a[$i]\\n\";\n\t}\n#\tprint \"$f--@a\\n\";\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n#\tprint \"--@a\\n\";\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t$A[$i] ne $a[$i] and $f=1;\n\t}\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t$A[$i] ne $a[$i] and $f=1;\n\t}\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t$A[$i] ne $a[$i] and $f=1;\n\t}\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t$A[$i] ne $a[$i] and $f=1;\n\t}\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n\t\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t$A[$i] ne $a[$i] and $f=1;\n\t}\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n\t\n\tif (@a%2!=0){print 0+@a,\"\\n\"; next}\n\t@A=reverse @a;\n\t$f=0;\n\tfor $i(0..@A-1){\n\t\t$A[$i] ne $a[$i] and $f=1;\n\t}\n\tif ($f==1){print 0+@a,\"\\n\"; next}\n\t@a=@a[0..(@a/2-1)];\n\t\n\tprint \"\\n\";\n\t}\n\t\n"}], "negative_code": [], "src_uid": "90125e9d42c6dcb0bf3b2b5e4d0f845e"}
{"source_code": "($n,$m)=split/ /,<>;@a=split/ /,<>;$q=0;$q+=($_+1)*($_<$n-1&&@a[$_]==@a[$_+1]?1:$n-$_)for(0..$n-1);for(1..$m){($_,$x)=split/ /,<>;$q-=(--$_+1)*($_<$n-1&&@a[$_]==@a[$_+1]?1:$n-$_)+($_)*(@a[$_-1]==@a[$_]?1:$n-$_+1)*($_>0);@a[$_]=$x;$q+=($_+1)*($_<$n-1&&@a[$_]==@a[$_+1]?1:$n-$_)+($_)*(@a[$_-1]==@a[$_]?1:$n-$_+1)*($_>0);print$q,\" \"}", "positive_code": [{"source_code": "($n,$m)=split/ /,<>;@a=split/ /,<>;$q=0;$q+=($_+1)*($_<$n-1&&@a[$_]==@a[$_+1]?1:$n-$_)for(0..$n-1);for(1..$m){($_,$x)=split/ /,<>;$q-=(--$_+1)*($_<$n-1&&@a[$_]==@a[$_+1]?1:$n-$_)+$_*(@a[$_-1]==@a[$_]?1:$n-$_+1)*($_>0);@a[$_]=$x;$q+=($_+1)*($_<$n-1&&@a[$_]==@a[$_+1]?1:$n-$_)+$_*(@a[$_-1]==@a[$_]?1:$n-$_+1)*($_>0);print$q,\" \"}"}], "negative_code": [], "src_uid": "d70a774248d9137c30f33fb37c6467a7"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n#open (my $F1, \"<\", \"a\") or die \"a: $!\";\n#my $num=0;\nmy %Q=();\nmy $num = <>; \nchomp($num);\nmy $line2 = <>; \nchomp($line2);\nmy @snacks = split (\" \", $line2);\nmy $len = scalar @snacks;\nif ($num != $len ) { print \"Error: $num != $len\\n\";exit(1);}\n#print \"num=$num\\n\";\n#print \"snacks:@snacks\\n\";\n#close($F1);\n##############################################\nmy $wait_for = $num;\nfor (my $i=0;$i < $num;$i++) {\n   if ($wait_for == $snacks[$i] ) { \n      print \"$wait_for\";\n      $wait_for--;\n      #while (my $ele = pop (@Q)) { \n      while ($Q{$wait_for}) { \n         #if ($wait_for == $ele) {\n            print \" $wait_for\";\n            $wait_for--;\n    \n      }   \n      print \"\\n\";\n   } else {\n      print \"\\n\";\n      $Q{$snacks[$i]} = 1;\n      #push (@Q,$snacks[$i]);\n   }   \n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\t@_ = (-1, 1 .. $_);\n\t\n\tmy @A = (split ' ', <>);\n\t\n\tmy $last = $_;\n\t\n\tfor my $i ( @A ){\n\t\t\n\t\t$_[ $i ] = 0;\n\t\t\n\t\tmy @out;\n\t\t\n\t\twhile( $_[ $last ] == 0 ){\n\t\t\tpush @out, $last --\n\t\t\t}\n\t\t\t\n\t\tprint \"@out\";\n\t\t}\n\t\n\t\n\t$debug and print '-' x 10;\n\t}"}, {"source_code": "@_ = -1 .. <>;\n\nfor ( split ' ', <> ){\n\n\t$_[ $_ ] = -2;\n\t\n\tpop @_, print \"$#_ \" while -1 > $_[ @_-2 ];\n\t\t\n\tprint $/\n\t}"}, {"source_code": "use strict;\nuse warnings;\n\nuse feature qw/say/;\n{\n    my $n = <>;\n    chomp $n;\n    my %has;   \n    my $temp_heap = $n;\n    my @values;\n    {\n        local $/ = ' ';\n        for (my $i=1;$i<=$n;$i++){\n            if ($i == $n){\n                $/ = \"\\n\";\n            }\n            my $str = <>;\n            chomp $str;\n            $has{$str} = 1;\n\n            while (defined $has{$temp_heap} ){\n                print $temp_heap . \" \";\n                $temp_heap--;\n            }\n            print \"\\n\";\n        }\n    }\n}\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\n\nuse feature qw/say/;\n{\n    my $n = <>;\n    chomp $n;\n    \n    my $temp_heap = $n+1;\n    my @values;\n    {\n        local $/ = ' ';\n        for (my $i=1;$i<=$n;$i++){\n            if ($i == $n){\n                $/ = \"\\n\";\n            }\n            my $str = <>;\n            chomp $str;\n            push @values, $str;\n            @values = reverse sort @values;\n            while (defined $values[0] && $values[0]+1 == $temp_heap ){\n                my $new_heap = shift @values;\n                print $new_heap . \" \";\n                $temp_heap = $new_heap;\n            }\n            print \"\\n\";\n        }\n    }\n}\n"}, {"source_code": "@_ = -1 .. <>;\n\nfor ( split ' ', <> ){\n\n\t$_[ $_ ] = 0;\n\t\n\tpop @_, print \"$#_ \" while ! $_[ @_-2 ];\n\t\t\n\tprint $/\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\t@_ = (-1, 1 .. $_);\n\t\n\tmy @A = (split ' ', <>);\n\t\n\tmy $c = $_;\n\tmy $last = $_;\n\t\n\tfor my $i ( reverse 1 .. @_ - 1 ){\n\t\tmy $num = shift @A;\n\t\t$_[ $num ] = 0;\n\t\tif( $num >= $i ){ $c-- }\n\t\t$debug and print \"  $c\";\n\t\tif( $num != $i and $_[ $i ] == 0 ){ $c-- }\n\t\t$debug and print \"    $c\";\n\t\tif( $c < $i ){\n\t\t\tprint join ' ', reverse $c + 1 .. $last;\n\t\t\t$last = $c;\n\t\t\t}\n\t\telse{\n\t\t\tprint ''\n\t\t\t}\n\t\t}\n\t\n\t\n\t$debug and print '-' x 10;\n\t}"}], "src_uid": "3d648acee2abbf834f865b582aa9b7bc"}
{"source_code": "<>;\n$A = <>;\n$az = join '', a .. z;\n($r, $t) = split, $az =~ s/[$r$t]/$& eq $r? $t : $r/ge for <>;\n$z = 'a';\n%h = map { $z ++, $_ } split //, $az;\n$A =~ s/./$h{$&}/ge;\nprint $A", "positive_code": [{"source_code": "<>;\n$A = <>;\n$az = join '', a .. z;\n($r, $t) = split, $az =~ s/[$r$t]/$& eq $r? $t : $r/ge for <>;\n$z = 'a';\n%h = map { $z ++, $_ } split //, $az;\n$A =~ s/./$h{$&}/ge;\nprint $A"}, {"source_code": "#!/usr/bin/perl\n\n($n, $m) = split /\\s/, <>;\n\n$name = <>;\nchomp $name;\n\n@name_letters = split //, $name;\n \nfor my $i (0..$#name_letters)\n{\n    $h{@name_letters[$i]} = [] if ! exists   $h{@name_letters[$i]};\n     \n    push @{$h{@name_letters[$i]}}, $i;\n}\n\nfor (1..$m)\n{\n    my $xy = <>;\n    chomp $xy;\n    (my $x, my $y) = split /\\s/, $xy;\n\n    if($x ne $y)\n    {\n    if(exists $h{$x} and exists $h{$y})\n        {\n        my $ar_ref = $h{$x};\n            $h{$x} = $h{$y};\n            $h{$y} = $ar_ref;\n    }\n        elsif(exists $h{$x})\n        {\n        my $ar_ref = $h{$x};\n            delete  $h{$x};\n            $h{$y} = $ar_ref;\n        }\n        elsif(exists $h{$y})\n        {\n        my $ar_ref = $h{$y};\n            delete  $h{$y};\n            $h{$x} = $ar_ref;\n        }\n    }\n}\n\nfor my $letter (keys %h)\n{\n    for my $i (@{$h{$letter}})\n    {\n    @name_letters[$i] = $letter;\n    }\n}\n\n$name = join '', @name_letters;\n\nprint $name, \"\\n\"; \n"}], "negative_code": [], "src_uid": "67a70d58415dc381afaa74de1fee7215"}
{"source_code": "use strict;\nuse warnings;\n\nmy $case = <STDIN>;\n\nfor my $i(0..$case - 1){\n\tmy $num = <STDIN>;\n\tmy $sum = 0;\n\tmy $exp = 0;\n\t\n\t$sum = ($num * ($num + 1)) >> 1;\n\tfor my $j(0..$num - 1){\n\t\tif($num < (1 << $j)){\n\t\t\t$exp = $j;\n\t\t\tlast;\n\t\t}\n\t}\n\t\n\t$sum -= (2 * ((1 << $exp) - 1));\n\t\n\tif($num == 1){\n\t\tprint \"-1\\n\";\n\t}elsif($num == 2){\n\t\tprint \"-3\\n\";\n\t}else{\n\t\tprint $sum, \"\\n\";\n\t}\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.010;\nuse strict;\nuse warnings;\nuse bignum;\n\n\nmy $count=<>;\nmy $sum;\nmy $temp;\n\nfor (my $i=0;$i<$count;$i+=1)\n{\n\t$temp=1;\n\tmy $number=<>;\n\t$sum = (1 + $number) * ($number / 2);\n\n\twhile ($temp <= $number)\n\t{\n\t\t$sum = $sum - ($temp * 2);\n\t\t$temp = $temp * 2;\n\t}\n\tprint $sum ;\n\tprint \"\\n\" ;\n}\n\n\n"}, {"source_code": "#!/usr/bin/perl -w\nuse bigint;\n\nsub doit {\n    my $n = $_[0];\n    my $next_power_of_two = 1;\n    while ($next_power_of_two <= $n) {\n        $next_power_of_two *= 2;\n    }\n    $n * ($n + 1) / 2 - 2 * ($next_power_of_two - 1);\n}\n\nmy $t = <>;\nfor (1..$t) {\n    my $n = <>;\n    print doit($n), \"\\n\";\n}\n"}, {"source_code": "#!perl\nuse bigint;\n\n$\\ = \"\\n\";\n\n$n = <>;\n\nfor (1..$n)\n{\n    $a = <>;\n    \n    chomp $a;\n    $str = unpack(\"B32\", pack(\"N\", $a));\n    $str =~ m/^0*(1\\d*)/;\n    $n1 = '1'.('0'x ((length $1) - 1));\n    $b = unpack(\"N\", pack(\"B32\", substr(\"0\" x 32 . $n1, -32)));\n    \n    $ar_sum = (1 + $a)*$a/2;\n    $ge_sum = (2*$b - 1);\n    push @result, $ar_sum - 2*$ge_sum;\n}\n\nfor my $item (@result)\n{\n    print $item;\n}\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.010;\nuse strict;\nuse warnings;\n\n\nmy $count=<>;\nmy $sum;\nmy $temp;\n\nfor (my $i=0;$i<$count;$i+=1)\n{\n\t$temp=1;\n\tmy $number=<>;\n\t$sum = (1 + $number) * ($number / 2);\n\n\twhile ($temp <= $number)\n\t{\n\t\t$sum = $sum - ($temp * 2);\n\t\t$temp = $temp * 2;\n\t}\n\tprint $sum ;\n\tprint \"\\n\" ;\n}\n\n\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $case = <STDIN>;\n\nfor my $i(0..$case){\n\tmy $num = <STDIN>;\n\tmy $sum = 0;\n\tmy $exp = 0;\n\t\n\t$sum = ($num * ($num + 1)) >> 1;\n\tfor my $j(0..$num - 1){\n\t\tif($num < (1 << $j)){\n\t\t\t$exp = $j;\n\t\t\tlast;\n\t\t}\n\t}\n\t\n\t$sum -= (2 * ((1 << $exp) - 1));\n\t\n\tif($num == 1){\n\t\tprint \"-1\\n\";\n\t}elsif($num == 2){\n\t\tprint \"-3\\n\";\n\t}else{\n\t\tprint $sum, \"\\n\";\n\t}\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $case = <STDIN>;\n\nfor my $i(0..$case){\n\tmy $num = <STDIN>;\n\tmy $sum = 0;\n\tmy $exp = 0;\n\t\n\t$sum = ($num * ($num + 1)) >> 1;\n\tfor my $j(0..$num){\n\t\tif($num < (1 << $j)){\n\t\t\t$exp = $j;\n\t\t\tlast;\n\t\t}\n\t}\n\t\n\t$sum -= (2 * ((1 << $exp) - 1));\n\t\n\tif($num == 1){\n\t\tprint \"-1\\n\";\n\t}elsif($num == 2){\n\t\tprint \"-3\\n\";\n\t}else{\n\t\tprint $sum, \"\\n\";\n\t}\n}"}], "src_uid": "a3705f29b9a8be97a9e9e54b6eccba09"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy @squeezed;\n\t\n\tmy $last = -1;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tnext if $_[ $i ] == $last;\n\t\tpush @squeezed, $_[ $i ];\n\t\t$last = $_[ $i ];\n\t\t}\n\t\n\t@_ = @squeezed;\n\t\n\tmy $fail = 0;\n\t\n\tfor my $i ( 0 .. @_ - 3 ){\n\t\t$fail ||= ( $_[ $i ] < $_[ $i + 1 ] and $_[ $i + 1 ] > $_[ $i + 2 ] );\n\t\t}\n\t\n\tprint $fail ? 'NO' : 'YES';\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\t\r\n\t1 while s/\\b(\\d+)\\K \\1\\b//g;\r\n\t\r\n\tprint /\\b(\\d+) (\\d+) (\\d+)\\b(??{ z x not $1 < $2 && $2 > $3 })/ ? NO : YES\r\n\t}"}], "negative_code": [], "src_uid": "7b6a3de5ad0975e4c43f097d4648c9c9"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $del = 0;\n\t\n\t@_ = ();\n\t\n\tfor( split // ){\n\t\tif( @_ > 0 and $_ eq $_[ -1 ] ){\n\t\t\tpop @_;\n\t\t\t$del ++;\n\t\t\t}\n\t\telse{\n\t\t\tpush @_, $_;\n\t\t\t}\n\t}\n\t\n\tprint $del % 2 ? \"Yes\" : \"No\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $del = 0;\n\t\n\t@_ = ();\n\t\n\tfor( split // ){\n\t\tpush @_, $_;\n\t\tif( @_ > 1 and $_[ -2 ] eq $_[ -1 ] ){\n\t\t\tpop @_ for 1 .. 2;\n\t\t\t$del ++;\n\t\t\t}\n\t}\n\t\n\tprint $del % 2 ? \"Yes\" : \"No\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $del = 0;\n\t\n\tmy $pos = pos;\n\t\n\t( pos ) = $pos < 0 ? 0 : $pos while s/\\G.*?\\K(.)\\1(?{ $del ++; $pos = ( pos ) - 3; })//x;\n\t\n\tprint $del % 2 ? \"Yes\" : \"No\";\n\t}"}, {"source_code": "$_ = <>;\n\n( pos ) = $pos < 0 ? 0 : $pos while s/\\G.*?\\K(.)\\1(?{ $del ++; $pos = ( pos ) - 3; })//x;\n\nprint $del % 2 ? \"Yes\" : \"No\""}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $del = 0;\n\t\n\tmy $pos = pos;\n\t\n\t( pos ) = $pos while s/\\G.*?\\K(.)\\1(?{ $del ++; $pos = ( pos ) - 3; })//x;\n\t\n\tprint $del % 2 ? \"Yes\" : \"No\";\n\t}"}], "src_uid": "8fd51c391728b433cc94923820e908ff"}
{"source_code": "sub uniq {\n    my %seen;\n    grep !$seen{$_}++, @_;\n}\nchomp($line=<STDIN>);\n($n,$l)=split(\" \",$line);\nchomp($line2=<STDIN>);\n@arr=split(\" \",$line2);\n@arr=uniq(@arr);\n@arr=sort{$a<=>$b}@arr;\n$max=0;\n$len=@arr;\nfor($i=0;$i<$len-1;$i++)\n\t{\n\t$d=$arr[$i+1]-$arr[$i];\n\tif($d>$max)\n\t\t{\n\t\t$max=$d;\n\t\t}\n\t}\n$max=$max/2;\nif($arr[0]!=0)\n\t{\n\t$c1=$arr[0];\n\t}\nif($c1>$max){$max=$c1;}\nif($arr[$len-1]!=$l)\n\t{\n\t$c2=$l-$arr[$len-1];\n\t}\nif($c2>$max){$max=$c2;}\nif($max==0){$max=$l;}\nprintf \"%.10f\", $max;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n\nmy $n; my $l;\nmy @num;\nsub valid{\n    my $d = shift;\n    my $last = 0;\n    for my $i(0..$n-1){\n        return 0 if $num[$i]-$d > $last;\n        $last = $last > $num[$i] + $d ? $last : $num[$i] + $d;\n    }\n    return $last >= $l;\n}\n\n($n,$l) = split ' ',<>;\n@num = split ' ',<>;\n@num = sort {$a <=> $b} @num;\nmy ($start,$len) = (0,$l+1);\nwhile($len > 1e-11){\n    $len /= 2.0;\n    my $mid = $start + $len;\n    $start = $mid if(!valid($mid)) ;\n}\n\nprintf \"%0.11f\\n\",$start;\n"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$l)=split;\n\t@_ = sort {$a <=> $b} split/ /,\"\".<>;\n\tchomp @_;\n\tunshift @_, -$_[0];\n\tpush @_, $l + ($l - $_[-1]);\n#\tprint \"@_\",$/;\n\t@d=();\n\tfor $i(1..@_-1){\n\t\tpush @d, $_[$i]-$_[$i-1];\n\t\t}\n\t@d = sort {$a <=> $b} @d;\t\n#\tprint \"@d\",$/;\n\tprint $d[-1]/2,$/;\n\t}"}, {"source_code": "use List::Util \"max\";\n\n($n, $l) = split \" \", <>;\n@arr = sort { $a <=> $b } split \" \", <>;\n$dist = max ($arr[0], $l - $arr[-1]);\n\nfor (1 .. $n - 1) {\n    $dist = max ($dist, ($arr[$_] - $arr[$_ - 1]) / 2);\n}\nprintf (\"%.10f\\n\", $dist);"}, {"source_code": "my ($n, $m) = split / /,<>;\nmy @arr = sort {$a <=> $b} map {$_ = int$_} split / /, <>;\n@arr = (-$arr[0], @arr, $m + $m - $arr[-1]);\nmy $max = 0;\nfor(1..$n+1) {\n    $max = $arr[$_] - $arr[$_ - 1] if ($arr[$_] - $arr[$_ - 1] > $max);\n}\nprint $max / 2;\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n# use List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nsub max {\n    my ($x, $y) = (shift, shift);\n    return $x>$y ? $x:$y;\n}\n\n($n, $l) = split / /, <>;\n@a = sort {$a <=> $b} split / /, <>;\n$ans = max ($a[0]*2, ($l-$a[-1])*2);\n$ans = max $ans,$a[$_]-$a[$_-1] foreach (1..$n-1);\nsay $ans/2;"}], "negative_code": [{"source_code": "use List::Util \"max\";\n\n($n, $l) = split \" \", <>;\n@arr = sort { $a <=> $b } split \" \", <>;\n$dist = max ($arr[0], $l - $arr[-1]);\n\nfor (1 .. $n - 2) {\n    $dist = max ($dist, ($arr[$_] - $arr[$_ - 1]) / 2);\n}\nprintf (\"%.10f\\n\", $dist);"}, {"source_code": "my ($n, $m) = split / /,<>;\nmy @arr = sort {$a <=> $b} map {$_ = int$_} ((split / /, <>) , $m);\nmy $max = 0;\nfor(1..$n) {\n    $max = $arr[$_] - $arr[$_ - 1] if ($arr[$_] - $arr[$_ - 1] > $max);\n}\nprint $max / 2;"}, {"source_code": "my ($n, $m) = split / /,<>;\nmy @arr = sort {$a <=> $b} map {$_ = int$_} split / /, <>;\n@arr = (-$arr[0], @arr, $m + $m - $arr[-1]);\nmy $max = 0;\nfor(1..$n) {\n    $max = $arr[$_] - $arr[$_ - 1] if ($arr[$_] - $arr[$_ - 1] > $max);\n}\nprint $max / 2;"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n#use List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nsub max {\n    my ($x, $y) = (shift, shift);\n    return $x>$y ? $x:$y;\n}\n\n($n, $l) = split / /, <>;\n@a = sort {$a <=> $b} split / /, <>;\n$ans = max ($a[0]*2, (l-$a[-1])*2);\n$ans = max ($ans,$a[$_]-$a[$_-1]) foreach (1..$n-1);\nsay $ans/2;"}, {"source_code": "sub uniq {\n    my %seen;\n    grep !$seen{$_}++, @_;\n}\nchomp($line=<STDIN>);\n($n,$l)=split(\" \",$line);\nchomp($line2=<STDIN>);\n@arr=split(\" \",$line2);\n@arr=uniq(@arr);\n@arr=sort{$a<=>$b}@arr;\n$max=0;\n$len=@arr;\nfor($i=0;$i<$len-1;$i++)\n\t{\n\t$d=$arr[$i+1]-$arr[$i];\n\tif($d>$max)\n\t\t{\n\t\t$max=$d;\n\t\t}\n\t}\n$max=$max/2;\nif($arr[0]!=0)\n\t{\n\t$c1=$arr[0];\n\t}\nif($c1>$max){$max=$c1;}\nif($arr[$len-1]!=$l)\n\t{\n\t$c2=$arr[$len-1];\n\t}\nif($c2>$max){$max=$c2;}\nprintf \"%.10f\", $max;\n"}, {"source_code": "sub uniq {\n    my %seen;\n    grep !$seen{$_}++, @_;\n}\nchomp($line=<STDIN>);\n($n,$l)=split(\" \",$line);\nchomp($line2=<STDIN>);\n@arr=split(\" \",$line2);\n@arr=uniq(@arr);\n@arr=sort{$a<=>$b}@arr;\n$max=0;\n$len=@arr;\nfor($i=0;$i<$len-1;$i++)\n\t{\n\t$d=$arr[$i+1]-$arr[$i];\n\tif($d>$max)\n\t\t{\n\t\t$max=$d;\n\t\t}\n\t}\n$max=$max/2;\nif($arr[0]!=0)\n\t{\n\t$c1=$arr[0];\n\t}\nif($c1>$max){$max=$c1;}\nif($arr[$len-1]!=$l)\n\t{\n\t$c2=$arr[$len-1];\n\t}\nif($c2>$max){$max=$c2;}\nif($max==0){$max=$l;}\nprintf \"%.10f\", $max;\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n; my $l;\nmy @num;\nsub valid{\n    my $d = shift;\n    my $last = 0;\n    for my $i(0..$n-1){\n        return 0 if $num[$i]-$d > $last;\n        $last = $last > $num[$i] + $d ? $last : $num[$i] + $d;\n    }\n    return $last >= $l;\n}\n\n($n,$l) = split ' ',<>;\n@num = split ' ',<>;\n@num = sort {$a <=> $b} @num;\nmy ($low,$high) = (0,$l+1);\nwhile($high - $low > 1e-8){\n    my $mid = ($low + $high) / 2;\n    if(valid($mid)){\n        $high = $mid;\n    }\n    else{\n        $low = $mid;\n    }\n}\n\nprintf \"%0.11   f\\n\",$low;\n"}], "src_uid": "d79166497eb61d81fdfa4ef80ec1c8e8"}
{"source_code": "sub game($$){\n    my $r=($_[0]-1)/$_[1];\n    while($r>=1){\n        if ($r == 1){\n            return 1;\n        }\n        $r/=$_[1];\n    }\n    return 0;\n}\n$\\=$/;\nmy $max=0;\n$n=<STDIN>;\nmy $maxn=0;\n@sculptures=(0,split(\" \",<STDIN>));\n\n$pointSTOP=$n/3;\n\nfor ($index=1;$index<$n+1;$index++){\n    \n    $max+=$sculptures[$index];\n\n}\n#print \"pointSTOP=\".$pointSTOP.\"   n=\".$n.\"\\n\";\nfor ($delims=2;(($delims<=$pointSTOP));$delims++){\n    if (($n%$delims==0)){\n#       print \"delims=\".\"$delims\";\n        \n        for ($index=1;(($index<=$delims));$index++){\n            #if (game($index,$delims)==0){\n                #print \"        index=\".\"$index\";\n                $maxn=0;\n                for ($subindex=$index-1;$subindex<$index+$n-1;($subindex+=$delims)){\n                #   print \"         subindex=\".$subindex.\"    delims=\".$delims.\"    sculpturerank=\".$sculptures[$subindex%($n)+1];\n                    $maxn+=$sculptures[$subindex%($n)+1];\n                #   print \"         maxn=\".$maxn;\n                }\n                #print \"        max=\".$max.\"  maxn=\".$maxn;\n                if ($max<$maxn){\n                $max=$maxn;\n                }\n            #}\n        }\n    }\n    \n}\n\nprint $max;\n", "positive_code": [{"source_code": "#!perl\nsub sum{\n\tmy $step = shift;\n\tmy $start = shift;\n\tmy $s = 0;\n\tfor(my $i = $start; $i <= $#_; $i += $step){\n\t\t$s += $_[$i];\n\t}\n\t$s;\n}\nmy $n = <STDIN>;\nif ($n <= 2) {\n\tdie \"wrong input\\n\";\n}\nmy @possible;\n$m = sqrt($n);\nfor (my $i = 2; $i <= $m; $i++) {\n\tif (0 == $n % $i) {\n\t\t$d = int $n / $i;\n\t\tpush @possible, $i if $d >= 3;\n\t\tpush @possible, $d if $i >= 3;\n\t}\n}\n\nmy @statues = map {int $_} grep {/^-?\\d+$/} split / +/, <STDIN>;\n@statues = @statues[0..($n-1)];\nmy $max = sum 1, 0, @statues;\nfor my $k(@possible){\n\tfor (0..($k-1)) {\n\t\tmy $s = sum $k, $_, @statues;\n\t\t$max = $s if ($s > $max);\n\t}\n}\nprint $max.\"\\n\";\n"}, {"source_code": "use strict;\n\nchomp(my $n = <>);\nmy @a = split / /, <>;\n\nmy $res = -1e9;\n\nfor (my $i = 1; $i <= $n / 3; $i++) {\n  $n % $i == 0 or next;\n  for (my $j = 0; $j < $i; ++$j) {\n    my $t = 0;\n    for (my $x = $j; $x < $n; $x += $i) {\n      $t += $a[$x];\n    }\n    $res = $res > $t ? $res : $t;\n  }\n}\n\nprint $res, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\n# Codeforces Practice - 26 May 2012\nuse strict;\nuse warnings;\nuse Math::Complex;\n\nmy $n = <STDIN>;\nchomp($n);\n\nmy @tis = split(\" \",<STDIN>);\n\nmy $tSum =0;\n$tSum += $_ for @tis; #summing up the array\n\nif($n<6) {\n    print $tSum;\n}\n\nelse {\n    my @sums = ($tSum);\n    my $count;\n    \n    #................ Calculate factors of $n\n    \n    my @factors;\n\n    for(2..sqrt $n){\n        if($n % $_ == 0){\n            my $div = $n/$_;\n            push(@factors,$_);\n            unless($div == $_){\n                push(@factors,$div);\n    }}}\n\n    @factors = sort {$a<=>$b} @factors;\n\n    #................ Finished calculating factors of $n\n\n    foreach my $factor (@factors){\n        next if ($n / $factor < 3);\n        my @factSums = ();\n        my $count = 0;\n        foreach my $t (@tis){\n            @factSums[$count++ % $factor] += $t;\n        }\n        @sums = (@sums,@factSums);\n    }\n    \n    my $max = $sums[0];\n$_ > $max and $max = $_ \n    for @sums;\n    \n    \nprint $max;\n}\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse List::Util qw(sum max);\n\nmy $n = <>;\nmy @t = split ' ', <>;\n\nmy @foos = ();\n\nfor my $m (1 .. $n / 3) {\n    next unless $n % $m == 0;\n    for my $i (0 .. $m - 1) {\n        my @foo = map { $t[$i + $m * $_] } (0 .. $n / $m - 1);\n        push @foos, sum @foo;\n    }\n}\n\nprint max @foos;\n"}, {"source_code": "my ($n) = split(/\\s/, <STDIN>);\n\nmy @t = split(/\\s/, <STDIN>);\n\nsub calc {\n    my (@a) = @_;\n    my $sum = 0;\n    for my $e (@a) {\n        $sum += $e;\n    }\n    if (scalar @a % 2 == 0 && scalar @a > 4) {\n        my @b;\n        my @c;\n        for (my $i = 0; $i < scalar @a; $i++) {\n            if ($i % 2 == 0) {\n                push(@b, $a[$i]);\n            } else {\n                push(@c, $a[$i]);\n            }\n        }\n        my $odd_sum = calc(@b);\n        my $even_sum = calc(@c);\n        $sum = $odd_sum if ($odd_sum > $sum);\n        $sum = $even_sum if ($even_sum > $sum);\n    }\n    return $sum;\n}\n\nprint calc(@t);"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n# Codeforces Practice - 26 May 2012\nuse strict;\nuse warnings;\n\n\nmy $n = <STDIN>;\nchomp($n);\n\nmy @tis = split(\" \",<STDIN>);\nmy $tSum =0;\n$tSum += $_ for @tis;\nif($n%2==1 || $n<6) {print $tSum;}\nelse {\nmy ($sum1,$sum2) = (0,0);\nmy $toggle = 0;\nforeach my $t (@tis) {\n    if($toggle){\n        $sum1 += $t;\n    } else {\n        $sum2 += $t;\n    }\n    $toggle = not $toggle;\n}\nif($sum1 >= $tSum && $sum1 >= $sum2){print $sum1;}\nelsif($sum2 >= $tSum && $sum2 >= $sum1){print $sum2;}\nelse {print $tSum;}\n}\n"}, {"source_code": "#!/usr/bin/perl\n# Codeforces Practice - 26 May 2012\nuse strict;\nuse warnings;\n\n\nmy $n = <STDIN>;\nchomp($n);\n\nmy @tis = split(\" \",<STDIN>);\nmy $tSum =0;\n$tSum += $_ for @tis;\nif($n%2==1) {print $tSum;}\nelse {\nmy ($sum1,$sum2) = (0,0);\nmy $toggle = 0;\nforeach my $t (@tis) {\n    if($toggle){\n        $sum1 += $t;\n    } else {\n        $sum2 += $t;\n    }\n    $toggle = not $toggle;\n}\nif($sum1 >= $tSum && $sum1 >= $sum2){print $sum1;}\nelsif($sum2 >= $tSum && $sum2 >= $sum1){print $sum2;}\nelse {print $tSum;}\n}\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse List::Util qw(sum max);\n\nmy $n = <>;\nmy @t = split ' ', <>;\n\nmy @foos = ();\n\nfor my $m (1 .. $n) {\n    next unless $n % $m == 0;\n    for my $i (0 .. $m - 1) {\n        my @foo = map { $t[$i + $m * $_] } (0 .. $n / $m - 1);\n        push @foos, sum @foo;\n    }\n}\n\nprint max @foos;\n"}, {"source_code": "sub game($$){\n    my $r=($_[0]-1)/$_[1];\n    while($r>=1){\n        if ($r == 1){\n            return 1;\n        }\n        $r/=$_[1];\n    }\n    return 0;\n}\n$\\=$/;\nmy $max=0;\n$n=<STDIN>;\nmy $maxn=0;\n@sculptures=(0,split(\" \",<STDIN>));\n\n$pointSTOP=$n/3;\n\nfor ($index=1;$index<$n+1;$index++){\n    \n    $max+=$sculptures[$index];\n\n}\n#print \"pointSTOP=\".$pointSTOP.\"   n=\".$n.\"\\n\";\nfor ($delims=2;(($delims<$pointSTOP));$delims++){\n    if (($n%$delims==0)){\n#       print \"delims=\".\"$delims\";\n        \n        for ($index=1;(($index<=$delims));$index++){\n            #if (game($index,$delims)==0){\n                #print \"        index=\".\"$index\";\n                $maxn=0;\n                for ($subindex=$index-1;$subindex<$index+$n-1;($subindex+=$delims)){\n                #   print \"         subindex=\".$subindex.\"    delims=\".$delims.\"    sculpturerank=\".$sculptures[$subindex%($n)+1];\n                    $maxn+=$sculptures[$subindex%($n)+1];\n                #   print \"         maxn=\".$maxn;\n                }\n                #print \"        max=\".$max.\"  maxn=\".$maxn;\n                if ($max<$maxn){\n                $max=$maxn;\n                }\n            #}\n        }\n    }\n    \n}\n\nprint $max;\n"}, {"source_code": "sub game($$){\n    my $r=($_[0]-1)/$_[1];\n    while($r>=1){\n        if ($r == 1){\n            return 1;\n        }\n        $r/=$_[1];\n    }\n    return 0;\n}\n$\\=$/;\nmy $max=0;\n$n=<STDIN>;\nmy $maxn=0;\n@sculptures=(0,split(\" \",<STDIN>));\n\n$pointSTOP=$n/3+1;\n\nfor ($index=1;$index<$n+1;$index++){\n    \n    $max+=$sculptures[$index];\n\n}\n#print \"pointSTOP=\".$pointSTOP.\"   n=\".$n.\"\\n\";\nfor ($delims=2;(($delims<$pointSTOP));$delims++){\n    if (($n%$delims==0)){\n        #print \"delims=\".\"$delims\";\n        \n        for ($index=1;(($index<=$delims));$index++){\n            #if (game($index,$delims)==0){\n            #   print \"     index=\".\"$index\";\n                $maxn=0;\n                for ($subindex=$index-1;$subindex<$index+$n-1;($subindex+=$delims)){\n                    #print \"            subindex=\".$subindex.\"    delims=\".$delims.\"    sculpturerank=\".$sculptures[$subindex%($n)+1];\n                    $maxn+=$sculptures[$subindex%($n)+1];\n                    #print \"            maxn=\".$maxn;\n                }\n                #print \"        max=\".$max.\"  maxn=\".$maxn;\n                if ($max<$maxn){\n                $max=$maxn;\n                }\n            #}\n        }\n    }\n    \n}\n\nprint $max;\n"}, {"source_code": "use strict;\n\nmy ($n) = split(/\\s/, <STDIN>);\n\nmy @t = split(/\\s/, <STDIN>);\n\nsub calc {\n    my (@a) = @_;\n    my $sum = 0;\n    for my $e (@a) {\n        $sum += $e;\n    }\n    if (scalar @a % 2 == 0) {\n        my @b;\n        my @c;\n        for (my $i = 0; $i < scalar @a; $i++) {\n            if ($i % 2 == 0) {\n                push(@b, $a[$i]);\n            } else {\n                push(@c, $a[$i]);\n            }\n        }\n        my $sum_even = calc(@b);\n        my $sum_odd = calc(@c);\n        $sum = $sum_even if ($sum < $sum_even);\n        $sum = $sum_odd if ($sum < $sum_odd);\n    }\n    return $sum;\n}\n\nprint calc(@t) . \"\\n\";"}, {"source_code": "my ($n) = split(/\\s/, <STDIN>);\n\nmy @t = split(/\\s/, <STDIN>);\n\nmy @res = ();\n\nsub calc {\n    my (@a) = @_;\n    my $sum = 0;\n    for my $e (@a) {\n        $sum += $e;\n    }\n    push (@res, $sum);\n    if (scalar @a % 2 == 0) {\n        my @b;\n        my @c;\n        for (my $i = 0; $i < scalar @a; $i++) {\n            if ($i % 2 == 0) {\n                push(@b, $a[$i]);\n            } else {\n                push(@c, $a[$i]);\n            }\n        }\n        calc(@b);\n        calc(@c);\n    }\n}\n\ncalc(@t);\n\nmy $max = $res[0];\nfor $e (@res) {\n    $max = $e if ($max < $e);\n}\n\n\nprint $max;"}], "src_uid": "0ff4ac859403db4e29554ca7870f5490"}
{"source_code": "#!/usr/bin/perl\n\n$n = <STDIN>;\n@b = split ' ', <STDIN>;\n$ans = 0;\n$delta = 0;\nforeach (@b) {\n    $ans += abs $_ - $delta;\n    $delta += $_ - $delta;\n}\nprint $ans, \"\\n\";\n\n", "positive_code": [{"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@_ = split ' ', <>;\n\t\n\t$sum = 0;\n\t$i = 0;\n\t\n\tfor (@_){\n\t\t$sum += abs($_ - $i);\n\t\t$i = $_;\n\t\t}\n\t\n\tprint $sum\n\t\n\t}"}, {"source_code": "#     /\\ /\\\n$_ = (<>,<>);\n#       O\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s + abs"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s"}, {"source_code": "$_ = (<>,<>);\n\n$s = abs;\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s\n"}], "negative_code": [{"source_code": "$s = $_ = (<>,<>);\n\n$s += abs $2 - $1 while /(\\S+)(?= (\\S+))/g;\n\nprint $s"}], "src_uid": "97a226f47973fcb39c40e16f66654b5f"}
{"source_code": "<>;\n\n$h{ $_ } ++ or $L = $_ for reverse split ' ', <>;\n\nprint $L", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy %h;\n\tmy $last;\n\t\n\tfor( reverse split ' ', <> ){\n\t\tnot exists $h{ $_ } and $last = $_;\n\t\t$h{ $_ } ++;\n\t\t}\n\t\n\tprint $last;\n\t}"}], "negative_code": [], "src_uid": "bdea209c7b628e4cc90ebc2572826485"}
{"source_code": "@A = 0 .. 1e6;\n\n( $n, $m, $k ) = split ' ', <>;\n$A[ $_ ] = 0 for split ' ', <>;\n\t\n$x = 1;\n\nwhile(<>){\n\t\n\t( $u, $v ) = split;\n\t\n\tnext if ! $A[ $x ];\n\t\t\n\t$x == $u and $x = $v or\n\t$x == $v and $x = $u\n\t}\n\nprint $x", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m, $k ) = split;\n\tmy @A = 0 .. 1e6;\n\tmap { $A[ $_ ] = -1 } split ' ', <>;\n\t\t\n\tmy $x = 1;\n\t\n\tfor (1 .. $k){\n\t\t\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\tif( $A[ $x ] == -1 ){\n\t\t\tnext;\n\t\t\t}\n\t\t\t\n\t\t$x == $u and $x = $v and next;\n\t\t$x == $v and $x = $u and next;\n\t\t}\n\t\n\tprint $x;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m, $k ) = split;\n\tmy @A = 0 .. 1e6;\n\tmap { $A[ $_ ] = -1 } split ' ', <>;\n\t\t\n\tmy $x = 1;\n\t\n\tfor (1 .. $k){\n\t\t\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\tif( $A[ $x ] == -1 ){\n\t\t\tlast;\n\t\t\t}\n\t\t\t\n\t\t$x == $u and $x = $v and next;\n\t\t$x == $v and $x = $u and next;\n\t\t}\n\t\n\tprint $x;\n\t}"}], "src_uid": "1f41c017102f4a997be324a4ec9b7fd6"}
{"source_code": "use strict;\n\nmy ($n, $m, @pass, @fail);\n\n($n,$m) = split / /, <>;\n@pass = split / /, <>;\n@fail = split / /, <>;\nchomp(@pass), chomp(@fail);\n\n@pass = sort {$a <=> $b} @pass;\n@fail = sort {$a <=> $b} @fail;\n\n(print \"-1\") and exit if (($pass[-1] >= $fail[0]) || (2 * $pass[0] >= $fail[0]));\n\nprint ((2 * $pass[0] > $pass[-1]) ? 2 * $pass[0] : $pass[-1]);", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nsub max\n{\n    my $max = $_[0];\n    foreach (@_)\n    {\n        $max = $_ if $_ > $max;\n    };\n    return $max;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\n$possible = 0 if max(@right) >= min(@wrong);\n\nif ($possible)\n{\n    if (max(@right) == min(@right)) {\n        print min(min(@wrong) - 1, $v)\n    } else {\n        print min(min(@wrong) - 1, max(@right, $v))\n    }\n}\nelse\n{\n    print -1;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\nwhile(    <>=~/ / ){\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@a=split/ /,<>;\n@b=split/ /,<>;\n\n$ib=min(@b);\n$ia=min(@a);\n$aa=max(@a);\n\n$TL=max($ia*2,$aa);\nprint $TL<$ib?$TL:-1;\nn();\n\n}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "use strict;\n\nmy ($n, $m, @pass, @fail);\n\n($n,$m) = split / /, <>;\n@pass = split / /, <>;\n@fail = split / /, <>;\nchomp(@pass), chomp(@fail);\n\n@pass = sort @pass;\n@fail = sort @fail;\n\n(print \"-1\") and exit if (($pass[-1] >= $fail[0]) || (2 * $pass[0] >= $fail[0]));\n\nprint ((2 * $pass[0] > $pass[-1]) ? 2 * $pass[0] : $pass[-1]);"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nsub max\n{\n    my $max = $_[0];\n    foreach (@_)\n    {\n        $max = $_ if $_ > $max;\n    };\n    return $max;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\nif ($possible)\n{\n    if (max(@right) == min(@right)) {\n        print min(min(@wrong) - 1, $v)\n    } else {\n        print min(min(@wrong) - 1, max(@right))\n    }\n}\nelse\n{\n    print -1;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\nif ($possible)\n{\n    print min(@wrong) - 1;\n}\nelse\n{\n    print -1;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nsub max\n{\n    my $max = $_[0];\n    foreach (@_)\n    {\n        $max = $_ if $_ > $max;\n    };\n    return $max;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\n$possible = 0 if max(@right) >= max(@wrong);\n\nif ($possible)\n{\n    if (max(@right) == min(@right)) {\n        print min(min(@wrong) - 1, $v)\n    } else {\n        print min(min(@wrong) - 1, max(@right, $v))\n    }\n}\nelse\n{\n    print -1;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nsub max\n{\n    my $max = $_[0];\n    foreach (@_)\n    {\n        $max = $_ if $_ > $max;\n    };\n    return $max;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\nif ($possible)\n{\n    if (max(@right) == max(@wrong)) {\n        print min(min(@wrong) - 1, $v)\n    } else {\n        print min(min(@wrong) - 1, max(@right))\n    }\n}\nelse\n{\n    print -1;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nsub max\n{\n    my $max = $_[0];\n    foreach (@_)\n    {\n        $max = $_ if $_ > $max;\n    };\n    return $max;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\nif ($possible)\n{\n    print min(min(@wrong) - 1, $v)\n}\nelse\n{\n    print -1;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nsub min\n{\n    my $min = $_[0];\n    foreach (@_)\n    {\n        $min = $_ if $_ < $min;\n    };\n    return $min;\n}\n\nsub max\n{\n    my $max = $_[0];\n    foreach (@_)\n    {\n        $max = $_ if $_ > $max;\n    };\n    return $max;\n}\n\nmy ($m, $n) = split(' ', <>);\n\nmy @right = split(' ', <>);\nmy @wrong = split(' ', <>);\n\n\n\nmy $v = min(@right) * 2;\n\nmy $possible = 1;\n\n\nforeach my $time (@wrong)\n{\n    if ($time <= $v)\n    {\n        $possible = 0;\n        last;\n    }\n}\n\nif ($possible)\n{\n    if (max(@right) == min(@right)) {\n        print min(min(@wrong) - 1, $v)\n    } else {\n        print min(min(@wrong) - 1, max(@right, $v))\n    }\n}\nelse\n{\n    print -1;\n}\n"}], "src_uid": "49c47ebfd710a3733ce7ecb3a3c134a7"}
{"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Thu Oct 25 21:02:27 IST 2012\n# File Name: a.pl\n# USAGE: \n#       a.pl \n# \n# \n#------------------------------------------------\nuse List::Util qw(first max maxstr min minstr reduce shuffle sum);\nchomp (my $n = <STDIN>);\nmy %times;\nmy $buf;\nwhile ($n--) {\n  chomp ($buf = <STDIN>);\n  $times{$buf}++; \n}\nprint &max(values %times);\n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse List::Util qw(max);\nuse strict;\n\nmy %times = ();\nchomp(my $n = <>);\nfor (1 .. $n) {\n\tchomp($_ = <>);\n\t++$times{$_};\n}\nmy $res = max values %times;\nprint \"$res\\n\";\n"}, {"source_code": "use List::Util 'max';for(<>){++$_{$_}}print max values%_\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <STDIN>;\nmy %h = ();\nfor (1 .. $n) {\n  $_ = <STDIN>;\n  ++$h{$_};\n}\nmy $m = 0;\nfor (values %h) {\n  $m = $_ if $_ > $m;\n}\nprint \"$m\\n\";\n"}, {"source_code": "#!perl -n\nuse List::Util 'max';\nINIT{$_=<>}++$_{$_};END{print max values%_}\n"}, {"source_code": "#!perl -n\nuse List::Util 'max';\nBEGIN{$_='1'}++$_{$_};END{print max values%_}\n"}, {"source_code": "#!perl -n\nuse List::Util 'max';\nEND{print max values%_}++$_{$_}\n"}, {"source_code": "use strict;\nuse warnings;\nuse List::Util 'max';\n\nmy $n = <STDIN>;\nmy %h = ();\nfor (1 .. $n) {\n  $_ = <STDIN>;\n  ++$h{$_};\n}\nmy $m = 0;\nfor (values %h) {\n  $m = $_ if $_ > $m;\n}\nprint \"$m\\n\";\n"}, {"source_code": "<>; for (<>) {\n\tchomp;\n\tif ($_ eq $p) {\n\t\t$c++;\n\t} else {\n\t\t$c=1;\n\t\t$p=$_;\n\t}\n\t$C=$c>$C?$c:$C;\n}\nprint $C;\n"}, {"source_code": "my %hash;\nmy $n = int<>;\nmy $max = 0;\n$hash{<>}++ for(1..$n);\nfor(values %hash) {\n    $max = $_ if ($_ > $max);\n}\nprint $max;"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\n@c = (0) x 1440;\nchomp($n = <>);\nwhile (<>) {\n\tchomp;\n\t($h, $m) = split / /;\n\t++$c[$h*60+$m];\n}\n$ans = 0;\n$ans=$ans>$_ ? $ans:$_ foreach (@c);\nsay $ans;"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy ($ch, $cm) = (-1, -1);\nmy $mc = 0;\nmy $cash = 1;\nfor (1..$n) {\n    my ($h, $m) = split ' ', <>;\n    if ($h == $ch && $m == $cm) {\n        $cash++;\n    } else {\n        $cash = 1;\n    }\n    $ch = $h;\n    $cm = $m;\n    $mc = $cash > $mc ? $cash : $mc;\n}\n\nprint $mc, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse List::Util qw(max min);\n\nchomp(my $n = <STDIN>);\nmy %cnt;\nfor (my $i = 0; $i < $n; $i++) {\n    chomp(my $customer = <STDIN>);\n    if (exists($cnt{$customer})) {\n        $cnt{$customer} += 1;\n    } else {\n        $cnt{$customer} = 1;\n    }\n}\n\nprint max values %cnt;\n"}, {"source_code": "#!usr/bin/perl\n#use warnings;\n#use strict;\n#use autodie;\n#use diagnostics;\nuse utf8;\nuse 5.010;\nuse 5.012;\nuse 5.014;\nmy($line,$n,$max,$count,$prev,$ans);\n$count=0;\n$max=1;\n$ans=1;\nchomp($n=<STDIN>);\nwhile($count ne $n)\n{\n    chomp($line=<STDIN>);\n    if($count eq 0)\n    {\n        $prev=$line;\n        $count++;\n        next;\n    }\n    $count++;\n    if($prev eq $line)\n    {\n        $ans++;\n    }\n    else\n    {\n        if($max<$ans)\n        {\n            $max=$ans;\n        }\n        $ans=1;\n    }\n    $prev=$line;\n}\nif($max<$ans){$max=$ans;}\nsay $max;"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\nuse List::Util qw(max);\n\nmy $n = int <STDIN>;\nmy %hash;\nfor (1 .. $n) {\n    my ($h, $m) = map int, split /\\D/, <STDIN>;\n    $m += $h*60;\n    if ($hash{$m}) {\n\t$hash{$m}++;\n    } else {\n\t$hash{$m} = 1;\n    }\n}\nprint max values %hash;\n"}, {"source_code": "my $num = <>;\nchomp $num;\nmy %count;\nfor (1..$num) {\n    my $time = <>;\n    chomp $time;\n    $count{$time}++;\n}\nmy @temp = sort {$count{$b}<=>$count{$a}} keys %count;\nmy $time = shift @temp;\nprint $count{$time};"}], "negative_code": [{"source_code": "<>; for (<>) {\n\tchomp;\n\t$C=$c>$C?$c:$C;\n\tif ($_ eq $p) {\n\t\t$c++;\n\t} else {\n\t\t$c=1;\n\t\t$p=$_;\n\t}\n}\nprint $C;\n"}, {"source_code": "my $n = int<>;\nmy @temp;\nmy @arr;\nfor (1..$n) {\n    @temp = split / /, <>;\n    push @arr, $temp[0] * 100 + $temp[1];\n}\n@arr = sort @arr;\nmy ($max, $ans) = (0, 0);\nfor (1..$n - 1) {\n    if (int$arr[$_] == int$arr[$_ - 1]) {\n        $ans++;\n    }\n    else {\n        $max = $ans if ($ans > $max);\n        $ans = 0;\n    }\n}\nprint $max + 1;"}, {"source_code": "my $n = int<>;\nmy @temp;\nmy @arr;\nfor (1..$n) {\n    @temp = split / /, <>;\n    push @arr, $temp[0] * 100 + $temp[1];\n}\nmy ($max, $ans) = (0, 0);\nfor (1..$n - 1) {\n    if (int$arr[$_] == int$arr[$_ - 1]) {\n        $ans++;\n    }\n    else {\n        $max = $ans if ($ans > $max);\n        $ans = 0;\n    }\n}\nprint $max + 1;\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy ($ch, $cm) = (0, 0);\nmy $mc = 0;\nmy $cash = 1;\nfor (1..$n) {\n    my ($h, $m) = split ' ', <>;\n    if ($h == $ch && $m == $cm) {\n        $cash++;\n    } else {\n        $cash = 1;\n    }\n    $ch = $h;\n    $cm = $m;\n    $mc = $cash > $mc ? $cash : $mc;\n}\n\nprint $mc, \"\\n\";\n"}, {"source_code": "#!usr/bin/perl\n#use warnings;\n#use strict;\n#use autodie;\n#use diagnostics;\nuse utf8;\nuse 5.010;\nuse 5.012;\nuse 5.014;\nmy($line,$n,$max,$count,$prev,$ans);\n$count=0;\n$max=1;\n$ans=1;\nchomp($n=<STDIN>);\nwhile($count ne $n)\n{\n    chomp($line=<STDIN>);\n    if($count eq 0)\n    {\n        $prev=$line;\n        $count++;\n        next;\n    }\n    $count++;\n    if($prev eq $line)\n    {\n        $ans++;\n    }\n    else\n    {\n        if($max<$ans)\n        {\n            $max=$ans;\n        }\n        $ans=1;\n    }\n    $prev=$line;\n}\nsay $max;"}], "src_uid": "cfad2cb472e662e037f3415a84daca57"}
{"source_code": "chomp (($_, $b) = <>);\nfor $j (1 .. length){\n\t$e .= chop $b ne ($a = chop) ? \n\t\t(++ $i % 2 ? $a : 1 - $a)\n\t:\n\t\t0\n\t}\nprint $i % 2 ? 'impossible' : scalar reverse $e", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($a = <>);\nchomp($b = <>);\n$len = length $a;\n@a = split //, $a;\n@b = split //, $b;\n$c = 0;\n$a[$_] ne $b[$_] and ++$c foreach (0 .. $len-1);\n$c%2>0 and say \"impossible\" and exit;\nfor ($i=0,$j=0,$c>>=1; $i<$len; ++$i) {\n\tif ($a[$i] eq $b[$i]) {\n\t\tpush @ans, $a[$i];\n\t} else {\n\t\t$j < $c and push @ans, $a[$i] or push @ans, $b[$i];\n\t\t++$j;\n\t}\n}\nsay join '', @ans;"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($a = <>);\nchomp($b = <>);\n$len = length $a;\n@a = split //, $a;\n@b = split //, $b;\n$c = 0;\n$a[$_] ne $b[$_] and ++$c foreach (0 .. $len-1);\n$c%2>0 and say \"impossible\" and exit;\nfor ($i=0,$j=0; $i<$len; ++$i) {\n\tif ($a[$_] eq $b[$_]) {\n\t\tpush @ans, $a[$_];\n\t} else {\n\t\t$j < $c and push @ans, $a[$_] or push @ans, $b[$_];\n\t\t++$j;\n\t}\n}\nsay join '', @ans;"}, {"source_code": "chomp (($_, $b) = <>);\nfor $j (1 .. length){\n\t$e .= chop $b ne (chop) ? \n\t\t++ $i % 2\n\t:\n\t\t0\n\t}\nprint $i % 2 ? 'impossible' : scalar reverse $e"}, {"source_code": "chomp (($_, $b) = <>);\nfor $j (1 .. length){\n\t$e .= chop $b ne (chop) ? \n\t\t++ $i % 2\n\t:\n\t\t0\n\t}\nprint $i % 2 ? 'Impossible' : scalar reverse $e"}], "src_uid": "2df181f2d1f4063a22fd2fa2d47eef92"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tmy %h;\n\t\n\t/\n\t\t.\n\t\t(?{ $h{ $& } ++ })\n\t\t(*F)\n\t\t/x;\n\t\n\tmy @ans;\n\t\n\twhile( not grep !$_, @h{ split //, 'one' } ){\n\t\tpush @ans, 1;\n\t\tmap { $_ -- } @h{ split //, 'one' };\n\t\t}\n\t\n\twhile( not grep !$_, @h{ split //, 'zero' } ){\n\t\tpush @ans, 0;\n\t\tmap { $_ -- } @h{ split //, 'zero' };\n\t\t}\n\t\n\tprint join ' ', @ans;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub remainder {\n    my ($dividend, $divisor) = @_;\n}\n\n# solve\n\nmy $length = read_token;\nmy $input = read_line;\n\nmy @chars = split q{}, $input;\n\nmy @bins = ();\n\nfor (@chars) {\n    push @bins, 0 if $_ eq 'z';\n    push @bins, 1 if $_ eq 'n';\n}\n\n@bins = reverse sort @bins;\n\nsay \"@bins\";\n"}], "negative_code": [], "src_uid": "5e5dbd70c7fcedf0f965aed5bafeb06c"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $A, $B, $C, $T ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\tfor( @_ ){\n\t\tif( $B > $C ){\n\t\t\t$sum += $A;\n\t\t\t}\n\t\telse{\n\t\t\t$sum += $A + ( $T - $_ ) * ( $C - $B );\n\t\t\t}\n\t\t}\n\t\n\tprint $sum;\n\t}", "positive_code": [{"source_code": "my ($n, $A, $B, $C, $T) = split ' ', <>;\nmy @ti = split ' ', <>;\nmy $max_amt = 0;\n$max_amt += $A + ($C > $B ? $C - $B : 0) * ($T - $_) for @ti;\nprint \"$max_amt\\n\";\n"}, {"source_code": "( $n, $A, $B, $C, $T ) = split ' ', <>;\n\n$s += $A + ( $B < $C ) * ( $T - $_ ) * ( $C - $B ) for split ' ', <>;\n\nprint $s"}], "negative_code": [], "src_uid": "281b95c3686c94ae1c1e4e2a18b7fcc4"}
{"source_code": "#!/usr/bin/perl\r\n \r\nuse warnings;\r\nuse strict;\r\n \r\n$\\ = $/;\r\n \r\n<>;\r\n \r\nwhile(<>){\r\n\tmy( %h, $s, @Q );\r\n\t\r\n\tfor my $i ( 1 .. $_ - 1 ){\r\n\t\tmy( $u, $v ) = split ' ', <>;\r\n\t\t$h{ $u }{ $v } = $i;\r\n\t\t$h{ $v }{ $u } = $i;\r\n\t\t}\r\n\t\r\n\tif( grep { 2 < values %{ $h{ $_ } } } keys %h ){\r\n\t\tprint -1;\r\n\t\tnext;\r\n\t\t}\r\n\t\r\n\tmy( $f ) = grep { 1 == values %{ $h{ $_ } } } keys %h;\r\n\t\r\n\tfor my $i ( 1 .. $_ - 1 ){\r\n\t\t( $s ) = keys %{ $h{ $f } };\r\n\t\tpush @Q, [ $h{ $f }{ $s }, 2 + $i % 2 ];\r\n\t\tdelete $h{ $s }{ $f };\r\n\t\t$f = $s;\r\n\t\t}\r\n\t\r\n\t@Q = map $_->[ 1 ], sort { $a->[ 0 ] <=> $b->[ 0 ] } @Q;\r\n\t\r\n\tprint \"@Q\";\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\tmy $n = $_;\n\t\n\tmy %h;\n\tmy %g;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$g{ $u } ++;\n\t\t$g{ $v } ++;\n\t\t$h{ $u }{ $v } = $i;\n\t\t$h{ $v }{ $u } = $i;\n\t\t}\n\t\n\t$_ = join '', sort { $a <=> $b } values %g;\n\t\n\tif( not m/^112*$/ ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy $first;\n\t\n\tfor my $i ( 1 .. $n ){\n\t\tif( $g{ $i } == 1 ){\n\t\t\t$first = $i;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tmy $second;\n\t\n\tmy @seq;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\t( $second ) = sort keys %{ $h{ $first } };\n\t\tpush @seq, [ $h{ $first }{ $second }, $i % 2 ];\n\t\texists $h{ $second }{ $first } and delete $h{ $second }{ $first };\n\t\t$first = $second;\n\t\t}\n\t\n\t@seq = map $_->[ 1 ], sort { $a->[ 0 ] <=> $b->[ 0 ] } @seq;\n\t\n\tprint \"@seq\" =~ y/10/52/r;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( %h, $s, @Q );\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t$h{ $u }{ $v } = $i;\n\t\t$h{ $v }{ $u } = $i;\n\t\t}\n\t\n\tif( grep { 2 < values %{ $h{ $_ } } } keys %h ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy( $f ) = grep { 1 == values %{ $h{ $_ } } } keys %h;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\t( $s ) = keys %{ $h{ $f } };\n\t\tpush @Q, [ $h{ $f }{ $s }, 2 + $i % 2 ];\n\t\tdelete $h{ $s }{ $f };\n\t\t$f = $s;\n\t\t}\n\t\n\t@Q = map $_->[ 1 ], sort { $a->[ 0 ] <=> $b->[ 0 ] } @Q;\n\t\n\tprint \"@Q\";\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\tmy $n = $_;\n\t\n\tmy %h;\n\tmy %g;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$g{ $u } ++;\n\t\t$g{ $v } ++;\n\t\t$h{ $u }{ $v } = $i;\n\t\t$h{ $v }{ $u } = $i;\n\t\t}\n\t\n\t$_ = join '', sort { $a <=> $b } values %g;\n\t\n\tif( not m/^112*$/ ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy $first;\n\t\n\tfor my $i ( 1 .. $n ){\n\t\tif( $g{ $i } == 1 ){\n\t\t\t$first = $i;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tmy $second;\n\t\n\tmy @seq;\n\t\n\tfor my $i ( 1 .. $n - 1 ){\n\t\t( $second ) = keys %{ $h{ $first } };\n\t\tpush @seq, [ $h{ $first }{ $second }, $i % 2 ];\n\t\texists $h{ $second }{ $first } and delete $h{ $second }{ $first };\n\t\t$first = $second;\n\t\t}\n\t\n\t@seq = map $_->[ 1 ], sort { $a->[ 0 ] <=> $b->[ 1 ] } @seq;\n\t\n\tprint \"@seq\" =~ y/10/52/r;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\tmy $n = $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++,\n\tmap { split ' ', <> } 1 .. $n - 1;\n\t\n\t$_ = join '', sort { $a <=> $b } values %h;\n\t\n\tif( m/^112*+2*+2*+2*+$/ ){\n\t\tprint join ' ', ( qw( 2 5 11 ) x ( 1 + $n / 3 ) )[ 0 .. $n - 2 ];\n\t\t}\n\telse{\n\t\tprint -1;\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\tmy $n = $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++,\n\tmap { split ' ', <> } 1 .. $n - 1;\n\t\n\t$_ = join '', sort { $a <=> $b } values %h;\n\t\n\tif( m/^112*$/ ){\n\t\tprint join ' ', ( qw( 2 5 11 ) x ( 1 + $n / 3 ) )[ 0 .. $n - 2 ];\n\t\t}\n\telse{\n\t\tprint -1;\n\t\t}\n\t}"}], "src_uid": "0639fbeb3a5be67a4c0beeffe8f5d43b"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $div = int $_ / 2020;\n\t\n\tmy $div_plus = 2021 * $div;\n\t\n\tif( $div_plus >= $_ ){\n\t\tprint \"YES\";\n\t\t}\n\telse{\n\t\tprint \"NO\";\n\t\t}\n\t}", "positive_code": [{"source_code": "for (1..<>) {\r\n        chomp (my $n = <>);\r\n        my $flag = 0;\r\n        unless ($n%2021) {\r\n                $flag = 1;\r\n        }\r\n        while ($n >= 2020) {\r\n                unless ($n%2020) {\r\n                        $flag = 1;\r\n                        last;\r\n                }\r\n                $n -= 2021;\r\n        }\r\n        print $flag? \"YES\\n\" : \"NO\\n\";\r\n}\r\nexit;"}], "negative_code": [], "src_uid": "3ec1b7027f487181dbdfb12f295f11ae"}
{"source_code": "my $max;\r\nmy $min;\r\n\r\nfor(1..<>) {\r\n        $min = 1000000001;\r\n        $max = 0;\r\n        <>;\r\n        chomp (my $in = <>);\r\n        @a = split / /, $in;\r\n        foreach (@a){\r\n                if ($_ > $max) {\r\n                        $max = $_;\r\n                }\r\n                if ($_ < $min) {\r\n                        $min = $_;\r\n                }\r\n        }\r\n        print $max - $min;\r\n        print \"\\n\";\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t@_ = sort { $b <=> $a } @_;\n\t\n\tprint $_[ 0 ] - $_[ @_ - 1 ];\n\t}"}], "negative_code": [{"source_code": "my $max;\r\nmy $min;\r\n\r\nfor(1..<>) {\r\n        $min = 9999999;\r\n        $max = 0;\r\n        <>;\r\n        chomp (my $in = <>);\r\n        @a = split / /, $in;\r\n        foreach (@a){\r\n                if ($_ > $max) {\r\n                        $max = $_;\r\n                }\r\n                if ($_ < $min) {\r\n                        $min = $_;\r\n                }\r\n        }\r\n        print $max - $min;\r\n        print \"\\n\";\r\n}"}, {"source_code": "my $max;\r\nmy $min;\r\n\r\nopen(FH, '<', 'input.txt');\r\n\r\nfor(1..<FH>) {\r\n        $min = 9999999;\r\n        $max = 0;\r\n        <FH>;\r\n        chomp (my $in = <FH>);\r\n        @a = split / /, $in;\r\n        foreach (@a){\r\n                if ($_ > $max) {\r\n                        $max = $_;\r\n                }\r\n                if ($_ < $min) {\r\n                        $min = $_;\r\n                }\r\n        }\r\n        print $max - $min;\r\n        print \"\\n\";\r\n}"}], "src_uid": "cf3cfcae029a6997ee62701eda959a60"}
{"source_code": "<>;\n@_=<>;\nwhile(@_){\n\t@c=((split/ /,$_[0])[0]);\n\twhile (@c){\n\t\t$c=shift @c;\n\t\tfor (@_){\n\t\t\tif (/\\b$c\\b/){\n\t\t\t\ts/ ?\\b$c\\b ?//;\n\t\t\t\tpush @c, 0+$_;\n\t\t\t\t$a++;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tpush @left, $_\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\tpush @all, $c, @c;\n\t\tfor (@left){\n\t\t\t($x,$y)=split/ /;\n\t\t\t$f=0;\n\t\t\tfor $ix(@all){\n\t\t\t\t$ix==$x and $f++\n\t\t\t\t}\n\t\t\t$g=0;\n\t\t\tfor $iy(@all){\n\t\t\t\t$iy==$y and $g++\n\t\t\t\t}\n\t\t\t$f and $g or push @LEFT,$_ \n\t\t\t}\n\t\t@_=@LEFT;\n\t\t@LEFT=();\n\t\t@left=();\n\t\t\n\t\t}\n\t\n\t}\nprint 2**$a", "positive_code": [{"source_code": "\n\n\n# perform dfs to make the connected\n# components\nsub make_disjoint_sets {\n\n    my ($lst_ref, $visit_ref, $ds_ref, $curr, $id ) = @_;\n    \n    if ( exists $visit_ref -> { $curr } ) {\n\treturn;\n    }\n    \n    $visit_ref -> { $curr } = 1;\n    $ds_ref -> { $curr } = $id;\n    \n    for my $adjacent ( keys %{ $lst_ref -> { $curr } } ) {\n\t&make_disjoint_sets ( $lst_ref, $visit_ref,\n\t\t\t     $ds_ref, $adjacent, $id );\n    }\n\n    return;\n}\n\n# use a hash as a set to count the number\n# of unique sets\nsub count_disjoint_sets {\n\n    my $ds_ref = $_[0];\n    my %count_set = ();\n\n    for my $i (values %{ $ds_ref }) {\n\t$count_set { $ds_ref -> { $i } } = 1;\n    }\n\n    my $val = (scalar (keys %count_set));\n    return $val;\n}\n\n\nmy $f = <STDIN>;\nchomp ( $f );\nmy ($n, $m) = split m/ /, $f;\n\nmy %disjoint_sets = ();\nmy %lst = ();\nmy %visit = ();\n\nmy $a, $b;\nfor my $i (1..$m) {\n    $f = <STDIN>;\n    chomp ( $f );\n    ($a, $b) = split m/ /, $f;\n    $lst { $a }{ $b } = 1;\n    $lst { $b }{ $a } = 1;\n}\n\n\n\nfor my $i (1..$n) {\n    &make_disjoint_sets ( \\%lst, \\%visit, \\%disjoint_sets, $i, $i );\n}\n\nmy $cc = &count_disjoint_sets ( \\%disjoint_sets );\n\nmy $answer = (2 ** ($n - $cc));\n    \nprint \"$answer\\n\";\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}], "negative_code": [], "src_uid": "c36f4bb34543476abc31fe986032122d"}
{"source_code": "\nsub maxInd {\n    (my $max, my $index) = (0, 0);\n    for($i = 0; $i <= $#_; $i++)\n    {\n        if($max < $_[$i]) {\n            $max = $_[$i];\n            $index = $i;\n        }\n    }\n    $index;\n}\n\nsub minInd {\n    (my $min, my $index) = (100, 0);\n    for($i = $#_; $i >= 0; $i--)\n    {\n        if($min > $_[$i]) {\n            $min = $_[$i];\n            $index = $i;\n        }\n    }\n    $index;\n}\n\n<STDIN>;\nchomp($s = <STDIN>);\n@arr = split(/ /, $s);\n$max = &maxInd(@arr);\n$min = &minInd(@arr);\n$answer = $max + abs($#arr - $min);\nprint $max - $min > 0 ? --$answer : $answer;", "positive_code": [{"source_code": "my $n   = <>;\nmy @arr = split \" \", <>;\nmy ($min, $max) = (105, 0);\nmy ($x, $y) = (105, 0);\n\nfor (my $i = 0; $i < $n; $i++) {\n    if ($arr[$i] <= $min) {\n        $min = $arr[$i];\n        $x = $i;\n        # print \"$min $x\\n\";\n    }\n    if ($arr[$i] > $max) {\n        $max = $arr[$i];\n        $y = $i;\n        # print \"$max $y\\n\";\n    }\n}\nmy $ans = $y + $n - $x - 1;\n$ans-- if ($x < $y);\nprint $ans;\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\n($mn, $mx) = (10 x 8, -10 x 8);\n$i = 0;\nfor (split / /, <>) {\n\tif ($_ > $mx) {\n\t\t$mx = $_;\n\t\t$mxv = $i;\n\t}\n\tif ($_ <= $mn) {\n\t\t$mn = $_;\n\t\t$mnv = $i;\n\t}\n\t++$i;\n}\n$ans = $mxv - 1 + $n - $mnv;\n$mnv<$mxv and --$ans;\nsay $ans;\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\n<>;\nmy @a = split ' ', <>;\n\nmy $imax = 0;\nmy $imin = 0;\n$imax = $a[$_] > $a[$imax] ? $_ : $imax for 1..$#a;\n$imin = $a[$_] <= $a[$imin] ? $_ : $imin for 1..$#a;\n\nprint $imax > $imin ? ($imax + ($#a - $imin) - 1) : ($imax + ($#a - $imin)), \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\n<>;\nmy @a = split ' ', <>;\n\nmy $imax = 0;\nmy $imin = 0;\nmy $c = 0;\n$imax = $a[$_] > $a[$imax] ? $_ : $imax for 1..$#a;\n\nwhile ($imax != 0) {\n    @a[$imax - 1, $imax] = @a[$imax, $imax - 1];\n    $imax--;\n    $c++;\n}\n\n$imin = $a[$_] <= $a[$imin] ? $_ : $imin for 1..$#a;\n\nwhile ($imin != $#a) {\n    @a[$imin - 1, $imin] = @a[$imin, $imin - 1];\n    $imin++;\n    $c++;\n}\n\nprint $c, \"\\n\";\n"}, {"source_code": "chomp($n = <STDIN>);\n@soldiers = split /\\s+/, <STDIN>;\n\n%pos = { };\n$tall = -1;\n$small = 99999;\n\nfor($s=0;$s < $n; $s++) {\n\tif($soldiers[$s] > $tall) {\n\t\t$tall = $soldiers[$s];\n\t\t$pos{'tall'} = $s;\n\t}\n\tif($soldiers[$s] <= $small) {\n\t\t$small = $soldiers[$s];\n\t\t$pos{'small'} = $s;\n\t}\n}\n\n#print \"Tallest in pos \".$pos{'tall'}.\", smallest in \".$pos{'small'}.\"\\n\";\n\n$swaps = $pos{'tall'} + ($n - $pos{'small'} - 1);\nif($pos{'tall'} > $pos{'small'}) { $swaps--; }\nprint \"$swaps\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $n = <STDIN>;\nmy @soldiers = split(' ', <STDIN>);\nmy $min = 100000;\nmy $min_position = 0;\nmy $max = -1;\nmy $max_position = 0;\n\nfor (my $i = 0; $i < $n; $i++)\n{\n    my $soldier = $soldiers[$i];\n    if ($soldier > $max)\n    {\n        $max = $soldier;\n        $max_position = $i;\n    }\n    if ($soldier <= $min)\n    {\n        $min = $soldier;\n        $min_position = $i;\n    }\n}\n\nmy $result = $max_position + ($n - 1 - $min_position);\nif ($max_position > $ min_position)\n{\n    $result--;\n}\n\nprint $result;"}, {"source_code": "$n=<>;\n@a=split(' ',<>);\n$m=0;\n$c=0;\n$i=0;\n$j=0;\n$n-=1;\nforeach(@a)\n{\nif($_>$m){$m=$_;$i=$c;}\n$c+=1;\n}\n$c=0;\nforeach(@a)\n{\nif($_<=$m){$m=$_;$j=$c;}\n$c+=1;\n}\n$ans=$i+$n-$j;\nif($i>$j){$ans-=1;}\nprint \"$ans\\n\";\n"}], "negative_code": [{"source_code": "\nsub maxInd {\n    (my $max, my $index) = (0, 0);\n    for($i = 0; $i <= $#_; $i++)\n    {\n        if($max < $_[$i]) {\n            $max = $_[$i];\n            $index = $i;\n        }\n    }\n    $index;\n}\n\nsub minInd {\n    (my $min, my $index) = (100, 0);\n    for($i = $#_; $i >= 0; $i--)\n    {\n        if($min > $_[$i]) {\n            $min = $_[$i];\n            $index = $i;\n        }\n    }\n    $index;\n}\n\nchomp($s = <STDIN>);\n@arr = split(/ /, $s);\n$max = &maxInd(@arr);\n$min = &minInd(@arr);\n$answer = $max + abs($#arr - $min);\nprint $max - $min > 0 ? --$answer : $answer;"}], "src_uid": "ef9ff63d225811868e786e800ce49c92"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\t@_ = ();\n\t\n\tfor ( 1 .. $_ ){\n\t\t$_ = <>;\n\t\tchomp;\n\t\t\n\t\tmy $i = 0;\n\t\t\n\t\twhile( length ){\n\t\t\tmy $ch = chop;\n\t\t\t$_[ $i ] += $ch;\n\t\t\t$i ++;\n\t\t\t}\n\t\t}\n\t\n\tprint +(sort { $b <=> $a } @_)[ 0 ];\n\t\n\t}\n", "positive_code": [{"source_code": "$n = <>;\nchomp;\nfor ($i = 0; $i < $n; $i++) {\n\t$code = <>;\n\tchomp;\n\tfor ($j = 0; $j < 7; $j++) {\n\t\tif (substr($code, $j, 1) eq \"1\") {\n\t\t\t$list[$j]++;\n\t\t}\n\t}\n}\n$ans = 0;\nfor ($j = 0; $j < 7; $j++) {\n\tif ($list[$j] > $ans) {\n\t\t$ans = $list[$j];\n\t}\n}\nprint \"$ans\\n\";\n\t\n\n"}], "negative_code": [], "src_uid": "d8743905d56c6c670b6eeeddc7af0e36"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n360%(180-<>)==0 and say \"YES\" or say \"NO\" foreach (1..$n);", "positive_code": [{"source_code": "<>;map{$_=180-$_;print int(360/$_)*$_==360?YES:NO,\"\\n\"}<>"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "my $n = <>;\nmy $t;\nfor(1..$n) {\n    $t = <>;\n    if (360 % (180 - $t) == 0) {\n        print \"YES\\n\";\n    }\n    else {\n        print \"NO\\n\";\n    }\n}\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub is_regular_angle {\n  my ($theta) = @_;\n\n  my $outside = 180 - $theta;\n  360 % $outside == 0;\n}\n\nmy $n = <>;\nfor (1..$n) {\n  my $theta = <>;\n  say is_regular_angle($theta) ? 'YES' : 'NO';\n}\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "#!usr/bin/perl\n#use warnings;\n#use strict;\n#use autodie;\n#use diagnostics;\nuse utf8;\nuse 5.010;\nuse 5.012;\nuse 5.014;\nmy($count,$t,$n);\nchomp($t=<STDIN>);\n$count=0;\nwhile($count != $t)\n{\n\t$count++;\n\tchomp($n=<STDIN>);\n\t$n=180-$n;\n\t$n=360/$n;\n\tif($n=~/\\./)\n\t{\n\t\tsay \"NO\";\n\t}\n\telse\n\t{\n\t\tsay \"YES\";\n\t}\n}\n"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "$n = <>;\nprint 360 % (180 - <>) ? \"NO\\n\" : \"YES\\n\" foreach(1..$n);"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}, {"source_code": "my $num = <>;\nchomp $num;\nfor (1..$num) {\n    my $angle = <>;\n    chomp $angle;\n    (360%(180-$angle)) ? print \"NO\\n\" : print \"YES\\n\";\n}"}, {"source_code": "#!perl -pl\nINIT{<>}$_=360%(180-$_)?'NO':'YES'\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;"}], "src_uid": "9037f487a426ead347baa803955b2c00"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tmy @A;\n\t\n\t( $_ = <>, chomp ), push @A, [ split // ] for 1 .. $n;\n\t\n\tmy $fail = 0;\n\t\n\tfor my $i ( 0 .. $n - 1 ){\n\t\tfor my $j ( 0 .. $m - 1 ){\n\t\t\tnext if $A[$i][$j] eq '*';\n\t\t\t\n\t\t\tmy $bombs = 0;\n\t\t\t\n\t\t\t$i > 0 and $A[$i-1][$j+0] eq '*' and $bombs ++;\n\t\t\t$i > 0 and $j > 0 and $A[$i-1][$j-1] eq '*' and $bombs ++;\n\t\t\t$i > 0 and $j < $m - 1 and $A[$i-1][$j+1] eq '*' and $bombs ++;\n\t\t\t$i < $n - 1 and $A[$i+1][$j+0] eq '*' and $bombs ++;\n\t\t\t$i < $n - 1 and $j > 0 and $A[$i+1][$j-1] eq '*' and $bombs ++;\n\t\t\t$i < $n - 1 and $j < $m - 1 and $A[$i+1][$j+1] eq '*' and $bombs ++;\n\t\t\t$j > 0 and $A[$i+0][$j-1] eq '*' and $bombs ++;\n\t\t\t$j < $m - 1 and $A[$i+0][$j+1] eq '*' and $bombs ++;\n\t\t\t\n\t\t\t$debug and print $bombs;\n\t\t\t\n\t\t\tnext if $A[$i][$j] eq '.' and not $bombs;\n\t\t\t\n\t\t\tif( $bombs ne $A[$i][$j] ){ $fail = 1; }\n\t\t\t}\n\t\t}\n\t\n\tprint $fail ? \"NO\" : \"YES\";\n\t\n\t$debug and print '-' x 15;\n\t}", "positive_code": [{"source_code": "( $n, $m ) = split ' ', <>;\n\n$_ = join \"\\n\", map { chomp; \".$_.\" } 0 x $m, <>, 0 x $m;\n\ny/./0/;\n\n/\n(?=\n\t(\\S{3})\n\t.{$m}\n\t(\\S)(\\d)(\\S)\n\t.{$m}\n\t(\\S{3})\n\t(?{\n\t\t$f += \"$3\" != ( () = \"$1$2$4$5\" =~ m!\\*!g );\n\t})\n\t(?!)\n)\n/xs;\n\nprint $f ? \"NO\" : \"YES\""}, {"source_code": "( $n, $m ) = split ' ', <>;\n\n$_ = join \"\\n\",\n\t0 x ( $m + 2 ), \n\t( map 0 . <> =~ s/\\n//r . 0, 1 .. $n ), \n\t0 x ( $m + 2 );\n\ny/./0/;\n\n/\n(?=\n\t(\\S{3})\n\t.{$m}\n\t(\\S)(\\d)(\\S)\n\t.{$m}\n\t(\\S{3})\n\t(?{\n\t\t$f += \"$3\" != ( () = \"$1$2$4$5\" =~ m!\\*!g );\n\t})\n\t(?!)\n)\n/xs;\n\nprint $f ? \"NO\" : \"YES\""}, {"source_code": "( $n, $m ) = split ' ', <>;\n\n$_ = join \"\\n\", map { chomp; \".$_.\" } 0 x $m, <>, 0 x $m;\n\ny/./0/;\n\n/\n(?=\n\t(\\S{3})\n\t.{$m}\n\t(\\S)(\\d)(\\S)\n\t.{$m}\n\t(\\S{3})\n\t(?{\n\t\t$f += \"$3\" != ( () = \"$1$2$4$5\" =~ m!\\*!g );\n\t})\n\t(?!)\n)\n/xs;\n\nprint $f ? \"NO\" : \"YES\""}, {"source_code": "use warnings;\nuse strict;\nuse constant NL => qq/\\n/;\n\n\n\nmy ( $n, $m ) = (<STDIN> =~ m/(\\d+)\\s(\\d+)/);\nmy @arr = ();\nfor ( 1 .. $n ) {\n    my $line = <STDIN>;\n    push @arr, [ split qq//, $line ] }\nmy $is_valid = 1;\n\nAA: for my $i ( 0 .. ($n-1) ) {\n    AB: for my $j ( 0 .. ($m-1) ) {\n        if ( $arr [ $i ][ $j ] eq '.' ) {\n            AC: for my $one ( ($i-1) .. ($i+1) ) {\n                AD: for my $two ( ($j-1) .. ($j+1) ) {\n                    if ( $one eq $i and $two eq $j ) { next AD }\n                    if ( $one >= 0 and $two >= 0 and $one < $n and $two < $m and \n                         ($arr [ $one ][ $two ] eq '*') ) {\n                        $is_valid = 0;\n                        last AA }}}}\n        elsif ( $arr [ $i ][ $j ] ne '*' ) {\n            my $sum = 0;\n            AE: for my $one ( ($i-1) .. ($i+1) ) {\n                AF: for my $two ( ($j-1) .. ($j+1) ) {\n                    if ( $one eq $i and $two eq $j ) { next AF }\n                    if ( $one >= 0 and $two >= 0 and\n                         $one < $n and $two < $m and \n                         ( $arr [ $one ][ $two ] eq '*') ) { $sum += 1 } }}\n            if ( $sum != $arr [ $i ][ $j ] ) {\n                $is_valid = 0;\n                last AA }}\n    }\n}\n\nprint qq/YES\\n/ if $is_valid;\nprint qq/NO\\n/ if not $is_valid;\n"}], "negative_code": [], "src_uid": "0d586ba7d304902caaeb7cd9e6917cd6"}
{"source_code": "sub get { split \" \", <> }\n($n, $m) = get; $_ = <>; $c1 = () = /-/g; $c2 = () = /1/g; $c2 -= $c1;\nfor (1..$m) {\n\t($l, $r) = get; $c = $r - $l + 1;\n\tif ($c & 1) {\n\t\t$r = 0;\n\t} else {\n\t\t$c /= 2;\n\t\t$r = ($c <= $c1 && $c <= $c2? 1: 0);\n\t}\n\tprint $r, \"\\n\"\n}", "positive_code": [{"source_code": "while (<>){\n    / /;\n    @_=split/ /,<>;\n    $i=0;\n    for (@_){$_==1 and $i++}\n    $i = $`-$i<$i?$`-$i:$i;\n #   print \" $i\\n\";\n    \n    for (1..$'){\n        <>=~/ /;\n        print ((abs($`-$')) %2==1 && (abs($`-$'))<=$i*2?1:0);\n        print\"\\n\";\n        }\n    }"}, {"source_code": "sub get { split \" \", <> }\n($n, $m) = get; $_ = <>; $c1 = y/-/-/; $c2 = y/1/1/; $c2 -= $c1;\nfor (1..$m) {\n\t($l, $r) = get; $c = $r - $l + 1;\n\tif ($c & 1) {\n\t\t$r = 0;\n\t} else {\n\t\t$c /= 2;\n\t\t$r = ($c <= $c1 && $c <= $c2? 1: 0);\n\t}\n\tprint $r, \"\\n\"\n}"}, {"source_code": "my ($n, $m) = split / /, <>;\nmy @a = split / /, <>;\nforeach (@a) {$one++ if $_==1;}\n$pair = ($one < $n-$one) ? $one : $n-$one;\nwhile (<>) {\n\tchomp;\n\t($l, $r) = split / /;\n\tif (($r-$l) & 1) {\n\t\tif (($r-$l+1) > $pair*2) {\n\t\t\tprint \"0\\n\";\n\t\t} else {\n\t\t\tprint \"1\\n\";\n\t\t}\n\t} else {\n\t\tprint \"0\\n\";\n\t}\n}"}, {"source_code": "($n, $q) = split /\\s+/, <STDIN>;\n@ints = split /\\s+/, <STDIN>;\n$m = 0;\n$p = 0;\nmap { $m++ if $_ == -1; $p++ if $_ == 1; } @ints;\n\n#print \"Got $m negatives and $p positives\\n\";\nwhile($q--) {\n\t($l, $r) = split /\\s+/, <STDIN>;\n\tif ($l == $r){ print \"0\\n\"; next; };\n#\tif($l > $m){ print \"0\\n\"; next; };\n#\tif($r < $m){ print \"0\\n\"; next; };\n\t$d = 1 + $r - $l;\n\tif($d % 2 == 1){ print \"0\\n\"; next; };\n#\tprint \"l=$l, r=$r, Want \".($d/2).\" of both\\n\";\n\tif($d/2 <= $m && $d/2 <= $p){ print \"1\\n\"; next; };\n\tprint \"0\\n\";\n}"}], "negative_code": [{"source_code": "($n, $q) = split /\\s+/, <STDIN>;\n@ints = split /\\s+/, <STDIN>;\n$m = 0;\n$p = 0;\nmap { $m++ if $_ == -1; $p++ if $_ == 1; } @ints;\n\n#print \"Got $m negatives and $p positives\\n\";\nwhile($q--) {\n\t($l, $r) = split /\\s+/, <STDIN>;\n\tif ($l == $r){ print \"0\\n\"; next; };\n\tif($l > $m){ print \"0\\n\"; next; };\n\tif($r < $m){ print \"0\\n\"; next; };\n\t$d = 1 + $r - $l;\n\tif($d % 2 == 1){ print \"0\\n\"; next; };\n\tif($d/2 <= $m && $d/2 <= $p){ print \"1\\n\"; next; };\n\tprint \"0\\n\";\n}"}, {"source_code": "#!/usr/bin/perl\n\n($n,$m)=split/ /,<>;\n$_=<>;\ns/-/++$x/ge;\nfor(1..$m){\n    <>=~/ /;\n    $d=$`-$'+1;\n    printf \"%d\\n\", $d%2 || $d>$x*2?0:1;\n    }"}, {"source_code": "#!/usr/bin/perl\n\n($n,$m)=split/ /,<>;\n$_=<>;\ns/-/++$x/ge;\n$n-$x<$x and $x=$n-$x;\nfor(1..$m){\n    <>=~/ /;\n    $d=$`-$'+1;\n    printf \"%d\\n\", $d%2 || $d>$x*2?0:1;\n    }"}, {"source_code": "while (<>){\n    / /;\n    @_=split/ /,<>;\n    $i=0;\n    for (@_){$_==1 and $i++}\n    $i = $`>$i?$`:$i;\n    \n    for (1..$'){\n        <>=~/ /;\n        print ((abs($`-$')) %2==0 && (abs($`-$'))<=$i?0:1);\n        print\"\\n\";\n        }\n    }"}], "src_uid": "deeb49969ac4bc4f1c7d76b89ac1402f"}
{"source_code": "use strict;\nuse warnings;\n\nuse Data::Dumper;\n$,=\" \";\nmy ($n,$c)=split / /,<>;\nchomp($n,$c);\nmy $sum=1;\nmy @t=split  / /,<>;\nchomp(@t);\nmy $a=shift @t;\nfor(@t)\n{\nif($_-$a<=$c)\n{\n$sum++ ;\n}\nelse\n{\n  $sum=1;\n}\n$a=$_;\n}\n\nprint $sum . \"\\n\";\n", "positive_code": [{"source_code": "@line = split(/\\s/, <>);\n$n = $line[0];\n$c = $line[1];\n$ans = 0;\n$last = 0;\nforeach $i (split(/\\s/, <>)) {\n    if ($i - $last > $c) {\n        $ans = 0;\n    }\n    $ans++;\n    $last = $i;\n}\nprint $ans, \"\\n\";\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nmy ($n, $c) = split ' ', <>;\nmy @times = split ' ', <>;\nmy $last = 0;\nmy $count = 0;\n\nfor my $time (@times) {\n  if ($time - $last > $c) {\n    $count = 1;\n  } else {\n    $count++;\n  }\n\n  $last = $time;\n}\n\nsay $count;\n"}, {"source_code": "$\\ = $/; ($_, $c) = split ' ', <>; @t = reverse split ' ', <>;\n$p = shift @t; $n = 1;\nfor (@t) {\n    $p - $_ > $c && last;\n    $n++; $p = $_;\n}\nprint $n;\n"}, {"source_code": "$\\ = $/; ($_, $c) = split ' ', <>; @t = split ' ', <>;\n$p = pop @t;\n$n = 1;\nfor (reverse @t) {\n    last if ($p - $_ > $c);\n    $n++; $p = $_;\n}\nprint $n;\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $c) = split;\n\t@_ = reverse split ' ', <>;\n\t$last = $_[0];\n\t$i = 0;\n\tfor (@_){\n\t\t$last - $_ > $c and last;\n\t\t$last = $_;\n\t\t$i ++;\n\t\t}\n\t\n\tprint $i;\n\t}"}], "negative_code": [{"source_code": "($n, $c) = split ' ', <>;\n\n$_ = ' ' . <>;\ns/.*(\\b\\d+) (\\d+\\b)(??{ $2 - $1 <= $c })//;\ns/\\d//g;\n\nprint length"}], "src_uid": "fb58bc3be4a7a78bdc001298d35c6b21"}
{"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]", "positive_code": [{"source_code": "# open STDIN,\"<\",\"a.in\" or die $!;\nmy $a1 = ReadLine();\nmy $a2 = ReadLine();\n$a1 =~ s/^0+//;\n$a2 =~ s/^0+//;\n\n# print \"$a1 $a2\";\nmy ($len1,$len2) = (length($a1),length($a2));\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}\n\nprint \"\\n\";\n\nsub ReadLine {\n    my $line = <STDIN>;\n    chop($line);\n    my $lll = length($line);\n    while(not $lll) {\n        $line = <STDIN>;\n        chop($line);\n        $lll = length($line);\n    }\n    return $line;\n}"}, {"source_code": "#open STDIN,\"<\",\"a.in\" or die $!;\nmy $a1 = ReadLine();\nmy $a2 = ReadLine();\n$a1 =~ s/^0+//; # 去前导零\n$a2 =~ s/^0+//;\n\n# print \"$a1 $a2\";\nmy ($len1,$len2) = (length($a1),length($a2));\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}\n\nprint \"\\n\";\n\nsub ReadLine { # 读一行非空的字符串\n    chop(my $line = <STDIN>);\n    while(not length($line)) {\n        chop($line = <STDIN>);\n    }\n    return $line;\n}"}, {"source_code": "#open STDIN,\"<\",\"a.in\" or die $!;\nmy $a1 = ReadLine();\nmy $a2 = ReadLine();\n$a1 =~ s/^0+//;\n$a2 =~ s/^0+//;\n\n# print \"$a1 $a2\";\nmy ($len1,$len2) = (length($a1),length($a2));\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}\n\nprint \"\\n\";\n\nsub ReadLine {\n    my $line = <STDIN>;\n    chop($line);\n    while(not length($line)) {\n        chop($line = <STDIN>);\n    }\n    return $line;\n}"}, {"source_code": "$ch1=<>;\nchomp $ch1;\n$ch2=<>;\nchomp$ch2;\n\n$ch1=~m/^(0*)./;\n\n$ll1=length$1; \n$ch2=~m/^(0*)./;\n\n$ll2=length$1; \n$l1=length$ch1;\n$l2=length$ch2;\n\nif($l1-$ll1>$l2-$ll2){\nprint \">\";\n}\nelsif($l1-$ll1<$l2-$ll2){\nprint \"<\";\n}\n\n \nelsif(substr($ch1,$ll1) gt substr($ch2,$ll2)){\nprint \">\";\n}\nelsif(substr($ch1,$ll1) lt substr($ch2,$ll2)){\nprint \"<\";\n}\nelse{\nprint \"=\";\n}"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]\n"}, {"source_code": "$a = <>;\n$a =~ s/^0+//;\n$b = <>;\n$b =~ s/^0+//;\n$s = length( $a ) <=> length($b);\nif ( $s ) {\n\tresult( $s );\n}\nelse {\n\t@ma = split //,$a;\n\t@mb = split //,$b;\n\n\tfor $i (0..length($a)) {\n\t   $s = $ma[$i] <=> $mb[$i];\n\t   if ( $s ) {\n\t   \t\tresult( $s );\n\t   }\n\t}\n\tresult( 0 );\n}\n\nsub result {\n    my $s = shift;\n\tif( $s > 0 ) {\n\t\tprint \">\";\n\t}\n\telsif ( $s < 0 ) {\n\t\tprint \"<\";\n\t}\n\telse {\n\t\tprint \"=\";\n\t}\t\n\texit;\n}"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]\n"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]"}, {"source_code": "($A, $B) = map { chomp; s/^0+//r } <>;\n\n$W = 0;\n\nprint qw(= > <)[ length $A <=> length $B || do { \n\t\t\tfor (1 .. length $A) { $W = chop $A <=> chop $B || $W }\n\t\t\t$W\n\t\t} \n\t]"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]\n"}, {"source_code": "$a=<>; chomp($a);\n$b=<>; chomp($b);\n$a=~/^(0*)./; $la=length($a)-length($1); \n$b=~/^(0*)./; $lb=length($b)-length($1);\nif ($la>$lb) {\n\t$r=1;\n} elsif ($la<$lb) {\n\t$r=-1;\n} else {\n\t$r=substr($a,-$la) cmp substr($b,-$lb);\n}\nprint [\"<\",\"=\",\">\"]->[$r+1];\n"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]\n"}, {"source_code": "print qw(= > <)[ eval join 'cmp', map { sprintf \"'%01000001s'\", $_  } <> ]"}], "negative_code": [{"source_code": "$a=<>; chomp($a);\n$b=<>; chomp($b);\n$a=~/^0*/; $la=length($a)-length($&); \n$b=~/^0*/; $lb=length($b)-length($&);\nif ($la>$lb) {\n\t$r=1;\n} elsif ($la<$lb) {\n\t$r=-1;\n} else {\n\t$r=substr($a,-$la) cmp substr($b,-$lb);\n}\nprint [\"<\",\"=\",\">\"]->[$r+1];\n"}, {"source_code": "my $a1 = <STDIN>;\nmy $a2 = <STDIN>;\n$a1 =~ s/0+//;\n$a2 =~ s/0+//;\nmy ($len1,$len2) = (length($a1),length($a2));\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}"}, {"source_code": "#open STDIN,\"<\",\"a.in\" or die $!;\nmy $a1 = <STDIN>;\nmy $a2 = <STDIN>;\n$a1 =~ s/^0+//;\n$a2 =~ s/^0+//;\n\nmy ($len1,$len2) = (length($a1),length($a2));\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}"}, {"source_code": "my $a1 = <STDIN>;\nmy $a2 = <STDIN>;\nif($a1 == $a2) {\n    print \"=\"; \n}\nelsif($a1 > $a2) {\n    print \">\";\n}\nelse {\n    print \"<\";\n}"}, {"source_code": "my $a1 = <STDIN>;\nmy $a2 = <STDIN>;\n$a1 =~ s/^0+//;\n$a2 =~ s/^0+//;\nmy ($len1,$len2) = (length($a1),length($a2));\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}"}, {"source_code": "#open STDIN,\"<\",\"a.in\" or die $!;\nmy $a1 = <STDIN>;\nmy $a2 = <STDIN>;\n$a1 =~ s/^0+//;\n$a2 =~ s/^0+//;\n\nmy ($len1,$len2) = (length($a1),length($a2));\nprint \"$len1 $len2\" if ($a2 eq \"8\");\nif($len1 eq $len2) {\n    if($a1 eq $a2) {print \"=\";}\n    elsif($a1 ge $a2) {print \">\";}\n    else {print \"<\"};\n}\nelsif($len1 ge $len2) {print \">\";}\nelse {print \"<\";}"}, {"source_code": "$ch1=<>;\nchomp $ch1;\n$ch2=<>;\nchomp$ch2;\n$num1=int($ch1);\n$num2=int($ch2);\nif($num2==$num1){\nprint \"=\";\n}\nelsif ($num1>$num2){\nprint\">\";\n}\nelse{\nprint \"<\";\n}"}, {"source_code": "$ch1=<>;\nchomp $ch1;\n$ch2=<>;\nchomp$ch2;\n\n$ch1=~m/^(0*)./;\n$l1=length$1; \n$ch2=~m/^(0*)./;\n$l2=length$1;\n \nif(substr($ch1,$l1) gt substr($ch2,$l2)){\nprint \">\";\n}\nelsif(substr($ch1,$l1) lt substr($ch2,$l2)){\nprint \"<\";\n}\nelse{\nprint \"=\";\n}"}, {"source_code": "print qw(= > <)[<><=><>]"}, {"source_code": "use bigint;\n\nprint qw(= > <)[ eval join '<=>', map { s/^0+// ; 0 + $_ } <> ]"}, {"source_code": "use bigint;\nprint qw(= > <)[<><=><>]"}], "src_uid": "fd63aeefba89bef7d16212a0d9e756cd"}
{"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z\n", "positive_code": [{"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z\n"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z\n"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z\n"}, {"source_code": "@_ = split ' ', (<>, <>);\n\nprint( (grep !$_, @_) ? \n\t0\n: \n\t( (join '', grep !/^10*$/, @_) || 1 ) \n\t. 0 x eval join '+', map ~- length, grep /^10*$/, @_ \n)"}, {"source_code": "<>;\n\n@_ = split ' ', <>;\n\nprint( (grep !$_,@_) ? \n\t0\n: \n\tdo { \n\t\t( (join '', grep !/^10*$/, @_) || 1 ) \n\t\t. 0 x eval join '+', map { -1 + length } grep /^10*$/, @_ \n\t}\n)"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/\\b10*\\b/ '' x ($z +=~- length $&) /ger =~ s/ //gr || 1) . 0 x $z"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z"}, {"source_code": "$_ = (<>,<>), chomp;\n\nprint /\\b0\\b/ ? 0 : ( s/ ?\\b1(0*)\\b ?/ $z .= $1, '' /ger || 1) . $z\n"}], "negative_code": [{"source_code": "@_ = split ' ', (<>, <>);\n\nprint $x = (join '', grep !/^10*$/, @_) || 1,\n\t0 x (eval join '+', map ~- length, grep /^10*$/, @_) x!! $x"}], "src_uid": "9b1b082319d045cf0ec6d124f97a8184"}
{"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n", "positive_code": [{"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}, {"source_code": "<>;$_=<>;@a=split ' ';$r=0;\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $r = $x if $x > $r;\n}\nprint $r;\n\n"}], "negative_code": [{"source_code": "<>;$_=<>;@a=split ' ';\nwhile (<>) {\n  ($u,$v,$c) = split ' ';\n  $x = ($a[$u-1]+$a[$v-1])/$c;\n  $res = $x if $x > $res;\n}\nprint $res;\n"}], "src_uid": "ba4304e79d85d13c12233bcbcce6d0a6"}
{"source_code": "($n, $x) = split \" \", <>; $y=0;\nfor (<>) {\n\ts/ //;\n\tif ($x + $_ < 0) {\n\t\t$y++;\n\t} else {\n\t\t$x += $_;\t\n\t}\n}\nprint \"$x $y\"", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\t$g = 0;\n\tfor (1 .. $n){\n\t\t($i, $u) = split ' ', <>;\n\t\tif ($i eq '+'){\n\t\t\t$m += $u;\n\t\t\t}\n\t\telse {\n\t\t\tif( $u > $m ){\n\t\t\t\t$g++;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$m -= $u;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint \"$m $g\";\n\t}"}, {"source_code": "for (<>){\n\t\n\t/\\d+$/;\n\t$u = $&;\n\t\n\t$m +=!/-/?\n\t\t$u\n\t:\n\t\t$u > $m ?\n\t\t\t$g ++ * 0\n\t\t:\n\t\t\t- $u\n\t}\n\t\nprint $m, ' ', 0 + $g"}], "negative_code": [], "src_uid": "0a9ee8cbfa9888caef39b024563b7dcd"}
{"source_code": "<>;\n$A = <>;\n\nfor( <> ){\n\t( $l, $r, $c, $d ) = split;\n\t( substr $A, $l - 1, $r - $l + 1 ) =~ s/$c/$d/g;\n\t}\n\nprint $A", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t$_ = <>, chomp;\n\tmy @A = map [ split ' ', <> ], 1 .. $m;\n\t\n\tfor my $i ( @A ){\n\t\t( substr $_, $i->[ 0 ] - 1, $i->[ 1 ] - $i->[ 0 ] + 1 ) =~ s/$i->[2]/$i->[3]/g;\n\t\t}\n\t\n\tprint;\n\t}"}], "negative_code": [], "src_uid": "3f97dc063286a7af4838b7cd1c01df69"}
{"source_code": "map { $h{$_}++ } <>=~/(?=((?:\\d\\d-){2}201[3-5]))/g;\nfor (keys %h){\n\t($d,$m,$y)=split/-/;\n\t($d > 0 and ($d <= 31 and $m =~ /^(0[13578]|1[02])$/\n\t\t\t\tor\n\t\t\t\t$d <= 30 and $m =~ /^(0[469]|11)$/\n\t\t\t\tor\n\t\t\t\t$d <= 28 and $m =~ /^02$/\n\t\t\t\t)\n\t)\n\tor delete $h{$_}\n\t}\n\n$_ > $max and $max = $_ for values %h;\n$h{$_} == $max and print for keys %h;", "positive_code": [{"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n#print;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\n#print\" @_\\n\";\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1>0 and $1<=31 and ($2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12)){\npush @a,$_;\n}\nif($1>0 and $1<=30 and ($2==4 or $2==6 or $2==9 or $2==11)){\npush @a,$_;\n}\nif($1>0 and $1<=28 and $2==2){\npush @a,$_;\n}\n}\n#print\"  @a\\n\";\n}\nfor(@a){\ns/-//;\ns/-201//;\n#print;\n$m[$_]++;\n}\n# print \"@m\\n\";\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n#print \"  $max\\n\";\nfor$i(0..@m-1){\n$max==$m[$i] and $_=$i;\n}\n#$_=$a[$max];\n#print;\nlength==4 and s/^/0/;\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}], "negative_code": [{"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n#print;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\n#print\" @_\\n\";\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1<=31 and ($2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12)){\npush @a,$_;\n}\nif($1<=30 and ($2==4 or $2==6 or $2==9 or $2==11)){\npush @a,$_;\n}\nif($1<=28 and $2==2){\npush @a,$_;\n}\n}\n#print\"  @a\\n\";\n}\nfor(@a){\ns/-//;\ns/-201//;\n#print;\n$m[$_]++;\n}\n# print \"@m\\n\";\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n#print \"  $max\\n\";\nfor$i(0..@m-1){\n$max==$m[$i] and $_=$i;\n}\n#$_=$a[$max];\n#print;\nlength==4 and s/^/0/;\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}, {"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1<=31 and $2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12){\npush @a,$_;\n}\nif($1<=30 and $2==4 or $2==6 or $2==9 or $2==11){\npush @a,$_;\n}\nif($1<=28 and $2==2){\npush @a,$_;\n}\n}\n}\nfor(@a){\ns/-//;\ns/-201//;\n$m[$_]++;\n}\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n$_=$a[$max];\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}, {"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1<=31 and $2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12){\npush @a,$_;\n}\nif($1<=30 and $2==4 or $2==6 or $2==9 or $2==11){\npush @a,$_;\n}\nif($1<=28 and $2==2){\npush @a,$_;\n}\n}\n}\nfor(@a){\ns/-//;\ns/-201//;\n$m[$_]++;\n}\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n$_=$m[$max];\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}, {"source_code": "map { $h{$_}++ } <>=~/(?=((?:\\d\\d-){2}201[3-5]))/g;\nfor (keys %h){\n\t($d,$m,$y)=split/-/;\n\t($d > 0 and ($d <= 31 and $m =~ /^([13578]|1[02])$/\n\t\t\t\tor\n\t\t\t\t$d <= 30 and $m =~ /^([469]|11)$/\n\t\t\t\tor\n\t\t\t\t$d <= 28 and $m =~ /^2$/\n\t\t\t\t)\n\t)\n\tor delete $h{$_}\n\t}\n\n$_ > $max and $max = $_ for values %h;\n$h{$_} == $max and print for keys %h;"}, {"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n#print;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\n#print\" @_\\n\";\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1<=31 and $2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12){\npush @a,$_;\n}\nif($1<=30 and $2==4 or $2==6 or $2==9 or $2==11){\npush @a,$_;\n}\nif($1<=28 and $2==2){\npush @a,$_;\n}\n}\n#print\"  @a\\n\";\n}\nfor(@a){\ns/-//;\ns/-201//;\n#print;\n$m[$_]++;\n}\n# print \"@m\\n\";\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n#print \"  $max\\n\";\nfor$i(0..@m-1){\n$max==$m[$i] and $_=$i;\n}\n#$_=$a[$max];\n#print;\nlength==4 and s/^/0/;\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}, {"source_code": "$_=<>;\ns/(\\d{3})-/$1$1-/g;\n#print;\n@_=/\\d\\d-\\d\\d-\\d\\d\\d\\d/g;\n#print\" @_\\n\";\nfor (@_){\nif (/201[345]/) {\n/^(\\d\\d)-(\\d\\d)/;\nif($1<=31 and $2==1 or $2==3 or $2==5 or $2==7 or $2==8 or $2==10 or $2==12){\npush @a,$_;\n}\nif($1<=30 and $2==4 or $2==6 or $2==9 or $2==11){\npush @a,$_;\n}\nif($1<=28 and $2==2){\npush @a,$_;\n}\n}\n#print\"  @a\\n\";\n}\nfor(@a){\ns/-//;\ns/-201//;\n#print;\n$m[$_]++;\n}\n# print \"@m\\n\";\n$max=0;\nfor(@m){\n$max<$_ and $max=$_;\n}\n#print \"  $max\\n\";\nfor$i(0..@m-1){\n$max==$m[$i] and $_=$i;\n}\n#$_=$a[$max];\n#print;\ns/\\d\\d/$&-/;\ns/-\\d\\d/$&-201/;\nprint"}, {"source_code": "map { $h{$_}++ } <>=~/(?=((?:\\d\\d-){2}\\d{4}))/g;\n$_ > $max and $max = $_ for values %h;\n$h{$_} == $max and print for keys %h"}], "src_uid": "dd7fd84f7915ad57b0e21f416e2a3ea0"}
{"source_code": "\nsub RC_to_CR {\n\tmy $rc = shift;\n\t$rc =~ /^R(\\d+)C(\\d+)/;\n\tmy $row = $1;\n\tmy $col = $2;\n\tmy $ret = '';\n#\tmy $p = 1;\n#\tprint \"col = $col\\n\";\n\twhile($col > 26) {\n\t\tmy $tmp = int($col / 26);\n\t\tmy $v = $col - $tmp * 26;\n#\t\tprint \"col = $col, p = $p, tmp = $tmp, v = $v\\n\";\n\t\tif($v==0) { $v = 26; $col -= 26; }\n\t\t$ret .= chr(64+$v);\n\t\t$col = int($col/26);\n#\t\t$p++;\n\t}\n\t$ret .= chr(64+$col);\n\t$ret = scalar reverse $ret;\n\t$ret .= $row;\n\treturn $ret;\n}\n\nsub CR_to_RC {\n\tmy $cr = shift;\n\t$cr =~ /([A-Z]+)(\\d+)/;\n\tmy $col = $1;\n\tmy $row = $2;\n\tmy $ret = 'R'.$row.\"C\";\n\tmy $l = length($col)-1;\n\tmy $c = 0;\n\tmy $p = $l;\n\tforeach my $ltr (split //, $col) {\n\t\tmy $v = (ord($ltr)-64);\n\t\t$c += ($v * 26**$p);\n\t\t$p--;\n\t}\n\t$ret .= $c;\n\treturn $ret;\n}\n\nmy $num = <STDIN>;\nchomp($num);\nwhile($num-- > 0) {\n\tchomp($row = <STDIN>);\n\tif($row =~ /^R\\d+C\\d+/) {\n\t\tprint RC_to_CR($row).\"\\n\";\n\t} else {\n\t\tprint CR_to_RC($row).\"\\n\";\n\t}\n}\n", "positive_code": [{"source_code": "my $num = <STDIN>;\nfor (1..$num) {\n    my $input = <STDIN>;\n    chomp $input;\n    if ($input =~ /R(\\d+)C(\\d+)/) {\n        my ($row, $col) = ($1, $2);\n        my @col;\n        while ($col > 26) {\n            my $r = $col % 26;\n            $r = 26 if !$r;\n            push @col, $r;\n            $col = int (($col-$r)/26);\n        }\n        push @col, $col;\n        @col = reverse @col;\n        my $str;\n        $str .= ('A'..'Z')[$_-1] foreach @col;\n        $str .= $row;\n        print $str, \"\\n\";\n    } else {\n        $input =~ /([A-Z]+)(\\d+)/;\n        my ($col_str, $row) = ($1, $2);\n        my $col = 0;\n        foreach (map { ord($_) - 64 } split //, $col_str) {\n            $col *= 26;\n            $col += $_;\n        }\n        print \"R\", $row, \"C\", $col, \"\\n\";\n    }\n}"}, {"source_code": "#!/usr/local/bin/perl\n$n = <>;\nfor ( 1 .. $n ) {\n    $line = <>;\n\n    if ( $line =~ /(\\D+)(\\d+)(\\D+)(\\d+)/ ) {\n        print makeNormal($2,$4).\"\\n\";\n\n    }\n    elsif($line =~ /(\\D+)(\\d+)/ ){      \n        print makeRC($1 , $2).\"\\n\";\n    }\n\n}\n    sub makeNormal {\n        use integer;\n        my $row = $_[0];\n        my $col = $_[1];\n        my @alph = (A..Z);\n        \n        $result = $row;\n        do{\n            my $r, $letter;\n            $col -= 1;\n            $r = $col % 26;\n            $col = $col / 26;           \n            $result = @alph[$r].$result;\n        } while ($col);\n        return $result;\n    }\n\n    sub makeRC {\n        use integer;\n        my $row = $_[1];\n        my $col = $_[0];\n        my $resCol = 0;\n        my $n = 1;\n        my $A = ord(\"A\");\n        foreach $ch (reverse split (// , $col)){\n            $resCol+= (ord($ch) - $A +1) * $n;\n            $n *= 26;\n        }\n        return \"R\".$row.\"C\".$resCol;\n        \n        \n    }\n"}, {"source_code": "use strict;\nuse warnings;\nuse utf8;\n\nmy $n=<STDIN>;\nchomp($n);\n\nour @dic=(\"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\");\nour %alphabet = do { my $i; map { $_ => ++$i } qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) };\n\nfor(my $i=0; $i<$n; $i++){\n\tmy $stdin=<STDIN>;\n\tchomp($stdin);\n\tprint solveB($stdin).\"\\n\";\n}\n\nsub solveB{\n\tmy $s=$_[0];\n\tif($s=~/^R(\\d+)C(\\d+)$/){\n\t\treturn solve1($2,\"\").$1;\n\t}\n\tif($s=~/^([A-Z]+)(\\d+)$/){\n\t\tmy $ans=0;\n\t\tfor(my $i=0; $i<length($1); $i++){\n\t\t\t$ans+=$alphabet{substr($1,$i,1)}*(26**(length($1)-$i-1));\n\t\t}\n\t\treturn \"R\".$2.\"C\".$ans;\n\t}\n}\n\nsub solve1{\n\treturn\t$_[1]\tif($_[0]==0);\n\tmy $a=$_[0]-($_[0]%26==0?26:0);\n\treturn &solve1(int($a/26), $dic[$a%26].$_[1]);\n}\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\nuse integer;\n\nsub ntos {\n    my $n = shift;\n    my @arr = ('A' .. 'Z');\n    my $s = '';\n    while ($n > 0) {\n\t$s = @arr[$n % 26 - 1] . $s;\n\tif (not $n % 26) { $n--; }\n\t$n /= 26;\n    }\n    return $s;\n}\n\nsub ston {\n    my $s = shift;\n    my %hash;\n    @hash{('A'..'Z')} = (1 .. 26);\n    my $n = 0;\n    for (split //, $s) {\n\t$n *= 26;\n\t$n += $hash{$_};\n    }\n    return $n;\n}\n\nsub main {\n    my $n = int <>;\n    for (1 .. $n) {\n\tmy $s = <>;\n\tif ($s =~ /^R([\\d]+)C([\\d]+)$/) {\n\t    print ntos($2) . \"$1\\n\";\n\t} elsif ($s =~ /^([\\D]*)([\\d]*)$/) {\n\t    print \"R$2C\" . (ston $1) . \"\\n\";\n\t} else {\n\t    exit(-1);\n\t}\n    }\n}\n\nmain();\n"}, {"source_code": "\n#!/usr/bin/perl\n\nmain();\n\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /(\\D+)(\\d+)(\\D+)(\\d+)/) {\n            print convertToSymbols($4).\"$2\\n\";\n            next;\n        }\n        if ($line =~ /(\\D+)(\\d+)/) {\n            print \"R\".$2.\"C\".convertFromSymbols($1).\"\\n\";\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $tmp = $cur % 26;\n        $tmp = 26 if ($tmp==0);\n        my $c = chr(ord(\"A\") + $tmp - 1);\n        $result = $result.$c;\n        $cur = ($cur - $tmp) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "\nuse strict;\nuse warnings;\nuse integer;\n\nmy @arr = ('A' .. 'Z');\nsub ntos {\n    my $n = shift;\n    my $s = '';\n    while ($n > 0) {\n    $s = @arr[$n % 26 - 1] . $s;\n    $n-- unless ($n % 26);\n    $n /= 26;\n    }\n    return $s;\n}\n\nsub ston {\n    my $n = 0;\n    $n = $n * 26 + ord($_) - 64 for (split //, shift);\n    return $n;\n}\n\nmy $n = int <>;\nfor (1 .. $n) {\n    my $s = <>;\n    if ($s =~ /^R([\\d]+)C([\\d]+)$/) {\n        print ntos($2) . \"$1\\n\";\n    } else {\n        $s =~ /^([\\D]*)([\\d]*)$/;\n        print \"R$2C\" . (ston $1) . \"\\n\";\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n$n = <>;\nwhile ($n--) {\n  $_ = <>;\n  chomp;\n  if ($_=~/^R(\\d+)C(\\d+)$/i) {\n    $row = $1*1;\n    $col = $2*1;\n    $acol = \"\";\n    while ($col>0) {\n      $col--;\n      $acol = chr(65+($col%26)) . $acol;\n      $col = int($col/26);\n    }\n    print \"$acol$row$/\";\n  }\n  elsif ($_=~/^([A-Z]+)(\\d+)$/i) {\n    $acol = $1;\n    $row = $2*1;\n    $col = 0;\n    $i = 0;\n    while ($i<length($acol)) {\n      $col = $col * 26 + (ord(substr($acol,$i,1))-65+1);\n      $i++;\n    }\n    print \"R$row\".\"C$col$/\";\n  }\n  else {\n    print \"Error$/\";\n  }\n}\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t>26){return ((($t%26==0)?ntl(int($t/26-1),$ln):ntl(int($t/26),$ln)).$$ln{$t%26});}\n    else{return $$ln{$t%26};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=($2>26)?ntl($2,$g):$ln{$2%26};\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "my $n = <>;\nwhile( <> ) {\n    if ( /^R([0-9]+)C([0-9]+)/ ) { \n        print convert_to_26($2) . $1 . \"\\n\";\n    }\n    elsif ( /^([A-Z]+)([0-9]+)/ ) {\n       print \"R$2C\" . convert_to_10( $1 ) . \"\\n\"; \n    }\n\n    $n--;\n    last if ( !$n );\n}\n\nsub convert_to_26 {\n    my $n = shift;\n    return chr( ord('A') + $n - 1 ) if ( $n <= 26 );\n\n    my $rem = $n % 26;\n    my $div = int ($n / 26 );\n    if ( !$rem ) {\n        $rem = 26;\n        $div--;\n    }\n    return convert_to_26($div) . chr ( ord('A') + $rem - 1 );\n}\n\nsub convert_to_10 {\n    my @n = split '', shift;\n    my $ret = 0;\n    for ( my $i=0; $i <= $#n; $i++ ) {\n        $ret += ( ord( $n[$i] ) - ord('A') + 1 ) * ( 26 ** ( $#n - $i ) );\n    }\n\n    return $ret;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n\n%num2char = map { ($_ + 1) => chr(ord('A') + $_) } (0..25) ;\n%char2num = reverse %num2char;\n\n\n#map { print \"$_ $num2char{$_}\\n\" } sort { $a <=> $b } keys %num2char;\n#map { print \"$_ $char2num{$_}\\n\" } sort keys %char2num;\n\n$n = <>;\n\nfor (1..$n) {\n    $input = <>;\n    if ($input =~ /^R(\\d+)C(\\d+)$/) {\n        $row = $1;\n        $col = $2;\n        $new_char = undef;\n        while ($col > 0) {\n            $new_char = ($col % 26 == 0 ? $num2char{26} : $num2char{$col % 26}) . $new_char;\n            if ($col % 26 == 0) { $col--; }\n            $col = int($col / 26);\n        }\n        $col = $new_char;\n        print \"$col$row\\n\";\n    }\n    elsif ($input =~ /^([A-Z]+)(\\d+)$/) {\n        $row = $2;\n        $col = $1;\n        $count = 0;\n        $sum = 0;\n        for $c (reverse split //,$col) {\n            $sum += (26 ** $count++) * $char2num{$c};  \n        }\n        $col = $sum;\n        print \"R$row\" . \"C$col\\n\";\n    }\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nuse 5.012;\n\nmy $num_inputs = <>;\nmy @inputs;\n\nfor ( 1 .. $num_inputs ) {\n  my $input = <>;\n  chomp $input;\n  if ( $input =~ /\\AR(\\d+)C(\\d+)\\z/ ) {\n    printf \"%s%s\\n\", row_num_to_letter($2), $1;\n  }\n  else {\n    $input =~ /\\A([A-Z]+)(\\d+)\\z/;\n    printf \"R%sC%s\\n\", $2, row_letter_to_num( $1 );\n  }\n}\n\nsub row_num_to_letter {\n  my ( $num ) = @_;\n  my $str = '';\n  while ( $num > 0 ) {\n    if ( my $left = $num % 26 ) {\n      $str = chr( $left + 64 ) . $str;\n      $num = int( $num / 26 );\n    } else {\n      $str = 'Z' . $str;\n      $num = int( $num / 26 ) - 1;\n    }\n  }\n  return $str;\n}\n\nsub row_letter_to_num {\n  my ( @letters ) = split //,  $_[0];\n  my $num = 0;\n  my $scale = 0; \n  while ( @letters ) {\n    my $letter = pop(@letters);\n    my $nvalue = ord($letter) - 64;\n    $num = $num + ( $nvalue * ( 26 ** $scale ) );\n    $scale ++;\n  }\n  return $num;\n}\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nmy $totalNum =  <STDIN>;\n\nmy @inputs;\nfor(my $i = 0; $i < $totalNum; $i++){\n    my $input = <STDIN>;\n    push @inputs, $input;        \n}\n\nforeach my $input (@inputs){\n#    print $input . \"\\n\";\n    if ( $input =~ /^R([0-9]+)C([0-9]+)$/){\n        print convert26($2) . \"$1\" . \"\\n\";\n    }\n    if ($input =~ /^([A-Z]+)(\\d+)$/ ){\n        print \"R$2\" . \"C\" . iconvert26($1) . \"\\n\";\n    }\n}\n\n\n#\n#foreach my $i (1..250){\n#    print convert26($i), \" \";\n#}\n#\n#print \"\\n\";\n#\n\n#foreach my $i ('AA'..'AZ'){\n#    print iconvert26($i), \"  \";\n#}\n\n\n\n#===================================================================\nsub convert26 \n{\n\tmy ($input) = @_;\n\tmy $base = 26;\n\tmy @elements = ( 'A'..'Z');\n\tmy @ret=();\n\tdo{\t    \n\t    unshift @ret, $elements[($input)%$base -1];\n\t    $input = int(($input-1) /$base);\n\t}while($input);\n\treturn join('', @ret);\n}\n\nsub iconvert26\n{\n    my ($input) = @_;\n    my $base = 26;\n    my @elements = ('', 'A'..'Z');\n    my @inputs = reverse (split(\"\", $input));\n    my $ret = 0;\n    my $pos = 0;\n    foreach my $in (@inputs){\n        my $index = 0;\n        foreach my $elem (@elements){\n            \n            if($elem eq $in){\n                last;\n            }\n            $index ++;\n        }\n        $ret += $index  * $base ** $pos; \n        $index = 0;\n        $pos++;\n    }\n    return $ret;\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>;\nchomp $n;\n\nwhile ($n--) {\n    my $line = <STDIN>;\n    chomp $line;\n    print trans($line), \"\\n\";\n}\n\nsub trans\n{\n    my $x = shift @_;\n    my $res = \"\";\n\n    if ($x =~ m/R(\\d+)C(\\d+)/) {\n        my $r = $1;\n        my $c = $2;\n\n#        print \"$r $c\\n\";\n        while ($c > 0) {\n            $res = chr(ord('A') + ($c + 25)%26).$res;\n            if ($c % 26) {\n                $c = int($c/26);\n            } else {\n                $c = $c/26 - 1;\n            }\n        }\n        $res .= $r;\n    } else {\n        $x =~ m/([A-Z]+)(\\d+)/;\n        my $r = $2;\n\n#        print \"$1 $2\\n\";\n        my $c = 0;\n        my $pow = 0;\n        my $len = length($1);\n        foreach (split \"\", $1) {\n#            print \"$_\\n\";\n            $pow += 1;\n            $c += (ord($_) - ord('A') + 1)*(26**($len-$pow));\n#            print \"$len $pow $_ $c\\n\";\n        }\n\n        $res = \"R\".$r.\"C\".$c;\n    }\n\n    return $res;\n}\n"}], "negative_code": [{"source_code": "\nuse strict;\nuse warnings;\nuse bigint;\nmy $n = int(<>);\nmy $inp;\nfor (1..$n) {\n    $inp = <>;\n    if ($inp =~ /([A-Z]{1})(\\d+)([A-Z]{1})(\\d+)/) {\n        print chr(64 + $4 / 26) if ($4 / 26);\n        print chr(64 + $4 % 26) if ($4);\n        print $2, \"\\n\";\n    }\n    else {\n        $inp =~ /([A-Z]+)([0-9]+)/;\n        print \"R$2C\";\n        my @arr = split \"\", $1;\n        if (length $1 == 1) {\n            @arr = (chr 64, $1);\n        }\n        # print ord $arr[0], \"\\n\";\n        print ((ord($arr[0]) - 64) * 26 + ord($arr[1]) - 64);\n    }\n}\n"}, {"source_code": "my $n = <>;\nwhile( <> ) {\n    if ( /^R([0-9]+)C([0-9]+)/ ) { \n        print convert_to_26($2) . $1 . \"\\n\";\n    }\n    elsif ( /^([A-Z]+)([0-9]+)/ ) {\n       print \"R$2C\" . convert_to_10( $1 ) . \"\\n\"; \n    }\n\n    $n--;\n    last if ( !$n );\n}\n\nsub convert_to_26 {\n    my $n = shift;\n    return chr( ord('A') + $n - 1 ) if ( $n <= 26 );\n\n    return convert_to_26( $n/26 ) . chr ( ord('A') + ($n % 26) - 1 );\n}\n\nsub convert_to_10 {\n    my @n = split '', shift;\n    my $ret = 0;\n    for ( my $i=0; $i <= $#n; $i++ ) {\n        $ret += ( ord( $n[$i] ) - ord('A') + 1 ) * ( 26 ** ( $#n - $i ) );\n    }\n\n    return $ret;\n}\n"}, {"source_code": "my $n = <>;\nwhile( <> ) {\n    if ( /^R([0-9]+)C([0-9]+)/ ) { \n        print convert_to_26($2) . $1 . \"\\n\";\n    }\n    elsif ( /^([A-Z]+)([0-9]+)/ ) {\n       print \"R$2C\" . convert_to_10( $1 ) . \"\\n\"; \n    }\n\n    $n--;\n    last if ( !$n );\n}\n\nsub convert_to_26 {\n    my $n = shift;\n    return chr( ord('A') + $n - 1 ) if ( $n <= 26 );\n\n    my $rem = $n % 26;\n    my $div = $n / 26;\n    if ( !$rem ) {\n        $rem = 26;\n        $div--;\n    }\n    return convert_to_26($div) . chr ( ord('A') + $rem - 1 );\n}\n\nsub convert_to_10 {\n    my @n = split '', shift;\n    my $ret = 0;\n    for ( my $i=0; $i <= $#n; $i++ ) {\n        $ret += ( ord( $n[$i] ) - ord('A') + 1 ) * ( 26 ** ( $#n - $i ) );\n    }\n\n    return $ret;\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nuse 5.012;\n\nmy $num_inputs = <>;\nmy @inputs;\n\nfor ( 1 .. $num_inputs ) {\n  my $input = <>;\n  chomp $input;\n  if ( $input =~ /\\AR(\\d+)C(\\d+)\\z/ ) {\n    printf \"%s%s\\n\", row_num_to_letter($2), $1;\n  }\n  else {\n    $input =~ /\\A([A-Z]+)(\\d+)\\z/;\n    printf \"R%sC%s\\n\", $2, row_letter_to_num( $1 );\n  }\n}\n\nsub row_num_to_letter {\n  my ( $num ) = @_;\n  my $str = '';\n  while ( $num > 26 ) {\n    my $left = $num % 26; \n    $str = chr( $left + 64 ) . $str;\n    $num = int( $num / 26 );\n  }\n  return chr( $num + 64 ) . $str;\n}\nsub row_letter_to_num {\n  my ( @letters ) = split //,  $_[0];\n  my $num = 0;\n  my $scale = 0; \n  while ( @letters ) {\n    my $letter = pop(@letters);\n    my $nvalue = ord($letter) - 64;\n    $num = $num + ( $nvalue * ( 26 ** $scale ) );\n    $scale ++;\n  }\n  return $num;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>;\nchomp $n;\n\nwhile ($n--) {\n    my $line = <STDIN>;\n    chomp $line;\n    print trans($line), \"\\n\";\n}\n\nsub trans\n{\n    my $x = shift @_;\n    my $res = \"\";\n\n    if ($x =~ m/R(\\d+)C(\\d+)/) {\n        my $r = $1;\n        my $c = $2;\n\n#        print \"$r $c\\n\";\n        while ($c > 0) {\n            $res = chr(ord('A') - 1 + $c%26).$res;\n            $c = int($c/26);\n#            $c -= 1;\n        }\n        $res .= $r;\n    } else {\n        $x =~ m/([A-Z]+)(\\d+)/;\n        my $r = $2;\n\n#        print \"$1 $2\\n\";\n        my $c = 0;\n        my $pow = 0;\n        my $len = length($1);\n        foreach (split \"\", $1) {\n#            print \"$_\\n\";\n            $pow += 1;\n            $c += (ord($_) - ord('A') + 1)*(26**($len-$pow));\n#            print \"$len $pow $_ $c\\n\";\n        }\n\n        $res = \"R\".$r.\"C\".$c;\n    }\n\n    return $res;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>;\nchomp $n;\n\nwhile ($n--) {\n    my $line = <STDIN>;\n    chomp $line;\n    print trans($line), \"\\n\";\n}\n\nsub trans\n{\n    my $x = shift @_;\n    my $res = \"\";\n\n    if ($x =~ m/R(\\d+)C(\\d+)/) {\n        my $r = $1;\n        my $c = $2;\n\n#        print \"$r $c\\n\";\n        $c -= 1;\n        while ($c > 0) {\n            $res = chr(ord('A') + $c%26).$res;\n            $c = int($c/26);\n            $c -= 1;\n        }\n        $res .= $r;\n    } else {\n        $x =~ m/([A-Z]+)(\\d+)/;\n        my $r = $2;\n\n#        print \"$1 $2\\n\";\n        my $c = 0;\n        my $pow = 0;\n        my $len = length($1);\n        foreach (split \"\", $1) {\n#            print \"$_\\n\";\n            $pow += 1;\n            $c += (ord($_) - ord('A') + 1)*(26**($len-$pow));\n#            print \"$len $pow $_ $c\\n\";\n        }\n\n        $res = \"R\".$r.\"C\".$c;\n    }\n\n    return $res;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>;\nchomp $n;\n\nwhile ($n--) {\n    my $line = <STDIN>;\n    chomp $line;\n    print trans($line), \"\\n\";\n}\n\nsub trans\n{\n    my $x = shift @_;\n    my $res = \"\";\n\n    if ($x =~ m/R(\\d+)C(\\d+)/) {\n        my $r = $1;\n        my $c = $2;\n\n#        print \"$r $c\\n\";\n        $c -= 1;\n        while ($c > 0) {\n            $res = chr(ord('A') + $c%26).$res;\n            $c = int($c/26);\n            $c -= 1;\n        }\n        $res .= $r;\n    } else {\n        $x =~ m/([A-Z]+)(\\d+)/;\n        my $r = $2;\n\n#        print \"$1 $2\\n\";\n        my $c = 0;\n        foreach (split \"\", $1) {\n#            print \"$_\\n\";\n            $c *= 26;\n            $c += ord($_) - ord('A') + 1;\n        }\n\n        $res = \"R\".$r.\"C\".$c;\n    }\n\n    return $res;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>;\nchomp $n;\n\nwhile ($n--) {\n    my $line = <STDIN>;\n    chomp $line;\n    print trans($line), \"\\n\";\n}\n\nsub trans\n{\n    my $x = shift @_;\n    my $res = \"\";\n\n    if ($x =~ m/R(\\d+)C(\\d+)/) {\n        my $r = $1;\n        my $c = $2;\n\n#        print \"$r $c\\n\";\n        $c -= 1;\n        while ($c > 0) {\n            $res = chr(ord('A') + $c%26).$res;\n            $c = int($c/26);\n            $c -= 1;\n        }\n        $res .= $r;\n    } else {\n        $x =~ m/([A-Z]+)(\\d+)/;\n        my $r = $2;\n\n#        print \"$1 $2\\n\";\n        my $c = 0;\n        foreach (split \"\", $1) {\n            print \"$_\\n\";\n            $c *= 26;\n            $c += ord($_) - ord('A') + 1;\n        }\n\n        $res = \"R\".$r.\"C\".$c;\n    }\n\n    return $res;\n}\n"}, {"source_code": "\nsub RC_to_CR {\n\tmy $rc = shift;\n\t$rc =~ /^R(\\d+)C(\\d+)/;\n\tmy $row = $1;\n\tmy $col = $2;\n\tmy $ret = '';\n\twhile($col > 26) {\n\t\t$ret .= chr(64+($col % 26));\n\t\t$col /= 26;\n\t}\n\t$ret .= chr(64+$col);\n\t$ret = scalar reverse $ret;\n\t$ret .= $row;\n\treturn $ret;\n}\n\nsub CR_to_RC {\n\tmy $cr = shift;\n\t$cr =~ /([A-Z]+)(\\d+)/;\n\tmy $col = $1;\n\tmy $row = $2;\n\tmy $ret = 'R'.$row.\"C\";\n\tmy $p = length($col)-1;\n\tmy $c = 0;\n\tforeach my $ltr (split //, $col) {\n\t\tmy $v = (ord($ltr)-64);\n\t\t$c += ($v * 26**$p);\n\t\t$p--;\n\t}\n\t$ret .= $c;\n\treturn $ret;\n}\n\nmy $num = <STDIN>;\nchomp($num);\nwhile($num-- > 0) {\n\tchomp($row = <STDIN>);\n\tif($row =~ /^R\\d+C\\d+/) {\n\t\tprint RC_to_CR($row).\"\\n\";\n\t} else {\n\t\tprint CR_to_RC($row).\"\\n\";\n\t}\n}"}, {"source_code": "\nsub RC_to_CR {\n\tmy $rc = shift;\n\t$rc =~ /^R(\\d+)C(\\d+)/;\n\tmy $row = $1;\n\tmy $col = $2;\n\tmy $ret = '';\n\tmy $p = 1;\n\twhile($col > 26) {\n\t\tif($col % 26**$p == 0) {\n\t\t\t$ret .= \"Z\";\n\t\t\t$col -= 26**$p;\n\t\t} else {\n\t\t\tmy $tmp = int($col / 26);\n#\t\t$tmp = 1 if($tmp == 0);\n\t\t\tmy $v = $col - $tmp * 26;\n#\t\t\tprint \"Got $v, it turns into \".chr(64+$v).\"\\n\";\n\t\t\t$ret .= chr(64+$v);\n\t\t}\n\t\t$col = int($col/26);\n\t\t$p++;\n\t}\n\n\t$ret .= chr(64+$col);\n\t$ret = scalar reverse $ret;\n\t$ret .= $row;\n\treturn $ret;\n}\n\nsub CR_to_RC {\n\tmy $cr = shift;\n\t$cr =~ /([A-Z]+)(\\d+)/;\n\tmy $col = $1;\n\tmy $row = $2;\n\tmy $ret = 'R'.$row.\"C\";\n\tmy $l = length($col)-1;\n\tmy $c = 0;\n\tmy $p = $l;\n\tforeach my $ltr (split //, $col) {\n\t\tmy $v = (ord($ltr)-64);\n\t\t$c += ($v * 26**$p);\n\t\t$p--;\n\t}\n\t$ret .= $c;\n\treturn $ret;\n}\n\nmy $num = <STDIN>;\nchomp($num);\nwhile($num-- > 0) {\n\tchomp($row = <STDIN>);\n\tif($row =~ /^R\\d+C\\d+/) {\n\t\tprint RC_to_CR($row).\"\\n\";\n\t} else {\n\t\tprint CR_to_RC($row).\"\\n\";\n\t}\n}\n"}, {"source_code": "\nsub RC_to_CR {\n\tmy $rc = shift;\n\t$rc =~ /^R(\\d+)C(\\d+)/;\n\tmy $row = $1;\n\tmy $col = $2;\n\tmy $ret = '';\n\twhile($col > 26) {\n\t\t$ret .= chr(64+($col % 26));\n\t\t$col /= 26;\n\t}\n\t$ret .= chr(64+$col);\n\t$ret = scalar reverse $ret;\n\t$ret .= $row;\n\treturn $ret;\n}\n\nsub CR_to_RC {\n\tmy $cr = shift;\n\t$cr =~ /([A-Z]+)(\\d+)/;\n\tmy $col = $1;\n\tmy $row = $2;\n\tmy $ret = 'R'.$row.\"C\";\n\tmy $l = length($col)-1;\n\tmy $c = 0;\n\tfor(my $p=$l;$p>=0;$p--) {\n\t\tmy $ltr = substr($col,($p-$l), 1);\n\t\tmy $v = (ord($ltr)-64);\n\t\t$c += ($v * 26**$p);\n\t}\n\t$ret .= $c;\n\treturn $ret;\n}\n\nmy $num = <STDIN>;\nchomp($num);\nwhile($num-- > 0) {\n\tchomp($row = <STDIN>);\n\tif($row =~ /^R\\d+C\\d+/) {\n\t\tprint RC_to_CR($row).\"\\n\";\n\t} else {\n\t\tprint CR_to_RC($row).\"\\n\";\n\t}\n}"}, {"source_code": "\nsub RC_to_CR {\n\tmy $rc = shift;\n\t$rc =~ /^R(\\d+)C(\\d+)/;\n\tmy $row = $1;\n\tmy $col = $2;\n\tmy $ret = '';\n\tmy $p = 1;\n\twhile($col > 26) {\n\t\tif($col % 26**$p == 0) {\n\t\t\t$ret .= \"Z\";\n\t\t\t$col /= 26;\n\t\t} else {\n\t\t\tmy $tmp = int($col / 26);\n\t\t\tmy $v = $col - $tmp * 26;\n\t\t\t$ret .= chr(64+$v);\n\t\t\t$col /= 26;\n\t\t}\n\t\t$p++;\n\t}\n\t$ret .= chr(64+$col);\n\t$ret = scalar reverse $ret;\n\t$ret .= $row;\n\treturn $ret;\n}\n\nsub CR_to_RC {\n\tmy $cr = shift;\n\t$cr =~ /([A-Z]+)(\\d+)/;\n\tmy $col = $1;\n\tmy $row = $2;\n\tmy $ret = 'R'.$row.\"C\";\n\tmy $l = length($col)-1;\n\tmy $c = 0;\n\tmy $p = $l;\n\tforeach my $ltr (split //, $col) {\n\t\tmy $v = (ord($ltr)-64);\n\t\t$c += ($v * 26**$p);\n\t\t$p--;\n\t}\n\t$ret .= $c;\n\treturn $ret;\n}\n\nmy $num = <STDIN>;\nchomp($num);\nwhile($num-- > 0) {\n\tchomp($row = <STDIN>);\n\tif($row =~ /^R\\d+C\\d+/) {\n\t\tprint RC_to_CR($row).\"\\n\";\n\t} else {\n\t\tprint CR_to_RC($row).\"\\n\";\n\t}\n}\n"}, {"source_code": "\nsub RC_to_CR {\n\tmy $rc = shift;\n\t$rc =~ /^R(\\d+)C(\\d+)/;\n\tmy $row = $1;\n\tmy $col = $2;\n\tmy $ret = '';\n\tmy $p = 1;\n\twhile($col > 26) {\n\t\tif($col % 26**$p == 0) {\n\t\t\t$ret .= \"Z\";\n$col -= 26**$p;\n\t\t\t$col /= 26;\n\t\t} else {\n\t\t\tmy $tmp = int($col / 26);\n\t\t\tmy $v = $col - $tmp * 26;\n\t\t\t$ret .= chr(64+$v);\n\t\t\t$col /= 26;\n\t\t}\n\t\t$p++;\n\t}\n\t$ret .= chr(64+$col);\n\t$ret = scalar reverse $ret;\n\t$ret .= $row;\n\treturn $ret;\n}\n\nsub CR_to_RC {\n\tmy $cr = shift;\n\t$cr =~ /([A-Z]+)(\\d+)/;\n\tmy $col = $1;\n\tmy $row = $2;\n\tmy $ret = 'R'.$row.\"C\";\n\tmy $l = length($col)-1;\n\tmy $c = 0;\n\tmy $p = $l;\n\tforeach my $ltr (split //, $col) {\n\t\tmy $v = (ord($ltr)-64);\n\t\t$c += ($v * 26**$p);\n\t\t$p--;\n\t}\n\t$ret .= $c;\n\treturn $ret;\n}\n\nmy $num = <STDIN>;\nchomp($num);\nwhile($num-- > 0) {\n\tchomp($row = <STDIN>);\n\tif($row =~ /^R\\d+C\\d+/) {\n\t\tprint RC_to_CR($row).\"\\n\";\n\t} else {\n\t\tprint CR_to_RC($row).\"\\n\";\n\t}\n}\n"}, {"source_code": "use strict;\nuse warnings;\nuse utf8;\n\nmy $n=<STDIN>;\nchomp($n);\n\nour @dic=(\"A\",\"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\");\nour %alphabet = do { my $i; map { $_ => ++$i } qw(A B C D E F G H I J K L M N O P Q R S T U V Q X Y Z) };\n\nfor(my $i=0; $i<$n; $i++){\n\tmy $stdin=<STDIN>;\n\tchomp($stdin);\n\tprint solveB($stdin).\"\\n\";\n}\n\nsub solveB{\n\tmy $s=$_[0];\n\tif($s=~/^R(\\d+)C(\\d+)$/){\n\t\treturn solve1($2,\"\").$1;\n\t}\n\tif($s=~/^([A-Z]+)(\\d+)$/){\n\t\tmy $ans=0;\n\t\tfor(my $i=0; $i<length($1); $i++){\n\t\t\t$ans+=$alphabet{substr($1,$i,1)}*(26**(length($1)-$i-1));\n\t\t}\n\t\treturn \"R\".$2.\"C\".$ans;\n\t}\n}\n\nsub solve1{\n\treturn\t$_[1]\tif($_[0]==0);\n\treturn &solve1(int($_[0]/26), $dic[$_[0]%26].$_[1]);\n}\n"}, {"source_code": "use strict;\nuse warnings;\nuse utf8;\n\nmy $n=<STDIN>;\nchomp($n);\n\nour @dic=(\"A\",\"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\");\nour %alphabet = do { my $i; map { $_ => ++$i } qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) };\n\nfor(my $i=0; $i<$n; $i++){\n\tmy $stdin=<STDIN>;\n\tchomp($stdin);\n\tprint solveB($stdin).\"\\n\";\n}\n\nsub solveB{\n\tmy $s=$_[0];\n\tif($s=~/^R(\\d+)C(\\d+)$/){\n\t\treturn solve1($2,\"\").$1;\n\t}\n\tif($s=~/^([A-Z]+)(\\d+)$/){\n\t\tmy $ans=0;\n\t\tfor(my $i=0; $i<length($1); $i++){\n\t\t\t$ans+=$alphabet{substr($1,$i,1)}*(26**(length($1)-$i-1));\n\t\t}\n\t\treturn \"R\".$2.\"C\".$ans;\n\t}\n}\n\nsub solve1{\n\treturn\t$_[1]\tif($_[0]==0);\n\treturn &solve1(int($_[0]/26), $dic[$_[0]%26].$_[1]);\n}\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nsub ntos {\n# Slow, but should be OK\n    my $n = shift;\n    my $s = 'A';\n    for (1 .. $n - 1) { $s++; }\n    return $s;\n}\n\nsub ston {\n    my $s = shift;\n    my %hash;\n    @hash{('A'..'Z')} = (1 .. 26);\n    my $n = 0;\n    for (split //, $s) {\n\t$n *= 26;\n\t$n += $hash{$_};\n    }\n    return $n;\n}\n\nsub main {\n    my $n = int <>;\n    for (1 .. $n) {\n\tmy $s = <>;\n\tif ($s =~ /^R([\\d]*)C([\\d]*)$/) {\n\t    print ntos($2) . \"$1\\n\";\n\t} elsif ($s =~ /^([\\D]*)([\\d]*)$/) {\n\t    print \"R$2C\" . (ston $1) . \"\\n\";\n\t} else {\n\t    exit(-1);\n\t}\n    }\n}\n\nmain();\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\nuse integer;\n\nsub ntos {\n    my $n = shift;\n    my @arr = ('A' .. 'Z');\n    my $s = '';\n    while ($n > 0) {\n\t$s = @arr[$n % 26 - 1] . $s;\n\t$n /= 26;\n    }\n    return $s;\n}\n\nsub ston {\n    my $s = shift;\n    my %hash;\n    @hash{('A'..'Z')} = (1 .. 26);\n    my $n = 0;\n    for (split //, $s) {\n\t$n *= 26;\n\t$n += $hash{$_};\n    }\n    return $n;\n}\n\nsub main {\n    my $n = int <>;\n    for (1 .. $n) {\n\tmy $s = <>;\n\tif ($s =~ /^R([\\d]+)C([\\d]+)$/) {\n\t    print ntos($2) . \"$1\\n\";\n\t} elsif ($s =~ /^([\\D]*)([\\d]*)$/) {\n\t    print \"R$2C\" . (ston $1) . \"\\n\";\n\t} else {\n\t    exit(-1);\n\t}\n    }\n}\n\nmain();\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t>=26){return ((($t%26==0)?ntl(int($t/26-1),$ln):ntl(int($t/26),$ln)).$$ln{$t%26});}\n    else{return $$ln{$t};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=($2>26)?ntl($2,$g):$ln{$2%26};\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t==0){return \"\";}\n    elsif($t>26){return (($t%26==0)?ntl(int($t/26-1),$ln):ntl(int($t/26)),$ln).$$ln{$t%26};}\n    else{return $$ln{$t};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=ntl($2,$g);\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t==0){return \"\";}\n    elsif($t>26){return ((($t%26==0)?ntl(int($t/26-1),$ln):ntl(int($t/26),$ln)).$$ln{$t%26});}\n    else{return $$ln{$t};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=ntl($2,$g);\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t==0){return \"\";}\n    elsif($t==1){return \"A\";}\n    elsif($t>26){return ntl(int($t/26),$ln).$$ln{$t%26};}\n    else{return $$ln{$t-1};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=ntl($2,$g);\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t==0){return \"\";}\n    elsif($t>26){return (($t%26)?ntl(int($t/26-1),$ln):ntl(int($t/26)),$ln).$$ln{$t%26};}\n    else{return $$ln{$t};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=ntl($2,$g);\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t==0){return \"\";}\n    elsif($t>26){return ntl(int($t/26),$ln).$$ln{$t%26};}\n    else{return $$ln{$t};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=ntl($2,$g);\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nno warnings 'recursion';\nuse strict;\n\nsub ltn{\n    my @k=split//,shift;my $ln=shift;\n    if(@k==1){return $$ln{$k[0]};}\n    else{\n\tmy $h=pop @k;my $f=join \"\",@k;\n\treturn ($$ln{$h}+26*ltn($f,$ln));\n    }\n}\nsub ntl{\n    my $t=shift;my $ln=shift;\n    if($t>26){return ((($t%26==0)?ntl(int($t/26-1),$ln):ntl(int($t/26),$ln)).$$ln{$t%26});}\n    else{return $$ln{$t};}\n}\n\nmy $row_n;my %ln;$ln{0}=\"Z\";$ln{\"Z\"}=26;my $l=\"A\";\nfor my $j(1..25){\n    $ln{$j}=$l;\n    $ln{$l}=$j;\n    ++$l;\n}my $g=\\%ln;\nmy $n=<STDIN>;\nmy @final_list;\nforeach my $i (1..$n){\n    my $sr=<STDIN>;\n    chomp($sr);\n    if($sr=~/^R([0-9]+)C([0-9]+)$/){\n\tmy $p=($2>26)?ntl($2,$g):$ln{$2%26};\n\tpush @final_list,\"$p\".\"$1\\n\";\n    }\n    elsif($sr=~/([A-Z]+)([0-9]+)/){\n\tmy $col=ltn($1,$g);\n\t$row_n=$2;\n\tpush @final_list,\"R$row_n\".\"C$col\\n\";\n    }\n}\nprint @final_list;\n"}, {"source_code": "#!/usr/bin/perl\n\n\n%num2char = map { ($_ + 1) => chr(ord('A') + $_) } (0..25) ;\n%char2num = reverse %num2char;\n\n\n#map { print \"$_ $num2char{$_}\\n\" } sort { $a <=> $b } keys %num2char;\n#map { print \"$_ $char2num{$_}\\n\" } sort keys %char2num;\n\n$n = <>;\n\nfor (1..$n) {\n    $input = <>;\n    if ($input =~ /^R(\\d+)C(\\d+)$/) {\n        #print \"Row-column to column-row\\n\";\n        $row = $1;\n        $col = $2;\n        $new_char = undef;\n        while ($col > 0) {\n            $new_char = $num2char{$col % 26} . $new_char;\n            $col = int($col / 26);\n        }\n        $col = $new_char;\n        print \"$col$row\\n\";\n    }\n    elsif ($input =~ /^([A-Z]+)(\\d+)$/) {\n        #print \"Column-row to row-column $1, $2\\n\";\n        $row = $2;\n        $col = $1;\n        $count = 0;\n        $sum = 0;\n        for $c (reverse split //,$col) {\n            $sum += (26 ** $count++) * $char2num{$c};  \n        }\n        $col = $sum;\n        print \"R$row\" . \"C$col\\n\";\n    }\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n\n%num2char = map { ($_ + 1) => chr(ord('A') + $_) } (0..25) ;\n%char2num = reverse %num2char;\n\n\n#map { print \"$_ $num2char{$_}\\n\" } sort { $a <=> $b } keys %num2char;\n#map { print \"$_ $char2num{$_}\\n\" } sort keys %char2num;\n\n$n = <>;\n\nfor (1..$n) {\n    $input = <>;\n    if ($input =~ /^R(\\d+)C(\\d+)$/) {\n        #print \"Row-column to column-row\\n\";\n        $row = $1;\n        $col = $2;\n        $new_char = undef;\n        while ($col > 1) {\n            $new_char = ($col % 26 == 0 ? $num2char{26} : $num2char{$col % 26}) . $new_char;\n            $col = int($col / 26);\n        }\n        $col = $new_char;\n        print \"$col$row\\n\";\n    }\n    elsif ($input =~ /^([A-Z]+)(\\d+)$/) {\n        #print \"Column-row to row-column $1, $2\\n\";\n        $row = $2;\n        $col = $1;\n        $count = 0;\n        $sum = 0;\n        for $c (reverse split //,$col) {\n            $sum += (26 ** $count++) * $char2num{$c};  \n        }\n        $col = $sum;\n        print \"R$row\" . \"C$col\\n\";\n    }\n}\n"}, {"source_code": "#!/usr/local/bin/perl\n$n = <>;\nfor ( 1 .. $n ) {\n    $line = <>;\n\n    if ( $line =~ /(\\D+)(\\d+)(\\D+)(\\d+)/ ) {\n        print makeNormal($2,$4);\n\n    }\n    elsif($line =~ /(\\D+)(\\d+)/ ){      \n        print makeRC($1 , $2);\n    }\n\n}\n    sub makeNormal {\n        use integer;\n        my $row = $_[0];\n        my $col = $_[1];\n        my @alph = (A..Z);\n        \n        $result = $row;\n        do{\n            my $r, $letter;\n            $col -= 1;\n            $r = $col % 26;\n            $col = $col / 26;           \n            $result = @alph[$r].$result;\n        } while ($col);\n        return $result;\n    }\n\n    sub makeRC {\n        use integer;\n        my $row = $_[1];\n        my $col = $_[0];\n        my $resCol = 0;\n        my $n = 1;\n        my $A = ord(\"A\");\n        foreach $ch (reverse split (// , $col)){\n            $resCol+= (ord($ch) - $A +1) * $n;\n            $n *= 26;\n        }\n        return \"R\".$row.\"C\".$resCol;\n        \n        \n    }\n"}, {"source_code": "my $num = <STDIN>;\nfor (1..$num) {\n    my $input = <STDIN>;\n    chomp $input;\n    if ($input =~ /R(\\d+)C(\\d+)/) {\n        my ($row, $col) = ($1, $2);\n        my @col;\n        while ($col >= 26) {\n            push @col, $col % 26;\n            $col = int ($col/26);\n        }\n        push @col, $col;\n        @col = reverse @col;\n        my $str;\n        $str .= ('A'..'Z')[$_-1] foreach @col;\n        $str .= $row;\n        print $str, \"\\n\";\n    } else {\n        $input =~ /([A-Z]+)(\\d+)/;\n        my ($col_str, $row) = ($1, $2);\n        my $col = 0;\n        foreach (map { ord($_) - 64 } split //, $col_str) {\n            $col *= 26;\n            $col += $_;\n        }\n        print \"R\", $row, \"C\", $col, \"\\n\";\n    }\n}"}, {"source_code": "my $num = <STDIN>;\nfor (1..$num) {\n    my $input = <STDIN>;\n    chomp $input;\n    if ($input =~ /R(\\d+)C(\\d+)/) {\n        my ($row, $col) = ($1, $2);\n        my $str;\n        while ($col >= 26) {\n            $str .= ('A'..'Z')[int ($col/26)-1];\n            $col %= 26;\n        }\n        $str .= ('A'..'Z')[$col-1] . $row;\n        print $str, \"\\n\";\n    } else {\n        $input =~ /([A-Z]+)(\\d+)/;\n        my ($col_str, $row) = ($1, $2);\n        my $col = 0;\n        foreach (map { ord($_) - 64 } split //, $col_str) {\n            $col *= 26;\n            $col += $_;\n        }\n        print \"R\", $row, \"C\", $col, \"\\n\";\n    }\n}"}, {"source_code": "\nmy $num = <STDIN>;\nfor (1..$num) {\n    my $input = <STDIN>;\n    chomp $input;\n    if ($input =~ /R(\\d+)C(\\d+)/) {\n        my ($row, $col) = ($1, $2);\n        my @col;\n        while ($col >= 26) {\n            push @col, $col % 26;\n            $col = int (($col-1)/26);\n        }\n        push @col, $col;\n        @col = reverse @col;\n        my $str;\n        $str .= ('A'..'Z')[$_-1] foreach @col;\n        $str .= $row;\n        print $str, \"\\n\";\n    } else {\n        $input =~ /([A-Z]+)(\\d+)/;\n        my ($col_str, $row) = ($1, $2);\n        my $col = 0;\n        foreach (map { ord($_) - 64 } split //, $col_str) {\n            $col *= 26;\n            $col += $_;\n        }\n        print \"R\", $row, \"C\", $col, \"\\n\";\n    }\n}\n\n"}, {"source_code": "\n#!/usr/bin/perl\n\nuse 5.006;\nuse strict;\nuse warnings;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /R[0-9]+C[0-9]+/) {\n            my $row = $line;\n            $row =~ s/R//g;\n            $row =~ s/C[0-9]+//g;\n            my $col = $line;\n            $col =~ s/^R[0-9]+C//g;\n            print convertToSymbols($col).\"$row\\n\";\n        } else {\n            my $row = $line;\n            $row =~ s/[A-Z]+//g;\n            my $col = $line;\n            $col =~ s/[0-9]+//g;\n            print \"R\".$row.\"C\".convertFromSymbols($col).\"\\n\";\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $c = chr(ord(\"A\") + $cur % 26 - 1);\n        $result = $result.$c;\n        $cur = ($cur - $cur % 26) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "#!/usr/bin/perl\n\nmain();\n\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /(\\D+)(\\d+)(\\D+)(\\d+)/) {\n            print convertToSymbols($4).\"$2\\n\";\n            next;\n        }\n        if ($line =~ /(\\D+)(\\d+)/) {\n            print \"R\".$2.\"C\".convertFromSymbols($1).\"\\n\";\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $c = chr(ord(\"A\") + $cur % 26 - 1);\n        $result = $result.$c;\n        $cur = ($cur - $cur % 26) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "\n#!/usr/bin/perl\n\nmain();\n\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /(\\D+)(\\d+)(\\D+)(\\d+)/) {\n            print convertToSymbols($4).\"$2\\n\";\n            next;\n        }\n        if ($line =~ /(\\D+)(\\d+)/) {\n            print \"R\".$2.\"C\".convertFromSymbols($1).\"\\n\";\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $c = chr(ord(\"A\") + ($cur - 1) % 26);\n        $result = $result.$c;\n        $cur = ($cur - $cur % 26) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "\n#!/usr/bin/perl\n\nuse 5.006;\nuse strict;\nuse warnings;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /R[0-9]+C[0-9]+/) {\n            my $row = $line;\n            $row =~ s/R//g;\n            $row =~ s/C[0-9]+//g;\n            my $col = $line;\n            $col =~ s/^R[0-9]+C//g;\n            print convertToSymbols($col).\"$row\";\n        } else {\n            my $row = $line;\n            $row =~ s/[A-Z]+//g;\n            my $col = $line;\n            $col =~ s/[0-9]+//g;\n            print \"R\".$row.\"C\".convertFromSymbols($col);\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $c = chr(ord(\"A\") + $cur % 26 - 1);\n        $result = $result.$c;\n        $cur = ($cur - $cur % 26) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse 5.006;\nuse strict;\nuse warnings;\n\nmain();\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /R[0-9]+C[0-9]+/) {\n            my $row = $line;\n            $row =~ s/R//g;\n            $row =~ s/C[0-9]+//g;\n            my $col = $line;\n            $col =~ s/^R[0-9]+C//g;\n            print convertToSymbols($col).\"$row\";\n        } else {\n            my $row = $line;\n            $row =~ s/[A-Z]+//g;\n            my $col = $line;\n            $col =~ s/[0-9]+//g;\n            print \"R\".$row.\"C\".convertFromSymbols($col);\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $c = chr(ord(\"A\") + $cur % 26 - 1);\n        $result = $result.$c;\n        $cur = ($cur - $cur % 26) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "\n#!/usr/bin/perl\n\nuse 5.006;\nuse strict;\nuse warnings;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    for(1..$n) {\n        my $line = <>;\n        if ($line =~ /R[0-9]+C[0-9]+/) {\n            my $row = $line;\n            $row =~ s/R//g;\n            $row =~ s/C[0-9]+//g;\n            my $col = $line;\n            $col =~ s/^R[0-9]+C//g;\n            print convertToSymbols($col).\"$row\";\n        } else {\n            my $row = $line;\n            $row =~ s/[A-Z]+//g;\n            my $col = $line;\n            $col =~ s/[0-9]+//g;\n            print \"R\".convertFromSymbols($col).\"C$row\";\n        }\n    }\n}\n\nsub convertToSymbols {\n    my $cur = shift;\n    my $result = \"\";\n    while ($cur > 0) {\n        my $c = chr(ord(\"A\") + $cur % 26 - 1);\n        $result = $result.$c;\n        $cur = ($cur - $cur % 26) / 26;\n    }\n    return reverse $result;\n}\n\nsub convertFromSymbols {\n    my $s = shift;\n    my @arr = split //, $s;\n    my $result = 0;\n    foreach(@arr) {\n        $result = $result * 26 + ord($_) - ord(\"A\") + 1;\n    }\n    return $result;\n}"}, {"source_code": "use strict;\nuse warnings;\nuse bigint;\nmy $n = int(<>);\nmy $inp;\nfor (1..$n) {\n    $inp = <>;\n    if ($inp =~ /([A-Z]{1})(\\d+)([A-Z]{1})(\\d+)/) {\n        print chr(64 + $4 / 26);\n        print chr(64 + $4 % 26) if ($4);\n        print $2, \"\\n\";\n    }\n    else {\n        $inp =~ /([A-Z]+)([0-9]+)/;\n        print \"R$2C\";\n        my @arr = split \"\", $1;\n        if (length $1 == 1) {\n            @arr = (chr 64, $1);\n        }\n        # print ord $arr[0], \"\\n\";\n        print ((ord($arr[0]) - 64) * 26 + ord($arr[1]) - 64);\n    }\n}\n"}, {"source_code": "\nmy @arr = ('A' .. 'Z');\nsub ntos {\n    my $n = shift;\n    my $s = \"\";\n    while ($n > 0) {\n    $s = @arr[$n % 26 - 1] . $s;\n    $n-- unless($n % 26);\n    $n /= 26;\n    }\n    return $s;\n}\n\nsub ston {\n    my $n = 0;\n    $n = $n * 26 + ord $_ - 64 for (split //, shift);\n    return $n;\n}\nmy $n = int <>;\nfor (1 .. $n) {\n    my $s = <>;\n    if ($s =~ /^R([\\d]+)C([\\d]+)$/) {\n        print ntos($2) . \"$1\\n\";\n    }\n    else {\n        $s =~ /^([\\D]*)([\\d]*)$/;\n        print \"R$2C\" . (ston $1) . \"\\n\";\n    }\n}"}, {"source_code": "my $n = int(<>);\nmy $inp;\nmy $num;\nmy $str;\n\nfor (1..$n) {\n    $inp = <>;\n    $num = 0;\n    if ($inp =~ /([A-Z]{1})(\\d+)([A-Z]{1})(\\d+)/) {\n        $str = \"A\";\n        $str++ for(1..($4-1));\n        print \"$str$2\\n\";\n    }\n    else {\n        $inp =~ /([A-Z]+)([0-9]+)/;\n        $str = join \"\", (\"A\")x ((length $1)-1);\n        $num++ for($str..$1);\n        print \"R$2C$num\\n\";\n    }\n}"}, {"source_code": "my $n = int(<>);\nmy $inp;\nfor (1..$n) {\n    $inp = <>;\n    if ($inp =~ /([A-Z]{1})(\\d+)([A-Z]{1})(\\d+)/) {\n        print chr(64 + $4 / 26);\n        print chr(64 + $4 % 26) if ($4);\n        print $2, \"\\n\";\n    }\n    else {\n        $inp =~ /([A-Z]+)([0-9]+)/;\n        print \"R$2C\";\n        my @arr = split \"\", $1;\n        if (length $1 == 1) {\n            @arr = (chr 64, $1);\n        }\n        # print ord $arr[0], \"\\n\";\n        print ((ord($arr[0]) - 64) * 26 + ord($arr[1]) - 64);\n    }\n}"}], "src_uid": "910c0e650d48af22fa51ab05e8123709"}
{"source_code": "print <> =~ s/(.)(?!\\1)\\B|a$/1/gr =~ y/ab/00/r =~ s/\\B/ /gr", "positive_code": [{"source_code": "print <> =~ s/a+|b++(?!$)/ 0 x ( -1 + length $& ) . 1 /egr =~ y/b/0/r =~ s/\\B/ /gr"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $length = length;\n\t\n\t$debug and print '-' x 15;\n\t$debug and print;\n\t\n\tmy @ans;\n\t\n\tmy $len = 0;\n\t\n\ts/^a*b+(?=a)// and do {\n\t\t$len += length $&;\n\t\tpush @ans, $len;\n\t\t};\n\t\t\n\twhile( /a/ ){\n\t\ts/a+// and do {\n\t\t\t$len += length $&;\n\t\t\tpush @ans, $len;\n\t\t\t};\n\t\t\n\t\ts/b+(?=a)// and do {\n\t\t\t$len += length $&;\n\t\t\tpush @ans, $len;\n\t\t\t};\n\t\t}\n\t\n\t$debug and print \"@ans\";\n\t\n\tmy @ANS = ( 0 ) x $length;\n\t\n\tfor( @ans ){\n\t\t$ANS[ $_ - 1 ] = 1;\n\t\t}\n\t\t\n\tprint \"@ANS\";\n\t}"}], "negative_code": [{"source_code": "print <> =~ s/(.)\\1*(?<!b$)/ 0 x ( -1 + length $& ) . 1 /egr =~ y/b/0/r =~ s/\\B/ /gr"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\t@_ = ();\n\t\n\tmy $q = 0;\n\t\n\twhile( 1 < length ){\n\t\tmy $ch = chop;\n\t\tmy $front = substr $_, 0, 1;\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $front eq 'b' and $ch eq 'b' ){\n\t\t\tpush @_, 0;\n\t\t\t}\n\t\telsif( $front eq 'a' and $ch eq 'b' ){\n\t\t\tif( $q ){\n\t\t\t\tpush @_, 1;\n\t\t\t\t$_ = reverse( $_ . $ch );\n\t\t\t\tchop;\n\t\t\t\t$q = 0;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\tpush @_, 0;\n\t\t\t\t}\n\t\t\t}\n\t\telsif( $front eq 'b' and $ch eq 'a' ){\n\t\t\tpush @_, 1;\n\t\t\t$_ = reverse( $_ . $ch );\n\t\t\tchop;\n\t\t\t}\n\t\telsif( $front eq 'a' and $ch eq 'a' ){\n\t\t\tpush @_, $q ? 0 : '?';\n\t\t\t$q ||= 1;\n\t\t\t}\n\t\t}\n\t\n\tmy $last = $_;\n\t\n\tpush @_, 0;\n\t@_ = reverse @_;\n#%\tprint \"@_\";\n\t\n\tmy $one = 0;\n\t\n\tfor( @_ ){\n\t\t/\\?/ and $one and do {\n\t\t\t$_ = 1;\n\t\t\t};\n\t\t/\\?/ and $one = 1;\n\t\t}\n\t\n\tfor( @_ ){\n\t\t/\\?/ and do {\n\t\t\t$_ = $last eq 'b' ? 1 : 0;\n\t\t\tlast;\n\t\t\t};\n\t\t}\n\t\n\tprint \"@_\";\n\t}"}], "src_uid": "fc0d3b122d800dcbcb99795581229d42"}
{"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\t\n\t@_ = ( 0 ) x 53;\n\t\n\t$p = 26;\n\t\n\t/./g;\n\t$_[ $p ] = $&;\n\t\n\t$F = 0;\n\t\n\twhile( /./g ){\n\t\t\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $_[ $p - 1 ] eq $& ){\n\t\t\t$p --;\n\t\t\t}\n\t\telsif( $_[ $p + 1 ] eq $& ){\n\t\t\t$p ++;\n\t\t\t}\n\t\telsif( grep { $_ eq $& } @_ ){\n\t\t\t$F = 1;\n\t\t\t}\n\t\telsif( $_[ $p - 1 ] eq 0 ){\n\t\t\t$_[ -- $p ] = $&;\n\t\t\t}\n\t\telsif( $_[ $p + 1 ] eq 0 ){\n\t\t\t$_[ ++ $p ] = $&;\n\t\t\t}\n\t\telse{\n\t\t\t$F = 1;\n\t\t\t}\n\t\t\n\t\tlast if $F;\n\t\t}\n\t\n\t$_ = join '', @_;\n\ts/^0+|0+$//g;\n\t\n\tif( $F ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint for \"YES\", $_ . ( join '', 'a' .. 'z' ) =~ s/[$_]//gr;\n\t\t}\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\t\n\tif( 1 == length ){\n\t\tprint for \"YES\", join '', 'a' .. 'z';\n\t\tnext;\n\t\t}\n\t\n\t@_ = split '';\n\t\n\tmy $alphabet = shift @_;\n\t\n\t$alphabet = join \"<$alphabet>\", ( ',' ) x 2;\n\t\n\t$debug and print \"[$alphabet]\";\n\t\n\tmy $fail = 0;\n\t\n\tfor( @_ ){\n\t\t$debug and print \"    [$alphabet], \\$_:[$_]\";\n\t\t\n\t\t$alphabet =~ /(.)\\<(.)\\>(.)/;\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $_ eq $1 ){\n\t\t\t$alphabet =~ s/(.)\\<(.)\\>(.)/\\<$_\\>$2$3/;\n\t\t\t}\n\t\telsif( $_ eq $3 ){\n\t\t\t$alphabet =~ s/(.)\\<(.)\\>(.)/$1$2\\<$_\\>/;\n\t\t\t}\n\t\telsif( ',' eq $1 ){\n\t\t\t$alphabet =~ s/(.)\\<(.)\\>(.)/\\<$_\\>$2$3/;\n\t\t\t}\n\t\telsif( ',' eq $3 ){\n\t\t\t$alphabet =~ s/(.)\\<(.)\\>(.)/$1$2\\<$_\\>/;\n\t\t\t}\n\t\telse{\n\t\t\t$fail = 1;\n\t\t\tlast;\n\t\t\t}\n\t\t\n\t\tif( $alphabet =~ /([a-z]).*\\1/ ){\n\t\t\t$fail = 1;\n\t\t\tlast;\n\t\t\t}\n\t\t\n\t\t$alphabet = \",$alphabet,\";\n\t\t$alphabet =~ s/,,/,/g;\n\t\t}\n\t\n\t$alphabet =~ s/[,<>]//g;\n\t\n\tif( $fail ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint for \"YES\", $alphabet . ( join '', 'a' .. 'z' ) =~ s/[$alphabet]//gr;\n\t\t}\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\t\n\tif( 1 == length ){\n\t\tprint for \"YES\", join '', 'a' .. 'z';\n\t\tnext;\n\t\t}\n\t\n\tmy %h;\n\t\n\t/\n\t\t(.)\n\t\t(?=(.))\n\t\t(?{ $h{ join '', sort $1, $2 } ++ })\n\t\t(*FAIL)\n\t\t/x;\n\t\n\t$debug and print \":$_ --> [$h{ $_ }]\" for sort keys %h;\n\t\n\t@_ = map { [ split '' ] } sort keys %h;\n\t\n\tmy $alphabet = join '', @{ shift @_ };\n\t\n\tmy %alphabet;\n\t\n\t$alphabet{ $_ } = 0 for 'a' .. 'z';\n\t\n\tmap { $alphabet{ $_ } ++ } split '', $alphabet;\n\t\n\tmy $j = 26 ** 1 + 2;\n\t\n\twhile( @_ ){\n\t\t$j -- < 0 and last;\n\t\t\n\t\tmy $try = shift @_;\n\t\t\n\t\tif( 1 != $alphabet{ $try->[ 0 ] } + $alphabet{ $try->[ 1 ] } ){\n\t\t\tpush @_, $try;\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tmy $fail = 0;\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $alphabet =~ /^$try->[ 0 ]/ ){\n\t\t\t$alphabet = $try->[ 1 ] . $alphabet;\n\t\t\t$alphabet{ $try->[ 1 ] } ++;\n\t\t\t}\n\t\telsif( $alphabet =~ /^$try->[ 1 ]/ ){\n\t\t\t$alphabet = $try->[ 0 ] . $alphabet;\n\t\t\t$alphabet{ $try->[ 0 ] } ++;\n\t\t\t}\n\t\telsif( $alphabet =~ /$try->[ 0 ]$/ ){\n\t\t\t$alphabet .= $try->[ 1 ];\n\t\t\t$alphabet{ $try->[ 1 ] } ++;\n\t\t\t}\n\t\telsif( $alphabet =~ /$try->[ 1 ]$/ ){\n\t\t\t$alphabet .= $try->[ 0 ];\n\t\t\t$alphabet{ $try->[ 0 ] } ++;\n\t\t\t}\n\t\telse{\n\t\t\t$fail = 1;\n\t\t\t}\n\t\t\n\t\tif( $fail ){\n\t\t\tpush @_, $try;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"alphabet:[$alphabet]|\\@_:[@_]|j:[$j]\";\n\t\n\tif( $j == -2 ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint for \"YES\", $alphabet . ( join '', 'a' .. 'z' ) =~ s/[$alphabet]//gr;\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\t\n\tif( 1 == length ){\n\t\tprint for \"YES\", join '', 'a' .. 'z';\n\t\tnext;\n\t\t}\n\t\n\tmy %h;\n\t\n\t/\n\t\t(.)\n\t\t(?=(.))\n\t\t(?{ $h{ join '', sort $1, $2 } ++ })\n\t\t(*FAIL)\n\t\t/x;\n\t\n\t$debug and print \":$_ --> [$h{ $_ }]\" for sort keys %h;\n\t\n\t@_ = map { [ split '' ] } sort keys %h;\n\t\n\tmy $alphabet = join '', @{ shift @_ };\n\t\n\tmy %alphabet;\n\t\n\t$alphabet{ $_ } = 0 for 'a' .. 'z';\n\t\n\tmap { $alphabet{ $_ } ++ } split '', $alphabet;\n\t\n\tmy $j = 26 ** 1 + 2;\n\t\n\twhile( @_ ){\n\t\t$j -- < 0 and last;\n\t\t\n\t\tmy $try = shift @_;\n\t\t\n\t\tif( 2 == $alphabet{ $try->[ 0 ] } + $alphabet{ $try->[ 1 ] } ){\n\t\t\t$j = -2;\n\t\t\tlast;\n\t\t\t}\n\t\t\n\t\tif( 0 == $alphabet{ $try->[ 0 ] } + $alphabet{ $try->[ 1 ] } ){\n\t\t\tpush @_, $try;\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tmy $fail = 0;\n\t\t\n\t\tif( 0 ){ ; }\n\t\telsif( $alphabet =~ /^$try->[ 0 ]/ ){\n\t\t\t$alphabet = $try->[ 1 ] . $alphabet;\n\t\t\t$alphabet{ $try->[ 1 ] } ++;\n\t\t\t}\n\t\telsif( $alphabet =~ /^$try->[ 1 ]/ ){\n\t\t\t$alphabet = $try->[ 0 ] . $alphabet;\n\t\t\t$alphabet{ $try->[ 0 ] } ++;\n\t\t\t}\n\t\telsif( $alphabet =~ /$try->[ 0 ]$/ ){\n\t\t\t$alphabet .= $try->[ 1 ];\n\t\t\t$alphabet{ $try->[ 1 ] } ++;\n\t\t\t}\n\t\telsif( $alphabet =~ /$try->[ 1 ]$/ ){\n\t\t\t$alphabet .= $try->[ 0 ];\n\t\t\t$alphabet{ $try->[ 0 ] } ++;\n\t\t\t}\n\t\telse{\n\t\t\t$fail = 1;\n\t\t\t}\n\t\t\n\t\tif( $fail ){\n\t\t\tpush @_, $try;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"alphabet:[$alphabet]|\\@_:[@_]|j:[$j]\";\n\t\n\tif( $j == -2 ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint for \"YES\", $alphabet . ( join '', 'a' .. 'z' ) =~ s/[$alphabet]//gr;\n\t\t}\n\t}"}], "src_uid": "8fb62b497b6fb2a5fb4f2669aeb51b73"}
{"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@letters = split //, $line;\n\n$filler = \"~\";\npush @letters, $filler if @letters[$#letters] eq \",\" or @letters[$#letters] eq \";\";\n@letters = ($filler, @letters) if @letters[0] eq \",\" or @letters[0] eq \";\";\n\nfor (my $i = 0; $i <= $#letters; $i++)\n{\n    my $word = \"\";\n    my $char_flag = 0;\n    my $zero_flag = 0;\n    \n    $zero_flag = 1 if @letters[$i] eq '0'; \n     \n    while ($i <= $#letters and ',' ne @letters[$i] and ';' ne @letters[$i])\n    {\n        $char_flag = 1 if @letters[$i] gt '9' or @letters[$i] eq '.'; \n        $word .= @letters[$i];\n        $i++;\n    }\n    \n    if($char_flag == 1 or $word eq \"\" or $zero_flag == 1 and length $word > 1)\n    {\n        $b .= $word.',';\n    }\n    else\n    {\n        $a .= $word.',';\n    }\n}\n\nchop $a;\nchop $b;\n\n$a = '-' if $a eq \"\";\n$b = '-' if $b eq \"\";\n\n$b =~ s/$filler//g;\n\nprint $a eq \"-\" ? '-' : qq(\"$a\");\nprint $b eq \"-\" ? '-' : qq(\"$b\");", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t@_ = split /[,;]/, $_, -1;\n\t@nums = grep /^0$|^[1-9]\\d*$/, @_;\n\t@other = grep !/^0$|^[1-9]\\d*$/, @_;\n\t\n\tprint @nums ? (map qq[\"$_\"], join ',', @nums) : '-';\n\tprint @other ? (map qq[\"$_\"], join ',', @other) : '-';\n\t}"}, {"source_code": "$s = <>; chomp $s;\n@t = split /,|;/, $s, -1;\nforeach $t (@t) {\n\tif ($t eq \"0\" || $t =~ /^[1-9]\\d*$/) {\n\t\tpush @a, $t;\n\t} else {\n\t\tpush @b, $t;\n\t}\n}\nsub out {\n\tmy $a = shift;\n\tprint @$a? chr(34).join(\",\", @$a).chr(34): \"-\", \"\\n\";\n}\n\nout \\@a;\nout \\@b;"}, {"source_code": "$\\ = $/;\n\n$r = qr/^0$|^[1-9]\\d*$/;\n\nwhile(<>){\n\tchomp;\n\t@_ = split /[,;]/, $_, -1;\n\tw( grep  /$r/, @_ );\n\tw( grep !/$r/, @_ );\n\t}\n\t\nsub w { print !@_ ? '-' : map qq[\"$_\"], join ',', @_ }"}], "negative_code": [{"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@letters = split //, $line;\n\n$end_filler = \"~\";\npush @letters, $end_filler if @letters[$#letters] eq \",\" or @letters[$#letters] eq \";\";\n\nfor (my $i = 0; $i <= $#letters; $i++)\n{\n    my $word = \"\";\n    my $char_flag = 0;\n    my $zero_flag = 0;\n    \n    $zero_flag = 1 if @letters[$i] eq '0'; \n     \n    while ($i <= $#letters and ',' ne @letters[$i] and ';' ne @letters[$i])\n    {\n        $char_flag = 1 if @letters[$i] gt '9' or @letters[$i] eq '.'; \n        $word .= @letters[$i];\n        $i++;\n    }\n    \n    if($char_flag == 1 or $word eq \"\" or $zero_flag == 1 and length $word > 1)\n    {\n        $b .= $word.',';\n    }\n    else\n    {\n        $a .= $word.',';\n    }\n}\n\nchop $a;\nchop $b;\n\nprint $a eq \"\" ? '-' : qq(\"$a\");\nprint $b eq \"\" ? '-' : $b =~ m/(.*)$end_filler$/ ? qq(\"$1\") : qq(\"$b\");"}, {"source_code": "while(<>){\n\tchomp;\n\t@_ = split /[,;]/;\n\tprint map s/\"\"/-/r, map qq[\"$_\"\\n], join ',', grep /^0$|^[1-9]\\d*$/, @_;\n\tprint map s/\"\"/-/r, map qq[\"$_\"\\n], join ',', grep !/^0$|^[1-9]\\d*$/, @_;\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t@_ = split /[,;]/, $_, -1;\n\tprint map s/\"\"/-/r, map qq[\"$_\"\\n], join ',', grep /^0$|^[1-9]\\d*$/, @_;\n\tprint map s/\"\"/-/r, map qq[\"$_\"\\n], join ',', grep !/^0$|^[1-9]\\d*$/, @_;\n\t}"}, {"source_code": "$s = <>; chomp $s;\n@t = split /,|;/, $s, -1;\nforeach $t (@t) {\n\tif ($t eq \"0\" || $t =~ /^[1-9]\\d*$/) {\n\t\tpush @a, $t;\n\t} else {\n\t\tpush @b, $t;\n\t}\n}\nprint @a? join(\",\", @a): \"-\", \"\\n\";\nprint @b? join(\",\", @b): \"-\", \"\\n\";"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@words = split /;|,/, $line;\n\nfor my $word (@words)\n{\n    if($word =~ m/^(([1-9]+\\d*)|0)$/)\n    {\n        push @as, $word;\n    }\n    else\n    {\n        push @bs, $word;\n    }\n}\n\npush @bs, \"\" if $line =~ m/^.*,$/;\n\n$a = scalar @as > 0 ? join ',', @as : '-';\n$b = scalar @bs > 0 ? join ',', @bs : '-';\n\nprint $a;\nprint $b;"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@words = split /;|,/, $line;\n\nfor my $word (@words)\n{\n    if($word =~ m/^(([1-9]+\\d*)|0)$/)\n    {\n        push @as, $word;\n    }\n    else\n    {\n        push @bs, $word;\n    }\n}\n\npush @bs, \"\" if $line =~ m/^.*,$/;\n\n$a = scalar @as > 0 ? join ',', @as : '-';\n$b = scalar @bs > 0 ? join ',', @bs : '-';\n\n$a eq '-' ? print '-' : print \"\\\"$a\\\"\";\n$b eq '-' ? print '-' : print \"\\\"$b\\\"\";"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@letters = split //, $line;\n\nfor (my $i = 0; $i <= $#letters; $i++)\n{\n    my $word = \"\";\n    my $char_flag = 0;\n    my $zero_flag = 0;\n    \n    $zero_flag = 1 if @letters[$i] eq '0'; \n     \n    while ($i <= $#letters and ',' ne @letters[$i] and ';' ne @letters[$i])\n    {\n        $char_flag = 1 if @letters[$i] gt '9' or @letters[$i] eq '.'; \n        $word .= @letters[$i];\n        $i++;\n    }\n    \n    if($char_flag == 1 or $word eq \"\" or $zero_flag == 1 and length $word > 1)\n    {\n        $b .= $word.',';\n    }\n    else\n    {\n        $a .= $word.',';\n    }\n}\n\nchop $a;\nchop $b;\n\n$b .= \",\" if @letters[$#letters] eq \",\" or @letters[$#letters] eq \";\";\n\nprint $a eq \"\" ? '-' : qq(\"$a\");\nprint $b eq \"\" ? '-' : $b eq \",\" ? qq(\"\") : qq(\"$b\");"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@letters = split //, $line;\n\nfor (my $i = 0; $i <= $#letters; $i++)\n{\n    my $word = \"\";\n    my $char_flag = 0;\n    my $zero_flag = 0;\n    \n    $zero_flag = 1 if @letters[$i] eq '0'; \n     \n    while ($i <= $#letters and ',' ne @letters[$i] and ';' ne @letters[$i])\n    {\n        $char_flag = 1 if @letters[$i] gt '9' or @letters[$i] eq '.'; \n        $word .= @letters[$i];\n        $i++;\n    }\n    \n    if($char_flag == 1 or $word eq \"\" or $zero_flag == 1 and length $word > 1)\n    {\n        $b .= $word.',';\n    }\n    else\n    {\n        $a .= $word.',';\n    }\n}\n\nchop $a;\nchop $b;\n\n$b .= \",\" if @letters[$#letters] eq \",\" or @letters[$#letters] eq \";\";\n\nprint $a eq \"\" ? '-' : qq(\"$a\");\nprint $b eq \"\" ? '-' : qq(\"$b\");"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@words = split /;|,/, $line;\n\nfor my $word (@words)\n{\n    if($word =~ m/^(([1-9]+\\d*)|0)$/)\n    {\n        push @as, $word;\n    }\n    else\n    {\n        push @bs, $word;\n    }\n}\n\npush @bs, \"\" if $line =~ m/^.*,$/;\n\n$a = scalar @as > 0 ? join ',', @as : '-';\n$b = scalar @bs > 0 ? join ',', @bs : '-';\n\nprint \"\\\"$a\\\"\";\nprint \"\\\"$b\\\"\";"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@letters = split //, $line;\n\nfor (my $i = 0; $i <= $#letters; $i++)\n{\n    my $word = \"\";\n    my $char_flag = 0;\n    \n    $zero_flag = 1 if @letters[$i] eq '0'; \n     \n    while ($i <= $#letters and ',' ne @letters[$i] and ';' ne @letters[$i])\n    {\n        $char_flag = 1 if @letters[$i] gt '9' or @letters[$i] eq '.'; \n        $word .= @letters[$i];\n        $i++;\n    }\n    \n    if($char_flag == 1 or $word eq \"\" or $zero_flag == 1 and length $word > 1)\n    {\n        $b .= $word.',';\n    }\n    else\n    {\n        $a .= $word.',';\n    }\n}\n\nchop $a;\nchop $b;\n\n$b .= \",\" if @letters[$#letters] eq \",\" or @letters[$#letters] eq \";\";\n\nprint $a eq \"\" ? '-' : qq(\"$a\");\nprint $b eq \"\" ? '-' : qq(\"$b\");"}, {"source_code": "#!perl \n$\\ = \"\\n\";\n\n$line = <>;\nchomp $line;\n\n@letters = split //, $line;\n\nfor (my $i = 0; $i <= $#letters; $i++)\n{\n    my $word = \"\";\n    my $char_flag = 0;\n    \n    $zero_flag = 1 if @letters[$i] eq '0'; \n     \n    while ($i <= $#letters and ',' ne @letters[$i] and ';' ne @letters[$i])\n    {\n        $char_flag = 1 if @letters[$i] gt '9'; \n        $word .= @letters[$i];\n        $i++;\n    }\n    \n    if($char_flag == 1 or $word eq \"\" or $zero_flag == 1 and length $word > 1)\n    {\n        $b .= $word.',';\n    }\n    else\n    {\n        $a .= $word.',';\n    }\n}\n\nchop $a;\nchop $b;\n\n$b .= \",\" if @letters[$#letters] eq \",\" or @letters[$#letters] eq \";\";\n\nprint $a eq \"\" ? '-' : qq(\"$a\");\nprint $b eq \"\" ? '-' : qq(\"$b\");"}], "src_uid": "ad02cead427d0765eb642203d13d3b99"}
{"source_code": "\nchomp(my $n=<>);\nmy $k = $n>>1;\nprint $k**2+($n-$k)**2,\"\\n\";\n$odd = \"C.\"x$k;\n$even = \".C\"x$k;\n$odd .= \"C\" if $n&1;\n$even .= \".\" if $n&1;\n$odd .= \"\\n\";\n$even .= \"\\n\";\nfor (1..$n) {\n\tif ($_ & 1) {\n\t\tprint $odd;\n\t} else {\n\t\tprint $even;\n\t}\t\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n$ans = (($n+1)>>1)*(($n+1)>>1) + ($n>>1)*($n>>1);\nforeach (1 .. $n) {\n\tif ($_ & 1) {\n\t\t$l1 .= 'C';\n\t\t$l2 .= '.';\n\t} else {\n\t\t$l2 .= 'C';\n\t\t$l1 .= '.';\n\t}\n}\nsay $ans;\nforeach (1 .. $n) {\n\tif ($_ & 1) {\n\t\tsay $l1;\n\t} else {\n\t\tsay $l2;\n\t}\n}"}, {"source_code": "chomp($_=<>);\n$a=(\"C.\"x($_/2)).(\"C\"x($_%2)).\"\\n\";\n$b=(\".C\"x($_/2)).(\".\"x($_%2)).\"\\n\";\n$c=($_**2 + $_**2 %2) /2;\nprint \"$c\\n\";\nfor (1..$_){\nprint $_%2 ? $a:$b\n}"}, {"source_code": "# nEro\n$n=<STDIN>;\nif($n%2)\n{\n$n--,$k=$n/2,$n++;\n}\nelse{$k=$n/2;}\n$n%2?print $k**2+($k+1)**2:print $k*$n;\nfor($i=0;$i<$n;$i++)\n{\n\tprint \"\\n\";\n\tif($i%2){\n\t\t$s=\".C\";\n\t\tprint ($s x $k);\n\t\tif($n%2) {print \".\";}\n\t}\n\telse{\n\t\t$s=\"C.\";\n\t\tprint ($s x $k);\n\t\tif($n%2) {print \"C\";}\n\t}\n}"}, {"source_code": "my $n = int<>;\nmy $str = \"C.\" x int($n/2) . \"C\" x ($n%2);\nmy $str2 = \".C\" x int($n/2) . \".\" x ($n%2);\nmy $pr = $str . \"\\n\" . $str2 . \"\\n\";\nprint $n * int($n / 2) + (int($n/2)+1)*($n%2) . \"\\n\";\nprint $pr x int($n/2) . $str x ($n % 2) . \"\\n\";"}], "negative_code": [{"source_code": "# nEro\n$n=<STDIN>;\n$k=$n/2;\n$n%2?print $k**2+($k+1)**2:print $k*$n;\nfor($i=0;$i<$n;$i++)\n{\n\tprint \"\\n\";\n\tif($i%2){\n\t\t$s=\".C\";\n\t\tprint ($s x $k);\n\t\tif($n%2) {print \".\";}\n\t}\n\telse{\n\t\t$s=\"C.\";\n\t\tprint ($s x $k);\n\t\tif($n%2) {print \"C\";}\n\t}\n}"}, {"source_code": "my $n = int<>;\nmy $str = \"C.\" x int($n/2) . \"C\" x ($n%2);\nmy $str2 = \".C\" x int($n/2) . \".\" x ($n%2);\nmy $pr = $str . \"\\n\" . $str2 . \"\\n\";\nprint $pr x int($n/2) . $str x ($n % 2) . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\nforeach (1 .. $n) {\n\tif ($_ & 1) {\n\t\t$l1 .= 'C';\n\t\t$l2 .= '.';\n\t} else {\n\t\t$l2 .= 'C';\n\t\t$l1 .= '.';\n\t}\n}\nforeach (1 .. $n) {\n\tif ($_ & 1) {\n\t\tsay $l1;\n\t} else {\n\t\tsay $l2;\n\t}\n}"}], "src_uid": "1aede54b41d6fad3e74f24a6592198eb"}
{"source_code": "while(<>){\n\t\n\t$max = (sort {$b <=> $a} split)[0];\n\t$cmax = () = /\\b$max\\b/g;\n\t\n\t$area = eval join '+', map { eval join '*', split } @groups = /\\d+ \\d+/g;\n\t\n\t$area == $max ** 2 and $cmax =~ /[13]/ or do { print -1; next };\n\n\t$letter = 'A';\n\t\n\tprint join \"\\n\", $max, \n\t\t$cmax == 3 ? \n\t\tdo {\n\t\t\tmap { ( $letter ++ x $max ) x $_ } grep !/\\b$max\\b/, split\n\t\t\t}\n\t\t:\n\t\tdo {\n\t\t\t($wide2) = grep $max != $_, split ' ', join '', grep /\\b$max\\b/, @groups;\n\t\t\t$wide1 = $max - $wide2;\n\t\t\t\n\t\t\t$pre = join \"\\n\", map { s/ ?\\b$wide1\\b ?//; ( $letter ++ x $wide1 . 'C' x $wide2 ) x $_ } \n\t\t\t\tgrep !/\\b$max\\b/, @groups;\n\t\t\t\n\t\t\t$groups[0] =~ /\\b$max\\b/ and $pre =~ y/ABC/BCA/;\n\t\t\t$groups[1] =~ /\\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t\t\n\t\t\t$pre\n\t\t}\n}", "positive_code": [{"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|}\n        = ( sort { $b <=> $a } $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, map { $_->{x} * $_->{y} } values %{$logos};\n\nif ( $sqrt != int($sqrt) ) {\n    say -1;\n    exit;\n}\n\nmy $banner = [];\nmy $n      = -( scalar keys %{$logos} );\n\nwhile (1) {\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            $banner->[$y][$x] = '0';\n        }\n    }\n    for my $logo ( sort {$n} keys %{$logos} ) {\n        my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n        my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n            or last;\n\n        ( $width, $height ) = ( $height, $width ) if $rotate;\n\n        for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n            for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n                $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n            }\n        }\n    }\n    if ( grep {/0/} map { @$_ ? @$_ : () } @{$banner} ) {\n        if ( $n++ >= scalar keys %{$logos} ) {\n            say -1;\n            exit;\n        }\n        next;\n    }\n    last;\n}\n\nsay $sqrt;\nsay join q{}, @$_ for @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n    my $_sqrt = scalar @{$matrix};\n\n    for ( my $y = 0; $y < $_sqrt; $y++ ) {\n        for ( my $x = 0; $x < $_sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                for ( 0 .. $_width - 1 ) {\n                    return if $x + $_ >= $_sqrt;\n                    next   if $matrix->[$y][ $x + $_ ] !~ /0/;\n                }\n\n                for ( 0 .. $_height - 1 ) {\n                    return if $y + $_ >= $_sqrt;\n                    next   if $matrix->[ $y + $_ ][$x] !~ /0/;\n                }\n                return 1;\n            };\n\n            if ( $matrix->[$y][$x] =~ /0/ ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|}\n        = ( sort { $b <=> $a } $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, map { $_->{x} * $_->{y} } values %{$logos};\n\nif ( $sqrt != int($sqrt) ) {\n    say -1;\n    exit;\n}\n\nmy $banner = [];\nmy $n      = -1;\n\nwhile (1) {\n    push @{$banner}, [ (undef) x $sqrt ] for 1 .. $sqrt;\n    for my $logo ( sort {$n} keys %{$logos} ) {\n        my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n        my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n            or last;\n\n        ( $width, $height ) = ( $height, $width ) if $rotate;\n\n        for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n            for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n                $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n            }\n        }\n    }\n    if ( grep { !defined } map { @$_ ? @$_ : () } @{$banner} ) {\n        if ( $n++ >= 1 ) {\n            say -1;\n            exit;\n        }\n        undef $banner;\n        next;\n    }\n    last;\n}\n\nsay $sqrt;\nsay q{}, @$_ for @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n    my $_sqrt = scalar @{$matrix};\n\n    for ( my $y = 0; $y < $_sqrt; $y++ ) {\n        for ( my $x = 0; $x < $_sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                for ( 0 .. $_width - 1 ) {\n                    return if $x + $_ >= $_sqrt;\n                    next   if defined $matrix->[$y][ $x + $_ ];\n                }\n\n                for ( 0 .. $_height - 1 ) {\n                    return if $y + $_ >= $_sqrt;\n                    next   if defined $matrix->[ $y + $_ ][$x];\n                }\n                return 1;\n            };\n\n            if ( !defined $matrix->[$y][$x] ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "#!perl\n$\\ = \"\\n\";\n\n@a = split /\\s/, <>;\n\n$side = sqrt(@a[0]*@a[1] + @a[2]*@a[3] + @a[4]*@a[5]);\n\nif($side - int($side) == 0)\n{\n    for my $i (0, 2, 4)\n    {\n        (@a[$i], @a[$i + 1]) = @a[$i] < @a[$i + 1] ? (@a[$i], @a[$i + 1]) : (@a[$i + 1], @a[$i]);\n    }\n    \n    if(@a[1] == @a[3] and @a[3] == @a[5] and @a[1] == @a[0] + @a[2] + @a[4])\n    {\n        @result = ([@a[0], @a[1], 'A'],  [@a[2], @a[3], 'B'], [@a[4], @a[5], 'C']);\n        $case = 1;\n    }\n    else\n    {\n        @tringles = sort {@{$a}[1] <=> @{$b}[1]} ([@a[0], @a[1], 'A'],  [@a[2], @a[3], 'B'], [@a[4], @a[5], 'C']);\n        \n        if(@{@tringles[2]}[1] == $side)\n        {\n            for my $position ([0, 0, 1, 1], [0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 0])\n            {\n                (my $i, my $j, my $k, my $l) = @{$position};\n                \n                if(@{@tringles[0]}[$i] == @{@tringles[1]}[$j] \n                   and @{@tringles[0]}[$k] + @{@tringles[1]}[$l] == $side\n                   and @{@tringles[0]}[$i] + @{@tringles[2]}[0] == $side)\n                {\n                    @result = (@tringles[2],  \n                              [@{@tringles[0]}[$i], @{@tringles[0]}[$k], @{@tringles[0]}[2]], \n                              [@{@tringles[0]}[$j], @{@tringles[1]}[$l], @{@tringles[1]}[2]]);\n                    $case = 2;\n                    last;\n                }\n            }\n        }\n    }\n    \n    if(@result)\n    {\n        print $side;\n        \n        if($case == 1)\n        {\n            for my $triangle (@result)\n            {\n                for (1..@{$triangle}[0])\n                {\n                    print @{$triangle}[2]x$side;\n                }\n            }\n        }\n        else\n        {\n            for (1..@{@result[0]}[0])\n            {\n                print @{@result[0]}[2]x$side;\n            }\n                \n            for my $i (1..@{@result[1]}[0])\n            {\n                print @{@result[1]}[2]x@{@result[1]}[1].@{@result[2]}[2]x@{@result[2]}[1];\n            }\n        }\n    }\n    else\n    {\n        print -1;\n    }\n}\nelse\n{\n    print -1;\n}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@s = sort {$b <=> $a} split;\n\t($max, $min) = @s[0,-1];\n\t$cmax = () = /\\b$max\\b/g;\n\n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n\n\t$area = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\n\t$area == $max ** 2 or do { print -1; next };\n\n\t%hash = ();\n\tmap { ++ $hash{ $_ } } split;\n\t(join ' ', values %hash) =~ /[46]/ and do { print -1; next };\n\t\n\t$let = 'A';\n\t\n\t$cmax == 3 ? \n\tdo {\n\t\ts/\\b$max\\b//g;\n\t\t(eval join '+', split) == $max or do { print -1; next };\n\t\t\n\t\tprint join \"\\n\", $max , map { ( $let ++ x $max ) x $_ } split;\n\t\t}\n\t:\n\tdo {\n\t\t$cmax == 1 or do { print -1; next }; \n\t\t\n\t\t($bemax = $_) =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide2 = $1;\n\t\t$wide1 = $max - $wide2;\n\t\t\n\t\t$pre = join \"\\n\", map { s/ ?\\b$wide1\\b ?//; ( $let ++ x $wide1 ) x $_ } $bemax =~ /\\d+ \\d+/g;\n\t\t\n\t\t$pre =~ s/$/ 'C' x $wide2 /gem;\n\t\t\n\t\t/^$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ $max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t\n\t\tprint join \"\\n\", $max, $pre;\n\t\n\t}\n}"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|}\n        = ( sort { $b <=> $a } $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, map { $_->{x} * $_->{y} } values %{$logos};\n\nif ( $sqrt != int($sqrt) ) {\n    say -1;\n    exit;\n}\n\nmy $banner = [];\nmy $n      = -( scalar keys %{$logos} );\n\nwhile (1) {\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            $banner->[$y][$x] = '0';\n        }\n    }\n    for my $logo ( sort {$n} keys %{$logos} ) {\n        my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n        my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n            or last;\n\n        ( $width, $height ) = ( $height, $width ) if $rotate;\n\n        for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n            for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n                $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n            }\n        }\n    }\n    if ( grep {/0/} map { @$_ ? @$_ : () } @{$banner} ) {\n        if ( $n++ >= scalar keys %{$logos} ) {\n            say -1;\n            exit;\n        }\n        undef $banner;\n        next;\n    }\n    last;\n}\n\nsay $sqrt;\nsay join q{}, @$_ for @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n    my $_sqrt = scalar @{$matrix};\n\n    for ( my $y = 0; $y < $_sqrt; $y++ ) {\n        for ( my $x = 0; $x < $_sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                for ( 0 .. $_width - 1 ) {\n                    return if $x + $_ >= $_sqrt;\n                    next   if $matrix->[$y][ $x + $_ ] !~ /0/;\n                }\n\n                for ( 0 .. $_height - 1 ) {\n                    return if $y + $_ >= $_sqrt;\n                    next   if $matrix->[ $y + $_ ][$x] !~ /0/;\n                }\n                return 1;\n            };\n\n            if ( $matrix->[$y][$x] =~ /0/ ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}], "negative_code": [{"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|}\n        = ( sort { $b <=> $a } $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, map { $_->{x} * $_->{y} } values %{$logos};\n\nif ( $sqrt != int($sqrt) ) {\n    say -1;\n    exit;\n}\n\nmy $banner = [];\nmy $n      = -( scalar keys %{$logos} );\n\nwhile (1) {\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            $banner->[$y][$x] = '0';\n        }\n    }\n    for my $logo ( sort { $n++ } sort keys %{$logos} ) {\n        my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n        my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n            or last;\n\n        ( $width, $height ) = ( $height, $width ) if $rotate;\n\n        for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n            for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n                $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n            }\n        }\n    }\n    if ( grep {/0/} map { @$_ ? @$_ : () } @{$banner} ) {\n        if ( $n >= scalar keys %{$logos} ) {\n            say -1;\n            exit;\n        }\n        next;\n    }\n    last;\n}\n\nsay $sqrt;\nsay join q{}, @$_ for @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n    my $_sqrt = scalar @{$matrix};\n\n    for ( my $y = 0; $y < $_sqrt; $y++ ) {\n        for ( my $x = 0; $x < $_sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                for ( 0 .. $_width - 1 ) {\n                    return if $x + $_ >= $_sqrt;\n                    next   if $matrix->[$y][ $x + $_ ] !~ /0/;\n                }\n\n                for ( 0 .. $_height - 1 ) {\n                    return if $y + $_ >= $_sqrt;\n                    next   if $matrix->[ $y + $_ ][$x] !~ /0/;\n                }\n                return 1;\n            };\n\n            if ( $matrix->[$y][$x] =~ /0/ ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\n# my @input  = split / /, <>;\nmy @input = qw(1 2 2 4 3 2);\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|} = ( $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, ( map { $_->{x} * $_->{y} } values %{$logos} );\nif ( $sqrt - int($sqrt) ) {\n    say -1;\n    exit 1;\n}\n\nmy $banner = [];\n\nfor ( my $y = 0; $y < $sqrt; $y++ ) {\n    for ( my $x = 0; $x < $sqrt; $x++ ) {\n        $banner->[$y][$x] = 0;\n    }\n}\n\nfor my $logo ( keys %{$logos} ) {\n    my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n    my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n        or next;\n\n    ( $width, $height ) = ( $height, $width ) if $rotate;\n    say $logo, $rotate//0;\n\n    for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n        for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n            $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n        }\n    }\n}\n\nsay $sqrt;\n\nsay join q{}, @$_ for map { @$_ ? $_ : () } @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                my ( $success, $width_success );\n                for ( 0 .. $_width - 1 ) {\n                    if ( !defined $matrix->[$y][ $x + $_ ] ) {\n                        $width_success = 0;\n                        last;\n                    }\n                    next if $matrix->[$y][ $x + $_ ] ne 0;\n                    $width_success++;\n                }\n\n                if ($width_success) {\n                    for ( 0 .. $_height - 1 ) {\n                        if ( !defined $matrix->[ $y + $_ ][$x] ) {\n                            $success = 0;\n                            last;\n                        }\n                        next if $matrix->[ $y + $_ ][$x] ne 0;\n                        $success++;\n                    }\n                }\n                return $success;\n            };\n\n            if ( $matrix->[$y][$x] eq 0 ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n                elsif ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|} = ( $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, ( map { $_->{x} * $_->{y} } values %{$logos} );\nif ( $sqrt - int($sqrt) ) {\n    say -1;\n    exit 1;\n}\n\nmy $banner = [];\n\nfor ( my $y = 0; $y < $sqrt; $y++ ) {\n    for ( my $x = 0; $x < $sqrt; $x++ ) {\n        $banner->[$y][$x] = 0;\n    }\n}\n\nfor my $logo ( keys %{$logos} ) {\n    my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n    my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n        or next;\n\n    ( $width, $height ) = ( $height, $width ) if $rotate;\n\n    for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n        for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n            $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n        }\n    }\n}\n\nsay $sqrt;\n\nsay join q{}, @$_ for map { @$_ ? $_ : () } @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                my ( $success, $width_success );\n                for ( 0 .. $_width - 1 ) {\n                    if ( !defined $matrix->[$y][ $x + $_ ] ) {\n                        $width_success = 0;\n                        last;\n                    }\n                    next if $matrix->[$y][ $x + $_ ] ne 0;\n                    $width_success++;\n                }\n\n                if ($width_success) {\n                    for ( 0 .. $_height - 1 ) {\n                        if ( !defined $matrix->[ $y + $_ ][$x] ) {\n                            $success = 0;\n                            last;\n                        }\n                        next if $matrix->[ $y + $_ ][$x] ne 0;\n                        $success++;\n                    }\n                }\n                return $success;\n            };\n\n            if ( $matrix->[$y][$x] eq 0 ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n                elsif ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|} = ( $x, $y );\n}\nmy $sqrt = sqrt eval join q{+},\n    ( map { $_->{x} * $_->{y} } values %{$logos} );\nif ( $sqrt - int($sqrt) ) {\n    say -1;\n    exit 1;\n}\n\nmy $banner = [];\n\nLOOP: while (1) {\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            $banner->[$y][$x] = '0';\n        }\n    }\n\n    for my $logo ( sort { int( rand(3) ) - 1 } keys %{$logos} ) {\n        my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n        my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n            or next LOOP;\n\n        ( $width, $height ) = ( $height, $width ) if $rotate;\n\n        for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n            for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n                $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n            }\n        }\n    }\n\n    last;\n}\n\nsay $sqrt;\n\nsay join q{}, @$_ for map { @$_ ? $_ : () } @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                my ( $success, $width_success );\n                for ( 0 .. $_width - 1 ) {\n                    if ( !defined $matrix->[$y][ $x + $_ ] ) {\n                        $width_success = 0;\n                        last;\n                    }\n                    if ( $matrix->[$y][ $x + $_ ] ne '0' ) {\n                        $width_success = 0;\n                        next;\n                    }\n                    $width_success++;\n                }\n\n                if ($width_success) {\n                    for ( 0 .. $_height - 1 ) {\n                        if ( !defined $matrix->[ $y + $_ ][$x] ) {\n                            $success = 0;\n                            last;\n                        }\n                        if ( $matrix->[ $y + $_ ][$x] ne '0' ) {\n                            $success = 0;\n                            next;\n                        }\n                        $success++;\n                    }\n                }\n                return $success;\n            };\n\n            if ( $matrix->[$y][$x] eq '0' ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|}\n        = ( sort { $b <=> $a } $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+}, map { $_->{x} * $_->{y} } values %{$logos};\n\nif ( $sqrt != int($sqrt) ) {\n    say -1;\n    exit;\n}\n\nmy $banner = [];\nmy $n      = -( scalar keys %{$logos} );\n\nwhile (1) {\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            $banner->[$y][$x] = '0';\n        }\n    }\n\n    for my $logo ( sort { $n++ } keys %{$logos} ) {\n        my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n        my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n            or last;\n\n        ( $width, $height ) = ( $height, $width ) if $rotate;\n\n        for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n            for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n                $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n            }\n        }\n    }\n    if ( grep {/0/} map { @$_ ? @$_ : () } @{$banner} ) {\n        if ( $n = scalar keys %{$logos} ) {\n            say -1;\n            exit;\n        }\n        next;\n    }\n    last;\n}\n\nsay $sqrt;\nsay join q{}, @$_ for @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n    my $_sqrt = scalar @{$matrix};\n\n    for ( my $y = 0; $y < $_sqrt; $y++ ) {\n        for ( my $x = 0; $x < $_sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                for ( 0 .. $_width - 1 ) {\n                    return if $x + $_ >= $_sqrt;\n                    next   if $matrix->[$y][ $x + $_ ] !~ /0/;\n                }\n\n                for ( 0 .. $_height - 1 ) {\n                    return if $y + $_ >= $_sqrt;\n                    next   if $matrix->[ $y + $_ ][$x] !~ /0/;\n                }\n                return 1;\n            };\n\n            if ( $matrix->[$y][$x] =~ /0/ ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|} = sort { $b <=> $a } ( $x, $y );\n}\nmy $sqrt = sqrt eval join q{+},\n    ( map { $_->{x} * $_->{y} } values %{$logos} );\nif ( $sqrt - int($sqrt) ) {\n    say -1;\n    exit 1;\n}\n\nmy $banner = [];\n\nfor ( my $y = 0; $y < $sqrt; $y++ ) {\n    for ( my $x = 0; $x < $sqrt; $x++ ) {\n        $banner->[$y][$x] = '0';\n    }\n}\n\nfor my $logo (keys %{$logos}) {\n    my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n    my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n        or next;\n\n    ( $width, $height ) = ( $height, $width ) if $rotate;\n\n    for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n        for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n            $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n        }\n    }\n}\n\nsay $sqrt;\n\nsay join q{}, @$_ for map { @$_ ? $_ : () } @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                my ( $success, $width_success );\n                for ( 0 .. $_width - 1 ) {\n                    if ( !defined $matrix->[$y][ $x + $_ ] ) {\n                        $width_success = 0;\n                        last;\n                    }\n                    if ( $matrix->[$y][ $x + $_ ] ne '0' ) {\n                        $width_success = 0;\n                        next;\n                    }\n                    $width_success++;\n                }\n\n                if ($width_success) {\n                    for ( 0 .. $_height - 1 ) {\n                        if ( !defined $matrix->[ $y + $_ ][$x] ) {\n                            $success = 0;\n                            last;\n                        }\n                        if ( $matrix->[ $y + $_ ][$x] ne '0' ) {\n                            $success = 0;\n                            next;\n                        }\n                        $success++;\n                    }\n                }\n                return $success;\n            };\n\n            if ( $matrix->[$y][$x] eq '0' ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|} = ( $x, $y );\n}\n\nmy $sqrt = sqrt eval join q{+},\n    ( map { $_->{x} * $_->{y} } values %{$logos} );\nif ( $sqrt - int($sqrt) ) {\n    say -1;\n    exit 1;\n}\n\nmy $banner = [];\n\nfor ( my $y = 0; $y < $sqrt; $y++ ) {\n    for ( my $x = 0; $x < $sqrt; $x++ ) {\n        $banner->[$y][$x] = '0';\n    }\n}\n\nfor my $logo ( keys %{$logos} ) {\n    my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n    my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n        or next;\n\n    ( $width, $height ) = ( $height, $width ) if $rotate;\n\n    for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n        for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n            $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n        }\n    }\n}\n\nsay $sqrt;\n\nsay join q{}, @$_ for map { @$_ ? $_ : () } @{$banner};\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                my ( $success, $width_success );\n                for ( 0 .. $_width - 1 ) {\n                    if ( !defined $matrix->[$y][ $x + $_ ] ) {\n                        $width_success = 0;\n                        last;\n                    }\n                    if ( $matrix->[$y][ $x + $_ ] ne '0' ) {\n                        $width_success = 0;\n                        next;\n                    }\n                    $width_success++;\n                }\n\n                if ($width_success) {\n                    for ( 0 .. $_height - 1 ) {\n                        if ( !defined $matrix->[ $y + $_ ][$x] ) {\n                            $success = 0;\n                            last;\n                        }\n                        if ( $matrix->[ $y + $_ ][$x] ne '0' ) {\n                            $success = 0;\n                            next;\n                        }\n                        $success++;\n                    }\n                }\n                return $success;\n            };\n\n            if ( $matrix->[$y][$x] eq 0 ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n\n                if ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings FATAL => 'all';\n\nmy @input  = split / /, <>;\nmy $logos  = {};\nmy $letter = 'A';\n\nwhile ( my ( $x, $y ) = splice @input, 0, 2 ) {\n    @{ $logos->{ $letter++ } }{qw|x y|} = ( $x, $y );\n}\n\nmy $sqrt = sqrt sum( map { $_->{x} * $_->{y} } values %{$logos} );\nif ( $sqrt - int($sqrt) ) {\n    say -1;\n    exit 1;\n}\n\nmy $banner = [];\n\nfor ( my $y = 0; $y < $sqrt; $y++ ) {\n    for ( my $x = 0; $x < $sqrt; $x++ ) {\n        $banner->[$y][$x] = 0;\n    }\n}\n\nfor my $logo ( sort keys %{$logos} ) {\n    my ( $width, $height ) = @{ $logos->{$logo} }{qw|x y|};\n    my ( $os_x, $os_y, $rotate ) = find_area( $banner, $width, $height )\n        or next;\n\n    ( $width, $height ) = ( $height, $width ) if $rotate;\n\n    for ( my $cur_y = 0; $cur_y < $height; $cur_y++ ) {\n        for ( my $cur_x = 0; $cur_x < $width; $cur_x++ ) {\n            $banner->[ $os_y + $cur_y ][ $os_x + $cur_x ] = $logo;\n        }\n    }\n}\n\nsay $sqrt;\n\nsay join q{}, @$_ for map { @$_ ? $_ : () } @{$banner};\n\nsub sum {\n    my $sum;\n    $sum += $_ for @_;\n    return $sum;\n}\n\nsub find_area {\n    my ( $matrix, $width, $height ) = @_;\n\n    for ( my $y = 0; $y < $sqrt; $y++ ) {\n        for ( my $x = 0; $x < $sqrt; $x++ ) {\n            my $paste = sub {\n                my ( $_width, $_height ) = @_;\n                my ( $success, $width_success );\n                for ( 0 .. $_width - 1 ) {\n                    if ( !defined $matrix->[$y][ $x + $_ ] ) {\n                        $width_success = 0;\n                        last;\n                    }\n                    next if $matrix->[$y][ $x + $_ ] ne 0;\n                    $width_success++;\n                }\n\n                if ($width_success) {\n                    for ( 0 .. $_height - 1 ) {\n                        if ( !defined $matrix->[ $y + $_ ][$x] ) {\n                            $success = 0;\n                            last;\n                        }\n                        next if $matrix->[ $y + $_ ][$x] ne 0;\n                        $success++;\n                    }\n                }\n                return $success;\n            };\n\n            if ( $matrix->[$y][$x] eq 0 ) {\n                if ( $paste->( $width, $height ) ) {\n                    return $x, $y;\n                }\n                elsif ( $paste->( $height, $width ) ) {\n                    return $x, $y, 1;\n                }\n            }\n        }\n    }\n    return;\n}\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\tprint;\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$f = 0;\n\t$_ > 3 and $f ++  for values %h;\n\t$f and do { print -1; next }; \n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\t\n\t/(\\b\\d+\\b).{2,}\\1.{2,}\\1/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$_ > 3 and do { print -1; next } for values %h;\n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\t\n\t/(\\b\\d+\\b).{2,}\\1.{2,}\\1/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n#\tprint;\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$f = 0;\n\t$_ > 3 and $f ++  for values %h;\n\t$f and do { print -1; next }; \n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\t\n\t/(\\b\\d+\\b).{2,}\\1.{2,}\\1/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n#\tprint;\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$f = 0;\n\t$_ > 3 and $f ++  for values %h;\n\t$f and do { print -1; next }; \n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\t\n\t/(\\d+).{2,}\\b\\1\\b.{2,}\\b\\1\\b/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t$max = (sort {$b <=> $a} split)[0];\n\t$sum == $max ** 2 or do { print -1; next };\n\t\n#\tprint;\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$f = 0;\n\t$_ =~ /[46]/ and $f ++  for values %h;\n\t$f and do { print -1; next }; \n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\n\t$g = 0;\n\t$_ == 5 and $g ++  for values %h;\n\t$g and do {\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t/\\b$max $max\\b/ and do { print -1; next }; \n\t\t$min = (sort {$b <=> $a} split)[1];\n\t\t$min * 2 == $max or do { print -1; next };\n\t\t\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ($let x $min) x $min , (++ $let x $min) x $min;\n\t\t$pre =~ s/$/ 'C' x $min /gems;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\tnext;\n\t\t};\n\t\n\t/\\b(\\d+)\\b.{2,}\\b\\1\\b.{2,}\\b\\1\\b/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n#\tprint;\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$f = 0;\n\t$_ =~ /[46]/ and $f ++  for values %h;\n\t$f and do { print -1; next }; \n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\n\t$g = 0;\n\t$_ == 5 and $g ++  for values %h;\n\t$g and do {\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t/\\b$max $max\\b/ and do { print -1; next }; \n\t\t$min = (sort {$b <=> $a} split)[1];\n\t\t$min * 2 == $max or do { print -1; next };\n\t\t\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ($let x $min) x $min , (++ $let x $min) x $min;\n\t\t$pre =~ s/$/ 'C' x $min /gems;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\tnext;\n\t\t};\n\t\n\t/(\\d+).{2,}\\b\\1\\b.{2,}\\b\\1\\b/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\t\n\t/(\\b\\d+\\b).{2,}\\1.{2,}\\1/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n#\tprint;\n\t%h = ();\n\tmap { ++ $h{ $_ } } split;\n\t$f = 0;\n\t$_ =~ /[46]/ and $f ++  for values %h;\n\t$f and do { print -1; next }; \n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n#\tprint;\n\n\t$g = 0;\n\t$_ == 5 and $g ++  for values %h;\n\t$g and do {\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t/\\b$max $max\\b/ and do { print -1; next }; \n\t\t$min = (sort {$b <=> $a} split)[1];\n\t\t$min * 2 == $max or do { print -1; next };\n\t\t\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ($let x $min) x $min , (++ $let x $min) x $min;\n\t\t$pre =~ s/$/ 'C' x $min /gems;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\tnext;\n\t\t};\n\t\n\t/\\b(\\d+)\\b.{2,}\\b\\1\\b.{2,}\\b\\1\\b/ ? \n\tdo {\n\t\t$del = $1;\n\t\ts/\\b$del\\b//g;\n\t\t$sum = eval join '+', split;\n\t\t$sum == $del or do { print -1; next }; \n\t\t$let = 'A';\n\t\tprint join \"\\n\", $del , map { ( $let ++x $del ) x $_ } split;\n\t\t\n\t\t}\n\t:\n\tdo {\n\t\t(eval join '==', (sort {$b <=> $a} split)[0 .. 1]) and do { print -1; next }; \n\t\t$sum = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\t$max = (sort {$b <=> $a} split)[0];\n\t\t$sum == $max ** 2 or do { print -1; next };\n\t\t$bemax = $_;\n\t\t$bemax =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide = $1;\n#\t\tprint $bemax;\n\t\t$let = 'A';\n\t\t$pre = join \"\\n\", ( $let x ($max - $wide) ) x (split ' ', $bemax)[1] ,\n\t\t\t( ++ $let x ($max - $wide) ) x (reverse split ' ', $bemax)[0];\n#\t\tprint $pre;\n\t\t$pre =~ s/$/ 'C' x $wide /gems;\n#\t\tprint $pre;\n\t\t\n\t\t/^\\b$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ \\b$max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t/\\b$max\\b \\d+$/     and $pre =~ y/ABC/ABC/;\n\t\t\n\t\tprint $max, \"\\n\", $pre;\n\t\t}\n\t\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@s = sort {$b <=> $a} split;\n\t($max, $min) = @s[0,-1];\n\t$cmax = () = /\\b$max\\b/g;\n\n\ts/(\\d+) (\\d+)/ join ' ', sort {$b <=> $a} @_ = ($1, $2) /ge;\n\n\t$area = eval join '+', map { eval join '*', split } /\\d+ \\d+/g;\n\t\n\t$area == $max ** 2 or do { print -1; next };\n\n\t%hash = ();\n\tmap { ++ $hash{ $_ } } split;\n\t(join ' ', values %hash) =~ /[46]/ and do { print -1; next };\n\t\n\t$let = 'A';\n\t\n\t$cmax == 3 ? \n\tdo {\n\t\ts/\\b$max\\b//g;\n\t\t(eval join '+', split) == $max or do { print -1; next };\n\t\t\n\t\tprint join \"\\n\", $max , map { ( $let ++ x $max ) x $_ } split;\n\t\t}\n\t:\n\tdo {\n\t\t$cmax == 1 or do { print -1; next }; \n\t\t\n\t\t($bemax = $_) =~ s/\\b$max\\b (\\d+) ?//;\n\t\t$wide2 = $1;\n\t\t$wide1 = $max - $wide2;\n\t\t\n\t\t$bemax =~ s/\\b$wide1\\b// for 1 .. 2;\n\t\t\n\t\t$pre = join \"\\n\", map { ( $let ++ x $wide1 ) x $_ } split ' ', $bemax;\n\t\t\n\t\t$pre =~ s/$/ 'C' x $wide2 /gem;\n\t\t\n\t\t/^$max\\b/         and $pre =~ y/ABC/BCA/;\n\t\t/^\\d+ \\d+ $max\\b/ and $pre =~ y/ABC/ACB/;\n\t\t\n\t\tprint join \"\\n\", $max, $pre;\n\t\n\t}\n}"}], "src_uid": "2befe5da2df57d23934601cbe4d4f151"}
{"source_code": "use 5.020;\nuse warnings;\nuse utf8;\n\nsub readNext {\n    my $line = <STDIN>;\n    chomp($line);\n    return $line;\n}\n\nmy $count = int( &readNext() );\n\nREAD: while ($count) {\n\n    my @a = split //, &readNext();\n    my @b = split //, &readNext();\n    my @c = split //, &readNext();\n\n    $count--;\n\n    foreach ( 0 .. $#a ) {\n        if ( $a[$_] eq $c[$_] || $b[$_] eq $c[$_] ) {\n            next;\n        }\n        else {\n            say \"NO\";\n            next READ;\n        }\n    }\n\n    say \"YES\";\n}\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $A = $_;\n\tmy $B = <>;\n\tmy $C = <>;\n\t\n\tchomp for $A, $B, $C;\n\t\n\tmy $fail = 0;\n\t\n\tfor my $i ( 0 .. -1 + length $A ){\n\t\tmy $cA = substr $A, $i, 1;\n\t\tmy $cB = substr $B, $i, 1;\n\t\tmy $cC = substr $C, $i, 1;\n\t\t\n\t\tif( not( $cA eq $cC || $cB eq $cC ) ){\n\t\t\t$fail = 1;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tprint $fail ? \"NO\" : \"YES\";\n\t}"}], "negative_code": [], "src_uid": "08679e44ee5d3c3287230befddf7eced"}
{"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge", "positive_code": [{"source_code": "<>;\nwhile(<>){\n  chomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n    $t=sprintf(\"%04s\",$1);\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n  }\n  $cnt = 0;\n  ++$cnt while /(?>:|^)([^:]{4})(?=:|$)/g;\n  s/::/\":0000:\"x(8-$cnt)/e;\n  s/::/:/g;\n  s/^:|:$//g;\n  print\"$_\\n\";\n}\n"}, {"source_code": "<>;\nwhile(<>){\nchomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n    $t=sprintf(\"%04s\",$1);\n#print \"t->$t<\\n\";\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n#print \"now=$_\\n\";\n#sleep 3;\n  }\n  $cnt = 0;\n  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n    ++$cnt;\n  }\n  s/::/\":0000:\"x(8-$cnt)/e;\n#print \"$_\\n\";\n  s/::/:/g;\n  s/^:|:$//g;\n  print \"$_\\n\";\n}\n"}, {"source_code": "#!perl -p\nINIT{<>}$n=y/:/:/;s/::/':'x(9-$n)/e;s/^|:/$&0000/g;s/\\w*(\\w{4}\\W)/$1/g;\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/^|:/$&0000/g;s/\\w*(\\w{4}\\W)/$1/g;"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge"}, {"source_code": "#!perl -p\nINIT{<>}$n=y/:/:/;s/::/':'x(9-$n)/e;s/^|:/$&0000/g;s/\\w*(\\w{4}\\W)/$1/g;"}, {"source_code": "#!perl -p\nINIT{<>}$:=y/:/:/;s/::/':'x(9-$:)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -pl\nINIT{$_ = <>}$:=y/:/:/;s/::/':'x(9-$:)/e if/::/;s/(?<!\\w)\\w*/'0'x(4-length$&).$&/ge\n"}, {"source_code": "#!perl -p\nINIT{$_=<>}$:=y/:/:/;s/::/':'x(9-$:)/e;s/\\w*\\W/'0'x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -pl\nINIT{$_ = <>}$:=y/:/:/;s/::/':'x(9-$:)/e;s/(?<!\\w)\\w*/'0'x(4-length$&).$&/ge\n"}, {"source_code": "#!perl -pl\n\nINIT {\n  $_ = <>;\n}\n\n$: = y/:/:/;\ns/::/':' x (9 - $:)/e if /::/;\n$_ = join ':', map { '0' x (4 - length) . $_ } (split ':', $_, -1);\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -pl\nINIT{$_ = <>}$:=y/:/:/;s/::/':'x(9-$:)/e if/::/;s/(?<!\\w)\\w*/'0'x(4-length$&).$&/ge"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}, {"source_code": "<>;\nwhile(<>){\n\tchomp;\n\t$j=0;\n\ts/:/++$j and \":\"/ge;\n\ts/::/\":0000\"x(8-$j).\":\"/e;\n\ts/:/ /g;\n\ts/ $//;\n\t@_=split/ /;\n\tfor $i(@_){\n\t\t$i=~s/^(.*)$/(\"0\"x(4-length $&)).$1/e;\n\t\t}\n\tprint join\":\",@_;\n\tprint (\":0000\"x(8-@_));\n\tprint \"\\n\";\n\t}"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y#:#:#)/e;s/\\w*\\W/0 x(5-length$&).$&/ge\n"}], "negative_code": [{"source_code": "<>;\nwhile(<>){\n  chomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n    $t=sprintf(\"%04s\",$1);\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n  }\n#$cnt = 0;\n#  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n#    ++$cnt;\n#  }\n  $cnt = split\":\",$_;\n  s/::/\":0000:\"x(8-$cnt)/e;\n  s/::/:/g;\n  s/^:|:$//g;\n  print\"$_\\n\";\n}\n"}, {"source_code": "<>;\nwhile(<>){\n#chomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n#print \"|$`<$&>$'|\\n\";\n#print \"=>$1<\\n\";\n#s/([^:]+):/sprintf(\"04s\",$1)/e;\n    $t=sprintf(\"%04s\",$1);\n#print \"t->$t<\\n\";\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n#print \"now=$_\\n\";\n#sleep 3;\n  }\n  $cnt = 0;\n  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n    ++$cnt;\n  }\n  s/::/\":0000:\"x(8-$cnt)/e;\n#print \"$_\\n\";\n  s/::/:/g;\n  s/^:|:$//g;\n  print;\n}\n"}, {"source_code": "<>;\nwhile(<>){\n  chomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n#print \"|$`<$&>$'|\\n\";\n#print \"=>$1<\\n\";\n#s/([^:]+):/sprintf(\"04s\",$1)/e;\n    $t=sprintf(\"%04s\",$1);\n#print \"t->$t<\\n\";\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n#print \"now=$_\\n\";\n#sleep 3;\n  }\n  $cnt = 0;\n  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n    ++$cnt;\n  }\n  s/::/\":0000:\"x(8-$cnt)/e;\n#print \"$_\\n\";\n  s/::/:/g;\n  s/^:|:$//g;\n  print;\n}\n"}, {"source_code": "<>;\nwhile(<>){\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n    $t=sprintf(\"%04s\",$1);\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n  }\n#$cnt = 0;\n#  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n#    ++$cnt;\n#  }\n  $cnt = split\":\",$_;\n  s/::/\":0000:\"x(8-$cnt)/e;\n  s/::/:/g;\n  s/^:|:$//g;\n  print;\n}\n"}, {"source_code": "<>;\nwhile(<>){\n  chomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n    $t=sprintf(\"%04s\",$1);\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n  }\n#$cnt = 0;\n#  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n#    ++$cnt;\n#  }\n  $cnt = split\":\",$_;\n  s/::/\":0000:\"x(8-$cnt)/e;\n  s/::/:/g;\n  s/^:|:$//g;\n  print;\n}\n"}, {"source_code": "<>;\nwhile(<>){\n  chomp;\n  while(/(?>:|^)([^:]{1,3})(?=:|$)/g) {\n#print \"|$`<$&>$'|\\n\";\n#print \"=>$1<\\n\";\n#s/([^:]+):/sprintf(\"04s\",$1)/e;\n    $t=sprintf(\"%04s\",$1);\n#print \"t->$t<\\n\";\n    s/(:|^)([^:]{1,3})(:|$)/$1$t$3/;\n#print \"now=$_\\n\";\n#sleep 3;\n  }\n  $cnt = 0;\n  while( /(?>:|^)([^:]{4})(?=:|$)/g ) {\n    ++$cnt;\n  }\n  s/::/\":0000:\"x(8-$cnt)/e;\n  print \"$_\\n\";\n  s/::/:/g;\n  s/^:|:$//;\n  print \"$_\\n\";\n}\n"}, {"source_code": "#!perl -p\nINIT{<>}s/::/':'x(9-y|:|:|)/e;s/\\w*./0 x(5-length$&).$&/ge\n"}, {"source_code": "#!perl -pl\n\nINIT {\n  $_ = <>;\n}\n\n$: = y/:/:/;\nif ($: < 7) {\n  s/::/':' x (9 - $:)/e;\n}\n$_ = join ':', map { '0' x (4 - length) . $_ } (split ':', $_, -1);\n"}, {"source_code": "<>;\nwhile(<>){\n\tchomp;\n\ts/^:/0:/;\n\twhile (/::/) {s/::/ 0:/};\n\ts/:/ /g;\n\ts/ $//;\n\t@_=split/ /;\n\tfor $i(@_){\n\t\t$i=~s/^(.*)$/(\"0\"x(4-length $&)).$1/e;\n\t\t}\n\tprint join\":\",@_;\n\tprint (\":0000\"x(8-@_));\n\tprint \"\\n\";\n\t}"}], "src_uid": "20f69ee5f04c8cbb769be3ab646031ab"}
{"source_code": "$ch1=<>;\nchomp$ch1;\n$ch2=<>;\nchomp$ch2;\n$l1=length$ch1;\n$l2=length$ch2;\nif($l1 != $l2){\nprint \"NO\";\n}\nelse{\n$nb=0;\nfor($i=0;$i<$l1;$i++){\nif(substr($ch1,$i,1) ne substr($ch2,$i,1)){\n$nb++;\npush(@arr1,substr($ch1,$i,1));\npush(@arr2,substr($ch2,$i,1));\n}\nif($nb>2){\nlast;\n}\n\n\n}\n\nif(($nb!=2) || ($nb==2 && ($arr1[0] ne $arr2[1] || $arr1[1] ne $arr2[0]))){\nprint \"NO\";\n}\nelse{\n\nprint\"YES\";\n\n}\n\n\n\n\n\n\n\n}", "positive_code": [{"source_code": "$a=<>;\n$b=<>;\n@x=sort split '',$a;\n@y=sort split '',$b;\n$flag=0;\nif((join '',@x)eq(join '',@y)){\n  @x=split '',$a;\n  @y=split '',$b;\n  for($i=0;$i<@x;++$i){\n    ++$cnt if $x[$i]ne$y[$i];\n  }\n  $flag=1 if $cnt>2;\n} else {                                                                                                                                                              \n  $flag=1;\n}\nprint qw/YES NO/[$flag];"}], "negative_code": [{"source_code": "$a=<>;\n$b=<>;\n@x=sort split '',$a;\n@y=sort split '',$b;\n$flag=0;\nif((join '',@x)eq(join '',@y)){\n  @x=split '',$a;\n  @y=split '',$b;\n  for($i=0;$i<@x;++$i){\n    ++$cnt if $x[$i]ne$y[$i];\n  }\n  if($cnt>2){\n    $flag=1;\n    exit;\n  }\n} else {\n  $flag=1;\n}\nprint qw/YES NO/[$flag];      "}], "src_uid": "c659bdeda1c1da08cfc7f71367222332"}
{"source_code": "chomp($_=<>);\n$le=length;\n$_.=<>;\nfor $i(1..$le){\n\tif ($le % $i) {next}\n\telse {$m=substr $_,0,$i}\t\n\t$g+= /^($m)+$/\n\t}\nprint 0+$g", "positive_code": [{"source_code": "chomp($_=<>);\nchomp($b=<>);\n$le=length;\n$lb=length $b;\nfor ($i=1; $i<=$le; $i+=$j || 1){\n\tif ($le % $i) {next}\n\telse { $j//=$i ; $m=substr $_,0,$i}\n#\tprint \" $m\\n\";\n\t$n=()=/$m/g;\n\t$nb=()=$b=~/$m/g;\n\t$i*$n == $le and $i*$nb == $lb and $g++;\n\t}\nprint 0+$g"}, {"source_code": "chomp($_=<>);\nchomp($b=<>);\n$le=length;\n$lb=length $b;\nfor $i(1..$le){\n\tif ($le % $i) {next}\n\telse {$m=substr $_,0,$i}\n#\tprint \" $m\\n\";\n\t$n=()=/$m/g;\n\t$nb=()=$b=~/$m/g;\n\t$i*$n == $le and $i*$nb == $lb and $g++;\n\t}\nprint 0+$g"}], "negative_code": [{"source_code": "chomp($_=<>);\n$le=length;\nchomp($_.=<>);\nfor $i(1..$le){\n\tif ($le % $i) {next}\n\telse {\n\t\t$g and (length)% $i==0 and $g++, next; \n\t\t$m=substr $_,0,$i\n\t\t}\n\t\n\t$g+= /^($m)+$/\n\t}\nprint 0+$g"}, {"source_code": "chomp($_=<>);\n$b=<>;\n$le=length;\nfor $i(1..$le){\n\tif ($le % $i) {next}\n\telse {$m=substr $_,0,$i}\n\t\"$_$b\"=~/^$m+$/ && $g++\n\t}\nprint 0+$g"}], "src_uid": "d28614f0365ea53530e35c6bd1e6f1dd"}
{"source_code": "#!perl\nuse strict;\nuse warnings;\nwhile(<>){\n    my(@b,@a,$i,$x0,$n,$m,$s0,$pos,$length);\n    ($n,$m)=split;\n    for $i ( 0..$n-1 ) {\n        ($s0,$x0)=split ' ',<>;\n        push @a,$s0;\n    }\n    $length = 1;\n    $b[0]=$a[0];\n    for $i ( 1..$#a ){\n        if ($a[$i] < $b[0]) {\n            $b[0] = $a[$i];\n        }\n        elsif ($a[$i] >= $b[$length-1]) {\n            $b[$length++] = $a[$i];\n        }\n        else {\n            $pos = lower_bound($a[$i], \\@b);\n            $b[$pos] = $a[$i];\n        }\n    }\n    #print \"length=$length\\n\";\n    print $n-$length,\"\\n\";\n}\n#find the first more than or equal to $num;\nsub lower_bound {\n    my ($num,$array)=@_;\n    my ($i,$high,$low,$mid);\n    $low = -1;\n    $high = $#{$array};\n    while($low+1 < $high) {\n        $mid=$low + int(($high-$low)/2);\n        if($array->[$mid] > $num) {\n            $high=$mid;\n        } else {\n            $low=$mid;\n        }\n    }\n    return $high;\n}\n", "positive_code": [{"source_code": "#!perl\nuse v5.18;\nuse strict;\nuse warnings;\n# time complexity: O(Nlog(N))\n# got Accepted\nwhile(<>){\n    my(@b,@a,$i,$n,$m,$s0,$pos);\n    ($n,$m)=split;\n    for $i ( 0..$n-1 ) {\n        ($s0,$_)=split ' ',<>; push @a,$s0;\n    }\n    $b[0]=$a[0];\n    for $i ( 1..$#a ){\n        $pos=upper_bound($a[$i], \\@b);\n        if ($pos == @b) {push @b, $a[$i];}\n        else {$b[$pos] = $a[$i];}\n    }\n    say $n-@b;\n}\n\n#find the first more than $num;\nsub upper_bound {\n    my ($num,$array)=@_;\n    my ($i,$high,$low,$mid);\n    $low = -1; $high = $#{$array};\n    while($low+1 < $high) {\n        $mid=$low + int(($high-$low)/2);\n        if($array->[$mid] > $num) {$high=$mid;}\n        else {$low=$mid;}\n    }\n    return $array->[$high]<=$num ? scalar @$array : $high;\n}\n"}, {"source_code": "#!perl\nuse v5.18;\n# time complexity: O(Nlog(N))\nwhile(<>){\n    my(@b,@a,$i,$x0,$n,$m,$s0,$pos,$length);\n    ($n,$m)=split;\n    for $i ( 0..$n-1 ) {\n        ($s0,$x0)=split ' ',<>; push @a,$s0;\n    }\n    $length = 1; $b[0]=$a[0];\n    for $i ( 1..$#a ){\n        $pos=upper_bound($a[$i], \\@b);\n        if ($pos == @b) {push @b, $a[$i];}\n        else {$b[$pos] = $a[$i];}\n    }\n    say $n-@b;\n}\n\n#find the first more than $num;\nsub upper_bound {\n    my ($num,$array)=@_;\n    my ($i,$high,$low,$mid);\n    $low = -1; $high = $#{$array};\n    while($low+1 < $high) {\n        $mid=$low + int(($high-$low)/2);\n        if($array->[$mid] > $num) {$high=$mid;}\n        else {$low=$mid;}\n    }\n    return $array->[$high]<=$num ? scalar @$array : $high;\n}\n"}, {"source_code": "#!perl\nuse v5.18;\n# time complexity: O(Nlog(N))\n# got Accepted\nwhile(<>){\n    my(@b,@a,$i,$n,$m,$s0,$pos);\n    ($n,$m)=split;\n    for $i ( 0..$n-1 ) {\n        ($s0,$_)=split ' ',<>; push @a,$s0;\n    }\n    $b[0]=$a[0];\n    for $i ( 1..$#a ){\n        $pos=upper_bound($a[$i], \\@b);\n        if ($pos == @b) {push @b, $a[$i];}\n        else {$b[$pos] = $a[$i];}\n    }\n    say $n-@b;\n}\n\n#find the first more than $num;\nsub upper_bound {\n    my ($num,$array)=@_;\n    my ($i,$high,$low,$mid);\n    $low = -1; $high = $#{$array};\n    while($low+1 < $high) {\n        $mid=$low + int(($high-$low)/2);\n        if($array->[$mid] > $num) {$high=$mid;}\n        else {$low=$mid;}\n    }\n    return $array->[$high]<=$num ? scalar @$array : $high;\n}\n"}, {"source_code": "#!perl\nuse v5.20;\n# time complexity: O(Nlog(N))\nwhile(<>){\n    my(@b,@a,$i,$x0,$n,$m,$s0,$pos,$length);\n    ($n,$m)=split;\n    for $i ( 0..$n-1 ) {\n        ($s0,$x0)=split ' ',<>; push @a,$s0;\n    }\n    $length = 1; $b[0]=$a[0];\n    for $i ( 1..$#a ){\n        if ($a[$i] < $b[0]) {$b[0] = $a[$i];}\n        elsif ($a[$i] >= $b[$length-1]) {$b[$length++] = $a[$i];}\n        else {$b[lower_bound($a[$i], \\@b)] = $a[$i];}\n    }\n    say $n-$length;\n}\n\n#find the first more than $num;\nsub lower_bound {\n    my ($num,$array)=@_;\n    my ($i,$high,$low,$mid);\n    $low = -1; $high = $#{$array};\n    while($low+1 < $high) {\n        $mid=$low + int(($high-$low)/2);\n        if($array->[$mid] > $num) {$high=$mid;}\n        else {$low=$mid;}\n    }\n    return $high;\n}\n"}], "negative_code": [{"source_code": "#!perl\nuse strict;\nuse warnings;\nwhile(<>){\n    my(@b,@a,@len,$i,$x0,$n,$m,$s0,$pos,$result);\n    ($n,$m)=split;\n    for $i ( 0..$n-1 ) {\n        ($s0,$x0)=split ' ',<>;\n        push @a,$s0;\n    }\n    $b[0]=$a[0];$len[0]=1;\n    for $i ( 1..$#a ){\n        $pos=upper_bound($a[$i],\\@b);\n        if($pos==@b){\n            $len[$pos]=$len[$pos-1]+1;\n            $b[$pos]=$a[$i];\n        } elsif ($pos==0 && $a[$i] < $b[$pos]) {\n            $b[$pos] = $a[$i];\n        }\n        else{\n            if($a[$i]==$b[$pos]){\n                $len[$pos]++;\n            } else{\n                $b[$pos+1]=$a[$i];\n            }\n        }\n    }\n    $result=1;\n    for $i ( 0.. $#len ) { $result = $len[$i] if ($result < $len[$i]); }\n    print $n-$result,\"\\n\";\n}\n#find the last less or equal to $num; if all of the element\n#in array are less than num. return the length of the array\nsub upper_bound {\n    my ($num,$array)=@_;\n    my ($i,$high,$low,$mid);\n    $low=0;$high=$#{$array};\n    while($low<=$high){\n        $mid=int(($low+$high)/2);\n        if($array->[$mid] > $num){\n            $high=$mid-1;\n        } else{\n            $low=$mid+1;\n        }\n    }\n    if($high==$#{$array} &&\n       $num > $array->[$high]){\n        return $high+1;\n    }\n    return -1!=$high ? $high : 0;\n}\n"}], "src_uid": "32f245fa1a2d99bfabd30b558687ca5f"}
{"source_code": "$/ = $\\;\n$_ = <>;\n\nfor $i (a .. z){\n\tfor $j (a .. z){\n\t\t$A = length join '', /^[$i$j]+$/gm;\n\t\t$max < $A and $max = $A;\n\t\t}\n\t}\n\nprint 0 + $max", "positive_code": [{"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "#!/usr/bin/perl\n# your code here\n$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "$/ = $\\;\n$s = <>;\n\nprint -1e3 + (sort map { 1e3 + length join '', $s =~ /^[$_]+$/gm } aa .. zz)[-1];\n"}, {"source_code": "$/ = $\\;\n$A = <>;\n\n$a = a;\npush @_, 1e3 + length join '', $A =~ /^[$a]+$/gm while $a ++ ne zz;\nprint -1e3 + (sort @_)[-1]"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = ();\n\tfor (1 .. $_){\n\t\tpush @_, ''.<>;\n\t\t}\n\tchomp @_;\n\t\n\t$max = 0;\n\t\n\tfor $i (a .. z){\n\t\tfor $j (a .. z){\n\t\t\t$A = length join '', grep /^[$i$j]+$/, @_;\n\t\t\t$max < $A and $max = $A;\n\t\t\t}\n\t\t}\n\tprint $max;\n\t\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = ();\n\tfor (1 .. $_){\n\t\tpush @_, ''.<>;\n\t\t}\n\tchomp @_;\n\t\n\t$max = -~0;\n\t\n\tfor $i (a .. d){\n\t\tfor $j (a .. d){\n\t\t\t$i eq $j and next;\n\t\t\t$A = length join '', grep /^[$i$j]+$/, @_;\n\t\t\t$max < $A and $max = $A;\n\t\t\t}\n\t\t}\n\tprint $max;\n\t\n\t}"}, {"source_code": "$/ = $\\;\n$A = <>;\n\n$a = a;\npush @_, 1e3 + length join '', $s =~ /^[$a]+$/gm while $a ++ ne zz;\nprint -1e3 + (sort @_)[-1]"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = ();\n\tfor (1 .. $_){\n\t\tpush @_, ''.<>;\n\t\t}\n\tchomp @_;\n\t\n\t$max = -~0;\n\t\n\tfor $i (a .. d){\n\t\tfor $j (a .. d){\n#\t\t\t$i eq $j and next;\n\t\t\t$A = length join '', grep /^[$i$j]+$/, @_;\n\t\t\t$max < $A and $max = $A;\n\t\t\t}\n\t\t}\n\tprint $max;\n\t\n\t}"}], "src_uid": "d8a93129cb5e7f05a5d6bbeedbd9ef1a"}
{"source_code": "use strict ;\nuse warnings ;\n\nmy $noCounters = <STDIN>;\nmy $noPeople = <STDIN>;\n\nmy $min = 0;\n\nfor(my $i=0;$i<$noCounters;$i++){\n    my $Items = <STDIN>;\n    my @noItems = split(/ /,$Items);\n    my $sum = 0;\n    for(my $j=0;$j<=$#noItems;$j++){\n        $sum += 5*$noItems[$j];\n    }\n    $sum += 15*($#noItems+1);\n    #print \"$sum\";\n    if($i==0){\n        $min=$sum;\n    }else{\n        if($sum<=$min){\n            $min=$sum;\n        }\n    }\n}\n\nprint \"$min\" ;", "positive_code": [{"source_code": "\nwhile(<>){\n\t$n=$_;\n\t<>;\n\tfor $i(1..$n){\n\t\t$_=<>;\n\t\t@_=split/ /;\n\t\t$a[$i]+=$_*5 for @_;\n\t\t$a[$i]+=15*@_;\n\t\t\n\t}\n#\tprint \"@a\";\n\tshift @a;\n\t@a= sort {$a<=>$b} @a;\n#\tprint \"@a\";\n\tprint (shift @a);\n\tprint \"\\n\"\n\t}\n\t\n"}, {"source_code": "for $i(0..<>-1){\n\t$j++ or <>;\n\t$_=<>;\n\t@_=split/ /;\n\t$a[$i]+=$_*5 for @_;\n\t$a[$i]+=15*@_;\n}\nprint ((@a= sort {$a<=>$b} @a)[0])\n\t\n"}], "negative_code": [{"source_code": "for $i(1..<>){\n\t$j++ or <>;\n\t$_=<>;\n\t@_=split/ /;\n\t$a[$i]+=$_*5 for @_;\n\t$a[$i]+=15*@_;\n}\nshift @a;\n@a= sort {$a<=>$b} @a[1..-1];\nprint @a[0]"}], "src_uid": "0ea79b2a7ddf3d4da9c7a348e61933a7"}
{"source_code": "use bigrat;\n($n, $X, $Y) = split \" \", <>;\nfor (<>){\n\t($x, $y) = split;\n\t$x -= $X + 0/1;\n\t$y -= $Y + 0/1;\n\t$h{ $x ? $y / $x : INF } ++\n\t}\nprint 0+ keys %h", "positive_code": [{"source_code": "use bigrat;\n$\\ = $/;\nwhile(<>){\n\t($n, $X, $Y) = split;\n\tundef %h;\n\tfor (1 .. $n){\n\t\t($x, $y) = split \" \", <>;\n\t\t$x -= $X + 0/1;\n\t\t$y -= $Y + 0/1;\n\t\t$h{ $x ? ( $y / $x) : INF } ++\n\t\t}\n\t$, = $\";\n#\tprint \"$_ -> $h{$_} \" for keys %h;\n\tprint scalar keys %h\n\t}"}], "negative_code": [{"source_code": "use bigrat;\n$\\ = $/;\nwhile(<>){\n\t($n, $X, $Y) = split;\n\tundef %h;\n\tfor (1 .. $n){\n\t\t($x, $y) = split \" \", <>;\n\t\t$x -= $X;\n\t\t$y -= $Y;\n\t\t$h{ $x ? ($y / $x) : INF } ++\n\t\t}\n\t$, = $\";\n#\tprint \"$_ -> $h{$_} \" for keys %h;\n\tprint scalar keys %h\n\t}"}, {"source_code": "$\\ = $/;\nwhile(<>){\n\t($n, $X, $Y) = split;\n\tundef %h;\n\tfor (1 .. $n){\n\t\t($x, $y) = split \" \", <>;\n\t\t$x -= $X;\n\t\t$y -= $Y;\n\t\t$h{ $x ? ($y / $x) : INF } ++\n\t\t}\n\t$, = $\";\n#\tprint \"$_ -> $h{$_} \" for keys %h;\n\tprint scalar keys %h\n\t}"}], "src_uid": "8d2845c33645ac45d4d37f9493b0c380"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nmy %poly = (\n    Tetrahedron => 4,\n    Cube        => 6,\n    Octahedron  => 8,\n    Dodecahedron=> 12,\n    Icosahedron => 20,\n);\n\nmy $answer = 0;\n\nmy $n = read_token();\n\nfor ( 1..$n ) {\n    $answer += $poly{read_token()};\n}\n\nsay $answer;\n\n\n\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n", "positive_code": [{"source_code": "use 5.016;\n\nmy %sides = (\n  Tetrahedron  => 4,\n  Cube         => 6,\n  Octahedron   => 8,\n  Dodecahedron => 12,\n  Icosahedron  => 20,\n);\n\nmy $n = <>;\nmy $s = 0;\nfor (1..$n) {\n  chomp (my $shape = <>);\n  $s += $sides{$shape};\n}\nsay $s;\n"}, {"source_code": "$n = <STDIN>;\n$ans = 0;\nfor($i=0;$i<$n;$i++)\n{\n\t$str = <STDIN>;\n\tchomp($str);\n\tif($str =~ /Tetrahedron/)\n\t{\n\t\t$ans += 4;\n\t}\n\telsif($str =~ /Cube/)\n\t{\n\t\t$ans += 6;\n\t}\n\telsif($str =~ /Octahedron/)\n\t{\n\t\t$ans += 8;\n\t}\n\telsif($str =~ /Dodecahedron/)\n\t{\n\t\t$ans += 12;\n\t}\n\telse\n\t{\n\t\t$ans += 20;\n\t}\n}\nprint(\"$ans\\n\");\n"}, {"source_code": "<>;\n\nprint eval join ' + ', map { y/TCODIa-z/46812/dr =~ s/2/20/r =~ s/^1/12/r } <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy %h;\nmap { /(\\w+).*?(\\d+)/; $h{ $1 } = $2 } <DATA>;\n\nwhile(<>){\n\t\n\tmy $sum = 0;\n\t\n\tfor (1 .. $_){\n\t\t$_ = <>, chomp;\n\t\t$sum += $h{ $_ };\n\t\t}\n\t\n\tprint $sum;\n\t}\n\t\n__DATA__\n    Tetrahedron. Tetrahedron has 4 triangular faces.\n    Cube. Cube has 6 square faces.\n    Octahedron. Octahedron has 8 triangular faces.\n    Dodecahedron. Dodecahedron has 12 pentagonal faces.\n    Icosahedron. Icosahedron has 20 triangular faces. "}], "negative_code": [], "src_uid": "e6689123fefea251555e0e096f58f6d1"}
{"source_code": "$k = ( split ' ', <> )[ 1 ];\n\n%h = map { $_ => $i ++ } split ' ', <>;\n\n@w = split ' ', <>;\n\t\nfor( 1 .. $k ){\n\t@set = <> =~ / \\d+/g;\n\t\n\t$min = ( sort { $a <=> $b } map { $w[ $_ - 1 ] } @set )[ 0 ];\n\t\n\tmap { $w[ $_ - 1 ] = $min } @set;\n\t}\n\nprint 0 + eval join ' + ', map { $w[ $h{ $_ } ] } split ' ', <>", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k, $m ) = split;\n\t\n\tmy @dict = split ' ', <>;\n\t\n\tmy @w = split ' ', <>;\n\t\n\tmy @groups = map ~~<>, 1 .. $k;\n\t\n\tmy @orig = split ' ', <>;\n\t\n\tfor( @groups ){\n\t\tmy( undef, @set ) = split;\n\t\t\n\t\tmy $min = ( sort { $a <=> $b } map { $w[ $_ - 1 ] } @set )[ 0 ];\n\t\t\n\t\tmap { $w[ $_ - 1 ] = $min } @set;\n\t\t}\n\t\n\tmy $i = 0;\n\t\n\tmy %h = map { $_ => $i ++ } @dict;\n\t\n\tprint 0 + eval join ' + ', map { $w[ $h{ $_ } ] } @orig;\n\t}"}], "negative_code": [], "src_uid": "296552dc2df23b3920baef7d47d0a591"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <>){\n\t\n\tmy $blue_area = ( $n - $n % 2 ) ** 2;\n\t\n\tmy %count;\n\t\n\tmap { $count{ $_ } ++ } split ' ', <>;\n\t\n\tmy @BLUE;\n\tmy @YELLOW;\n\tmy @GREEN;\n\t\n\tfor my $key ( keys %count ){\n\t\tpush @BLUE, ( $key ) x ( $count{ $key } / 4 );\n\t\tpush @YELLOW, $key if $count{ $key } % 4 >= 2;\n\t\tpush @GREEN, $key if $count{ $key } % 2 == 1;\n\t\t}\n\t\n\tpush @YELLOW, ( pop @BLUE ) x 2 while @BLUE * 4 > $blue_area;\n\t\n\tif( $blue_area != @BLUE * 4 or \n\t\t$n % 2 and 1 != @GREEN ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\tmy @MATRIX;\n\t\n\twhile( @BLUE ){\n\t\tpush @MATRIX, [ splice @BLUE, 0, $n / 2, () ];\n\t\t}\n\t\n\tfor( @MATRIX ){\n\t\tpush @{ $_ }, grep { defined } pop @YELLOW, reverse @{ $_ };\n\t\t}\n\t\n\t@GREEN and push @MATRIX, [ @YELLOW, @GREEN, reverse @YELLOW ];\n\t\n\tpush @MATRIX, reverse @MATRIX[ 0 .. ( $n >> 1 ) - 1 ];\n\t\n\tprint \"YES\";\n\tprint \"@{ $_ }\" for @MATRIX;\n\t}\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <>){\n\t\t\n\tmy $w = ( $n - ( $n % 2 ? 1 : 0 ) ) ** 2;\n\t\n\t$_ = join ' ', sort split ' ', <>;\n\t\n\tmy @f;\n\tmy @c;\n\t\n\ts/\\b(\\d+)(\\s+\\1){3}\\b/ '' x push @f, $1 /ge;\n\ts/\\b(\\d+)(\\s+\\1)\\b/    '' x push @c, $1 /ge;\n\t\n\tpush @c, ( pop @f ) x 2 while @f * 4 > $w;\n\t\n\tunshift @c, split;\n\t\n\tif( $w != @f * 4 or \n\t\t$n % 2 and $n != @c ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\tmy @p;\n\t\n\t@c and @p = [ ( reverse @c[ 0 .. $n / 2 ] ), @c[ 1 .. $n / 2 ] ];\n\t\n\twhile( @f ){\n\t\tmy @l = splice @f, 0, $n / 2, ();\n\t\t\n\t\tmy $up = [ @l, @c ? pop @c : (), reverse @l ];\n\t\t@p = ( $up, @p, $up );\n\t\t}\n\t\n\tprint \"YES\";\n\tprint \"@{ $_ }\" for @p;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <>){\n\t\t\n\tmy $blue_area = ( $n - $n % 2 ) ** 2;\n\t\n\t$_ = join ' ', sort split ' ', <>;\n\t\n\tmy @BLUE;\n\tmy @YELLOW;\n\t\n\ts/\\b(\\d+)(\\s+\\1){3}\\b/ '' x push @BLUE  , $1 /ge;\n\ts/\\b(\\d+)(\\s+\\1){1}\\b/ '' x push @YELLOW, $1 /ge;\n\t\n\tmy @GREEN = split;\n\t\n\tpush @YELLOW, ( pop @BLUE ) x 2 while @BLUE * 4 > $blue_area;\n\t\n\tif( $blue_area != @BLUE * 4 or \n\t\t$n % 2 and 1 != @GREEN ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\tmy @MATRIX;\n\t\n\t$n % 2 and @MATRIX = [ grep { defined } ( reverse @YELLOW[ 0 .. $n / 2 - 1 ] ), @GREEN, @YELLOW[ 0 .. $n / 2 - 1 ] ];\n\t\n\twhile( @BLUE ){\n\t\tmy @half = splice @BLUE, 0, $n / 2, ();\n\t\t\n\t\tmy $row = [ grep { defined } @half, pop @YELLOW, reverse @half ];\n\t\t@MATRIX = ( $row, @MATRIX, $row );\n\t\t}\n\t\n\tprint \"YES\";\n\tprint \"@{ $_ }\" for @MATRIX;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 20;\n\t\n\tchomp;\n\tmy $n = $_;\n\t\t\n\tmy %h;\n\t\n\tmap { $h{ $_ } ++ } split ' ', <>;\n\t\t\t\n\tmy @odd_cross;\n\t\n\tif( $n % 2 == 1 ){\n\t\t\n\t\tfor my $key ( sort keys %h ){\n\t\t\tif( $h{ $key } % 2 == 1 ){\n\t\t\t\t$h{ $key } -= 1;\n\t\t\t\tpush @odd_cross, $key;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tmy $require = $n - 1;\n\t\t\n\t\tfor my $key ( sort keys %h ){\n\t\t\tif( $require > 0 and $h{ $key } % 4 == 2 ){\n\t\t\t\t$h{ $key } -= 2;\n\t\t\t\tpush @odd_cross, $key;\n\t\t\t\t$require --;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tfor my $key ( sort keys %h ){\n\t\t\twhile( $require > 0 and $h{ $key } % 4 == 0 and $h{ $key } > 0 ){\n\t\t\t\t$h{ $key } -= 4;\n\t\t\t\tpush @odd_cross, ( $key ) x 2;\n\t\t\t\t$require -= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"odd_cross:[@odd_cross]\";\n\t\n\tmy $sum = eval join '+', map { $h{ $_ } } keys %h;\n\tmy $not_tetra = grep { $h{ $_ } % 4 != 0 } keys %h;\n\t\n\t$debug and print \"n:[$n], sum:[$sum], not_tetra:[$not_tetra]\";\n\t\n\tif( $not_tetra or $sum != ( $n - ( $n % 2 ? 1 : 0 ) ) ** 2 ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\tmy @fill = map { ( $_ ) x ( $h{ $_ } / 4 ) } sort keys %h;\n\t\n\t$debug and print \"fill:[@fill]\";\n\t\t\n\tmy @palindrome;\n\t\n\t@odd_cross and @palindrome = [ ( reverse @odd_cross[ 0 .. $n / 2 ] ), @odd_cross[ 1 .. $n / 2 ] ];\n\t\n\twhile( @fill ){\n\t\tmy @line = splice @fill, 0, $n / 2, ();\n\t\t\n\t\tmy $unshift_push = [ @line, @odd_cross ? pop @odd_cross : (), reverse @line ];\n\t\tunshift @palindrome, $unshift_push;\n\t\tpush @palindrome, $unshift_push;\n\t\t}\n\t\n\tprint \"YES\";\n\tprint \"@{ $_ }\" for @palindrome;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <>){\n\t\n\tmy $blue_area = ( $n - $n % 2 ) ** 2;\n\t\n\tmy %count;\n\t\n\tmap { $count{ $_ } ++ } split ' ', <>;\n\t\n\tmy @BLUE;\n\tmy @YELLOW;\n\tmy @GREEN;\n\t\n\tfor my $key ( keys %count ){\n\t\tpush @BLUE, ( $key ) x ( $count{ $key } / 4 );\n\t\tpush @YELLOW, $key if $count{ $key } % 4 == 2;\n\t\tpush @GREEN, $key if $count{ $key } % 2 == 1;\n\t\t}\n\t\n\tpush @YELLOW, ( pop @BLUE ) x 2 while @BLUE * 4 > $blue_area;\n\t\n\tif( $blue_area != @BLUE * 4 or \n\t\t$n % 2 and 1 != @GREEN ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\tmy @MATRIX;\n\t\n\twhile( @BLUE ){\n\t\tpush @MATRIX, [ splice @BLUE, 0, $n / 2, () ];\n\t\t}\n\t\n\tfor( @MATRIX ){\n\t\tpush @{ $_ }, grep { defined } pop @YELLOW, reverse @{ $_ };\n\t\t}\n\t\n\t@GREEN and push @MATRIX, [ @YELLOW, @GREEN, reverse @YELLOW ];\n\t\n\tpush @MATRIX, reverse @MATRIX[ 0 .. ( $n >> 1 ) - 1 ];\n\t\n\tprint \"YES\";\n\tprint \"@{ $_ }\" for @MATRIX;\n\t}\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile( my $n = <> ){\n\t\t\t\n\tmy %h;\n\t\n\tmap { $h{ $_ } ++ } split ' ', <>;\n\t\n\t@_ = map { ( $_->[0] ) x $h{ $_->[0] } } \n\t\t\tsort { $a->[1] <=> $b->[1] } \n\t\t\tmap { [ $_, $h{ $_ } % 4 + $h{ $_ } % 2 * 4 ] }\n\t\t\tkeys %h;\n\t\t\n\tmy $w = ( $n - $n % 2 ) ** 2;\n\t\n\t$_ = join ' ', splice @_, 0, $w, ();\n\ts/\\b(\\d+)( \\1){3}\\b/$1/g;\n\tmy @f = split;\n\t\n\t$_ = \"@_\";\n\ts/\\b(\\d+)( \\1)\\b/$1/g;\n\tmy @c = reverse split;\n\t\n\tif( $w / 4 != @f or $n % 2 and $n != split ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\tmy @p;\n\t\n\t@c and @p = [ ( reverse @c[ 0 .. $n / 2 ] ), @c[ 1 .. $n / 2 ] ];\n\t\n\twhile( @f ){\n\t\tmy @l = splice @f, 0, $n / 2, ();\n\t\t\n\t\tmy $up = [ @l, @c ? pop @c : (), reverse @l ];\n\t\t@p = ( $up, @p, $up );\n\t\t}\n\t\n\tprint \"YES\";\n\tprint \"@{ $_ }\" for @p;\n\t}"}], "src_uid": "20928dd8e512bee2d86c6611c5e76390"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nuse Carp;\n    \n# essential\nmy @tokens = ();\n    \nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n    \nsub say_all {\n    my @args = @_;\n    say join ' ', @args;\n}\n    \nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n    \nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n    \nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n    \n    $$ref = !$$ref;\n}\n    \nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n    \nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n    \nsub sum_of_digits {\n    my $n = shift;\n    my @numbers = split q{}, $n;\n    \n    my $sum = 0;\n    \n    for (@numbers) {\n        $sum += $_;\n    }\n    \n    return $sum;\n}\n    \n# solution\n    \nmy $n = read_line;\n\nfor (1..$n) {\n    my ($a, $b) = split q{ }, read_line;\n    if ($a == 1 || $b == 1) {\n        say 'YES';\n        next;\n    }\n    if ($a == 2 && $b == 2) {\n        say 'YES';\n        next;\n    }\n    say 'NO';\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tprint $n == 2 && $m == 2 || $n == 1 || $m == 1 ? \"YES\" : \"NO\";\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tprint $n == 2 && $n == 2 || $n == 1 || $m == 1 ? \"YES\" : \"NO\";\n\t}"}], "src_uid": "55595ff38a08b80bc86cf1ebae6f55af"}
{"source_code": "$n = <>;\n@a = split(' ', <>);\n$m = 123;\nforeach(@a){\n\t$m = $_ if $_ < $m;\n}\n$re = 123;\nforeach(@a){\n\t$re = $_\n\tif $_ > $m and $_ < $re;\n}\nprint ($re != 123 ? $re : \"NO\");", "positive_code": [{"source_code": "my $n = <STDIN>;\nchomp $n;\n\nmy $int_list = <STDIN>;\nchomp $int_list;\n\nmy @array = split(\" \",$int_list);\n\nmy $min = $array[0];\n\nmy $sec = \"NO\";\n\nfor my $elem (@array){\n    if ($elem < $min){\n        $sec = $min;\n        $min = $elem;\n    }\n    elsif (($elem > $min) && (($sec eq \"NO\") ||($sec > $elem))){\n        $sec = $elem;\n    }\n}\n\nprint $sec;"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n<>;\nmy $str = <>;\nchomp($str);\nmy @arr = split(/ /, $str);\nmy $min = $arr[0];\nmy $mmin;\nfor my $i (@arr) {\n    if ($i < $min) {\n        $mmin = $min;\n        $min = $i;\n    } elsif ($i > $min) {\n        if ( (! defined $mmin) || ($mmin > $i) ) {\n             $mmin = $i;\n        }\n    }\n}\nif (!defined $mmin) {\n    print \"NO\";\n} else {\n    print $mmin;\n}"}], "negative_code": [{"source_code": "my $n = <STDIN>;\nchomp $n;\n\nmy $int_list = <STDIN>;\nchomp $int_list;\n\nmy @array = split(\" \",$int_list);\n\nmy $min = $array[0];\n\nmy $sec = \"NO\";\n\nfor my $elem (@array){\n    if ($elem < $min){\n        $sec = $min;\n        $min = $elem;\n    }\n    elsif (($elem > $min) && (($sec eq \"NO\") ||($sec > $elem))){\n        $sec = $elem;\n    }\n}"}, {"source_code": "$n = <>;\n@a = split(' ', <>);\n$m = 123;\nforeach(@a){\n\t$m = $_ if $_ < $m;\n}\nforeach(@a){\n\tprint $_ and exit\n\tif $_ > $m;\n}\nprint \"NO\";"}, {"source_code": "$n = <>;\n@a = split(' ', <>);\nunshift @a, $m = 123;\nforeach(@a){\n\t$m = $_ if $_ < $m;\n}\nfor(1..$n){\n\tprint $_ and exit\n\tif $a[$_] > $m;\n}\nprint \"NO\";"}, {"source_code": "$n = <>;\n@a = split(' ', <>);\nunshift @a, $m = 123;\nforeach(@a){\n\t$m = $_ if $_ < $m;\n}\nfor(1..$n){\n\tprint $_ and exit\n\tif $a[$_] > $m;\n}\nprint \"No\";"}, {"source_code": "$n = <>;\n@a = split(' ', <>);\nunshift @a, $m = 123;\nforeach(@a){\n\t$m = $_ if $_ < $m;\n}\nforeach(@a){\n\tprint $_ and exit\n\tif $_ > $m;\n}\nprint \"NO\";"}], "src_uid": "930be5ec102fbe062062aa23eac75187"}
{"source_code": "while(<>){\n\t\n\tchomp;\n\t$n=<>;\n\t@az=split/ /,<>;\n\t\n\t@Az = sort {$b<=>$a} @az;\n#\tprint $Az[0];\n\t\n\ts/./ $&/g;\n\ttr/a-j/0-9/;\n\ts/[k-t]/1$&/g;\n\ts/[u-z]/2$&/g;\n\ttr/k-t/0-9/;\n\ttr/u-z/0-5/;\n\ts/ //;\n\t\n#\tprint \"=$_=\";\n\t\n\t@a=/\\d+/g;\n\t$j=0;\n\t$sum=0;\n\t\n#\tprint \"?@a?\";\n\tfor $i(@a){\n\t\t\n\t\t$j++;\n\t\t$sum += @az[$i] * $j;\n\t\t\n#\t\tprint \"$sum\\n\";\n\t\t}\n\t\t\n\tfor $i(1..$n){\n\t\t$j++;\n\t\t$sum += @Az[0] * $j;\n\t\t\n\t\t}\n#\tprint 'z'-'a';\n\tprint \"$sum\\n\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         STDIN: dzy_string.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 05/26/2015 09:44:35 AM\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\n#open STDIN, \"in.txt\";\nchomp(my $str = <STDIN>);\nmy @st = split //, $str;\nchomp(my $cnt = <STDIN>);\nchomp($_ = <STDIN>);\nmy @alph = split;\nmy %value;\nwhile (my ($inde, $val) = each @alph){\n    $value{chr($inde + ord('a'))} = $val;\n}\nmy $sum = 0;\nwhile (my ($inde, $val) = each @st){\n    $sum += ($inde + 1) * $value{$val};\n}\nmy @sor_alph = sort {$b <=> $a} @alph;\nmy $len = @st;\nwhile ($cnt) {\n    $sum += $sor_alph[0] * ($len + $cnt);\n    $cnt--;\n}\nprint $sum . \"\\n\";\n\n"}, {"source_code": "chomp($m = <>);\nchomp($n = <>);\nchomp($num = <>);\n@nums = split (\" \", $num);\n@ms = split //, $m;\n$max = $_ > $max ? $_ : $max for(@nums);\nfor $i(0..$#ms){\n    $ans += ($i + 1) * $nums[ord($ms[$i]) - 97];\n}\nfor $i(1..$n) {\n    $ans += $max * ($i + 1 +  $#ms); \n}\nprint \"$ans\\n\";\n"}], "negative_code": [], "src_uid": "85f90533a9840e944deef9f3b4229cb8"}
{"source_code": "($n, $m) = split \" \", <>;\n%k = ();\nfor (0 .. $m - 1) {\n    ($a, $b) = split \" \", <>;\n    $k{$a} = $b;\n}\n@a = split \" \", <>;\nfor (@a) {\n    print length $_ <= length $k{$_}? \"$_ \" : \"$k{$_} \";\n}", "positive_code": [{"source_code": "($n,$m)=split ' ',<>;\nwhile($m--) {\n  ($a,$b)=split ' ',<>;\n  $h{$a} = length$a>length$b?$b:$a;                                             \n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--) {\n  chomp($_=<>);\n  ($a,$b)=split ' ';\n  $h{$a} = length$a<=length$b?$a:$b;                                            \n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--) {\n  chomp($_=<>);\n  ($a,$b)=split ' ';\n  $h{$a} = $b; \n}\nchomp($_=<>);\n@ans = map {$_ = (length$h{$_} < length$_ ? $h{$_} : $_)} split ' ';\nprint \"@ans\";"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($n, $m) = split / /, <>;\nforeach (1 .. $m) {\n\tchomp($line = <>);\n\t@a = split / /, $line;\n\tif (length $a[0] <= length $a[1]) {\n\t\t$tb{$a[0]} = $a[0];\n\t\t$tb{$a[1]} = $a[0];\n\t} else {\n\t\t$tb{$a[0]} = $a[1];\n\t\t$tb{$a[1]} = $a[1];\n\t}\n}\nchomp($line = <>);\nprint \"$tb{$_} \" foreach (split / /, $line);"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: b.pl\n#\n#        USAGE: ./b.pl  \n#\n#  DESCRIPTION: \n#\n#\n#      OPTIONS: ---\n# REQUIREMENTS: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: YOUR NAME (), \n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 1/14/2015 7:34:13 PM\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\nchomp($_ = <STDIN>);\nmy ($n, $m) = split(/ /);\nmy %words;\nwhile ($m--)\n{\n\tchomp($_ = <STDIN>);\n\tmy ($a, $b) = split(/ /);\n\t$words{$a} = $b;\n}\nchomp(my $sentence = <STDIN>);\nmy @res = split(/ /, $sentence);\nfor my $item (@res) {\n\tif (length($item) <= length($words{$item})) {\n\t\tprint \"$item \";\n\t}\n\telse {\n\t\tprint \"$words{$item} \";\n\t}\n}\nprint \"\\n\";\n"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy ( $n, $m ) = split ( \" \", <> );\nmy %map;\nwhile ( $m-- ){\n\tmy ( $a, $b ) = split ( \" \", <> );\n\t$map{$a} = $b;\n}\n\nprint join ( \" \", map ( ( length $_ <= length $map{$_} ? $_ : $map{$_} ), split ( \" \", <> ) ) ).\"\\n\";\n"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}, {"source_code": "$\\ = $/;\nwhile (<>){\n\t($n, $m)=split;\n\tundef %h;\n\tfor $i (1..$m){\n\t\t($first, $second) = split \" \", <>;\n\t\t$value = length $second < length $first ? $second : $first;\n\t\t$h{$first} = $value;\n\t\t}\n\t$, = $\";\n#\tprint keys %h;\n#\tprint values %h;\n\t\n\t$_ = <>;\n\ts/(\\w+)/$h{$1}/eg;\n\n\tprint\n\t}\n"}, {"source_code": "($n, $m)=split \" \", <>;\nfor (1..$m){\n\t($f, $s) = split \" \", <>;\n\t$h{$f} = length $s < length $f ? $s : $f;\n\t}\n$_ = <>;\ns/(\\w+)/$h{$1}/eg;\nprint $_.$/"}, {"source_code": "($n,$m)=split ' ',<>;\nwhile($m--){\n  ($a,$b)=split ' ',<>;\n  $h{$a}=length$a>length$b?$b:$a;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint\n"}], "negative_code": [{"source_code": "($n,$m)=split ' ',<>;                                                           \nwhile($m--) {\n  chomp($_=<>);\n  ($a,$b)=split ' ';\n  $h{$a} = length$a<length$b?$a:$b;\n}\n$_=<>;\ns/(\\w+)/$h{$1}/eg;\nprint"}], "src_uid": "edd556d60de89587f1b8daa893538530"}
{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\nuse integer;\n\n<>;\n\nwhile (<>) {\n\tchomp;\n\tif (is_homo($_)) {\n\t\tprint \"-1\\n\";\n\t} else {\n\t\tmy @chars = split //;\n\t\tprint sort @chars;\n\t\tprint \"\\n\";\n\t}\n}\n\nsub is_homo {\n\tmy $string = shift;\n\tmy @chars = split //, $string;\n\tmy $is_homo = 1;\n\n\tif (@chars > 0) {\n\t\tmy $prev = $chars[0];\n\t\tfor (my $i = 1; $i < @chars; $i++) {\n\t\t\t$is_homo = $is_homo && $chars[$i] eq $prev;\n\t\t\t$prev = $chars[$i];\n\t\t}\n\t}\n\treturn $is_homo;\t\n}\n\nsub is_palindrome {\n\tmy $string = shift;\n\tmy @chars = split //, $string;\n\tmy $radius = @chars / 2;\n\n\tmy $is_palindrome = 1;\n\tfor (my $i = 0; $i < $radius; $i++) {\n\t\t$is_palindrome = $is_palindrome && $chars[$i] eq $chars[$#chars - $i];\n\t}\n\treturn $is_palindrome;\t\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\t$_ = join '', sort split //;\n\t\n\tprint /^(.)\\1*$/ ? -1 : $_;\n\t}"}], "negative_code": [], "src_uid": "b9f0c38c6066bdafa2e4c6daf7f46816"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B ) = split;\n\t\n\tmap { $_ = sprintf \"%021b\", $_ } $A, $B;\n\t\n\t$B = reverse $B;\n\t\n\t$_ = $A =~ s/.\\K/ ( chop $B ) . ',' /ger;\n\t\n\tmy $flag = -1;\n\t\n\ts/^(00,|11,|01,(?{ $flag ++; }))*01,//;\n\t\n\tmy $len = ( length ) / 3;\n\t\n\t$A = $_;\n\t$B = '';\n\t\n\t$A =~ s/.\\K(.),(?{ $B .= $1; })//g;\n\t\n\tmy $_1 = $B =~ m/1/;\n\t\n\t$_ = eval \"0b$_\" for $A, $B;\n\t\n\tprint +( sort { $a <=> $b } \n\t\t1 + $A - $B, \n\t\t( 1 << $len ) - $A + ( $flag || $_1 ? 1 : 0 )\n\t\t)[ 0 ];\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B ) = split;\n\t\n\tmap { $_ = sprintf \"%021b\", $_ } $A, $B;\n\t\n\t$B = reverse $B;\n\t\n\t$_ = $A =~ s/.\\K/ ( chop $B ) . ',' /ger;\n\t\n\ts/^(00,|11,|01,)*0\\K1/X/;\n\t\n\tmy $c = 0;\n\t\n\t1 while 0\n\t\t|| s/^00,//\n\t\t|| s/^11,//\n\t\t|| s/^01,// && ++ $c\n\t\t;\n\t\n\tmy $len = ( length ) / 3;\n\t\n\ts/0X,//;\n\t\n\t$A = $_;\n\t$B = '';\n\t\n\t$A =~ s/.\\K(.),(?{ $B .= $1; })//g;\n\t\n\tmy $cB = $B;\n\t\n\t$_ = eval \"0b$_\" for $A, $B;\n\t\n\tprint +( sort { $a <=> $b } \n\t\t1 + $A - $B, \n\t\t( ( $c > 0 || $cB =~ m/1/ ) ? 1 : 0 ) - $A + ( 1 << ( $len - 1 ) ) \n\t\t)[ 0 ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $A, $B ) = split;\n\t\n\t$debug and print \"$A $B\";\n\t\n\tmap { $_ = sprintf \"%021b\", $_ } $A, $B;\n\t\n\t$B = reverse $B;\n\t\n\t$_ = $A =~ s/.\\K/ ( chop $B ) . ',' /ger;\n\t\n\t$debug and print;\n\t\n\ts/^(00,|11,|01,)*0\\K1/X/;\n\t\n\t$debug and print;\n\t\n\tmy $c = 0;\n\t\n\t1 while 0\n\t\t|| s/^00,//\n\t\t|| s/^11,//\n\t\t|| s/^01,// && ++ $c\n\t\t;\n\t\n\t$debug and print;\n\t\n\tmy $len = ( length ) / 3;\n\t\n\ts/0X,//;\n\t\n\t$A = $_;\n\t$B = '';\n\t\n\t$A =~ s/.\\K(.),(?{ $B .= $1; })//g;\n\t\n\t$debug and print $A;\n\t$debug and print $B;\n\t\n\tmy $copy_B = $B;\n\t\n\t$_ = eval \"0b$_\" for $A, $B;\n\t\n\t$debug and print \"$A $B\";\n\t\n\tprint +( sort { $a <=> $b } \n\t\t1 + $A - $B, \n\t\t( ( $c > 0 || $copy_B =~ m/1/ ) ? 1 : 0 ) - $A + ( 1 << ( $len - 1 ) ) \n\t\t)[ 0 ];\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $A, $B ) = split;\n\t\n\t$debug and print \"$A $B\";\n\t\n\t$_ = sprintf \"%021b\", $_ for $A, $B;\n\t\n\tmy $len;\n\tmy $c = 0;\n\t\n\tOUTER:\n\twhile( 1 ){\n\t\twhile( $A =~ m/^0/ and $B =~ m/^0/ ){\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\twhile( $A =~ m/^1/ and $B =~ m/^1/ ){\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\twhile( $A =~ m/^0/ and $B =~ m/^1/ ){\n\t\t\n\t\t\t$len = length $A;\n\t\t\t$c ++;\n\t\t\t\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\t\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\t\n\t\tlast;\n\t\t}\n\t\n\t$debug and print $A;\n\t$debug and print $B;\n\t\n\tmy $copy_B = $B;\n\t\n\t$_ = eval \"0b$_\" for $A, $B;\n\t\n\t$debug and print \"$A $B\";\n\t\n\tprint +( sort { $a <=> $b } \n\t\t1 + $A - $B, \n\t\t( $c > 1 || $copy_B =~ m/1/ ? 1 : 0 ) + 0 - $A + ( 1 << ( $len - 1 ) ) \n\t\t)[ 0 ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $A, $B ) = split;\n\t\n\t$debug and print \"$A $B\";\n\t\n\t$_ = sprintf \"%021b\", $_ for $A, $B;\n\t\n\tmy $len;\n\tmy $c = 0;\n\t\n\tOUTER:\n\twhile( 1 ){\n\t\twhile( $A =~ m/^0/ and $B =~ m/^0/ ){\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\twhile( $A =~ m/^1/ and $B =~ m/^1/ ){\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\twhile( $A =~ m/^0/ and $B =~ m/^1/ ){\n\t\t\n\t\t\t$len = length $A;\n\t\t\t$c ++;\n\t\t\t\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\t\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\t\n\t\tlast;\n\t\t}\n\t\n\t$debug and print $A;\n\t$debug and print $B;\n\t\n\t$_ = eval \"0b$_\" for $A, $B;\n\t\n\t$debug and print \"$A $B\";\n\t\n\tprint +( sort { $a <=> $b } \n\t\t1 + $A - $B, \n\t\t( $c > 1 ? 1 : 0 ) + 0 - $A + ( 1 << ( $len - 1 ) ) \n\t\t)[ 0 ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $A, $B ) = split;\n\t\n\t$debug and print \"$A $B\";\n\t\n\t$_ = sprintf \"%021b\", $_ for $A, $B;\n\t\n\tmy $len;\n\tmy $c = 0;\n\t\n\tOUTER:\n\twhile( 1 ){\n\t\twhile( $A =~ m/^0/ and $B =~ m/^0/ ){\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\twhile( $A =~ m/^1/ and $B =~ m/^1/ ){\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\n\t\twhile( $A =~ m/^0/ and $B =~ m/^1/ ){\n\t\t\n\t\t\t$len = length $A;\n\t\t\t$c ++;\n\t\t\t\n\t\t\t$A =~ s/.//;\n\t\t\t$B =~ s/.//;\n\t\t\t\n\t\t\tnext OUTER;\n\t\t\t}\n\t\t\t\n\t\tlast;\n\t\t}\n\t\n\t$debug and print $A;\n\t$debug and print $B;\n\t\n\t$_ = eval \"0b$_\" for $A, $B;\n\t\n\t$debug and print \"$A $B\";\n\t\n\tprint +( sort { $a <=> $b } \n\t\t1 + $A - $B, \n\t\t( $c > 1 ? 1 : 0 ) + $B - $A + ( 1 << ( $len - 1 ) ) \n\t\t)[ 0 ];\n\t}"}], "src_uid": "eed751c881767ecd978a728d980da594"}
{"source_code": "$t=readline STDIN;\nchomp $t;\n while ($t) {\n     $n= readline STDIN; chomp $n;\n     @line=split / /, readline STDIN; chomp @line;\n     \n    my $min;\n    while($l=shift @line) {\n     foreach $k (@line) {\n        $min=abs($k-$l) if abs($k-$l)<$min or !defined $min;\n        last if !$min;\n     }\n    }\n    \n    print $min;\n    print \"\\n\";\n    $t--;\n }\n", "positive_code": [{"source_code": "$t=readline STDIN;\nchomp $t;\n while ($t) {\n     $n= readline STDIN; chomp $n;\n     @line=split / /, readline STDIN; chomp @line;\n     \n    my $min;\n    while($l=shift @line) {\n     foreach $k (@line) {\n        $min=abs($k-$l) if abs($k-$l)<$min or !defined $min;\n        last if !$min;\n     }\n     last if !min;\n    }\n    \n    print $min;\n    print \"\\n\";\n    $t--;\n }"}], "negative_code": [], "src_uid": "d2669f85bdb59715352c6bc3d7ba9652"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $c ) = split;\n\t$_ = <>, chomp;\n\t$_ x= 2;\n\t\n\tif( $c eq 'g' ){\n\t\tprint 0;\n\t\tnext;\n\t\t}\n\t\n\tprint -1 + ( sort { $b <=> $a } map length, m/$c.*?g/g )[ 0 ];\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $n, $c, $_ ) = split ' ', $_ . <>;\r\n\t$_ x= 2;\r\n\t\r\n\tprint $c eq 'g' ? 0 : ( sort { $b <=> $a } map length, /$c\\K.*?g/g )[ 0 ]\r\n\t}"}], "negative_code": [], "src_uid": "9d3ee1b292a2402bb2204ab85dcab587"}
{"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $t = <STDIN>);\n\nfor (1..$t) {\n    chomp (my $n = <STDIN>);\n    chomp (my $line = <STDIN>);\n    my @prices = split q{ }, $line;\n    my $i = 1;\n    my @prices_and_order\n        = map { [$i++,$_] } @prices;\n\n    @prices_and_order \n        = sort { $a->[1] <=> $b->[1] } @prices_and_order;\n\n    my $pao = shift @prices_and_order;\n    my $max = $pao->[0];\n    my $answer = 0;\n    for ( @prices_and_order ) {\n        if ( $pao->[1] == $_->[1] ) {\n            if ( $_->[0] > $max ) {\n                $max = $_->[0];\n            }\n            else {\n                $answer++;\n            }\n        }\n        else {\n            if ( $max > $_->[0] ) {\n                $answer++;\n            }\n            else {\n                $max = $_->[0];\n            }\n        }\n        $pao = $_;\n    }\n    say $answer;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = split ' ', <>;\n\t\n\t$debug and print \"\\@_: @_\";\n\t\n\t@_ = reverse @_;\n\t\n\tmy @min;\n\t\n\t$min[ 0 ] = $_[ 0 ];\n\t\n\tmy $min = $min[ 0 ];\n\t\n\tfor my $i ( 1 .. @_ - 1 ){\n\t\t$min > $_[ $i ] and $min = $_[ $i ];\n\t\t$min[ $i ] = $min;\n\t\t}\n\t\n\t@min = reverse @min;\n\t@_ = reverse @_;\n\t\n\t$debug and print \"\\@min: @min\";\n\t\n\tmy $cnt = 0;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\t$cnt += $_[ $i ] > $min[ $i ];\n\t\t}\n\t\n\tprint $cnt;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $t = <STDIN>);\n\nfor (1..$t) {\n    chomp (my $n = <STDIN>);\n    chomp (my $line = <STDIN>);\n    my @prices = split q{ }, $line;\n    my $i = 1;\n    my @prices_and_order\n        = map { [$i++,$_] } @prices;\n\n    @prices_and_order \n        = sort { $a->[1] <=> $b->[1] } @prices_and_order;\n\n    my $pao = shift @prices_and_order;\n    my $max = $pao->[0];\n    my $answer = 0;\n    for ( @prices_and_order ) {\n        if ( $pao->[1] == $_->[1] ) {\n        }\n        else {\n            if ( $max > $_->[0] ) {\n                $answer++;\n            }\n            else {\n                $max = $_->[0];\n            }\n        }\n        $pao = $_;\n    }\n    say $answer;\n}\n"}, {"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $t = <STDIN>);\n\nfor (1..$t) {\n    chomp (my $n = <STDIN>);\n    chomp (my $line = <STDIN>);\n    my @prices = split q{ }, $line;\n    my $i = 1;\n    my @prices_and_order\n        = map { [$i++,$_] } @prices;\n\n    @prices_and_order \n        = sort { $a->[1] <=> $b->[1] } @prices_and_order;\n\n    my $pao = shift @prices_and_order;\n    my $max = $pao->[0];\n    my $answer = 0;\n    for ( @prices_and_order ) {\n        if ( $pao->[1] == $_->[1] ) {\n            $max = $_->[0];\n        }\n        else {\n            if ( $max > $_->[0] ) {\n                $answer++;\n            }\n            else {\n                $max = $_->[0];\n            }\n        }\n        $pao = $_;\n    }\n    say $answer;\n}\n"}], "src_uid": "09faf19627d2ff00c3821d4bc2644b63"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m, $k) = split;\n\t@A = 0;\n\tfor $i (1 .. $n){\n\t\t$_ = <>, chomp;\n\t\tpush @A, [ undef, split // ];\n\t\t}\n\n\t$is = 1;\n\t$next = 1;\n\t%NO = ();\n\t%OCC = ();\n\t\n\twhile($is){\n\t\t$found = 0;\n\t\tfor $i (0 .. $n+1){\n\t\t\tfor $j (0 .. $m+1){\n\t\t\t\t$A[$i][$j] eq '.' and do {\n\t\t\t\t\t\t$found ++;\n\t\t\t\t\t\t($x, $y) = ($i, $j);\n\t\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t$found and last;\n\t\t\t}\n\t\t\n\t\tif ($found){\n\t\t\tpush @try, ($x, $y);\n\t\t\twhile( @try ){\n\t\t\t\t($x, $y) = splice @try, 0, 2;\n\t\t\t\tif ($A[$x][$y] eq '.'){\n\t\t\t\t\t$A[$x][$y] = $next;\n\t\t\t\t\tpush @try, ($x-1, $y), ($x, $y-1), ($x+1, $y), ($x, $y+1);\n\t\t\t\t\t}\n\t\t\t\telsif (!defined $A[$x][$y]){\n\t\t\t\t\t$NO{ $next } ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\telse {$is = 0}\n\t\t\n\t\t$next ++;\n\t\t}\n\t\n\tfor $c (1 .. $next){\n\t\t$NO{ $c } and next;\n\t\t$occ = 0;\n\t\tfor (@A){ \n\t\t\t$occ += grep $_ == $c, @{$_};\n\t\t\t}\n\t\t$occ and $OCC{ $c } = $occ;\n\t\t}\n\t\n\t$K = keys %OCC;\n\t%delete = ('*' => 1, map { $_, 1 } (sort { $OCC{$b} <=> $OCC{$a} } keys %OCC)[ $k .. $K - 1 ] );\n\n\tprint 0 + eval join '+', map { $OCC{$_} } grep /\\d/, keys %delete;\n\t\n\tfor $i (1 .. $n){\n\t\tfor $j (1 .. $m){\n\t\t\t$A[$i][$j] = $delete{ $A[$i][$j] } ? '*' : '.'\n\t\t\t}\n\t\tprint @{$A[$i]}[1 .. $m];\n\t\t\n\t\t}\n\t}", "positive_code": [{"source_code": "($n, $m, $k) = split \" \", <>; \n@s = <>; chomp @s; y/*./01/ for @s;\n@n = 0..$n-1;\n\nfor (@n) {\n\twhile ($s[$_] =~ /1+/g) {\n\t\t$l = length $&;\n\t\t$f = $_==0 || $_==$n-1 || $-[0]==0 || $+[0]==$m;\n\t\t$a = [(0 x $m) x $n, $f? $n*$m: $l];\n\t\tsubstr($$a[$_], $-[0], $l, $&);\n\t\t@N = ();\n\t\tfor $b (@L) {\n\t\t\tif ($_ && ($$a[$_] & $$b[$_-1]) =~ /1/) {\n\t\t\t\t$$a[$_] |= $$b[$_] for @n;\n\t\t\t\t$$a[$n] += $$b[$n];\n\t\t\t} else {\n\t\t\t\tpush @N, $b;\n\t\t\t}\n\t\t}\n\t\t@L = (@N, $a);\n\t}\n}\n\nsub w { $_[0]->[$n] }\n@L = grep w($_) < $n*$m, @L;\n@L = sort { w($a) <=> w($b) } @L;\n\n$k = @L - $k; $c = 0;\nfor (1..$k) {\n\t$l = shift @L;\n\t$c += w($l);\n\ty/10/01/ for @$l;\n\t$s[$_] &= $$l[$_] for @n;\n}\n\ny/01/*./ for @s;\nprint \"$c\\n\", join(\"\\n\", @s);\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m, $k) = split;\n\t@A = ();\n\tpush @A, [ (-1) x (2 + $m) ];\n\tfor $i (1 .. $n){\n\t\t$_ = <>, chomp;\n\t\tpush @A, [ -1, (split //), -1 ];\n\t\t}\n\tpush @A, [ (-1) x (2 + $m) ];\n\t\n#\tprint @$_ for @A;\n\t\n\t$is_point = 1;\n\t$next = 1;\n\t%NO = ();\n\t%OCC = ();\n\t\n\twhile($is_point){\n\t\t$found = 0;\n\t\tfor $i (0 .. $n+1){\n\t\t\tfor $j (0 .. $m+1){\n\t\t\t\t$A[$i][$j] eq '.' and do {\n\t\t\t\t\t\t$found ++;\n\t\t\t\t\t\t($x, $y) = ($i, $j);\n\t\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t$found and last;\n\t\t\t}\n\t\t\n\t\tif ($found){\n\t\t\t$A[$x][$y] = $next;\n\t\t\tpush @try, ($x-1, $y), ($x, $y-1), ($x+1, $y), ($x, $y+1);\n\t\t\twhile( @try ){\n\t\t\t\t($xx, $yy) = (shift @try, shift @try);\n\t\t\t\tif ($A[$xx][$yy] eq '.'){\n\t\t\t\t\t$A[$xx][$yy] = $next;\n\t\t\t\t\tpush @try, ($xx-1, $yy), ($xx, $yy-1), ($xx+1, $yy), ($xx, $yy+1);\n\t\t\t\t\t}\n\t\t\t\telsif ($A[$xx][$yy] eq '-1'){\n\t\t\t\t\t$NO{ $next } ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\telse {$is_point = 0}\n\t\t\n\t\t$next ++;\n\t\t}\n\t\t\n#\tprint @$_ for @A;\n\t\n#\tprint join ' ', keys %NO;\n#\tprint $next;\n\t\n\tfor $c (1 .. $next){\n\t\t$NO{ $c } and next;\n\t\t$occ = 0;\n\t\tfor (@A){ \n\t\t\t$occ += grep $_ == $c, @{$_};\n\t\t\t}\n\t\t$occ and $OCC{ $c } = $occ;\n\t\t}\n\t\n#\tprint \"$_ -> $OCC{$_}\" for keys %OCC;\n\t\n\t$K = keys %OCC;\n\t%delete = ('*' => 1, map { $_, 1 } (sort { $OCC{$b} <=> $OCC{$a} } keys %OCC)[ $k .. $K - 1 ] );\n\n#\tprint \"K k[$K $k]\";\n\t\n\t$del = eval join '+', map { $OCC{$_} } grep /\\d/, keys %delete;\n\t\n\tprint 0+$del;\n\t\n\tfor $i (1 .. $n){\n\t\tfor $j (1 .. $m){\n\t\t\t$A[$i][$j] = $delete{ $A[$i][$j] } ? '*' : '.'\n\t\t\t}\n\t\tprint @{$A[$i]}[1 .. $m];\n\t\t\n\t\t}\n\t}"}], "negative_code": [{"source_code": "($n, $m, $k) = split \" \", <>; \n@s = <>; chomp @s; y/*./01/ for @s;\n@n = 0..$n-1;\n\nfor (@n) {\n\twhile ($s[$_] =~ /1+/g) {\n\t\t$l = length $&;\n\t\t$f = $_==0 || $_==$n-1 || $-[0]==0 || $+[0]==$m;\n\t\t$a = [(0 x $m) x $n, $f? $n*$m: $l];\n\t\tsubstr($$a[$_], $-[0], $l, $&);\n\t\t@N = ();\n\t\tfor $b (@L) {\n\t\t\tif (($$a[$_] & $$b[$_-1]) =~ /1/) {\n\t\t\t\t$$a[$_] |= $$b[$_] for @n;\n\t\t\t\t$$a[$n] += $$b[$n];\n\t\t\t} else {\n\t\t\t\tpush @N, $b;\n\t\t\t}\n\t\t}\n\t\t@L = (@N, $a);\n\t}\n}\n\nsub w { $_[0]->[$n] }\n@L = grep w($_) < $n*$m, @L;\n@L = sort { w($a) <=> w($b) } @L;\n\n$k = @L - $k; $c = 0;\nfor (1..$k) {\n\t$l = shift @L;\n\t$c += w($l);\n\ty/10/01/ for @$l;\n\t$s[$_] &= $$l[$_] for @n;\n}\n\ny/01/*./ for @s;\nprint \"$c\\n\", join(\"\\n\", @s);\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m, $k) = split;\n\t@A = ();\n\tpush @A, [ (-1) x (2 + $m) ];\n\tfor $i (1 .. $n){\n\t\t$_ = <>, chomp;\n\t\tpush @A, [ -1, (split //), -1 ];\n\t\t}\n\tpush @A, [ (-1) x (2 + $m) ];\n\t\n#\tprint @$_ for @A;\n\t\n\t$is_point = 1;\n\t$next = 1;\n\t%NO = ();\n\t%OCC = ();\n\t\n\twhile($is_point){\n\t\t$found = 0;\n\t\tfor $i (0 .. $n+1){\n\t\t\tfor $j (0 .. $m+1){\n\t\t\t\t$A[$i][$j] eq '.' and do {\n\t\t\t\t\t\t$found ++;\n\t\t\t\t\t\t($x, $y) = ($i, $j);\n\t\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t$found and last;\n\t\t\t}\n\t\t\n\t\tif ($found){\n\t\t\t$A[$x][$y] = $next;\n\t\t\tpush @try, ($x-1, $y), ($x, $y-1), ($x+1, $y), ($x, $y+1);\n\t\t\twhile( @try ){\n\t\t\t\t($xx, $yy) = (shift @try, shift @try);\n\t\t\t\tif ($A[$xx][$yy] eq '.'){\n\t\t\t\t\t$A[$xx][$yy] = $next;\n\t\t\t\t\tpush @try, ($xx-1, $yy), ($xx, $yy-1), ($xx+1, $yy), ($xx, $yy+1);\n\t\t\t\t\t}\n\t\t\t\telsif ($A[$xx][$yy] eq '-1'){\n\t\t\t\t\t$NO{ $next } ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\telse {$is_point = 0}\n\t\t\n\t\t$next ++;\n\t\t}\n\t\t\n#\tprint @$_ for @A;\n\t\n#\tprint join ' ', keys %NO;\n#\tprint $next;\n\t\n\tfor $c (1 .. $next){\n\t\t$NO{ $c } and next;\n\t\t$occ = 0;\n\t\tfor (@A){ \n\t\t\t$occ += grep $_ == $c, @{$_};\n\t\t\t}\n\t\t$occ and $OCC{ $c } = $occ;\n\t\t}\n\t\n#\tprint \"$_ -> $OCC{$_}\" for keys %OCC;\n\t\n\t$K = keys %OCC;\n\t%delete = ('*' => 1, map { $_, 1 } (sort { $OCC{$b} <=> $OCC{$a} } keys %OCC)[ $k .. $K - 1 ] );\n\n#\tprint \"K k[$K $k]\";\n\t\n\tprint $K - $k;\n\t\n\tfor $i (1 .. $n){\n\t\tfor $j (1 .. $m){\n\t\t\t$A[$i][$j] = $delete{ $A[$i][$j] } ? '*' : '.'\n\t\t\t}\n\t\tprint @{$A[$i]}[1 .. $m];\n\t\t\n\t\t}\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m, $k) = split;\n\t@A = ();\n\tpush @A, [ (-1) x (2 + $m) ];\n\tfor $i (1 .. $n){\n\t\t$_ = <>, chomp;\n\t\tpush @A, [ -1, (split //), -1 ];\n\t\t}\n\tpush @A, [ (-1) x (2 + $m) ];\n\t\n#\tprint @$_ for @A;\n\t\n\t$is_point = 1;\n\t$next = 1;\n\t%NO = ();\n\t%OCC = ();\n\t\n\twhile($is_point){\n\t\t$found = 0;\n\t\tfor $i (0 .. $n+1){\n\t\t\tfor $j (0 .. $m+1){\n\t\t\t\t$A[$i][$j] eq '.' and do {\n\t\t\t\t\t\t$found ++;\n\t\t\t\t\t\t($x, $y) = ($i, $j);\n\t\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t$found and last;\n\t\t\t}\n\t\t\n\t\tif ($found){\n\t\t\t$A[$x][$y] = $next;\n\t\t\tpush @try, ($x-1, $y), ($x, $y-1), ($x+1, $y), ($x, $y+1);\n\t\t\twhile( @try ){\n\t\t\t\t($xx, $yy) = (shift @try, shift @try);\n\t\t\t\tif ($A[$xx][$yy] eq '.'){\n\t\t\t\t\t$A[$xx][$yy] = $next;\n\t\t\t\t\tpush @try, ($xx-1, $yy), ($xx, $yy-1), ($xx+1, $yy), ($xx, $yy+1);\n\t\t\t\t\t}\n\t\t\t\telsif ($A[$xx][$yy] eq '-1'){\n\t\t\t\t\t$NO{ $next } ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\telse {$is_point = 0}\n\t\t\n\t\t$next ++;\n\t\t}\n\t\t\n#\tprint @$_ for @A;\n\t\n#\tprint join ' ', keys %NO;\n#\tprint $next;\n\t\n\tfor $c (1 .. $next){\n\t\t$NO{ $c } and next;\n\t\t$occ = 0;\n\t\tfor (@A){ \n\t\t\t$occ += grep $_ == $c, @{$_};\n\t\t\t}\n\t\t$occ and $OCC{ $c } = $occ;\n\t\t}\n\t\n#\tprint \"$_ -> $OCC{$_}\" for keys %OCC;\n\t\n\t$K = keys %OCC;\n\t%delete = ('*' => 1, map { $_, 1 } (sort { $OCC{$b} <=> $OCC{$a} } keys %OCC)[ $k .. $K - 1 ] );\n\n#\tprint \"K k[$K $k]\";\n\t\n\t$del = eval join '+', map { $OCC{$_} } grep /\\d/, keys %delete;\n\t\n\tprint $del;\n\t\n\tfor $i (1 .. $n){\n\t\tfor $j (1 .. $m){\n\t\t\t$A[$i][$j] = $delete{ $A[$i][$j] } ? '*' : '.'\n\t\t\t}\n\t\tprint @{$A[$i]}[1 .. $m];\n\t\t\n\t\t}\n\t}"}], "src_uid": "e514d949e7837c603a9ee032f83b90d2"}
{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = <>;\nif ($n =~ /0/) {\n    $n =~ s/0//;\n} else {\n    $n =~ s/1//;\n}\nprint $n;\n", "positive_code": [{"source_code": "chomp($_ = <>);\nunless (s/0//) { s/^.//; }\ns/^0*//;\nprint;\n"}, {"source_code": "#!/bin/bash/perl\n$input=<>;\n@inputProcessor=split(\" \",$input);\n$input=$inputProcessor[0];\n@elements=split(\"\",$input);\n$f=0;\nfor($i=0;$i<@elements;++$i){\n\tif($f==0 && $i==(@elements-1)){\n\t\t#do nothing\n\t}\n\telse{\n\t\tif($elements[$i] eq 0 && $f==0){\n\t\t\t#then trim it and dont print\n\t\t\t#also signal the flag\n\t\t\t$f=1;\n\t\t}\n\t\telse{\n\t\t\tprint $elements[$i];\n\t\t}\n\t}\n}"}], "negative_code": [{"source_code": "#!/bin/bash/perl\n$input=<>;\n@inputProcessor=split(\" \",$input);\n$input=$inputProcessor[0];\n$input=$input+0;\n@elements=split(\"\",$input);\n$f=0;\nfor($i=0;$i<@elements;++$i){\n\tif($f==0 && $i==(@elements-1)){\n\t\t#do nothing\n\t}\n\telse{\n\t\tif($elements[$i]==0 && $f==0){\n\t\t\t#then trim it and dont print\n\t\t\t#also signal the flag\n\t\t\t$f=1;\n\t\t}\n\t\telse{\n\t\t\tprint $elements[$i];\n\t\t}\n\t}\n}"}], "src_uid": "133eaf241bb1557ba9a3f59c733d34bf"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\t\r\n\tmy %h;\r\n\t\r\n\t$h{ $_ } ++ for @_;\r\n\t\r\n\t@_ = 1 .. @_;\r\n\t\r\n\t$_ < keys %h and $_ = keys %h for @_;\r\n\t\r\n\tprint \"@_\";\r\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tmy %h;\r\n\t\r\n\t$h{ $_ } ++ for split ' ', <>;\r\n\t\r\n\t$k = keys %h;\r\n\t\r\n\tprint join ' ', ( $k ) x $k, $k + 1 .. $_;\r\n\t}"}, {"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\t\r\n\tmy %h;\r\n\t\r\n\t$h{ $_ } ++ for @_;\r\n\t\r\n\tprint join ' ', map { ( sort { $b <=> $a } $_, 0 + keys %h )[ 0 ] } 1 .. @_;\r\n\t}"}], "negative_code": [], "src_uid": "06212223295c56a78a5d4e55c53a63e0"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $x ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = unpack '%32i' . @_, pack 'i' . @_, @_;\n\t\t\n\tprint $sum + @_ - 1 == $x ? \"YES\" : \"NO\";\n\t}", "positive_code": [{"source_code": "( $n, $x ) = split ' ', <>;\n\t\t\t\t\t\nprint $x == $n - 1 + ( eval <> =~ s/ / + /gr ) ? \"YES\" : \"NO\""}], "negative_code": [], "src_uid": "080a3458eaea4903da7fa4cf531beba2"}
{"source_code": "while(<>){print<>}", "positive_code": [{"source_code": "while(<>){print<>}"}, {"source_code": "while(<>){print<>,\" \";}"}, {"source_code": "while(<>){print <>,\" \";}"}, {"source_code": "while(<>){print<>}"}, {"source_code": "while(<>){print<>}"}, {"source_code": "print<> while(<>)"}, {"source_code": "while(<>){print<>}"}], "negative_code": [], "src_uid": "b7e36ca8a96dd7951359070d4953beec"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\t$_ = <>;\n\t\n\t$rx = qr/\\.(?=\\.)/;\n\t$sum = () = /$rx/g;\n\t\n\ts/^/a/;\n\t\n\t@_ = ();\n\t\n\tfor $i (1 .. $m){\n\t\t($pos, $let) = split ' ', <>;\n\t\t$sum -= () = (substr $_, $pos - 1, 3) =~ /$rx/g;\n\t\tsubstr $_, $pos, 1, $let;\n\t\t$sum += () = (substr $_, $pos - 1, 3) =~ /$rx/g;\n\t\tpush @_, $sum;\n\t\t}\n\t\t\n\t$, = $/;\n\tprint @_;\n\t\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n\t($n, $m) = split \" \", <>;\n\t$_ = <>, chomp;\n\t$sum = () = /\\.(?=\\.)/g;\n\t\n\t$_ = 'a' . $_ . 'a';\n\t@_ = ();\n\t\n\t{local $/; $a = <>};\n\t@a = split \" \", $a;\n\t\n\tfor $i (1 .. $m){\n\t\tpush @_, $sum;\n\t\t($idx, $let) = (shift @a, shift @a);\n\t\t($pre, $is, $post) = split //, substr $_, $idx - 1, 3;\n\t\tsubstr $_, $idx, 1, $let;\n\t\t$is ne '.' and $let ne '.' and next;\n\t\t$is eq '.' and $let eq '.' and next;\n\t\tif ($is eq '.' and $let ne '.'){\n\t\t\t$sum -= ($pre eq '.') + ($post eq '.');\n\t\t\t} \n\t\telsif ($is ne '.' and $let eq '.'){\n\t\t\t$sum += ($pre eq '.') + ($post eq '.');\n\t\t\t} \n\t\t}\n\t\t\n\tpush @_, $sum;\n\tshift @_;\n\n\t$, = $/;\n\tprint @_;\n\t"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\t$_ = <>, chomp;\n\t$sum = () = /\\.(?=\\.)/g;\n\t\n\t$_ = 'a' . $_ . 'a';\n\t@_ = ();\n\t\n\tfor $i (1 .. $m){\n\t\tpush @_, $sum;\n\t\t($idx, $let) = split \" \", <>;\n\t\t($pre, $is, $post) = split //, substr $_, $idx - 1, 3;\n\t\tsubstr $_, $idx, 1, $let;\n\t\t$is ne '.' and $let ne '.' and next;\n\t\t$is eq '.' and $let eq '.' and next;\n\t\tif ($is eq '.' and $let ne '.'){\n\t\t\t$sum -= ($pre eq '.') + ($post eq '.');\n\t\t\t} \n\t\telsif ($is ne '.' and $let eq '.'){\n\t\t\t$sum += ($pre eq '.') + ($post eq '.');\n\t\t\t} \n\t\t}\n\t\t\n\tpush @_, $sum;\n\tshift @_;\n\n\t$, = $/;\n\tprint @_;\n\t}"}, {"source_code": "($n, $m) = split ' ', <>;\n$_ = <>;\n\n$rx = qr/\\.(?=\\.)/;\n$s = () = /$rx/g;\n\ns/^/a/;\n\t\nfor $i (1 .. $m){\n\t($pos, $L) = split ' ', <>;\n\t$s -= () = (substr $_, $pos - 1, 3) =~ /$rx/g;\n\tsubstr $_, $pos, 1, $L;\n\t$s += () = (substr $_, $pos - 1, 3) =~ /$rx/g;\n\tpush @_, $s\n\t}\n\t\t\n$, = $/;\nprint @_"}], "negative_code": [{"source_code": "($n, $m) = split, ' ', <>;\n$_ = <>;\n\n$rx = qr/\\.(?=\\.)/;\n$s = () = /$rx/g;\n\ns/^/a/;\n\t\nfor $i (1 .. $m){\n\t($pos, $L) = split ' ', <>;\n\t$s -= () = (substr $_, $pos - 1, 3) =~ /$rx/g;\n\tsubstr $_, $pos, 1, $L;\n\t$s += () = (substr $_, $pos - 1, 3) =~ /$rx/g;\n\tpush @_, $s\n\t}\n\t\t\n$, = $/;\nprint @_"}], "src_uid": "68883ab115882de5cf77d0848b80b422"}
{"source_code": "($x,$y,$a,$b)=split(/ |\\n/,<>);\n$sum=0;\nfor($i=($a>$b ? $a : $b); $i<=$x; $i++){\n\tfor($j=$b; $j<$i && $j<=$y ; $j++){\n\t\t$sum++;\n\t}\n}\nprint \"$sum\\n\";\nfor($i=($a>$b ? $a : $b); $i<=$x; $i++){\n\tfor($j=$b; $j<$i && $j<=$y ; $j++){\n\t\tprint \"$i $j\\n\";\n\t}\n}\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp($_ = <>);\nmy ($x, $y, $p, $q) = split;\nmy @res = ();\n\nfor my $v ($p .. $x) {\n    for my $p ($q .. $y) {\n        next if $v <= $p;\n        push @res, [$v, $p];\n    }\n}\n\n@res = sort { if ($$a[0] != $$b[0]) { $$a[0] <=> $$b[0]; } else { $$a[1] <=> $$b[1]; }  } @res;\nprint scalar @res, \"\\n\";\nfor (@res) {\n    print \"@$_\\n\";\n}\n"}, {"source_code": "while (<>){\n    chomp;\n    / (\\d+) (\\d+) /;\n    $a=0;\n    @_=();\n    for ($i=($'+1>$2?$'+1:$2) ; $i<=$`; $i++){\n        for ($j=$'; $j<$i && $j<=$1; $j++){\n            $a++;\n            push @_,\"$i $j\\n\"\n            }\n        }\n    unshift @_, \"$a\\n\";\n    print @_\n    }"}], "negative_code": [{"source_code": "($x,$y,$a,$b)=split(/ |\\n/,<>);\n$sum=0;\nfor($i=($a>$b ? $a : $b); $i<=$x; $i++){\n\tfor($j=$b; $j<$i; $j++){\n\t\t$sum++;\n\t}\n}\nprint \"$sum\\n\";\nfor($i=($a>$b ? $a : $b); $i<=$x; $i++){\n\tfor($j=$b; $j<$i; $j++){\n\t\tprint \"$i $j\\n\";\n\t}\n}\n\n"}, {"source_code": "($x,$y,$a,$b)=split(/ |\\n/,<>);\n$sum=0;\nfor($i=($a>$b ? $a : $b); $i<=$x; $i++){\n\tfor($j=$b; $j<$i && $j<$y ; $j++){\n\t\t$sum++;\n\t}\n}\nprint \"$sum\\n\";\nfor($i=($a>$b ? $a : $b); $i<=$x; $i++){\n\tfor($j=$b; $j<$i && $j<$y ; $j++){\n\t\tprint \"$i $j\\n\";\n\t}\n}\n\n"}, {"source_code": "while (<>){\n    chomp;\n    / (\\d+) (\\d+) /;\n    $a=0;\n    @_=();\n    for ($i=($'+1>$2?$'+1:$2) ; $i<=$`; $i++){\n        for ($j=$'; $j<$i; $j++){\n            $a++;\n            push @_,\"$i $j\\n\"\n            }\n        }\n    unshift @_, \"$a\\n\";\n    print @_\n    }"}], "src_uid": "bb3e3b51a4eda8fef503952a00777910"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = (split ' ', <>);\n\t$i = 0; map { $A[ $_ ] = ++ $i } @_;\n\t$prev = 0;\n\t$len = 0;\n\t$max = 0;\n\tfor (1 .. @_){\n\t\n\t\t$prev < $A[ $_ ] ?\n\t\t\tdo { $len ++ ; $prev = $A[ $_ ]; $max < $len and $max = $len; }\n\t\t:\n\t\t\tdo { $len = 0; $prev = 0; redo };\n\t}\n\tprint @_ - $max\n\t}", "positive_code": [{"source_code": "$n = <>;\n@a = split(' ', <>);\n\nforeach(@a){\n\t$p[$_] = $p[$_ - 1] + 1;\n}\nfor(1..$n){\n\t$re = $re < $p[$_] ? $p[$_] : $re;\n}\nprint $n - $re;"}], "negative_code": [], "src_uid": "277948a70c75840445e1826f2b23a897"}
{"source_code": "($n, $k, $p, $x, $y, @_) = split \" \", join '', <>;\nmap $df += .1 + $_ <=> $y, @_;\nfor $i (1 .. $n - $k){\n\tpush @_, $df > 0 ? 1 : $y;\n\t$df  += .1 <=>  $df;\n\t}\n$s += $_ for @_;\nprint $s > $x || $df < 0 ? -1 : \"@_[$k .. $n-1]\"", "positive_code": [{"source_code": "($n, $k, $p, $x, $y, @_) = split \" \", join '', <>;\nmap $df += .1 + $_ <=> $y, @_;\nfor $i (1 .. $n - $k){\n\tpush @_, $df > 0 ? 1 : $y;\n\t$df  += .1 <=>  $df;\n\t}\n$s += $_ for @_;\nprint $s > $x || $df < 0 ? -1 : \"@_[$k .. $n-1]\""}], "negative_code": [{"source_code": "$\\ = $/;\nwhile(<>){\n\t($n, $k, $p, $x, $y) = split;\n\t@_ = split \" \", <>;\n\t$le = scalar grep $_ <  $y, @_;\n\t$mo = scalar grep $_ >= $y, @_;\n\t$df = $mo - $le;\n#\t\tprint \"$le $mo | $df\";\n\t\tfor $i (1 .. $n - $k){\n\t\t\tif ($df > 0){\n\t\t\t\tif (@_ == $n - 1 and $n % 2 == 0){\n\t\t\t\t\t@a = sort {$a <=> $b} @_;\n\t\t\t\t\t$mid = $a[$n / 2];\n\t\t\t\t\tpush @_, $y - ($mid - $y);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tpush @_, 1;\n\t\t\t\t\t\t}\n\t\t\t\t$df --;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tpush @_, $y;\n\t\t\t\t$df ++;\n\t\t\t\t}\n\t\t\t}\n\t\t$sum = 0;\n\t\t$sum += $_ for @_;\n\t\t\n\t\tprint $sum > $x ? -1 : \"@_[$k .. $n-1]\";\n\t}"}], "src_uid": "f01d11bd231a7b2e7ca56de1df0f1272"}
{"source_code": "while(<>){\n\tchomp;\n\t$a=0;\n\twhile (s/^(.*?)bear/ear/){\n\t\t$a+=(1+length $1)*(1+length $');\n\t\t}\n\tprint $a\n\t}", "positive_code": [{"source_code": "#!/bin/perl\n\nchomp(my $str = <>);\nmy $str_len = length $str;\nmy $start = 0;\nmy $ans = 0;\nwhile ((my $idx = index($str, 'bear', $start)) != -1) {\n    my ($f, $s) = ($idx - $start, $str_len - $idx - 4);\n    $ans += $f + $s + 1 + $f * $s;\n    $start = $idx + 1;\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "chomp($_ = <>);\nwhile (s/\\A(.*?)bear/ear/) {\n    $ans += (1 + length $1) * (1 + length $');\n}\nprint ($ans or 0) . \"\\n\";\n"}], "negative_code": [{"source_code": "chomp($_ = <>);\nwhile (s/(.*?)bear/ear/) {\n    $ans += (1 + length $1) * (1 + length $');\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "chomp($_ = <>);\nwhile (s/\\A(.*?)bear/ear/) {\n    $ans += (1 + length $1) * (1 + length $');\n}\nprint $ans . \"\\n\";\n"}], "src_uid": "240a2b88ded6016d0fd7157d0ee2beea"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tm/./, s/$&/</g;\r\n\t\r\n\t/\\w$/ and s/$&/>/g or print 'NO' and next;\r\n\t\r\n\tprint qw( YES NO )[ ! grep {\r\n\t\t\t1 while s/<>//g;\r\n\t\t\t! m/./\r\n\t\t\t} s/\\w/</gr, s/\\w/>/gr \r\n\t\t];\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\t/./;\n\tmy $open = $&;\n\t\n\ts/$open/(/g;\n\t\n\t/[ABC]$/ or do {\n\t\tprint 'NO';\n\t\tnext;\n\t\t};\n\t\n\tmy $close = $&;\n\t\n\ts/$close/)/g;\n\t\n\tmy $A = s/[ABC]/(/gr;\n\tmy $B = s/[ABC]/)/gr;\n\t\n\t1 while $A =~ s/[(][)]//g;\n\t1 while $B =~ s/[(][)]//g;\n\t\n\tif( ! $A or ! $B ){\n\t\tprint \"YES\";\n\t\t}\n\telse{\n\t\tprint \"NO\";\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "4d24aaf5ebf70265b027a6af86e09250"}
{"source_code": "$_=<>;\n$a=<>;\n\nchomp;\nchomp $a;\n\ns/ //g;\n$a=~s/ //g;\n\n@_=split//,$a;\n\nfor $i(0..@_-1){\ns/$_[$i]// or $f++\n}\n\nprint $f?\"NO\\n\":\"YES\\n\"", "positive_code": [{"source_code": "$s1=<>;\n$s2=<>;\n$s1=~s/\\s+//g;\n$s2=~s/\\s+//g;\n++$h1{$_} for split'',$s1;\n++$h2{$_} for split'',$s2;\nfor(keys %h2) {\n  print \"NO\" and exit if($h2{$_} > $h1{$_});\n}\nprint\"YES\"\n"}, {"source_code": "#!/bin/bash/perl\n$input=<>;\n@reference = split(\" \",$input);\n$input=<>;\n@tofind=split(\" \",$input);\n#for($x=0;$x<@tofind;++$x){print length($tofind[$x]).\"\\n\";}\n%hash;\nfor($var='a';$var ne 'aa';++$var){\n    $hash{$var}=0;\n}\nfor($var='A';$var ne 'AA';++$var){\n    $hash{$var}=0;\n}\n#fill the hash\nfor($i=0;$i<@reference;++$i){\n    @temp=split(\"\",$reference[$i]);\n    for($j=0;$j<@temp;++$j){\n        ++$hash{$temp[$j]};\n    }\n}\n\n#start checking the hash\n$notfound=1;\nfor($i=0;$i<@tofind && $notfound==1;++$i){\n    @temp=split(\"\",$tofind[$i]);\n    for($j=0;$j<@temp;++$j){\n        if($hash{$temp[$j]}<=0){\n            $notfound=0;\n            $j=@temp;\n        }\n        else{\n            $hash{$temp[$j]}--;\n        }\n    }\n}\n\nif($notfound==0){\n    print \"NO\";\n}\nelse{\n    print \"YES\";\n}"}], "negative_code": [{"source_code": "#!/bin/bash/perl\n$input=<>;\n@reference = split(\" \",$input);\n$input=<>;\n@tofind=split(\" \",$input);\n#for($x=0;$x<@tofind;++$x){print length($tofind[$x]).\"\\n\";}\n$tofindnums=@tofind;\n$havenums=@reference;\n$found=0;\n$inflag;\n\n\n\n\nfor($i=0;$i<@tofind;++$i){\n    $wordlen=length($tofind[$i]);\n    $inflag=1;\n    \n    for($j=0;$j<@reference && $inflag;++$j){\n        \n        if(length($reference[$j])>= $wordlen){\n            \n            for($k=0;$k<=length($reference[$j])-$wordlen;++$k){\n                $sub = substr($reference[$j],$k,$wordlen);\n                #print \"sub found is $sub \\n\";\n                if($sub eq $tofind[$i]){\n                    #increase found enrty\n                    ++$found;\n                    #now replenish this with new character\n                    @temp=split(\"\",$reference[$j]);\n                    for($s=$k;$s<$k+$wordlen;++$s){\n                        $temp[$s]='-';\n                    }\n                    $tempnew;\n                    for($s=0;$s<@temp;++$s){\n                        if($temp[$s] ne '-')\n                        {$tempnew=$tempnew.$temp[$s];}\n                    }\n                    $reference[$j]=$tempnew;\n                    \n                    #propogate out of array\n                    $k=length($reference[$j]);\n                    #mark outer array bbreaker\n                    $inflag=0;\n                }\n            }\n        }\n    }\n}\n\n\nif($found==$tofindnums){\n    print \"YES\";\n}\nelse{\n    #print \"found value is $found\\n expected value $tofindnums\\n\";\n    print \"NO\";\n}"}, {"source_code": "#!/bin/bash/perl\n$input=<>;\n@reference = split(\" \",$input);\n$input=<>;\n@tofind=split(\" \",$input);\n#for($x=0;$x<@tofind;++$x){print length($tofind[$x]).\"\\n\";}\n%hash;\nfor($var='a';$var ne 'aa';++$var){\n    $hash{$var}=0;\n}\nfor($var='A';$var ne 'AA';++$var){\n    $hash{$var}=0;\n}\n#fill the hash\nfor($i=0;$i<@reference;++$i){\n    @temp=split(\"\",$reference[$i]);\n    for($j=0;$j<@temp;++$j){\n        ++$hash{$temp[$j]};\n    }\n}\n#start checking the hash\n$notfound=1;\nfor($i=0;$i<@tofind && $notfound==1;++$i){\n    @temp=split(\"\",$tofind[$$i]);\n    for($j=0;$j<@temp;++$j){\n        if($hash{$temp[$j]}<=0){\n            $notfound=0;\n            $j=@temp;\n        }\n    }\n}\n\nif($notfound==0){\n    print \"NO\";\n}\nelse{\n    print \"YES\";\n}"}, {"source_code": "#!/bin/bash/perl\n$input=<>;\n@reference = split(\" \",$input);\n$input=<>;\n@tofind=split(\" \",$input);\n#for($x=0;$x<@tofind;++$x){print length($tofind[$x]).\"\\n\";}\n%hash;\nfor($var='a';$var ne 'aa';++$var){\n    $hash{$var}=0;\n}\nfor($var='A';$var ne 'AA';++$var){\n    $hash{$var}=0;\n}\n#fill the hash\nfor($i=0;$i<@reference;++$i){\n    @temp=split(\"\",$reference[$i]);\n    for($j=0;$j<@temp;++$j){\n        ++$hash{$temp[$j]};\n    }\n}\n#start checking the hash\n$notfound=1;\nfor($i=0;$i<@tofind && $notfound==1;++$i){\n    @temp=split(\"\",$tofind[$$i]);\n    for($j=0;$j<@temp;++$j){\n        if($hash{$temp[$j]}<=0){\n            $notfound=0;\n            $j=@temp;\n        }\n        else{\n            $hash{$temp[$j]}--;\n        }\n    }\n}\n\nif($notfound==0){\n    print \"NO\";\n}\nelse{\n    print \"YES\";\n}"}], "src_uid": "b1ef19d7027dc82d76859d64a6f43439"}
{"source_code": "\n\n#\nmy $n = <STDIN>;\nchomp ( $n );\n\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy @arr = split m/ /, $f;\nmy @arr_two = (sort { $a <=> $b } @arr);\n\nmy @ans;\nmy $i = 0;\nmy $temp;\nwhile ( @arr_two > 0 ) {\n\n    if ( $i % 2 == 0 ) {\n\tpush @ans, (shift @arr_two);}\n    else {\n\tpush @ans, (pop @arr_two);}\n    $i += 1;\n}\n\nprint (join \" \", @ans);\nprint \"\\n\";\n\n\n\n# never impossible\n\n", "positive_code": [{"source_code": "<>;\n@_ = sort {$a <=> $b} split ' ', <>;\npush @ans, shift @_, pop @_ while @_;\nprint \"@ans\""}, {"source_code": "use strict;\n\nchomp (my $n = <STDIN>);\nchomp (my @arr = sort {$a <=> $b} split /\\s+/, <STDIN>);\n\nmy (@x, @y);\nif (@arr & 1) {\n  @x = @arr[0 .. (@arr >> 1)];\n  @y = reverse @arr[(@arr >> 1) + 1 .. (@arr - 1)];\n} else {\n  @x = @arr[0 .. (@arr >> 1) - 1];\n  @y = reverse @arr[(@arr >> 1) .. (@arr - 1)];\n}\n\n# print \"@arr\\n@x\\n@y\";\n\nforeach (my $i = 0; $i < @arr; $i++) {\n  if ($i & 1) {\n    $arr[$i] = $y[$i >> 1]\n  } else {\n    $arr[$i] = $x[$i >> 1]\n  }\n}\n\nprint \"@arr\";\n"}], "negative_code": [{"source_code": "\n\nmy $n = <STDIN>;\nchomp ( $n );\nmy @arr;\nmy $f = <STDIN>;\nchomp ( $f );\n@arr = split m/ /, $f;\n\nmy @arr_two = sort @arr;\nmy @one, @two;\n\n\nmy $i;\nwhile ( @arr_two > 0 ) {\n\n    if ( ($i+1) % 2 == 0 ) {\n\tpush @one, (shift @arr_two);\n    }\n    else {\n\tpush @two, (shift @arr_two);\n    }\n\n    $i += 1;\n}\n\nmy @two_two = reverse @two;\n\nmy @ans = ();\n$i = 0;\nwhile ( @two_two > 0 or @one ) {\n\n    if ( ($i + 1) % 2 == 0 ) {\n\tpush @ans, (shift @one);}\n    else {\n\tpush @ans, (shift @two_two);}\n    $i += 1;\n}\n\n\n\nprint (join \" \", @ans);\nprint \"\\n\";\n\n\n"}, {"source_code": "\n#\nmy $n = <STDIN>;\nchomp ( $n );\n\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy @arr = split m/ /, $f;\nmy @arr_two = sort @arr;\n\nmy @ans;\nmy $i = 0;\nwhile ( @arr_two > 0 ) {\n\n    if ( $i % 2 == 0 ) {\n\tpush @ans, (shift @arr_two);}\n    else {\n\tpush @ans, (pop @arr_two);}\n    $i += 1;\n}\n\nprint (join \" \", @ans);\nprint \"\\n\";\n\n\n\n# never impossible\n\n"}, {"source_code": "\n# \nmy $n = <STDIN>;\nchomp ( $n );\nmy @arr;\nmy $f = <STDIN>;\nchomp ( $f );\n@arr = split m/ /, $f;\n\nmy @arr_two = sort @arr;\nmy @one, @two;\n\n\nmy $i;\nwhile ( @arr_two > 0 ) {\n\n    if ( ($i+1) % 2 == 0 ) {\n\tpush @one, (shift @arr_two);\n    }\n    else {\n\tpush @two, (shift @arr_two);\n    }\n\n    $i += 1;\n}\n\nmy @two_two = reverse @one;\n\nmy @ans = ();\n$i = 0;\nwhile ( @two_two > 0 or @two ) {\n\n    if ( ($i + 1) % 2 == 0 ) {\n\tpush @ans, (shift @two_two);}\n    else {\n\tpush @ans, (shift @two);}\n    $i += 1;\n}\n\n\n\nprint (join \" \", @ans);\nprint \"\\n\";\n\n\n"}, {"source_code": "use strict;\n\nchomp (my $n = <STDIN>);\nchomp (my @arr = split /\\s+/, <STDIN>);\n\nmy (@a1, @a0);\nforeach (my $i = 0; $i < @arr; $i++) {\n  if ($i & 1) {\n    push @a1, $arr[$i]\n  } else {\n    push @a0, $arr[$i]\n  }\n}\n\n@a0 = sort {$a <=> $b} @a0;\n@a1 = sort {$b <=> $a} @a1;\n\nforeach (my $i = 0; $i < @arr; $i++) {\n  if ($i & 1) {\n    $arr[$i] = $a1[$i >> 1]\n  } else {\n    $arr[$i] = $a0[$i >> 1]\n  }\n}\n\nprint \"@arr\";\n"}, {"source_code": "<>;\n@_ = sort {$a <=> $b} split ' ', <>;\npush @ans, pop @_, shift @_ while @_;\nprint \"@ans\""}], "src_uid": "2401d34db475853661d6e1e1cb5a8216"}
{"source_code": "use warnings;\nuse strict;\nuse constant NL => qq/\\n/;\nuse integer;\n\n<STDIN>;\nmy @arr = sort { $a <=> $b } ( split qq/ /, <STDIN> );\nmy $i = 0;\nwhile ( @arr > 1 ) {\n    pop @arr if ($i % 2 == 0);\n    shift @arr if ($i % 2 == 1);\n    $i += 1;\n}\nprint $arr [ 0 ];\nprint NL;\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = sort { $a <=> $b } split ' ', <>;\n\t\n\tprint $_[ ( @_ - 1 ) / 2 ];\n\t}"}], "negative_code": [{"source_code": "use warnings;\nuse strict;\nuse constant NL => qq/\\n/;\n\n<STDIN>;\nmy @arr = sort ( split qq/ /, <STDIN> );\nprint $arr [ int ( $#arr / 2) ];\nprint NL;\n\n"}, {"source_code": "use warnings;\nuse strict;\nuse constant NL => qq/\\n/;\n\n<STDIN>;\nmy @arr = sort ( split qq/ /, <STDIN> );\nmy $i = 0;\nwhile ( @arr > 1 ) {\n    pop @arr if $i % 2 == 0;\n    shift @arr if $i % 2 == 1;\n    $i += 1;\n}\nprint $arr [ 0 ];\nprint NL;\n\n"}], "src_uid": "f93a8bd64a405233342f84542fce314d"}
{"source_code": "$\\ = $/;\nwhile(<>){\n($n,$A)=split;\n@d=split \" \",<>;\n$sum = 0;\n$sum += $_ for @d;\n#print \"$sum\";\n#$diff = $sum - $A;\n\n@e = ();\n\n#$e = ($_ - 1) + $diff, ($e < 0 and $e = 0), \n#$f = ($diff > 0? $diff : 0) - ($n - 1), \n#($f < 0 and $f = 0), \n\n#(print ($sum - $_)),\n#(print ($sum - ($n - 1))),\n$e = $A - ($sum - $_),\n$f = $A - ($n - 1),\n$r = $_ - $f,\n($r < 0 and $r = 0),\n$l = $e - 1,\n($l < 0 and $l = 0),\n$q = $r + $l,\n\n#push @e, $e .\" - \". $f .\" = \".($_ - ($f - $e + 1) ).\" <$r><$l>[$q]|\" for @d;\npush @e, $q for @d;\n\n#print \":@e\";\nprint \"@e\";\n}", "positive_code": [{"source_code": "use List::Util qw(max sum);\n$\\ = $/;\n\nwhile(<>){\n\t($n, $A) = split;\n\t@d = split \" \", <>;\n\t$sum = sum @d;\n\t\n\t@e = ();\n\n\tpush @e, 0\n\t+\t(max $_ - $A + $n   - 1, 0)\n\t+\t(max $_ + $A - $sum - 1, 0)\n\tfor @d;\n\t\n\tprint \"@e\"\n}"}], "negative_code": [], "src_uid": "2c51414eeb430ad06aac53a99ff95eff"}
{"source_code": "use bigint;\n\n$\\ = $/;\n\nwhile(<>){\n\t($l, $r, $k) = split;\n\t\n\t$ans = join \" \", grep $_ <= $r, grep $l <= $_ , map $k ** ($_ + 0), 0 .. 65;\n\t\n\tprint $ans || -1\n\t\n\t}", "positive_code": [{"source_code": "use bigint;\n\n($l, $r, $k) = split ' ', <>;\n\t\nprint( ( join \" \", grep $_ <= $r && $l <= $_ , map $k ** ($_ + 0), 0 .. 65 ) || -1 )"}], "negative_code": [{"source_code": "use bigint;\n\n$\\ = $/;\n\nwhile(<>){\n\t($l, $r, $k) = split;\n\t\n\t$ans = join \" \", grep $_ <= $r, grep $l <= $_ , map $k ** $_, 0 .. 65;\n\t\n\tprint $ans || -1\n\t\n\t}"}], "src_uid": "8fcec28fb4d165eb58f829c03e6b31d1"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\t@n = split ' ', <>;\n\t@m = split ' ', <>;\n\tpush @m, 5e10;\n\t\n\t$left = -5e10;\n\t\n\t@ans = ();\n\t\n\tfor (@n){\n\t\t\n\t\twhile( $m[0] < $_ ){\n\t\t\t$left = shift @m;\n\t\t\t}\n\t\t\n\t\tpush @ans, (sort {$a <=> $b} $_ - $left, $m[0] - $_)[ 0 ];\n\t\t}\n\t\n\tprint +(sort {$b <=> $a} @ans)[ 0 ];\n\t}", "positive_code": [{"source_code": "sub get { split \" \", <> }\nsub tag { my $tag = shift; map { [$tag, $_] } @_ }\nsub max { $_[0] > $_[1]? $_[0]: $_[1] }\nsub min { $_[0] < $_[1]? $_[0]: $_[1] }\n\n<>; @n = get; @m = get;\n@a = sort {$a->[1] <=> $b->[1]} tag(0, @n), tag(1, @m);\nunshift @a, [1, -4e9]; push @a, [1, 4e9];\n@s = map $_->[0], @a; $s = join \"\", @s;\n\nwhile ($s =~ /10+(?=1)/g) {\n\t($i, $j) = ($-[0], $+[0]);\n\t$m1 = $a[$i]->[1];\n\t$m2 = $a[$j]->[1];\n\twhile (++$i < $j) {\n\t\t$v = $a[$i]->[1];\n\t\t$maxval = max($maxval, min(abs($m1 - $v), abs($m2 - $v)))\n\t}\n}\nprint $maxval, \"\\n\";\n"}], "negative_code": [{"source_code": "sub get { split \" \", <> }\nsub tag { my $tag = shift; map { [$tag, $_] } @_ }\nsub max { $_[0] > $_[1]? $_[0]: $_[1] }\nsub min { $_[0] < $_[1]? $_[0]: $_[1] }\n\n<>; @n = get; @m = get;\n@a = sort {$a->[1] <=> $b->[1]} tag(0, @n), tag(1, @m);\nunshift @a, [1, -2e9]; push @a, [1, 2e9];\n@s = map $_->[0], @a; $s = join \"\", @s;\n\nwhile ($s =~ /10+(?=1)/g) {\n\t($i, $j) = ($-[0], $+[0]);\n\t$m1 = $a[$i]->[1];\n\t$m2 = $a[$j]->[1];\n\twhile (++$i < $j) {\n\t\t$v = $a[$i]->[1];\n\t\t$maxval = max($maxval, min(abs($m1 - $v), abs($m2 - $v)))\n\t}\n}\nprint $maxval, \"\\n\";\n"}], "src_uid": "9fd8e75cb441dc809b1b2c48c4012c76"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t@no = ();\n\t\n\tfor $i (2 .. $_){\n\t\t$ii = $i;\n\t\t$g = 0;\n\t\tfor $j (2 .. $i){\n\t\t\tif ($ii and not $ii % $j){\n\t\t\t\t++ $g;\n\t\t\t\t$ii /= $j while not $ii % $j;\n\t\t\t\t}\n\t\t\t$g and $ii > 1 and $no[$i] = 1;\n\t\t\t}\n\t\t\n\t\t}\n\t\t@e = grep ! $no[$_], 2 .. $_;\t\t\n\t\tprint $_ > 1 ? (scalar @e, \"\\n@e\") : 0\n\t\n\t}", "positive_code": [{"source_code": "\t$_ = <>;\n\n\tfor $i (2 .. $_){\n\t\t$ii = $i;\n\t\t$g = 0;\n\t\tfor $j (2 .. $i){\n\t\t\tif ($ii and not $ii % $j and not $g ++){\n\t\t\t\t$ii /= $j while not $ii % $j;\n\t\t\t\t}\n\t\t\t$g and $no[$i] = $ii > 1;\n\t\t\t}\n\t\t}\n\n\t@e = grep 1 > $no[$_], 2 .. $_;\t\t\n\tprint @e . \"\\n@e\""}], "negative_code": [], "src_uid": "7f61b1d0e8294db74d33a6b6696989ad"}
{"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy $s = <>;\n$s =~ s/\\.\\.\\./ \\.\\.\\./g;\n$s =~ s/[ ]*\\,/\\,/g;\n$s =~ s/\\,/\\, /g;\n$s =~ s/\\.\\.\\.[ ]+([^.])/\\.\\.\\.$1/g;\n$s =~ s/[ ]+/ /g;\n$s =~ s/^[ ]*//g;\n$s =~ s/[ ]*$//g;\nprint $s\n\n", "positive_code": [{"source_code": "while (<>) {\n    s/ *, */, /g;\n    s/ *\\.\\.\\. */ \\.\\.\\./g;\n    s/ +/ /g;\n    s/^\\s+//g;\n    s/\\s+$//g;\n    print\n}\n"}, {"source_code": "chomp($_ = <STDIN>);\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/([\\d\\.])\\s+?,/$1,/g;\ns/\\s+/ /g;\ns/^\\s+?|\\s+$//g;\ns/\\.\\.\\.\\s+?(\\d)/...$1/g;\nprint;\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)( {2,})?\\./$1 ./g;\n\ts/\\. +(\\d)/.$1/g;\n\ts/,( {2,})?\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\twhile(/(\\d) {2,}(\\d)/){s/(\\d) {2,}(\\d)/$1 $2/};\n\ts/\\.{3} +,/...,/g;\n\ts/\\. {2,}\\./. ./g;\n\tprint\n\t}\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\.\\s*/ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n"}], "negative_code": [{"source_code": "#!perl -lp\ns/\\s+//g;\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/\\s+/ /g\n"}, {"source_code": "#!perl -lp\ns/\\s*,/, /g;\ns/\\.\\.\\./ .../g;\ns/\\s+/ /g;\ns/^ | $//g;\n"}, {"source_code": "#!perl -lp\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/\\s+/ /g\n"}, {"source_code": "#!perl -lp\n#s/\\s+//g;\ns/\\s*,/, /g;\ns/\\.\\.\\./ .../g;\ns/\\s+/ /g;\ns/^ | $//;\n"}, {"source_code": "#!perl -lp\ns/\\s+//g;\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/\\s+/ /g;\ns/^ | $//;\n"}, {"source_code": "chomp($_ = <STDIN>);\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/([\\d\\.])\\s,/$1,/g;\ns/\\s+/ /g;\ns/^\\s+|\\s+$//;\nprint;\n"}, {"source_code": "chomp($_ = <STDIN>);\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/([\\d\\.])\\s,/$1,/g;\ns/\\s+/ /g;\ns/^\\s+?|\\s+$//g;\nprint;\n"}, {"source_code": "chomp($_ = <STDIN>);\ns/,/, /g;\ns/(\\S)?\\.\\.\\./$1 .../g;\ns/([\\d\\.])\\s,/$1,/g;\ns/\\s+/ /g;\nprint;\n"}, {"source_code": "chomp($_ = <STDIN>);\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/([\\d\\.])\\s,/$1,/g;\ns/\\s+/ /g;\ns/^\\s+//;\nprint;\n"}, {"source_code": "chomp($_ = <STDIN>);\ns/,/, /g;\ns/\\.\\.\\./ .../g;\ns/([\\d\\.])\\s+?,/$1,/g;\ns/\\s+/ /g;\ns/^\\s+?|\\s+$//g;\nprint;\n"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy $s = <>;\n$s =~ s/\\.\\.\\./ \\.\\.\\./g;\n$s =~ s/[ ]*\\,/\\,/g;\n$s =~ s/\\,/\\, /g;\n$s =~ s/\\.\\.\\.[ ]+[^.]/\\.\\.\\./g;\n$s =~ s/[ ]+/ /g;\n$s =~ s/^[ ]*//g;\n$s =~ s/[ ]*$//g;\nprint $s\n\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)( {2,})?\\./$1 ./g;\n\ts/\\. +(\\d)/.$1/g;\n\ts/,( {2,})?\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\twhile(/(\\d) {2,}(\\d)/){s/(\\d) {2,}(\\d)/$1 $2/};\n\ts/\\.{3} +,/...,/g;\n\tprint\n\t}\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)( {2,})?\\./$1 ./g;\n\ts/\\. +(\\d)/.$1/g;\n\ts/,( {2,})?\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\twhile(/(\\d) {2,}(\\d)/){s/(\\d) {2,}(\\d)/$1 $2/};\n\tprint\n\t}\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)( {2,})?\\./$1 ./g;\n\ts/,( {2,})?\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\twhile(/(\\d) {2,}(\\d)/){s/(\\d) {2,}(\\d)/$1 $2/};\n\tprint\n\t}\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)\\./$1 ./g;\n\ts/,( {2,})?\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\twhile(/(\\d) {2,}(\\d)/){s/(\\d) {2,}(\\d)/$1 $2/};\n\tprint\n\t}\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)\\./$1 ./g;\n\ts/,\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\twhile(/(\\d) {2,}(\\d)/){s/(\\d) {2,}(\\d)/$1 $2/};\n\tprint\n\t}\n"}, {"source_code": "while(<>){\n\twhile(/,( {2,})?(\\d+)/){\n\t\ts/,( {2,})?(\\d+)/, $2/g}\n#\tprint;\n\ts/(\\d+) +,/$1,/g;\n\twhile(/,( {2,})?,/){\n\t\ts/,( {2,})?,/, ,/g}\n#\tprint;\n\ts/(\\d+)\\./$1 ./g;\n\ts/,\\./, ./g;\n\twhile(/\\.{4}/){s/\\.{4}/... ./};\n\tprint\n\t}\n"}], "src_uid": "c7d8c71a1f7e6c7364cce5bddd488a2f"}
{"source_code": "use strict;\nuse warnings;\nuse 5.010;\n \nmy $str = <>;\nchop $str;\nmy $rev = reverse $str;\n$str .= $rev;\nsay $str;\n", "positive_code": [{"source_code": "$a = <STDIN>;\nchomp $a;\nprint($a);\nprint(scalar reverse $a);"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\nuse 5.010;\n \nmy $str = <>;\nmy $rev = reverse $str;\n$str .= $rev;\nsay $str;\n#"}, {"source_code": "use strict;\nuse warnings;\nuse 5.010;\n \nmy $str = <>;\nmy $rev = reverse $str;\n$str .= $rev;\nsay $str;\n"}], "src_uid": "9b1887582a9eb7cff49994ddcc2ee9b8"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $max = -1;\n\tmy $ans = -1;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tif( $_[ $i ] > $max + 1 ){\n\t\t\t$ans = $i + 1;\n\t\t\tlast;\n\t\t\t}\n\t\t$max < $_[ $i ] and $max = $_[ $i ];\n\t\t}\n\t\n\tprint $ans;\n\t}", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $input = <STDIN>;\nmy $n = 0+$input;\n$input = <STDIN>;\nmy @arr = map {$_+0} split / /, $input;\nmy $max_mex = 0;\nmy $answer = -1;\nmy $e;\nfor my $i (0.. scalar @arr - 1) {\n    $e = $arr[$i];\n    if ($e > $max_mex) {\n        $answer = $i+1;\n        last;\n    } else {\n        $max_mex = $e + 1 if $max_mex == $e;\n    }\n}\nprint($answer);"}], "negative_code": [], "src_uid": "e17427897fd5147c601204cb1c48b143"}
{"source_code": "#!/usr/bin/perl\n\n$l = <>;\n$p = <>;\n$q = <>;\n\nprint $p*$l/($p + $q), \"\\n\";", "positive_code": [{"source_code": "@_ = <>;\nprint $_[0] * $_[1] / ($_[1] + $_[2])"}, {"source_code": "@_ = <>;\nprint $_[0] * $_[1] / ($_[1] + $_[2])"}], "negative_code": [], "src_uid": "6421a81f85a53a0c8c63fbc32750f77f"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $d ) = split;\n\t\n\tfor( 1 .. <> ){\n\t\tmy( $x, $y ) = sort { $a <=> $b } split ' ', <>;\n\t\tprint \"NO\" and next if $x + $y < $d;\n\t\tprint \"NO\" and next if $x + $y > $n + $n - $d;\n\t\tprint \"NO\" and next if $y - $x > $d;\n\t\tprint \"NO\" and next if $y - $x < -$d;\n\t\t\n\t\tprint \"YES\";\n\t\t}\n\t\n\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n( $n, $d ) = split ' ', <>;\n\nfor( 1 .. <> ){\n\t( $x, $y ) = split ' ', <>;\n\tprint $x + $y < $d || $x + $y > $n + $n - $d || abs( $y - $x ) > $d ? \"NO\" : \"YES\"\n\t}"}], "negative_code": [], "src_uid": "9c84eb518c273942650c7262e5d8b45f"}
{"source_code": "#!/usr/bin/perl\n\n# TLE 5;\n# greedy, fill\n\nuse warnings;\nuse strict;\n \n$\\ = $/;\n \nmy @widths = map 2 ** $_, 0 .. 19;\n \n<>;\n\nwhile(<>){\n\tmy( $n, $w ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\tmy $height = 0;\n\t\n\twhile( keys %h ){\n\t\t$height ++;\n\t\tmy $ww = $w;\n\t\t\n\t\tfor my $i ( sort { $b <=> $a } keys %h ){\n\t#%\tfor my $i ( reverse @widths ){\n\t\t\tnext if not exists $h{ $i };\n\t\t\tif( $ww - $i >= 0 ){\n\t\t\t\t$ww -= $i;\n\t\t\t\t$h{ $i } --;\n\t\t\t\t$h{ $i } == 0 and delete $h{ $i };\n\t\t\t\tredo;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint $height;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nmy @widths = map [ 2 ** $_, 0 ], 0 .. 19;\n\nmy %dict = map { 2 ** $_, $_ } 0 .. 19;\n\nmy @ans;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $w ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy @W = @widths;\n\t\n\tmap { $W[ $dict{ $_ } ][ 1 ] ++ } @_;\n\t\n\t@W = reverse @W;\n\t\n\tmy $height = 0;\n\t\n\t@W = grep { $_->[ 1 ] > 0 } @W;\n\t\n\twhile( @W ){\n\t\t$height ++;\n\t\tmy $ww = $w;\n\t\t\n\t\t$debug and print join \", \", map \"$_->[ 0 ] $_->[ 1 ]\", @W;\n\t\t\n\t\tfor my $i ( @W ){\n\t\t\tif( $ww - $i->[ 0 ] >= 0 ){\n\t\t\t\t$ww -= $i->[ 0 ];\n\t\t\t\t$i->[ 1 ] --;\n\t\t\t\t$i->[ 1 ] == 0 and do {\n\t\t\t\t\tnext;\n\t\t\t\t\t};\n\t\t\t\tredo;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t@W = grep { $_->[ 1 ] > 0 } @W;\n\t\t}\n\t\n\tpush @ans, $height;\n\t}\n\nprint join \"\\n\", @ans;"}], "negative_code": [], "src_uid": "49ba9921ae8b6bc53726e7a521eefe39"}
{"source_code": "\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\t\n\t@_=split/ /,<>;\n\t\n\tfor $i(1..1e3){\n\t\t\n\t\t@e=($i);\n\t\tpush @e, $e[@e-1]+$k for 2..$n;\n\t\t\t\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\t$i[$i]++\n\t\t\t}\n\t\t}\n\t\t}\n\t\t\n\t\t$min=1e3;\n\t\tfor $j(1..1e3){\n\t\t\t$min > $i[$j] and ($min=$i[$j], $I=$j);\n\t\t\t}\n\t\n\t\t@e=($I);\n\t\tpush @e, $e[@e-1]+$k for 2..$n;\n\t\t\n\t\t@m=();\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\tpush @m, (($j+1).\" \".($e[$j]-$_[$j]))\n\t\t\t}\n\t\t}\n\t\n\ts/-// ? s/^/- / : s/^/+ / for @m;\n\t\n\tprint 0+@m;\n\tprint \"\\n$_\" for @m\n\t\n\t}\n\t\n", "positive_code": [{"source_code": "\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\tchomp $k;\n\t\n#\tprint \" $n $k\\n\";\n\t\n\tchomp ($_=<>);\n\t@_=split/ /;\n\t\n\t@i=();\n\tfor $i(1..1000){\n\t\t\n\t\t@e=($i);\n\t\tfor $j(2..$n){\n\t\t\tpush @e, $e[@e-1]+$k\n\t\t\t}\n\t\t\t\n\t\t$h=0;\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\t$h++; \n\t#\t\t\tpush @m, (($i+1).\" \".($e[$i]-$_[$i]))\n\t\t\t}\n\t\t}\n\t\t$i[$i]=$h;\n\t\t}\n\t\t\n\t\t$min=1000;\n\t\t$ii=1;\n\t\tfor $j(1..1000){\n\t\t\t$min > $i[$j] and ($min=$i[$j], $ii= $j);\n\t\t\t}\n\t\n\t\t@e=($ii);\n\t\tfor $j(2..$n){\n\t\t\tpush @e, $e[@e-1]+$k\n\t\t\t}\n\t\t\n\t\t@m=();\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\tpush @m, (($j+1).\" \".($e[$j]-$_[$j]))\n\t\t\t}\n\t\t}\n\t\n#\tprint \"@e\\n\";\n#\tprint \"@_\\n\";\n\n#\tprint \"@m\\n\";\n\t\n\tfor (@m){\n\t\tif (s/-//){ s/^/- / }\n\t\telse {s/^/+ /}\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tprint 0+@m;\n\tprint \"\\n\";\n\tfor (@m){\n\t\tprint \"$_\\n\"\n\t\t}\n\t\n#\tprint \"\\n\";\n\t}\n\t\n"}, {"source_code": "\n($n, $k)=split/ /,<>;\n\t\n\t@_=split/ /,<>;\n\t\n\tfor $i(1..1e3){\n\t\t\n\t\t@e=($i);\n\t\tpush @e, $e[@e-1]+$k for 2..$n;\n\t\t\t\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\t$i[$i]++\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\t$min=1e3;\n\t\tfor $j(1..1e3){\n\t\t\t$min > $i[$j] and $min=$i[$I=$j];\n\t\t\t}\n\t\n\t\t@e=($I);\n\t\tpush @e, $e[@e-1]+$k for 2..$n;\n\t\t\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\tpush @m, ($j+1).\" \".($e[$j]-$_[$j])\n\t\t\t}\n\t\t}\n\t\n\ts/-// ? s/^/- / : s/^/+ / for @m;\n\t\n\tprint 0+@m;\n\tprint \"\\n$_\" for @m\n\t"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy ($n, $k) = split /\\s/, <>;\nmy @w = split /\\s/, <>;\n\nmy $min = 1001;\nmy $min_i;\nfor my $i (0..$n-1){\n\tmy $err = 0;\n\tmy $lmin = 0;\n\tfor my $j (0..$n-1){\n\t\tif ( $w[$i] + ($j-$i)*$k <= 0 ) {\n\t\t\t$err = 1;\n\t\t\tlast;\n\t\t}\n\t\t\n\t\tif($w[$i] + ($j-$i)*$k != $w[$j]){\n\t\t\t$lmin++;\n\t\t}\n\t}\n\tif(!$err && $lmin < $min){\n\t\t$min = $lmin;\n\t\t$min_i = $i;\n\t}\n}\n\nprint \"$min\\n\";\nfor my $j (0..$n-1){\n\tmy $delta = $w[$min_i]+($j-$min_i)*$k - $w[$j];\n\tif($delta != 0){\n\t\tmy $sign = ($delta > 0) ? '+' : '-';\n\t\t$delta = abs($delta);\n\t\tmy $pos = $j+1;\n\t\tprint \"$sign $pos $delta\\n\";\n\t}\n}"}, {"source_code": "\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\tchomp $k;\n\t\n\tchomp ($_=<>);\n\t@_=split/ /;\n\t\n\tfor $i(1..1000){\n\t\t\n\t\t@e=($i);\n\t\tfor $j(2..$n){\n\t\t\tpush @e, $e[@e-1]+$k\n\t\t\t}\n\t\t\t\n\t\t$h=0;\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\t$h++\n\t\t\t}\n\t\t}\n\t\t$i[$i]=$h;\n\t\t}\n\t\t\n\t\t$min=1000;\n\t\t$ii=1;\n\t\tfor $j(1..1000){\n\t\t\t$min > $i[$j] and ($min=$i[$j], $ii= $j);\n\t\t\t}\n\t\n\t\t@e=($ii);\n\t\tfor $j(2..$n){\n\t\t\tpush @e, $e[@e-1]+$k\n\t\t\t}\n\t\t\n\t\t@m=();\n\t\tfor $j(0..@_-1){\n\t\t\tif ($e[$j]!=$_[$j]){\n\t\t\t\tpush @m, (($j+1).\" \".($e[$j]-$_[$j]))\n\t\t\t}\n\t\t}\n\t\n\tfor (@m){\n\t\tif (s/-//){ s/^/- / }\n\t\telse {s/^/+ /}\n\t\t}\n\t\n\tprint 0+@m;\n\tprint \"\\n\";\n\tfor (@m){\n\t\tprint \"$_\\n\"\n\t\t}\n\t\n\t}\n\t\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy ($n, $k) = split /\\s/, <>;\nmy @w = split /\\s/, <>;\n\nmy $min = 1001;\nmy $min_i;\nfor my $i (0..$n-1){\n\tmy $lmin = 0;\n\tfor my $j (0..$n-1){\n\t\tif($w[$j]-$w[$i] != ($j-$i)*$k){\n\t\t\t$lmin++;\n\t\t}\n\t}\n\tif($lmin < $min){\n\t\t$min = $lmin;\n\t\t$min_i = $i;\n\t}\n}\n\nprint \"$min\\n\";\nfor my $j (0..$n-1){\n\tmy $delta = $w[$min_i]+($j-$min_i)*$k - $w[$j];\n\tif($delta != 0){\n\t\tmy $sign = ($delta > 0) ? '+' : '-';\n\t\t$delta = abs($delta);\n\t\tmy $pos = $j+1;\n\t\tprint \"$sign $pos $delta\\n\";\n\t}\n}"}, {"source_code": "sub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\tchomp $k;\n\t\n\t@_=split/ /,<>;\n\tchomp @_;\n\t\n\t@c=@_;\n\t\n\t$f=0;\n\t$cnt=0;\n\t$cntX=$_[0];\n\t$cntx=0;\n\t\n\tfor $i(0..@_-2){\n\t\t$a=$_[$i+1]-$_[$i];\n\t\tif ($a==$k and ($_[$i]-$k*$i >= 0)){\n\t\t\t$f++;\n\t\t\t}\n\t\telse {\n\t\t\tif ($f>=$cnt){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[$i];\n\t\t\t\t$cntx=$i;\n\t\t\t\t}\n\t\t\t$f=0;\n\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\t}\n\tif ($f>=$cnt){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[@_-1];\n\t\t\t\t$cntx=@_-1;\n\t\t\t\t}\n\t\t\t\t\n\tif ($cnt){\n\t\t\t\t\n#\tprint \"$cnt $cntx $cntX\\n\";\n\t\n\t@e=();\n\tfor $i(0..$cntx){\n\t\tunshift @e, $cntX-$k*$i\n\t\t\n\t\t}\n#\tprint \"@e\\n\";\n\t\n\tfor $i(1..@_-1-$cntx){\n\t\tpush @e, $cntX+$k*$i\n\t\t\n\t\t}\n#\tprint \"@e\\n\";\n#\tprint \"@_\\n\";\n\t}\n\telse {\n\t\t\n\t\t@e=();\n\t\tfor $i(0..@_-1){\n\t\t\tpush @e, $_[0]+$k*$i\n\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n\t\n\t@m=();\n\tfor $i(0..@_){\n\t\tif ($e[$i]!=$_[$i]){\n\t\t\tpush @m, (($i+1).\" \".($e[$i]-$_[$i]))\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tfor (@m){\n\t\tif (s/-//){ s/^/- / }\n\t\telse {s/^/+ /}\n\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tprint 0+@m;\n\tprint \"\\n\";\n\tfor (@m){\n\t\tprint \"$_\\n\"\n\t\t}\n\t\n#\tprint \"\\n\";\n\t}\n\t\n"}, {"source_code": "sub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\tchomp $k;\n\t\n\t@_=split/ /,<>;\n\tchomp @_;\n\t\n\t@c=@_;\n\t\n\t$f=0;\n\t$cnt=0;\n\t$cntX=$_[0];\n\t\n\tfor $i(0..@_-2){\n\t\t$a=$_[$i+1]-$_[$i];\n\t\tif ($a==$k and ($_[$i]-$k*$i > 0)){\n\t\t\t$f or\t$cntX=$_[$i]-$k*$i;\n\t\t\t$f++;\n\t\t\t}\n\t\telse {\n\t\t\tif ($f>$cnt){\n\t\t\t\t$cnt=$f\n\t\t\t\t}\n\t\t\t$f=0;\n\t\t\t}\n\t\t}\n\tif ($f>$cnt and ($_[@_-1]-$k*(@_-1) > 0)){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[@_-1]-$k*(@_-1);\n\t\t\t\t}\n\t\t\t\t\n\n\t\t@e=();\n\t\tfor $i(0..@_-1){\n\t\t\tpush @e, $cntX+$k*$i\n\t\t\t}\n\t\t\n\t\n#\tprint \"@e\\n\";\n#\tprint \"@_\\n\";\n\t\n\t@m=();\n\tfor $i(0..@_){\n\t\tif ($e[$i]!=$_[$i]){\n\t\t\tpush @m, (($i+1).\" \".($e[$i]-$_[$i]))\n\t\t\t}\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tfor (@m){\n\t\tif (s/-//){ s/^/- / }\n\t\telse {s/^/+ /}\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tprint 0+@m;\n\tprint \"\\n\";\n\tfor (@m){\n\t\tprint \"$_\\n\"\n\t\t}\n\t\n#\tprint \"\\n\";\n\t}\n\t\n"}, {"source_code": "sub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\tchomp $k;\n\t\n\t@_=split/ /,<>;\n\tchomp @_;\n\t\n\t@c=@_;\n\t\n\t$f=0;\n\t$cnt=0;\n\tfor $i(0..@_-2){\n\t\t$a=$_[$i+1]-$_[$i];\n\t\tif ($a==$k){\n\t\t\t$f++;\n\t\t\t}\n\t\telse {\n\t\t\tif ($f>=$cnt){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[$i];\n\t\t\t\t$cntx=$i;\n\t\t\t\t}\n\t\t\t$f=0;\n\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\t}\n\tif ($f>=$cnt){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[@_-1];\n\t\t\t\t$cntx=@_-1;\n\t\t\t\t}\n\t\t\t\t\n#\tprint \"$cnt $cntx $cntX\\n\";\n\t\n\t@e=();\n\tfor $i(0..$cntx){\n\t\tunshift @e, $cntX-$k*$i\n\t\t\n\t\t}\n#\tprint \"@e\\n\";\n\t\n\tfor $i(1..@_-1-$cntx){\n\t\tpush @e, $cntX+$k*$i\n\t\t\n\t\t}\n#\tprint \"@e\\n\";\n#\tprint \"@_\\n\";\n\t\n\t@m=();\n\tfor $i(0..@_){\n\t\tif ($e[$i]!=$_[$i]){\n\t\t\tpush @m, (($i+1).\" \".($e[$i]-$_[$i]))\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tfor (@m){\n\t\tif (s/-//){ s/^/- / }\n\t\telse {s/^/+ /}\n\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tprint 0+@m;\n\tprint \"\\n\";\n\tfor (@m){\n\t\tprint \"$_\\n\"\n\t\t}\n\t\n#\tprint \"\\n\";\n\t}\n\t\n"}, {"source_code": "sub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n\nwhile(<>){\n\t\n\t($n, $k)=split/ /;\n\tchomp $k;\n\t\n\t@_=split/ /,<>;\n\tchomp @_;\n\t\n\t@c=@_;\n\t\n\t$f=0;\n\t$cnt=0;\n\t$cntX=$_[0];\n\t$cntx=0;\n\t\n\tfor $i(0..@_-2){\n\t\t$a=$_[$i+1]-$_[$i];\n\t\tif ($a==$k and ($_[$i]-$k*$i > 0)){\n\t\t\t$f++;\n\t\t\t}\n\t\telse {\n\t\t\tif ($f>=$cnt){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[$i];\n\t\t\t\t$cntx=$i;\n\t\t\t\t}\n\t\t\t$f=0;\n\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\t}\n\tif ($f>=$cnt){\n\t\t\t\t$cnt=$f;\n\t\t\t\t$cntX=$_[@_-1];\n\t\t\t\t$cntx=@_-1;\n\t\t\t\t}\n\t\t\t\t\n\tif ($cnt){\n\t\t\t\t\n#\tprint \"$cnt $cntx $cntX\\n\";\n\t\n\t@e=();\n\tfor $i(0..$cntx){\n\t\tunshift @e, $cntX-$k*$i\n\t\t\n\t\t}\n#\tprint \"@e\\n\";\n\t\n\tfor $i(1..@_-1-$cntx){\n\t\tpush @e, $cntX+$k*$i\n\t\t\n\t\t}\n#\tprint \"@e\\n\";\n#\tprint \"@_\\n\";\n\t}\n\telse {\n\t\t\n\t\t@e=();\n\t\tfor $i(0..@_-1){\n\t\t\tpush @e, $_[0]+$k*$i\n\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n\t\n\t@m=();\n\tfor $i(0..@_){\n\t\tif ($e[$i]!=$_[$i]){\n\t\t\tpush @m, (($i+1).\" \".($e[$i]-$_[$i]))\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tfor (@m){\n\t\tif (s/-//){ s/^/- / }\n\t\telse {s/^/+ /}\n\t\t\n\t\t}\n#\tprint \"@m\\n\";\n\t\n\tprint 0+@m;\n\tprint \"\\n\";\n\tfor (@m){\n\t\tprint \"$_\\n\"\n\t\t}\n\t\n#\tprint \"\\n\";\n\t}\n\t\n"}], "src_uid": "7f08e74945d6b58abde1d8002b8b686a"}
{"source_code": "( $n, $s ) = split ' ', <>;\n\n$s -= 2;\n\n$_ = reverse <> =~ s/.\\s/ $& * 3 /ger;\n$_ = ( <> =~ s/.\\s/ $& + chop /ger );\n\ns/([14][013]*)4/ \"$&\" =~ y!1!2!r /ge;\n\nprint /^[34].{$s}[234]/ ? \"YES\" : \"NO\"", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $input = <STDIN>;\nmy ($n, $m) = map {$_+0} split / /, $input;\n$input = <STDIN>;\nmy @a1 = map {$_+0} split / /, $input;\n$input = <STDIN>;\nmy @a2 = map {$_+0} split / /, $input;\nmy %hash = ($m => 1);\nmy %hash2 = ();\nmy @a = ($m);\nmy $oo;\nwhile(@a) {\n    $m = $a[0];\n    my $ok = ff($m, \\%hash, $n, \\@a1, \\@a2, 1);\n    if ($ok == 1) {\n        print \"YES\";\n        $oo=1;\n        last;\n    }\n    $hash2{$m} = 1;\n    @a = grep {not defined $hash2{$_}} keys %hash;\n}\nprint \"NO\" unless $oo;\n\nsub ff {\n    my ($station, $h, $n, $a1, $a2, $m) = @_;\n    my $ok = 0;\n    if ($station < $n && $a2->[$station-1]) {\n        for (($station + 1) .. $n) {\n            if ($a2->[$_-1]) {\n                return 1 if $_ == $m;\n                $ok = -1 unless defined $h->{$_};\n                $h->{$_} = 1;\n            }\n        }\n    }\n    if ($station > 1) {\n        for (1..$station - 1) {\n            if ($a1->[$_-1] && $a1->[$station-1]) {\n                return 1 if $_ == $m;\n                $ok = -1 unless defined $h->{$_};\n                $h->{$_} = 1;\n            }\n        }\n    }\n}\n"}], "negative_code": [{"source_code": "( $n, $s ) = split ' ', <>;\n\n$s -= 2;\n\n$_ = reverse <> =~ s/.\\s/ $& * 3 /ger;\n$_ = ( <> =~ s/.\\s/ $& + chop /ger );\n\ns/(1[01]*)4/ \"$&\" =~ y!1!2!r /ge;\n\nprint /^[34].{$s}[24]/ ? \"YES\" : \"NO\""}, {"source_code": "( $n, $s ) = split ' ', <>;\n\n$s -= 2;\n\n$_ = reverse <> =~ s/.\\s/ $& * 2 /ger;\n$_ = ( <> =~ s/.\\s/ $& + chop /ger );\n\ns/(1[01]*)3/ \"$&\" =~ y!1!2!r /ge;\n\nprint /^[23].{$s}[23]/ ? \"YES\" : \"NO\""}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $s ) = split;\n\t\n\tmy @A = split ' ', <> =~ s/1/2/rg;\n\tmy @B = split ' ', <>;\n\t\n\tif( $A[ 0 ] == 0 ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\t$_ += shift @B for @A;\n\t\n\t$_ = reverse join '', @A;\n\t\n\ts/3\\K(1+)/ 2 x length $1 /ge;\n\t\n\t$_ = reverse;\n\t\n\tprint 1 < ( substr $_, $s - 1, 1 ) ? \"YES\" : \"NO\";\n\t}"}], "src_uid": "64b597a47106d0f08fcfad155e0495c3"}
{"source_code": "$a = <>;\nchomp $a;\n\n$b = <>;\nchomp $b;\n\nif (length($a) != length($b)) { print \"NO\\n\"; exit(); }\n\n$fa = ($a =~ /1/ ? 1 : 0);\n$fb = ($b =~ /1/ ? 1 : 0);\n\nif ($fa == $fb) { print \"YES\\n\"; } else { print \"NO\\n\"; }\n\n", "positive_code": [{"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO"}, {"source_code": "($a,$b)=<>;print length$a==length$b&&$a=~/1/==$b=~/1/?YES:NO"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "\n\n($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}, {"source_code": "chomp ($str1 = <STDIN>);\nchomp ($str2 = <STDIN>);\nif (length($str1) == length($str2)) {\n\tprintf \"YES\\n\" if ($str1 =~ /1/ && $str2 =~ /1/);\n\tprintf \"YES\\n\" if ($str1 !~ /1/ && $str2 !~ /1/);\n\tprintf \"NO\\n\"  if ($str1 !~ /1/ && $str2 =~ /1/);\n\tprintf \"NO\\n\"  if ($str1 =~ /1/ && $str2 !~ /1/);\n} else {\n\tprintf \"NO\\n\";\n}\n"}, {"source_code": "($_,$a)=<>;print/1/==$a=~/1/&&length==length$a?YES:NO\n"}], "negative_code": [], "src_uid": "113ae625e67c8ea5ab07be44c3b58a8f"}
{"source_code": "($.,$$)=split\" \",<>;@$=split\" \",<>;@$=sort{$a<=>$b}@$;$.=0;for(@$){$/=$_-$.;last if(!$$);next if($/<=0);;print\"$/\\n\";$.+=$_-$.;$$--;};while($$){$$--;print\"0\\n\"}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\t@_ = sort { $a <=> $b } keys %h;\n\t\n\tmy $prev = 0;\n\tmy @ans;\n\t\n\tfor my $i ( 1 .. $k ){\n\t\tmy $A = shift @_ // $prev;\n\t\tpush @ans, $A - $prev;\n\t\t$prev = $A;\n\t\t}\n\t\n\tprint join \"\\n\", @ans;\n\t}"}], "negative_code": [], "src_uid": "0f100199a720b0fdead5f03e1882f2f3"}
{"source_code": "#use v5.24;\nuse warnings;\nmy @usb,@ps2,@merged,$nrcump=0,$costtot=0;\n\nmy $line=<stdin>;\nchomp($line);\nmy ($usbonly,$ps2only,$both)=split(/ /,$line);\n$line=<stdin>;\nchomp($line);\nmy ($n)=split(/ /,$line);\nfor (my $i=1;$i<=$n;$i++){\n\t$line=<stdin>;\n\tchomp($line);\n\tmy ($cost,$tip)=split(/ /,$line);\n\tif ($tip eq \"USB\") {push @usb, $cost;}\n\telse {push @ps2, $cost;}\n}\n@usb=sort {$a<=>$b} @usb;\n@ps2=sort {$a<=>$b} @ps2;\nwhile ($usbonly>0 && scalar @usb>0){\n\t$usbonly--;\n\t$nrcump++;\n\t$costtot=$costtot+shift @usb;\n}\nwhile ($ps2only>0 && scalar @ps2>0){\n\t$ps2only--;\n\t$nrcump++;\n\t$costtot=$costtot+shift @ps2;\n}\nforeach my $var (@usb) {push @merged, $var;}\nforeach my $var (@ps2) {push @merged, $var;}\n@merged=sort {$a<=>$b} @merged;\nwhile ($both>0 && scalar @merged>0){\n\t$both--;\n\t$nrcump++;\n\t$costtot=$costtot+shift @merged;\n}\nprint $nrcump.' '.$costtot;\n<stdin>;\nexit(0);", "positive_code": [{"source_code": "    use warnings;\n    use utf8;\n    use feature \"say\";\n     \n    my $line = <>;\n    chomp($line);\n    my ($usb, $ps2, $mix) = split(' ', $line);\n    my $pcNr = <>;\n    chomp($pcNr);\n    my (@usb, @ps2);\n    while ($pcNr > 0) {\n      $line = <>;\n      chomp($line);\n      my($price, $type) = split(' ', $line);\n      if ($type eq \"USB\") {\n        push ( @usb, $price );\n      } else {\n        push ( @ps2, $price);\n      }\n      --$pcNr;\n    }\n    @usb = sort ( { $a <=> $b } @usb );\n    @ps2 = sort ( { $a <=> $b } @ps2 );\n     \n    my $price = 0;\n     \n    for ( ; $usb > 0 && scalar(@usb); --$usb) {\n            $price += shift @usb;\n            ++$pcNr;\n    }\n     \n    for ( ; $ps2 > 0 && scalar(@ps2); --$ps2) {\n            $price += shift @ps2;\n            ++$pcNr;\n    }\n     \n    my @c = sort( { $a <=> $b } @usb, @ps2 );\n\t\n\tfor ( ;scalar( @c ) && $mix > 0; --$mix) {\n\t\t$price += shift @c;\n\t\t++$pcNr;\n\t}\n\t    \n    say $pcNr.\" \".$price;"}, {"source_code": "use v5.14;\nuse warnings;\n \nuse Data::Dumper qw(Dumper);\n\nmy $input = <>;\nchomp $input;\nmy ($c, $d, $e) = split / /, $input;\nmy $cost = 0;\nmy $nr = 0;\nmy $m = <>;\nmy @list;\nfor(my $i = 1; $i <= $m; $i++)\n{\n\t$input = <>;\n\tchomp $input;\n\tmy($val, $s) = split / /, $input;\n    push @list, [$val,$s];\n}\n@list = sort{$a->[0]<=>$b->[0]} @list;\nfor(my $i = 0; $i < $m; $i++)\n{\n    if($list[$i]->[1] eq \"USB\")\n    {\n        if($c > 0)\n        {\n            $c--;\n            $nr++;\n            $cost+=$list[$i]->[0];\n        }\n        else\n        {\n            if($e > 0)\n            {\n                $e--;\n                $nr++;\n                $cost+=$list[$i]->[0];\n            }\n        }\n    }\n    else\n    {\n        if($d > 0)\n        {\n            $d--;\n            $nr++;\n            $cost+=$list[$i]->[0];\n        }\n        else\n        {\n            if($e > 0)\n            {\n                $e--;\n                $nr++;\n                $cost+=$list[$i]->[0];\n            }\n        }\n    }\n}\nsay \"$nr $cost\";\n    \n"}, {"source_code": "use v5.20;\nuse warnings;\n\nsub compare {\n\treturn $a <=> $b;\n}\n\nmy ($a,$b,$c) = split(' ',<>);\nmy $m = int <>;\n\nmy (@A,@B);\n\nfor (1..$m) {\n\tmy ($val,$type) = split(' ',<>);\n\tif ($type eq \"USB\") {\n\t\tpush @A,$val;\n    }\n\telse { \n\t\tpush @B,$val;\n\t}\n}\n\n@A = sort compare @A;\n@B = sort compare @B;\n\nmy $cost = 0;\nmy $comp = 0;\n\nwhile ($a and scalar @A) {\n\t$comp += 1;\n\t$cost += shift @A;\n\t$a -= 1;\n}\n\nwhile ($b and scalar @B) {\n\t$comp += 1;\n\t$cost += shift @B;\n\t$b -= 1;\n}\n\nmy @C = sort compare (@A,@B);\n\nwhile ($c and scalar @C) {\n\t$comp += 1;\n\t$cost += shift @C;\n\t$c -= 1;\n}\n\nsay \"$comp $cost\";\n\n"}, {"source_code": "use v5.20;\n\nmy $input = <>;\nmy ($usb_comp, $ps2_comp, $both_comp) = split(/ /, $input);\n\nmy $m = <>;\nmy @usb, my @ps2;\nfor (my $i = 0; $i < $m; $i = $i + 1) {\n\t$input = <>;\n\tchomp $input;\n\tmy ($number, $type) = split(/ /, $input);\n\n\tif ($type eq \"USB\") {\n\t\tpush(@usb, $number);\n\t} else {\n\t\tpush(@ps2, $number);\n\t}\n}\n\nmy $price = 0;\nmy $matched = 0;\n# Match as many only-usb computers to usb mouses.\n@usb = sort {$a <=> $b} @usb;\nmy $i = 0;\nwhile ($i < scalar @usb and $usb_comp > 0) {\n\t$price = $price + $usb[$i];\n\t$i++;\n\t$matched++;\n\t$usb_comp--;\n}\n\n# Match as many only-ps2 computers to usb mouses.\n@ps2 = sort {$a <=> $b} @ps2;\nmy $j = 0;\nwhile ($j < scalar @ps2 and $ps2_comp > 0) {\n\t$price = $price + $ps2[$j];\n\t$j++;\n\t$matched++;\n\t$ps2_comp--;\n}\n\n# Match the computers having both ports to cheapest mouses.\nwhile (($j < scalar @ps2 or $i < scalar @usb) and $both_comp > 0) {\n\tif ($i >= scalar @usb or ($j < scalar @ps2 and $ps2[$j] < $usb[$i])) {\n\t\t$price = $price + $ps2[$j];\n\t\t$j++;\n\t} else {\n\t\t$price = $price + $usb[$i];\n\t\t$i++;\n\t}\n\t$matched++;\n\t$both_comp--;\n}\n\nprint \"$matched $price\"\n"}, {"source_code": "use v5.20.1;\nuse warnings;\n\n=pod\nmy $filename = \"date.in\";\nopen(my $fh, '<:encoding(UTF-8)', $filename)\n\tor die \"Could not open the file\";\n=cut\n\nmy $line = <STDIN>;\nchomp($line);\n\nmy($a, $b, $c) = split(' ', $line);\n\n$line = <STDIN>;\nchomp($line);\n\nmy $m = $line;\n\nmy @usb;\nmy @ps;\nmy $model;\nmy $price = 0;\n\nfor(my $i = 0; $i < $m; $i++){\n\n\t$line = <STDIN>;\n\t($price, $model) = split(' ', $line);\n\tif($model eq \"USB\"){\n\n\t\tpush @usb, $price;\n\n\t}elsif($model eq \"PS/2\"){\n\n\t\tpush @ps, $price;\n\n\t}\n\n}\n\nmy @usbSorted = sort {$::a <=> $::b} @usb;\nmy @psSorted = sort {$::a <=> $::b} @ps;\n\n@usb = @usbSorted;\n@ps = @psSorted;\n\nmy $ui = 0;\nmy $pi = 0;\nmy $cost = 0;\nmy $mice = 0;\n\nwhile($ui < @usb && $a > 0){\n\n\t$cost += $usb[$ui];\n\t#say $usb[$ui], \"\\n\";\n\t$ui++;\n\t$mice++;\n\t$a--;\n\n}\n\nwhile($pi < @ps && $b > 0){\n\n\t$cost += $ps[$pi];\n\t#say $ps[$pi], \"\\n\";\n\t$pi++;\n\t$b--;\n\t$mice++;\n\n}\n\nwhile($ui < @usb && $pi < @ps && $c > 0){\n\n\tif($usb[$ui] < $ps[$pi]){\n\n\t\t$cost += $usb[$ui];\n\t\t#say $usb[$ui], \"\\n\";\n\t\t$c--;\n\t\t$ui++;\n\t\t$mice++;\n\n\t}else{\n\n\t\t$cost += $ps[$pi];\n\t\t#say $ps[$pi], \"\\n\";\n\t\t$pi++;\n\t\t$c--;\n\t\t$mice++;\n\n\t}\n\n}\n\nwhile($ui < @usb && $c > 0){\n\n\t$cost += $usb[$ui];\n\t#say $usb[$ui], \"\\n\";\n\t$ui++;\n\t$c--;\n\t$mice++;\n\n}\n\nwhile($pi < @ps && $c > 0){\n\n\t$cost += $ps[$pi];\n\t#say $ps[$pi], \"\\n\";\n\t$pi++;\n\t$c--;\n\t$mice++;\n\n}\n\nsay $mice, \" \", $cost, \"\\n\";\n"}, {"source_code": "use warnings;\n\nmy $line = <>;\nchomp($line);\nmy($muie, $cuie, $c) = split(' ', $line);\n\nmy $i;\nmy @v1;\nmy @v2;\nmy $m = <>;\nchomp($m);\n\nfor($i=1;$i<=$m;++$i) {\n\tmy $line = <>;\n\tchomp($line);\n\tmy($x, $y) = split(' ', $line);\n\t\n\tif($y eq \"USB\") {\n\t\tpush(@v1, $x);\n\t}\n\telse {\n\t\tpush(@v2, $x);\n\t}\n}\n\n@v1 = sort {$a <=> $b} @v1;\n@v2 = sort {$a <=> $b} @v2;\n\n$i=0;\nmy $nr=0;\nwhile($i < scalar @v1 && $i < $muie) {\n\t$nr++;\n\t\n\t$total+=$v1[$i];\n\t$i++;\n}\n\nmy $j=0;\nwhile($j < scalar @v2 && $j < $cuie) {\n\t$nr++;\n\t\n\t$total+=$v2[$j];\n\t$j++;\n}\n\n#for($i=0;$i<scalar @v2;++$i) {\n#\tprintf(\"%d\\n\", $v2[$i]);\n#}\n\nwhile(($i < scalar @v1 || $j < scalar @v2) && $c > 0) {\n#\tprintf(\"%d %d %d %d\\n\", $i, $j, scalar @v1, scalar @v2);\n\t\n\tif($j >= scalar @v2 || ($v1[$i] <= $v2[$j] && $i < scalar @v1)) {\n\t\t$total+=$v1[$i];\n\t\t++$i;\n\t}\n\telse {\n\t\t$total+=$v2[$j];\n\t\t++$j;\n\t}\n\t\n\t++$nr;\n\t--$c;\n}\n\n\nprintf(\"%d %d\\n\", $nr, $total);\n"}, {"source_code": "sub input { $_ = <>; chomp; wantarray? split: $_ }\n\nsub less_first { sort { $a <=> $b } @_ }\n\nsub buy {\n\tmy ($c, $aref) = @_;\n\twhile ($c--) {\n\t\tlast unless @$aref;\n\t\t$R++, $V += shift @$aref;\n\t}\n}\n\n$R = $V = 0; @c = input; $m = input; \nfor (1..$m) {\n\t($v, $t) = input;\n\tif ($t eq \"USB\") {\n\t\tpush @v0, $v;\n\t} else {\n\t\tpush @v1, $v;\n\t}\n}\n\n@v0 = less_first @v0; \n@v1 = less_first @v1; \n\nbuy $c[0], \\@v0;\nbuy $c[1], \\@v1;\n@v2 = less_first @v0, @v1;\nbuy $c[2], \\@v2;\n\nprint $R, \" \", $V;\n"}, {"source_code": "use warnings;\nuse v5.20;\n\nmy @array;\nmy $total = 0;\nmy $count = 0;\n\nmy $input = <STDIN>;\nchomp $input;\nmy($A, $B, $C) = split(' ', $input);\n\n$input = <STDIN>;\nchomp $input;\nmy $m = int($input);\n\nfor(my $i = 0; $i < $m; $i += 1){\n    $input = <STDIN>;\n    chomp $input;\n    my($value, $name) = split(' ', $input);\n    $value = int($value);\n    push @array, {id => $value, type => $name};\n}\n\n\nfor my $item ( sort { $a->{id} <=> $b->{id} } @array ) {\n    if($item->{type} eq \"USB\"){\n        if($A > 0){\n            $total = $total + $item->{id};\n            $count += 1;\n            $A -= 1;\n        }\n        elsif($C > 0){\n            $total = $total + $item->{id};\n            $count += 1;\n            $C -= 1;\n        }\n    }\n    else{\n        if($B > 0){\n            $total = $total + $item->{id};\n            $count += 1;\n            $B -= 1;\n        }\n        elsif($C > 0){\n            $total = $total + $item->{id};\n            $count += 1;\n            $C -= 1;\n        }\n    }\n}\nprint(\"$count $total\\n\");"}, {"source_code": "use strict;\nuse warnings;\n\nmy ($usb_nr, $ps_nr, $both_nr) = split(\" \", <>);\nmy $nr_prices = <>;\nmy @prices_usb = ();\nmy @prices_ps = ();\nmy $current_price = 0;\nmy $current_type = \"\";\nmy $equipped_usb = 0;\nmy $equipped_ps = 0;\nmy $equipped_both = 0;\nmy $cost = 0;\nmy $bought = 0;\nforeach(1 .. $nr_prices)\n{\n\t($current_price, $current_type) = split(\" \", <>);\n\tif($current_type eq \"USB\")\n\t{\n\t\tpush(@prices_usb, $current_price);\n\t}\n\telse\n\t{\n\t\tpush(@prices_ps, $current_price);\n\t}\n}\n@prices_usb = sort {$a <=> $b} @prices_usb;\n@prices_ps = sort {$a <=> $b} @prices_ps;\n#print \"Prices USB: @prices_usb \\n\";\n#print \"Prices PS/2: @prices_ps \\n\";\n$bought = 0;\nforeach(0 .. scalar $usb_nr-1)\n{\n\tif($_ < scalar @prices_usb)\n\t{\n\t\t#print \"Equipped USB PC with $prices_usb[$_]\\n\";\n\t\t$equipped_usb += 1;\n\t\t$cost += $prices_usb[$_];\n\t\t$bought += 1;\n\t}\n}\nsplice @prices_usb, 0, $bought;\n$bought = 0;\nforeach(0 .. $ps_nr-1)\n{\n\tif($_ < scalar @prices_ps)\n\t{\n\t\t#print \"Equipped PS/2 PC with $prices_ps[$_]\\n\";\n\t\t$equipped_ps += 1;\n\t\t$cost += $prices_ps[$_];\n\t\t$bought += 1;\n\t}\n}\nsplice @prices_ps, 0, $bought;\nmy $pos_usb = 0;\nmy $pos_ps = 0;\nwhile($pos_usb < scalar @prices_usb and $pos_ps < scalar @prices_ps and $equipped_both < $both_nr)\n{\n\tif($prices_usb[$pos_usb] <= $prices_ps[$pos_ps])\n\t{\n\t\t#print \"Equipped PC with both with USB: $prices_usb[$pos_usb]\\n\";\n\t\t$equipped_both += 1;\n\t\t$cost += $prices_usb[$pos_usb];\n\t\t$pos_usb += 1;\n\t}\n\telse\n\t{\n\t\t#print \"Equipped PC with both with PS/2: $prices_ps[$pos_ps]\\n\";\n\t\t$equipped_both += 1;\n\t\t$cost += $prices_ps[$pos_ps];\n\t\t$pos_ps += 1;\n\t}\n}\nwhile($pos_usb < scalar @prices_usb and $equipped_both < $both_nr)\n{\n\t#print \"Equipped PC with both with USB: $prices_usb[$pos_usb]\\n\";\n\t$equipped_both += 1;\n\t$cost += $prices_usb[$pos_usb];\n\t$pos_usb += 1;\n}\nwhile($pos_ps < scalar @prices_ps and $equipped_both < $both_nr)\n{\n\t#print \"Equipped PC with both with PS/2: $prices_ps[$pos_ps]\\n\";\n\t$equipped_both += 1;\n\t$cost += $prices_ps[$pos_ps];\n\t$pos_ps += 1;\n}\nprint $equipped_usb + $equipped_ps + $equipped_both, \" \", $cost;\n"}, {"source_code": "use warnings;\nuse utf8;\nuse feature \"say\";\n\nmy $line = <>;\nchomp($line);\nmy ($usb, $ps2, $mix) = split(' ', $line);\nmy $pcNr = <>;\nchomp($pcNr);\nmy (@usb, @ps2);\nwhile ($pcNr > 0) {\n  $line = <>;\n  chomp($line);\n  my($price, $type) = split(' ', $line);\n  if ($type eq \"USB\") {\n    push ( @usb, $price );\n  } else {\n    push ( @ps2, $price);\n  }\n  --$pcNr;\n}\n@usb = sort ( { $a <=> $b } @usb );\n@ps2 = sort ( { $a <=> $b } @ps2 );\n\nmy $price = 0;\nmy ( $iU, $iP );\n\nfor ( $iU = 0; $usb > 0 && $iU < scalar(@usb); ++$iU, --$usb) {\n        $price += $usb[$iU];\n        ++$pcNr;\n}\n\nfor ( $iP = 0; $ps2 > 0 && $iP < scalar(@ps2); ++$iP, --$ps2) {\n        $price += $ps2[$iP];\n        ++$pcNr;\n}\n\nfor (; ($iU < scalar(@usb) || $iP < scalar( @ps2 )) && $mix > 0; ) {\n        if ( $iU < scalar(@usb) && $iP < scalar(@ps2) && $usb[$iU] <= $ps2[$iP] || $iP >= scalar(@ps2)) {\n                $price += $usb[$iU];\n                ++$pcNr;\n                --$mix;\n                ++$iU;\n        } elsif ($iP < scalar(@ps2) && $iU < scalar(@usb) && $usb[$iU] > $ps2[$iP] || $iU >= scalar(@usb)) {\n                $price += $ps2[$iP];\n                ++$pcNr;\n                --$mix;\n                ++$iP;\n        }\n}\n\nsay $pcNr.\" \".$price;\n"}], "negative_code": [{"source_code": "use v5.20;\nuse warnings;\n\nsub compare {\n\treturn $a <=> $b;\n}\n\nmy ($a,$b,$c) = split(' ',<>);\nmy $m = int <>;\n\nmy (@A,@B);\n\nfor (1..$m) {\n\tmy ($val,$type) = split(' ',<>);\n\tif ($type eq \"USB\") {\n\t\tpush @A,$val;\n    }\n\telse { \n\t\tpush @B,$val;\n\t}\n}\n\n@A = sort compare @A;\n@B = sort compare @B;\n\nmy $cost = 0;\nmy $comp = 0;\n\nwhile ($a and @A) {\n\t$comp += 1;\n\t$cost += shift @A;\n\t$a -= 1;\n}\n\nwhile ($b and @B) {\n\t$comp += 1;\n\t$cost += shift @B;\n\t$b -= 1;\n}\n\nmy @C = sort compare (@A,@B);\n\nwhile ($c and @C) {\n\t$comp += 1;\n\t$cost += shift @B;\n\t$c -= 1;\n}\n\nsay \"$comp $cost\";\n\n"}, {"source_code": "use v5.20;\n\nmy $input = <>;\nmy ($usb_comp, $ps2_comp, $both_comp) = split(/ /, $input);\n\nmy $m = <>;\nmy @usb, my @ps2;\nfor (my $i = 0; $i < $m; $i = $i + 1) {\n\t$input = <>;\n\tchomp $input;\n\tmy ($number, $type) = split(/ /, $input);\n\n\tif ($type eq \"USB\") {\n\t\tpush(@usb, $number);\n\t} else {\n\t\tsay $type;\n\t\tpush(@ps2, $number);\n\t}\n}\n\nmy $price = 0;\nmy $matched = 0;\n# Match as many only-usb computers to usb mouses.\n@usb = sort {$a <=> $b} @usb;\nmy $i = 0;\nwhile ($i < scalar @usb and $usb_comp > 0) {\n\tsay 1;\n\t$price = $price + $usb[$i];\n\t$i++;\n\t$matched++;\n\t$usb_comp--;\n}\n\n# Match as many only-ps2 computers to usb mouses.\n@ps2 = sort {$a <=> $b} @ps2;\nmy $j = 0;\nwhile ($j < scalar @ps2 and $ps2_comp > 0) {\n\tsay 2;\n\t$price = $price + $ps2[$j];\n\t$j++;\n\t$matched++;\n\t$ps2_comp--;\n}\n\n# Match the computers having both ports to cheapest mouses.\nwhile (($j < scalar @ps2 or $i < scalar @usb) and $both_comp > 0) {\n\tsay 3;\n\tif ($i >= scalar @usb or ($j < scalar @ps2 and $ps2[$j] < $usb[$i])) {\n\t\t$price = $price + $ps2[$j];\n\t\t$j++;\n\t} else {\n\t\t$price = $price + $usb[$i];\n\t\t$i++;\n\t}\n\t$matched++;\n\t$both_comp--;\n}\n\nprint \"$matched $price\"\n"}, {"source_code": "#use v5.24;\nuse warnings;\nmy @usb,@ps2,@merged,$nrcump=0,$costtot=0;\n\nmy $line=<stdin>;\nchomp($line);\nmy ($usbonly,$ps2only,$both)=split(/ /,$line);\n$line=<stdin>;\nchomp($line);\nmy ($n)=split(/ /,$line);\nfor (my $i=1;$i<=$n;$i++){\n\t$line=<stdin>;\n\tchomp($line);\n\tmy ($cost,$tip)=split(/ /,$line);\n\tif ($tip eq \"USB\") {push @usb, $cost;}\n\telse {push @ps2, $cost;}\n}\n@usb=sort {$a<=>$b} @usb;\n@ps2=sort {$a<=>$b} @ps2;\nwhile ($usbonly>0 && scalar @usb>0){\n\t$usbonly--;\n\t$nrcump++;\n\t$costtot=$costtot+shift @usb;\n}\nwhile ($ps2only>0 && scalar @ps2>0){\n\t$ps2only--;\n\t$nrcump++;\n\t$costtot=$costtot+shift @ps2;\n}\nforeach my $var (@usb) {push @merged, $var;}\nforeach my $var (@ps2) {push @merged, $var;}\nwhile ($both>0 && scalar @merged>0){\n\t$both--;\n\t$nrcump++;\n\t$costtot=$costtot+shift @merged;\n}\nprint $nrcump.' '.$costtot;\n<stdin>;\nexit(0);"}, {"source_code": "use v5.20.1;\nuse warnings;\n\nmy $line = <STDIN>;\nchomp($line);\n\nmy($a, $b, $c) = split(' ', $line);\n\n$line = <STDIN>;\nchomp($line);\n\nmy $m = $line;\n\nmy @usb = ();\nmy @ps = ();\nmy $model = \"\";\nmy $price = 0;\n\nfor(my $i = 0; $i < $m; $i++){\n\n\t$line = <STDIN>;\n\t($price, $model) = split(' ', $line);\n\tif($model eq \"USB\"){\n\n\t\tpush @usb, $price;\n\n\t}elsif($model eq \"PS/2\"){\n\n\t\tpush @ps, $price;\n\n\t}\n\n}\n\n@usb = sort @usb;\n@ps = sort @ps;\n\nmy $ui = 0;\nmy $pi = 0;\nmy $cost = 0;\nmy $mice = 0;\n\nwhile($ui < @usb && $a > 0){\n\n\t$cost += $usb[$ui];\n\t$ui++;\n\t$mice++;\n\t$a--;\n\n}\n\nwhile($pi < @ps && $b > 0){\n\n\t$cost += $ps[$pi];\n\t$pi++;\n\t$b--;\n\t$mice++;\n\n}\n\nwhile($ui < @usb && $pi < @ps && $c > 0){\n\n\tif($usb[$ui] < $ps[$pi]){\n\n\t\t$cost += $usb[$ui];\n\t\t$c--;\n\t\t$ui++;\n\t\t$mice++;\n\n\t}else{\n\n\t\t$cost += $ps[$pi];\n\t\t$pi++;\n\t\t$c--;\n\t\t$mice++;\n\n\t}\n\n}\n\nwhile($ui < @usb && $c > 0){\n\n\t$cost += $usb[$ui];\n\t$ui++;\n\t$c--;\n\t$mice++;\n\n}\n\nwhile($pi < @ps && $c > 0){\n\n\t$cost += $ps[$pi];\n\t$pi++;\n\t$c--;\n\t$mice++;\n\n}\n\nprint $mice, \" \", $cost, \"\\n\";\n"}, {"source_code": "use warnings;\n\nmy $line = <>;\nchomp($line);\nmy($muie, $cuie, $c) = split(' ', $line);\n\nmy $i;\nmy @v1;\nmy @v2;\nmy $m = <>;\nchomp($m);\n\nfor($i=1;$i<=$m;++$i) {\n\tmy $line = <>;\n\tchomp($line);\n\tmy($x, $y) = split(' ', $line);\n\t\n\tif($y eq \"USB\") {\n\t\tpush(@v1, $x);\n\t}\n\telse {\n\t\tpush(@v2, $x);\n\t}\n}\n\n@v1 = sort {$a <=> $b} @v1;\n@v2 = sort {$a <=> $b} @v2;\n\n$i=0;\nmy $nr=0;\nwhile($i < scalar @v1 && $i < $muie) {\n\t$nr++;\n\t\n\t$total+=$v1[$i];\n\t$i++;\n}\n\nmy $j=0;\nwhile($j < scalar @v2 && $j < $cuie) {\n\t$nr++;\n\t\n\t$total+=$v2[$j];\n\t$j++;\n}\n\n#for($i=0;$i<scalar @v2;++$i) {\n#\tprintf(\"%d\\n\", $v2[$i]);\n#}\n\nwhile(($i < scalar @v1 || $j < scalar @v2) && $c > 0) {\n#\tprintf(\"%d %d %d %d\\n\", $i, $j, scalar @v1, scalar @v2);\n\t\n\tif($j >= scalar @v2 || ($v1[$i] <= $v2[$j] && $i < scalar @v1)) {\n\t\tprint \"jeg\";\n\t\tprint $v1[$i];\n\t\t$total+=$v1[$i];\n\t\t++$i;\n\t}\n\telse {\n\t\t$total+=$v2[$j];\n\t\t++$j;\n\t}\n\t\n\t++$nr;\n\t--$c;\n}\n\n\nprintf(\"%d %d\\n\", $nr, $total);\n"}, {"source_code": "use warnings;\n\nmy $line = <>;\nchomp($line);\nmy($muie, $cuie, $c) = split(' ', $line);\n\nmy $i;\nmy @v1;\nmy @v2;\nmy $m = <>;\nchomp($m);\n\nfor($i=1;$i<=$m;++$i) {\n\tmy $line = <>;\n\tchomp($line);\n\tmy($x, $y) = split(' ', $line);\n\t\n\tif($y eq \"USB\") {\n\t\tpush(@v1, $x);\n\t}\n\telse {\n\t\tpush(@v2, $x);\n\t}\n}\n\n@v1 = sort {$a <=> $b} @v1;\n@v2 = sort {$a <=> $b} @v2;\n\n$i=0;\nmy $nr=0;\nwhile($i < scalar @v1 && $i < $muie) {\n\t$nr++;\n\t\n\t$total+=$v1[$i];\n\t$i++;\n}\n\nmy $j=0;\nwhile($j < scalar @v2 && $j < $cuie) {\n\t$nr++;\n\t\n\t$total+=$v2[$j];\n\t$j++;\n}\n\n#for($i=0;$i<scalar @v2;++$i) {\n#\tprintf(\"%d\\n\", $v2[$i]);\n#}\n\nwhile(($i < scalar @v1 || $j < scalar @v2) && $c > 0) {\n\tprintf(\"%d %d %d %d\\n\", $i, $j, scalar @v1, scalar @v2);\n\t\n\tif($j >= scalar @v2 || ($v1[$i] <= $v2[$j] && $i < scalar @v1)) {\n\t\tprint \"jeg\";\n\t\tprint $v1[$i];\n\t\t$total+=$v1[$i];\n\t\t++$i;\n\t}\n\telse {\n\t\t$total+=$v2[$j];\n\t\t++$j;\n\t}\n\t\n\t++$nr;\n\t--$c;\n}\n\n\nprintf(\"%d %d\\n\", $nr, $total);\n"}, {"source_code": "sub input { $_ = <>; chomp; wantarray? split: $_ }\n\nsub less_first { sort { $a <=> $b } @_ }\n\nsub buy {\n\tmy ($c, $aref) = @_;\n\twhile ($c--) {\n\t\tlast unless @$aref;\n\t\t$R++, $V += shift @$aref;\n\t}\n}\n\n@c = input; $m = input; \nfor (1..$m) {\n\t($v, $t) = input;\n\tif ($t eq \"USB\") {\n\t\tpush @v0, $v;\n\t} else {\n\t\tpush @v1, $v;\n\t}\n}\n\n@v0 = less_first @v0; \n@v1 = less_first @v1; \n\nbuy $c[0], \\@v0;\nbuy $c[1], \\@v1;\n@v2 = less_first @v0, @v1;\nbuy $c[2], \\@v2;\n\nprint $R, \" \", $V;\n"}, {"source_code": "use utf8;\nuse feature \"say\";\n\nmy $line = <>;\nchomp($line);\nmy ($usb, $ps2, $mix) = split(' ', $line);\nmy $pcNr = <>;\nchomp($pcNr);\nmy (@usb, @ps2);\nwhile ($pcNr > 0) {\n  $line = <>;\n  chomp($line);\n  my($price, $type) = split(' ', $line);\n  if ($type eq \"USB\") {\n    push ( @usb, $price );\n  } else {\n    push ( @ps2, $price);\n  }\n  --$pcNr;\n}\n\n@usb = sort ( { $a <=> $b } @usb );\n@ps2 = sort ( { $a <=> $b } @ps2 );\nmy $price = 0;\nmy ( $iU, $iP );\n\nfor ( $iU = 0; $iU < scalar ( @usb ) && $usb > 0; ++$iU, --$usb ) {\n   $price += $usb[$iU];\n   ++$pcNr;\n}\nfor ( $iP = 0; $iP < scalar ( @ps2 ) && $ps2 > 0; ++$iP, --$ps2 ) {\n   $price += $ps2[$iP];\n   ++$pcNr;\n}\n\nfor ( ; ( $iU < scalar( @usb ) || $iP < scalar ( @ps2 ) ) && $mix > 0; --$mix ) {\n   if ( ({ $usb[$iU] <=> $ps2[$iP] } < 1) || $iP >= scalar ( @ps2 ) ) {\n      $price += $usb[$iU];\n      ++$pcNr;\n      ++$iU;\n   } else {\n      $price += $ps2[$iP];\n      ++$pcNr;\n      ++$iP;\n   }\n}\n\nsay $pcNr.\" \".$price;"}, {"source_code": "use warnings;\nuse utf8;\nuse feature \"say\";\n\nmy $line = <>;\nchomp($line);\nmy ($usb, $ps2, $mix) = split(' ', $line);\nmy $pcNr = <>;\nchomp($pcNr);\nmy (@usb, @ps2);\nwhile ($pcNr > 0) {\n  $line = <>;\n  chomp($line);\n  my($price, $type) = split(' ', $line);\n  if ($type eq \"USB\") {\n    push ( @usb, $price );\n  } else {\n    push ( @ps2, $price);\n  }\n  --$pcNr;\n}\n@usb = sort ( { $a <=> $b } @usb );\n@ps2 = sort ( { $a <=> $b } @ps2 );\n\nmy $price = 0;\nmy ( $iU, $iP );\nfor ( $iU = 0; $iU < scalar ( @usb ) && $usb > 0; ++$iU, --$usb ) {\n   $price += $usb[$iU];\n   say $usb[$iU];\n   ++$pcNr;\n}\nfor ( $iP = 0; $iP < scalar ( @ps2 ) && $ps2 > 0; ++$iP, --$ps2 ) {\n   $price += $ps2[$iP];\n   say $ps2[$iP];\n   ++$pcNr;\n}\nfor ( ; ( $iU < scalar( @usb ) || $iP < scalar ( @ps2 ) ) && $mix > 0; --$mix ) {\n   if ( $usb[$iU] <= $ps2[$iP]) {\n      $price += $usb[$iU];\n      ++$pcNr;\n      ++$iU;\n   } else {\n      $price += $ps2[$iP];\n      ++$pcNr;\n      ++$iP;\n   }\n}\n\nsay $pcNr.\" \".$price;\n"}], "src_uid": "3d6151b549bd52f95ab7fdb972e6fb98"}
{"source_code": "( $b, $q, $l ) = split ' ', <>;\nmap ++ $h{ $_ }, split ' ', <>;\n\t\nwhile( abs $b <= abs $l ){\n\t$A += !$h{ $b };\n\t$b *= $q;\n\tlast if $c ++ > 80;\n\t}\n\nprint $A > 35 ? inf : 0 + $A", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $b, $q, $l, $m ) = split;\n\tmy %h = map { $_ => 1 } split ' ', <>;\n\t\n\tmy @ans;\n\t\n\tmy $maxl = abs $l;\n\tmy $minl = - $maxl;\n\t\n\tmy $c = 0;\n\t\n\twhile( $minl <= $b and $b <= $maxl ){\n\t\t$h{ $b } or push @ans, $b;\n\t\t$b *= $q;\n\t\t$c ++ > 2e4 and last;\n\t\t}\n\t\n\tprint @ans >= 1e4 ? \"inf\" : 0 + @ans;\n\t}"}, {"source_code": "$/ = \"\"; $_ = <>; chomp; ($b, $q, $l, $m, @a) = split; \n\n$a{$_} = 1 for @a;\nif (abs($b) <= $l) {\n\t$Y = 1, $B = !$a{$b}, $U = !$a{-$b}, $Z = !$a{0}\n}\t\n\nif ($b == 0) {\n\t$c = inf if $B;\n} elsif ($q == 0) {\n\t$c = 1 if $B;\n\t$c = inf if $Z;\n} elsif ($q == 1) {\n\t$c = inf if $B;\n} elsif ($q == -1) {\n\t$c = inf if $B || $U;\n} else {\n\t$c = 1 + int( log($l/abs($b)) / log(abs($q)) ) if $Y;\n\tfor ($i = $b; abs($i) <= $l; $i *= $q) { \n\t\t$c -= $a{$i};\n\t}\n}\n\nprint $c // 0;"}], "negative_code": [{"source_code": "$/ = \"\"; $_ = <>; chomp; ($b, $q, $l, $m, @a) = split; \n\n$a{$_} = 1 for @a;\nif (abs($b) <= $l) {\n\t$B = !$a{$b}, $U = !$a{-$b}, $Z = !$a{0}\n}\t\n\nif ($b == 0) {\n\t$c = inf if $B;\n} elsif ($q == 0) {\n\t$c = 1 if $B;\n\t$c = inf if $Z;\n} elsif ($q == 1) {\n\t$c = inf if $B;\n} elsif ($q == -1) {\n\t$c = inf if $B || $U;\n} else {\n\t$c = 1 + int( log($l/abs($b)) / log(abs($q)) );\n\tfor ($i = $b; abs($i) <= $l; $i *= $q) { \n\t\t$c -= $a{$i};\n\t}\n}\n\nprint $c // 0;"}, {"source_code": "$/ = \"\"; $_ = <>; chomp; ($b, $q, $l, $m, @a) = split; \n\n$a{$_} = 1 for @a;\nif (abs($b) <= $l) {\n\t$B = !$a{$b}, $U = !$a{-$b}, $Z = !$a{0}\n}\t\n\nif ($b == 0) {\n\t$c = inf if $B;\n} elsif ($q == 0) {\n\t$c = 1 if $B;\n\t$c = inf if $Z;\n} elsif ($q == 1) {\n\t$c = inf if $B;\n} elsif ($q == -1) {\n\t$c = inf if $B || $U;\n} else {\n\t$c = 1 + int( log($l/abs($b)) / log(abs($q)) ) if $B;\n\tfor ($i = $b; abs($i) <= $l; $i *= $q) { \n\t\t$c -= $a{$i};\n\t}\n}\n\nprint $c // 0;"}, {"source_code": "$/ = \"\"; $_ = <>; chomp; ($b, $q, $l, $m, @a) = split; \n\n$a{$_} = 1 for @a;\nif (abs($q) > 1) {\n\tfor ($i = $b; abs($i) <= $l; $i *= $q) { \n\t\t$C += $a{$i};\n\t}\n}\t\n$B = !$a{$b}, $U = !$a{-$b} if abs($b) <= $l;\n$Z = !$a{0};\n\nif ($b == 0) {\n\t$c = inf if $Z;\n} elsif ($q == 0) {\n\t$c = 1 if $B;\n\t$c = inf if $Z;\n} elsif ($q == 1) {\n\t$c = inf if $B;\n} elsif ($q == -1) {\n\t$c = inf if $B || $U;\n} else {\n\t$c = 1 - $C + int( log($l/abs($b)) / log(abs($q)) );\n}\n\nprint $c // 0;"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $b, $q, $l, $m ) = split;\n\tmy %h = map { $_ => 1 } split ' ', <>;\n\t\n\tmy @ans;\n\t\n\tmy $maxl = abs $l;\n\tmy $minl = - $maxl;\n\t\n\tmy $inf;\n\t\n\tif( $b == 0 ){\n\t\t$inf = $h{ 0 } ? 0 : \"inf\";\n\t\t}\n\telsif( $q == 0 ){\n\t\t$inf = $h{ 0 } ? 0 : \"inf\";\n\t\t$inf or $inf += ($minl <= $b and $b <= $maxl and not $h{ $b });\n\t\t}\n\t\n\tif( not defined $inf and $minl <= $b and $b <= $maxl and $q =~ /^-?1$/ ){\n\t\tif( $q == 1 ){ $inf = $h{ $b } ? 0 : \"inf\" }\n\t\telsif( $q == -1 ){ $inf = ($h{ $b } * $h{ 0 - $b }) ? 0 : \"inf\" }\n\t\t}\n\telsif( not defined $inf and not( $minl <= $b and $b <= $maxl) and $q =~ /^-?1$/ ){\n\t\t$inf = 0;\n\t\t}\n\t\n\twhile( not defined $inf and $minl <= $b and $b <= $maxl ){\n\t\t$h{ $b } or push @ans, $b;\n\t\t$b *= $q;\n\t\t}\n\t\n\tprint defined $inf ? $inf : 0 + @ans;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $b, $q, $l, $m ) = split;\n\tmy %h = map { $_ => 1 } split ' ', <>;\n\t\n\tmy @ans;\n\t\n\tmy $maxl = abs $l;\n\tmy $minl = - $maxl;\n\t\n\tmy $c = 0;\n\t\n\twhile( $minl <= $b and $b <= $maxl ){\n\t\t$h{ $b } or push @ans, $b;\n\t\t$b *= $q;\n\t\t$c ++ > 1e4 and last;\n\t\t}\n\t\n\tprint @ans >= 1e4 ? \"inf\" : 0 + @ans;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $b, $q, $l, $m ) = split;\n\tmy %h = map { $_ => 1 } split ' ', <>;\n\t\n\tmy @ans;\n\t\n\tmy $maxl = abs $l;\n\tmy $minl = - $maxl;\n\t\n\tmy $c = 0;\n\t\n\twhile( $minl <= $b and $b <= $maxl ){\n\t\t$h{ $b } or push @ans, $b;\n\t\t$b *= $q;\n\t\t$c ++ > 1e4 and last;\n\t\t}\n\t\n\tprint @ans >= 1e4 ? \"inf\" : 0 + @ans;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $b, $q, $l, $m ) = split;\n\tmy %h = map { $_ => 1 } split ' ', <>;\n\t\n\tmy @ans;\n\t\n\tmy $maxl = abs $l;\n\tmy $minl = - $maxl;\n\t\n\tmy $inf;\n\t$b == 0 || $q == 0 and $inf = \"inf\";\n\t\n\tif( not defined $inf and $minl <= $b and $b <= $maxl and $q == 1 ){\n\t\t$inf = $h{ $b } ? 0 : \"inf\";\n\t\t}\n\telsif( not defined $inf and not( $minl <= $b and $b <= $maxl) and $q == 1 ){\n\t\t$inf = 0;\n\t\t}\n\t\n\twhile( not defined $inf and $minl <= $b and $b <= $maxl ){\n\t\t$h{ $b } or push @ans, $b;\n\t\t$b *= $q;\n\t\t}\n\t\n\tprint defined $inf ? $inf : 0 + @ans;\n\t}"}], "src_uid": "749c290c48272a53e2e79730dab0538e"}
{"source_code": "chomp (my ($n, $m) = split /\\s+/, <STDIN>);\n\nchomp (my %arr = map {$_ => 1} split /\\s+/, <STDIN>);\n\nmy @ans;\nfor (my $i = 1; $i <= 10 ** 9; $i++) {\n  next if exists $arr{$i};\n  if ($m >= $i) {\n    $m -= $i;\n    push @ans, $i;\n  } else {\n    last;\n  }\n}\n\nprintf \"%s\\n\", scalar @ans;\nprintf \"@ans\\n\";\n", "positive_code": [{"source_code": "sub gets { my $s = <>; chomp($s); split(' ', $s) }\n($n, $m) = gets(); @a = gets();\n@a = sort({$a <=> $b} @a);\nA: for $a (@a) {\n\tif ($a - $a1 > 1) {\n\t\tfor $r ($a1 + 1 .. $a - 1) {\n\t\t\t$m -= $r;\n\t\t\tif ($m < 0) {\n\t\t\t\tlast A;\n\t\t\t}\n\t\t\tpush(@r, $r);\n\t\t}\n\t}\n\t$a1 = $a;\n}\nif ($m > 0) {\n    $r = $a1;\n    while (1) {\n    \t$m -= ++$r;\n    \tlast if $m < 0;\n    \tpush(@r, $r);\n    }\n}\nprint 0 + @r, \"\\n\";\nprint \"@r\\n\";\n"}, {"source_code": "my @n = split(/ /, <STDIN>);\nmy $m = $n[1];\nmy @A = sort {$a <=> $b} split(/ /, <STDIN>);\nmy $j = 0, $t = 1;\nmy @ans;\nwhile(1) {\n    while($A[$j] == $t) {\n        $j++;\n        $t++;\n    }\n    if($m >= $t) {\n        $m -= $t;\n        push @ans, $t;\n        $t++;\n    } else {\n        print scalar @ans.\"\\n\";\n        foreach $x (@ans) { print \"$x \"; }\n        exit 0;\n    }\n}"}, {"source_code": "($n, $m) = split ' ', <>;\n%h = map { $_, 0 } split ' ', <>;\n$h{ ++ $i } // do { ($m -= $i) < 0 or push @ans, $i } while $m > 0;\nprint ~~ @ans, \"\\n@ans\"\n"}, {"source_code": "($n, $m) = split ' ', <>;\n%h = map { $_, 0 } split ' ', <>;\n$h{ ++ $i } // do { ($m -= $i) < 0 or push @ans, $i } while $m > 0;\nprint ~~ @ans, \"\\n@ans\""}], "negative_code": [], "src_uid": "0318d4d5ea3425bf6506edeb1026f597"}
{"source_code": "# Perl\nchomp($n = <>);\nchomp($_ = <>);\n@a = sort { $a <=> $b } split / /;\nforeach (@a) {\n\t$c++ if $_==$a[0] or last;\n}\nforeach (reverse @a) {\n\t$d++ if $_==$a[-1] or last;\n}\nif ($a[-1] == $a[0]) {\n\tprint \"0 \", $n*($n-1)/2, \"\\n\";\n} else {\n\tprint $a[-1]-$a[0], ' ', $c*$d, \"\\n\";\n}\n\n", "positive_code": [{"source_code": "#!/perl -w\n\nuse strict ;\n\nchomp( my $n = <STDIN> );\n\nmy @beauty = split /\\s+/ , <STDIN>;\n\nmy $maxbeauti = 0 ;\nmy $minbeauti = 10E9 + 1;\nmy $maxcount  = 0 ;\nmy $mincount  = 0 ;\n\nforeach( @beauty ){\n    if ( $_ >= $maxbeauti ){\n        $maxbeauti = $_ ;\n    }\n    if ( $_ <= $minbeauti ){\n        $minbeauti = $_ ;\n    }\n}\nif( $minbeauti != $maxbeauti ){\n    foreach( @beauty ){\n        if ( $_ == $maxbeauti ){\n            $maxcount ++ ;\n        }\n        if ( $_ == $minbeauti ){\n            $mincount ++ ;\n        }\n    }\n    print $maxbeauti - $minbeauti , \" \" , $mincount * $maxcount ;\n}else{\n    print \"0\" , \" \" , $n*($n - 1)/2 ;\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\n@a = sort { $a <=> $b } @a;\n$a[0]==$a[$n-1] and say 0, \" \", $n*($n-1)/2 and exit;\n$i = 0;\nwhile ($a[$i] == $a[0]) {\n\t++$i;\n}\n$j = $n-1;\nwhile ($a[$j] == $a[$n-1]) {\n\t--$j;\n}\n($mx, $ans) = ($a[$n-1]-$a[0], $i * ($n-1-$j));\nsay \"$mx $ans\";"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\n<>;\nmy @x = sort { $a <=> $b } split ' ', <>;\nmy $min = $x[0];\nmy $max = $x[-1];\nmy $max_diff = $max - $min;\n\nmy $count_min = 0;\nfor my $x (@x) {\n  if ($x > $min) {\n    last;\n  } else {\n    $count_min++;\n  }\n}\n\nmy $count_max = 0;\nfor my $x (reverse @x) {\n  if ($x < $max) {\n    last;\n  } else {\n    $count_max++;\n  }\n}\n\nmy $ways = $max_diff == 0 ? $count_min * ($count_min - 1) / 2\n                          : $count_min * $count_max;\n\nsay \"$max_diff $ways\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @num = split ' ',<>;\n@num = sort {$a <=> $b} @num;\nmy ($res,$cnt1,$cnt2) = ($num[$#num] - $num[0], 0, 0);\nif($res == 0){\n\tprint 0, \" \", ($n*($n-1))/2, \"\\n\";\n\texit 0;\n}\nforeach(@num){\n\t$cnt1 += $_ == $num[0];\n\t$cnt2 += $_ == $num[$#num];\n}\nprint \"$res \", $cnt1*$cnt2, \"\\n\";\n"}, {"source_code": "<>;\n@a=split/ /,<>;\n$y=10**9;\n($y > $_ and $y = $_), $Y < $_ and $Y = $_ for @a;\n($y == $_ and $w++), $Y == $_ and $W++ for @a;\nprint $y == $Y ? (\"0 \", $w*($w-1)/2) : ($Y-$y, \" \", $w*$W)"}, {"source_code": "my $n = <>;\nmy @a = sort {$a <=> $b } split \" \", <>;\nmy ($minc, $maxc) = (0, 0);\nfor (0 .. $n - 1) {\n    last unless $a[$_] == $a[0];\n    ++$minc;\n}\nfor (reverse 0 .. $n - 1) {\n    last unless $a[$_] == $a[$n - 1];\n    ++$maxc;\n}\n\nprintf (\"%.0f %.0f\\n\", $a[-1] - $a[0], $minc == $n? $n * ($n - 1) / 2 : $minc * $maxc);"}, {"source_code": "my $n = <>;\nmy @arr = split / /, <>;\nmy ($min, $max) = (10**9, 0);\nmy ($ans, $cmin, $cmax) = (0, 0, 0);\nfor (@arr) {\n    if ($_ > $max) {\n        $max = $_;\n        $cmax = 0;\n    }\n    if ($_ < $min) {\n        $min = $_;\n        $cmin = 0;\n    }\n    $cmax++ if ($_ == $max);\n    $cmin++ if ($_ == $min);\n}\n$ans = $cmax * $cmin;\n$ans = ($n * ($n - 1)) / 2 if($max == $min);\nprint $max - $min . \" \" . $ans . \"\\n\";\n"}], "negative_code": [{"source_code": "my $n = <>;\nmy @a = sort split \" \", <>;\nmy ($minc, $maxc) = (0, 0);\nfor (0 .. $n - 1) {\n    last unless $a[$_] == $a[0];\n    ++$minc;\n}\nfor (reverse 0 .. $n - 1) {\n    last unless $a[$_] == $a[$n - 1];\n    ++$maxc;\n}\n\nprint $a[-1] - $a[0], \" \", $minc == $n? $n * ($n - 1) / 2 : $minc * $maxc;"}, {"source_code": "my $n = <>;\nmy @a = sort split \" \", <>;\nmy ($minc, $maxc) = (0, 0);\nfor (0 .. $n - 1) {\n    last unless $a[$_] == $a[0];\n    ++$minc;\n}\nfor (reverse 0 .. $n - 1) {\n    last unless $a[$_] == $a[$n - 1];\n    ++$maxc;\n}\n\nprintf (\"%.0f %.0f\\n\", $a[-1] - $a[0], $minc == $n? $n * ($n - 1) / 2 : $minc * $maxc);"}, {"source_code": "my $n = <>;\nmy @arr = split / /, <>;\nmy ($min, $max) = (10**9, 0);\nmy ($ans, $cmin, $cmax) = (0, 0, 0);\nfor (@arr) {\n    if ($_ > $max) {\n        $max = $_;\n        $cmax = 0;\n    }\n    if ($_ < $min) {\n        $min = $_;\n        $cmin = 0;\n    }\n    $cmax++ if ($_ == $max);\n    $cmin++ if ($_ == $min);\n}\n$ans = $cmax * $cmin;\n$ans = ($n * ($n - 1)) / 2 if($max == $min);\nprint $ans . \"\\n\";"}, {"source_code": "#!/perl -w\n\nuse strict ;\n\nchomp( my $n = <STDIN> );\n\nmy @beauty = split /\\s+/ , <STDIN>;\n\nmy $maxbeauti = 0 ;\nmy $minbeauti = 10E9 + 1;\nmy $maxcount  = 0 ;\nmy $mincount  = 0 ;\n\nforeach( @beauty ){\n    if ( $_ >= $maxbeauti ){\n        $maxbeauti = $_ ;\n    }\n    if ( $_ <= $minbeauti ){\n        $minbeauti = $_ ;\n    }\n}\n\nforeach( @beauty ){\n    if ( $_ == $maxbeauti ){\n        $maxcount ++ ;\n    }\n    if ( $_ == $minbeauti ){\n        $mincount ++ ;\n    }\n}\n\nprint $maxbeauti-$minbeauti , \" \" , $mincount * $maxcount ;"}, {"source_code": "# Perl \nchomp($n = <>); \nchomp($_ = <>);\n@a = sort sub {$a <=> $b}, split / /;\n foreach (@a) {\n\t$a++ if $_==$a[0] or last;\n } \nforeach (reverse @a) { \n\t$b++ if $_==$a[-1] or last;\n } \nif ($a[-1] == $a[0]) { \n\tprint \"0 \", $n*($n-1)/2, \"\\n\"; \n} else { \n\tprint $a[-1]-$a[0], ' ', $a*$b, \"\\n\";\n }\n\n"}, {"source_code": "# Perl\nchomp($n = <>);\n@a = sort split / /, <>;\nforeach (@a) {\n\t$a++ if $_==$a[0] or last;\n}\nforeach (reverse @a) {\n\t$b++ if $_==$a[-1] or last;\n}\nprint $a[-1]-$a[0], ' ', $a*$b, \"\\n\";\n\n"}, {"source_code": "# Perl\nchomp($n = <>);\nchomp($_ = <>);\n@a = sort split / /;\nforeach (@a) {\n\t$a++ if $_==$a[0] or last;\n}\n$e = $a[-1];\nforeach (reverse @a) {\n\t$b++ if $_==$e or last;\n}\nif ($a[-1] == $a[0]) {\n\tprint \"0 \", $n*($n-1)/2, \"\\n\";\n} else {\n\tprint $a[-1]-$a[0], ' ', $a*$b, \"\\n\";\n}\n\n"}, {"source_code": "# Perl\nchomp($n = <>);\n@a = sort split / /, <>;\nforeach (@a) {\n\t$a++ if $_==$a[0] or last;\n}\nforeach (reverse @a) {\n\t$b++ if $_==$a[-1] or last;\n}\nif ($a[-1] == $a[0]) {\n\tprint \"0 \", $n*($n-1)/2, \"\\n\";\n} else {\n\tprint $a[-1]-$a[0], ' ', $a*$b, \"\\n\";\n}\n\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\n<>;\nmy @x = sort { $a <=> $b } split ' ', <>;\nmy $min = $x[0];\nmy $max = $x[-1];\nmy $max_diff = $max - $min;\n\nmy $count_min = 0;\nfor my $x (@x) {\n  if ($x > $min) {\n    last;\n  } else {\n    $count_min++;\n  }\n}\n\nmy $count_max = 0;\nfor my $x (reverse @x) {\n  if ($x < $max) {\n    last;\n  } else {\n    $count_max++;\n  }\n}\n\nmy $ways = $count_min * $count_max;\n\nsay \"$max_diff $ways\";\n"}, {"source_code": "<>;\n@a=split/ /,<>;\n$y=10**9;\n($y > $_ and $y = $_), $Y < $_ and $Y = $_ for @a;\nprint $y == $Y ? (\"0 \", $y*($y-1)/2) : ($Y-$y, \" \", $y*$Y)"}, {"source_code": "<>;\n@_=split/ /,<>;\n$_>$max and $max=$_ for @_;\n$min=$max;\n$_<$max and $max=$_ for @_;\n$min==$_ and $MIN++ for @_;\n$max==$_ and $MAX++ for @_;\n$max-$min and $f=$MIN*$MAX;\nprint $max-$min, \" \", 0+$f;"}], "src_uid": "eb2d1072c5308d9ef686315a122d9d3c"}
{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n=<>;\nmy $up=<>;\nmy @current=split(' ',<>);\nmy $last=7-$up;\nmy $can=1;\nforeach my $count(1..$n-1){\n\t@current=split(' ',<>);\n\tif($last==$current[0] || $last==7-$current[0] || $last==$current[1] || $last==7-$current[1]){\n\t\t$can=0;\n\t}\n}\nif($can==1){\n\tprint\"YES\\n\";\n}else{\n\tprint\"NO\\n\";\n}", "positive_code": [{"source_code": "chomp($totalDice = <STDIN>);\nchomp($topFace = <STDIN>);\n$bottomFace = 7 - $topFace;\n@diceFaces = ( 1, 2, 3, 4, 5, 6);\n@topBottomFaces = ( $topFace, $bottomFace);\nmy %diceFaces=map{$_ =>1} @diceFaces;\nmy %topBottomFaces=map{$_=>1} @topBottomFaces;\nmy @remFaces=grep(!defined $topBottomFaces{$_}, @diceFaces);\nwhile (<STDIN>) { # assigns each line in turn to $_\n    #print \"Just read in this line: $_\";\n    $currentLine = $_;\n    if($currentLine =~ /([1-6]) ([1-6])/) {\n        $leftFace = $1;\n        $rightFace = $2;\n        if ( grep { $_ eq $leftFace } @remFaces ) {\n        }\n        else {\n            print \"NO\";\n            exit 0;\n        }\n        if ( grep { $_ eq $rightFace } @remFaces ) {\n        }\n        else {\n            print \"NO\";\n            exit 0;\n        }\n    }\n    $totalDice--;\n}\nif ( $totalDice == 0) {\n    print \"YES\";\n}\nelse {\n    print \"NO\";\n}"}], "negative_code": [{"source_code": "chomp($totalDice = <STDIN>);\n$topFace = <STDIN>;\n$bottomFace = 7 - $topFace;\n@diceFaces = ( 1, 2, 3, 4, 5, 6);\n@topBottomFaces = ( $topFace, $bottomFace);\n@diff{ @diceFaces } = { @diceFaces };\ndelete @diff{ @topBottomFaces };\n@remFaces = (keys %diff);\nwhile (<STDIN>) { # assigns each line in turn to $_\n\t#print \"Just read in this line: $_\";\n\t$currentLine = $_;\n\tif($currentLine =~ /([1-6]) ([1-6])/) {\n\t\t$leftFace = $1;\n\t\t$rightFace = $2;\n\t\tif ( grep { $_ eq $leftFace } @remFaces ) {\n\t\t}\n\t\telse {\n\t\t\tprint \"NO\";\n\t\t\texit 0;\n\t\t}\n\t\tif ( grep { $_ eq $leftFace } @remFaces ) {\n\t\t}\n\t\telse {\n\t\t\tprint \"NO\";\n\t\t\texit 0;\n\t\t}\n\t}\n\t$totalDice--;\n}\nif ( $totalDice == 0) {\n\tprint \"YES\";\n}\nelse {\n\tprint \"NO\";\n}"}, {"source_code": "chomp($totalDice = <STDIN>);\n$topFace = <STDIN>;\n$bottomFace = 7 - $topFace;\n@diceFaces = ( 1, 2, 3, 4, 5, 6);\n@topBottomFaces = ( $topFace, $bottomFace);\n@diff{ @diceFaces } = { @diceFaces };\ndelete @diff{ @topBottomFaces };\n@remFaces = (keys %diff);\nwhile (<STDIN>) { # assigns each line in turn to $_\n    $currentLine = $_;\n    if($currentLine =~ /([1-6]) ([1-6])/) {\n        $leftFace = $1;\n        $rightFace = $2;\n        if ( grep { $_ eq $leftFace } @remFaces ) {\n        }\n        else {\n            print \"NO\";\n            exit 0;\n        }\n        if ( grep { $_ eq $rightFace } @remFaces ) {\n        }\n        else {\n            print \"NO\";\n            exit 0;\n        }\n    }\n    $totalDice--;\n}\nif ( $totalDice == 0) {\n    print \"YES\";\n}\nelse {\n    print \"NO\";\n}"}], "src_uid": "2d6a1202139e1f77f32377224e1fe752"}
{"source_code": "while(<>){\n\tchomp;\n\t@_=split/ /;\n\t$_=<>;\n\t$sum=0;\n\twhile(/./g){\n\t\t$& == 1 and $sum+=$_[0];\n\t\t$& == 2 and $sum+=$_[1];\n\t\t$& == 3 and $sum+=$_[2];\n\t\t$& == 4 and $sum+=$_[3];\n\t\t\n\t\t}\n\t\n\t\n\tprint $sum;\n\tprint \"\\n\";\n\t}", "positive_code": [{"source_code": "use List::Util \"sum\";\n@a = split \" \", <>;\n@b = split \"\", <>;\nprint ((sum map { $a[$_ - 1] } @b) - @a[-1]);"}, {"source_code": "my @arr = (0, split / /, <>);\nmy $ans = 0;\nfor (split //, <>) {\n    $ans += $arr[$_];\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n@a = (0, split / /, <>);\nchomp($line = <>);\n$tb{int($_)}++ foreach (split //, $line);\n$ans+=$a[$_] * $tb{$_} foreach(keys %tb);\nsay $ans;"}, {"source_code": "\n@val = (0, split(/ /, <>));\n$ans = 0;\nforeach $i (split(//, <>)) {\n\t$ans += $val[$i];\n}\nprint \"$ans\\n\";\n"}, {"source_code": "use strict;\nmy @a = split(' ', <>);\nmy @b = split(//, <>);\nmy $ans = 0;\nsub kek{\n  my ($a, $b) = @_;\nfor(my $i = 0; $i < $#b; $i++){\n  #print $a[$b[$i] - 1], ' ';\n  $ans += $a[$b[$i] - 1];\n}\nprint $ans;\n}\nkek(\\@a, \\@b);\n"}, {"source_code": "#!/usr/bin/perl\n\nmy @cal = split / /, <>;\nmy $s = <>;\nchomp $s;\n\nprint eval join '+', map { $cal[$_ - 1] } (split //, $s);"}], "negative_code": [{"source_code": "use strict;\n#open STDIN, '<input.txt';\n#open STDOUT, '>output.txt';\nmy @a = split(' ', <>);\nmy @b = split(//, <>);\nmy $ans = 0;\nsub kek{\n  my ($a, $b) = @_;\nfor(my $i = 0; $i < $#b; $i++){\n  print $a[$b[$i] - 1], ' ';\n  $ans += $a[$b[$i] - 1];\n}\nprint $ans;\n}\nkek(\\@a, \\@b);\n"}], "src_uid": "db9065d975878227a749083f0036a169"}
{"source_code": "<>;\r\n\r\nprint m/^(.+)\\1$/ ? \"YES\\n\" : \"NO\\n\" while <>", "positive_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nmy ($tcase) = split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $tcase -- > 0 ){\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  if( length($s) % 2 == 1 ){\r\n    print \"No\\n\"; next;\r\n  }\r\n  if( substr($s,0,length($s)/2) eq substr($s,length($s)/2,length($s)/2) ){\r\n    print \"Yes\\n\";\r\n  } else {\r\n    print \"No\\n\";\r\n  }\r\n}\r\n"}, {"source_code": "<>;print m/^(.+)\\1$/?\"YES \":\"NO \"while<>"}, {"source_code": "<>;print m/^(.+)\\1$/?\"YES\\n\":\"NO\\n\"while<>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tprint m/^(.+)\\1$/ ? \"YES\" : \"NO\";\n\t\n\t\n\t\n\t}"}, {"source_code": "##!/usr/local/bin/perl \r\n\r\nuse strict;\r\nuse warnings;\r\n\r\n#use Data::Dumper qw(Dumper);\r\nuse feature qw(say);\r\n\r\n#print \"------------------------------------------------------------------------------\\n\";\r\n\r\n#open my $fh,'<','codef_1703_input.txt' or die();\r\n\r\nmy $lines = <STDIN>;\r\nmy @out;\r\n\r\nfor(my $i = 0; $i < $lines; $i++)\r\n{\r\n    my $temp = <STDIN>;\r\n    chomp($temp);\r\n    my $len = length($temp);\r\n    if(($len % 2))\r\n    {\r\n        push(@out,\"NO\");\r\n    }\r\n    elsif(substr($temp,0,$len/2) eq substr($temp,$len/2,$len/2))\r\n    {\r\n        push(@out,\"YES\");\r\n    }else\r\n    {\r\n        push(@out,\"NO\");\r\n    }\r\n}\r\nfor(my $i = 0; $i < $lines; $i++)\r\n{\r\n    say $out[$i];\r\n}\r\n\r\n\r\n#say(Dumper %hash);\r\n\r\n# print \"------------------------------------------------------------------------------\\n\";"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nmy ($tcase) = split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $tcase -- > 0 ){\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  if( length($s) % 2 == 1 ){\r\n    print \"No\\n\"; next;\r\n  }\r\n  print ( substr($s,0,length($s)/2) . \"\\n\" );\r\n}\r\n"}, {"source_code": "#!/usr/bin/perl\r\n\r\nmy ($tcase) = split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $tcase -- > 0 ){\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  my %x = ();\r\n  for(my $i=0;$i<length($s);$i++){\r\n    for(my $j=$i;$j<length($s);$j++){\r\n      my $ss = substr($s,$i,$j-$i+1);\r\n      $x{$ss}++;\r\n    }\r\n  }\r\n  my $res = 'No';\r\n\tforeach my $k (keys %x){\r\n    $res = 'Yes' if $x{$k}-0 > 1;\r\n\t}\r\n  print \"$res\\n\";\r\n}\r\n"}], "src_uid": "9640b7197bd7b8a59f29aecf104291e1"}
{"source_code": "#!/usr/bin/perl -wl\nuse strict;\n\nwhile(<>) {\n    @_ = reverse map { my @k = split ' ', <>; $k[1] } 1..$_;\n    chomp(my $k = <>);\n    1 while scalar(@_) > 0 and eval $k.'-'.pop @_ > 0;\n    print scalar(@_) + 1;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl -wl\n\nuse strict;\n\nwhile( <> ){\n    $_ = join ',', map { '-' x ( 1 + eval join '-', reverse split ' ', <> ) } 1 .. $_;\n    s/-*\\K-/;/g;\n    y/,//d;\n    chomp( my $k = <> );\n    substr $_, 0, $k - 1, '';\n    print scalar( () = /;/g );\n    }\n"}], "negative_code": [], "src_uid": "2545b6af730f99193041a8810b728cb3"}
{"source_code": "$/ = undef; $_ = <>; ($n, @p) = split;\n\nfor ($i = 0; $i < $n; $i++) {\n\t$c = 0;\n\twhile ($p[$i]) {\n\t\t$j = $p[$i] - 1;\n\t\t$c += 1;\n\t\t$p[$i] = 0;\n\t\t$i = $j;\n\t}\n\t$ans += $c * $c;\n\t($x, $y) = sort { $b <=> $a} $x, $y, $c;\n}\n\nprint $ans + 2 * $x * $y;\n", "positive_code": [{"source_code": "$_ = <>;\n\nmap $h{ ++ $i } = $_, split ' ', <>;\n\nfor( 1 .. $_ ){\n\tnext if ! $h{ $_ };\n\t$c = 0;\n\twhile( $h{ $_ } ){\n\t\t$c ++;\n\t\t$o = $_;\n\t\t$_ = $h{ $o };\n\t\tdelete $h{ $o };\n\t\t}\n\tpush @c, $c;\n\t}\n\n@c = sort { $a <=> $b } @c;\n\n@c > 1 and $c[ -2 ] += pop @c;\n\n$Z = 0;\n$Z += $_ ** 2 for @c;\n\nprint $Z"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\tmy $i = 0;\n\tmap { $h{ ++ $i } = $_ } @_;\n\tmy @c;\n\t\n\tfor my $key ( 1 .. @_ ){\n\t\tnext if not exists $h{ $key };\n\t\tmy $new = $key;\n\t\tmy $c = 0;\n\t\twhile( exists $h{ $new } ){\n\t\t\t$c ++;\n\t\t\tmy $old = $new;\n\t\t\t$new = $h{ $old };\n\t\t\tdelete $h{ $old };\n\t\t\t}\n\t\tpush @c, $c;\n\t\t}\n\t\n\t@c = ( sort { $a <=> $b } @c );\n\t\n\tif( @c >= 2 ){\n\t\tpush @c, ( pop @c ) + ( pop @c );\n\t\t}\n\t\n\tmy $sum = 0;\n\tmap { $sum += $_ ** 2 } @c;\n\t\n\tprint $sum;\n\t}"}], "negative_code": [{"source_code": "<>;\n\nmap $h{ ++ $i } = $_, split ' ', <>;\n\nfor( 1 .. $_ ){\n\tnext if ! $h{ $_ };\n\t$c = 0;\n\twhile( $h{ $_ } ){\n\t\t$c ++;\n\t\t$o = $_;\n\t\t$_ = $h{ $o };\n\t\tdelete $h{ $o };\n\t\t}\n\tpush @c, $c;\n\t}\n\n@c = sort { $a <=> $b } @c;\n\n@c > 1 and $c[ -2 ] += pop @c;\n\n$Z = 0;\n$Z += $_ ** 2 for @c;\n\nprint $Z"}], "src_uid": "ad9fd71025c5f91cece740ea95b0eb6f"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $t) = split;\n\t$_ = <>, chomp;\n\t$copy = $_;\n\ts/(.*)\\.//;\n\t$integer = $1;\n\n\tprint s/(4*)([5-9]).*// ? do {\n\t\t$_123 = $`;\n\t\t($_4_length = length $1) -= $t;\n\n\t\tif ( $1 and $_4_length >= 0 ){ $_45 = 4 x $_4_length . 5 }\n\t\tif ( $1 and $_4_length < 0 or $2 and ! $1 ){ (length $_123 ? $_123 : $integer) ++ }\n\t\t\"$integer.${_123}${_45}\" =~ s/\\.$//r\n\t} : $copy;\n\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $t) = split;\n\t$_ = <>, chomp;\n\t$c = $_;\n\ts/(.*)\\.//;\n\t$start = $1;\n\tprint s/(4*)([5-9]).*// ?  do {\n\t\t$left = $`;\n\t\t$len = length $1;\n\t\t$len += - $t;\n\t\t$rem = '';\n\t\tif ( $1 and $len >= 0 ){ $rem = 4 x $len . 5 }\n\t\tif ( $1 and $len < 0 ){ length $left ? $left ++ : $start ++ }\n\t\tif ( $2 and not $1 ){ length $left ? $left ++ : $start ++ }\n\t\t$ans = \"$start.$left$rem\";\n\t\t$ans =~ s/\\.$//;\n\t\t$ans;\n\t} : $c;\n\t\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $t) = split;\n\t$_ = <>, chomp;\n\t$c = $_;\n\ts/(.*)\\.//;\n\t$start = $1;\n\tprint s/(4*)([5-9]).*// ?  do {\n\t\t$left = $`;\n\t\t$len = length $1;\n\t\t$len += - $t;\n\t\t$rem = '';\n\t\tif ( $1 and $len >= 0 ){ $rem = 4 x $len . 5 }\n\t\tif ( $1 and $len < 0 ){ defined $left ? $left ++ : $start ++ }\n\t\tif ( $2 and not $1 ){ defined $left ? $left ++ : $start ++ }\n\t\t$ans = \"$start.$left$rem\";\n\t\t$ans =~ s/\\.$//;\n\t\t$ans;\n\t} : $c;\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $t) = split;\n\t$_ = <>, chomp;\n\t$c = $_;\n\ts/(.*)\\.//;\n\t$start = $1;\n\tprint s/(4*)([5-9]).*// ?  do {\n\t\t$left = $`;\n\t\t$len = length $1;\n\t\t$len += - $t;\n\t\t$rem = '';\n\t\tif ( $1 and $len >= 0 ){ $rem = 4 x $len . 5 }\n\t\tif ( $1 and $len < 0 ){ $left ? $left ++ : $start ++ }\n\t\tif ( $2 and not $1 ){ $left ? $left ++ : $start ++ }\n\t\t$ans = \"$start.$left$rem\";\n\t\t$ans =~ s/\\.$//;\n\t\t$ans;\n\t} : $c;\n\t\n\t}"}], "src_uid": "d563ce32596b54f48544a6085efe5cc5"}
{"source_code": "#!/usr/bin/perl \n\nuse warnings;\nuse strict;\n\nuse Data::Dumper;\n\nmy $keyboards = <>;\nmy $numbers = <>;\n\nmy @splitted = split(\" \", $numbers);\n\nmy $min;\nmy $max;\nforeach my $one (@splitted) {\n\tif (! defined $min || $min > $one) {\n\t      $min = $one;\n\t}\n\tif (! defined $max || $one > $max) {\n\t\t$max = $one;\n\t}\n}\n\t\nmy $result = $max - $min + 1 - $keyboards;\n\nprint \"$result\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = sort { $a <=> $b } split ' ', <>;\n\t\n#\tprint \"@_\";\n\t\n\tprint $_[ @_ - 1 ] - $_[ 0 ] - @_ + 1;\n\t}"}, {"source_code": "use v5.10;\n\nchomp($n = <STDIN>);\nchomp($piano = <STDIN>);\n@pianoList = split / /, $piano;\n@pianoList = sort {$a<=>$b} @pianoList;\nsay $pianoList[$#pianoList] - $pianoList[0] - $n + 1;"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = sort { $a <=> $b } split ' ', <>;\n\t\n\tprint \"@_\";\n\t\n\tprint $_[ @_ - 1 ] - $_[ 0 ] - @_ + 1;\n\t}"}], "src_uid": "6469ed9f2486b498c9ffeb8270391e3a"}
{"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    chomp;\n    $i=$j=0;\n    s/heavy/H/g;\n    s/metal/M/g;\n    s/[a-z]//g;\n    @m=split//;\n    foreach (@m){\n        /H/ and $i++;\n        /M/ and $j+=$i;\n        }\n    print \"$j\\n\";\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\nchomp ($_ = <>);\n$i = 0;\n$res = 0;\nfor ($i = 0; $i < length ($_) - 4; $i++) {\n    $block = substr $_, $i, 5;\n    \n    if ($block eq \"heavy\") {\n        $h++;\n        $i += 4;\n    } elsif ($block eq \"metal\") {\n        $res += $h;\n        $i += 4;\n    }\n}\n\nprint $res;\n    \n"}], "negative_code": [{"source_code": "#!/usr/bin/perl -pi\nfor ($i = 0; $i < length ($_); $i++) {\n    $block = substr $_, $i, 5;\n    \n    if ($block eq \"heavy\") {\n        $h++;\n        $i += 4;\n    } elsif ($block eq \"metal\") {\n        $res += $h;\n        $i += 4;\n    }\n}\n$_ = $res;\n    \n"}, {"source_code": "#!/usr/bin/perl\nchomp ($_ = <>);\n$_ =~ s/heavy/1/g;\n$_ =~ s/metal/0/g;\n\n$_ =~ s/[^10]//g;\n$i = ($_ =~ s/[10]/\\1/g);\nprint $i - 1;\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    chomp;\n    s/heavy/H/g;\n    s/metal/M/g;\n    s/[a-z]//g;\n    @m=split//;\n    foreach (@m){\n        /H/ and $i++;\n        /M/ and $j+=$i;\n        }\n    print \"$j\\n\";\n    $i=$j=0;\n}"}], "src_uid": "960e4c234666d2444b80d5966f1d285d"}
{"source_code": "<>;print/11.*00/?NO:YES,\"\\n\"while<>;", "positive_code": [{"source_code": "<>;print/11.*00/?NO:YES,\"\\n\"while<>;"}, {"source_code": "<>;print/11.*00/?NO:YES,\"\\n\"while<>;"}, {"source_code": "<>; print /11.*00/ ? \"NO\\n\" : \"YES\\n\" while <>;"}], "negative_code": [], "src_uid": "357dcc8fb7783d878cd2c4ed34eb437e"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $f = 0;\n\t\n\tmy @A;\n\tmy $last = -1;\n\t\n\tfor( @_ ){\n\t\tpush @A, $_ if $_ != $last;\n\t\t$last = $_;\n\t\t}\n\t\n\t@_ = @A;\n\t\n\tfor my $i ( 1 .. @_ - 2 ){\n\t\t$_[ $i - 1 ] > $_[ $i ] and $_[ $i ] < $_[ $i + 1 ] and $f = 1;\n\t\t}\n\t\n\tprint $f ? \"NO\" : \"YES\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>;\n\tmy $f = 0;\n\t\n\t0 while s/\\b(\\d+)\\b\\K \\1\\b//g;\n\t\n\tm/\n\t\t\\b(\\d+)[ ]\n\t\t(\\d+)[ ]\n\t\t(\\d+)\\b\n\t\t(?{ $f ||= $1 > $2 && $2 < $3 })\n\t\t(*F)\n\t\t/x;\n\t\n\tprint $f ? \"NO\" : \"YES\";\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\tmy $f = 0;\r\n\t\r\n\t0 while s/\\b(\\d+)\\b \\K\\1\\b//g;\r\n\t\r\n\tm/\r\n\t\t\\b(\\d+)[ ]\r\n\t\t(\\d+)[ ]\r\n\t\t(\\d+)\\b\r\n\t\t(?{ $f ||= $1 > $2 && $2 < $3 })\r\n\t\t(*F)\r\n\t\t/x;\r\n\t\r\n\tprint $f ? \"NO\" : \"YES\";\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $f = 0;\n\t\n\tfor my $i ( 1 .. @_ - 2 ){\n\t\t$_[ $i - 1 ] > $_[ $i ] and $_[ $i ] < $_[ $i + 1 ] and $f = 1;\n\t\t}\n\t\n\tprint $f ? \"NO\" : \"YES\";\n\t}"}], "src_uid": "c35d309dd6a9569ec298e7128aa3fc0e"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse re 'eval';\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nmy @ans;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m ) = split ' ', <>;\n\t\n\t@_ = ();\n\tmy %h;\n\t\n\tfor my $i ( 1 .. $n ){\n\t\t$_ = <>;\n\t\t\n\t#\tm/\n\t#\t\t...?\n\t#\t\t(?{ $h{ $& } = [ $-[0] + 1, $+[0], $i ] })\n\t#\t\t(*FAIL)\n\t#\t\t/x;\n\t\t\n\t\tfor my $j ( 0 .. $m - 2 ){\n\t\t\t$h{ substr $_, $j, 2 } = [ $j + 1, $j + 2, $i ];\n\t\t\t}\n\t\t\n\t\tfor my $j ( 0 .. $m - 3 ){\n\t\t\t$h{ substr $_, $j, 3 } = [ $j + 1, $j + 3, $i ];\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"$_ -> [@{ $h{ $_ } }]\" for sort keys %h;\n\t\n\t$_ = <>, chomp;\n\t\n\tmy $re = join '|', sort keys %h;\n\t\n\tm/^\n\t\t(?:\n\t\t($re)(?{ push @_, $1 })|\n\t\t(?{ pop @_ })(*FAIL)\n\t\t)+\n\t\t$\n\t\t(?{ push @_, $1 })\n\t\t/x ?\n\t\tdo { push @ans, $_ for 0 + @_, map \"@{ $h{ $_ } }\", @_ }\n\t\t:\n\t\tdo { push @ans, -1 };\n\t}\n\nprint join \"\\n\", @ans,", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse re 'eval';\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tfor my $i ( 1 .. $n ){\n\t\t$_ = <>;\n\t\t\n\t\tm!\n\t\t\t...?\n\t\t\t(?{ $h{ $& } //= [ $-[0] + 1, $+[0], $i ] })\n\t\t\t(*FAIL)\n\t\t\t!x;\n\t\t}\n\t\n\t$_ = <>, chomp;\n\t\n\tmy $re = join '|', sort keys %h;\n\t\n\t@_ = ();\n\t\n\tm/^\n\t\t(?:\n\t\t($re)(?{ push @_, $1 })|\n\t\t(?{ pop @_ })(*FAIL)\n\t\t)+\n\t\t$\n\t\t(?{ push @_, $1 })\n\t\t/x ?\n\t\tdo { print for 0 + @_, map \"@{ $h{ $_ } }\", @_ }\n\t\t:\n\t\tdo { print -1 };\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\nuse re 'eval';\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split ' ', <>;\n\t\n\tmy %h;\n\t\n\tfor my $i ( 1 .. $n ){\n\t\t$_ = <>;\n\t\t\n\t\tfor my $k ( 2 .. 3 ){\n\t\t\tfor my $j ( 0 .. $m - $k ){\n\t\t\t\t$h{ substr $_, $j, $k } //= [ $j + 1, $j + $k, $i ];\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t### 2-3x slower, gets TLE:\n\t#\n\t#\tm/\n\t#\t\t...?\n\t#\t\t(?{ $h{ $& } //= [ $-[0] + 1, $+[0], $i ] })\n\t#\t\t(*FAIL)\n\t#\t\t/x;\n\t\t\n\t\t}\n\t\n\t$_ = <>, chomp;\n\t\n\tmy $re = join '|', sort keys %h;\n\t\n\t@_ = ();\n\t\n\tm/^\n\t\t(?:\n\t\t($re)(?{ push @_, $1 })|\n\t\t(?{ pop @_ })(*FAIL)\n\t\t)+\n\t\t$\n\t\t(?{ push @_, $1 })\n\t\t/x ?\n\t\tdo { print for 0 + @_, map \"@{ $h{ $_ } }\", @_ }\n\t\t:\n\t\tdo { print -1 };\n\t}"}], "negative_code": [], "src_uid": "a4f4ad94387b16e8760e7c7fd45b93b3"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\npush @a, [split //, <>] foreach (0 .. $n-1);\n$ch = $a[0][0];\n$a[$_][$_] ne $ch and say \"NO\" and exit foreach(0 .. $n-1);\n$a[$_][$n-1-$_] ne $ch and say \"NO\" and exit foreach(0 .. $n-1);\n$a[1][0] eq $ch and say \"NO\" and exit;\n$ch = $a[1][0];\nforeach $i (0 .. $n-1) {\n\tforeach $j (0 .. $n-1) {\n\t\t($j==$i || $j==$n-1-$i) and next;\n\t\t$a[$i][$j] ne $ch and say \"NO\" and exit;\n\t}\n}\nsay \"YES\";", "positive_code": [{"source_code": "$n=<>; @_=<>;\n($L,$M)=$_[0]=~/(.)(.)/;\n$L ne $M or $f=1;\nfor $i(1..$n){\n\t$j= $i > $n-$i+1 ? $n-$i : $i-1 ;\n\t$_= $M x $j . $L . $M x ($n-$j*2-2) . $L . $M x $j ;\n\ts/$L+/$L/;\n\t$_[$i-1]=~/$_/ or $f=1;\n\t}\nprint $f? \"NO\" : \"YES\""}, {"source_code": "sub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n\nwhile(<>){\n\t\n\tchomp;\n\t$n=$_;\n\tchomp($first_line=<>);\n\t$first_line =~ /(.)(.)/;\n\t$L1=$1;\n\t$L2=$2;\n\t\n\t$f=0;\n\t@_=($first_line);\n\tfor $i(1..$n-1){\n\t\t$_=<>;\n\t\tchomp;\n\t\tpush @_, $_;\n\t\t\n\t\t}\n\t\t\n\tfor $i(1..$n){\n\t\t$j= min ($i, $n-$i+1);\n\t\t$m=($L2 x ($j-1) .  $L1 .  $L2 x ($n-$j*2)  .  $L1  . $L2 x ($j-1));\n\t\t$m=~s/($L1){2}/$1/;\n\t\t$_[$i-1] eq $m or $f=1;\n#\t\tprint $m;\n\t#\tprint \" \";\n\t#\tprint \"$_[$i-1]\\n\"\n\t\t}\n\t\n\tprint $f? \"NO\\n\" : \"YES\\n\" ;\n\t\n\t\n\t\n\t}\n\t\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\npush @a, [split //, <>] foreach (0 .. $n-1);\n$ch = $a[0][0];\n$a[$_][$_] ne $ch and say \"NO\" and exit foreach(0 .. $n-1);\n$a[$_][$n-1-$_] ne $ch and say \"NO\" and exit foreach(0 .. $n-1);\n$ch = $a[1][0];\nforeach $i (0 .. $n-1) {\n\tforeach $j (0 .. $n-1) {\n\t\t($j==$i || $j==$n-1-$i) and next;\n\t\t$a[$i][$j] ne $ch and say \"NO\" and exit;\n\t}\n}\nsay \"YES\";"}, {"source_code": "$n=<>; @_=<>;\n($L,$M)=$_[0]=~/(.)(.)/;\nfor $i(1..$n){\n\t$j= $i > $n-$i+1 ? $n-$i : $i-1 ;\n\t$_= $M x $j . $L . $M x ($n-$j*2-2) . $L . $M x $j ;\n\ts/$L+/$L/;\n\t$_[$i-1]=~/$_/ or $f=1;\n\t}\nprint $f? \"NO\" : \"YES\""}], "src_uid": "02a9081aed29ea92aae13950a6d48325"}
{"source_code": "my $n   = <>;\nmy @arr = split \" \", <>;\nmy $l   = scalar @arr - 1;\nmy $ans = 0;\n@arr = sort @arr;\nwhile (scalar @arr > 1) {\n    # if ($arr[-1] >= 4) {\n    #     $ans += int(($arr[-1] + 3) / 4);\n    #     pop @arr;\n    # }\n    # else {\n        if ($arr[-1] + $arr[0] <= 4) {\n            push @arr, shift(@arr) + pop @arr;\n        }\n        else {\n            $ans += int(($arr[-1] +3) / 4);\n            pop @arr;\n        }\n    # }\n}\n$ans+= int(($arr[0]+3)/4) if scalar @arr;\nprint $ans . \"\\n\";", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\nuse integer;\n\nmy %val;\nchomp(my $i = <>);\nchomp(my $line = <>);\n$val{$_} = 0 for 1..3;\n$val{$_}++ for split / /, $line;\n\nmy $cnt = $val{4};\nif ($val{1} > $val{3}) {\n\t$val{1} -= $val{3};\n\t$cnt += $val{3};\n\t$val{3} = 0;\n}\nelse {\n\t$cnt += $val{1};\n\t$val{3} -= $val{1};\n\t$cnt += $val{3};\n\t$val{1} = 0;\n}\n$cnt += $val{2} / 2;\n$val{2} = $val{2} % 2;\nif ($val{2}) {\n\t$val{1} -= 2;\n\t$cnt++;\n}\nif ($val{1} > 0) {\n\t$cnt += $val{1} / 4;\n\t$cnt++ if $val{1} % 4;\n}\nprint $cnt;\n"}, {"source_code": "my $n   = <>;\nmy @arr = split \" \", <>;\nmy $l   = scalar @arr - 1;\nmy $ans = 0;\n@arr = sort @arr;\nwhile (scalar @arr > 1) {\n    if ($arr[-1] >= 4) {\n        $ans += int(($arr[-1] + 3) / 4);\n        # print \"+ $arr[-1]\\n\";\n        pop @arr;\n    }\n    else {\n        if ($arr[-1] + $arr[0] <= 4) {\n            # print \"- $arr[-1] $arr[0]\\n\";\n            push @arr, shift(@arr) + pop @arr;\n        }\n        else {\n            $ans += int(($arr[-1] +3) / 4);\n            # print \"* $arr[-1]\\n\";\n            pop @arr;\n        }\n    }\n    # print scalar @arr . \"\\n\";\n}\n$ans+= int(($arr[0]+3)/4) if scalar @arr;\nprint $ans . \"\\n\";"}, {"source_code": "use strict;\nuse List::Util qw(max);\n\nmy $n = <>;\nmy @a;\n\n++$a[$_] for(split / /, <>);\n\nmy $res = $a[4] + $a[3] + int(($a[2] + 1) / 2);\nmy $x = $a[1] - $a[3] - 2 * ($a[2] % 2);\n$res += int(($x + 3) / 4) if ($x > 0);\n\nprint $res;"}, {"source_code": "#!/usr/bin/perl\n# 158 B\n\nuse warnings;\nuse strict;\nuse POSIX;\n\nmy $n = <STDIN>;\nmy @groups = split(\" \", <STDIN>);\nmy ($one, $two, $three, $four);\nmy $ret = 0;\n\nforeach(@groups){\n    if($_==1){\n        $one++;\n    }elsif($_==2){\n        $two++;\n    }elsif($_==3){\n        $three++;\n    }else{\n        $four++;\n    }\n}\n\n# groups of 4\n$ret += $four;\n$four= 0;\n\n# groups of 3\nif($three<=$one){\n    $ret += $three;\n    $one -= $three;\n    $three=0;\n} else {\n    $ret += $one;\n    $three -= $one;\n    $ret += $three;\n    $three = 0;\n    $one = 0;\n}\n\n# groups of 2\nmy $div = floor($two/2);\nmy $rem = $two % 2;\n\n$ret += $div;\n$two = $rem; #at this point $two will be 0 or 1\n\nif($two == 1){\n    $one -= 2;\n    $ret++;\n}\n\n$ret += ceil($one/4);\nprint $ret;"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse integer;\n\nchomp($n = <>);\nchomp;\n@c = (0) x 5;\n$c[$_]++ foreach (split / /, <>);\n$ans = $c[4];\n$ans += $c[3];\n$c[1] -= $c[3]>$c[1] ? $c[1]:$c[3];\n$ans += ($c[2] + 1) / 2;\n$c[1] -= $c[2]%2*2>$c[1] ? $c[1]:$c[2]%2*2;\n$ans += ($c[1] + 3) / 4;\nprint $ans;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp($n);\n\ndie('n to big') unless $n >= 1 && $n <= 100000;\n\nmy $line = <>;\nchomp($line);\nmy @in = split(' ', $line);\n\nmy $result = 0;\n\n# calculate how many groups of each size in stop one. so for example:\n# 1 2 4 3 3 goes into\n# 1: 1\n# 2: 1\n# 3: 2\n# 4: 1\n\n#remove 4 from equation since its a corner case\n#possible compbis per number:\n# 3: only go with 1...\n# 2: can go with 2 and 1\n# 1: can go with 3, 2, 1\n#we see higher number is more restrictive. therefor lest start to solve backwards\n# try to generalisation:\n# x: 4-x.... test. 3: 4-3=1 OK. 2: 4-2=2 OK. 1\n\n\n\nmy %groups;\nfor (@in) {\n    die('1-4...') unless $_ >= 1 && $_ <= 4;\n    $groups{$_}++;\n}\nmy $taxies = 0;\n\nwhile (grep { $_ >= 1 } values %groups) {\n    if ($groups{4}) {\n        $groups{4}--;\n        $taxies++;\n    } elsif($groups{3}) {\n        $groups{3}--;\n        if ($groups{1}) {\n            $groups{1}--;\n        }\n        $taxies++;\n    } elsif ($groups{2}) {\n        $groups{2}--;\n        if ($groups{2}) {\n            $groups{2}--;\n        } elsif ($groups{1} >= 2) {\n            $groups{1} -=2;\n        } elsif ($groups{1} >= 1) {\n            $groups{1}--;\n        }\n        $taxies++;\n    } elsif ($groups{1}) {\n        $groups{1}--;\n        if ($groups{1} >= 3) {\n            $groups{1} -= 3;\n        } elsif($groups{1} >= 2) {\n            $groups{1} -= 2;\n        } elsif($groups{1} >= 1) {\n            $groups{1}--;\n        }\n        $taxies++;\n    } else {\n        die('invalid input error...');\n    }\n\n}\n\n\nprint $taxies;\n"}, {"source_code": "$DEBUG = 0;\nchomp($n = <STDIN>);\nchomp($line = <STDIN>);\n\n%g = {};\nmap { $g{$_} = 0; } 1..4;\nforeach(split /\\s/, $line) {\n\t$g{$_}++;\n}\n$taxis = $g{4};\nprint \"$taxis groups of 4\\n\" if $DEBUG;\nif($g{3} <= $g{1}) {\n\tprint $g{3}.\" groups of 3+1\\n\" if $DEBUG;\n\t$taxis += $g{3};\n\t$g{1} -= $g{3};\n\t$g{3} = 0;\n} else {\n\t$taxis += $g{1};\n\tprint $g{1}.\" groups of 3+1\\n\" if $DEBUG;\n\t$g{3} -= $g{1};\n\t$g{1} = 0;\n}\nif($g{3} > 0) { $taxis += $g{3}; print $g{3}.\" groups of 3\\n\" if $DEBUG; }\nwhile($g{2} > 1) {\n\t$taxis++;\n\t$g{2} -= 2;\n\tprint \"A group of 2+2\\n\" if $DEBUG;\n}\nif($g{2}>0) {\n\t$taxis++;\n\t$g{1} -= 2;\n\tprint \"A group of 2+1+1, \".$g{1}.\" singles left\\n\" if $DEBUG;\n}\nwhile($g{1}>0) {\n\t$taxis++;\n\t$g{1} -= 4;\n\tprint \"A group of 4 singles\\n\" if $DEBUG;\n}\nprint \"$taxis\\n\";"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @s = split ' ', <>;\nmy %cnt;\nfor my $x (@s){\n\t$cnt{$x}++;\n}\nmy $res = $cnt{4};\n\nwhile(1) {\n\tif ($cnt{3}) {\n\t\t$res++;\n\t\t$cnt{3}--;\n\t\t$cnt{1}-- if $cnt{1};\n\t\tnext;\n\t}\n\n\tif ($cnt{2}) {\n\t\t$res++;\n\t\t$cnt{2}--;\n\t\tif ($cnt{2}) {\n\t\t\t$cnt{2}--;\n\t\t} else {\n\t\t\t$cnt{1}-- if $cnt{1};\n\t\t\t$cnt{1}-- if $cnt{1};\n\t\t}\n\t\tnext;\n\t}\n\n\tif ($cnt{1}) {\n\t\t$res++;\n\t\t$cnt{1}--;\n\t\t$cnt{1}-- if $cnt{1};\n\t\t$cnt{1}-- if $cnt{1};\n\t\t$cnt{1}-- if $cnt{1};\n\t\tnext;\t\t\t\t\n\t}\t\n\n\tlast;\n}\n\nprint \"$res\\n\";\n"}, {"source_code": "$\\=\"\\n\";\n$n=<STDIN>;\n\n$/=\" \";\nmy $cabs=0;\nmy @passGroups=(0,0,0,0,0);\n\nfor ($i=1;$i<$n;$i++){\n    $passGroups[<STDIN>]+=1;\n}\n$/=\"\\n\";\n$passGroups[<STDIN>]+=1;\n#print \"\\n\", @passGroups;\n\n#print \"1) \".$cubs;\n\n#print \"        passGroups[1]= $passGroups[1]\";\n#print \"        passGroups[2]= $passGroups[2]\";\n#print \"        passGroups[3]= $passGroups[3]\";\n#print \"        passGroups[4]= $passGroups[4]\";\n\n$cubs+=$passGroups[4];\n#print \"12) \".$cubs;\n#print \"        passGroups[1]= $passGroups[1]\";\n#print \"        passGroups[2]= $passGroups[2]\";\n#print \"        passGroups[3]= $passGroups[3]\";\n#print \"        passGroups[4]= $passGroups[4]\";\n\nif ($passGroups[1]<=$passGroups[3]){\n    $cubs+=$passGroups[3];\n    $passGroups[1]=0;\n}\n\n\nif ($passGroups[1]>$passGroups[3]){\n    $passGroups[1]-=$passGroups[3];\n    $cubs+=$passGroups[3];\n}\n\nif ($passGroups[2]%2!=0){\n    $cubs+=1;\n    $passGroups[2]-=1;\n    if ($passGroups[1]>1){\n        $passGroups[1]-=2;\n    }\n    if ($passGroups[1]==1){\n        $passGroups[1]-=1;\n    }\n    \n}\n    $cubs+=$passGroups[2]/2;\nif ($passGroups[1]%4!=0){\n    $cubs+=int($passGroups[1]/4) +1;\n}else{\n    $cubs+=int($passGroups[1]/4);\n}\n\n\nprint $cubs;\n\n\n"}, {"source_code": "$\\=\"\\n\";\n$n=<STDIN>;\nmy $cabs=0;\nmy @passGroups=(0,0,0,0,0);\n\n@passs=split(\" \",<STDIN>);\n\nforeach $i (@passs){\n    $passGroups[$i]+=1;\n    #print $i;\n}\n\n$cubs+=$passGroups[4];\n\nif ($passGroups[1]<=$passGroups[3]){\n    $cubs+=$passGroups[3];\n    $passGroups[1]=0;\n}\n\n\nif ($passGroups[1]>$passGroups[3]){\n    $passGroups[1]-=$passGroups[3];\n    $cubs+=$passGroups[3];\n}\n\nif ($passGroups[2]%2!=0){\n    $cubs+=1;\n    $passGroups[2]-=1;\n    if ($passGroups[1]>1){\n        $passGroups[1]-=2;\n    }\n    if ($passGroups[1]==1){\n        $passGroups[1]-=1;\n    }\n    \n}\n    $cubs+=$passGroups[2]/2;\nif ($passGroups[1]%4!=0){\n    $cubs+=int($passGroups[1]/4) +1;\n}else{\n    $cubs+=int($passGroups[1]/4);\n}\n\n\nprint $cubs;\n\n\n"}, {"source_code": "<STDIN>; @_= sort {$b <=> $a} (split \" \", <STDIN>); my $res = 0; my $sym = 0; for(@_){ if($_ == 4){ $res += 1; }elsif($_ == 3) {  if( $_[-1] == 1 ){ pop @_ } $res += 1;  }else{ $sym += $_;  } } $sym = $sym/4; print $res + ($sym == int($sym) ? $sym : int($sym)+1), \"\\n\";"}, {"source_code": "$n = <>;\n@a = split' ', <>;\n$one = 0; $two = 0; $three = 0; $ans = 0;\nfor (my $i = 0; $i < $n; ++$i) {\n    if ($a[$i] == 4) { ++$ans; }\n    if ($a[$i] == 3) { ++$three; }\n    if ($a[$i] == 2) { ++$two; }\n    if ($a[$i] == 1) { ++$one; }\n}\nif ($three <= $one) { \n    $one -= $three;\n    $ans += $three;\n}\nelse {\n    $ans += $one;\n    $three -= $one;\n    $ans += $three;\n    $one = 0;\n}\n$ans += int ($two / 2);\n$two = $two % 2;\n\nif ($two == 1) {\n    $one -= 2;\n    ++$ans;\n}\n\n$ans += int (($one + 3) / 4);\nprint $ans;"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n@groups = split / +/, <STDIN>;\n\n@zlicz = (0, 0, 0, 0, 0);\n\nfor($i=0;$i<$n;$i++)\n{\n\n  @zlicz[ @groups[$i] ]++;\n\n}\n\n$wynik = @zlicz[4];\n@zlicz[4] = 0;\n\nif( @zlicz[3] != 0 )\n{\n\n  if( @zlicz[3] > @zlicz[1] )\n  {\n\n    $m = @zlicz[1];\n\n  }\n  else\n  {\n\n    $m = @zlicz[3];\n\n  }\n\n  $wynik += $m;\n  @zlicz[1] -= $m;\n  @zlicz[3] -= $m;\n\n  $wynik += @zlicz[3];\n  @zlicz[3] = 0;\n\n}\n\nif( @zlicz[2] > int(@zlicz[1]/2) )\n{\n\n  $m = int(@zlicz[1]/2);\n\n}\nelse\n{\n\n  $m = @zlicz[2];\n\n}\n\n$wynik += $m;\n@zlicz[1] -= $m * 2;\n@zlicz[2] -= $m;\n\n$wynik += int( @zlicz[2]/2 );\n@zlicz[2] -= int( @zlicz[2]/2 ) * 2;\n\nif( @zlicz[2] != 0 )\n{\n\n  if( @zlicz[1] != 0 )\n  {\n\n    $wynik++;\n\n    @zlicz[2] = 0;\n    @zlicz[1] -= 2;\n\n    if( @zlicz[1] < 0 )\n    {\n\n      @zlicz[1] = 0;\n\n    }\n\n  }\n\n  $wynik += @zlicz[2];\n  @zlicz[2] = 0;\n\n}\n\n$wynik += int( @zlicz[1]/4 );\n@zlicz[1] -= int( @zlicz[1]/4 ) * 4;\n\nif( @zlicz[1] != 0 )\n{\n\n  $wynik++;\n\n}\n\nprint $wynik;\n"}, {"source_code": "#!/usr/bin/perl\nuse strict; use warnings;\n\nsub ceil { my $j = $_[0]; my $i = int $j; $i < $j ? $i + 1 : $i }\n\nmy ($taxi, $one, $two, $three) = (0, 0, 0, 0); <STDIN>;\nforeach (split ' ', <STDIN>)\n{ if ($_ == 1) { if ($three) { --$three } else { ++$one; next } }\n  elsif ($_ == 2) { if ($two) { --$two } else { ++$two; next } }\n  elsif ($_ == 3) { if ($one) { --$one } else { ++$three; next } }\n  ++$taxi }\nif ($two) { $one -= $one > 1 ? 2 : $one; ++$taxi }\nprintf \"%d\\n\", $taxi + $three + ceil $one / 4\n"}, {"source_code": "#!/usr/bin/perl\nuse strict; use warnings;\n\nsub ceil { my $j = $_[0]; my $i = int $j; $i < $j ? $i + 1 : $i }\n\nsub input\n{ <STDIN>; $_ = <STDIN>; s/\\s//g; my ($n, $m, @a) = length;\n  foreach my $i (1..4)\n  { s/$i+//g; $m = length; push @a, $n - $m; $n = $m }\n  @a }\n\nmy ($one, $two, $three, $four) = input;\n$one -= $one < $three ? $one : $three;\nif ($two % 2) { $one -= $one < 2 ? $one : 2; ++$two }\nprintf \"%d\\n\", $two / 2 + $three + $four + ceil $one / 4\n\n"}, {"source_code": "<>;\n$_=<>;\nchomp;\ns/(\\d+)/$&==4?($f++):($&==3?($t++):($&==2?($w++):($o++)))/eg;\n#print\"$f $t $w $o\";\n\n$ats+=$f;\n\n$ats+=$t; $o-=$t; $o<1 and $o=0;\n\n$ww = ($w - $w%2) / 2; $w %= 2;\n$ats+=$ww;\n\n$oooo = ($o - $o%4) / 4; $o %= 4;\n$ats+=$oooo;\n\n$wo=$w*2+$o;\n$wo>4?($v=2):($wo?($v=1):($v=0));\n$ats+=$v;\n\nprint$ats"}, {"source_code": "use integer;\n\n<>;\n$_=<>;\n@_=(0)x 5;\n$_[$&]++ while /\\d+/g;\n\n($f,$t,$w,$o) = reverse @_;\n\n$ats += $f;\n$ats += $t; $o-=$t; $o<1 and $o=0;\n\n$ats += $w / 2; $w %= 2;\n$ats += $o / 4; $o %= 4;\n\n$wo = $w*2 + $o;\n$ats += --$wo >> 2 <=> 0;\n\nprint $ats + 1"}, {"source_code": "use integer;\n\n<>;\n$_=<>;\n@_=(0)x 5;\n$_[$1]++ while /(\\d)/g;\n\n($f,$t,$w,$o) = reverse @_;\n\n$ats += $f;\n$ats += $t; $o-=$t; $o<1 and $o=0;\n\n$ats += $w / 2; $w %= 2;\n$ats += $o / 4; $o %= 4;\n\n$wo = $w*2 + $o;\n$ats += --$wo >> 2 <=> 0;\n\nprint $ats + 1"}, {"source_code": "$n=<>;\n@l=split(' ',<>);\n$a=0;$b=0;$c=0;$d=0;\nforeach(@l)\n{\nif($_==1){$a+=1;}\nif($_==2){$b+=1;}\nif($_==3){$c+=1;}\nif($_==4){$d+=1;}\n}\n$ans=0;\nif($b%2==0){$ans+=$b/2;$b=0;}\nelse{$ans+=int($b/2);$b=1;}\nif($a>$c){$ans+=$c;$a-=$c;if($b>0){$a-=2;$ans+=1;}}\nelse{$ans+=$c+$b;$a=0;$b=0;}\nif($a>0){$a+=3;$ans+=int($a/4);}\n$ans+=$d;\nprint \"$ans\\n\";\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\nuse integer;\n\nchomp(my $i = <>);\nchomp(my $line = <>);\nmy $g = ($line =~ s/ //gr);\nmy $cnt = ($g =~ tr/4/4/);\nmy $threes = ($g =~ tr/3/3/);\nmy $twos = ($g =~ tr/2/2/);\nmy $ones = ($g =~ tr/1/1/);\n$cnt += $threes;\n$ones -= $threes;\n$cnt += $ones if $ones > 0;\n$cnt += $twos / 2;\n$cnt++ if $twos % 2;\nprint $cnt;\n"}, {"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\nuse integer;\n\nchomp(my $i = <>);\nchomp(my $line = <>);\nmy $g = ($line =~ s/ //gr);\nmy $cnt = ($g =~ tr/4/4/);\nmy $threes = ($g =~ tr/3/3/);\nmy $twos = ($g =~ tr/2/2/);\nmy $ones = ($g =~ tr/1/1/);\n$cnt += $threes;\n$ones -= $threes;\n$ones = 0 if $ones < 0;\n$cnt += $twos / 2;\n$cnt++ if $twos % 2;\n$cnt += $ones / 4;\n$cnt++ if $ones % 4;\nprint $cnt;\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse integer;\n\nchomp($n = <>);\nchomp;\n@c = (0) x 5;\n$c[$_]++ foreach (split / /, <>);\n$ans = $c[4];\n$ans += $c[3];\n$c[1] -= $c[3]>$c[1] ? $c[1]:$c[3];\n$ans += ($c[2] + 1) / 2;\n$c[1] -= $c[2]%2>$c[1] ? $c[1]:$c[2]%2;\n$ans += ($c[1] + 3) / 4;\nprint $ans;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp($n);\n\ndie('n to big') unless $n >= 1 && $n <= 10000;\n\nmy $line = <>;\nchomp($line);\nmy @in = split(' ', $line);\n\nmy $result = 0;\n\n# calculate how many groups of each size in stop one. so for example:\n# 1 2 4 3 3 goes into\n# 1: 1\n# 2: 1\n# 3: 2\n# 4: 1\n\n#remove 4 from equation since its a corner case\n#possible compbis per number:\n# 3: only go with 1...\n# 2: can go with 2 and 1\n# 1: can go with 3, 2, 1\n#we see higher number is more restrictive. therefor lest start to solve backwards\n# try to generalisation:\n# x: 4-x.... test. 3: 4-3=1 OK. 2: 4-2=2 OK. 1\n\n\n\nmy %groups;\nfor (@in) {\n    die('1-4...') unless $_ >= 1 && $_ <= 4;\n    $groups{$_}++;\n}\n# I want to loop: 4 3 3 2 1\n\n\nfor (my $i = 4; $i >= 1; $i--) {\n    while ($groups{$i} >= 1) {\n        my $taxi_occupany = $i;\n        $groups{$i}--; #remove self from groups\n        my $max_friend_group = 4 - $taxi_occupany;;\n\n        for (my $j = $max_friend_group; $j >= 1; $j--) {\n            if ($groups{$j} > 0) {\n                $groups{$j}--;\n                $taxi_occupany += $j;\n            }\n            last if $taxi_occupany >= 4;\n        }\n        $result++;\n    }\n}\n\nprint $result;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @s = split ' ', <>;\nmy %cnt;\nfor my $x (@s){\n\t$cnt{$x}++;\n}\nmy $res = $cnt{4};\n\nwhile(1) {\n\tif ($cnt{3}) {\n\t\t$res++;\n\t\t$cnt{3}--;\n\t\t$cnt{1}-- if $cnt{1};\n\t\tnext;\n\t}\n\n\tif ($cnt{2}) {\n\t\t$res++;\n\t\t$cnt{2}--;\n\t\tif ($cnt{2}) {\n\t\t\t$cnt{2}--;\n\t\t} else {\n\t\t\t$cnt{1}-- if $cnt{1};\n\t\t\t$cnt{1}-- if $cnt{1};\n\t\t}\n\t\tnext;\n\t}\n\n\tif ($cnt{1}) {\n\t\t$res++;\n\t\t$cnt{1}--;\n\t\t$cnt{1}-- if $cnt{1};\n\t\t$cnt{1}-- if $cnt{1};\n\t\t$cnt{1}-- if $cnt{1};\t\t\t\t\n\t}\t\n\n\tlast;\n}\n\nprint \"$res\\n\";\n"}, {"source_code": "$\\=\"\\n\";\n$n=<STDIN>;\n\n$/=\" \";\nmy $cabs=0;\nmy @passGroups=(0,0,0,0,0);\n\nfor ($i=1;$i<$n;$i++){\n    $passGroups[<STDIN>]+=1;\n}\n$/=\"\\n\";\n$passGroups[<STDIN>]+=1;\n\n\n\n\n$cubs+=$passGroups[4];\n\nif ($passGroups[1]<=$passGroups[3]){\n    $cubs+=$passGroups[3];\n    $passGroups[1]=0;\n}\n\n\n\nif ($passGroups[1]>$passGroups[3]){\n    $passGroups[1]-=$passGroups[3];\n    $cubs+=$passGroups[3];\n}\n\nif ($passGroups[2]%2!=0){\n    $cubs+=1;\n    $passGroups[2]-=1;\n    if ($passGroups[1]>1){\n        $passGroups[1]-=2;\n    }\n}\n    \n    $cubs+=$passGroups[2]/2;\n\nif ($passGroups[1]%4!=0){\n    $cubs+=int($passGroups[1]/4) +1;\n}else{\n    $cubs+=int($passGroups[1]/4);\n}\n\n\n\n\nprint $cubs;\n\n\n"}, {"source_code": "$n = <>;\n@a = split' ', <>;\n$one = 0; $two = 0; $three = 0; $ans = 0;\nfor (my $i = 0; $i < $n; ++$i) {\n    if ($a[$i] == 4) { ++$ans; }\n    if ($a[$i] == 3) { ++$three; }\n    if ($a[$i] == 2) { ++$two; }\n    if ($a[$i] == 1) { ++$one; }\n}\n$ans += $three;\nif ($three < $one) { $one -= $three; }\nelse { $one = 0; }\n\nif ($two % 2 == 1) { $ans += ($two - 1) / 2; }\nelse { $ans += $two / 2; }\n\nif ($two % 2 == 1) {\n    ++$ans;\n    $one -= 2;\n}\nif ($one > 0) {\n    if ($one % 2 != 0) { $ans += ($one + 3) / 4; }\n    else { $ans += $one / 4; }\n}\nprint $ans;"}, {"source_code": "$n = <>;\n@a = split' ', <>;\n$one = 0; $two = 0; $three = 0; $ans = 0;\nfor (my $i = 0; $i < $n; ++$i) {\n    if ($a[$i] == 4) { ++$ans; }\n    if ($a[$i] == 3) { ++$three; }\n    if ($a[$i] == 2) { ++$two; }\n    if ($a[$i] == 1) { ++$one; }\n}\n$ans += $three;\nif ($three < $one) { $one -= $three; }\nelse { $one = 0; }\n\nif ($two % 2 == 1) { $ans += ($two - 1) / 2; }\nelse { $ans += $two / 2; }\n\nif ($two % 2 == 1) {\n    ++$ans;\n    $one -= 2;\n}\nif ($one > 4) {\n    if ($one % 2 != 0) { $ans += int (($one + 3) / 4); }\n    else { $ans += $one / 4; }\n}\nelse { if ($one > 0) {++$ans;} }\nprint $ans;"}, {"source_code": "$n = <>;\n@a = split' ', <>;\n$one = 0; $two = 0; $three = 0; $ans = 0;\nfor (my $i = 0; $i < $n; ++$i) {\n    if ($a[$i] == 4) { ++$ans; }\n    if ($a[$i] == 3) { ++$three; }\n    if ($a[$i] == 2) { ++$two; }\n    if ($a[$i] == 1) { ++$one; }\n}\n$ans += $three;\nif ($three < $one) { $one -= $three; }\nelse { $one = 0; }\n\nif ($two % 2 == 1) { $ans += ($two - 1) / 2; }\nelse { $ans += $two / 2; }\n\nif ($two % 2 == 1) {\n    ++$ans;\n    $one -= 2;\n}\nif ($one > 4) {\n    if ($one % 2 != 0) { $ans += int (($one + 3) / 4); }\n    else { $ans += $one / 4; }\n}\nelse { ++$ans; }\nprint $ans;"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n@groups = split / +/, <STDIN>;\n\n@zlicz = (0, 0, 0, 0, 0);\n\nfor($i=0;$i<$n;$i++)\n{\n\n  @zlicz[ @groups[$i] ]++;\n\n}\n\n$wynik = @zlicz[4];\n@zlicz[4] = 0;\n\nif( @zlicz[3] > @zlicz[1] )\n{\n\n  $m = @zlicz[1];\n\n}\nelse\n{\n\n  $m = @zlicz[3];\n\n}\n\n$wynik += $m;\n@zlicz[1] -= $m;\n@zlicz[3] -= $m;\n\n$wynik += @zlicz[3];\n@zlicz[3] = 0;\n\nif( @zlicz[2] > int(@zlicz[1]/2) )\n{\n\n  $m = int(@zlicz[1]/2);\n\n}\nelse\n{\n\n  $m = @zlicz[2];\n\n}\n\n$wynik += $m;\n@zlicz[1] -= $m * 2;\n@zlicz[2] -= $m;\n\n$wynik += int( @zlicz[2]/2 );\n@zlicz[2] -= int( @zlicz[2]/2 ) * 2;\n\n$wynik += @zlicz[2];\n@zlicz[2] = 0;\n\n$wynik += int( @zlicz[1]/4 );\n@zlicz[1] -= int( @zlicz[1]/4 ) * 4;\n\nif( @zlicz[1] != 0 )\n{\n\n  $wynik++;\n\n}\n\nprint $wynik;\n"}, {"source_code": "use integer;\n\n<>;\n$_=<>;\n@_=(0)x 5;\n$_[$&]++ while /\\d+/g;\n\n($f,$t,$w,$o) = reverse @_;\n\n$ats += $f;\n$ats += $t; $o-=$t; $o<1 and $o=0;\n\n$ats += $w / 2; $w %= 2;\n$ats += $o / 4; $o %= 4;\n\n$wo = $w*2 + $o;\n$ats += ($wo - 1) / 4 <=> 0;\n\nprint $ats + 1"}, {"source_code": "$n=<>;\n@l=split(' ',<>);\n$a=0;$b=0;$c=0;$d=0;\nforeach(@l)\n{\nif($_==1){$a+=1;}\nif($_==2){$b+=1;}\nif($_==3){$c+=1;}\nif($_==4){$d+=1;}\n}\n$ans=0;\nif($b%2==0){$ans+=$b/2;$b=0;}\nelse{$ans+=int($b/2);$b=1;}\nif($a>$c){$ans+=$a;}\nelse{$ans+=$c+$b;}\n$ans+=$d;\nprint \"$ans\\n\";\n"}, {"source_code": "$n=<>;\n@l=split(' ',<>);\n$a=0;$b=0;$c=0;$d=0;\nforeach(@l)\n{\nif($_==1){$a+=1;}\nif($_==2){$b+=1;}\nif($_==3){$c+=1;}\nif($_==4){$d+=1;}\n}\n$ans=0;\nif($b%2==0){$ans+=$b/2;$b=0;}\nelse{$ans+=int($b/2);$b=1;}\nif($a>$c){$ans+=$c;$a-=$c;if($b>0){$a-=2;}}\nelse{$ans+=$c+$b;$a=0;$b=0;}\nif($a>0){$a+=3;$ans+=int($a/4);}\n$ans+=$d;\nprint \"$ans\\n\";\n"}], "src_uid": "371100da1b044ad500ac4e1c09fa8dcb"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\t\n\tmy $R = $k;\n\tmy $L = $k;\n\t\n\t$_ = 'o';\n\t\n\twhile( $n >= $k * 2 + 1 + length ){\n\t\t$_ .= '-' x ( $k * 2 ) . 'o';\n\t\t}\n\t\n\twhile( $R > 0 ){\n\t\tif( $n >= 1 + length ){\n\t\t\t$_ .= '-';\n\t\t\t$R --;\n\t\t\tnext;\n\t\t\t}\n\t\tlast;\n\t\t}\n\t\t\n\twhile( $L > 0 ){\n\t\tif( $n >= 1 + length ){\n\t\t\ts/^/-/;\n\t\t\t$L --;\n\t\t\tnext;\n\t\t\t}\n\t\tlast;\n\t\t}\n\t\n\t@_ = ();\n\t\n\twhile( /o/g ){\n\t\tpush @_, \"@+\";\n\t\t}\n\t\n\tprint for ~~ @_, \"@_\";\n\t}", "positive_code": [{"source_code": "( $n, $k ) = split ' ', <>;\n\n$_ = 'o';\n\n$_ .= '-' x ( $k * 2 ) . 'o' while $n > $k * 2 + length;\n\t\nfor $i ( 0, 1 ){\n\t$_ = reverse;\n\t$q = $k;\n\ts/^/-/ while $q -- and $n > length;\n\t}\n\npush @_, \"@+\" while /o/g;\n\nprint @_ . \"\\n@_\""}], "negative_code": [], "src_uid": "dfd60a02670749c67b0f96df1a0709b9"}
{"source_code": "use strict;\nuse warnings;\n\nchomp (my $length = <>);\nchomp (my @array = split(\" \", <>));\nmy @positions;\nfor (my $i = 0;$i<@array;$i++){\n\t$positions[$array[$i]] = $i;\n}\n\nchomp (my $numQueries = <>);\nchomp (my @queries = split(\" \", <>));\n\nmy $vasya = 0;\nmy $petya = 0;\n\nfor(@queries) {\n\t$vasya += $positions[$_]+1;\n\t$petya += $length - $positions[$_];\n}\n\nprint \"$vasya $petya\";", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nchomp (my $length = <>);\nchomp(my $temp = <>);\nmy @array = split(\" \", $temp);\nundef $temp;\nmy @positions;\nfor (my $i = 0;$i<@array;$i++){\n\t$positions[$array[$i]] = $i;\n}\n\nchomp (my $numQueries = <>);\nchomp($temp = <>);\nmy @queries = split(\" \", $temp);\nundef $temp;\n\nmy $vasya = 0;\nmy $petya = 0;\n\nfor(@queries) {\n\t$vasya += $positions[$_]+1;\n\t$petya += $length - $positions[$_];\n}\n\nprint \"$vasya $petya\";"}, {"source_code": "chomp($n=<STDIN>);\n@elements = split /\\s+/, <STDIN>;\nchomp($m = <STDIN>);\n@queries = split /\\s+/, <STDIN>;\n\n%index = { };\n$i = 1;\nforeach $e (@elements) {\n\t$index{$e} = $i;\n\t$i++;\n}\n\n$vasya = 0;\n$petya = 0;\n\nforeach $q (@queries) {\n\t$i = $index{$q};\n\t$vasya += $i;\n\t$petya += ($n-$i + 1);\n}\nprint \"$vasya $petya\\n\";"}, {"source_code": "use warnings;\nuse strict;\nuse List::Util (\"sum\", \"max\", \"min\");\n\nmy ($n) =  scalar <>;\nmy @vals = split \" \", scalar <>;\nmy $q = scalar <>;\nmy @qs = split \" \", scalar <>;\n\nmy %pos_left;\nmy %pos_right;\n\nfor (0..$#vals)\n{\n\t$pos_left{$vals[$_]} ||= 1 + $_;\n\t$pos_right{$vals[$_]} = 1 + $#vals - $_;\n}\n$\\ = \" \";\nprint sum(map $pos_left{$_},  @qs);\nprint sum(map $pos_right{$_},  @qs);\n\n"}], "negative_code": [], "src_uid": "b7aef95015e326307521fd59d4fccb64"}
{"source_code": "use strict;\n#open STDIN, '<input.txt';\n#open STDOUT, '>output.txt';\nmy $n = <>;\nmy @a;\nmy $ans = 0;\nfor (my $i = 0; $i < $n; $i++){\n  my @buf = split(' ', <>);\n  for(my $j = 0; $j <= $#buf; $j++){\n    $ans += $buf[$j];\n  }\n  my @buf2;\n  $buf2[0] = $ans;\n  $buf2[1] = $i + 1;\n  push(@a, [@buf2]);\n  $ans = 0;\n}\n@a = sort{\n  $b->[0] <=> $a->[0] ||\n  $a->[1] <=> $b->[1];\n}@a;\n\nfor(my $i = 0; $i < $n; $i++){\n  if($a[$i][1] == 1){\n   print $i + 1;\n  }\n}\n", "positive_code": [{"source_code": "use strict;\nmy $n = <>;\nmy @a;\nmy $ans = 0;\nfor (my $i = 0; $i < $n; $i++){\n  my @buf = split(' ', <>);\n  for(my $j = 0; $j <= $#buf; $j++){\n    $ans += $buf[$j];\n  }\n  push(@a, [($ans, $i + 1)]);\n  $ans = 0;\n}\n@a = sort{\n  $b->[0] <=> $a->[0] ||\n  $a->[1] <=> $b->[1];\n}@a;\n\nfor(my $i = 0; $i < $n; $i++){\n  if($a[$i][1] == 1){\n   print $i + 1;\n  }\n}\n"}], "negative_code": [], "src_uid": "3c984366bba580993d1694d27982a773"}
{"source_code": "use strict;\nuse warnings;\n\nmy ( $n, $x ) = split ( \" \",  <> );\nmy $cur = 1;\nmy $result = 0;\nwhile ( $n-- ){\n\tmy ( $s, $e ) = split ( \" \", <> );\n\tmy $y = int ( ( $s - $cur ) / $x );\n\t$result += $e - ( $y * $x + $cur ) + 1;\n\t$cur = $e + 1;\n}\nprint \"$result\\n\";\n", "positive_code": [{"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s"}, {"source_code": "($n, $x) = split \" \", <>;\n$/ = $,;\n$_ = \"0\\n\".<>;\n$s += $2 - $1 + 1 while /(\\d+) (\\d+)/g;\n$s += ($2 - $1 - 1) % $x while /(\\d+)\\n(\\d+)/g;\nprint $s"}, {"source_code": "($n, $x) = split \" \", <>;\n/(\\d+) (\\d+)/,\n$s += ($1 - $b - 1) % $x + ($b = $2) - $1 + 1\nfor <>;\nprint $s"}, {"source_code": "$\\ = $/;\n($n, $x) = split \" \", <>;\n$/ = $,;\n$_ = <>;\n$sum += $2 - $1 + 1 while /(\\d+) (\\d+)/g;\ns/^/0\\n/;\n$sum += ($2 - $1 - 1) % $x while / (\\d+) \\n (\\d+) /gx;\nprint $sum"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: a.pl\n#\n#        USAGE: ./a.pl  \n#\n#  DESCRIPTION: \n#\n#      OPTIONS: ---\n# REQUIREMENTS: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: YOUR NAME (), \n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 1/14/2015 8:02:38 PM\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\nchomp($_ = <STDIN>);\nmy ($n, $x) = split(/ /, $_);\nmy @time;\nwhile (<>) {\n\tchomp;\n\tmy ($l, $r) = split(/ /);\n\tpush(@time, $l);\n\tpush(@time,$r);\n}\nmy ($now, $sum);\n$now = 1; $sum = 0; \nwhile (1) {\n\tmy $l = shift @time;\n\tmy $r = shift @time;\n\twhile (1) {\n\t\tif ($now + $x > $l) {\n\t\t\t$sum += ($r - $now + 1);\n\t\t\t$now = $r + 1;\n\t\t\tlast;\n\t\t}\n\t\telse {\n\t\t\t$now += $x;\n\t\t}\n\t}\n\tif ( scalar @time == 0 ) {\n\t\tlast;\n\t}\n}\nprint \"$sum\\n\";\n\n\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "($x) =<>=~ /\\d+$/g;\nmap {/ /,\n$s += ($` - $b - 1) % $x + ($b = $') - $` + 1\n} <>;\nprint $s\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\nuse integer;\n\nmy ($n, $x) = split / /, <>;\n($ans, $cur) = (0, 1);\nwhile ($n-- > 0) {\n\t($l, $r) = split / /, <>;\n\t$m = ($l - $cur) / $x;\n\t$l = $cur + $m * $x;\n\t$ans += ($r - $l + 1);\n\t$cur = $r + 1;\n}\nsay $ans;"}], "negative_code": [{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: a.pl\n#\n#        USAGE: ./a.pl  \n#\n#  DESCRIPTION: \n#\n#      OPTIONS: ---\n# REQUIREMENTS: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: YOUR NAME (), \n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 1/14/2015 8:02:38 PM\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\nchomp($_ = <STDIN>);\nmy ($n, $x) = split(/ /, $_);\nmy @time;\nwhile (<>) {\n\tchomp;\n\tmy ($l, $r) = split(/ /);\n\tpush(@time, $l);\n\tpush(@time,$r);\n}\nmy ($now, $sum);\n$now = 1; $sum = 0; \nwhile ($now < $time[$#time]) {\n\tmy $l = shift @time;\n\tmy $r = shift @time;\n\twhile (1) {\n\t\tif ($now + $x >= $l) {\n\t\t\t$sum += ($r - $now + 1);\n\t\t\t$now = $r + 1;\n\t\t\tlast;\n\t\t}\n\t\telse {\n\t\t\t$now += $x;\n\t\t}\n\t}\n\tif ( scalar @time == 0 ) {\n\t\tlast;\n\t}\n}\nprint \"$sum\\n\";\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#\n#         FILE: a.pl\n#\n#        USAGE: ./a.pl  \n#\n#  DESCRIPTION: \n#\n#      OPTIONS: ---\n# REQUIREMENTS: ---\n#         BUGS: ---\n#        NOTES: ---\n#       AUTHOR: YOUR NAME (), \n# ORGANIZATION: \n#      VERSION: 1.0\n#      CREATED: 1/14/2015 8:02:38 PM\n#     REVISION: ---\n#===============================================================================\n\nuse strict;\nuse warnings;\nuse utf8;\nuse 5.012;\n\nchomp($_ = <STDIN>);\nmy ($n, $x) = split(/ /, $_);\nmy @time;\nwhile (<>) {\n\tchomp;\n\tmy ($l, $r) = split(/ /);\n\tpush(@time, $l);\n\tpush(@time,$r);\n}\nmy ($now, $sum);\n$now = 1; $sum = 0; \nwhile ($now < $time[$#time]) {\n\tmy $l = shift @time;\n\tmy $r = shift @time;\n\twhile (1) {\n#\t\tprint \"now = $now\\n\";\n\t\tif ($now + $x > $l) {\n\t\t\t$sum += ($r - $now + 1);\n\t\t\t$now = $r + 1;\n\t\t\tlast;\n\t\t}\n\t\telse {\n\t\t\t$now += $x;\n\t\t}\n\t}\n\tif ( scalar @time == 0 ) {\n\t\tlast;\n\t}\n}\nprint \"$sum\\n\";\n"}, {"source_code": "$\\ = $/;\n($n, $x) = split \" \", <>;\n$/ = $,;\n$_ = <>;\n$sum += $2 - $1 + 1 while /(\\d+) (\\d+)/g;\ns/^/1 /;\n$sum += ($2 - $1) % $x while / (\\d+) \\n (\\d+) /gx;\nprint $sum"}, {"source_code": "$\\ = $/;\n($n, $x) = split \" \", <>;\n$/ = $,;\n$_ = <>;\n$sum += $2 - $1 + 1 while /(\\d+) (\\d+)/g;\n$sum += ($2 - $1) % $x while / (\\d+) \\n (\\d+) /gx;\nprint $sum"}, {"source_code": "$\\ = $/;\nwhile (<>){\n\t($n, $x)=split;\n\t@_ = (0) x (1e5 + 1);\n\tfor $i (1..$n){\n\t\t($l, $r)= split \" \",<>;\n\t\t$base = ($l - 1) - ($l - 1) % $x;\n\t\tfor $j ($base + 1 .. $r){\n\t\t\t$_[$j] = 1;\n\t\t\t}\n\t\t}\n\tundef $occ;\n\t$_ && $occ++ for @_;\n\tprint $occ\n\t}"}], "src_uid": "ac33b73da5aaf2139b348a9c237f93a4"}
{"source_code": "$ch1=<>;\nchomp$ch;\n$ch2=<>;\nchomp$ch2;\n$n=length$ch1;\n$diff=0,$nb71=0,$nb72=0;\nfor($i=0;$i<$n;$i++){\n\nif(substr($ch1,$i,1)!=substr($ch2,$i,1)){\n$diff++;\n}\nif(substr($ch1,$i,1)=='7'){\n$nb71++;\n}\nif(substr($ch2,$i,1)=='7'){\n$nb72++;\n}\n\n}\n$res=abs($nb72-$nb71)+($diff-abs($nb72-$nb71))/2;\nprint $res;", "positive_code": [{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\nuse List::Util qw{max};\n\nmy @a = split //, <>;\nmy @b = split //, <>;\npop @a;\npop @b;\nmy ($fours, $sevens) = (0, 0);\n\nfor (0 .. $#a) {\n    if ($a[$_] > $b[$_]) {\n\t$sevens++;\n    } elsif ($a[$_] < $b[$_]) {\n\t$fours++;\n    }\n}\n\nprint max($sevens, $fours) . \"\\n\";\n"}], "negative_code": [], "src_uid": "2d1609b434262d30f6bd030d41a71bd5"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tfor( @_ ){\n\t\tmy( $name, undef, @T ) = split;\n\t\t$h{ $name }{ $_ } = 1 for @T;\n\t\t}\n\t\n\tfor my $name ( keys %h ){\n\t\tmy @keys = keys %{ $h{ $name } };\n\t\tfor my $i ( @keys ){\n\t\t\tfor my $j ( @keys ){\n\t\t\t\t$i =~ /(?<=.)$j$/ and delete $h{ $name }{ $j };\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tprint for ~~ keys %h,\n\t\tmap { my @K = keys %{ $h{ $_ } }; $_ . ' ' . @K . ' ' . \"@K\" } keys %h;\n\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n<>;\n\nfor( <> ){\n\t( $n, undef, @T ) = split;\n\t$h{ $n }{ $_ } = 1 for @T;\n\t}\n\nfor $n ( keys %h ){\n\t@K = keys %{ $h{ $n } };\n\tfor $i ( @K ){\n\t\tfor $j ( @K ){ \n\t\t\t$i =~ /.$j$/ and delete $h{ $n }{ $j }\n\t\t\t}\n\t\t}\n\t}\n\nprint for ~~ keys %h,\n\tmap { @K = keys %{ $h{ $_ } }; \"$_ \" . @K . \" @K\" } keys %h"}], "negative_code": [{"source_code": "<>;\n\nfor( <> ){\n\t( $n, undef, @T ) = split;\n\t$h{ $n }{ $_ } = 1 for @T;\n\t}\n\nfor $n ( keys %h ){\n\t@K = keys %{ $h{ $n } };\n\tfor $i ( @K ){\n\t\tfor $j ( @K ){ \n\t\t\t$i =~ /.$j$/ and delete $h{ $n }{ $j }\n\t\t\t}\n\t\t}\n\t}\n\nprint for ~~ keys %h,\n\tmap { @K = keys %{ $h{ $_ } }; \"$_ \" . @K . \" @K\" } keys %h"}], "src_uid": "df7b16d582582e6756cdb2d6d856c873"}
{"source_code": "#!/usr/bin/perl\r\n\r\nmy ($t) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $t -- > 0 ){\r\n  my ($n,$k) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  \r\n  my $fi = -1;\r\n  my $la = -1;\r\n  for(my $i=0;$i<$n;$i++){\r\n    if( substr($s,$i,1) eq '*' ){\r\n      $fi = $i if $fi < 0;\r\n      $la = $i;\r\n    }\r\n  }\r\n  if( $fi == $la ){\r\n    print \"1\\n\"; next;\r\n  }\r\n  my $i = $fi;\r\n  my $c = 2;\r\n  while( $i < $la ){\r\n    last if $la <= $i + $k;\r\n    for(my $j=$i+$k;$j>$i;$j--){\r\n      if( substr($s,$j,1) eq '*' ){\r\n        $i = $j;\r\n        $c++;\r\n        last;\r\n      }\r\n    }\r\n  }\r\n  print \"$c\\n\";\r\n}\r\n\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tmy( undef, $k ) = split;\r\n\t\r\n\t$k --;\r\n\t\r\n\tprint length \r\n\t\t<> =~\r\n\t\ts/\\*/x/r =~\r\n\t\ts/[x*].{0,$k}\\K(?=\\*)/,/gr =~\r\n\t\ts/,\\*/x/gr =~\r\n\t\ty/.*\\n//dr;\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\ts/\\*/x/;\n##\ts/\\*[^*]*$/x/;\n\t\n\t$debug and print;\n\t\n\t$k --;\n\t\n\ts/[x*].{0,$k}\\K(?=\\*)/,/g;\n\t\n\t$debug and print;\n\t\n\ts/,\\*/x/g;\n\t\n\t$debug and print;\n\t\n\tprint scalar( () = m/x/g );\n\t}"}], "negative_code": [], "src_uid": "874e22d4fd8e35f7e0eade2b469ee5dc"}
{"source_code": "while ($eil=<>) {\n\n$i=1;\n$_=<>;\nchomp;\n/\\d+ /;\n$_.=\" $&\";\ns/\\d+ /$&$&/g;\ns/\\d+ //;\ns/\\d+ $//;\n# print \"$_\\n\";\ns/(\\d+) (\\d+) /(abs($1-$2)).\" \"/eg;\n# print \"$_\\n\";\ns/ $//;\n@_=split/ /;\n$min = shift @_;\n$j=$i;\nfor (@_){\n    $i++;\n    if ($_ < $min){\n        $min = $_;\n        $j=$i;\n        }\n    \n    }\nprint \"$j \";\nprint $j==$eil?1:++$j;\nprint \"\\n\";\n}", "positive_code": [{"source_code": "chomp($n = <STDIN>);\n@soldiers = split /\\s+/, <STDIN>;\nunshift @soldiers, 0;\n$mingap = 9999;\n$minpos = 0;\nfor($i=1;$i<($n);$i++) {\n\t$d = abs($soldiers[$i]-$soldiers[$i+1]);\n#\tprint \"diff between pos $i and \".($i+1).\" is $d\\n\";\n\tif( $d < $mingap) {\n\t\t$mingap = $d;\n\t\t$minpos = $i;\n\t}\n}\n#print \"minggap $mingap, diff between first and last : \".abs($soldiers[1]-$soldiers[-1]).\"\\n\";\n\nif(abs($soldiers[1]-$soldiers[-1])<$mingap) {\n\tprint \"1 $n\\n\";\n} else {\n\tprint \"\".($minpos).\" \".($minpos+1).\"\\n\";\n}"}], "negative_code": [{"source_code": "chomp($n = <STDIN>);\n@soldiers = split /\\s+/, <STDIN>;\nunshift @soldiers, 0;\n$mingap = 9999;\n$minpos = 0;\nfor($i=1;$i<($n-1);$i++) {\n\tif(abs($soldiers[$i]-$soldiers[$i+1]) < $mingap) {\n\t\t$mingap = abs($soldiers[$i]-$soldiers[$i+1]);\n\t\t$minpos = $i;\n\t}\n}\n#print \"minggap $mingap, diff between first and last : \".abs($soldiers[0]-$soldiers[-1]).\"\\n\";\n\nif(abs($soldiers[1]-$soldiers[-1])<$mingap) {\n\tprint \"1 $n\\n\";\n} else {\n\tprint \"\".($minpos).\" \".($minpos+1).\"\\n\";\n}"}, {"source_code": "chomp($n = <STDIN>);\n@soldiers = split /\\s+/, <STDIN>;\n\n$mingap = 9999;\n$minpos = 0;\nfor($i=1;$i<($n-1);$i++) {\n\tif(abs($soldiers[$i]-$soldiers[$i+1]) < $mingap) {\n\t\t$mingap = abs($soldiers[$i]-$soldiers[$i+1]);\n\t\t$minpos = $i;\n\t}\n}\n#print \"minggap $mingap, diff between first and last : \".abs($soldiers[0]-$soldiers[-1]).\"\\n\";\n\nif(abs($soldiers[0]-$soldiers[-1])<$mingap) {\n\tprint \"1 $n\\n\";\n} else {\n\tprint \"-\".($minpos).\" - \".($minpos+1).\"-\\n\";\n}"}, {"source_code": "chomp($n = <STDIN>);\n@soldiers = split /\\s+/, <STDIN>;\n\n$mingap = 9999;\n$minpos = 0;\nfor($i=1;$i<($n-1);$i++) {\n\tif(abs($soldiers[$i]-$soldiers[$i+1]) < $mingap) {\n\t\t$mingap = abs($soldiers[$i]-$soldiers[$i+1]);\n\t\t$minpos = $i;\n\t}\n}\n#print \"minggap $mingap, diff between first and last : \".abs($soldiers[0]-$soldiers[-1]).\"\\n\";\n\nif(abs($soldiers[0]-$soldiers[-1])<$mingap) {\n\tprint \"1 $n\\n\";\n} else {\n\tprint ($minpos).\" \".($minpos+1).\"\\n\";\n}"}, {"source_code": "chomp($n = <STDIN>);\n@soldiers = split /\\s+/, <STDIN>;\n\n$mingap = 9999;\n$minpos = 0;\nfor($i=1;$i<($n-1);$i++) {\n\tif(abs($soldiers[$i]-$soldiers[$i+1]) < $mingap) {\n\t\t$mingap = abs($soldiers[$i]-$soldiers[$i+1]);\n\t\t$minpos = $i;\n\t}\n}\n#print \"minggap $mingap, diff between first and last : \".abs($soldiers[0]-$soldiers[-1]).\"\\n\";\n\nif(abs($soldiers[0]-$soldiers[-1])<$mingap) {\n\tprint \"1 $n\\n\";\n} else {\n\tprint \"\".($minpos).\" \".($minpos+1).\"\\n\";\n}"}], "src_uid": "facd9cd4fc1e53f50a1e6f947d78e942"}
{"source_code": "use strict;\n\n# cf713a\n=item\n\nA. Memory and Crow\ntime limit per test\n2 seconds\nmemory limit per test\n256 megabytes\ninput\nstandard input\noutput\nstandard output\n\nThere are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure:\n\n    The crow sets ai initially 0.\n    The crow then adds bi to ai, subtracts bi + 1, adds the bi + 2 number, and so on until the n'th number. Thus, ai = bi - bi + 1 + bi + 2 - bi + 3.... \n\nMemory gives you the values a1, a2, ..., an, and he now wants you to find the initial numbers b1, b2, ..., bn written in the row? Can you do it?\nInput\n\nThe first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of integers written in the row.\n\nThe next line contains n, the i'th of which is ai ( - 109 ≤ ai ≤ 109) — the value of the i'th number.\nOutput\n\nPrint n integers corresponding to the sequence b1, b2, ..., bn. It's guaranteed that the answer is unique and fits in 32-bit integer type.\nExamples\nInput\n\n5\n6 -4 8 -2 3\n\nOutput\n\n2 4 6 1 3 \n\nInput\n\n5\n3 -2 -1 5 6\n\nOutput\n\n1 -3 4 11 6 \n\nNote\n\nIn the first sample test, the crows report the numbers 6, - 4, 8, - 2, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6 = 2 - 4 + 6 - 1 + 3, and  - 4 = 4 - 6 + 1 - 3.\n\nIn the second sample test, the sequence 1,  - 3, 4, 11, 6 satisfies the reports. For example, 5 = 11 - 6 and 6 = 6.\n\n\n=cut\n\n# ai = bi - bi + 1 + bi + 2 - bi + 3...\n=item\na0=b0\na1=b1-b0\na2=b2-b1+b0=b2-a1\na3=b3-b2+b1-b0=b3-a2\n\nb0=a0\nb1=a0+a1\nb2=a1+a2\nb3=a2+a3\n=cut\n\nmy ($n,$l)=<>;\nmy @as=split(' ',$l);\nfor(my $i=1;$i<$n;++$i) {\n  print $as[$i-1]+$as[$i],' ';\n}\nprint $as[$n-1],\"\\n\";\n\n\n", "positive_code": [{"source_code": "$,=\" \";\nmy $n=<>;\nchomp($n);\nmy @d=split / /,<>;\nchomp(@d);\n$n--;\nfor(0..$n)\n{\n  my $k=$d[$_]+$d[$_+1];\n  print $k . \" \";\n}\nprint \"\\n\";\n"}], "negative_code": [], "src_uid": "fa256021dc519f526ef3878cce32ff31"}
{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\tprint s/^(?|.*\\K(.)(.)(??{ 'x' x !( $1 + $2 > 9 ) })\r\n\t\t\t   |(.)(.)\r\n\t\t\t   )\r\n\t\t\t   /\r\n\t\t\t   $1 + $2\r\n\t\t\t   /erx\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\ts/^.*\\K(19|2[89]|3[7-9]|4[6-9]|5[5-9]|6[4-9]|7[3-9]|8[2-9]|9[1-9])/\n\t\t0 + eval join '+', split '', $& /e ||\n\t\ts/../ 0 + eval join '+', split '', $& /e;\n\t\n\tprint;\n\t}"}], "negative_code": [{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\tprint s/^(?|.*\\K(.)(.)(??{ 'x' x !( $1 < $2 && $1 + $2 > 9 ) })\r\n\t\t\t   |.*\\K(.)(.)(??{ 'x' x !( $1 == $2 && $1 + $2 > 9 ) })\r\n\t\t\t   |(.)(.)\r\n\t\t\t   )\r\n\t\t\t   /\r\n\t\t\t   $1 + $2\r\n\t\t\t   /erx\r\n\t}"}, {"source_code": "<>;\r\n\r\nwhile(<>){\r\n\tprint s/^(?|.*\\K(.)(.)(??{ 'x' x !( $1 <= $2 && $1 + $2 > 9 ) })\r\n\t\t\t   |(.)(.)\r\n\t\t\t   )\r\n\t\t\t   /\r\n\t\t\t   $1 + $2\r\n\t\t\t   /erx\r\n\t}"}, {"source_code": "<>;\r\n\r\nwhile(<>){\r\n\tprint s/^(?|.*\\K(.)(.)(??{ 'x' x !( $1 < $2 && $1 + $2 > 9 ) })\r\n\t\t\t   |(.)(.)\r\n\t\t\t   )\r\n\t\t\t   /\r\n\t\t\t   $1 + $2\r\n\t\t\t   /erx\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n<>;\n\nwhile(<>){\n\tprint s/^(?|.*\\K(.)(.)(??{ 'x' x ( $1 >= $2 || $1 + $2 < 10 ) })\n\t\t\t   |(.)(.)\n\t\t\t   )\n\t\t\t   /\n\t\t\t   $1 + $2\n\t\t\t   /erx\n\t}"}, {"source_code": "<>;\r\n\r\nwhile(<>){\r\n\tprint s/^(?|.*\\K(.)(.)(??{ 'x' x ( $1 >= $2 ) })\r\n\t\t\t   |(.)(.)\r\n\t\t\t   )\r\n\t\t\t   /\r\n\t\t\t   $1 + $2\r\n\t\t\t   /erx\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\ts/^.*\\K(19|2[89]|3[7-9]|4[6-9]|5[5-9]|6[4-9]|7[3-9]|8[2-9]|9[1-9])/\n\t\t0 + eval join '+', split '', $& /e ||\n\t\ts/../ 0 + eval join '+', split '', $& /e;\n\t\n\tprint;\n\t}"}], "src_uid": "6db42771fdd582578194c7b69a4ef575"}
{"source_code": "@i = 1..<>; $_ = <>;\ns/@i/$i[-1]/g, pop(@i) while @i > 1;\nprint 0 + split, \"\\n$_\";\n", "positive_code": [{"source_code": "@i = 1..<>; $_ = <>;\ns/@i/$i[-1]/g, pop(@i) while @i > 1;\nprint 0 + split, \"\\n$_\";\n"}], "negative_code": [{"source_code": "<>; $_ = <>;\n@i = 1..1000;\ns/@i/$i[-1]/e, pop(@i) while @i > 1;\nprint 0+split, \"\\n$_\";\n"}], "src_uid": "0ee86e75ff7a47a711c9eb41b34ad1a5"}
{"source_code": "$k=<>;\n$_=<>;\ns/(\\w)/$h{$1}++/eg;\nfor(keys %h) {\n  if($h{$_}%$k){\n    print -1;\n    exit;\n  }\n  $s.=$_ x ($h{$_}/$k);\n}\nprint $s x $k;", "positive_code": [{"source_code": "$k=<>;\n$_=<>;\nchomp;\nmap {$h{$_}++} split '';\nfor(keys %h) {                                                                  \n  if($h{$_}%$k){\n    print -1;\n    exit;\n  }\n  $s.=$_ x ($h{$_}/$k);\n}\nprint $s x $k;"}, {"source_code": "\n$k=<>;\n@ch=split('',<>);\npop(@ch);\nforeach $var (@ch){\n$map{$var}++;\n\n}\n$ok=1;\nforeach $var (values%map){\nif($var%$k!=0){\n$ok=0;\nlast;\n}\n}\nif(!$ok){\nprint -1;\n}\nelse{\n\nfor($i=0;$i<$k;$i++){\nwhile(($key,$v) = each(%map) ) {\n   print $key x ($v/$k) ;\n}\n\n\n\n}\n\n}"}, {"source_code": "#!/bin/perl\nuse strict;\nuse warnings;\n\nmy $k = int <STDIN>;\nmy $str = <STDIN>;\nchomp $str;\nmy @arr = split //, $str;\n\nmy %hash;\nmy $i;\nforeach $i ( @arr ) {\n\tif ( $hash{$i} ) {\n\t\t$hash{$i}++;\n\t} else {\n\t\t$hash{$i} = 1;\n\t}\n}\n\n$str = '';\nforeach $i ( keys %hash ) {\n\tif ( $hash{$i} % $k ) {\n\t\tprint -1;\n\t\tgoto end;\n\t} else {\n\t\t$str .= $i x ( $hash{$i} / $k );\n\t}\n}\n\nprint $str x $k;\n\nend:\n\n__END__\n\n"}, {"source_code": "$k=<>;\n$_=<>;\ns/(\\w)/$h{$1}++/eg;\n#for(sort keys %h) {\n#  print \"$_ => $h{$_}\\n\";                                                      \n#}\nif(grep {$h{$_}%$k} keys %h) {\n  print -1; \n}else{\n  for(keys %h) {\n    $s.=$_ x ($h{$_}/$k);\n  }\n  print $s x $k; \n}"}], "negative_code": [], "src_uid": "f5451b19cf835b1cb154253fbe4ea6df"}
{"source_code": "my $n = <STDIN>;\nmy $line = <STDIN>;\nchomp $line;\nmy @chars = split(//, $line);\nmy $CA = 0;\nmy $CD = 0;\nfor my $i (0..$n-1) {\n\t$CA++ if $chars[$i] eq 'A';\n\t$CD++ if $chars[$i] eq 'D';\n}\nprint 'Danik'      if $CD > $CA;\nprint 'Anton'      if $CD < $CA;\nprint 'Friendship' if $CD == $CA;", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nchomp(my $a = <>);\nchomp(my $b = <>);\n\nmy $an = ($b =~ tr/A/A/);\nmy $da = ($b =~ tr/D/D/);\n\nif ($an > $da) {\n\tprint \"Anton\";\n}\nelsif ($da > $an) {\n\tprint \"Danik\";\n}\nelse {\n\tprint \"Friendship\";\n}\n"}, {"source_code": "use strict; \nuse warnings; \n\nsub main\n{\n    my $gameLen = <STDIN>;\n    my $result = <STDIN>;\n    my $anton=0;\n    my $danik=0;\n    my $current;\n    for(my $i=0;$i<$gameLen;$i++){\n        if(substr($result,$i,1) eq \"A\"){\n            $anton = $anton+1;\n        }\n        if(substr($result,$i,1) eq \"D\"){\n            $danik = $danik+1;\n        }\n    }\n    if($anton>$danik){\n        printf(\"Anton\\n\");\n    }elsif($anton<$danik){\n        printf(\"Danik\\n\");\n    }else{\n        printf(\"Friendship\\n\")\n    }\n}\n\nmain();"}, {"source_code": "use strict;\nuse warnings;\n\n<>;\nmy $s=<>;\nchomp($s);\nmy $k=length($s);\n$s =~ s/A//g;\nmy $D=length($s);\nmy $A=$k-$D;\nif($D>$A)\n{\n  print \"Danik\\n\";\n}\nelsif($A>$D)\n{\n  print \"Anton\\n\";\n}\nelse\n{\n  print \"Friendship\\n\";\n}\n"}, {"source_code": "use feature qw(switch);\n$n=<>;\n@ch=split('',<>);\n\n\n$A=0,$D=0;\nforeach $car (@ch){\ngiven($car){\n\nwhen('A') {$A++};\nwhen('D') {$D++};\n\n}\n\n}\n\nif($A>$D){\n\nprint \"Anton\";\n}\nelsif($D>$A){\nprint \"Danik\";\n}\nelse{\nprint \"Friendship\";\n}"}, {"source_code": "#!/usr/bin/perl \nuse strict;\nmy $n = <STDIN>;\nmy $array =<STDIN>;\nchomp $array;\nmy @array_p=split(undef, $array);\nmy $A = 0;\nmy $B = 0;\nforeach my $item (@array_p)\n{\n    $item eq 'A' ? $A++ : $B++ ;\n}\n$A == $B ? print 'Friendship' : $A > $B ? print 'Anton' : print 'Danik';"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy $winners = read_line;\n\nmy $a = 0;\nmy $d = 0;\n\nfor (0..$n-1) {\n    my $winner = substr($winners, $_, 1);\n    $a++ if $winner eq 'A';\n    $d++ if $winner eq 'D';\n}\n\nsay   $a == $d ? 'Friendship' \n    : $a > $d  ? 'Anton'\n    :            'Danik'\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy @winners = split q{}, read_line;\n\nmy $a = 0;\nmy $d = 0;\n\nfor (@winners) {\n    $a++ if $_ eq 'A';\n    $d++ if $_ eq 'D';\n}\n\nsay   $a == $d ? 'Friendship' \n    : $a > $d  ? 'Anton'\n    :            'Danik'\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$A = () = /A/g;\n\t$D = () = /D/g;\n\t\n\tprint qw(Friendship Anton Danik)[ $A <=> $D ]\n\t}"}, {"source_code": "<>;\n\n$_ = <>;\n\n$A = () = /A/g;\n$D = () = /D/g;\n\t\nprint qw(Friendship Anton Danik)[ $A <=> $D ]"}], "negative_code": [{"source_code": "my $n = <STDIN>;\nmy $line = <STDIN>;\nchomp $line;\nmy @chars = split(//, $line);\nmy $CA = 0;\nmy $CD = 0;\nforeach my $i (@chars) {\n\t$CA++ if $chars[i] eq 'A';\n\t$CD++ if $chars[i] eq 'D';\n}\nprint 'Danik'      if $CD > $CA;\nprint 'Anton'      if $CD < $CA;\nprint 'Friendship' if $CD == $CA;"}, {"source_code": "#!/usr/bin/perl \nuse strict;\nmy $n = <STDIN>;\nmy $array =<STDIN>;\nmy @array_p=split(undef, $array);\nmy $A = 0;\nmy $B = 0;\nforeach my $item (@array_p)\n{\n    $item eq 'A' ? $A++ : $B++ ;\n}\n$A == $B ? print 'Friendship' : $A > $B ? print 'Anton' : print 'Danik';"}], "src_uid": "0de32a7ccb08538a8d88239245cef50b"}
{"source_code": "use v5.20;\r\nuse integer;\r\nfor ( 1 .. <> ) {\r\n    my ( $n, $k ) = split ' ', <>;\r\n    my @p   = split ' ', <>;\r\n    my $sum = $p[0];\r\n    my $ans = 0;\r\n    for ( 1 .. $n ) {\r\n        my $t = $p[$_];\r\n        if ( 100 * $t > $k * $sum ) {\r\n            my $r = ( 100 * $t + $k - 1 ) / $k - $sum;\r\n            $ans = $r if $r > $ans;\r\n        }\r\n        $sum += $t;\r\n    }\r\n    say $ans;\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n,$k) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @p = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  \r\n  my @a = ($p[0]); $#a = $#p;\r\n  for(my $i=1;$i<$n;$i++){\r\n    $a[$i] = $a[$i-1] + $p[$i];\r\n  }\r\n  my $s = 0;\r\n  my $t = $a[0];\r\n  for(my $i=1;$i<$n;$i++){\r\n    if( 100 * $p[$i] <= $t * $k ){\r\n      $t += $p[$i];\r\n    } else {\r\n      my $v = &f( 100 * $p[$i] , $k );\r\n      $s += ( $v - $t );\r\n      $t = $v + $p[$i];\r\n    }\r\n  }\r\n  \r\n  print \"$s\\n\";\r\n}\r\n\r\nexit(0);\r\n\r\nsub f {\r\n  my $v = shift;\r\n  my $d = shift;\r\n  my $v1 = $v % $d;\r\n  if( $v1 > 0 ){\r\n    $v += $d - $v1;\r\n  }\r\n  return ( $v / $d );\r\n}\r\n\r\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\tmy( $n, $k ) = split;\n\tmy( $sum, @p ) = split ' ', <>;\n\t\n\tmy $add = 0;\n\t\n\twhile( @p ){\n\t\tmy $p_next = shift @p;\n\t\t$debug and print \"sum:[$sum], p_next:[$p_next]\";\n\t\t\n\t\tif( $sum * $k < $p_next * 100 ){\n\t\t\tmy $diff = ( int $p_next * 100 / $k ) + !!( $p_next * 100 % $k ) - $sum;\n\t\t\t$add += $diff;\n\t\t\t$sum += $diff + $p_next;\n\t\t\t}\n\t\telse{\n\t\t\t$sum += $p_next;\n\t\t\t}\n\t\t}\n\t\n\tprint $add;\n\t}"}, {"source_code": "use v5.20;\r\nuse integer;\r\nfor ( 1 .. <> ) {\r\n    my ( $n, $k ) = split ' ', <>;\r\n    my @p   = split ' ', <>;\r\n    my $sum = $p[0];\r\n    my $ans = 0;\r\n    for ( 1 .. $n - 1 ) {\r\n        my $t = $p[$_];\r\n        if ( 100 * $t > $k * $sum ) {\r\n            my $r = ( 100 * $t + $k - 1 ) / $k - $sum;\r\n            $ans = $r if $r > $ans;\r\n        }\r\n        $sum += $t;\r\n    }\r\n    say $ans;\r\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n,$k) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @p = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  \r\n  my @a = ($p[0]); $#a = $#p;\r\n  for(my $i=1;$i<$n;$i++){\r\n    $a[$i] = $a[$i-1] + $p[$i];\r\n  }\r\n  my $ru = 0;\r\n  for(my $i=$n-1;$i>0;$i--){\r\n    unless( 100 * $p[$i] <= ( $ru + $a[$i-1] ) * $k ){\r\n      my $v = &f( 100 * $p[$i] , $k );\r\n      my $v1 = $v - ( $ru + $a[$i-1] );\r\n      $ru += $v1;\r\n    }\r\n  }\r\n  print \"$ru\\n\";\r\n}\r\n\r\nexit(0);\r\n\r\nsub f {\r\n  my $v = shift;\r\n  my $d = shift;\r\n  my $v1 = $v % $d;\r\n  if( $v1 > 0 ){\r\n    $v += $d - $v1;\r\n  }\r\n  return ( $v / $d );\r\n}\r\n\r\n"}], "src_uid": "53975eea2503bb47bfd0a5119406aea3"}
{"source_code": "#!/usr/bin/perl\n\n# http://perlmonks.org/?node_id=1196089\n\nuse strict;\nuse warnings;\n\n$\\ = $/;\n\nwhile(<>)\n  {\n  my $dict = $_;\n  my $no_dict = ( join '', ' ', 'a' .. 'z' ) =~ s/[$dict]//gr;\n\n  $_ = <>;\n\n  my($head, $tail) = map length( $_ // '' ), split /\\*/;\n\n  s/\\?/[$dict]/g;\n  s/\\*/ [$no_dict]* /;\n\n  my $qr = qr/^$_/;\n\n  $_ = <>,\n    $head <= length($_) && substr($_, $head, 0, ' '),\n    $tail && $tail <= length($_) && substr($_, -$tail, 0, ' '),\n    print $_ =~ $qr ? \"YES\" : \"NO\"\n      for 1 .. <>;\n  }", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\tmy $dict = $_;\n\t$_ = <>;\n\t\n\ts/\\?/[$dict]/g;\n\ts/\\*/[^$dict]*/;\n\t\n\tmy $qr = qr/^$_$/;\n\t\n\tprint <> =~ $qr ? \"YES\" : \"NO\" for 1 .. <>;\n\t}"}, {"source_code": "@_ = <>; chomp @_; ($g, $t, $n, @q) = @_;\n$y = ($t =~ /\\*/); $l = length($t) - $y;\n$t =~ s{\\?} {\\[$g\\]}g;\n$t =~ s{\\*} {[^$g]*};\n\nfor (@q) {\n\t$r = (length >= $l? /^$t$/: 0);;\n\tprint $r? YES: NO, \"\\n\";\n}\n\n"}, {"source_code": "#!/usr/bin/perl\n\n# http://perlmonks.org/?node_id=1196089\n\nuse strict;\nuse warnings;\n\n$\\ = $/;\n\nwhile(<>)\n  {\n  my $dict = $_;\n  my $no_dict = ( join '', ' ', 'a' .. 'z' ) =~ s/[$dict]//gr;\n\n  $_ = <>;\n\n  my($head, $tail) = map length( $_ // '' ), split /\\*/;\n\n  s/\\?/[$dict]/g;\n  s/\\*/ [$no_dict]* /;\n\n  my $qr = qr/^$_/;\n\n  $_ = <>,\n    $head <= length($_) && substr($_, $head, 0, ' '),\n    $tail && $tail <= length($_) && substr($_, -$tail, 0, ' '),\n    print $_ =~ $qr ? \"YES\" : \"NO\"\n      for 1 .. <>;\n  }\n"}, {"source_code": "#!/usr/bin/perl\n\n# http://perlmonks.org/?node_id=1196089\n\nuse strict;\nuse warnings;\n\n$\\ = $/;\n\nwhile(<>)\n  {\n  chomp;\n  my $dict = $_;\n\n  $_ = <>;\n\n  my($head, $tail) = map length( $_ // '' ), split /\\*/;\n\n  s/\\?/[$dict]/g;\n  s/\\*/ [^$dict ]* /;\n\n  my $qr = qr/^$_/;\n\n  $_ = <>,\n    $head <= length($_) && substr($_, $head, 0, ' '),\n    $tail && $tail <= length($_) && substr($_, -$tail, 0, ' '),\n    print $_ =~ $qr ? \"YES\" : \"NO\"\n      for 1 .. <>;\n  }\n"}], "negative_code": [], "src_uid": "c6633581d7424d670eaa0f8a5c8cc366"}
{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nmy $num = <>;\nmy ($x,$y,$z);\nwhile ($num--) {\n\tmy ($a,$b,$c) = split / /, <>;\n\t$x += $a; \n\t$y += $b;\n\t$c += $c;\n}\nprint !$x && !$y && !$z ? 'YES' : 'NO';\n", "positive_code": [{"source_code": "my $n = int<>;\nmy @arr;\nmy @ans = (0, 0, 0);\npush @arr, [split \" \", <>] for(1..$n);\nfor my $i(0..$n-1) {\n    $ans[$_] += $arr[$i][$_] for(0..2);\n}\nprint (!$ans[0] && !$ans[1] && !$ans[2] ? \"YES\\n\" : \"NO\\n\");"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\nour ($x, $y, $z) = (0) x 3;\nwhile ($n-- > 0) {\n\t($xx, $yy, $zz) = split / /, <>;\n\t$x += $xx;\n\t$y += $yy;\n\t$z += $zz;\n}\n$x==0 and $y==0 and $z==0 and say \"YES\" or say \"NO\";"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy ($x, $y, $z) = (0, 0, 0);\nfor (1..$n) {\n    my @a = split ' ', <>;\n    $x += $a[0];\n    $y += $a[1];\n    $z += $a[2];\n}\nprint $x | $y | $z ? \"NO\\n\" : \"YES\\n\";\n"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n\nfor($i=0;$i<$n;$i++)\n{\n\n  $s = <STDIN>;\n\n  ($a, $b, $c) = split / +/, $s;\n\n  $x += $a;\n  $y += $b;\n  $z += $c;\n\n}\n\nif( !$x && !$y && !$z )\n{\n\n  print \"YES\";\n\n}\nelse\n{\n\n  print \"NO\";\n\n}\n"}, {"source_code": "my $num = <>;\nchomp $num;\nmy @force = (0, 0, 0);\nfor (1..$num) {\n    my $line = <>;\n    chomp $line;\n    my @new = split ' ', $line;\n    $force[$_] += $new[$_] for (0..2);\n}\nmy $flag=1;\nfor(0..2) {\n    $flag = 0 if $force[$_];\n}\n$flag ? print \"YES\" : print \"NO\";"}], "negative_code": [], "src_uid": "8ea24f3339b2ec67a769243dc68a47b2"}
{"source_code": "use List::Util qw[min max];$an=0;$x=0;$i=0;@a=split(' ',<>);@l=split(' ',<>);$c=0;$p=0;for(1..@a[0]){$c=max(0,int(($p-@l[$i]+@a[1])/@a[1]));$p=@l[$i]+$c*@a[1];$an+=$c;$i+=1;}print \"$an\\n\";\n", "positive_code": [{"source_code": "<>=~/ /;\n@_=split/ /,<>;\n$k=shift @_;\n$n=0;\nfor (@_){\nwhile($_<=$k){  \nwhile ($_+100000*$' <= $k) { $_+=100000*$'; $n+=100000 }\nwhile ($_+10000*$' <= $k) { $_+=10000*$'; $n+=10000 }\nwhile ($_+1000*$' <= $k) { $_+=1000*$'; $n+=1000 }\nwhile ($_+100*$' <= $k) { $_+=100*$'; $n+=100 }\nwhile ($_+10*$' <= $k) { $_+=10*$'; $n+=10 }\n$_+=$'; $n++\n} \n$k=$_;\n}\nprint $n"}], "negative_code": [], "src_uid": "0c5ae761b046c021a25b706644f0d3cd"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($s, $n) = split / /, <>;\npush @arr, [split / /, <>] foreach(1..$n);\n@arr = sort {$a->[0] <=> $b->[0]} @arr;\nforeach my $d (@arr) {\n\t# say \"$d \", $d->[0], \" \", $d->[1];\n\t$s<=$d->[0] and say \"NO\" and exit;\n\t$s += $d->[1];\n}\nsay \"YES\";\n", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\n$\\ = \"\\n\";\n\nmy ($s, $n) = split ' ', <>;\nmy @dragons;\nfor (1..$n) {\n    push @dragons, [split ' ', <>];\n}\n\n@dragons = sort { $a->[0] <=> $b->[0] } @dragons;\n\nmy $dead;\nfor my $dragon (@dragons) {\n    my ($strength, $increment) = @$dragon;\n    if ($s > $strength) {\n        $s += $increment;\n    } else {\n        $dead = 1;\n        last;\n    }\n}\n\nprint $dead ? 'NO' : 'YES';\n"}, {"source_code": "$DEBUG = 0;\nchomp($line=<STDIN>);\n($str, $n) = $line =~ /(\\d+)\\s+(\\d+)/;\n\nmy @dragons = ();\nwhile($n-- > 0) {\n\tchomp($line=<STDIN>);\n\t($dstr, $inc) = $line =~ /(\\d+)\\s+(\\d+)/;\n\tpush(@dragons, {strength=>$dstr, powerup => $inc});\n}\n\nforeach $dragon (sort by_strength @dragons) {\n\tprint \"Battle with $str against \".$dragon->{strength}.\"\\n\" if $DEBUG;\n\tif($str <= $dragon->{strength}) {\n\t\tprint \"NO\\n\";\n\t\texit; \n\t}\n\t$str += $dragon->{powerup};\n}\nprint \"YES\\n\";\n\nsub by_strength {\n\t$a->{strength} <=> $b->{strength};\n}"}, {"source_code": "my ($x, $n) = split \" \", <>;\nmy ($str, $bonus) = (0, 0);\nmy $ans = \"YES\\n\";\nmy @arr;\npush @arr, [split \" \", <>] for (1..$n);\n@arr = sort {$a->[0] <=> $b->[0]} @arr;\n# print \"$arr[$_][0] $arr[$_][1]\\n\" for(0..$n-1);\nfor my $i(0..$n-1) {\n    if ($x > $arr[$i][0]) {\n        $x += $arr[$i][1];\n    }\n    else {\n        $ans = \"NO\\n\";\n    }\n}\nprint $ans;\n"}], "negative_code": [{"source_code": "\nmy ($x, $n) = split \" \", <>;\nmy ($str, $bonus) = (0, 0);\nmy $ans = \"YES\\n\";\nmy @arr;\npush @arr, [split \" \", <>] for (1..$n);\n# print \"$arr[$_][0] $arr[$_][1]\\n\" for(0..$n-1);\n@arr = sort {@{$a}[0] > @{$b}[0]} @arr;\n@arr = reverse @arr;\n@arr = sort {@{$a}[0] > @{$b}[0]} @arr;\n# print \"$arr[$_][0] $arr[$_][1]\\n\" for(0..$n-1);\nfor my $i(0..$n-1) {\n    # print \"$x $arr[$i][0] $arr[$i][1]\\n\";\n    if ($x > $arr[$i][0]) {\n        $x += $arr[$i][1];\n    }\n    else {\n        $ans = \"NO\\n\";\n    }\n}\nprint $ans;\n"}, {"source_code": "\nmy ($x, $y) = split \" \", <>;\nmy ($str, $bonus, $n) = (0, 0, 0);\nmy @arr;\nwhile(<>) {\n    push @arr, [split \" \", $_];\n    $n++;\n}\n@arr = sort {@{$a}[0] > @{$b}[0]} @arr;\nmy $ans = \"YES\\n\";\nfor my $i(0..$n-1) {\n    if ($x > $arr[$i][0]) {\n        $x += $arr[$i][1];\n    }\n    else {\n        $ans = \"NO\\n\";\n    }\n}\nprint $ans;\n"}, {"source_code": "my ($x, $n) = split \" \", <>;\nmy ($str, $bonus) = (0, 0);\nmy @arr;\nwhile(<>) {\n    push @arr, [split \" \", $_];\n}\n@arr = sort {@{$a}[0] > @{$b}[0]} @arr;\nmy $ans = \"YES\\n\";\nfor my $i(0..$n-1) {\n    if ($x > $arr[$i][0]) {\n        $x += $arr[$i][1];\n    }\n    else {\n        $ans = \"NO\\n\";\n    }\n}\nprint $ans;\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($s, $n) = split / /, <>;\npush @arr, [split / /, <>] foreach(1..$n);\n@arr = sort {$a->[0] <=> $b->[0]} @arr;\nforeach my $d (@arr) {\n\t# say \"$d \", $d->[0], \" \", $d->[1];\n\t$s<$d->[0] and say \"NO\" and exit;\n\t$s += $d->[1];\n}\nsay \"YES\";\n"}, {"source_code": "use strict;\nuse warnings;\n\n$\\ = \"\\n\";\n\nmy ($s, $n) = split ' ', <>;\nmy @dragons;\nfor (1..$n) {\n    push @dragons, [split ' ', <>];\n}\n\nmy $dead;\nfor my $dragon (@dragons) {\n    my ($strength, $increment) = @$dragon;\n    if ($s > $strength) {\n        $s += $increment;\n    } else {\n        $dead = 1;\n        last;\n    }\n}\n\nprint $dead ? 'NO' : 'YES';\n"}], "src_uid": "98f5b6aac08f48f95b2a8ce0738de657"}
{"source_code": "for(1..<>){$n=<>;@a=split/\\s/,<>;$q=0;for(0..$n-1){$q++if@a[$_]&&!($_&&@a[$_-1])}print$q>2?2:$q,\" \"}", "positive_code": [{"source_code": "for(1..<>){<>;@a=split/\\s/,<>;$q=0;for(0..$#a){$q++if@a[$_]&&!($_&&@a[$_-1])}print$q>2?2:$q,\" \"}"}], "negative_code": [], "src_uid": "da3d1b2615d51044a7b43bd0ce939f4c"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $c = 0;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\tmy( $A, $B ) = sort { $a <=> $b } @_[ $i, $i + 1 ];\n\t\t\n\t\twhile( $B > $A * 2 ){\n\t\t\t$A *= 2;\n\t\t\t$c ++;\n\t\t\t}\n\t\t}\n\t\n\tprint $c;\n\t}", "positive_code": [{"source_code": "for(1..<>)\r\n{\r\n        <>;\r\n        chomp(my $in = <>);\r\n        my @a = split / /, $in;\r\n        my $s=0;\r\n        for (my $i = 1; $i < scalar @a; $i++) {\r\n                my $max = @a[$i] > @a[$i-1] ? @a[$i] : @a[$i-1];\r\n                my $min = @a[$i] < @a[$i-1] ? @a[$i] : @a[$i-1];\r\n                while ($min < $max/2) {\r\n                        $min *= 2;\r\n                        $s++;\r\n                }\r\n        }\r\n        print $s, \"\\n\";\r\n}\r\nexit;"}], "negative_code": [{"source_code": "for(1..<>) {\r\n        chomp(my $n = <>);\r\n        if ($n == 1) { print \"1\\n1\\n\"; next;}\r\n        \r\n        $i = 0;\r\n        my @ans = ();\r\n        my $x = 1;\r\n        while ($n > $x) {\r\n                if ($x = $n%10**++$i) {\r\n                        push(@ans, $x);\r\n                        $n -= $x;\r\n                }\r\n        }\r\n        print scalar(@ans), \"\\n\";\r\n        print join \" \", @ans, \"\\n\";\r\n}\r\nexit;"}, {"source_code": "for(1..<>)\r\n{\r\n        chomp($in = <>);\r\n        ($a, $b) = split / /, $in;\r\n        $c = abs($a - $b);\r\n        my $s = 0;\r\n        $s += int($c/10);\r\n        if ($s%10) {\r\n                $s += 1;\r\n        }\r\n        print $s, \"\\n\";\r\n}"}], "src_uid": "a544dd9fd96379f66a960de6f973dd50"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $s = 0;\r\n  my $n1 = 0;\r\n  for(my $i=0;$i<$n;$i++){\r\n    $s += $A[$i];\r\n    $n1++ if $A[$i]==1;\r\n  }\r\n  if( $s % 2 == 0 ){\r\n    if( $n % 2 == 1 and $n1 == 0 ){\r\n      print \"NO\\n\";\r\n    } else {\r\n      print \"YES\\n\";\r\n    }\r\n  } else {\r\n    print \"NO\\n\";\r\n  }\r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "for (1..<>) {\r\n        chomp (my $n = <>);\r\n        chomp (my $in = <>);\r\n        @a = split / /, $in;\r\n        $s = 0;\r\n        $oc = 0;\r\n        foreach (@a) {\r\n                $s+= $_;\r\n                $_ == 1 and $oc++;\r\n        }\r\n        if ($s%2 || ($oc == 0 && $n%2)) {\r\n                print \"NO\\n\";\r\n        } else {\r\n                print \"YES\\n\";\r\n        }\r\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h = qw( 1 0 2 0 );\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\t$h{ 2 } %= 2;\n\t\n\tif( $h{ 1 } > 2 ){\n\t\t$h{ 1 } %= 2;\n\t\t$h{ 1 } or $h{ 1 } = 2;\n\t\t}\n\t\n\tprint do {\n\t\tif( 0 ){ ; }\n\t\telsif( $h{ 2 } == 0 and $h{ 1 } == 0 ){ \"YES\" }\n\t\telsif( $h{ 2 } == 0 and $h{ 1 } == 1 ){ \"NO\" }\n\t\telsif( $h{ 2 } == 0 and $h{ 1 } == 2 ){ \"YES\" }\n\t\telsif( $h{ 2 } == 1 and $h{ 1 } == 0 ){ \"NO\" }\n\t\telsif( $h{ 2 } == 1 and $h{ 1 } == 1 ){ \"NO\" }\n\t\telsif( $h{ 2 } == 1 and $h{ 1 } == 2 ){ \"YES\" }\n\t\t};\n\t}"}], "negative_code": [], "src_uid": "1d9d34dca11a787d6e2345494680e717"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\nwhile (<>){\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$_=<>; chomp;\ns/-?\\d+/$sum+=$&/eg;\ns/\\S//g; s/$/ /;\n$sum+= 1e4 * length;\nprint (($sum % length )? (-1+ length): (length))\n\n}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\nsub fact{\n\tmy $i= shift;   my $j= 1;\n\t$j*=$i-- while $i;\n\treturn $j\n}\n\n# Transpose \"charbox\"\nsub trans{\n\tmy @t=(); my $i=0; \n\t$i=0, s/./$t[$i++].=$&/eg for @_;\n\treturn @t\n}\n\nsub rotL{\n\tmy @t=(); my $i=0; my $j;\n\tfor (@_){\n\t\t$i=0, $j=length; $t[$i++].=chop while $j--\n\t}\n\treturn @t\n}\n\nsub rotR{\n    my @m=@_;  chomp @m;   my @t=();\n\tmy $i= length $m[0];\n\twhile ($i--){\n\t\t$t[$i]=~s/^/chop/e for @m\n\t}\nreturn @t\n}\n\nsub revlines{\n\t$_=reverse $_ for @_;\n\treturn @_\n}\n\n# Transpose \"value sets\" ## slow?\nsub trans_s{\n\tmy @t=(); my $j;\n\t$j=0, s/\\S+/($t[$j++].=\"$& \")?$&:$&/eg for @_;\n\tchop @t;\nreturn @t\n}\n\n# rotL_s\n# rotR_s\n\n# slow?\nsub revlines_s{\n\t$_=join\" \", reverse split/\\s+/ \tfor @_;\n\treturn @_\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n\tmy @m=sort @_; my @u;\n\tpush @u, my $i=shift @m;\n\t$i eq $_ or push @u, $i=$_ for @m;\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse List::Util qw(sum);\n\nchomp(my $n = <>);\nchomp($_ = <>);\nmy $res = $n - ((sum split) % $n == 0 ? 0 : 1);\nprint $res, \"\\n\";\n"}, {"source_code": "use List::Util qw(sum);\n$n=<>;\n$_=<>;\nprint((sum split)%$n?$n-1:$n)\n"}, {"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 21:21:55 IST 2012\n# File Name: b.pl\n# USAGE: \n#       b.pl \n# \n# \n#------------------------------------------------\nchomp (my $n = <STDIN>);\nchomp (my $sum = eval join '+', split /\\s+/, <STDIN>);\n\nif ($sum % $n == 0) {\n        print $n\n} else {\n        print 1 > $n - 1 ? 1 : $n - 1\n}\n"}, {"source_code": "<>;\n$sum+=$_ for @_=split/ /,<>;\n$sum+= 1e4 * @_;\nprint (($sum % @_ )? (-1+ @_): (0+ @_))\n"}], "negative_code": [{"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 21:21:55 IST 2012\n# File Name: b.pl\n# USAGE: \n#       b.pl \n# \n# \n#------------------------------------------------\nchomp (my $n = <STDIN>);\nchomp (my $sum = eval join '+', split /\\s+/, <STDIN>);\n\nprint $n - 1;\n#int $sum / $n;\n"}, {"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 21:21:55 IST 2012\n# File Name: b.pl\n# USAGE: \n#       b.pl \n# \n# \n#------------------------------------------------\nchomp (my $n = <STDIN>);\nchomp (my $sum = eval join '+', split /\\s+/, <STDIN>);\n\nprint 1 > $n - 1 ? 1 : $n - 1;\n"}, {"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 21:21:55 IST 2012\n# File Name: b.pl\n# USAGE: \n#       b.pl \n# \n# \n#------------------------------------------------\nchomp (my $n = <STDIN>);\nchomp (my $sum = eval join '+', split /\\s+/, <STDIN>);\n\nprint int $sum / $n;\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\nwhile (<>){\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n\n$n=@_=split/ /,<>;\n$x=1;\nfor ($i=0; $i<$n; $i++){\n$sum = 0;\n\tfor ($j=$i; $j<$n; $j++){\n\t$sum += $_[$j]; \n#\t\tprint \"$sum\";\n\t$k=$j-$i+1;\n\t$sum % $k or $k>$x and $x=$k;\n#\t\tprint \" $x\\n\";\n\t}\n}\nprint \"$x\";\n\n}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\nsub fact{\n\tmy $i= shift;   my $j= 1;\n\t$j*=$i-- while $i;\n\treturn $j\n}\n\n# Transpose \"charbox\"\nsub trans{\n\tmy @t=(); my $i=0; \n\t$i=0, s/./$t[$i++].=$&/eg for @_;\n\treturn @t\n}\n\nsub rotL{\n\tmy @t=(); my $i=0; my $j;\n\tfor (@_){\n\t\t$i=0, $j=length; $t[$i++].=chop while $j--\n\t}\n\treturn @t\n}\n\nsub rotR{\n    my @m=@_;  chomp @m;   my @t=();\n\tmy $i= length $m[0];\n\twhile ($i--){\n\t\t$t[$i]=~s/^/chop/e for @m\n\t}\nreturn @t\n}\n\nsub revlines{\n\t$_=reverse $_ for @_;\n\treturn @_\n}\n\n# Transpose \"value sets\" ## slow?\nsub trans_s{\n\tmy @t=(); my $j;\n\t$j=0, s/\\S+/($t[$j++].=\"$& \")?$&:$&/eg for @_;\n\tchop @t;\nreturn @t\n}\n\n# rotL_s\n# rotR_s\n\n# slow?\nsub revlines_s{\n\t$_=join\" \", reverse split/\\s+/ \tfor @_;\n\treturn @_\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n\tmy @m=sort @_; my @u;\n\tpush @u, my $i=shift @m;\n\t$i eq $_ or push @u, $i=$_ for @m;\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\nwhile (<>){\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n\n$n=@_=split/ /,<>;\n$_+=1e4 for @_;\n$x=1;\nfor ($i=0; $i<$n; $i++){\n$sum = 0;\n\tfor ($j=$i; $j<$n; $j++){\n\t$sum += $_[$j]; \n#\t\tprint \"$sum\";\n\t$k=$j-$i+1;\n\t$sum % $k or $k>$x and $x=$k;\n#\t\tprint \" $x\\n\";\n\t}\n}\nprint \"$x\";\n\n}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\nsub fact{\n\tmy $i= shift;   my $j= 1;\n\t$j*=$i-- while $i;\n\treturn $j\n}\n\n# Transpose \"charbox\"\nsub trans{\n\tmy @t=(); my $i=0; \n\t$i=0, s/./$t[$i++].=$&/eg for @_;\n\treturn @t\n}\n\nsub rotL{\n\tmy @t=(); my $i=0; my $j;\n\tfor (@_){\n\t\t$i=0, $j=length; $t[$i++].=chop while $j--\n\t}\n\treturn @t\n}\n\nsub rotR{\n    my @m=@_;  chomp @m;   my @t=();\n\tmy $i= length $m[0];\n\twhile ($i--){\n\t\t$t[$i]=~s/^/chop/e for @m\n\t}\nreturn @t\n}\n\nsub revlines{\n\t$_=reverse $_ for @_;\n\treturn @_\n}\n\n# Transpose \"value sets\" ## slow?\nsub trans_s{\n\tmy @t=(); my $j;\n\t$j=0, s/\\S+/($t[$j++].=\"$& \")?$&:$&/eg for @_;\n\tchop @t;\nreturn @t\n}\n\n# rotL_s\n# rotR_s\n\n# slow?\nsub revlines_s{\n\t$_=join\" \", reverse split/\\s+/ \tfor @_;\n\treturn @_\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n\tmy @m=sort @_; my @u;\n\tpush @u, my $i=shift @m;\n\t$i eq $_ or push @u, $i=$_ for @m;\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}\n"}, {"source_code": "$sum+=$_ for @_=split/ /,<>;\n$sum+= 1e4 * @_;\nprint (($sum % @_ )? (-1+ @_): (0+ @_))"}], "src_uid": "71cead8cf45126902c518c9ce6e5e186"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @h = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $c = 0;\r\n  my $r = 'YES';\r\n  for(my $i=0;$i<$n;$i++){\r\n    if( $h[$i] < $i ){\r\n      if( $c < $i - $h[$i] ){\r\n        $r = 'NO';\r\n        last;\r\n      }\r\n      $c -= $i - $h[$i];\r\n    } else {\r\n      $c += $h[$i] - $i;\r\n    }\r\n  }\r\n  print \"$r\\n\";\r\n}\r\n\r\nexit(0);\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nOUTER:\nwhile(<>){\n\t\n\t@_ = split ' ', <>;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tif( $_[ $i ] < $i ){\n\t\t\tprint \"NO\";\n\t\t\tnext OUTER;\n\t\t\t}\n\t\telse{\n\t\t\t$_[ $i + 1 ] += $_[ $i ] - $i;\n\t\t\t}\n\t\t}\n\t\n\tprint \"YES\";\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nOUTER:\nwhile(<>){\n\t\n\tif( $_ == 1 ){\n\t\tprint \"NO\";\n\t\t<>;\n\t\tnext;\n\t\t}\n\t\n\t@_ = split ' ', <>;\n\t\n\tfor my $i ( 0 .. @_ - 1 ){\n\t\tif( $_[ $i ] < $i ){\n\t\t\tprint \"NO\";\n\t\t\tnext OUTER;\n\t\t\t}\n\t\telse{\n\t\t\t$_[ $i + 1 ] += $_[ $i ] - $i;\n\t\t\t}\n\t\t}\n\t\n\tprint \"YES\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t\n\tif( $_ == 1 ){\n\t\tprint \"NO\";\n\t\t<>;\n\t\tnext;\n\t\t}\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @_;\n\t\n\tif( @_ * ( @_ - 1 ) / 2 > $sum ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t\n\tif( $_ == 1 ){\n\t\tprint \"NO\";\n\t\tnext;\n\t\t}\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @_;\n\t\n\tif( @_ * ( @_ - 1 ) / 2 > $sum ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @_;\n\t\n\tif( @_ * ( @_ - 1 ) / 2 > $sum ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\t}\n\t\n\t\n\t}"}], "src_uid": "7a8c4ba98a77097faff625b94889b365"}
{"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>", "positive_code": [{"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>"}, {"source_code": "$a=<>;\n$b=<>;\n@n=(1..$a+$b+1);\nfor (1..$a+$b+1){\n\t$a-- > 0 and push @a, shift @n;\n\t$b-- > 0 and unshift @b, shift @n;\n\t}\npush @a, @n;\nprint \"@a @b\""}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}, {"source_code": "$_ = <> ,$, = $\",\nprint 1 .. $_ ++ , reverse $_ .. $_ + <>\n"}], "negative_code": [], "src_uid": "add2285f3f710eb41185d6a83e44b37a"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\n\nmy @dots;\npush @dots, <> for ($n);\n\nmy $count = 0;\n\nforeach my $dot (@dots)\n{\n    my $index = shift;\n    my ($x, $y) = split / /, $dot;\n    my $bits;\n\n    foreach (@dots)\n    {\n        my ($x_, $y_) = split / /, $_;\n\n            if ($x eq $x_)\n            {\n                $bits |= 1 if ($y_ > $y);\n                $bits |= 2 if ($y_ < $y);\n            }\n\n            if ($y eq $y_)\n            {\n                $bits |= 4 if ($x_ < $x);\n                $bits |= 8 if ($x_ > $x);\n            }\n\n    }\n\n    $count++ if ($bits eq 15);\n}\n\nprint $count, \"\\n\";", "positive_code": [{"source_code": "#!/usr/local/bin/perl\n\nuse strict;\n$|=1;\n\nmy $cnt = <>;\nmy $points = {};\nfor( my $i=0; $i<$cnt; $i++ ) {\n\tmy $line = <>;\n\tchomp($line);\n\t$line =~ /^([\\d\\.\\-]+) ([\\d\\.\\-]+)$/;\n\t$points->{ $1.'_'.$2 }=1;\n}\n\nmy $n=0;\nmy @k = keys %$points;\nforeach my $coord (@k) {\n#\tprint \"For coord $coord\\n\";\n\tmy ($x, $y) = split('_', $coord);\n\t#check x\n\tmy @xl = grep { /^([\\d\\.\\-]+)_${y}$/ && $1<$x } @k;\n\tmy @xg = grep { /^([\\d\\.\\-]+)_${y}$/ && $1>$x } @k;\n\n\t#check y\n\tmy @yl = grep { /^${x}_([\\d\\.\\-]+)$/ && $1<$y } @k;\n\tmy @yg = grep { /^${x}_([\\d\\.\\-]+)$/ && $1>$y } @k;\n\n\t$n++ if( @xl && @xg && @yl && @yg );\n#\tprint \"x less: \", join(\"; \", @xl), \"\\n\";\n#\tprint \"x grea: \", join(\"; \", @xg), \"\\n\";\n#\tprint \"y less: \", join(\"; \", @yl), \"\\n\";\n#\tprint \"y grea: \", join(\"; \", @yg), \"\\n\";\n}\n\nprint $n, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nuse warnings;\nuse strict;\nchomp(my $n = <STDIN>);\nmy @pts = ();\nwhile($n-- > 0){\n\tmy @tmp = split(/[\\s\\/n]/,<STDIN>);\n\tpush(@pts,\\@tmp);\n}\nmy @check = (0,0,0,0);\nmy $count = 0;\nforeach my $pt (@pts) {\n\t@check = (0,0,0,0);\n\tforeach my $otherpt (@pts) {\n\t\tif($$pt[0]==$$otherpt[0]){\n\t\t\t$check[0] = 1 if($$pt[1]>$$otherpt[1]);\n\t\t\t$check[1] = 1 if($$pt[1]<$$otherpt[1]);\n\t\t}\n\t\telsif($$pt[1]==$$otherpt[1]){\n\t\t\t$check[2] = 1 if($$pt[0]>$$otherpt[0]);\n\t\t\t$check[3] = 1 if($$pt[0]<$$otherpt[0]);\n\t\t}\n\t}\n\tmy $checksum = 0;\n\t$checksum += $_ for @check;\n\t$count++ if($checksum == 4);\n}\n\nprint $count;"}, {"source_code": "#!/usr/bin/perl\n$n=<>;\nfor($i=0; $i<$n; $i++){\n\t($tx, $ty) = ($x[$i], $y[$i]) = split(/[ \\n]/, <>);\n\tif(! exists($minx{$ty}) || $tx < $minx{$ty}){$minx{$ty} = $tx;}\n\tif(! exists($maxx{$ty}) || $tx > $maxx{$ty}){$maxx{$ty} = $tx;}\n\tif(! exists($miny{$tx}) || $ty < $miny{$tx}){$miny{$tx} = $ty;}\n\tif(! exists($maxy{$tx}) || $ty > $maxy{$tx}){$maxy{$tx} = $ty;}\n}\n$cnt=0;\nfor($i=0; $i<$n; $i++){\n\tif($x[$i]>$minx{$y[$i]}\n\t&& $x[$i]<$maxx{$y[$i]}\n\t&& $y[$i]>$miny{$x[$i]}\n\t&& $y[$i]<$maxy{$x[$i]}\n\t){\n\t\t$cnt++;\n\t}\n#\tprint \"$x[$i] $y[$i] $cnt\\n\";\n}\nprint \"$cnt\\n\";\n\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n = <>;\nmy @dots;\npush @dots, <> for ($n);\n\nmy $count = 0;\nforeach my $dot (@dots)\n{\n    my $index = shift;\n    my ($x, $y) = split /\\s/, $dot;\n    my $bits;\n\n    foreach (@dots)\n    {\n        my ($x_, $y_) = split /\\s/;\n\n        $bits |= ($y_ < $y)? 1 : (($y_ > $y) ? 2 : 0) if ($x eq $x_);\n        $bits |= ($x_ < $x)? 4 : (($x_ > $x) ? 8 : 0) if ($y eq $y_);\n    }\n\n    $count++ if ($bits eq 15);\n}\n\nprint $count, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\n\nmy @dots;\npush @dots, <> for ($n);\n\nmy $count = 0;\n\nsub is_super($)\n{\n    my $index = shift;\n    my ($x, $y) = split / /, $dots[$index];\n    chomp ($y);\n    my $score = 0;\n    my ($left, $right, $up, $down) = (0,0,0,0);\n\n    foreach (@dots)\n    {\n        chomp($_);\n        my ($x_, $y_) = split / /, $_;\n\n            if ($x eq $x_)\n            {\n                $up = ($y_ > $y) if (!$up);\n                $down = ($y_ < $y) if (!$down);\n            }\n\n            if ($y eq $y_)\n            {\n                $left = ($x_ < $x) if (!$left);\n                $right = ($x_ > $x) if (!$right);\n            }\n\n    }\n\n    $count++ if ($left && $right && $up && $down);\n}\n\nis_super($_) for (0..$n-1);\n\nprint $count, \"\\n\";"}, {"source_code": "while (<>){\n    @_=@A=();\n    for (1..$_){\n        push @_, \"\".<>;\n        }\n    chomp @_;\n    for (@_){\n        / /;\n        $a=$`;$b=$';\n        $d=$u=$r=$l=0;\n        for (@_){\n            / /;\n            $x=$`,$y=$';\n            \n            if ($a==$x and $b>$y){$d++}\n            if ($a==$x and $b<$y){$u++}\n            if ($a>$x and $b==$y){$l++}\n            if ($a<$x and $b==$y){$r++}\n            }\n        if ($d and $u and $l and $r){\n            push @A, $_;\n            }\n        \n        }\n    print 0+@A, \"\\n\";    \n    }"}], "negative_code": [{"source_code": "#!/usr/local/bin/perl\n\nuse strict;\n$|=1;\n\nmy $cnt = <>;\nmy $points = {};\nfor( my $i=0; $i<$cnt; $i++ ) {\n\tmy $line = <>;\n\t$line =~ /(\\d+) (\\d+)/;\n\t$points->{ $1.'_'.$2 }=1;\n}\n\nmy $n=0;\nmy @k = keys %$points;\nforeach my $coord (@k) {\n\tprint \"For coord $coord\\n\";\n\tmy ($x, $y) = split('_', $coord);\n\t#check x\n\tmy @xl = grep { /(\\d+)_${y}/ && $1<$x } @k;\n\tmy @xg = grep { /(\\d+)_${y}/ && $1>$x } @k;\n\n\t#check y\n\tmy @yl = grep { /${x}_(\\d+)/ && $1<$y } @k;\n\tmy @yg = grep { /${x}_(\\d+)/ && $1>$y } @k;\n\n\t$n++ if( @xl && @xg && @yl && @yg );\n\tprint \"x less: \", join(\"; \", @xl), \"\\n\";\n\tprint \"x grea: \", join(\"; \", @xg), \"\\n\";\n\tprint \"y less: \", join(\"; \", @yl), \"\\n\";\n\tprint \"y grea: \", join(\"; \", @yg), \"\\n\";\n\n}\n\nprint $n, \"\\n\";\n"}, {"source_code": "#!/usr/local/bin/perl\n\nuse strict;\n$|=1;\n\nmy $cnt = <>;\nmy $points = {};\nfor( my $i=0; $i<$cnt; $i++ ) {\n\tmy $line = <>;\n\t$line =~ /(\\d+) (\\d+)/;\n\t$points->{ $1.'_'.$2 }=1;\n}\n\nmy $n=0;\nmy @k = keys %$points;\nforeach my $coord (@k) {\n#\tprint \"For coord $coord\\n\";\n\tmy ($x, $y) = split('_', $coord);\n\t#check x\n\tmy @xl = grep { /(\\d+)_${y}/ && $1<$x } @k;\n\tmy @xg = grep { /(\\d+)_${y}/ && $1>$x } @k;\n\n\t#check y\n\tmy @yl = grep { /${x}_(\\d+)/ && $1<$y } @k;\n\tmy @yg = grep { /${x}_(\\d+)/ && $1>$y } @k;\n\n\t$n++ if( @xl && @xg && @yl && @yg );\n#\tprint \"x less: \", join(\"; \", @xl), \"\\n\";\n#\tprint \"x grea: \", join(\"; \", @xg), \"\\n\";\n#\tprint \"y less: \", join(\"; \", @yl), \"\\n\";\n#\tprint \"y grea: \", join(\"; \", @yg), \"\\n\";\n}\n\nprint $n, \"\\n\";\n"}, {"source_code": "#!/usr/local/bin/perl\n\nuse strict;\n$|=1;\n\nmy $cnt = <>;\nmy $points = {};\nfor( my $i=0; $i<$cnt; $i++ ) {\n\tmy $line = <>;\n\t$line =~ /([\\d\\.\\-]+) ([\\d\\.\\-]+)/;\n\t$points->{ $1.'_'.$2 }=1;\n}\n\nmy $n=0;\nmy @k = keys %$points;\nforeach my $coord (@k) {\n#\tprint \"For coord $coord\\n\";\n\tmy ($x, $y) = split('_', $coord);\n\t#check x\n\tmy @xl = grep { /([\\d\\.\\-]+)_${y}/ && $1<$x } @k;\n\tmy @xg = grep { /([\\d\\.\\-]+)_${y}/ && $1>$x } @k;\n\n\t#check y\n\tmy @yl = grep { /${x}_([\\d\\.\\-]+)/ && $1<$y } @k;\n\tmy @yg = grep { /${x}_([\\d\\.\\-]+)/ && $1>$y } @k;\n\n\t$n++ if( @xl && @xg && @yl && @yg );\n#\tprint \"x less: \", join(\"; \", @xl), \"\\n\";\n#\tprint \"x grea: \", join(\"; \", @xg), \"\\n\";\n#\tprint \"y less: \", join(\"; \", @yl), \"\\n\";\n#\tprint \"y grea: \", join(\"; \", @yg), \"\\n\";\n}\n\nprint $n, \"\\n\";\n"}, {"source_code": "#!/usr/local/bin/perl\n\nuse strict;\n$|=1;\n\nmy $cnt = <>;\nmy $points = {};\nfor( my $i=0; $i<$cnt; $i++ ) {\n\tmy $line = <>;\n\t$line =~ /([\\d\\.]+) ([\\d\\.]+)/;\n\t$points->{ $1.'_'.$2 }=1;\n}\n\nmy $n=0;\nmy @k = keys %$points;\nforeach my $coord (@k) {\n#\tprint \"For coord $coord\\n\";\n\tmy ($x, $y) = split('_', $coord);\n\t#check x\n\tmy @xl = grep { /([\\d\\.]+)_${y}/ && $1<$x } @k;\n\tmy @xg = grep { /([\\d\\.]+)_${y}/ && $1>$x } @k;\n\n\t#check y\n\tmy @yl = grep { /${x}_([\\d\\.]+)/ && $1<$y } @k;\n\tmy @yg = grep { /${x}_([\\d\\.]+)/ && $1>$y } @k;\n\n\t$n++ if( @xl && @xg && @yl && @yg );\n#\tprint \"x less: \", join(\"; \", @xl), \"\\n\";\n#\tprint \"x grea: \", join(\"; \", @xg), \"\\n\";\n#\tprint \"y less: \", join(\"; \", @yl), \"\\n\";\n#\tprint \"y grea: \", join(\"; \", @yg), \"\\n\";\n}\n\nprint $n, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n$n=<>;\nfor($i=0; $i<$n; $i++){\n\t($tx, $ty) = ($x[$i], $y[$i]) = split(/[ \\n]/, <>);\n\tif(! exists($minx{$ty}) || $tx < $minx{$ty}){$minx{$ty} = $tx;}\n\tif(! exists($maxx{$ty}) || $tx > $maxx{$ty}){$maxx{$ty} = $tx;}\n\tif(! exists($miny{$tx}) || $ty < $miny{$tx}){$miny{$tx} = $ty;}\n\tif(! exists($maxy{$tx}) || $ty > $maxy{$tx}){$maxy{$tx} = $ty;}\n}\nfor($i=0; $i<$n; $i++){\n\tif($x[$i]>$minx{$y[$i]}\n\t&& $x[$i]<$maxx{$y[$i]}\n\t&& $y[$i]>$miny{$x[$i]}\n\t&& $y[$i]<$maxy{$x[$i]}\n\t){\n\t\t$cnt++;\n\t}\n#\tprint \"$x[$i] $y[$i] $cnt\\n\";\n}\nprint \"$cnt\\n\"\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\n\nmy @dots;\npush @dots, <> for ($n);\n\nmy $count = 0;\n\nsub is_super($)\n{\n    my $index = shift;\n    my ($x, $y) = split / /, $dots[$index];\n    chomp ($y);\n    my $score = 0;\n\n    foreach (@dots)\n    {\n        chomp($_);\n        my ($x_, $y_) = split / /, $_;\n\n        $score++ if (($x > $x_) and ($y eq $y_));\n        $score++ if (($x < $x_) and ($y eq $y_));\n        $score++ if (($x eq $x_) and ($y > $y_));\n        $score++ if (($x eq $x_) and ($y < $y_));\n    }\n\n    $count++ if ($score >= 4);\n}\n\nis_super($_) for (0..$n-1);\n\nprint $count, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\n\nmy @dots;\npush @dots, <> for ($n);\n\nmy $count = 0;\n\nsub is_super($)\n{\n    my $index = shift;\n    my ($x, $y) = split / /, $dots[$index];\n    chomp ($y);\n    my $score = 0;\n\n    foreach (@dots)\n    {\n        chomp($_);\n        my ($x_, $y_) = split / /, $_;\n\n        if (($x_ ne $x) and ($y_ ne $y))\n        {\n            $score++ if ($x > $x_ and $y eq $y_);\n            $score++ if ($x < $x_ and $y eq $y_);\n            $score++ if ($x == $x and $y > $y_);\n            $score++ if ($x == $x and $y < $y_);\n        }\n    }\n\n    $count++ if ($score >= 4);\n}\n\nfor (0..$n-1)\n{\n    is_super($_);\n}\n\nprint $count, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\n\nmy @dots;\npush @dots, <> for ($n);\n\nmy $count = 0;\n\nsub is_super($)\n{\n    my $index = shift;\n    my ($x, $y) = split / /, $dots[$index];\n    chomp ($y);\n    my $score = 0;\n\n    foreach (@dots)\n    {\n        chomp($_);\n        my ($x_, $y_) = split / /, $_;\n\n        if (($x_ ne $x) and ($y_ ne $y))\n        {\n            $score++ if ($x > $x_ and $y eq $y_);\n            $score++ if ($x < $x_ and $y eq $y_);\n            $score++ if ($x == $x and $y > $y_);\n            $score++ if ($x == $x and $y < $y_);\n        }\n    }\n\n    $count++ if ($score > 4);\n}\n\nfor (0..$n-1)\n{\n    is_super($_);\n}\n\nprint $count, \"\\n\";"}], "src_uid": "594e64eef7acd055d59f37710edda201"}
{"source_code": "#!perl -w\nuse strict;\nuse warnings;\nuse POSIX qw[ceil];\n\nmain();\n\nsub main {\n    my ($n, $m) = split /\\D/, <>;\n    my @arr;\n    for my $i (0..int($m / 2)-1) {\n        unshift @arr, $m - $i;\n        unshift @arr, $i + 1;\n    }\n    if ($m & 1) {\n        unshift @arr, int($m / 2) + 1;\n    }\n    my $c = 0;\n    for my $i (1..$n) {\n        print $arr[$c % @arr], \"\\n\";\n        $c++;\n    }\n}\n\n__END__\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.006;\nuse strict;\nuse warnings;\n\nmy $n;\nmy $m;\n\nsub mcmp {\n  my $v1 = abs (($m + 1) / 2 - $a);\n  my $v2 = abs (($m + 1) / 2 - $b);\n  return -1 if($v1 < $v2);\n  return -1 if ($v1 == $v2 && $a < $b);\n  return 1;\n}\n\nmy $num = <>;\nmy @arr = split(/ /, $num);\n$n = $arr[0];\n$m = $arr[1];\nmy @array = ();\nfor(1..$m) {\n    push @array, $_;\n}\nmy @ans= sort mcmp @array;\nfor(0..($n - 1)) {\n  my $t = int($_ % $m);\n  print \"$ans[$t]\\n\";\n}\n\n\n"}], "negative_code": [], "src_uid": "907893a0a78a7444d26bdd793d9c7499"}
{"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n", "positive_code": [{"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}, {"source_code": "<>;\n$b=\"\",\n(/X/ and $b.=\" 1x12\"),\n(/X.{5}X/ and $b.=\" 2x6\"),\n(/X...X...X/ and $b.=\" 3x4\"),\n(/X..X..X..X/ and $b.=\" 4x3\"),\n(/X.X.X.X.X.X/ and $b.=\" 6x2\"),\n(/O/ or $b.=\" 12x1\"),\nprint ($B=()=$b=~/ /g,\"$b\\n\"),\nfor <>"}, {"source_code": "#!/usr/bin/perl\n\n<>;\nwhile (<>){\n\tchomp;\n\t@a=();\n\t/X/&& push @a,\"1x12\";\n\t/X.....X/&& push @a,\"2x6\";\n\t/X...X...X/&& push @a,\"3x4\";\n\t/X..X..X..X/&& push @a,\"4x3\";\n\t/X.X.X.X.X.X/&& push @a, \"6x2\";\n\t/XXXXXXXXXXXX/&& push @a,\"12x1\";\n\tprint 0+@a,\" @a\\n\";\n\n}\n"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>"}, {"source_code": "<>;\n$b=\"\",\n(/X/ and $b.=\" 1x12\"),\n(/X.{5}X/ and $b.=\" 2x6\"),\n(/X...X...X/ and $b.=\" 3x4\"),\n(/X..X..X..X/ and $b.=\" 4x3\"),\n(/X.X.X.X.X.X/ and $b.=\" 6x2\"),\n(/O/ or $b.=\" 12x1\"),\nprint ($B=()=$b=~/ /g,\"$b\\n\"),\nfor <>"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}, {"source_code": "use warnings;\nuse strict ;\nuse List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nmy $n = <>;\nmy @data = (<>);\n\nfor my $str (@data)\n{\n    chomp $str;    \n    $str or next;\n    my @u = split //, $str;\n    \n    my @res = ();\n    for my $rows (1, 2, 3, 4, 6, 12)\n    {\n        my $rl = @u / $rows;\n    \n        for my $i (0..$rl-1)\n        {\n\n            #print $i;\n            my $en = join \"\", map $u[$_* $rl + $i], 0..$rows-1;\n            \n            if ($en eq 'X'x $rows )\n            {\n                #print \"ok\";\n                push @res, $rows . \"x\" . $rl;\n                last;\n            }\n        }\n         \n    }\n    print join \" \", (scalar(@res),  @res);\n    print \"\\n\";\n\n    \n\n}\n"}, {"source_code": "use integer;\n\n\nwhile(<>){\n\t$i=$_;\n\tfor $ii(1..$i){\n\t\tchomp($string=<>);\n\t\t@b=();\n\t\tfor $j(1..4,6,12){\n\t\t\t$_=$string;\n\t\t\t@_=split//;\n\t\t#\tprint \"@_\\n\";\n\t\t\t@a=();\n\t\t\t$f=0;\n\t\t\twhile (@_){\n\t\t\tfor $k(1..((length)/$j)){\n\t\t\t\t(shift @_) eq 'X' and $a[$k % ((length)/$j) ]++;\n\t\t\t\tif ($a[$k % ((length)/$j) ]==$j){$f++}\n\t\t\t\t}\n\t\t\t}\n\t\t\t$a=join'',@a;\n\t\t#\tprint \"$a\\n\";\n\t\t#\tprint \"@a\\n\";\n\t\t#\t$f and push @b, ((length)/$j).\"x${j}\";\n\t\t\t$f and push @b, \"${j}x\".((length)/$j);\n\t\t#\tprint $f? \"yes\\n\":\"no\\n\"\n\t\t\t}\n\t\tprint 0+@b,\" @b\\n\";\n\t\t\n\t\t}\n\t\n\t}\n\t\n"}, {"source_code": "<>;\n$b=\"\",\n(/X/ and $b.=\" 1x12\"),\n(/X.{5}X/ and $b.=\" 2x6\"),\n(/X...X...X/ and $b.=\" 3x4\"),\n(/X..X..X..X/ and $b.=\" 4x3\"),\n(/X.X.X.X.X.X/ and $b.=\" 6x2\"),\n(/O/ or $b.=\" 12x1\"),\nprint ($B=()=$b=~/ /g,\"$b\\n\"),\nfor <>"}, {"source_code": "<>;\nwhile(<>){\n\tchomp;\n\t@b=();\n\t/X/ && push @b, \"1x12\";\n\t/X.{5}X/ && push @b, \"2x6\";\n\t/X...X...X/ && push @b, \"3x4\";\n\t/X..X..X..X/ && push @b, \"4x3\";\n\t/X.X.X.X.X.X/ && push @b, \"6x2\";\n\t/O/ || push @b, \"12x1\";\n\tprint 0+@b,\" @b\\n\";\n}"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>"}, {"source_code": "use integer;\n\n<>;\nwhile(<>){\n\t\tchomp;\n\t\t@b=();\n\t\tfor $j(1..4,6,12){\n\t\t\t@_=split//;\n\t\t\t$f=@a=();\n\t\t\t$L=(length)/$j;\n\t\t\t(shift @_) eq 'X' and $j==++$a[$_ % $L ] and $f++ for 1..@_;\n\t\t\t$f && push @b, \"${j}x$L\"\n\t\t\t}\n\t\tprint 0+@b,\" @b\\n\";\n\t}"}, {"source_code": "<>;\ns/X.*/$& 1x12/,\ns/X.{5}X.*/$& 2x6/,\ns/X...X...X.*/$& 3x4/,\ns/X..X..X..X.*/$& 4x3/,\ns/X.X.X.X.X.X.*/$& 6x2/,\ns/X{12}.*/$& 12x1/,\ns/X|O//g,\ns!^!()=/x/g!e,\nprint\nfor <>\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n<>;\nwhile (<>){\n\tchomp;\n\t@a=();\n\t/X/&& push @a,\"1x12\";\n\t/X.....X/&& push @a,\"2x6\";\n\t/X...X...X/&& push @a,\"3x4\";\n\t/X..X..X..X/&& push @a,\"4x3\";\n\t/X.X.X.X.X.X/&& push @a, \"6x2\";\n\t/XXXXXXXXXXX/&& push @a,\"12x1\";\n\tprint 0+@a,\" @a\\n\";\n\n}\n"}], "src_uid": "b669a42ff477a62ec02dcfb87e1e60bd"}
{"source_code": "#!/usr/bin/perl\n\n$n = <STDIN>;\n@a;\n$ans = 0;\nfor (my $i = 0; $i < $n; $i++){\n\t@buf = split ' ', <STDIN>;\n\tfor (my $j = 0; $j < 3; $j++){\n\t\t$a[$i] += $buf[$j];\n\t}\n\tif ($a[$i] >= 2){\n\t\t$ans++;\t\n\t}\n}\n#print \"@a\\n\";\nprint \"$ans\\n\";\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $res = 0;\nchomp(my $n = <>);\nfor (1 .. $n) {\n\tmy $cur = 0;\n\tchomp($_ = <>);\n\tmap { $cur += $_ } split;\n\t++$res if $cur >= 2;\n}\nprint \"$res\\n\";\n"}, {"source_code": "$_=<>;$n=0;while(<>){++$n if y/1//>1}print$n;\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse v5.012;\nuse warnings;\n\nmy $cnt = <STDIN>;\nmy $ret = 0;\nwhile ($cnt--) {\n\tmy $ones = (<STDIN> =~ tr/1/1/);\n\t$ret++ if $ones >= 2;\n}\nprint $ret;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $ans = 0;\nmy $count;\nwhile($n-- > 0){\n    $count = 0;\n    my @a = split(/ /,<>);\n    $count++ if $a[0]==1;\n    $count++ if $a[1]==1;\n    $count++ if $a[2]==1;\n    $ans++ if $count > 1;\n}\nprint \"$ans\\n\";"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nmy $cnt = 0;\n\nwhile ($n-- > 0) {\n    my @nums = <> =~ /(\\d+)/g; \n    if (@nums[0] + @nums[1] + @nums[2] >= 2) {\n\t$cnt++;\n    }\n}\n\nprint $cnt;\n"}, {"source_code": "my $n = <STDIN>;\nmy $count = 0;\nwhile($n--) {\n    my($a, $b, $c) = split(' ', <STDIN>);\n    if(($a + $b + $c) > 1) {\n        $count++;\n    }\n}\nprint $count;"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\n\n\nchomp($n = <>);\n$ans = 0;\nwhile ($n-- > 0) {\n\t$c = 0;\n\t$c += $_ foreach (split / /,<>);\n\t$c>=2 and $ans++;\n}\nprint $ans;"}, {"source_code": "#use strict; \n#use warnings;\n#use diagnostics;\n\nmy $lines = <STDIN>;\nmy $solutions = 0;\nfor (my $i=0; $i<$lines; $i++) {\t\n\tmy $sum = 0;\n\t$line = <STDIN>;\n\t@inputs = split (/ /,$line);\n\tforeach (@inputs) {\n\t\t$sum += $_;\n\t}\n\n\tif ($sum >= 2) {\n\t\t$solutions++;\n\t}\n}\n\nprint $solutions;\n"}, {"source_code": "my $n = <>;\nmy $solutions = 0;\nwhile (<>) {\n    my ($x,$y,$z) = $_ =~ /^(\\d) (\\d) (\\d)$/;\n    \n    $solutions++ if $x+$y+$z > 1;\n}\nprint $solutions;"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nchomp($n);\n\nmy $solutions = 0;\nfor (my $i=0; $i < $n; $i++) {\n    my $in = <>;\n    chomp($in);\n    \n    my @verdicts = split(' ', $in);\n    my $p = scalar grep { $_ } @verdicts;\n    $solutions += ($p >= 2) ? 1 : 0;\n}\n\nprint $solutions;\n"}, {"source_code": "chomp($n = <STDIN>);\n\n$a = 0;\n%sure = ();\n$sure{\"1 1 1\"} = 1;\n$sure{\"1 1 0\"} = 1;\n$sure{\"1 0 1\"} = 1;\n$sure{\"0 1 1\"} = 1;\n\nwhile($n-- > 0) {\n\tchomp($line = <STDIN>);\n\t$a++ if defined $sure{$line};\n}\nprint \"$a\\n\";"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $res = 0;\nfor (1..$n) {\n\tmy @sols = split ' ', <>;\n\tmy $b = 0;\n\tfor (@sols) { $b += $_ };\n\t$res++ if $b > 1;\n}\nprint $res.\"\\n\";\n\n"}, {"source_code": "<>;\nwhile(<>){\n\t$c = () = $_ =~ /1/g;\n\t$re += $c > 1 ? 1 : 0;}\nprint $re;\n\n"}, {"source_code": "#!/usr/bin/perl \nuse strict;\nmy $n = <STDIN>;\nmy $sum = 0;\nwhile (my $row = <STDIN>) \n{\n    my $sum_w = 0;\n    chomp $row;\n    my @inputs_p = split (' ', $row);\n    foreach my $item (@inputs_p)\n    {\n        if ($item == 1) { $sum_w++; }\n    }\n    if ($sum_w >= 2) { $sum++;} \n}\nprint $sum;"}, {"source_code": "chomp(my $testCase=<STDIN>);\nmy $count = 0;\nwhile($testCase){\n\tmy $a=<STDIN>;\n\tmy $sum;\n\tmy @arr = split / /,$a;\n\tforeach (@arr){\n\t\t$sum += $_;\n\t}\n\tif($sum >= 2 ){\n\t $count++; \n\t}\n\t$testCase--;\n}\nprint \"$count\";"}, {"source_code": "my $len=0; my $count = <STDIN>; for(1..$count){ @_ = split \" \", <STDIN>; my $sym = 0; for(@_){ $sym += $_; } if($sym > 1){ $len += 1; } }; print \"$len\\n\";"}, {"source_code": "<>;\nwhile(<>){\n\t$ss = () = $_ =~ /1/g;\n\t$pes += $ss > 1 ? 1 : 0;\n}\nprint $pes;\n "}, {"source_code": "$n = <>;\n$ans = 0;\nfor ($i = 0; $i < $n; ++$i) {\n    ($l, $m, $r) = split' ', <>;\n    if ($l && $m || $l && $r || $m && $r) { ++$ans; }\n}\nprint $ans;"}, {"source_code": "#!/bin/perl\n\n$n = <>;\n$cnt = 0;\n\nfor($i=0;$i<$n;$i++)\n{\n\n  $line = <STDIN>;\n  chomp $line;\n  ($a, $b, $c) = split / +/, $line;\n\n  if( $a + $b + $c >= 2 )\n  {\n\n    $cnt++;\n\n  }\n\n}\n\nprint $cnt;\n"}, {"source_code": "$n = <>;\n$r = 0;\n\nfor (1..$n) {\n\t($a, $b, $c) = split' ', <>;\n\t$r++ if (($a+$b+$c) > 1);\n}\n\nprint $r;"}, {"source_code": "#!/usr/bin/perl\nuse strict; use warnings;\n\nmy $n = 0; <STDIN>;\nwhile (<STDIN>)\n{ my ($a, $b, $c) = split ' ', $_; ++$n if $a + $b + $c > 1 }\nprint $n . \"\\n\"\n"}, {"source_code": "$n=<STDIN>;\nchomp $n;\n$ans=0;\nfor($i=0;$i<$n;$i++){\n        $a=<STDIN>; chomp $a;\n        @a=split(' ',$a);\n        if($a[0]+$a[1]+$a[2]>=2){\n                $ans++;\n        }\n}\nprint \"$ans\\n\";\n"}, {"source_code": "1<(()=/1/g) and $i++\nfor <>;\nprint 0+$i"}], "negative_code": [{"source_code": "use strict; \nuse warnings;\nuse diagnostics;\n\nmy $lines = <STDIN>;\nmy $solutions = 0;\nfor (my $i=0; $i<$lines; $i++) {\t\n\tmy $sum = 0;\n\t$sum += <STDIN>;\n\t$sum += <STDIN>;\n\t$sum += <STDIN>;\n\n\tif ($sum >= 2) {\n\t\t$solutions++;\n\t}\n}\n\nprint $solutions.\"\\n\";\n"}, {"source_code": "#use strict; \n#use warnings;\n#use diagnostics;\n\nmy $lines = <STDIN>;\nmy $solutions = 0;\nfor (my $i=0; $i<$lines; $i++) {\t\n\tmy $sum = 0;\n\t$sum += <STDIN>;\n\t$sum += <STDIN>;\n\t$sum += <STDIN>;\n\n\tif ($sum >= 2) {\n\t\t$solutions++;\n\t}\n}\n\nprint $solutions;\n"}, {"source_code": "#use strict; \n#use warnings;\n#use diagnostics;\n\nmy $lines = <STDIN>;\nmy $solutions = 0;\nfor (my $i=0; $i<$lines; $i++) {\t\n\tmy $sum = 0;\n\t$sum += <STDIN>;\n\t$sum += <STDIN>;\n\t$sum += <STDIN>;\n\n\tif ($sum >= 2) {\n\t\t$solutions++;\n\t}\n}\n\nprint \"2\";\n#print $solutions.\"\\n\";\n"}, {"source_code": "chomp($n = <STDIN>);\n\n$a = 0;\n%sure = ();\n$sure{\"1 1 0\"} = 1;\n$sure{\"1 0 1\"} = 1;\n$sure{\"0 1 1\"} = 1;\n\nwhile($n-- > 0) {\n\tchomp($line = <STDIN>);\n\t$a++ if defined $sure{$line};\n}\nprint \"$a\\n\";"}, {"source_code": "chomp(my $testCase=<STDIN>);\nmy $count;\nwhile($testCase){\n\tmy $a=<STDIN>;\n\tmy $sum;\n\tmy @arr = split / /,$a;\n\tforeach (@arr){\n\t\t$sum += $_;\n\t}\n\tif($sum >= 2 ){\n\t $count++; \n\t}\n\t$testCase--;\n}\nprint $count;"}], "src_uid": "3542adc74a41ccfd72008faf983ffab5"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\t\n\tprint int $_ / 2, \"\\n\",\n\t\tjoin ' ', \n\t\t\t(2) x ($_ / 2 - 1), \n\t\t\t(2) x (1 - $_ % 2), \n\t\t\t(3) x ($_ % 2),\n\t\n\t}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\n# send argument as array, not reference, to function requiring list\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy $count = 0;\nmy $answer = '';\n\nif ($n % 2 == 1) {\n    $n -= 3;\n    while ($n > 0) {\n        $count++;\n        $n -= 2;\n        $answer .= '2 ';\n    }\n    $count++;\n    $answer .= '3';\n}\nelse {\n    while ($n > 0) {\n        $count++;\n        $n -= 2;\n        $answer .= '2 ';\n    }\n}\n\nsay $count;\nsay $answer;\n"}, {"source_code": "$n = <STDIN>;\n$c = int($n / 2);\nprint(\"$c\\n\");\nif($n % 2 == 0)\n{\n\twhile($c > 0)\n\t{\n\t\tprint(\"2 \");\n\t\t$c--;\n\t}\n}\nelse\n{\n\twhile($c-1 > 0)\n\t{\n\t\tprint(\"2 \");\n\t\t$c--;\n\t}\n\tprint(\"3\");\n}\nprint(\"\\n\");\n"}], "negative_code": [], "src_uid": "98fd00d3c83d4b3f0511d8afa6fdb27b"}
{"source_code": "#Perl v5.18.2\n$n = <STDIN>;\n\nprint 9*$n;\nprint \" \";\nprint 8*$n;", "positive_code": [{"source_code": "use strict;\nuse warnings FATAL => 'all';\n\n\nmy $n = <STDIN>;\nchomp $n;\n$n = int($n);\n\nmy $a = 9 * $n;\nmy $b = 8 * $n;\n\nprint $a, ' ', $b"}, {"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\nsub min {\n    my ($a, $b) = @_;\n    if ($a < $b) {\n\t\treturn $a;\n\t} else {\n        return $b;\n    }\n}\nsub max {\n    my ($a, $b) = @_;\n    if ($a > $b) {\n        return $a;\n    } else {\n        return $b;\n    }\n}\n\nsub solve {\n    my $n = int(<>);\n    if ($n % 2 == 0) {\n        print $n + 4, \" 4\";\n    } else {\n        print $n + 9, \" 9\";\n    }\n    print \"\\n\";\n}\n\nsub main {\n    my $t = 1;\n#    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main(@ARGV));\n\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings FATAL => 'all';\n\n\nmy $n = <STDIN>;\nchomp $n;\n$n = int($n);\n\nmy $a = 3 * $n;\nmy $b = 2 * $n;\n\nprint $a, ' ', $b"}], "src_uid": "59d5e5ed2bc4b316e950e2a4dbc99d68"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = join '', split ' ', <>;\n\n\t$max = 0;\n\ts!(?:^|(?<=0))0((?:10)+)1(?=1|$)! \n\t\t$c = (length $1) / 2, \n\t\t($max < $c and $max = $c), \n\t\t0 . 0 x $c . 1 x $c . 1\n\t!ge;\n\n\ts!(?:^|(?<=1))1((?:01)+)0(?=0|$)! \n\t\t$c = (length $1) / 2, \n\t\t($max < $c and $max = $c), \n\t\t1 . 1 x $c . 0 x $c . 0\n\t!ge;\n\n\ts!(?:^|(?<=0))0((?:10)+)(?=0|$)!\n\t\t$c = (length $1) / 2, \n\t\t($max < $c and $max = $c), \n\t\t0 . 0 x $c . 0 x $c\n\t!ge;\n\n\ts!(?:^|(?<=1))1((?:01)+)(?=1|$)!\n\t\t$c = (length $1) / 2, \n\t\t($max < $c and $max = $c), \n\t\t1 . 1 x $c . 1 x $c\n\t!ge;\n\t\n\tprint int $max;\n\tprint join ' ', split //;\n\t}", "positive_code": [{"source_code": "$n = <>;\n@m = split ' ', <>;\n$cnt = 0;\n@sum = ();\n$pos = 0;\n$ans = 0;\nfor($i = 1;$i < $n;$i ++) {\n    if ($i < $n - 1 and $m[$i - 1] == $m[$i + 1] and $m[$i] != $m[$i - 1]) {\n        if($cnt == 0) {\n            $start = $m[$i - 1];\n            $end = $m[$i];\n        }\n        $cnt ++;\n    } else {\n        if (int(($cnt + 1) / 2) > $ans) {\n            $ans = int(($cnt + 1) / 2);\n        }\n        push @sum, @m[$pos..$i - $cnt - 1];\n        if ($cnt % 2 == 0) {\n            for($j = 0;$j < $cnt / 2;$j ++) {\n                push @sum, $start;\n            }\n            for($j = 0;$j < $cnt / 2;$j ++) {\n                push @sum, $end;\n            }\n        } else {\n            for($j = 0;$j < $cnt;$j ++) {\n                push @sum, $start;\n            }\n        }\n        $pos = $i;\n        $cnt = 0;\n    }\n}\nprint $ans, \"\\n\";\npush @sum, $m[-1];\n$m = join ' ', @sum;\nprint $m, \"\\n\";\n"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!\n\t(?<= (.) ) # lookbehind\n\t(\n\t\t(?<= 00)\n\t\t(?: 10 )+\n\t|\n\t\t(?<= 11)\n\t\t(?: 01 )+\n\t)\n\t(?= (.) ) # lookahead\n!\n\t$c = (length $2) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t1 * $1 x $c . $3 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = join '', split ' ', <>;\n\ts/^./$&$&/;\n\ts/.$/$&$&/;\n\n\t$max = 0;\n\ts!(?<=00)((?:10)+)(?=(.))!\n\t\t$c = (length $1) / 2, \n\t\t($max < $c and $max = $c), \n\t\t0 x $c . $2 x $c\n\t!ge;\n\n\ts!(?<=11)((?:01)+)(?=(.))! \n\t\t$c = (length $1) / 2, \n\t\t($max < $c and $max = $c), \n\t\t1 x $c . $2 x $c\n\t!ge;\n\n\ts/.//;\n\tchop;\n\t\n\tprint int $max;\n\tprint join ' ', split '';\n\t}"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!\n\t(?<= (.) ) # lookbehind\n\t(\n\t\t(?<= 00)\n\t\t(?: 10 )+\n\t|\n\t\t(?<= 11)\n\t\t(?: 01 )+\n\t)\n\t(?= (.) ) # lookahead\n!\n\t$c = (length $2) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $3 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}], "negative_code": [{"source_code": "$n = <>;\n@m = split ' ', <>;\n$ans = 0;\nwhile(++ $ans) {\n    $flag = 0;\n    @newm = @m;\n    for($i = 1;$i < $n - 1;$i ++) {\n        if ($m[$i - 1] == $m[$i + 1] and $m[$i] != $m[$i - 1]) {\n            $newm[$i] = 1 - $newm[$i];\n            $flag = 1;\n        }\n    }\n    if ($flag == 0) {\n        last;\n    }\n    @m = @newm;\n    print @m, \"\\n\";\n}\nprint $ans - 1, \"\\n\";\nfor ($i = 0;$i < $n;$i ++) {\n    print $m[$i];\n    print \"\\n\" if $i == $n - 1;\n    print \" \" if $i < $n - 1;\n}\n"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (?<= (0)0 | (1)1 ) # lookbehind\n    ( (?: (??{1-$1})\\1 )+ )  # capture $2\n    (?= (.) ) #lookahead\n!\n\t$c = (length $2) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $3 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (?<= (.)) \\1 \\K\n    (?= ( (??{ 1 - $1 . $1 }) ) )\n    (\n        \\2{1,}\n    )\n    (?= (.) )\n!\n\t$c = (length $3) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $4 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (?<= (.)) \\1 \\K\n    (?= ( (??{ 1 - $1 . $1 }) ) )\n    (\n        \\2+\n    )\n    (?= (.) )\n!\n\t$c = (length $3) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $4 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (?<= 00 | (1)1 ) # lookbehind\n    ( (?: (??{1-$1}) (??{1*$1}) )+ )  # capture $2\n    (?= (.) ) #lookahead\n!\n\t$c = (length $2) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t1*$1 x $c . $3 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (.)\\1 \\K  \n    ( (?: (??{1-$1})\\1 )+ )  # $2\n    (?= (.) ) \n!\n\t$c = (length $2) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $3 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\n%hash = map { $_, $_ x 1e2 } '01', '10';\n\ns!  (?<= (.)) \\1 \\K        # $1\n    (?= ( (??{ 1 - $1 . $1 }) ) ) # $2\n    (\n        (??{$2})+\n    )                             # $3\n    (?= (.) )              # $4\n!\n\t$c = (length $3) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $4 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (?<= (.)) \\1 \\K\n    ( (?: (??{1-$1})\\1 )+ )  # $2\n    (?= (.) ) \n!\n\t$c = (length $2) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $3 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\ns!  (?<= (.)) \\1 \\K\n    (?= ( (??{ 1 - $1 . $1 }) ) )\n    (\n        (?:\\2)+\n    )\n    (?= (.) )\n!\n\t$c = (length $3) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $4 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\n%hash = map { $_, $_ x 1e2 } '01', '10';\n\ns!  (?<= (.)) \\1 \\K        # $1\n    (?= ( (??{ 1 - $1 . $1 }) ) ) # $2\n    (\n        (?: $hash{ $2 } )*\n        \\2+\n    )                             # $3\n    (?= (.) )              # $4\n!\n\t$c = (length $3) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $4 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = join '', split ' ', <>;\n\n\t$max = 0;\n\ts!(^|0)0((?:10)+)1(1|$)! \n\t\t$c = (length $2) / 2, \n\t\t($max < $c and $max = $c), \n\t\t$1 . 0 . 0 x $c . 1 x $c . 1 . $3 \n\t!ge;\n\n\ts!(^|1)1((?:01)+)0(0|$)! \n\t\t$c = (length $2) / 2, \n\t\t($max < $c and $max = $c), \n\t\t$1 . 1 . 1 x $c . 0 x $c . 0 . $3 \n\t!ge;\n\n\ts!^0(?:10)*$! \n\t\t$c = (length $&) / 2, \n\t\t($max < $c and $max = $c), \n\t\t0 x length\n\t!ge;\n\t\n\ts!^1(?:01)*$! \n\t\t$c = (length $&) / 2, \n\t\t($max < $c and $max = $c), \n\t\t1 x length\n\t!ge;\n\t\n\tprint int $max;\n\tprint join ' ', split //;\n\t}"}, {"source_code": "<>;\n\n$_ = join '', split ' ', <>;\n\ns/^./$&$&/, s/.$/$&$&/;\n\n%hash = map { $_, $_ x 3e1 } '01', '10';\n\ns!  (?<= (.) ) \\1++ \\K        # $1\n    (?= ( (??{ 1 - $1 . $1 }) |) ) # $2\n    (\n        (?:$hash{$2})*+\n        \\2*\n    )                             # $3\n    (?= (.|) )              # $4\n!\n\t$c = (length $3) / 2, # half length of repetition 10.. or 01..\n\t($max < $c and $max = $c), \n\t$1 x $c . $4 x $c\n!gex;\n\ns/.//, chop;\n\t\nprint join \"\\n\", int $max, join ' ', split '', $_"}], "src_uid": "5da1c96b88b4ac0b698a37e4d2437ccb"}
{"source_code": "#!/usr/bin/env perl\n\nmy @result = ();\nmy $line = readline(*STDIN);\nmy ($w, $h) = split(' ', $line);\n\nfor (my $n=0; $n<$h; $n++) {\n    $line = readline(*STDIN);\n    chomp($line);\n    my $currentw = $n*2;\n    my $currenth = 0;\n    while ( $line =~ m/(.)/g) {\n     \tmy $nexth = $currenth + 1;\n     \tmy $nextw = $currentw + 1;\n        $result[$currenth][$currentw] = $result[$nexth][$currentw] = $result[$currenth][$nextw]= $result[$nexth][$nextw] = $1;\n        $currenth += 2;\n    }\n}\n\nfor (my $W = 0; $W<$w*2; $W++)\n{\n\tfor (my $H = 0; $H<$h*2; $H++)\t\n\t{\n\t\tprint $result[$W][$H];\n\t}\n\tprint \"\\n\";\n}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse 5.011;\nuse strict;\nuse warnings;\n\nmy ($w, $h) = split /\\s/, <>;\nmy @a;\npush @a, [split \"\"] while <>;\n\nmy @b;\nfor (my $i = 0; $i < $w; $i++) {\n    my @x;\n    for (my $j = 0; $j < $h; $j++) {\n        push @x, $a[$h - $j - 1][$i];\n    }\n    push @b, \\@x;\n}\n\nmy @c;\nfor (my $i = 0; $i < $w; $i++) {\n    my @x;\n    for (my $j = $h - 1; $j >= 0; $j--) {\n        push @x, $b[$i][$j];\n        push @x, $b[$i][$j];\n    }\n    push @c, \\@x;\n    push @c, \\@x;\n}\n\nsay @$_ for @c;\n"}], "negative_code": [], "src_uid": "9af19e1b482f7f0bcbffc754cf324092"}
{"source_code": "$_=<>;while(<>){print/yes/i?\"YES\\n\":\"NO\\n\"}\n\n", "positive_code": [{"source_code": "##!/usr/local/bin/perl \r\n\r\nuse strict;\r\nuse warnings;\r\n\r\n#use Data::Dumper qw(Dumper);\r\nuse feature qw(say);\r\n\r\n#print \"------------------------------------------------------------------------------\\n\";\r\n\r\n#open my $fh,'<','codef_1703_input.txt' or die();\r\nmy @input;\r\nwhile(<STDIN>)\r\n{\r\n    chomp;\r\n    push(@input,$_);\r\n}\r\n#close($fh);\r\n\r\nshift(@input);\r\n#say(Dumper @input);\r\n\r\nforeach (@input)\r\n{\r\n    if($_ =~ /yes/i)\r\n    {\r\n        say \"YES\";\r\n    }else \r\n    {\r\n        say \"NO\";\r\n    }\r\n}\r\n\r\n#say(Dumper %hash);\r\n\r\n#print \"------------------------------------------------------------------------------\\n\";"}, {"source_code": "<>;print/yes/i?$_:\"NO \"for(<>)"}, {"source_code": "<>;print uc eq\"YES\\n\"?uc:\"NO \"for(<>)"}, {"source_code": "<>;print/yes/i?$_:\"NO \"for(<>)"}, {"source_code": "<>;print/yes/i?$_:\"NO \"for(<>)"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tprint m/^yes$/i ? \"YES\" : \"NO\";\n\t}"}], "negative_code": [], "src_uid": "4c0b0cb8a11cb1fd40fef47616987029"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\nchomp($a=$');\n$t=0;\nwhile (<>){\n\tchomp;\n\tfor $i(0..$a){\n\t\t/$i/ or $k++;\n\t\t\n\t\t}\n\n\t$k or $t++;\n\t$k=0;\n\t\n\t}\nprint $t;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "my ($n, $k) = split ' ', <>;\n$count = 0;\nLabel:\nfor (1..$n) {\n    my $num = <>;\n    for (0..$k) {\n        next Label if $num !~ /$_/;\n    }\n    $count++;\n}\nprint $count;"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\nchomp($a=$'+1);\n$t=0;\nwhile (<>){\n\tchomp;\n\t@a=split//;\n\t@a=sort @a;\n#\tprint \" @a\\n\";\n\tfor $i(@a){\n\t\t($i==$j++) or ($k++)\n\t\t}\n\t$j=0;\n\t@a==$a or $k++;\n\t\n\t$k or $t++;\n\t$k=0;\n\t\n\t}\nprint $t;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\nchomp($a=$'+1);\n$t=0;\nwhile (<>){\n\tchomp;\n\t@a=split//;\n\t@a=sort @a;\n#\tprint \" @a\\n\";\n\tfor $i(@a){\n\t\t($i==$j++) or ($k++)\n\t\t}\n\t$j=0;\n\t@a<1 and push @a,1;\n\t@a==$a or $k++;\n\t\n\t$k or $t++;\n\t$k=0;\n\t\n\t}\nprint $t;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "fc831eda72f2ebe0865a3fb1b783edc5"}
{"source_code": "# cf708a # solution courtesy 20147365 s_p\nuse strict;\n$_=<>;\ns% [b-z]+ % $& =~ tr/b-z/a-y/r %xe || s/a$/z/;\nprint $_;\n", "positive_code": [{"source_code": "# cf708a\nuse strict;\nmy $c=getc();\nmy $s=0;\nwhile(defined($c)) {\n  if($s==0) { \n    if($c ne 'a') { $s=1; }\n  }\n  if($s==1) {\n    if($c ne 'a') { $c=chr(ord($c)-1); }\n    else { $s=2; }\n  }\n  my $nextC=getc();\n  if($nextC eq \"\\n\") { $nextC=undef }\n  print defined($nextC) || $s!=0 ? $c : 'z';\n  $c=$nextC;\n}\n"}, {"source_code": "$_ = <>; \ns% [b-z]+ % $&=~y/b-z/a-y/r %xe || s/a$/z/;\nprint;\n"}], "negative_code": [{"source_code": "$_ = <>; \ns% [b-z]+ % $&=~y/b-z/a-y/r %xe;\nprint;\n"}, {"source_code": "# cf708a\nuse strict;\nmy $c;\nmy $s=0;\nwhile(defined($c=getc())) {\n  if($s==0) { \n    if($c ne 'a') { $s=1; }\n  }\n  if($s==1) {\n    if($c ne 'a') { $c=chr(ord($c)-1); }\n    else { $s=2; }\n  }\n  print $c;\n}\n"}, {"source_code": "# cf708a\nuse strict;\nmy $c=getc();\nmy $s=0;\nwhile(defined($c)) {\n  if($s==0) { \n    if($c ne 'a') { $s=1; }\n  }\n  if($s==1) {\n    if($c ne 'a') { $c=chr(ord($c)-1); }\n    else { $s=2; }\n  }\n  my $nextC=getc();\n  print defined($nextC) || $s!=0 ? $c : 'z';\n  $c=$nextC;\n}\n"}], "src_uid": "e70708f72da9a203b21fc4112ede9268"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n,$m) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @aa = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @bb = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @cc = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  \r\n  my @need_col = (); $#need_col = $n + 10;\r\n  my @need_col_i = (); $#need_col_i = $n + 10;\r\n  \r\n  my $total_need = 0;\r\n  \r\n  my @btype = (); $#btype = $n + 10;\r\n  \r\n  for(my $i=0;$i<$n;$i++){\r\n    if( $aa[$i] != $bb[$i] ){\r\n      $need_col[$bb[$i]]++;\r\n      push(@{$need_col_i[$bb[$i]]},$i);\r\n      $total_need ++;\r\n    }\r\n    push(@{$btype[$bb[$i]]},$i);\r\n  }\r\n  \r\n  my @tr = (); $#tr = $m - 1;\r\n  my $init = 1;\r\n  my $prev = -1;\r\n  my $init_pass = 0;\r\n  for(my $i=$m-1;$i>=0;$i--){\r\n    my $c1 = $cc[$i];\r\n    if( $need_col[$c1] - 0 > 0 ){\r\n      $need_col[$c1] --;\r\n      $tr[$i] = $need_col_i[$c1]->[$need_col[$c1]];\r\n      $prev = $tr[$i];\r\n      $total_need --;\r\n      $init = 0;\r\n    } else {\r\n      if( $init==1 and !ref($btype[$c1]) and $prev < 0 ){\r\n        $init = -1; last;\r\n      }\r\n      if( $prev >= 0 ){\r\n        $tr[$i] = $prev;\r\n      } else {\r\n        $tr[$i] = $btype[$c1]->[0];\r\n        $prev = $tr[$i];\r\n      }\r\n    }\r\n  }\r\n  if( $init < 0 or $total_need > 0 ){\r\n    print \"NO\\n\"; next;\r\n  }\r\n  print \"YES\\n\";\r\n  for(my $i=0;$i<$m;$i++){\r\n    my $v = $tr[$i]+1;\r\n    print \" \" if $i > 0;\r\n    print \"$v\";\r\n  }\r\n  print \"\\n\";\r\n  \r\n}\r\n\r\nexit(0);\r\n\r\n\r\n#!/usr/bin/perl\r\nmy ($n,$m) = map {$_ - 0} split(/\\s+/o,<STDIN>);\r\n\r\nmy @tr = ();\r\n$#tr = $n-1;\r\nmy @par = ();\r\n$#par = $n-1;\r\n\r\nfor(my $i=0;$i<$n;$i++){\r\n  $par[$i] = $i;\r\n}\r\n\r\nfor(my $i=0;$i<$m;$i++){\r\n  my ($x,$y,$z) = map {$_ - 0} split(/\\s+/o,<STDIN>);\r\n  unite($x-1,$y-1);\r\n}\r\n\r\nmy %dum = ();\r\nfor(my $i=0;$i<$n;$i++){\r\n  $dum{&root($i)} = 1;\r\n}\r\nmy @d2 = keys %dum;\r\nmy $res = 1 + $#d2;\r\nprint \"$res\\n\";\r\n\r\nexit(0);\r\n\r\n\r\n###\r\n\r\n#!/usr/bin/perl\r\nuse Data::Dumper;\r\nmy ($n) = map {$_ - 0} split(/\\s+/o,<STDIN>);\r\n\r\nmy $f = &factr($n);\r\n\r\nmy @facts = keys %$f;\r\n\r\nmy %f0 = ();\r\n\r\nmy %oki = ();\r\n\r\nwhile(1){\r\n  my $gosei = 1;\r\n  foreach my $f1 (@facts){\r\n    $gosei *= ( $f1 ** ( $f0{$f1} - 0 ) );\r\n  }\r\n  if( $gosei >= 3 ){\r\n#    print \"gosei = $gosei\\n\";\r\n    my $syo = $n / $gosei;\r\n    if( $syo <= $gosei - 2 ){\r\n      my $g1 = $gosei - 1;\r\n      $oki{$g1} = 1;\r\n    }\r\n  }\r\n  my $cu = 0;\r\n  my $carry = 1;\r\n  while($carry > 0){\r\n    $f0{$facts[$cu]} += 1;\r\n    $carry = 0;\r\n    if( $f0{$facts[$cu]} > $f->{$facts[$cu]} ){\r\n      $f0{$facts[$cu]} = 0;\r\n      $carry = 1;\r\n      $cu++;\r\n    }\r\n    last if( $cu > $#facts );\r\n  }\r\n  last if $cu > $#facts;\r\n}\r\nmy $res = 0;\r\nforeach my $o1 (keys %oki){\r\n  $res += ( $o1 - 0);\r\n}\r\n#print &Dumper(\\%oki);\r\nprint \"$res\\n\";\r\nexit(0);\r\n\r\nsub factr {\r\n  my $v = shift;\r\n  my %f = ();\r\n  if( $v<4 ){\r\n    $f{$v}++;\r\n    return \\%f;\r\n  }\r\n  for(my $i=1;$i*$i<=$v;$i+=2){\r\n    my $ii = ($i == 1 ? 2 : $i);\r\n    while($v % $ii == 0){\r\n      $f{$ii}++;\r\n      $v /= $ii;\r\n    }\r\n  }\r\n  $f{$v}++ if $v>1;\r\n  return \\%f;\r\n}\r\n\r\n####  mod_int + nCr nPr set\r\n\r\n#!/usr/bin/perl\r\n\r\nmy $mod = 10 ** 9 + 7;\r\n# my $mod = 998244353;\r\n\r\nmy ($n,$k) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n\r\n&mk_fact($n+10);\r\n\r\n### write here \r\n\r\nexit(0);\r\n\r\n\r\nsub mod_pow {     # ( x ** n ) % mod\r\n  my ($x,$n) = @_;\r\n  my $r = 1;\r\n  while( $n ){\r\n    $r = ( $r * $x ) % $mod if 1 & $n;\r\n    $n >>= 1;\r\n    $x = ( $x * $x ) % $mod;\r\n  }\r\n  return $r;\r\n}\r\n\r\nsub mk_fact {     # make {global} n-size variable  fact[]  factinv[]\r\n  my $n_max = shift;\r\n  our @fact    = (1); $#fact = $n_max;\r\n  our @factinv = (1); $#factinv = $n_max;\r\n  for(my $i=1;$i<=$n_max;$i++){\r\n    $fact[$i] = ( $fact[$i-1] * $i ) % $mod;\r\n    $factinv[$i] = &mod_pow($fact[$i],$mod-2);\r\n  }\r\n}\r\n\r\nsub nCr {         # calc nCr % mod\r\n  my $n = shift; my $r = shift;\r\n  return (( $fact[$n] * ( ( $factinv[$r] * $factinv[$n-$r] ) % $mod ) ) % $mod);\r\n}\r\n\r\nsub nPr {         # calc nPr % mod\r\n  my $n = shift; my $r = shift;\r\n  return (( $fact[$n] * $factinv[$n-$r] ) % $mod );\r\n}\r\n\r\n#### union find set\r\n\r\n#!/usr/bin/perl\r\n\r\nmy ($n) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n\r\n#### write here\r\n\r\nexit(0);\r\n\r\nsub mk_uf {\r\n  my $n = shift;\r\n  our @uf = (); $#uf = $n - 1;\r\n  for(my $i=0;$i<$n;$i++){\r\n    $uf[$i] = $i;\r\n  }\r\n}\r\n\r\nsub root {\r\n  my $x = shift;\r\n  while( $uf[$x] != $x ){  $x = $uf[$x] = $uf[$uf[$x]];  }\r\n  return $x;\r\n}\r\n\r\nsub unite {\r\n  my $x = &root(scalar(shift)); my $y = &root(scalar(shift));\r\n  $uf[$y] = $x;\r\n}\r\n\r\n\r\n\r\n", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t%h = %g = @D = ();\r\n\t@A = split ' ', <>;\r\n\t@B = split ' ', <>;\r\n\t@C = split ' ', <>;\r\n\t\r\n\tundef $h{ $_ } for @B;\r\n\t\r\n\tfor( 0 .. @A - 1 ){\r\n\t\t$A[ $_ ] != $B[ $_ ] and $h{ $B[ $_ ] }{ $_ + 1 } = 1;\r\n\t\t$g{ $B[ $_ ] } = $_ + 1\r\n\t\t}\r\n\t\r\n\tfor( @C ){\r\n\t\tif( exists $h{ $_ } ){\r\n\t\t\t( $key ) = keys %{ $h{ $_ } };\r\n\t\t\t$key and delete $h{ $_ }{ $key };\r\n\t\t\tpush @D, $key || $g{ $_ }\r\n\t\t\t}\r\n\t\telse{\r\n\t\t\tpush @D, 0\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tif( ! $D[ @D - 1 ] or map { keys %{ $h{ $_ } } } keys %h ){\r\n\t\tprint 'NO'\r\n\t\t}\r\n\telse{\r\n\t\tmap { $_ ||= $D[ @D - 1 ] } @D;\r\n\t\tprint for 'YES', \"@D\"\r\n\t\t}\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m ) = split;\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\tmy @C = split ' ', <>;\n\t\n\t$debug and print \"\\@A:[@A]\";\n\t$debug and print \"\\@B:[@B]\";\n\t$debug and print \"\\@C:[@C]\";\n\t\n\tmy %h;\n\tmy %g;\n\t\n\tundef $h{ $_ } for @B;\n\t\n\tfor my $i ( 0 .. @A - 1 ){\n\t\t$A[ $i ] != $B[ $i ] and $h{ $B[ $i ] }{ $i + 1 } = 1;\n\t\t$g{ $B[ $i ] } = $i + 1;\n\t\t}\n\t\n\t$debug and print map \"keys %h:[$_]\", join \" \", sort keys %h;\n\t\n\tmy @D;\n\t\n\tfor( @C ){\n\t\tif( exists $h{ $_ } ){\n\t\t\tif( 0 < keys %{ $h{ $_ } } ){\n\t\t\t\tmy( $key ) = keys %{ $h{ $_ } };\n\t\t\t\tdelete $h{ $_ }{ $key };\n\t\t\t\tpush @D, $key;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\tpush @D, $g{ $_ };\n\t\t\t\t}\n\t\t\t}\n\t\telse{\n\t\t\tpush @D, -1;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@D:[@D]\";\n\t\n\tif( $D[ @D - 1 ] == -1 ){\n\t\tprint 'NO';\n\t\t}\n\telsif( 0 < map { keys %{ $h{ $_ } } } keys %h ){\n\t\tprint 'NO';\n\t\t}\n\telse{\n\t\tmap { $_ == -1 and $_ = $D[ @D - 1 ] } @D;\n\t\tprint 'YES';\n\t\tprint \"@D\";\n\t\t}\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t%h = %g = @D = ();\r\n\t@A = split ' ', <>;\r\n\t@B = split ' ', <>;\r\n\t@C = split ' ', <>;\r\n\t\r\n\t++ $h{ $_ } for @B;\r\n\t\r\n\tfor( 0 .. @A - 1 ){\r\n\t\t$A[ $_ ] != $B[ $_ ] and $h{ $B[ $_ ] }{ $_ + 1 } = 1;\r\n\t\t$g{ $B[ $_ ] } = $_ + 1\r\n\t\t}\r\n\t\r\n\tfor( @C ){\r\n\t\tif( exists $h{ $_ } ){\r\n\t\t\t( $key ) = keys %{ $h{ $_ } };\r\n\t\t\t$key and delete $h{ $_ }{ $key };\r\n\t\t\tpush @D, $key || $g{ $_ }\r\n\t\t\t}\r\n\t\telse{\r\n\t\t\tpush @D, 0\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tif( ! $D[ @D - 1 ] or map { keys %{ $h{ $_ } } } keys %h ){\r\n\t\tprint 'NO'\r\n\t\t}\r\n\telse{\r\n\t\tmap { $_ ||= $D[ @D - 1 ] } @D;\r\n\t\tprint for 'YES', \"@D\"\r\n\t\t}\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m ) = split;\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\tmy @C = split ' ', <>;\n\t\n\t$debug and print \"\\@A:[@A]\";\n\t$debug and print \"\\@B:[@B]\";\n\t$debug and print \"\\@C:[@C]\";\n\t\n\tmy %h;\n\tmy %g;\n\t\n\tundef $h{ $_ } for @B;\n\t\n\tfor my $i ( 0 .. @A - 1 ){\n\t\t$A[ $i ] != $B[ $i ] and $h{ $B[ $i ] }{ $i + 1 } = 1;\n\t\t$g{ $B[ $i ] } = $i + 1;\n\t\t}\n\t\n\t$debug and print map \"keys %h:[$_]\", join \" \", sort keys %h;\n\t\n\tmy @D;\n\t\n\tfor( @C ){\n\t\tif( exists $h{ $_ } ){\n\t\t\tif( 0 < keys %{ $h{ $_ } } ){\n\t\t\t\tmy( $key ) = keys %{ $h{ $_ } };\n\t\t\t\tdelete $h{ $_ }{ $key };\n\t\t\t\tpush @D, $key;\n\t\t\t\t\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\tpush @D, $g{ $_ };\n\t\t\t\t}\n\t\t\t}\n\t\telse{\n\t\t\tpush @D, -1;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"\\@D:[@D]\";\n\t\n\tif( $D[ @D - 1 ] == -1 ){\n\t\tprint 'NO';\n\t\t}\n\telse{\n\t\tmap { $_ == -1 and $_ = $D[ @D - 1 ] } @D;\n\t\tprint 'YES';\n\t\tprint \"@D\";\n\t\t}\n\t}"}], "src_uid": "a350430c707bb18a146df9f80e114f45"}
{"source_code": "\n\n\n\nmy %hash = ();\nmy $n = <STDIN>;\nchomp ( $n );\nmy $f = <STDIN>;\nchomp ( $f );\nmy @arr = split m/ /, $f;\nfor my $i (@arr) {\n    if ( not exists $hash { $i } ) {\n\t$hash { $i } = 0;\n    }\n    $hash { $i } += 1;\n}\n\nmy $winner = 1;\nfor my $i ( keys %hash ) {\n    if ( $hash { $i } % 2 == 1 ) {\n\t$winner = 0;\n    }\n}\nif ( $winner == 0 ) {\n    print \"Conan\\n\";\n}\nelse {\n    print \"Agasa\\n\";\n}\n\n\n\n\n\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split ' ', <>;\n\t\n\tprint qw( Conan Agasa )[ ! grep $_ % 2, values %h ];\n\t}"}, {"source_code": "<>;\n\n$h{ $_ } ++ for split ' ', <>;\n\nprint qw( Conan Agasa )[ ! grep $_ % 2, values %h ]"}, {"source_code": "<>;\n\nprint qw( Conan Agasa )[ 0 + ( join ' ', sort split ' ', <> ) =~ /^( ?\\b(\\d+) \\2\\b)*+( \\b(\\d+) \\4\\b)*$/ ]"}], "negative_code": [{"source_code": "<>;\n\nprint qw( Conan Agasa )[ 0 + ( join ' ', sort split ' ', <> ) =~ /^( ?\\b(\\d+) \\2\\b)+$/ ]"}, {"source_code": "<>;\n\nprint qw( Conan Agasa )[ 0 + ( join ' ', sort split ' ', <> ) =~ /^( ?\\b(\\d+) \\2\\b){1,5e4}$/ ]"}, {"source_code": "<>;\n\nprint qw( Conan Agasa )[ 0 + ( join ' ', sort split ' ', <> ) =~ /^( ?\\b(\\d+) \\2\\b)*+( ?\\b(\\d+) \\2\\b)*$/ ]"}], "src_uid": "864593dc3911206b627dab711025e116"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\tmy $n = $_;\n\t\n\tmy $i = 2;\n\t\n\tmy %h;\n\t\t\n\tmap {\n\t\t$h{ $i }{ $_ } = 1;\n\t\t$h{ $_ }{ $i } = 1;\n\t\t$i ++;\n\t\t} split ' ', <>;\n\t\t\n\tmy @try = ( 1 );\n\tmy @seq = @try;\n\t\t\n\twhile( @try ){\n\t\tmy $try = shift @try;\n\t\tmy @arr =\n\t\tmap {\n\t\t\t$h{ $_ }{ $try } = 0;\n\t\t\t$_\n\t\t\t} grep $h{ $try }{ $_ }, keys %{ $h{ $try } };\n\t\tunshift @seq, @arr;\n\t\tpush @try, @arr;\n\t\t}\n\t\n\tmy %nums;\n\t\t\n\twhile( @seq ){\n\t\tmy $leaflikes = shift @seq;\n\t\t\n\t\tmy @keys = grep { defined $nums{ $_ } } keys %{ $h{ $leaflikes } };\n\t\tmy $sum = 0;\n\t\tif( @keys ){\n\t\t\t$sum += $_ for map { $nums{ $_ } } @keys;\n\t\t\t}\n\t\t$nums{ $leaflikes } = $sum || 1;\n\t\t}\n\t\t\t\n\tprint join ' ', sort { $a <=> $b } grep $_, values %nums;\n\t}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\tmy $n = $_;\n\t\n\tmy $i = 2;\n\t\n\tmy %h;\n\t\t\n\tmap {\n\t\t$h{ $i }{ $_ } = 1;\n\t\t$h{ $_ }{ $i } = 1;\n\t\t$i ++;\n\t\t} split ' ', <>;\n\t\t\n\tmy @try = ( 1 );\n\tmy @seq = ( [ @try ] );\n\t\n\twhile( @try ){\n\t\tmy @allkeys;\n\t\tfor my $try ( @try ){\n\t\t\tpush @allkeys,\n\t\t\tmap {\n\t\t\t\t$h{ $_ }{ $try } = 0;\n\t\t\t#\t$h{ $try }{ $_ } = 0;\n\t\t\t\t$_\n\t\t\t\t} grep $h{ $try }{ $_ }, keys %{ $h{ $try } };\n\t\t\t}\n\t\tpush @seq, [ @allkeys ];\n\t\t@try = @allkeys;\n\t\t}\n\t\n\tpop @seq;\n\t@seq = reverse @seq;\n\t\n\t$debug and print \" seq : => @{ $_ }\" for @seq;\n\t\t\n\tmy %nums;\n\t\n\tmap { $nums{ $_ } = 1 } @{ shift @seq };\n\t\t\n\twhile( @seq ){\n\t\t\t\t\n\t\tmy @leaflikes = @{ shift @seq };\n\t\t\t\t\t\t\n\t\tfor my $leaflikes ( @leaflikes ){\n\t\t\tmy @keys = keys %{ $h{ $leaflikes } };\n\t\t\t@keys = grep { defined $nums{ $_ } } @keys;\n\t\t\tmy $sum = 0;\n\t\t\tif( @keys ){\n\t\t\t\t$sum += eval join ' + ', map { $nums{ $_ } } @keys;\n\t\t\t\t}\n\t\t\t$sum ||= 1;\n\t\t\t$nums{ $leaflikes } = $sum;\n\t\t\t}\n\t\t\n\t\t}\n\t\t\t\n\tprint join ' ', sort { $a <=> $b } grep $_, values %nums;\n\t}"}], "negative_code": [], "src_uid": "291bfc61026dddf6c53f4cd9a8aa2baa"}
{"source_code": "# input\n$/ = \"\"; $_ = <>; ($k, $n, @s) = split;\n($a, @b) = grep !$u{$_}++, @s; \ngoto ans if grep {cn($a) ne cn($_)} @b;\n$ans = make($a,0,1), goto ans unless @b;\n$aa = $a =~ /(.).*\\1/;\n\n# bet\nfor $b (@b) {\n\tlen($d) < 4 or last;\n\t$d |= $a ^ $b;\n}\n@d = split //, $d;\nfor $i (0..$#d) {\n\tif (ord $d[$i] and @i < 10) {\n\t\tpush @i, $i;\n\t}\n}\n\n# loop\nfor $i (@i) {\nfor $j (@i) {\n\t$y = 1;\n\t$t = make($a, $i, $j);\n\tdiag(\"i=$i j=$j t=$t\\n\");\n\tfor $b ($a, @b) {\n\t\t$d = len($t ^ $b);\n\t\t$y *= ($d==2 or ($d==0 and $aa));\n\t\tdiag(\"\\tb=$b d=$d y=$y\\n\");\n\t}\n\tif ($y) {\n\t\t$ans = $t, goto ans;\n\t}\n}}\nans: print $ans || -1;\n\nsub cn {\n\tjoin \"\", sort split //, shift;\n}\n\nsub make {\n\tmy ($s, $i, $j) = @_;\n\tvec($s,$i,8)^=vec($s,$j,8)^=vec($s,$i,8)^=vec($s,$j,8) if $i-$j;\n\t$s;\n}\n\nsub len {\n\tlength $_[0] =~ s/\\0//gr;\n}\n\nsub diag {\n\t# print @_;\n}\t\n", "positive_code": [{"source_code": "use strict;\n\nsub diag {\n\t# print @_;\n}\t\n\nsub counter {\n\tmy $a = shift;\n\tmy %c; $c{$_}++ for @$a;\n\t\\%c;\n}\n\nsub in_list {\n\tmy ($value, @list) = @_;\n\tfor (@list) {\n\t\treturn 1 if $_ == $value;\n\t}\n\treturn 0;\n}\n\nsub unique {\n\tmy %u; $u{$_} = 1 for @_;\n\tmy @rv; \n\tfor (@_) {\n\t\tif ($u{$_} > 0) {\n\t\t\tpush(@rv, $_);\n\t\t\t$u{$_} = 0;\n\t\t}\n\t}\n\t@rv;\n}\n\nsub swap {\n\tmy ($a, $i, $j) = @_;\n\tmy @b = @{ $a };\n\t@b[$i,$j] = @b[$j,$i];\n\t\\@b;\n}\n\npackage Set;\n\nsub new { bless {} }\n\nsub add {\n\tmy ($s, @list) = @_;\n\tfor (@list) {\n\t\t$s->{$_} = 1\n\t}\n}\n\nsub list {\n\tmy $s = shift;\n\tsort keys %$s;\n}\n\npackage main;\n\nsub diff {\n\tmy ($a, $b) = @_;\n\tmy @i;\n\tmy $ok = 1;\n\tfor (my $i = 0; $i < @$a; $i++) {\n\t\tif ($a->[$i] ne $b->[$i]) {\n\t\t\tpush @i, $i;\n\t\t}\n\t}\n\tif (join(\"\", sort @$a[@i]) ne join(\"\", sort @$b[@i])) {\n\t\t$ok = 0;\n\t}\n\tdiag \"diff a=[@$a] b=[@$b] i=[@i] ok=$ok\\n\";\n\t($ok, @i);\n}\n\nsub test($$$) {\n\tmy ($a, $repeat, $t) = @_;\n\tdiag \"test [@$t]\\n\";\n\tmy $y = 1;\n\tfor my $s (@$a) {\n\t\tmy ($ok, @i) = diff($s, $t);\n\t\tif ($ok) {\n\t\t\tmy $d = scalar @i;\n\t\t\t$y *= ($d==2 or ($d==0 and $repeat));\n\t\t} else {\n\t\t\t$y = 0;\n\t\t\tlast;\n\t\t}\n\t}\n\tdiag \"y=$y\\n\";\n\t$y;\n}\n\nsub get_repeat {\n\tmy $a = shift;\n\tmy $count = grep {$_ > 1} values %{counter $a->[0]};\n\tdiag \"repeat=$count\\n\";\n\t$count > 0;\n}\n\nsub input {\n\t$/ = \"\"; my ($k, $n, @s) = split \" \", <>;\n\tdiag \"input k=$k\\n\";\n\t@s = map { [split //] } unique @s[0..$k-1];\n\tdiag \"unique $#s+1\\n\";\n\t@s;\n}\t\n\nsub bet {\n\tmy $a = shift;\n\tmy $s = Set->new();\n\tfor (my $i = 1; $i <= 4; $i++) {\n\t\tif (@$a > $i) {\n\t\t\tmy ($ok, @i) = diff($a->[0], $a->[$i]);\n\t\t\tif ($ok) {\n\t\t\t\t$s->add(@i);\n\t\t\t}\n\t\t}\n\t}\n\tmy @i = $s->list();\n\t@i = splice @i, 0, 10;\n\tdiag \"bet i=[@i] count=$#i+1\\n\";\n\t@i;\n}\t\n\nsub loop {\n\tmy ($a, @i) = @_;\n\tmy $found;\n\tmy $repeat = get_repeat($a);\n\t\n\tif (@$a == 1) {\n\t\t$found = swap($a->[0], 0, 1);\n\t} else {\n\t\tmy @t;\n\t\tfor (my $i = 0; $i < @i; $i++) {\n\t\t\tfor (my $j = $i + 1; $j < @i; $j++) {\n\t\t\t\tmy $t = swap $a->[0], @i[$i,$j];\n\t\t\t\tpush @t, $t;\n\t\t\t}\n\t\t}\n\t\tif ($repeat) {\n\t\t\tunshift @t, $a->[0];\n\t\t}\n\t\tdiag \"plan $#t+1 tests\\n\";\n\t\tfor my $t (@t) {\n\t\t\tif (test($a, $repeat, $t)) {\n\t\t\t\t$found = $t;\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t}\t\n\t$found;\n}\n\nsub main {\t\n\tmy @a = input();\n\tmy @i = bet(\\@a);\n\tmy $found = loop(\\@a, @i);\n\tmy $ans = ($found? join(\"\", @$found): -1);\n\tprint $ans, \"\\n\";\n}\n\nmain();\t\n"}], "negative_code": [{"source_code": "$/ = \"\"; $_ = <>; ($k, $n, @s) = split;\n($a, @b) = grep !$u{$_}++, @s;\ngoto ans if grep {cn($a) ne cn($_)} @b;\n$ans = make($a,0,1), goto ans unless @b;\n$aa = $a =~ /(.).*\\1/;\n\n# bet\n$d |= $a ^ $_ for @b;\n@d = split //, $d;\nfor $i (0..$#d) {\n\tif (ord $d[$i] and @i<10) {\n\t\tpush @i, $i;\n\t}\n}\n\n# loop\nfor $i (@i) {\nfor $j (@i) {\n\t$y = 1;\n\t$t = make($a, $i, $j);\n\tfor $b (@b) {\n\t\t$d = grep {ord} split //, $t ^ $b;\n\t\t$y *= $d==2 || ($d==0 and $aa);\n\t}\n\tif ($y) {\n\t\t$ans = $t, goto ans;\n\t}\n}}\nans: print $ans || -1;\n\nsub cn {\n\tjoin \"\", sort split //, shift;\n}\n\nsub make {\n\tmy ($s, $i, $j) = @_;\n\tvec($s,$i,8)^=vec($s,$j,8)^=vec($s,$i,8)^=vec($s,$j,8) if $i-$j;\n\t$s;\n}"}, {"source_code": "sub diag {\n\t# print @_;\n}\t\n\nsub counter {\n\tmy $a = shift;\n\tmy %c; $c{$_}++ for @$a;\n\t\\%c;\n}\n\nsub in_list {\n\tmy ($value, @list) = @_;\n\tfor (@list) {\n\t\treturn 1 if $_ == $value;\n\t}\n\treturn 0;\n}\n\nsub unique {\n\tmy %u; $u{$_} = 1 for @_;\n\tmy @rv; \n\tfor (@_) {\n\t\tif ($u{$_} > 0) {\n\t\t\tpush(@rv, $_);\n\t\t\t$u{$_} = 0;\n\t\t}\n\t}\n\t@rv;\n}\n\nsub swap {\n\tmy ($a, $i, $j) = @_;\n\tmy @b = @{ $a };\n\t@b[$i,$j] = @b[$j,$i];\n\t\\@b;\n}\n\nsub diff {\n\tmy ($a, $b) = @_;\n\tmy @i;\n\tmy $ok = 1;\n\tfor $i (0..$n-1) {\n\t\tif ($a->[$i] ne $b->[$i]) {\n\t\t\tpush @i, $i;\n\t\t}\n\t}\n\tif (join(\"\", sort @$a[@i]) ne join(\"\", sort @$b[@i])) {\n\t\t$ok = 0;\n\t}\n\tdiag \"diff a=[@$a] b=[@$b] i=[@i] ok=$ok\\n\";\n\t($ok, @i);\n}\n\nsub test {\n\tmy $t = shift;\n\tdiag \"test [@$t]\\n\";\n\tmy $y = 1;\n\tfor $s (@s) {\n\t\tmy ($ok, @i) = diff($s, $t);\n\t\tif ($ok) {\n\t\t\tmy $d = scalar @i;\n\t\t\t$y *= ($d==2 or ($d==0 and $repeat));\n\t\t} else {\n\t\t\t$y = 0;\n\t\t\tlast;\n\t\t}\n\t}\n\tdiag \"y=$y\\n\";\n\t$y;\n}\n\nsub set_new {\n\tmy %s; \\%s;\n}\n\nsub set_add {\n\tmy ($s, @list) = @_;\n\tfor (@list) {\n\t\t$s->{$_} = 1\n\t}\n}\n\nsub set_size {\n\tmy $s = shift;\n\tscalar keys %$s;\n}\n\nsub set_list {\n\tmy $s = shift;\n\tsort keys %$s;\n}\n\n$/ = \"\"; ($k, $n, @s) = split \" \", <>;\ndiag \"input k=$k\\n\";\n@s = map { [split //] } unique @s[0..$k-1];\ndiag \"unique $#s+1\\n\";\n$repeat += $_ - 1 for values %{counter $s[0]};\ndiag \"repeat=$repeat\\n\";\n\n$s = set_new();\nfor ($i = 1; $i <= 4; $i++) {\n\tif (@s > $i) {\n\t\tmy ($ok, @i) = diff($s[0], $s[$i]);\n\t\tif ($ok) {\n\t\t\tset_add $s, @i;\n\t\t} else {\n\t\t\tgoto ans;\n\t\t}\n\t}\n}\n@i = set_list($s); @i = @i[0..3] if @i > 4;\n$count = scalar @i;\ndiag \"i=[@i] count=$count\\n\";\n\t\nif (@s == 1) {\n\t$ans = swap($s[0], 0, 1);\n} \nelsif (in_list $count, 2, 3, 4) {\n\tmy @t;\n\tfor ($i = 0; $i < @i; $i++) {\n\t\tfor ($j = $i + 1; $j < @i; $j++) {\n\t\t\t$t = swap $s[0], @i[$i,$j];\n\t\t\tpush @t, $t;\n\t\t}\n\t}\n\tif ($repeat) {\n\t\tunshift @t, $s[0];\n\t}\n\tdiag \"plan $#t+1 tests\\n\";\n\tfor $t (@t) {\n\t\tif (test($t)) {\n\t\t\t$ans = $t;\n\t\t\tlast;\n\t\t}\n\t}\n}\t\n\nans:\n$ans = join(\"\", @$ans) || -1;\nprint $ans;"}, {"source_code": "$diag = \"\";\n\nsub diag {\n\t# print @_;\n}\t\n\nsub counter {\n\tmy $a = shift;\n\tmy %c; $c{$_}++ for @$a;\n\t\\%c;\n}\n\nsub in_list {\n\tmy ($value, @list) = @_;\n\tfor (@list) {\n\t\treturn 1 if $_ == $value;\n\t}\n\treturn 0;\n}\n\nsub unique {\n\tmy %u; $u{$_} = 1 for @_;\n\tmy @rv; \n\tfor (@_) {\n\t\tif ($u{$_} > 0) {\n\t\t\tpush(@rv, $_);\n\t\t\t$u{$_} = 0;\n\t\t}\n\t}\n\t@rv;\n}\n\nsub swap {\n\tmy ($a, $i, $j) = @_;\n\tmy @b = @{ $a };\n\t@b[$i,$j] = @b[$j,$i];\n\t\\@b;\n}\n\nsub diff {\n\tmy ($a, $b) = @_;\n\tmy @i;\n\tmy $ok = 1;\n\tfor $i (0..$n-1) {\n\t\tif ($a->[$i] ne $b->[$i]) {\n\t\t\tpush @i, $i;\n\t\t}\n\t}\n\tif (join(\"\", sort @$a[@i]) ne join(\"\", sort @$b[@i])) {\n\t\t$ok = 0;\n\t}\n\tdiag \"diff a=[@$a] b=[@$b] i=[@i] ok=$ok\\n\";\n\t($ok, @i);\n}\n\nsub test {\n\tmy $t = shift;\n\tdiag \"test [@$t]\\n\";\n\tmy $y = 1;\n\tfor $s (@s) {\n\t\tmy ($ok, @i) = diff($s, $t);\n\t\tif ($ok) {\n\t\t\tmy $d = scalar @i;\n\t\t\t$y *= ($d==2 or ($d==0 and $repeat));\n\t\t} else {\n\t\t\t$y = 0;\n\t\t\tlast;\n\t\t}\n\t}\n\tdiag \"y=$y\\n\";\n\t$y;\n}\n\nsub set_new {\n\tmy %s; \\%s;\n}\n\nsub set_add {\n\tmy ($s, @list) = @_;\n\tfor (@list) {\n\t\t$s->{$_} = 1\n\t}\n}\n\nsub set_size {\n\tmy $s = shift;\n\tscalar keys %$s;\n}\n\nsub set_list {\n\tmy $s = shift;\n\tsort keys %$s;\n}\n\n$/ = \"\"; ($k, $n, @s) = split \" \", <>;\ndiag \"input k=$k\\n\";\n@s = map { [split //] } unique @s[0..$k-1];\ndiag \"unique $#s+1\\n\";\n$repeat += $_ - 1 for values %{counter $s[0]};\ndiag \"repeat=$repeat\\n\";\n\n$s = set_new();\nfor ($i = 1; $i <= 4; $i++) {\n\tif (@s > $i) {\n\t\tmy ($ok, @i) = diff($s[0], $s[$i]);\n\t\t$diag .= \"$i-$ok-$#i+1;\";\n\t\tif ($ok) {\n\t\t\tset_add $s, @i;\n\t\t} else {\n\t\t\tgoto ans;\n\t\t}\n\t}\n}\n@i = set_list($s); @i = @i[0..3] if @i > 4;\n$count = scalar @i;\ndiag \"i=[@i] count=$count\\n\";\n$diag .= join(\"+\", @i) . \";\";\n\t\nif (@s == 1) {\n\t$ans = swap($s[0], 0, 1);\n} \nelsif (in_list $count, 2, 3, 4) {\n\tmy @t;\n\tfor ($i = 0; $i < @i; $i++) {\n\t\tfor ($j = $i + 1; $j < @i; $j++) {\n\t\t\t$t = swap $s[0], @i[$i,$j];\n\t\t\tpush @t, $t;\n\t\t}\n\t}\n\tif ($repeat) {\n\t\tunshift @t, $s[0];\n\t}\n\tdiag \"plan $#t+1 tests\\n\";\n\t$diag .= \"$#t+1;\";\n\tfor $t (@t) {\n\t\tif (test($t)) {\n\t\t\t$ans = $t;\n\t\t\tlast;\n\t\t}\n\t}\n}\t\n\nans:\nif ($n == 1666) {\n\tprint $diag;\n} else {\n\t$ans = join(\"\", @$ans) || -1;\n\tprint $ans;\n}"}, {"source_code": "$/ = \"\"; $_ = <>; ($k, $n, @s) = split;\n($a, @b) = grep !$u{$_}++, @s;\ngoto ans if grep {cn($a) ne cn($_)} @b;\n$ans = make($a,0,1), goto ans unless @b;\n$aa = $a =~ /(.).*\\1/;\n\n# bet\n$d |= $a ^ $_ for @b;\n@d = split //, $d;\nfor $i (0..$#d) {\n\tpush @i, $i if $d[$i] and @i<10;\n}\n\n# loop\nfor $i (@i) {\nfor $j (@i) {\n\t$y = 1;\n\t$t = make($a, $i, $j);\n\tfor $b (@b) {\n\t\t$d = grep {ord} split //, $t ^ $b;\n\t\t$y *= $d==2 || ($d==0 and $aa);\n\t}\n\tif ($y) {\n\t\t$ans = $t, goto ans;\n\t}\n}}\nans: print $ans || -1;\n\nsub cn {\n\tjoin \"\", sort split //, shift;\n}\n\nsub make {\n\tmy ($s, $i, $j) = @_;\n\tvec($s,$i,8)^=vec($s,$j,8)^=vec($s,$i,8)^=vec($s,$j,8) if $i-$j;\n\t$s;\n}"}, {"source_code": "sub in_list {\n\tmy ($value, @list) = @_;\n\tfor (@list) {\n\t\treturn 1 if $_ == $value;\n\t}\n\treturn 0;\n}\n\nsub unique {\n\tmy %u; $u{$_} = 1 for @_;\n\tmy @rv; \n\tfor (@_) {\n\t\tif ($u{$_} > 0) {\n\t\t\tpush(@rv, $_);\n\t\t\t$u{$_} = 0;\n\t\t}\n\t}\n\t@rv;\n}\n\nsub swap {\n\tmy ($a, $i, $j) = @_;\n\tmy @b = @{ $a };\n\t@b[$i,$j] = @b[$j,$i];\n\t\\@b;\n}\n\nsub diff {\n\tmy ($a, $b) = @_;\n\tmy $count = 0;\n\tmy @i;\n\tfor $i (0..$n-1) {\n\t\tif ($a->[$i] ne $b->[$i]) {\n\t\t\t$count++;\n\t\t\tpush @i, $i;\n\t\t}\n\t}\n\tif (join(\"\", sort @$a[@i]) ne join(\"\", sort @$b[@i])) {\n\t\t$count = -1;\n\t}\n\t($count, @i);\n}\n\n$/ = \"\"; ($k, $n, @s) = split \" \", <>;\n@s = map { [split //] } unique splice @s, 0, $k;\n($count, @i) = diff($s[0], $s[1]);\n\nif (@s == 1) {\n\t$ans = swap($s[0], 0, 1);\n} \nelsif (in_list $count, 2, 3, 4) {\n\tfor ($i = 0; $i < @i; $i++) {\n\t\tfor ($j = $i + 1; $j < @i; $j++) {\n\t\t\t$t = swap $s[0], @i[$i,$j];\n\t\t\t$y = 1;\n\t\t\tfor $s (@s) {\n\t\t\t\t$d = diff($s, $t);\n\t\t\t\t$y *= ($d==0 or $d==2);\n\t\t\t}\n\t\t\tif ($y) {\n\t\t\t\t$ans = $t;\n\t\t\t}\n\t\t}\n\t}\n}\t\n\n$ans = join(\"\", @$ans) || -1;\nprint $ans;"}, {"source_code": "sub diag {\n\t# print @_;\n}\t\n\nsub counter {\n\tmy $a = shift;\n\tmy %c; $c{$_}++ for @$a;\n\t\\%c;\n}\n\nsub in_list {\n\tmy ($value, @list) = @_;\n\tfor (@list) {\n\t\treturn 1 if $_ == $value;\n\t}\n\treturn 0;\n}\n\nsub unique {\n\tmy %u; $u{$_} = 1 for @_;\n\tmy @rv; \n\tfor (@_) {\n\t\tif ($u{$_} > 0) {\n\t\t\tpush(@rv, $_);\n\t\t\t$u{$_} = 0;\n\t\t}\n\t}\n\t@rv;\n}\n\nsub swap {\n\tmy ($a, $i, $j) = @_;\n\tmy @b = @{ $a };\n\t@b[$i,$j] = @b[$j,$i];\n\t\\@b;\n}\n\nsub diff {\n\tmy ($a, $b) = @_;\n\tmy $count = 0;\n\tmy @i;\n\tfor $i (0..$n-1) {\n\t\tif ($a->[$i] ne $b->[$i]) {\n\t\t\t$count++;\n\t\t\tpush @i, $i;\n\t\t}\n\t}\n\tif (join(\"\", sort @$a[@i]) ne join(\"\", sort @$b[@i])) {\n\t\t$count = -1;\n\t}\n\tdiag \"diff a=[@$a] b=[@$b] count=$count i=[@i]\\n\";\n\t($count, @i);\n}\n\nsub test {\n\tmy $t = shift;\n\tdiag \"test [@$t]\\n\";\n\tmy $y = 1;\n\tfor $s (@s) {\n\t\t$d = diff($s, $t);\n\t\t$y *= ($d==2 or ($d==0 and $repeat));\n\t}\n\t$y;\n}\n\n$/ = \"\"; ($k, $n, @s) = split \" \", <>;\n@s = map { [split //] } unique splice @s, 0, $k;\n$repeat += $_ - 1 for values %{counter $s[0]};\ndiag \"repeat=$repeat\\n\";\n($count, @i) = diff($s[0], $s[1]);\n\nif (@s == 1) {\n\t$ans = swap($s[0], 0, 1);\n} \nelsif (in_list $count, 2, 3, 4) {\n\tmy @t;\n\tfor ($i = 0; $i < @i; $i++) {\n\t\tfor ($j = $i + 1; $j < @i; $j++) {\n\t\t\t$t = swap $s[0], @i[$i,$j];\n\t\t\tpush @t, $t;\n\t\t}\n\t}\n\tif ($repeat) {\n\t\tpush @t, $s[0];\n\t}\n\tdiag \"plan $#t+1 tests\\n\";\n\tfor $t (@t) {\n\t\tif (test($t)) {\n\t\t\t$ans = $t;\n\t\t\tlast;\n\t\t}\n\t}\n}\t\n\n$ans = join(\"\", @$ans) || -1;\nprint $ans;"}, {"source_code": "sub diag {\n\t# print @_;\n}\t\n\nsub counter {\n\tmy $a = shift;\n\tmy %c; $c{$_}++ for @$a;\n\t\\%c;\n}\n\nsub in_list {\n\tmy ($value, @list) = @_;\n\tfor (@list) {\n\t\treturn 1 if $_ == $value;\n\t}\n\treturn 0;\n}\n\nsub unique {\n\tmy %u; $u{$_} = 1 for @_;\n\tmy @rv; \n\tfor (@_) {\n\t\tif ($u{$_} > 0) {\n\t\t\tpush(@rv, $_);\n\t\t\t$u{$_} = 0;\n\t\t}\n\t}\n\t@rv;\n}\n\nsub swap {\n\tmy ($a, $i, $j) = @_;\n\tmy @b = @{ $a };\n\t@b[$i,$j] = @b[$j,$i];\n\t\\@b;\n}\n\nsub diff {\n\tmy ($a, $b) = @_;\n\tmy @i;\n\tfor $i (0..$n-1) {\n\t\tif ($a->[$i] ne $b->[$i]) {\n\t\t\tpush @i, $i;\n\t\t}\n\t}\n\tif (join(\"\", sort @$a[@i]) ne join(\"\", sort @$b[@i])) {\n\t\t@i = ();\n\t}\n\tdiag \"diff a=[@$a] b=[@$b] i=[@i]\\n\";\n\t@i;\n}\n\nsub test {\n\tmy $t = shift;\n\tdiag \"test [@$t]\\n\";\n\tmy $y = 1;\n\tfor $s (@s) {\n\t\t$d = diff($s, $t);\n\t\t$y *= ($d==2 or ($d==0 and $repeat));\n\t}\n\t$y;\n}\n\nsub set_new {\n\tmy %s; \\%s;\n}\n\nsub set_add {\n\tmy ($s, @list) = @_;\n\tfor (@list) {\n\t\t$s->{$_} = 1\n\t}\n}\n\nsub set_size {\n\tmy $s = shift;\n\tscalar keys %$s;\n}\n\nsub set_list {\n\tmy $s = shift;\n\tsort keys %$s;\n}\n\n$/ = \"\"; ($k, $n, @s) = split \" \", <>;\ndiag \"input k=$k\\n\";\n@s = map { [split //] } unique splice @s, 0, $k;\ndiag \"unique $#s+1\\n\";\n$repeat += $_ - 1 for values %{counter $s[0]};\ndiag \"repeat=$repeat\\n\";\n\n$s = set_new();\nfor ($i = 1; $i <= 4; $i++) {\n\tif (@s > $i) {\n\t\tset_add $s, diff($s[0], $s[$i]);\n\t}\n}\n@i = set_list($s);\n$count = scalar @i;\ndiag \"i=[@i] count=$count\\n\";\n\t\nif (@s == 1) {\n\t$ans = swap($s[0], 0, 1);\n} \nelsif (in_list $count, 2, 3, 4) {\n\tmy @t;\n\tfor ($i = 0; $i < @i; $i++) {\n\t\tfor ($j = $i + 1; $j < @i; $j++) {\n\t\t\t$t = swap $s[0], @i[$i,$j];\n\t\t\tpush @t, $t;\n\t\t}\n\t}\n\tif ($repeat) {\n\t\tpush @t, $s[0];\n\t}\n\tdiag \"plan $#t+1 tests\\n\";\n\tfor $t (@t) {\n\t\tif (test($t)) {\n\t\t\t$ans = $t;\n\t\t\tlast;\n\t\t}\n\t}\n}\t\n\n$ans = join(\"\", @$ans) || -1;\nprint $ans;"}, {"source_code": "# input\n$/ = \"\"; $_ = <>; ($k, $n, @s) = split;\n($a, @b) = grep !$u{$_}++, @s; \ngoto ans if grep {cn($a) ne cn($_)} @b;\n$ans = make($a,0,1), goto ans unless @b;\n$aa = $a =~ /(.).*\\1/;\n\n# bet\nfor $b (@b) {\n\tlen($d) < 4 or last;\n\t$d |= $a ^ $b;\n}\n@d = split //, $d;\nfor $i (0..$#d) {\n\tif (ord $d[$i] and @i < 10) {\n\t\tpush @i, $i;\n\t}\n}\n\n# loop\nfor $i (@i) {\nfor $j (@i) {\n\t$y = 1;\n\t$t = make($a, $i, $j);\n\tfor $b (@b) {\n\t\t$d = len($t ^ $b);\n\t\t$y *= ($d==2 or ($d==0 and $aa));\n\t}\n\tif ($y) {\n\t\t$ans = $t, goto ans;\n\t}\n}}\nans: print $ans || -1;\n\nsub cn {\n\tjoin \"\", sort split //, shift;\n}\n\nsub make {\n\tmy ($s, $i, $j) = @_;\n\tvec($s,$i,8)^=vec($s,$j,8)^=vec($s,$i,8)^=vec($s,$j,8) if $i-$j;\n\t$s;\n}\n\nsub len {\n\tlength $_[0] =~ s/\\0//gr;\n}"}], "src_uid": "0550004c6c7a386b8e7d214e71990572"}
{"source_code": "<>=~/ /;\nif ($`<=$'*2){print -1; exit}\nfor $j(1..$'){\n\tfor $i(1..$`){\n\t\tpush @_,(\"\\n$i \".($i+$j>$`?($i+$j-$`):($i+$j)));\n\t\t\t}\n\t\t}\nprint 0+@_,@_", "positive_code": [{"source_code": "<>=~/ /;\nif ($`<=$'*2){print -1; exit}\nfor $j(1..$'){\n\tfor $i(1..$`){\n\t\tpush @_,(\"\\n$i \".($i+$j>$`?($i+$j-$`):($i+$j)));\n\t\t\t}\n\t\t}\nprint 0+@_,@_"}, {"source_code": "<>=~/ /;\nif ($`<=$'*2){print -1; exit}\nfor $j(1..$'){\n\tfor $i(1..($m=$`+0)){\n\t\t$_.=\"\\n$i \".($i+$j>$m?($i+$j-$m):($i+$j));\n\t\t\t}\n\t\t}\nprint $`*$',$_"}, {"source_code": "($n,$k)=split/ /,<>;\nchomp $k;\n$_=\"\";\nif ($n<=$k*2){print -1; exit}\nfor $j(1..$k){\n\tfor $i(1..$n){\n\t\t\t\n\t\t$_.= \"\\n$i \".($i+$j>$n?($i+$j-$n):($i+$j));\n\t\t\t\t\n\t\t}\n\t\t\n\t}\nprint $n*$k,$_"}, {"source_code": "<>=~/ /;\nif ($`<=$'*2){print -1; exit}\nfor ($j=1; $j<=$'; $j++){\n\tfor ($i=1; $i<=$`; $i++){\n\t\tpush @_,(\"\\n$i \".($i+$j>$`?($i+$j-$`):($i+$j)));\n\t\t\t}\n\t\t}\nprint 0+@_,@_"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k*2){print -1; next}\n\tfor ($j=1; $j<=$k; $j++){\n\t\tfor ($i=1; $i<=$n; $i++){\n\t\t\t\n\t\t\tpush @_, (\"$i \".($i+$j>$n?($i+$j-$n):($i+$j)).\"\\n\");\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tprint 0+@_,\"\\n\";\n\tprint @_\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k*2){print -1; next}\n\tfor $j(1..$k){\n\t\tfor $i(1..$n){\n\t\t\t\n\t\t\tpush @_, (\"\\n$i \".($i+$j>$n?($i+$j-$n):($i+$j)));\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\tprint 0+@_,@_\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t$_=\"\";\n\tif ($n<=$k*2){print -1; next}\n\tfor ($j=1; $j<=$k; $j++){\n\t\tfor ($i=1; $i<=$n; $i++){\n\t\t\t\n\t\t\t$_.= (\"\\n$i \".($i+$j>$n?($i+$j-$n):($i+$j)));\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\tprint $n*$k,$_\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k*2){print -1; next}\n\tfor $j(1..$k){\n\t\tfor $i(1..$n){\n\t\t\t\n\t\t\tpush @_, (\"$i \".($i+$j>$n?($i+$j-$n):($i+$j)).\"\\n\");\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tprint 0+@_,\"\\n\";\n\tprint @_\n\t}"}, {"source_code": "$_=<>;\nchomp;\n($n,$k)=split/ /;\n$_=\"\";\nif ($n<=$k*2){print -1; exit}\nfor $j(1..$k){\n\tfor $i(1..$n){\n\t\t\t\n\t\t$_.= \"\\n$i \".($i+$j>$n?($i+$j-$n):($i+$j));\n\t\t\t\t\n\t\t}\n\t\t\n\t}\nprint $n*$k,$_"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k*2){print -1; next}\n\tfor ($j=1; $j<=$k; $j++){\n\t\tfor ($i=1, $m=1+$j; $i<=$n; $i++, $m++){\n\t\t\t\n\t\t\tpush @_, (\"$i \".($m>$n?($m-$n):$m).\"\\n\");\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tprint 0+@_,\"\\n\";\n\tprint @_\n\t}"}], "negative_code": [{"source_code": "$_=<>;chop;/ /;\nif ($`<=$'*2){print -1; exit}\nfor $j(1..$'){\n\tfor $i(1..$`){\n\t\t$_.=\"\\n$i \".($i+$j>$`?($i+$j-$`):($i+$j));\n\t\t\t}\n\t\t}\nprint $`*$',$_"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k){print -1; next}\n\tfor ($j=1; $j<=$k; $j++){\n\t\tfor ($i=1; $i<=$n; $i++){\n\t\t\t\n\t\t\tpush @_, (\"$i \".($i+$j>$n?($i+$j-$n):($i+$j)).\"\\n\");\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\nprint 0+@_,\"\\n\";\n\tprint @_\n\t}"}, {"source_code": "($n,$k)=split/ /,<>;\nchomp $k;\n$_=\"\";\nif ($n<=$k*2){print -1; next}\nfor $j(1..$k){\n\tfor $i(1..$n){\n\t\t\t\n\t\t$_.= \"\\n$i \".($i+$j>$n?($i+$j-$n):($i+$j));\n\t\t\t\t\n\t\t}\n\t\t\n\t}\nprint $n*$m,$_"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k){print -1; next}\n\tfor ($j=1; $j<=$k; $j++){\n\t\tfor ($i=1; $i<=$n; $i++){\n\t\t\t\n\t\t\tpush @_, (\"$i \".($i+$j>$n?($i+$j-$n):($i+$j)).\"\\n\");\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\tprint @_\n\t}"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t\n\t@_=();\n\tif ($n<=$k*2){print -1; next}\n\tfor $j(1..$k){\n\t\tfor $i(1..$n){\n\t\t\t\n\t\t\tpush @_, (\"\\n$i \".($i+$j));\n\t\t\t\n\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\tprint 0+@_,@_\n\t}"}], "src_uid": "14570079152bbf6c439bfceef9816f7e"}
{"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 22:10:07 IST 2012\n# File Name: c.pl\n# USAGE: \n#       c.pl \n# \n# \n#------------------------------------------------\nchomp (my ($n, $k) = split /\\s+/, <STDIN>);\nchomp (my @lst = sort {$a <=> $b} split /\\s+/, <STDIN>);\n\nmy $prefix = '';\nmy $i = 1;\nwhile ($k > 0) {\n        foreach ( @lst ) {\n                print \"$i $prefix$_\";\n                $k--;\n                last if not ($k > 0);\n        }\n        $prefix .= pop @lst;\n        $prefix .= ' ';\n        $i++;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse bigint;\nuse List::Util qw(sum);\n\nchomp($_ = <>);\nmy ($n, $k) = split;\nchomp($_ = <>);\nmy @a = split;\nmy %h = ();\n\nfor my $i (@a) {\n    my %tmp = (%h, $i => [$i]);\n    for my $j (keys %h) {\n        my $sum = $j + $i;\n        next if exists $tmp{$sum};\n        $tmp{$sum} = [@{$h{$j}}, $i];\n    }\n    %h = %tmp;\n    last if keys %h >= $k;\n}\nwhile (my ($key, $val) = each %h) {\n    print scalar @$val, \" @$val\\n\";\n    last if --$k == 0;\n}\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse bigint;\nuse List::Util qw(sum);\n\nchomp($_ = <>);\nmy ($n, $k) = split;\nchomp($_ = <>);\nmy @a = split;\nmy %h = ();\nfor my $i (@a) {\n    my %tmp = (%h, $i => [$i]);\n    for my $j (keys %h) {\n        my $sum = $j + $i;\n        next if exists $tmp{$sum};\n        $tmp{$sum} = [@{$h{$j}}, $i];\n    }\n    %h = %tmp;\n    last if keys %h >= $k;\n}\nwhile (my ($key, $val) = each %h) {\n    print scalar @$val, \" @$val\\n\";\n}\n"}, {"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 22:10:07 IST 2012\n# File Name: c.pl\n# USAGE: \n#       c.pl \n# \n# \n#------------------------------------------------\nchomp (my ($n, $k) = split /\\s+/, <STDIN>);\nchomp (my @lst = split /\\s+/, <STDIN>);\n\nmy $prefix = '';\nmy $i = 1;\nwhile ($k > 0) {\n        foreach ( @lst ) {\n                print \"$i $prefix$_\";\n                $k--;\n                last if not ($k > 0);\n        }\n        $prefix .= pop @lst;\n        $prefix .= ' ';\n        $i++;\n}\n"}, {"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Wed Nov 21 22:10:07 IST 2012\n# File Name: c.pl\n# USAGE: \n#       c.pl \n# \n# \n#------------------------------------------------\nchomp (my ($n, $k) = split /\\s+/, <STDIN>);\nchomp (my @lst = split /\\s+/, <STDIN>);\n\nmy $prefix = '';\nmy $i = 1;\nwhile ($k > 0) {\n        foreach ( @lst ) {\n                print \"$i $prefix$_\";\n                $k--;\n        }\n        $prefix .= pop @lst;\n        $prefix .= ' ';\n        $i++;\n}\n"}], "src_uid": "2b77aa85a192086316a7f87ce140112d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tif( @_ == 1 ){\n\t\tprint 0;\n\t\tnext;\n\t\t}\n\t\n\tmy @ok;\n\t\n\tfor my $i ( map { $_[ 0 ] + $_ } -1 .. 1 ){\n\t\tfor my $j ( map { $_[ @_ - 1 ] + $_ } -1 .. 1 ){\n\t\t\tmy $d = $i - $j;\n\t\t\tnext if $d % ( @_ - 1 );\n\t\t\tmy $step = $d / ( @_ - 1 );\n\t\t\tmy $st = 0;\n\t\t\tmy @diffs;\n\t\t\tfor( @_ ){\n\t\t\t\tmy $diff = $st + ( $_ - $i );\n\t\t\t\tpush @diffs, $diff;\n\t\t\t\t$st += $step;\n\t\t\t\t}\n\t\t\t$debug and print \"$step| $i [@diffs] $j\";\n\t\t\t\n\t\t\tmy $bad = grep { $_ < -1 || $_ > 1 } @diffs;\n\t\t\t\n\t\t\t$bad or push @ok, \"@diffs\";\n\t\t\t}\n\t\t}\n\t\n\tif( !@ok ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tprint +( sort { $a <=> $b } map { ~~ ( () = /1/g ) } @ok )[ 0 ];\n\t\n\t$debug and print \"-\" x 15;\n\t}", "positive_code": [{"source_code": "# author : Gabriel Hofer\nuse warnings;\nuse strict;\nuse constant NL => qq/\\n/;\n\nmy $n = <STDIN>;\nmy @seq = split qq/ /, <STDIN>;\nmy ($one, $two) = ( $seq [ 0 ], $seq [ 1 ] );\nmy $min = 10e9 + 3;\nAB: for my $three ( ($one-1) .. ($one+1) ) {\n    AC: for my $four ( ($two-1) .. ($two+1) ) {\n        my $sum = 0; \n        my $six = $three; \n        my $difference = $four - $three;\n        AD: for my $five ( @seq ) {\n            if ( abs ( $six - $five ) > 1 ) { next AC }\n            else { $sum += abs ( $six - $five );\n                   $six += $difference }}\n        $min = $sum if $sum < $min; \n    }\n}\n\nprint qq/-1\\n/ if $min == (10e9 + 3);\nprint qq/$min\\n/ if $min != (10e9 + 3);\n\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\n@_ = split ' ', <>;\n\nif( @_ < 2 ){\n\tprint 0;\n\texit;\n\t}\n\nmy @ok;\n\nfor $i ( map { $_[ 0 ] + $_ } -1 .. 1 ){\n\tfor $j ( map { $_[ @_ - 1 ] + $_ } -1 .. 1 ){\n\t\t$s = ( $i - $j ) / ( @_ - 1 );\n\t\tnext if $s =~ /\\./;\n\t\t$z = 0;\n\t\tmy @d;\n\t\tfor( @_ ){\n\t\t\tpush @d, $z + ( $_ - $i );\n\t\t\t$z += $s;\n\t\t\t}\n\t\t\t\t\t\n\t\tpush @ok, ~~ ( () = \"@d\" =~ /1/g ) if !grep { $_ < -1 || $_ > 1 } @d;\n\t\t}\n\t}\n\nprint !@ok ? -1 : ( sort { $a <=> $b } @ok )[ 0 ]"}], "negative_code": [], "src_uid": "79b0794f81acc1c882649d96b1c7f8da"}
{"source_code": "#!/usr/bin/perl -w\n\nmy $n = <STDIN>;\nmy @a = split(/ /, <STDIN>);\nmy $s = 0;\nforeach my $x (@a) { $s += $x; }\n$s = int(($s + $n - 2) / ($n-1));\nforeach my $x (@a) { $s = $x if $s < $x; }\nprintf(\"%d\\n\", $s);", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nmy $n = <STDIN>;\nmy @a = split(/ /, <STDIN>);\nmy $s = 0;\nforeach my $x (@a) { $s += $x; }\npush @a, int(($s + $n - 2) / ($n-1));\n$s = 0;\nforeach my $x (@a) { $s = $x if $s < $x; }\nprintf(\"%d\\n\", $s);"}, {"source_code": "use POSIX qw/ceil/;\n$n=<>;$m=0;@l=split(' ',<>);foreach(@l){if($_>$m){$m=$_;}}\n$s=0;map{$s+=$_}@l;$s=ceil($s/($n-1));\nif($m>$s){$s=$m;}\nprint \"$s\\n\";\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl -w\n\nmy $n = <STDIN>;\nmy @a = split(/ /, <STDIN>);\nforeach my $x (@a) { $s += $x; }\n$s = int(($s + $n - 2) / ($n-1));\nprint \"$s\";"}, {"source_code": "use POSIX qw/ceil/;\n$n=<>;@l=split(' ',<>);$s=0;map{$s+=$_}@l;$s=ceil($s/($n-1));print \"$s\\n\";\n"}], "src_uid": "09f5623c3717c9d360334500b198d8e0"}
{"source_code": "print 0 + eval join '+', grep !/-/, map { $_[0] - 1 - $_ } @_ = sort {$b <=> $a} split ' ', <>", "positive_code": [{"source_code": "print 0 + eval join '+', grep !/-/, map { $_[0] - 1 - $_ } @_ = sort {$b <=> $a} split ' ', <>"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@_ = sort {$b <=> $a} split;\n\tprint 0 + eval join '+', grep !/-/, map { $_[0] - 1 - $_ } @_;\n\t\n\t}"}], "negative_code": [{"source_code": "print eval join '+', grep !/-/, map { $_[0] - 1 - $_ } @_ = sort {$b <=> $a} split ' ', <>"}], "src_uid": "b34846d90dc011f2ef37a8256202528a"}
{"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @array = split(' ', <>);\n\n@array = sort {$a <=> $b} @array;\n\n$n /= 2;\nmy $ans = 1 << 30;\n\nfor($_ = 0 ; $_ < $n ; $_ ++){\n\t$ans = $array[$_ + $n] - $array[$_]\n\t\tif $ans > $array[$_ + $n] - $array[$_];\n}\nprint \"$ans\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$n = <STDIN>;\n@x = split \" \", <STDIN>;\n@x = sort {$a <=> $b} @x;\n$len = @x;\n$step = ($n - 2) / 2 + 1;\n$ans = -1;\nfor ($i = 0;$i + $step < $len;$i ++) {\n    if ($ans == -1 || $x[$i + $step] - $x[$i] < $ans) {\n        $ans = $x[$i + $step] - $x[$i];\n    }\n}\nprint $ans, \"\\n\";\n\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @array = split(' ', <>);\n\n@array = sort {$a <=> $b} @array;\n\n$n /= 2;\nmy $ans = 1 << 30;\n\nfor($_ = 0 ; $_ < $n ; $_ ++){\n    $ans = $array[$_ + $n] - $array[$_]\n        if $ans > $array[$_ + $n] - $array[$_];\n}\nprint \"$ans\\n\";"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @array = split(' ', <>);\n\n@array = sort {$a <=> $b} @array;\n\n$n /= 2;\nmy $ans = 1 << 30;\n\nfor(0..$n){\n    $ans = $array[$_ + $n] - $array[$_]\n        if $ans > $array[$_ + $n] - $array[$_];\n}\nprint \"$ans\\n\";"}], "src_uid": "8aaabe089d2512b76e5de938bac5c3bf"}
{"source_code": "$m = ~0;\n$m > $_ and $m = $_ for @_ = (@_ = split ' ', (<>, <>)) x 2;\n\t\nprint $m * @_ / 2 + ( sort {$b <=> $a} map length, split ' ', join '', map { $_ = $_ == $m ? ' ':1 } @_ )[ 0 ]", "positive_code": [{"source_code": "use feature ':all';\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t$min = ~0;\n\t$min > $_ and $min = $_ for @_;\n\t@_ = (@_) x 2;\n\t$max = 0;\n\tfor (0 .. @_-1){\n\t\t$_[$_] == $min ?\n\t\t\t\t( $cnt = 0 )\n\t\t\t: \n\t\t\t\tdo { $cnt ++; $max < $cnt and $max = $cnt }\n\t\t}\n\t\t\n\tsay $min * @_ / 2 + $max\n\t}"}], "negative_code": [], "src_uid": "e2db09803d87362c67763ef71e8b7f47"}
{"source_code": "<>; print qw(NO YES)[ !/^0$|0.*0|^1( 1)+$/ ] for <>", "positive_code": [{"source_code": "($n, $_) = <>;\nif ($n > 1) {\n\t$r = (y/0/0/ == 1);\n} else {\n\t$r = /1/;\n}\nprint $r? \"YES\": \"NO\";"}], "negative_code": [{"source_code": "print qw(NO YES)[ (<> !~ /^0$|0.*0|^1( 1)+$/) ]"}, {"source_code": "print qw(NO YES)[ 0+ (<> !~ /^0$|0.*0/) ]"}], "src_uid": "7db0b870177e7d7b01da083e21ba35f5"}
{"source_code": "use strict;\nmy ($n,$t,$c) = split (' ',<>);\nmy @mi = split (' ',<>);\nmy $temp = 0;\nmy $ans = 0;\nfor my $h (@mi)\n{\n    if($h > $t) \n    {\n        $ans += ($temp - ($c-1)) if ($temp - ($c-1))>0;\n        $temp = 0;\n    }\n    else\n    {\n        $temp++;\n    } \n}\n$ans += ($temp - ($c-1)) if ($temp != 0 and ($temp - ($c-1))>0);\nprint $ans;", "positive_code": [{"source_code": "#!perl\n\nuse strict;\nuse warnings;\n\nmy ($n,$t,$c) = split /\\s+/ , <STDIN>;\nmy @serve = split /\\s+/ , <STDIN> ;\n\nmy %overflag;\nmy $i;\nfor($i=0;$i<$n;$i++){\n    $overflag{$i}=1 if($serve[$i]>$t) ;\n}\n\n$overflag{$n} = 1;\nmy $thisgood=0;\nmy $lastgood=0;\nmy $count=0;\n\nforeach(sort {$a<=>$b} keys %overflag ){\n    $thisgood = $_ - 1 ; \n    if ( $thisgood < $lastgood ){\n        $lastgood = $_ + 1;\n        next ;\n    }\n    \n    \n    my $temp = $thisgood - $lastgood + 1 ;\n    $count += $temp >= $c ? $temp -$c + 1 : 0;\n    $lastgood = $_ + 1;\n\n}\n\nprintf \"%d\\n\" , $count ;"}], "negative_code": [{"source_code": "use strict;\nmy ($n,$t,$c) = split (' ',<>);\nmy @mi = split (' ',<>);\nmy $temp = 0;\nmy $ans = 0;\nfor my $h (@mi)\n{\n    if($h > $t) \n    {\n        $ans += ($temp - ($c-1));\n        $temp = 0;\n    }\n    else\n    {\n        $temp++;\n    } \n}\n$ans += ($temp - ($c-1)) unless $temp == 0;\nprint $ans;"}, {"source_code": "#!perl\n\nuse strict;\nuse warnings;\n\nmy ($n,$t,$c) = split /\\s+/ , <STDIN>;\nmy @serve = split /\\s+/ , <STDIN> ;\nmy %overflag;\nmy %badflag;\nmy ($i,$count);\nfor($i=0;$i<$n;$i++){\n    $overflag{$i}++ if($serve[$i]>$t) ;\n}\nforeach(keys %overflag){\n    for($i=$_-$c +1; $i<= $_ ; $i++){\n        $badflag{$i} = 1 ;\n    }\n}\n$count = $n - $c + 1 - scalar keys %badflag;\n\nprintf \"%d\\n\" , $count ;"}, {"source_code": "#!perl\n\nuse strict;\nuse warnings;\n\nmy ($n,$t,$c) = split /\\s+/ , <STDIN>;\nmy @serve = split /\\s+/ , <STDIN> ;\n\nmy %overflag;\nmy $i;\nfor($i=0;$i<$n;$i++){\n    $overflag{$i}=1 if($serve[$i]>$t) ;\n}\n\n$overflag{$n+$c-2} = 1;\nmy $thisgood=0;\nmy $lastgood=0;\nmy $count=0;\n\nforeach(sort {$a<=>$b} keys %overflag ){\n    $thisgood = $_ - $c + 1; \n    if ( $thisgood < $lastgood || $lastgood == $_ ){\n        $lastgood = $_ + 1;\n        next ;\n    }\n    \n    \n    my $temp = $thisgood - $lastgood + 1 ;\n    $count += $temp >= $c ? $temp -$c + 1 : 0;\n    $lastgood = $_ + 1;\n\n}\n\nprintf \"%d\\n\" , $count ;"}, {"source_code": "#!perl\n\nuse strict;\nuse warnings;\n\nmy ($n,$t,$c) = split /\\s+/ , <STDIN>;\nmy @serve = split /\\s+/ , <STDIN> ;\n\nmy %overflag;\nmy $i;\nfor($i=0;$i<$n;$i++){\n\t$overflag{$i}=1 if($serve[$i]>$t) ;\n}\n\n$overflag{$n+$c-2} = 1;\nmy $thisgood=0;\nmy $lastgood=0;\nmy $count=0;\n\nforeach(sort {$a<=>$b} keys %overflag ){\n\t$thisgood = $_ - $c + 1; \n\tif ( $thisgood < $lastgood || $thisgood==$_){\n\t\t$lastgood = $_ + 1;\n\t\tnext ;\n\t}\n\t\n\t\n\tmy $temp = $thisgood - $lastgood + 1 ;\n\t$count += $temp >= $c ? $temp -$c + 1 : 0;\n\t$lastgood = $_ + 1;\n\n}\n\nprintf \"%d\\n\" , $count ;"}], "src_uid": "7d1e8769a6b1d5c6680ab530d19e7fa4"}
{"source_code": "my $n=<>;\nchomp($n);\nmy $ans=0;\nmy $d=substr($n,-2);\n$A{1}=0;\n$A{2}=0;\n$A{3}=0;\n$A{0}=4;\nprint $A{$d%4} . \"\\n\";", "positive_code": [{"source_code": "$_=<>;\nchomp;\n$_ or print 4;\n$_ or exit;\n$b=chop;\n$a=chop;\n$ab=$a.$b;\n$q= $ab % 4;\n\nif ($q==1){\n\t$s=1+2+3+4\n\t}\nelsif ($q==2){\n\t$s=1+4+9+6\n\t}\nelsif ($q==3){\n\t$s=1+8+7+4\n\t}\nelsif ($q==0){\n\t$s=1+6+1+6\n\t}\nprint $s % 5"}, {"source_code": "print <>=~/.?.$/ && $& % 4 % 5 ? 0:4"}, {"source_code": "use v5.10;\n\nchomp($line = <>);\n@a = (0, split //, $line);\n$b = 10*$a[$#a-1] + $a[$#a];\nsay($b%4==0 ? 4:0);\n"}], "negative_code": [{"source_code": "print<>%4?0:4"}], "src_uid": "74cbcbafbffc363137a02697952a8539"}
{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 2.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:36:23 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n\nwhile (<>) {\n    my $num = $_;\n    my $line;\n    my @names;\n    for (1..$num) {\n        chomp($name = <>);\n        push @names, $name;\n    }\n    my $hash;\n    for (reverse @names) {\n        print $_, \"\\n\" unless $hash->{$_};\n        $hash->{$_} = 1;\n    }\n}\nexit 0;\n", "positive_code": [{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 2.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:36:23 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n\nwhile (<>) {\n    chomp;\n    my $num = $_;\n    my $line;\n    my @names;\n    while ($_ --) {\n        chomp($line = <>);\n        push @names, $line;\n    }\n    @names = reverse @names;\n    my %hash;\n    for (@names) {\n        print $_, \"\\n\" unless $hash{$_};\n        $hash{$_} = 1;\n    }\n}\nexit 0;\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $sum = <>;\nmy @sms_hist;\n\n$sms_hist[$#sms_hist+1] = <> for (1..$sum);\nmap {chomp} @sms_hist;\n\nmy $uniq_hash = {};\nmy @chat_list;\n\nfor (reverse @sms_hist) {\n\tpush @chat_list, $_ unless ( $uniq_hash->{$_} );\n\t$uniq_hash->{$_} = 1;\n}\n\nprint join \"\\n\", @chat_list;"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 2.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:36:23 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n\nwhile (<>) {\n    my $num = $_;\n    my $line;\n    my @names;\n    while ($_ --) {\n        chomp($line = <>);\n        push @names, $line;\n    }\n    my $hash = {};\n    for (reverse @names) {\n        print $_, \"\\n\" unless $hash->{$_};\n        $hash->{$_} = 1;\n    }\n}\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 2.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:36:23 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n\nwhile (<>) {\n    my $num = $_;\n    my $line;\n    my @names;\n    chomp($names[$#names+1] = <>) for (1..$num);\n    my $hash;\n    for (reverse @names) {\n        print $_, \"\\n\" unless $hash->{$_};\n        $hash->{$_} = 1;\n    }\n}\nexit 0;\n"}, {"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 2.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 02:36:23 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n\nwhile (<>) {\n    my $num = $_;\n    my @names;\n    my $name;\n    for (1..$num) {\n        chomp($name = <>);\n        push @names, $name;\n    }\n    my $hash;\n    for (reverse @names) {\n        print $_, \"\\n\" unless $hash->{$_};\n        $hash->{$_} = 1;\n    }\n}\nexit 0;\n"}], "negative_code": [], "src_uid": "18f4d9262150294b63d99803250ed49c"}
{"source_code": "use bignum;\n$_=<>;\ns/[a-j]/$a[ord($&)]++?$&:$&/ige;\ns/\\?/$k++?$&:$&/ge;\n$_ and $f++ for @a;\n$n=10;\n$c=1;\n$c*=$n-- for (1..$f);\n$c*=10**$k;\nif (!/^\\d/){\n$c*=9;\n$c/=10;\n}\nprint $c", "positive_code": [{"source_code": "use bignum;\nchomp($_=<>);\n@_=split//;\nfor (@_){\nif (/\\?/){$k++}\nelsif (/[A-J]/){$a[ord($&)]++}\n}\n$_ and $f++ for @a;\n$n=10;\n$c=1;\n$c*=$n-- for (1..$f);\n$c*=10**$k;\nif ($_[0]!~/^\\d/){\n$c*=9;\n$c/=10;\n}\nprint $c"}], "negative_code": [{"source_code": "use bignum;\n$_=<>;\ns/[a-j]/$a[$&]++?$&:$&/ige;\ns/\\?/$k++?$&:$&/ge;\n$_ and $f++ for @a;\n$n=10;\n$c=1;\n$c*=$n-- for (1..$f);\n$c*=10**$k;\nif (!/^\\d/){\n$c*=9;\n$c/=10;\n}\nprint $c"}], "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82"}
{"source_code": "$_=<>;\n@_=((0..$_),(reverse(0..$_-1)));\n$_=join\" \",@_;\npush @a, $_;\nwhile(/1/){\ns/0/ /g;\ns/\\d+/$&-1/eg;\npush @a,$_;\nunshift @a,$_;\n}\ns/\\s*$// for @a;\n$,=\"\\n\";\nprint @a;", "positive_code": [{"source_code": "my $n = int<>;\nmy @arr;\nfor (0..$n) {\n    @arr = (0..$_, reverse 0..$_-1);\n    print ' ' x (($n - $_) * 2), \"@arr\\n\";\n}\nfor (my $i = $n - 1; $i >=0; $i--) {\n    @arr = (0..$i, reverse 0..$i-1);\n    print ' ' x (($n - $i) * 2), \"@arr\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\nfor (my ($i,$k) = (0, $n+$n); $i<$n; ++$i,$k-=2) {\n\t$line = '';\n\t$line .= ' ' x $k;\n\tfor (my $j=0; $j<$i; $j++) {\n\t\t$line .= \"$j \";\n\t}\n\tfor (my $j=$i; $j>0; $j--) {\n\t\t$line .= \"$j \";\n\t}\n\t$line .= '0';\n\tsay $line;\n}\nfor (my ($i,$k) = ($n, 0); $i>=0; --$i,$k+=2) {\n\t$line = '';\n\t$line .= ' ' x $k;\n\tfor (my $j=0; $j<$i; $j++) {\n\t\t$line .= \"$j \";\n\t}\n\tfor (my $j=$i; $j>0; $j--) {\n\t\t$line .= \"$j \";\n\t}\n\t$line .= '0';\n\tsay $line;\n}\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nsub doit {\n\tmy $n = shift;\n\tmy $m = shift;\n    print ' ' x (2 * ($n - $m));\n    print join ' ', ((0..$m), reverse (0..($m - 1)));\n    print \"\\n\";\n}\n\nmy $n = <>;\n\nfor my $m (0..$n) {\n\tdoit($n, $m);\n}\nfor my $m (reverse (0..($n - 1))) {\n\tdoit($n, $m);\n}"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = int <>;\nmy $s;\nmy $field = \"|\" x ($n * 4 + 1);\nmy $format = qq(\nformat =\n\\@$field\n\\$s\n.\n);\n\neval $format;\nfor my $row (0 .. $n) {\n$s = '';\nmap { $s .= \"$_ \" } (0 .. $row);\nmap { $s .=  $row-$_ . ' ' } ( 1 .. $row );\nchop $s;\nwrite; \n}\n\nfor my $row (0 .. $n-1) {\n$s = '';\nmap { $s .= \"$_ \" } (0 .. $n-1 - $row);\nmap { $s .= $n-1 - $row - $_ . ' ' } (1 .. $n-1 - $row);\nchop $s;\nwrite;\n}\n"}, {"source_code": "#!perl\n\n$n = <STDIN>;\nfor $i (0..$n) {\n\t@arr = ((0..$i), reverse (0..$i-1));\n\tprint ' ' x (($n - $i)*2), \"@arr\\n\"\n}\n\nfor ($i = $n-1; $i >= 0; $i--) {\n\t@arr = ((0..$i), reverse (0..$i-1));\n\tprint ' ' x (($n - $i)*2), \"@arr\\n\"\n}"}], "negative_code": [{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = int <>;\nmy $s;\nmy $field = \"|\" x ($n * 4 + 1);\nmy $format = qq(\nformat =\n\\@$field\n\\$s\n.\n);\n\neval $format;\nfor my $row (0 .. $n) {\n$s = '';\nmap { $s .= \"$_ \" } (0 .. $row);\nmap { $s .=  $row-$_ . ' ' } ( 1 .. $row );\nchop $s;\nwrite; \n}\n\nfor my $row (0 .. $n-1) {\n$s = '';\nmap { $s .= \"$_ \" } (0 .. $n-1 - $row);\nmap { $s .= $n-1 - $row . ' ' } (1 .. $n-1 - $row);\nchop $s;\nwrite;\n}\n"}, {"source_code": "$_=<>;\n@_=((0..$_),(reverse(0..$_-1)));\n$_=join\" \",@_;\npush @a, $_;\nwhile(/1/){\ns/0/ /g;\ns/\\d+/$&-1/eg;\npush @a,$_;\nunshift @a,$_;\n}\n$,=\",\";\nprint @a;"}, {"source_code": "$_=<>;\n@_=((0..$_),(reverse(0..$_-1)));\n$_=join\" \",@_;\npush @a, $_;\nwhile(/1/){\ns/0/ /g;\ns/\\d+/$&-1/eg;\npush @a,$_;\nunshift @a,$_;\n}\n$,=\"\\n\";\nprint @a;"}], "src_uid": "7896740b6f35010af751d3261b5ef718"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@d = split / /, <>;\n($a, $b) = split / /, <>;\n($a, $b, $ans) = ($a-1, $b-1, 0);\n$ans+=$d[$_] foreach ($a .. $b-1);\nsay $ans;", "positive_code": [{"source_code": "<>;\n@d = split(/ /, <>);\n($a, $b) = split(/ /, <>);\nfor($i=$a-1;$i<$b-1;$i++)\n{\n    $sum += $d[$i];\n}\nprint(\"$sum\\n\");\n"}, {"source_code": "while (<>){\n    @_=split/ /,<>;\n    <>=~/ /;\n    $sum=0;\n    for ($`..$'-1){\n        $sum+=$_[$_-1]\n        }\n    print \"$sum\\n\"\n    }"}], "negative_code": [], "src_uid": "69850c2af99d60711bcff5870575e15e"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy @c = split ' ', <>;\n\t\n\tmy $black = grep $_ == 1, @c;\n\t\n\tmy %h;\n\tmy %g;\n\tmy %cnt;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t\n\t\t$cnt{ $u } ++;\n\t\t$cnt{ $v } ++;\n\t\t}\n\t\n\tmy @leaf = grep { !$c[ $_ - 1 ] } grep { 1 == $cnt{ $_ } } keys %cnt;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\t$debug and print \"$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t\n\t\t$g{ $leaf }{ $next } = 1;\n\t\t$g{ $next }{ $leaf } = 1;\n\t\t\n\t\tnext if 1 < keys %{ $h{ $next } };\n\t\tnext if $c[ $next - 1 ];\n\t\t\n\t\tpush @leaf, $next;\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\t@leaf = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tif( $c[ $next - 1 ] == 0 ){\n\t\t\t$c[ $next - 1 ] = 1;\n\t\t\tdelete $h{ $leaf };\n\t\t\tdelete $h{ $next }{ $leaf };\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t$debug and print \"[@c]\";\n\t\n\t@leaf = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\tif( @leaf != $black ){\n\t\tprint join ' ', ( 1 ) x @c;\n\t\tnext;\n\t\t}\n\t\n\tmy @bfs = grep { 1 != keys %{ $h{ $_ } } } keys %h;\n\t\n\t$debug and print \"[@bfs]\";\n\t\n\twhile( @bfs ){\n\t\tmy $u = shift @bfs;\n\t\t\n\t\tfor my $v ( keys %{ $g{ $u } } ){\n\t\t\tif( $c[ $v - 1 ] == 0 ){\n\t\t\t\tpush @bfs, $v;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$c[ $u - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\tprint \"@c\" =~ y/03/10/r;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy @c = split ' ', <>;\n\t\n\tmy $black = grep $_ == 1, @c;\n\t\n\tmy %h;\n\tmy %g;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t}\n\t\n\tmy @leaf = grep { 1 == keys %{ $h{ $_ } } } grep { !$c[ $_ - 1 ] } keys %h;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t\n\t\t$g{ $leaf }{ $next } = 1;\n\t\t$g{ $next }{ $leaf } = 1;\n\t\t\n\t\tnext if 1 < keys %{ $h{ $next } };\n\t\tnext if $c[ $next - 1 ];\n\t\t\n\t\tpush @leaf, $next;\n\t\t}\n\t\n\t@leaf = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tif( $c[ $next - 1 ] == 0 ){\n\t\t\t$c[ $next - 1 ] = 1;\n\t\t\tdelete $h{ $leaf };\n\t\t\tdelete $h{ $next }{ $leaf };\n\t\t\t}\n\t\t}\n\t\n\t@leaf = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\tif( @leaf != $black ){\n\t\tprint join ' ', ( 1 ) x @c;\n\t\tnext;\n\t\t}\n\t\n\tmy @bfs = grep { 1 != keys %{ $h{ $_ } } } keys %h;\n\t\n\twhile( @bfs ){\n\t\tmy $u = shift @bfs;\n\t\t\n\t\tfor my $v ( keys %{ $g{ $u } } ){\n\t\t\tif( $c[ $v - 1 ] == 0 ){\n\t\t\t\tpush @bfs, $v;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$c[ $u - 1 ] = 3;\n\t\t}\n\t\n\tprint \"@c\" =~ y/03/10/r;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy @c = split ' ', <>;\n\t\n\tmy $black = grep $_ == 1, @c;\n\t\n\tmy %h;\n\tmy %g;\n\tmy %cnt;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t\n\t\t$cnt{ $u } ++;\n\t\t$cnt{ $v } ++;\n\t\t}\n\t\n\tmy @leaf = grep { !$c[ $_ - 1 ] } grep { 1 == $cnt{ $_ } } keys %cnt;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\t$debug and print \"$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t\n\t\t$g{ $leaf }{ $next } = 1;\n\t\t$g{ $next }{ $leaf } = 1;\n\t\t\n\t\tnext if 1 < keys %{ $h{ $next } };\n\t\tnext if $c[ $next - 1 ];\n\t\t\n\t\tpush @leaf, $next;\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\t@leaf = grep { \n\t\t\tmy @keys = keys %{ $h{ $_ } };\n\t\t\t@keys == 1 and \n\t\t\t3 > keys %{ $h{ $keys[ 0 ] } };\n\t\t\t} keys %h;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\tif( @leaf != $black ){\n\t\tprint join ' ', ( 1 ) x @c;\n\t\tnext;\n\t\t}\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tif( 0 == keys %{ $h{ $leaf } } ){\n\t\t\t$c[ $leaf - 1 ] = 2;\n\t\t\tdelete $h{ $leaf };\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tif( $c[ $leaf - 1 ] == 1 ){\n\t\t\tpush @leaf, $next;\n\t\t\t}\n\t\t\n\t\t$c[ $leaf - 1 ] = 2;\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t$debug and print \"[@c]\";\n\t\n\tmy @bfs = keys %h;\n\t\n\tfor( @bfs ){\n\t\t$c[ $_ - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\twhile( @bfs ){\n\t\tmy $u = shift @bfs;\n\t\t\n\t\tfor my $v ( keys %{ $g{ $u } } ){\n\t\t\tif( $c[ $v - 1 ] == 0 ){\n\t\t\t\tpush @bfs, $v;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$c[ $u - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\tprint \"@c\" =~ y/023/110/r;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy @c = split ' ', <>;\n\t\n\tmy $black = grep $_ == 1, @c;\n\t\n\tmy %h;\n\tmy %g;\n\tmy %cnt;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t\n\t\t$cnt{ $u } ++;\n\t\t$cnt{ $v } ++;\n\t\t}\n\t\n\tmy @leaf = grep { !$c[ $_ - 1 ] } grep { 1 == $cnt{ $_ } } keys %cnt;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\t$debug and print \"$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t\n\t\t$g{ $leaf }{ $next } = 1;\n\t\t$g{ $next }{ $leaf } = 1;\n\t\t\n\t\tnext if 1 < keys %{ $h{ $next } };\n\t\tnext if $c[ $next - 1 ];\n\t\t\n\t\tpush @leaf, $next;\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\t@leaf = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\tif( @leaf != $black ){\n\t\tprint join ' ', ( 1 ) x @c;\n\t\tnext;\n\t\t}\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tif( 0 == keys %{ $h{ $leaf } } ){\n\t\t\t$c[ $leaf - 1 ] = 2;\n\t\t\tdelete $h{ $leaf };\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tif( $c[ $leaf - 1 ] == 1 ){\n\t\t\tpush @leaf, $next;\n\t\t\t}\n\t\t\n\t\t$c[ $leaf - 1 ] = 2;\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t$debug and print \"[@c]\";\n\t\n\tmy @bfs = keys %h;\n\t\n\tfor( @bfs ){\n\t\t$c[ $_ - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\twhile( @bfs ){\n\t\tmy $u = shift @bfs;\n\t\t\n\t\tfor my $v ( keys %{ $g{ $u } } ){\n\t\t\tif( $c[ $v - 1 ] == 0 ){\n\t\t\t\tpush @bfs, $v;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$c[ $u - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\tprint \"@c\" =~ y/023/110/r;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nMAIN:\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy @c = split ' ', <>;\n\t\n\tmy @black;\n\t\n\tfor my $i ( 1 .. @c ){\n\t\t$c[ $i - 1 ] and push @black, $i;\n\t\t}\n\t\n\tmy %h;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t}\n\t\n\tmy @leaf = grep { !$c[ $_ - 1 ] } grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\t$debug and print \"$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\tmy @color = ( 0 ) x @c;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\t$color[ $leaf - 1 ] = 1;\n\t\t\n\t\tmy( $next ) = grep { 0 == $color[ $_ - 1 ] } keys %{ $h{ $leaf } };\n\t\t\n\t\tnext if 1 < keys %{ $h{ $next } };\n\t\tnext if $c[ $next - 1 ];\n\t\t\n\t\tpush @leaf, $next;\n\t\t}\n\t\n\t$debug and print \"[@color]\";\n\t\n\tfor my $black ( @black ){\n\t\tif( 1 != grep { !$color[ $_ - 1 ] } keys %{ $h{ $black } } ){\n\t\t\tprint join ' ', ( 1 ) x @c;\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tfor my $black ( @black ){\n\t\t$color[ $_ - 1 ] = 2 for $black, keys %{ $h{ $black } };\n\t\t}\n\t\n\t$debug and print \"[@color]\";\n\t$debug and print \"[@c]\";\n\t\n\tmy @bfs;\n\t\n\tfor my $i ( 1 .. @color ){\n\t\tif( $color[ $i - 1 ] == 0 ){\n\t\t\tpush @bfs, $i;\n\t\t\t}\n\t\t}\n\t\n\twhile( @bfs ){\n\t\tmy $u = shift @bfs;\n\t\t\n\t\t$color[ $u - 1 ] = 0;\n\t\t\n\t\tpush @bfs, grep { $color[ $_ - 1 ] == 1 } keys %{ $h{ $u } };\n\t\t}\n\t\n\t$debug and print \"[@color]\";\n\t\n\tprint \"@color\" =~ y/2/1/r;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy @c = split ' ', <>;\n\t\n\tmy $black = grep $_ == 1, @c;\n\t\n\tmy %h;\n\tmy %g;\n\tmy %cnt;\n\t\n\tfor my $i ( 1 .. $_ - 1 ){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t\n\t\t$g{ $u }{ $v } = 1;\n\t\t$g{ $v }{ $u } = 1;\n\t\t\n\t\t$cnt{ $u } ++;\n\t\t$cnt{ $v } ++;\n\t\t}\n\t\n\tmy @leaf = grep { !$c[ $_ - 1 ] } grep { 1 == $cnt{ $_ } } keys %cnt;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\t$debug and print \"$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t\n\t\tnext if 1 < keys %{ $h{ $next } };\n\t\tnext if $c[ $next - 1 ];\n\t\t\n\t\tpush @leaf, $next;\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t\n\t@leaf = grep { 1 == keys %{ $h{ $_ } } } keys %h;\n\t\n\t$debug and print \"[@leaf]\";\n\t\n\tif( @leaf != $black ){\n\t\tprint join ' ', ( 1 ) x @c;\n\t\tnext;\n\t\t}\n\t\n\twhile( @leaf ){\n\t\tmy $leaf = shift @leaf;\n\t\t\n\t\tmy( $next ) = keys %{ $h{ $leaf } };\n\t\t\n\t\tif( $c[ $leaf - 1 ] == 1 ){\n\t\t\tpush @leaf, $next;\n\t\t\t}\n\t\t\n\t\t$c[ $leaf - 1 ] = 2;\n\t\t\n\t\tdelete $h{ $leaf };\n\t\tdelete $h{ $next }{ $leaf };\n\t\t}\n\t\n\t$debug and print \":$_ -> \", join ' ', keys %{ $h{ $_ } } for sort keys %h;\n\t$debug and print \"[@c]\";\n\t\n\tmy @bfs = keys %h;\n\t\n\tfor( @bfs ){\n\t\t$c[ $_ - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\twhile( @bfs ){\n\t\tmy $u = shift @bfs;\n\t\t\n\t\tfor my $v ( keys %{ $g{ $u } } ){\n\t\t\tif( $c[ $v - 1 ] == 0 ){\n\t\t\t\tpush @bfs, $v;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$c[ $u - 1 ] = 3;\n\t\t}\n\t\n\t$debug and print \"[@c]\";\n\t\n\tprint \"@c\" =~ y/023/110/r;\n\t}"}], "src_uid": "2dcc82e6abc733a9c4567742294184dc"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tprint +( sort { $b <=> $a } map { eval join ' + ', split } @_ )[ 0 ];\n\t}", "positive_code": [{"source_code": "#!usr/bin/perl -w\nuse strict;\n\nmy $n=<STDIN>;chomp($n);\nmy $sum=0;\nfor my $i(1..$n){\n    my($x,$y)=split/ /,<STDIN>;chomp($y);\n    $sum=$x+$y if($sum<=$x+$y);\n}\nprint \"$sum\\n\";"}, {"source_code": "print +( sort { $b <=> $a } map { eval join ' + ', split } grep / /, <> )[ 0 ]"}], "negative_code": [{"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;chomp($n);\nmy @x,my @y,my $maxx=0,my $maxy=0;my $p=0,my $q=0;\nfor my $i(0..$n-1){\n    ($x[$i],$y[$i])=split/ /,<STDIN>;chomp($y[$i]);\n    if($maxx<=$x[$i]&&$maxy<=$y[$i]){\n\t$maxx=$x[$i];$p=$i;\n\t$maxy=$y[$i];$q=$i;\n    }\n    if($maxx<$x[$i]){\n\t$maxx=$x[$i];$p=$i;\n    }\n    if($maxy<$y[$i]){\n\t$maxy=$y[$i];$q=$i;\n    }\n}\nif($p==$q){\n    print 2*$x[$p] if($x[$p]>=$y[$p]);\n    print 2*$y[$p] if($x[$p]<$y[$p]);\n}\nelse{\n    my $j=$x[$p]+$y[$p];\n    my $k=$x[$q]+$y[$q];\n    print $j if($j>=$k);\n    print $k if($j<$k);\n}\nprint \"\\n\";"}], "src_uid": "7c41fb6212992d1b3b3f89694b579fea"}
{"source_code": "#usr/bin/perl -w\nuse strict;\n\nmy ($l,$r)=split/ /,<STDIN>;chomp($r);\nprint \"YES\\n\";my $n=$l;\nwhile($n<=$r){\n    print \"$n \";\n    $n++;\n    print \"$n\\n\";\n    $n++;\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n#use bigint;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $L, $R ) = split;\n\t\n\tprint \"YES\";\n\t\n\tfor( my $i = $L; $i < $R; $i += 2 ){\n\t\tprint join ' ', $i, $i + 1;\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "6432a543eeee9833c6d849222ad6b93d"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n# 2013/11/26\n# [解析性の解釈]\n#   障害等の問題の把握、切り分けなどの解析のしやすさ\n# 気を付けていること:\n# - if 文や関数引数内で計算しない (行ブレークかけた時に計算結果がわかりにくい)\n# - 各行はシンプルに (上と同じ理由)\n# - perlの場合は use strict と use warnings を付ける (表記の曖昧さを排除するため)\n# - 1関数あたり50行程度 (印刷したときに1頁に収まる)\n\n# TICKET1 ... 1回乗車券:$c[0] burles\n# TICKET2 ... 特定バス/路面電車指定乗車券:$c[1] burles\n# TICKET3 ... バスあるいは路面電車限定乗車券:$c[2] burles\n# TICKET4 ... 全てのバス/路面電車乗り放題乗車券:$c[3] burles\n\nuse constant ERR_OUTOFRANGE=>-1;\nuse constant NO_ERR=>0;\nuse constant TICKET1=>0;\nuse constant TICKET2=>1;\nuse constant TICKET3=>2;\nuse constant TICKET4=>3;\n\nmy $ret = NO_ERR;\n$ret = main();\nexit $ret;\n\n# メイン処理\nsub main {\n    # 変数初期化\n    my $min_cost = 0;\n    my $min_cost_bus = 0;\n    my $min_cost_trolley = 0;\n    my $cost_bus = 0;\n    my $cost_trolley = 0;\n\n    # 標準入力からデータの読み込み\n    my $line1 = <>;\n    my $line2 = <>;\n    my $line3 = <>;\n    my $line4 = <>;\n\n    # 入力データの整形\n    my (@c) = split(/ /, $line1);\n    my ($n, $m) = split(/ /, $line2);\n    my @a = sort {$b <=> $a} split(/ /, $line3); # 数字が大きい順にソート\n    my @b = sort {$b <=> $a} split(/ /, $line4); # 数字が大きい順にソート\n    \n    # 入力データのエラーチェック\n    foreach(@c) {\n        if ($_ < 1 || $_ > 1000) { return ERR_OUTOFRANGE; }\n    }\n    if ($n < 1 || $n > 1000) { return ERR_OUTOFRANGE; }\n    if ($m < 1 || $m > 1000) { return ERR_OUTOFRANGE; }\n    \n    # 全てTICKET1(一回乗車券)を使った場合\n    $cost_bus += $_ * $c[TICKET1] for @a;\n    $cost_trolley += $_ * $c[TICKET1] for @b;\n    $min_cost_bus = $cost_bus;\n    $min_cost_trolley = $cost_trolley;\n\n    # 乗った回数の多い順からTICKET2(特定バス/路面電車指定乗車券)を使った場合\n    # - バス\n    foreach(@a) {\n        if ($_ < 0 || $_ > 1000) { return ERR_OUTOFRANGE; }\n        $cost_bus = $cost_bus - $_ * $c[TICKET1] + $c[TICKET2];\n        # TICKET2を使っても安くならない場合は次へ\n        if ($cost_bus > $min_cost_bus) { last; }\n        $min_cost_bus = $cost_bus;\n    }\n    # - 路面電車\n    foreach(@b) {\n        if ($_ < 0 || $_ > 1000) { return ERR_OUTOFRANGE; }\n        $cost_trolley = $cost_trolley - $_ * $c[TICKET1] + $c[TICKET2];\n        # TICKET2を使っても安くならない場合は次へ\n        if ($cost_trolley > $min_cost_trolley) { last; }\n        $min_cost_trolley = $cost_trolley;\n    }\n\n    # TICKET3(バスあるいは路面電車限定乗車券)を使った場合\n    if ($min_cost_bus > $c[TICKET3]) { $min_cost_bus = $c[TICKET3]; }\n    if ($min_cost_trolley > $c[TICKET3]) { $min_cost_trolley = $c[TICKET3]; }\n\n    # TICKET4(全てのバス/路面電車乗り放題乗車券)を使った場合\n    $min_cost = $min_cost_bus + $min_cost_trolley;\n    if ($min_cost > $c[TICKET4]) { $min_cost = $c[TICKET4]; }\n\n    chomp($min_cost);\n    print \"$min_cost\\n\";\n\n    return NO_ERR;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n#今回はログを埋め込んだのみ。\n#起動時に-debugをオプションでつけるとデバッグログが出力される。\n\n#解析容易性というと難しいけど、\n#一般的にはやっぱりデバッグ用のログ埋め込みと\n#要所要所でアサーションを挟んでやることですかね。\n\n#デバッガを使うというのであれば\n#1行あたりの命令数を少なくしておくと、\n#ブレークポイントが設定しやすくなる。\n\n#exceptionが実装されているような言語なら、\n#メソッド分割をしっかりしておくとtraceしやすくなるような気がする。\n\n#ちなみに今回はログを自前実装していますが、\n#CPANから取ってくればよいログのライブラリもあります。\n#assetも標準では使えないのでコメントアウト。\n\nuse strict;\nuse warnings;\n\nmy $debug = 0;\n\nif(@ARGV > 0 && $ARGV[0] eq \"-debug\"){\n    $debug = 1;\n}\n\n#use Test::Harness::Assert;\n\n#入力処理\nmy $line = <STDIN>;\nchomp $line;\nmy @costs = split(/\\s+/,$line);\n\n$line = <STDIN>;\nchomp $line;\nmy($num_bus, $num_trolley) = split(/\\s+/,$line);\n\n$line = <STDIN>;\nchomp $line;\nmy @using_buses = split(/\\s+/,$line);\n\n#assert($num_bus == @using_buses);\n\n$line = <STDIN>;\nchomp $line;\nmy @using_trolley = split(/\\s+/,$line);\n\n#assert($num_trolley == @using_trolley);\n\n#コスト計算\nmy $bus_cost = &calc_cost(@using_buses);\n&debuglog(\"sum of buses cost = $bus_cost\\n\");\nmy $trolley_cost = &calc_cost(@using_trolley);\n&debuglog(\"sum of trolleys cost = $trolley_cost\\n\");\nmy $sum = $bus_cost + $trolley_cost;\n\n\n#出力処理\nif($sum < $costs[3]){\n    print $sum,\"\\n\";\n}else{\n    print $costs[3],\"\\n\";\n}\n\nsub calc_cost{\n    my @nums = @_;\n    my @one_type_costs;\n    my $sum = 0;\n    foreach my $num (@nums){\n        if($num eq \"\"){\n            next;\n        }\n        my $cost = &calc_onetype_cost($num);\n        &debuglog(\"one type cost = $cost\\n\");\n        $sum += $cost;\n    }\n    \n    if($sum < $costs[2]){\n        return $sum;\n    }else{\n        return $costs[2];\n    }\n}\n\nsub calc_onetype_cost{\n    my($num) = @_;\n    my $cost;\n    if($num * $costs[0] > $costs[1]){\n        $cost = $costs[1];\n    }else{\n        $cost = $num * $costs[0];\n    }\n    return $cost;\n}\n\nsub debuglog{\n    my $str = $_[0];\n    if($debug == 1){\n        print STDERR  \"$str\\n\";\n    }\n}\n\n"}, {"source_code": "while(<>){\n\tchomp;\n\t/ (\\d+) (\\d+) /;\n\t$bin=<>;\n\t$n=<>;\n\t$m=<>;\n\t@n=split/ /,$n;\n\t@m=split/ /,$m;\n\t$min=$';\n\t$sum=0;\n\tfor $i(@n){\n\t\t$sum+=($i*$`>$1?($1):($i*$`));\n\t\t}\n\t$sum=($sum>$2?($2):($sum));\n\t$mus=0;\n\tfor $i(@m){\n\t\t$mus+=($i*$`>$1?($1):($i*$`));\n\t\t}\n\t$mus=($mus>$2?($2):($mus));\t\t\n\t\n\t$min=($min>$sum+$mus?($sum+$mus):($min));\n\tprint \"$min\\n\";\n}"}], "negative_code": [], "src_uid": "11fabde93815c1805369bbbc5a40e2d8"}
{"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\n\nchomp $n;\n\nif ($n <=3) {\n\tprint \"NO\\n\";\n\texit;\n}\n\nprint \"YES\\n\";\n\nwhile ($n > 5) {\n\tprint \"$n - \";\n\tprint $n - 1;\n\tprint \" = 1\\n\";\n\tprint \"1 * 1 = 1\\n\";\n\t$n -= 2;\n}\n\nif ($n == 5) {\n\tprint \"3 - 2 = 1\\n\";\n\tprint \"5 + 1 = 6\\n\";\n\tprint \"4 * 1 = 4\\n\";\n\tprint \"6 * 4 = 24\\n\";\n} else {\n\tprint \"1 * 2 = 2\\n\";\n\tprint \"2 * 3 = 6\\n\";\n\tprint \"4 * 6 = 24\\n\";\n}", "positive_code": [{"source_code": "chomp (my $n = <>);\n\nsub show4 {\n    printf \"1 * 2 = 2\\n\";\n    printf \"3 * 2 = 6\\n\";\n    printf \"6 * 4 = 24\\n\";\n}\n\nsub show7 {\n    printf \"7 - 5 = 2\\n\";\n    printf \"6 - 4 = 2\\n\";\n    printf \"2 * 2 = 4\\n\";\n    &show4;\n}\n\nsub boil4 {\n    my $x = $_[0];\n    my $n = ($x - 4) >> 1;\n    while ($x > 4) {\n        printf \"%d - %d = 1\\n\", $x--, $x--;\n    }\n    while ($n--) {\n        printf \"1 * 1 = 1\\n\";\n    }\n}\n\nsub boil7 {\n    my $x = $_[0];\n    my $n = ($x - 7) >> 1;\n    while ($x > 7) {\n        printf \"%d - %d = 1\\n\", $x--, $x--;\n    }\n    while ($n--) {\n        printf \"1 * 1 = 1\\n\";\n    }\n}\n\nif (0) {\n} elsif ($n == 1) {\n    printf \"NO\\n\";\n} elsif ($n == 2) {\n    printf \"NO\\n\";\n} elsif ($n == 3) {\n    printf \"NO\\n\";\n} elsif ($n == 5) {\n    printf \"YES\\n\";\n    printf \"5 - 1 = 4\\n\";\n    printf \"4 - 2 = 2\\n\";\n    printf \"4 * 2 = 8\\n\";\n    printf \"3 * 8 = 24\\n\";\n} elsif ($n == 4) {\n    printf \"YES\\n\";\n    &show4;\n} elsif ($n == 7) {\n    printf \"YES\\n\";\n    &show7;\n} elsif ($n & 1) {\n    printf \"YES\\n\";\n    &boil7 ($n);\n    &show7;\n} else {\n    printf \"YES\\n\";\n    &boil4 ($n);\n    &show4;\n}"}], "negative_code": [{"source_code": "chomp (my $n = <>);\n\nsub show4 {\n    printf \"1 * 2 = 2\\n\";\n    printf \"3 * 2 = 6\\n\";\n    printf \"6 * 4 = 24\\n\";\n}\n\nsub show7 {\n    printf \"7 - 5 = 2\\n\";\n    printf \"6 - 4 = 2\\n\";\n    printf \"2 * 2 = 4\\n\";\n    &show4;\n}\n\nsub boil4 {\n    my $x = $_[0];\n    my $n = ($x - 4) >> 1;\n    while ($x > 4) {\n        printf \"%d - %d = 1\\n\", $x--, $x--;\n    }\n    while ($n--) {\n        printf \"1 * 1 = 1\\n\";\n    }\n}\n\nsub boil7 {\n    my $x = $_[0];\n    my $n = ($x - 7) >> 1;\n    while ($x > 7) {\n        printf \"%d - %d = 1\\n\", $x--, $x--;\n    }\n    while ($n--) {\n        printf \"1 * 1 = 1\\n\";\n    }\n}\n\nif (0) {\n} elsif ($n == 1) {\n    printf \"NO\\n\";\n} elsif ($n == 2) {\n    printf \"NO\\n\";\n} elsif ($n == 3) {\n    printf \"NO\\n\";\n} elsif ($n == 5) {\n    printf \"NO\\n\";\n    \n} elsif ($n == 4) {\n    printf \"YES\\n\";\n    &show4;\n} elsif ($n == 7) {\n    printf \"YES\\n\";\n    &show7;\n} elsif ($n & 1) {\n    &boil7 ($n);\n    &show7;\n} else {\n    &boil4 ($n);\n    &show4;\n}"}, {"source_code": "chomp (my $n = <>);\n\nsub show4 {\n    printf \"1 * 2 = 2\\n\";\n    printf \"3 * 2 = 6\\n\";\n    printf \"6 * 4 = 24\\n\";\n}\n\nsub show7 {\n    printf \"7 - 5 = 2\\n\";\n    printf \"6 - 4 = 2\\n\";\n    printf \"2 * 2 = 4\\n\";\n    &show4;\n}\n\nsub boil4 {\n    my $x = $_[0];\n    my $n = ($x - 4) >> 1;\n    while ($x > 4) {\n        printf \"%d - %d = 1\\n\", $x--, $x--;\n    }\n    while ($n--) {\n        printf \"1 * 1 = 1\\n\";\n    }\n}\n\nsub boil7 {\n    my $x = $_[0];\n    my $n = ($x - 7) >> 1;\n    while ($x > 7) {\n        printf \"%d - %d = 1\\n\", $x--, $x--;\n    }\n    while ($n--) {\n        printf \"1 * 1 = 1\\n\";\n    }\n}\n\nif (0) {\n} elsif ($n == 1) {\n    printf \"NO\\n\";\n} elsif ($n == 2) {\n    printf \"NO\\n\";\n} elsif ($n == 3) {\n    printf \"NO\\n\";\n} elsif ($n == 5) {\n    printf \"YES\\n\";\n    printf \"5 - 1 = 4\\n\";\n    printf \"4 - 2 = 2\\n\";\n    printf \"4 * 2 = 8\\n\";\n    printf \"3 * 8 = 24\\n\";\n} elsif ($n == 4) {\n    printf \"YES\\n\";\n    &show4;\n} elsif ($n == 7) {\n    printf \"YES\\n\";\n    &show7;\n} elsif ($n & 1) {\n    &boil7 ($n);\n    &show7;\n} else {\n    &boil4 ($n);\n    &show4;\n}"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\n\nchomp $n;\n\nif ($n <=3) {\n\tprint \"NO\\n\";\n\texit;\n}\n\nwhile ($n > 5) {\n\tprint \"$n - \";\n\tprint $n - 1;\n\tprint \" = 1\\n\";\n\tprint \"1 * 1 = 1\\n\";\n\t$n -= 2;\n}\n\nif ($n == 5) {\n\tprint \"3 - 2 = 1\\n\";\n\tprint \"5 + 1 = 6\\n\";\n\tprint \"4 * 1 = 4\\n\";\n\tprint \"6 * 4 = 24\\n\";\n} else {\n\tprint \"1 * 2 = 2\\n\";\n\tprint \"2 * 3 = 6\\n\";\n\tprint \"4 * 6 = 24\\n\";\n}"}], "src_uid": "1bd1a7fd2a07e3f8633d5bc83d837769"}
{"source_code": "my @r = ();\n\nmy $m=0;\nwhile(<>){\n    chomp;\n    push (@r, $_);\n    if(length > $m){$m = length;}\n}\n\n$c=0;\nprint '*' x ($m+2),\"\\n\";\nforeach $a (@r){\n    $l = length($a);$t=($m-$l)/2;\n    if(($l%2) != ($m%2)){\n        print '*', ' ' x ($t+$c%2), $a, ' ' x ($t+(1-$c%2)), \"*\\n\";\n        $c++;\n    }else{\n        print \"*\", ' 'x $t, $a, ' 'x$t, \"*\\n\";\n      \n    }\n}\nprint '*' x ($m+2);", "positive_code": [{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\nuse List::Util qw{max};\nuse integer;\n\nmy @s;\nmy ($i,$l) = (0,0);\nwhile ($s[$i] = <>) {\n    chomp $s[$i++];\n}\ndelete $s[$#s];\nmy $len = max map length, @s;\nprint '*' x ($len + 2), \"\\n\";\nfor (@s) {\n    print '*';\n    my $s = $len - length $_;\n    if ($s % 2) {\n\tprint ' ' x ($s / 2 + $l), $_, ' ' x ($s / 2 + 1 - $l);\n\t$l = 1 - $l;\n    } else {\n\tprint ' ' x ($s / 2), $_, ' ' x ($s / 2);\n    }\n    print \"*\\n\";\n}\nprint '*' x ($len + 2), \"\\n\";\n"}], "negative_code": [{"source_code": "my @r = ();\n\nmy $m=0;\nwhile(<>){\n    chomp;\n    push (@r, $_);\n    if(length > $m){$m = length;}\n}\n\n$c=0;\nprint '*' x ($m+2),\"\\n\";\nforeach $a (@r){\n    $l = length($a);$t=($m-$l)/2;\n    if(($l%2) != ($m%2)){\n        print '*', ' ' x ($t+$c%2), $a, ' ' x ($t+(1-$c%2)), \"*\\n\";\n        $c++;\n    }else{\n        print \"*\", ' 'x $t, $a, ' 'x$t, \"*\\n\";\n        $c=0;\n    }\n}\nprint '*' x ($m+2);"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\nuse List::Util qw{max};\nuse integer;\n\nmy @s;\nmy ($i,$l) = (0,1);\nwhile ($s[$i] = <>) {\n    chomp $s[$i++];\n}\ndelete $s[$#s];\nmy $len = max map length, @s;\nprint '*' x ($len + 2), \"\\n\";\nfor (@s) {\n    print '*';\n    my $s = $len - length $_;\n    if ($s % 2) {\n\tprint ' ' x ($s / 2 + $l), $_, ' ' x ($s / 2 + 1 - $l);\n\t$l = 1 - $l;\n    } else {\n\tprint ' ' x ($s / 2), $_, ' ' x ($s / 2);\n    }\n    print \"*\\n\";\n}\nprint '*' x ($len + 2), \"\\n\";\n"}], "src_uid": "a017393743ae70a4d8a9d9dc40410653"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub max {\n\tmy ($x, $y) = (shift, shift);\n\t$x>$y ? $x:$y;\n}\n\n($n, $s) = split / /, <>;\n($ans, $s) = (-1, 100*$s);\nforeach (1 .. $n) {\n\t($x, $y) = split / /, <>;\n\t$x*100+$y<=$s and $ans = max($ans,(100-$y)%100);\n}\nsay $ans;", "positive_code": [{"source_code": "#!perl\n\n($n, $mony) = split / /, <>;\n\n$mony1 = $mony - 1;\n$flag = 0;\n$maxResult = 0;\n\nforeach my $i (1..$n)\n{\n    ($dolars, $cents) = split / /, <>;\n    \n    if(($dolars <= $mony1) or ($dolars == $mony and $cents == 0))\n    {\n        $result = 100 - $cents; \n        $maxResult = $result if $result > $maxResult and $result < 100;\n        \n        $flag = 1;\n    }\n}\n\n$\\ = \"\\n\";\n\nif($flag == 1)\n{\n    print $maxResult;\n}\nelse\n{\n    print -1;\n}"}, {"source_code": "use List::Util \"max\";\n($n, $s) = split \" \", <>;\n$s = $s * 100;\n$max = -1;\nfor ($i = 0; $i < $n; $i++) {\n    ($d, $c) = split \" \", <>;\n    $cost = $d * 100 + $c;\n    $max = max($max, ($s - $cost) % 100) unless $cost > $s;\n}\nprint $max;"}, {"source_code": "($n,$s)=split/ /,<>;\nfor (<>){\n\t/ /,\n\t$s >= $`+$'/100 and push @_, $'+0 ? 100-$'\n\t\n\t:-0\n\t\n\t}\nprint @_?((sort{$b<=>$a}@_)[0])\n\n:-1"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub max {\n\tmy ($x, $y) = (shift, shift);\n\t$x>$y ? $x:$y;\n}\n\n($n, $s) = split / /, <>;\n($ans, $s) = (-1, 10*$s);\nforeach (1 .. $n) {\n\t($x, $y) = split / /, <>;\n\t$x*10+$y<=$s and $ans = max($ans,(100-$y)%100);\n}\nsay $ans;"}, {"source_code": "($n,$s)=split/ /,<>;\nfor (<>){\n\t/ /,\n\t$s >= $` and push @_, $'+0 ? 100-$'\n\t\n\t:-0\n\t\n\t}\nprint @_?((sort{$b<=>$a}@_)[0])\n\n:-1"}, {"source_code": "($n,$s)=split/ /,<>;\nfor (<>){\n\t/ /,\n\t$'+0 && $s >= $` and push @_, 100-$';\n\t}\nprint @_?((sort{$b<=>$a}@_)[0]) :-1"}, {"source_code": "($n,$s)=split/ /,<>;\nfor (<>){\n\t/ /,\n\t$s > $` and push @_, $'+0 ? 100-$'\n\t\n\t:-0\n\t\n\t}\nprint @_?((sort{$b<=>$a}@_)[0])\n\n:-1"}], "src_uid": "91be5db48b44a44adff4c809ffbb8e3e"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\t$debug and print \"\\$_:[$_]\";\n\t\n\tif( 0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t){\n\t\tprint 'YES';\n\t\tnext;\n\t\t}\n\t\n\tmy %h3;\n\t\n\tmap $h3{ $_ } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h3 ){\n\t\tif( exists $h3{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy %h2;\n\tmy %h2L;\n\tmy %h2R;\n\t\n\tm/\\b\\w\\w\\b(?{ push @{ $h2{ $& } }, $-[0] })(*FAIL)/gx;\n\t\n\t$debug and print \"$_-->[@{ $h2{ $_ } }]\" for sort keys %h2;\n\t\n\tm/\\w(\\w\\w)(?{ $h2L{ scalar reverse $1 }   = $-[0] })(*FAIL)/gx;\n\tm!(\\w\\w)\\w(?{ $h2R{ scalar reverse $1 } //= $-[0] })(*FAIL)!gx;\n\t\n\t$debug and print \"L:$_-->$h2L{ $_ }\" for sort keys %h2L;\n\t$debug and print \"R:$_-->$h2R{ $_ }\" for sort keys %h2R;\n\t\n\tfor my $key ( sort keys %h2 ){\n\t\t\n\t\tif( exists $h2{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t\n\t\tfor my $i ( 0 .. @{ $h2{ $key } } - 1 ){\n\t\t\t\n\t\t\tif( exists $h2L{ $key } and $h2{ $key }[ $i ] < $h2L{ $key } ){\n\t\t\t\tprint 'YES';\n\t\t\t\tnext MAIN;\n\t\t\t\t}\n\t\t\t\n\t\t\tif( exists $h2R{ $key } and $h2{ $key }[ $i ] > $h2R{ $key } ){\n\t\t\t\tprint 'YES';\n\t\t\t\tnext MAIN;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t}\n\t\n\tprint 'NO';\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy $ok = ( m/\\b\\w\\b/ || m/\\b(\\w)\\1\\b/ );\n\t\n\tmy %h2;\n\tmy %h3;\n\t\n\tm/\t\\b\\w\\w\\b\n\t\t(?{ $h2{ $& } ++;\n\t\t\t$h2{ ~~ reverse $& } and $ok = 1;\n\t\t\t})\n\t\t(?!)\n\t\t/x;\n\t\n\tm/\t\\w\\w\\w\n\t\t(?{ $h3{ $& } ++;\n\t\t\t$h3{ ~~ reverse $& } and $ok = 1;\n\t\t\t})\n\t\t(?!)\n\t\t/x;\n\t\n\tmy %h2L;\n\tmy %h2R;\n\t\n\tm/\\w(\\w\\w)(?{ $h2L{ ~~ reverse $1 }   = $+[0] })(*FAIL)/gx;\n\tm!(\\w\\w)\\w(?{ $h2R{ ~~ reverse $1 } //= $+[0] })(*FAIL)!gx;\n\t\n\twhile( m/\\b\\w\\w\\b/g ){\n\t\t\n\t\tif( $h2L{ $& } and $+[0] < $h2L{ $& } or\n\t\t\t$h2R{ $& } and $+[0] > $h2R{ $& }\n\t\t\t){\n\t\t\t$ok = 1;\n\t\t\t}\n\t\t}\n\t\n\tprint $ok ? 'YES' : 'NO';\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy $ok = m/\\b\\w\\b/;\n\t\n\tmy %h2;\n\tmy %h3;\n\tmy %h2R;\n\t\n\tm/\t\\b(\\w)(\\w)\n\t\t(?:\n\t\t\\b\n\t\t(?{ $h2{ $& } ++;\n\t\t\t$ok ||= $h2{ $2 . $1 };\n\t\t\t$ok ||= $h2R{ $& };\n\t\t\t})\n\t\t|\n\t\t(\\w)\n\t\t(?{ $h3{ $& } ++;\n\t\t\t$ok ||= $h3{ \"$3$2$1\" };\n\t\t\t$ok ||= $h2{ $3 . $2 };\n\t\t\t$h2R{ $2 . $1 } ++;\n\t\t\t})\n\t\t)\n\t\t(?!)\n\t\t/x;\n\t\n\tprint $ok ? 'YES' : 'NO';\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\t$debug and print \"\\$_:[$_]\";\n\t\n\tif( 0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t){\n\t\tprint 'YES';\n\t\tnext;\n\t\t}\n\t\n\tmy %h3;\n\t\n\tmap $h3{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h3 ){\n\t\tif( exists $h3{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy %h2;\n\tmy %h2L;\n\tmy %h2R;\n\t\n\tm/\\b\\w\\w\\b(?{ push @{ $h2{ $& } }, $-[0] })(*FAIL)/gx;\n\t\n\t$debug and print \"$_-->[@{ $h2{ $_ } }]\" for sort keys %h2;\n\t\n\tm/\\w(\\w\\w)(?{ $h2L{ scalar reverse $1 }   = $-[0] })(*FAIL)/gx;\n\tm!(\\w\\w)\\w(?{ $h2R{ scalar reverse $1 } //= $-[0] })(*FAIL)!gx;\n\t\n\t$debug and print \"L:$_-->$h2L{ $_ }\" for sort keys %h2L;\n\t$debug and print \"R:$_-->$h2R{ $_ }\" for sort keys %h2R;\n\t\n\tfor my $key ( sort keys %h2 ){\n\t\t\n\t\tif( exists $h2{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t\n\t\tfor my $i ( 0 .. @{ $h2{ $key } } - 1 ){\n\t\t\t\n\t\t\tif( exists $h2L{ $key } and $h2{ $key }[ $i ] < $h2L{ $key } ){\n\t\t\t\tprint 'YES';\n\t\t\t\tnext MAIN;\n\t\t\t\t}\n\t\t\t\n\t\t\tif( exists $h2R{ $key } and $h2{ $key }[ $i ] > $h2R{ $key } ){\n\t\t\t\tprint 'YES';\n\t\t\t\tnext MAIN;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t}\n\t\n\tprint 'NO';\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\t$debug and print \"\\$_:[$_]\";\n\t\n\tif( 0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t){\n\t\tprint 'YES';\n\t\tnext;\n\t\t}\n\t\n\tmy %h3;\n\t\n\tmap $h3{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h3 ){\n\t\tif( exists $h3{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy %h2;\n\tmy %h2L;\n\tmy %h2R;\n\t\n\tm/\\b\\w\\w\\b(?{ push @{ $h2{ $& } }, $-[0] })(*FAIL)/gx;\n\t\n\t$debug and print \"$_-->[@{ $h2{ $_ } }]\" for sort keys %h2;\n\t\n\tm/\\w(\\w\\w)(?{ $h2L{ scalar reverse $1 }   = $-[0] })(*FAIL)/gx;\n\tm!(\\w\\w)\\w(?{ $h2R{ scalar reverse $1 } //= $-[0] })(*FAIL)!gx;\n\t\n\t$debug and print \"L:$_-->$h2L{ $_ }\" for sort keys %h2L;\n\t$debug and print \"R:$_-->$h2R{ $_ }\" for sort keys %h2R;\n\t\n\tfor my $key ( sort keys %h2 ){\n\t\tfor my $i ( 0 .. @{ $h2{ $key } } - 1 ){\n\t\t\t\n\t\t\tif( exists $h2L{ $key } and $h2{ $key }[ $i ] < $h2L{ $key } ){\n\t\t\t\tprint 'YES';\n\t\t\t\tnext MAIN;\n\t\t\t\t}\n\t\t\t\n\t\t\tif( exists $h2R{ $key } and $h2{ $key }[ $i ] > $h2R{ $key } ){\n\t\t\t\tprint 'YES';\n\t\t\t\tnext MAIN;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t}\n\t\n\tprint 'NO';\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy $_b;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/   \\b(\\w)(\\w)\n\t\t\t\t( \\b )?\n\t\t\t\t(.*+)? (.*+)? (.*+)? (.*+)? .*\n\t\t\t\t( \\b )?\n\t\t\t\t\\2\\1\\b\n\t\t\t\t(??{ '-' x ( ( defined $3 ) * ( defined $4 ) ) })\n\t\t\t\t/sx\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy $_b;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/   \\b(\\w)(\\w)\n\t\t\t\t( \\b )?\n\t\t\t\t.*\n\t\t\t\t( \\b )?\n\t\t\t\t\\2\\1\\b\n\t\t\t\t(??{ '-' x ( ( defined $3 ) * ( defined $4 ) ) })\n\t\t\t\t/sx\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy $_b;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/   \\b(\\w)(\\w)\n\t\t\t\t( \\b )?\n\t\t\t\t.*\n\t\t\t\t( \\b )?\n\t\t\t\t\\2\\1\\b\n\t\t\t\t(??{ '-' x ( $3 * $4 ) })\n\t\t\t\t/sx\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy $_b;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/   \\b(\\w)(\\w)\n\t\t\t\t(?{ $_b = 0 })\n\t\t\t\t(?: \\b (?{ $_b ++ }) | )\n\t\t\t\t.*\n\t\t\t\t(?: \\b (?{ $_b ++ }) | (?{ $_b -- }) )\n\t\t\t\t\\2\\1\\b\n\t\t\t\t(??{ '-' x ( $_b > 1 ) })\n\t\t\t\t/sx\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tmy $_b;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/   \\b(\\w)(\\w)\n\t\t\t\t(?{ $_b = 0 })\n\t\t\t\t(?: \\b (?{ $_b ++ }) | (?{ $_b -- }) )\n\t\t\t\t.*\n\t\t\t\t(?: \\b (?{ $_b ++ }) | (?{ $_b -- }) )\n\t\t\t\t\\2\\1\\b\n\t\t\t\t(??{ '-' x ( $_b > 1 ) })\n\t\t\t\t/sx\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w)(.*+)?(.*+)?(.*+)?(.*+)?.*\\2\\1\\b/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w)(.*+)?(.*+)?.*\\2\\1\\b/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w)(??{ \".*$2$1\\\\b\" })/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w).*.*\\2\\1\\b/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nMAIN:\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap $h{ $& } ++, m/\\w\\w\\w/g;\n\t\n\tfor my $key ( sort keys %h ){\n\t\tif( exists $h{ scalar reverse $key } ){\n\t\t\tprint 'YES';\n\t\t\tnext MAIN;\n\t\t\t}\n\t\t}\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w).*\\2\\1\\b/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n# WA\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w).*.*\\2\\1\\b/s\n\t\t|| m/\\b(\\w)(\\w)(\\w).*.*\\3\\2\\1\\b/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w).*\\2\\1\\b/s\n\t\t|| m/\\b(\\w)(\\w)(\\w).*\\3\\2\\1\\b/s\n\t\t) ];\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = join '', map ~~<>, 1 .. $_;\n\t\n\tprint qw( NO YES )[ 0 + (\n\t\t0\n\t\t|| m/\\b\\w\\b/\n\t\t|| m/\\b(\\w)\\1\\b/\n\t\t|| m/\\b(\\w)\\w\\1\\b/\n\t\t|| m/\\b(\\w)(\\w).*\\2\\1\\b/s\n\t\t) ];\n\t}"}], "src_uid": "6d5aefc5a08194e35826764d60c8db3c"}
{"source_code": "#!/usr/bin/perl\n\n## + https://www.perlmonks.org/?node_id=11118153\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tchomp;\n\tmy $character_bank = join '', reverse sort split //;\n\t\n\t<>;\n\t@_ = split ' ', <>;\n\t\n\tmy @idx;\n\tmy @groups;\n\t\n\twhile( @idx != @_ ){\n\t\n\t\tmy @idx_new;\n\t\t\n\t\tOUTER:\n\t\tfor my $i ( 0 .. @_ - 1 ){\n\t\t\tmy $sum = 0;\n\t\t\tfor my $j ( @idx ){\n\t\t\t\tnext OUTER if $i == $j;\n\t\t\t\t$sum += abs( $i - $j );\n\t\t\t\t}\n\t\t\t\n\t\t\t$_[ $i ] == $sum and push @idx_new, $i;\n\t\t\t}\n\t\t\n\t\tpush @idx, @idx_new;\n\t\tpush @groups, 0 + @idx_new;\n\t\t}\n\t\n\t\n\t$debug and print \"idx:[@idx]\";\n\t$debug and print \"groups:[@groups]\";\n\t\n\tmy $re = join '', map { \"(?=(.)) (\\\\g{-2}{$_}) \\\\g{-2}* .*? \" } @groups;\n\t\n\t$debug and print \"re:[$re]\";\n\t$debug and print \"[[$character_bank]]\";\n\t\n\t$character_bank =~ /\n\t\t$re\n\t\t/x or print \"FAIL!\";\n\t\n\tmy @chars_seq = ( $character_bank =~ /$re/x )[ map 2 * $_ + 1, 0 .. @groups - 1 ];\n\t\n\t$debug and print \"[[@chars_seq]]\";\n\t\n\tmy $chars_seq = join '', @chars_seq;\n\t\n\tmy @ans;\n\t\n\tfor my $c ( split //, $chars_seq ){\n\t\t$ans[ shift @idx ] = $c;\n\t\t}\n\t\n\tprint @ans;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n## + https://www.perlmonks.org/?node_id=11118153\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\t\n\tchomp;\n\t$_ = join '', reverse sort split //;\n\t\n\t<>;\n\t@_ = split ' ', <>;\n\t\n\tmy @idx;\n\tmy @groups;\n\t\n\twhile( @idx != @_ ){\n\t\n\t\tmy @idx_new;\n\t\t\n\t\tOUTER:\n\t\tfor my $i ( 0 .. @_ - 1 ){\n\t\t\tmy $sum = 0;\n\t\t\tfor my $j ( @idx ){\n\t\t\t\tnext OUTER if $i == $j;\n\t\t\t\t$sum += abs( $i - $j );\n\t\t\t\t}\n\t\t\t\n\t\t\t$_[ $i ] == $sum and push @idx_new, $i;\n\t\t\t}\n\t\t\n\t\tpush @idx, @idx_new;\n\t\tpush @groups, 0 + @idx_new;\n\t\t}\n\t\n\tmy $re = join '', map { \"(?=(.)) (\\\\g{-2}{$_}) \\\\g{-2}* .*? \" } @groups;\n\t\n\tmy @ans;\n\t@ans[ @idx ] = map { split '' } ( /$re/x )[ map 2 * $_ + 1, 0 .. @groups - 1 ];\n\t\n\tprint @ans;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n## + https://www.perlmonks.org/?node_id=11118153\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\t\n\tchomp;\n\t$_ = join '', reverse sort split //;\n\t\n\t<>;\n\t@_ = split ' ', <>;\n\t\n\tmy @idx;\n\tmy @groups;\n\t\n\twhile( @idx != @_ ){\n\t\n\t\tmy @idx_new;\n\t\t\n\t\tOUTER:\n\t\tfor my $i ( 0 .. @_ - 1 ){\n\t\t\tmy $sum = 0;\n\t\t\tfor my $j ( @idx ){\n\t\t\t\tnext OUTER if $i == $j;\n\t\t\t\t$sum += abs( $i - $j );\n\t\t\t\t}\n\t\t\t\n\t\t\t$_[ $i ] == $sum and push @idx_new, $i;\n\t\t\t}\n\t\t\n\t\tpush @idx, @idx_new;\n\t\tpush @groups, 0 + @idx_new;\n\t\t}\n\t\n\tmy $re = join '', map { \"(?=(.)) (\\\\g{-2}{$_}) \\\\g{-2}* .*? \" } @groups;\n\t\n\tmy @ans;\n\t@ans[ @idx ] = map { split '' } ( /$re/x )[ map 2 * $_ + 1, 0 .. @groups - 1 ];\n\t\n\tprint \"@ans\";\n\t}"}], "src_uid": "bc2f2b98c50a0165b7204a6d595eec4b"}
{"source_code": "\n\nmy $n=<>;\nchomp($n);\nif($n==1){\n\tprint \"-1\\n\";\n}else{\nmy $ans=$n . \" \" . ($n+1) . \" \" . (($n+1)*$n) . \"\\n\";\nprint $ans;\n}", "positive_code": [{"source_code": "$_ = <>;\n\nprint $_ < 2 ? -1 : join ' ', $_ + 0, $_ + 1, $_ * ($_ + 1)"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\t\n\tprint $_ == 1 ? -1 : join ' ', $_, $_ + 1, $_ * ($_ + 1);\n\t\n\t\n\t}"}], "negative_code": [{"source_code": "\n\nmy $n=<>;\nchomp($n);\n\nmy $ans=$n . \" \" . ($n+1) . \" \" . (($n+1)*$n) . \"\\n\";\nprint $ans;"}, {"source_code": "\n\nmy $n=<>;\nchomp($n);\nif($n==1){\n\tprint \"-1\\n\";\n}\nmy $ans=$n . \" \" . ($n+1) . \" \" . (($n+1)*$n) . \"\\n\";\nprint $ans;"}], "src_uid": "f60ea0f2caaec16894e84ba87f90c061"}
{"source_code": "#!/usr/bin/perl -wl\nuse strict;\n\nsub getM {\n    my $n = shift;\n    my %M;\n    for my $i ( 1 .. $n ) {\n        @_ = split ' ', <>;\n        for ( @_ ) {\n            push @{ $M{ $i } }, $_;\n            $i++;\n        }\n    }\n    for ( keys %M ) {\n        @{ $M{ $_ } } = sort @{ $M{ $_ } };\n    }\n    %M;\n}\n\nwhile (<>) {\n    my ( $n, $m ) = split;\n    my %A = getM($n);\n    my %B = getM($n);\n    my $ok = grep { \"@{ $A{ $_ } }\" ne \"@{ $B{ $_ } }\" } keys %A;\n    print $ok ? \"NO\" : \"YES\";\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl -wl\n\nuse strict;\n\nwhile( <> ){\n    my( $n, $m ) = split;\n    \n    my %h;\n    for my $i ( 1 .. $n ){\n        @_ = split ' ', <>;\n        my $j = 0;\n        for( @_ ){\n            push @{ $h{ $i + $j } }, $_;\n            $j ++;\n            }\n        }\n    \n    my %g;\n    for my $i ( 1 .. $n ){\n        @_ = split ' ', <>;\n        my $j = 0;\n        for( @_ ){\n            push @{ $g{ $i + $j } }, $_;\n            $j ++;\n            }\n        }\n    \n    my $fail = 0;\n    for my $key ( sort keys %h ){\n        @{ $h{ $key } } = sort @{ $h{ $key } };\n        @{ $g{ $key } } = sort @{ $g{ $key } };\n    #%    print \"[@{ $h{ $key } }|@{ $g{ $key } }]\";\n        unless( \"@{ $h{ $key } }\" eq \"@{ $g{ $key } }\" ){\n            $fail ++;\n            }\n        }\n    \n    print $fail ? \"NO\" : \"YES\";\n    }\n"}], "negative_code": [], "src_uid": "77e2ddc4684fccd1856c93c2fc6e1ce2"}
{"source_code": "<>;\nprint sort <> =~ /./g", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tprint join '', sort split //;\n\t}"}, {"source_code": "<>;\n\nprint sort <> =~ /./g"}], "negative_code": [], "src_uid": "8616ede6867c8aacde986a123ec8a921"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t$_ = '1100' x ( 1 + $m / 4 );\n\t\n\ts/.//;\n\t\n\ts/.{$m}\\K.*//;\n\t\n\tmy $norm = $_;\n\tmy $inv = y/10/01/r;\n\t\n\t@_ = ( $norm );\n\t\n\tpush @_, ( $norm, $inv, $inv, $norm )[ $_ % 4 ] for 1 .. $n - 1;\n\t\n\tprint s/\\B/ /gr for @_;\n\t}", "positive_code": [{"source_code": "for(1..<>){($n,$m)=split/\\s/,<>;for(1..$n){for$j(1..$m){print\" \",($_^$j)%4>>1}}}"}, {"source_code": "for(1..<>){($n,$m)=split/\\s/,<>;for(1..$n){for$j(1..$m){print\" \",($_^$j)%4>>1}}}"}, {"source_code": "for(1..<>){($n,$m)=split/\\s/,<>;for(1..$n){for$j(1..$m){print\" \",($j%4==2||$j%4==3)^($_%4==2||$_%4==3)?1:0}}}"}, {"source_code": "for(1..<>){($n,$m)=split/\\s/,<>;for(1..$n){for$j(1..$m){print\" \",($_^$j)%4>>1}}}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\t$_ = '1100' x ( 1 + $m / 4 );\n\t\n\ts/.//;\n\t\n\ts/.{$m}\\K.*//;\n\t\n\tmy $norm = $_;\n\tmy $inv = y/10/01/r;\n\t\n\t@_ = ( $norm );\n\t\n\tpush @_, ( $norm, $inv, $inv, $norm )[ $_ % 4 ] for 1 .. $n - 1;\n\t\n\tprint for @_;\n\t}"}], "src_uid": "b7d40e7fc4f277cc801b59a21a16dfc1"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub getBits {\n\tmy ($x, $ret) = (shift, 0);\n\t# say \"x = $x\";\n\twhile ($x) {\n\t\t$ret += ($x & 1);\n\t\t$x >>= 1;\n\t}\n\t# say \"ret = $ret\";\n\treturn $ret;\n}\n\n($n, $m, $k) = split / /, <>;\npush @a, int(<>) foreach (0..$m);\ngetBits($_ ^ $a[$m])<=$k and ++$ans foreach (@a);\nsay $ans-1;", "positive_code": [{"source_code": "use strict;\nuse warnings;\n\nsub dec2bin {\n    my $str = unpack(\"B32\", pack(\"N\", shift));\n    $str =~ s/^0+(?=\\d)//;   # otherwise you'll get leading zeros\n    return $str;\n}\n\nmy @arr;\nmy ($n, $m, $k) = split / /, <>;\nmy ($count, $ans) = (0, 0);\nfor my $i(0..$m) {\n    chomp($_ = <>);\n    push @arr, $_;\n}\nfor my $i(0..$m-1) {\n    # $count = unpack(\"%32b*\", $arr[$i] ^ $arr[-1]) - 2;\n    $count = dec2bin(int$arr[$i] ^ int$arr[-1]) =~ tr/1/1/;\n    # print unpack(\"%32b*\", 4);\n    # print $arr[$i] . \" \" . $arr[-1] . \" \" . $count . \" \" . dec2bin(int$arr[$i] ^ int$arr[-1]) .\"\\n\";\n    $ans++ if ($count <= $k);\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub popcount {\n  my ($n) = @_;\n\n  my $c = 0;\n  while ($n) {\n    $c++;\n    $n = $n & ($n - 1);\n  }\n  $c;\n}\n\nsub hamming_distance {\n  my ($x, $y) = @_;\n\n  popcount((0+$x) ^ (0+$y));\n}\n\nmy ($n, $m, $k) = split ' ', <>;\n\nmy @players;\nfor (1..$m) {\n  push @players, scalar <>;\n}\nmy $fedor = <>;\n\nsay scalar grep { hamming_distance($fedor, $_) <= $k } @players;\n"}, {"source_code": "sub dec2bin {\n    my $str = unpack(\"B32\", pack(\"N\", shift));\n    $str =~ s/^0+(?=\\d)//;   # otherwise you'll get leading zeros\n    return $str;\n}\n\nmy @arr;\nmy ($n, $m, $k) = split / /, <>;\nmy ($count, $ans) = (0, 0);\nfor my $i(0..$m) {\n    chomp($_ = <>);\n    push @arr, $_;\n}\nfor my $i(0..$m-1) {\n    $count = dec2bin(int$arr[$i] ^ int$arr[-1]) =~ tr/1/1/;\n    $ans++ if ($count <= $k);\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/perl -w\n\nuse strict ;\n\n\nmy($n,$m,$k) = split /\\s+/s , <STDIN> ;\n\nmy @soldiertype = (0) ;\nmy $num = 1 ;\nwhile($num <= $m+1 ){\n    chomp ( $soldiertype[$num] = <STDIN> );\n    $num++ ;\n}\n\nmy $friend = 0 ;\nforeach(1..($m)){\n    my $cmp_soldier = $soldiertype[$m+1] ; \n    my $diff = 0 ;\n    while ( $cmp_soldier || $soldiertype[$_] ){\n        if ( ( $soldiertype[$_] & 1 ) ^ ( $cmp_soldier & 1 )  ){\n            $diff ++ ;\n        }\n        $cmp_soldier = $cmp_soldier >> 1 ;\n        $soldiertype[$_] = $soldiertype[$_] >> 1 ;\n    }\n    $friend++ if ( $diff <= $k ) ;\n}\n\nprint $friend, \"\\n\" ;"}], "negative_code": [{"source_code": "my @arr;\nmy ($n, $m, $k) = split / /, <>;\nmy ($count, $ans) = (0, 0);\nfor my $i(0..$m) {\n    chomp($_ = <>);\n    push @arr, $_;\n}\nfor my $i(0..$m-1) {\n    $count = unpack(\"%32b*\", $arr[$i] & $arr[-1]);\n    $ans++ if ($count <= $k);\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "my @arr;\nmy ($n, $m, $k) = split / /, <>;\nmy ($count, $ans) = (0, 0);\nfor my $i(0..$m) {\n    chomp($_ = <>);\n    push @arr, $_;\n}\nfor my $i(0..$m-1) {\n    $count = unpack(\"%32b*\", $arr[$i] ^ $arr[-1]);\n    $ans++ if ($count <= $k);\n}\nprint $ans . \"\\n\";\n"}], "src_uid": "5ebb0ee239d68ea33d9dac2d0bdd5f4e"}
{"source_code": "#!/usr/bin/perl\r\n\r\nmy ($t) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $t -- > 0 ){\r\n  my ($n,$m,$x) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n  $x--;\r\n  \r\n  my $r = int( $x / $n );\r\n  my $d = $x % $n;\r\n  \r\n  my $res = 1 + $d * $m + $r;\r\n  print \"$res\\n\";\r\n  \r\n}\r\n\r\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m, $x ) = split;\n\t\n\t$x --;\n\t\n\tmy $int = int $x / $n;\n\tmy $mod = $x % $n;\n\t\n\tprint 1 + $int + $mod * $m;\n\t}"}, {"source_code": "use bigint;\r\n<STDIN>;\r\nwhile (<>)\r\n{\r\n    chomp;\r\n    my ($n, $m, $x) = split;\r\n    $x--;\r\n    my ($r, $c) = ($x % $n, int($x / $n));\r\n    my $res = $r * $m + $c + 1;\r\n    print \"$res\\n\";\r\n}"}], "negative_code": [{"source_code": "use bigint;\r\n<STDIN>;\r\nwhile (<>)\r\n{\r\n    chomp;\r\n    my ($n, $m, $x) = split;\r\n    $x--;\r\n    my ($r, $c) = ($x % $n, $x / $n);\r\n    my $res = $r * $m + $c + 1;\r\n    print \"$res\\n\";\r\n}"}, {"source_code": "use bigint;\r\n<STDIN>;\r\nwhile (<>)\r\n{\r\n    my ($n, $mm, $x) = split / /, chomp;\r\n    $x--;\r\n    my ($r, $c) = ($x % $n, $x / $n);\r\n    my $res = $r * $mm + $c + 1;\r\n    print \"$res\\n\";\r\n}"}, {"source_code": "use bigint;\r\n<STDIN>;\r\nwhile (<>)\r\n{\r\n    my ($n, $m, $x) = split / /, chomp;\r\n    $x--;\r\n    my ($r, $c) = ($x % $n, $x / $n);\r\n    my $res = $r * $m + $c + 1;\r\n    print \"$res\";\r\n}"}], "src_uid": "e519e4495c9acef4c4a614aef73cb322"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t@A = ( 1 ) x 3;\r\n\tmy @B;\r\n\t\r\n\tfor( 1 .. $_ ){\r\n\t\t( $d, $k, $_ ) = split ' ', <>;\r\n\t\t\r\n\t\t$B[ $d ] ||= y/b-z//d;\r\n\t\t$A[ $d ] += $k * length;\r\n\t\t\r\n\t\tprint $B[ 2 ] ? 'YES' :\r\n\t\t\t  $B[ 1 ] ? 'NO' :\r\n\t\t\t  $A[ 1 ] < $A[ 2 ] ? 'YES' : 'NO'\r\n\t\t}\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy @h;\n\t\n\t$h[ 1 ]{ a } ++;\n\t$h[ 2 ]{ a } ++;\n\t\n\t$h[ 1 ]{ b } = 0;\n\t$h[ 2 ]{ b } = 0;\n\t\n\tfor( 1 .. $_ ){\n\t\tmy( $d, $k, $x ) = split ' ', <>;\n\t\t\n\t\tmy $B = $x =~ /[^a]/;\n\t\t\n\t\tif( $B ){\n\t\t\t$h[ $d ]{ b } = 1;\n\t\t\t}\n\t\t\n\t\t$x =~ s/[^a]//g;\n\t\t$h[ $d ]{ a } += $k * length $x;\n\t\t\n\t\tif( $h[ 2 ]{ b } ){\n\t\t\tprint 'YES';\n\t\t\t}\n\t\telsif( $h[ 1 ]{ b } ){\n\t\t\tprint 'NO';\n\t\t\t}\n\t\telse{\n\t\t\tprint $h[ 1 ]{ a } < $h[ 2 ]{ a } ? 'YES' : 'NO';\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "d40f0f3b577a1a5cfad2a657d6a1b90a"}
{"source_code": "use strict;\nour ($n, $m, @l, @r);\n\nsub calc {\n\tmy $p = shift;\n\tmy ($left, $right) = ($l[$p - 1], $r[$p + 1]);\n\tif (!$left and !$right) {\n\t\t$l[$p] = $r[$p] = $p;\n\t} elsif ($left and $right) {\n\t\t$r[$left] = $right;\n\t\t$l[$right] = $left;\n\t} elsif ($left) {\n\t\t$l[$p] = $left;\n\t\t$r[$left] = $p;\n\t} elsif ($right) {\n\t\t$r[$p] = $right;\n\t\t$l[$right] = $p;\n\t}\n\tmy $empty = ($l[$n] == undef);\n\tmy $last = ($empty? 0: $n - $l[$n] + 1);\n\t++$m - $last + 1;\n}\n\n$n = <>; \nprint \"1 \";\nprint calc($_), \" \" for split \" \", <>;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tmy $m = @_;\n\tmy $c = 1;\n\tmy @c;\n\tpush @c, $c;\n\tmy @used = (0) x $m;\n\t\n\tfor( @_ ){\n\t\t$used[ $_ - 1 ] = 1;\n\t\t$_ == $m ?\n\t\t\tdo {\n\t\t\t\tmy $i = $_;\n\t\t\t\twhile( $i > 0 and $used[ $i - 1 ] ){\n\t\t\t\t\t$c --;\n\t\t\t\t\t$m --;\n\t\t\t\t\t$i --;\n\t\t\t\t\t}\n\t\t\t\t$c ++;\n\t\t\t\tpush @c, $c;\n\t\t\t}\n\t\t\t:\n\t\t\tdo {\n\t\t\t\t$c ++;\n\t\t\t\tpush @c, $c;\n\t\t\t};\n\t\t}\n\t\n\tprint \"@c\";\n\t}"}, {"source_code": "$m = <>;\n\nprint 1, map {\n\t$U[ $_ - 1 ] = 1;\n\tif( $_ == $m ){\n\t\t$i = $_;\n\t\t$c --, $m -- while $U[ $i - 1 ] and $i --;\n\t\t}\n\t' ', 1 + ++ $c\n\t} split ' ', <>\n"}], "negative_code": [], "src_uid": "b97eeaa66e91bbcc3b5e616cb480c7af"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = ();\n@b = ();\nforeach (1 .. $n) {\n\t($x, $a) = split / /, <>;\n\t$x>0 and push @a, [$x, $a] or push @b, [$x, $a];\n}\n($an, $bn) = (scalar @a, scalar @b);\n@a = sort {$a->[0] <=> $b->[0]} @a;\n@b = sort {$b->[0] <=> $a->[0]} @b;\n$ans = 0;\n# positive first\n$tmp = 0;\nif ($bn < $an) {\n\t$tmp += $a[$_][1] foreach (0 .. $bn);\n\t$tmp += $b[$_][1] foreach (0 .. $bn-1);\n} else {\n\t$tmp += $a[$_][1] foreach (0 .. $an-1);\n\t$tmp += $b[$_][1] foreach (0 .. $an-1);\n}\n$ans = $tmp>$ans ? $tmp:$ans;\n# negative first\n$tmp = 0;\nif ($an < $bn) {\n\t$tmp += $a[$_][1] foreach (0 .. $an-1);\n\t$tmp += $b[$_][1] foreach (0 .. $an);\n} else {\n\t$tmp += $a[$_][1] foreach (0 .. $bn-1);\n\t$tmp += $b[$_][1] foreach (0 .. $bn-1);\n}\n$ans = $tmp>$ans ? $tmp:$ans;\nsay $ans;", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy (@neg, @pos);\n\nfor (1..$n) {\n  my $line = <>;\n  chomp $line;\n  my ($p, $apples) = split(/ /, $line);\n  if ($p < 0) {\n    $p *= -1;\n    push(@neg, \"$p:$apples\");\n  } else {\n    push(@pos, \"$p:$apples\");\n  }\n}\n\n@neg = sort {\n  my @agh = split(/:/, $a);\n  my @bgh = split(/:/, $b);\n  my $na = $agh[0];\n  my $nb = $bgh[0];\n  $na <=> $nb\n} @neg;\n\n@pos = sort {\n  my @agh = split(/:/, $a);\n  my @bgh = split(/:/, $b);\n  my $na = $agh[0];\n  my $nb = $bgh[0];\n  $na <=> $nb\n} @pos;\n\nmap { my @tmp = split(/:/, $_); $_ = $tmp[1] } @pos;\nmap { my @tmp = split(/:/, $_); $_ = $tmp[1] } @neg;\n\nmy @origpos = @pos;\nmy @origneg = @neg;\nmy $res = 0;\nmy $tmp = 0;\nwhile (scalar(@pos) > 0) {\n  $tmp += shift @pos;\n  if (scalar(@neg) > 0) {\n    $tmp += shift @neg;\n  } else {\n    last;\n  }\n}\nif ($tmp > $res) {\n  $res = $tmp;\n}\n@pos = @origpos;\n@neg = @origneg;\n$tmp = 0;\nwhile (scalar(@neg) > 0) {\n  $tmp += shift @neg;\n  if (scalar(@pos) > 0) {\n    $tmp += shift @pos;\n  } else {\n    last;\n  }\n}\nif ($tmp > $res) {\n  $res = $tmp;\n}\nprint \"$res\\n\";\n\n\n"}, {"source_code": "$\\ = $/;\n\nwhile($n = <>){\n\tundef @h;\n\tfor (1 .. $n){\n\t\tpush @h, split \" \", <>;\n\t\t}\n\t%h = @h;\n\n\t$u = $d = 0;\n\t/-/ ? $d++ : $u++ for keys %h;\n\t$min = $d > $u ? $u : $d;\n\t@d = sort {$b <=> $a} grep  /-/, keys %h;\n\t@u = sort {$a <=> $b} grep !/-/, keys %h;\n\t\n\t$sum = 0;\n\tfor (1 .. $min){\n\t\t$dd = shift @d;\n\t\t$uu = shift @u;\n\t\t$sum += $h{$dd};\n\t\t$sum += $h{$uu};\n\t\t}\n\t\n\t$iu = $id = 0;\n\t@d and $id = shift @d;\n\t@u and $iu = shift @u;\n\t\n\t$max = $h{$iu} > $h{$id} ? $h{$iu} : $h{$id};\n\t\n\t$sum += $max;\n\tprint $sum;\n\t}"}, {"source_code": "\t<>, %h = map split, <>;\n\n\t++ ( /-/ ? $d : $u ) for keys %h;\n\n\t@d = sort {$b <=> $a} grep  /-/, keys %h;\n\t@u = sort {$a <=> $b} grep !/-/, keys %h;\n\t\n\t$sum += $h{shift @d} + $h{shift @u} while @d && @u; \n\n\tprint $sum += 0 + $h{ 0 + \"@d@u\" }"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile($n = <>){\n\tundef @h;\n\tfor (1 .. $n){\n\t\tpush @h, split \" \", <>;\n\t\t}\n\t%h = @h;\n\n\t$u = $d = 0;\n\t/-/ ? $d++ : $u++ for keys %h;\n\t$min = $d > $u ? $u : $d;\n\t@d = sort sort {$b <=> $a} grep  /-/, keys %h;\n\t@u = sort sort {$a <=> $b} grep !/-/, keys %h;\n\t\n\t$sum = 0;\n\tfor (1 .. $min){\n\t\t$dd = shift @d;\n\t\t$uu = shift @u;\n\t\t$sum += $h{$dd};\n\t\t$sum += $h{$uu};\n\t\t}\n\t\n\t$iu = $id = 0;\n\t@d and $id = shift @d;\n\t@u and $iu = shift @u;\n\t\n\t$max = $h{$iu} > $h{$id} ? $h{$iu} : $h{$id};\n\t\n\t$sum += $max;\n\tprint $sum;\n\t}"}, {"source_code": "\t<>, %h = map split, <>;\n\n\t++ ( /-/ ? $d : $u ) for keys %h;\n\n\t@d = sort {$b <=> $a} grep  /-/, keys %h;\n\t@u = sort {$a <=> $b} grep !/-/, keys %h;\n\t\n\t$sum += $h{shift @d} + $h{shift @u} while @d && @u; \n\n\tprint $sum += 0 + $h{+\"@d@u0\"}"}, {"source_code": "\t<>, %h = map split, <>;\n\n\t++ ( /-/ ? $d : $u ) for keys %h;\n\n\t@d = sort {$b <=> $a} grep  /-/, keys %h;\n\t@u = sort {$a <=> $b} grep !/-/, keys %h;\n\t\n\t$sum += $h{shift @d} + $h{shift @u} while @d && @u; \n\t\n\tprint $sum += (@d, @u, 0)[0]"}], "src_uid": "bf573af345509b2364ada6e613b6f998"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tfor $i (0 .. @_ - 2){\n\t\tfor $j (0 .. @_ - 2 - $i){\n\t\t\tif ( $_[$j] > $_[$j+1] ){\n\t\t\t\t( $_[$j], $_[$j+1] ) = ($_[$j+1],  $_[$j]);\n\t\t\t\tprint $j+1, ' ', $j+2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "positive_code": [{"source_code": "@_ = split ' ', (<>,<>);\n\nfor (0 .. @_ - 2){\n\tfor $j (0 .. @_ - 2 - $i){\n\t\tif ( $_[$j] > $_[$j+1] ){\n\t\t\t( $_[$j], $_[$j+1] ) = ( $_[$j+1],  $_[$j] );\n\t\t\tprint $j+1, ' ', $j+2, \"\\n\"\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tfor $i (0 .. @_ - 2){\n\t\tfor $j ($i .. @_ - 2){\n\t\t\tif ( $_[$j] > $_[$j+1] ){\n\t\t\t\t( $_[$j], $_[$j+1] ) = ($_[$j+1],  $_[$j]);\n\t\t\t\tprint $j, ' ', $j+1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tfor $i (0 .. @_ - 2){\n\t\tfor $j ($i .. @_ - 2){\n\t\t\tif ( $_[$j] > $_[$j+1] ){\n\t\t\t\t( $_[$j], $_[$j+1] ) = ($_[$j+1],  $_[$j]);\n\t\t\t\tprint $j+1, ' ', $j+2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}"}, {"source_code": "@_ = split ' ', (<>,<>);\n\nfor (0 .. @_ - 2){\n\tfor $j (0 .. @_ - 2 - $i){\n\t\tif ( $_[$j] > $_[$j+1] ){\n\t\t\t( $_[$j], $_[$j+1] ) = ( $_[$j+1],  $_[$j] );\n\t\t\tprint $j+1, ' ', $j+2\n\t\t\t}\n\t\t}\n\t}"}], "src_uid": "233c2806db31916609421fbd126133d0"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\nfor $i(0..<>-1){s/$/$i%4==0?(\"a\"):($i%4==1?(\"b\"):($i%4==2?(\"c\"):(\"d\")))/e}\nprint;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "$n=<>;print substr('abcd'x($n/4+$n%4),0,$n);\n"}, {"source_code": "$n=<>;\n$s='abcd'x($n/4+$n%4);\nprint substr($s,0,$n);\n\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\nchomp ($i=<>);\n$_=\"abcd\"x($i/4+1);\nfor $j(1..4-$i%4){chop}\nprint ;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$_=\"abcd\"x25e3;\nchomp ($i=<>);\nprint substr($_,0,$i);\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$_=\"abcd\"x25e3;\n$i=<>;\ns/.{$i}//;\nprint \"$&\\n\";\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "94278e9c55f0fc82b48145ebecbc515f"}
{"source_code": "$_=<>;\n$a=<>;\n$b=<>;\nchomp($a,$b);\n$a1 = reverse $a;\n$b1 = reverse $b;\nprint \"both\" and exit if /$a.*$b/ and /$b1.*$a1/;\nprint \"forward\" and exit if /$a.*$b/;\nprint \"backward\" and exit if /$b1.*$a1/;\nprint \"fantasy\"\n", "positive_code": [{"source_code": "$_=<>;\n$a=<>;\n$b=<>;\nchomp($a,$b,$_);\n$a1=join '',reverse split'',$a;\n$b1=join '',reverse split'',$b;\nprint \"both\" and exit if /$a.*$b/ and /$b1.*$a1/;\nprint \"forward\" and exit if /$a.*$b/;\nprint \"backward\" and exit if /$b1.*$a1/;\nprint \"fantasy\";\n"}, {"source_code": "$_=<>;\n$a=<>;\n$b=<>;\nchomp($a,$b);\n$a1 = reverse $a;\n$b1 = reverse $b;\nprint \"both\" and exit if /$a.*$b/ and /$b1.*$a1/;\nprint \"forward\" and exit if /$a.*$b/;\nprint \"backward\" and exit if /$b1.*$a1/;\nprint \"fantasy\";\n"}, {"source_code": "$ch=<>;\nchomp$ch;\n$str1=<>;\nchomp$str1;\n$str2=<>;\nchomp$str2;\n$ok1=0,$ok2=0;\nif($ch=~m/$str1.*$str2/){\n$ok1=1;\n}\nif(reverse($ch)=~m/$str1.*$str2/){\n$ok2=1;\n}\nif($ok2+$ok1==2){\nprint \"both\";\n}\nelsif($ok1){\nprint\"forward\";\n}\nelsif($ok2){\nprint\"backward\"\n}\nelse{\nprint \"fantasy\";\n}\n\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $s = <>;\nchomp $s;\nmy $s1 = <>;\nchomp $s1;\nmy $s2 = <>;\nchomp $s2;\nmy $fb = 0;\n\n$fb += 1 if ($s =~ m/$s1.*$s2/);\n$s = reverse $s;\n$fb += 2 if ($s =~ m/$s1.*$s2/);\nif ($fb == 3) {\n    print \"both\\n\";\n} elsif ($fb == 2) {\n    print \"backward\\n\";\n} elsif ($fb == 1) {\n    print \"forward\\n\";\n} else {\n    print \"fantasy\\n\";\n}\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nuse strict;\n\nmy $flags=<STDIN>;chomp($flags);my $one=<STDIN>;chomp($one);my $two=<STDIN>;chomp($two);\nmy $sgalf=reverse $flags;\nif($flags=~/\\A.*?$one.*?$two/&&$sgalf=~/\\A.*?$one.*?$two/){print \"both\\n\";}\nelsif($flags=~/\\A.*?$one.*?$two/){print \"forward\\n\";}\nelsif($sgalf=~/\\A.*?$one.*?$two/){print \"backward\\n\";}\nelse{print \"fantasy\\n\";}\n"}], "negative_code": [{"source_code": "$_=<>;\n$a=<>;\n$b=<>;\nchomp($a,$b,$_);\nprint \"both\" and exit if /$a.*$b/ and /$b.*$a/;\nprint \"forward\" and exit if /$a.*$b/;\nprint \"backward\" and exit if /$b.*$a/;\nprint \"fantasy\";\n"}, {"source_code": "$_=<>;\n$a=<>;\n$b=<>;\nchomp($a,$b);\nprint \"both\" and exit if /$a.*$b/ and /$b.*$a/;\nprint \"forward\" and exit if /$a.*$b/;\nprint \"backward\" and exit if /$b.*$a/;\nprint \"fantasy\";\n"}, {"source_code": "$ch=<>;\nchomp$ch;\n$str1=<>;\nchomp$str1;\n$str2=<>;\nchomp$str2;\n$ok1=0,$ok2=0;\nif($ch=~m/$str1.*$str2/){\n$ok1=1;\n}\nif($ch=~m/$str2.*$str1/){\n$ok2=1;\n}\nif($ok2+$ok1==2){\nprint \"both\";\n}\nelsif($ok1){\nprint\"forward\";\n}\nelsif($ok2){\nprint\"backward\"\n}\nelse{\nprint \"fantasy\";\n}\n\n"}, {"source_code": "$ch=<>;\nchomp$ch;\n$str1=<>;\nchomp$str1;\n$str2=<>;\nchomp$str2;\n$ok1=0,$ok2=0;\nif($ch=~m/$str1.*$str2/){\n$ok1=1;\n}\nif(reverse($ch)=~m/$str2.*$str1/){\n$ok2=1;\n}\nif($ok2+$ok1==2){\nprint \"both\";\n}\nelsif($ok1){\nprint\"forward\";\n}\nelsif($ok2){\nprint\"backward\"\n}\nelse{\nprint \"fantasy\";\n}\n\n"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nuse strict;\n\nmy $flags=<STDIN>;chomp($flags);my $one=<STDIN>;chomp($one);my $two=<STDIN>;chomp($two);\nif($flags!~/$one/||$flags!~/$two/){print \"fantasy\\n\";}\nelse{\n    my $sgalf=reverse $flags;\n    my $fone=$flags=~s/\\A.*?$one//r;my $ftwo=$sgalf=~s/\\A.*?$one//r;\n    if($fone=~/$two/&&$ftwo=~/$two/){print \"both\\n\";}\n    elsif($fone!~/$two/&&$ftwo!~/$two/){print \"fantasy\\n\";}\n    else{\n\tmy $ans=($fone=~/$two/)?\"forward\\n\":\"backward\\n\";\n\tprint $ans;\n    }\n}"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nuse strict;\n\nmy $flags=<STDIN>;chomp($flags);my $one=<STDIN>;chomp($one);my $two=<STDIN>;chomp($two);\nmy $fone=$flags=~s/\\A.*$one//r;my $ftwo=$flags=~s/$fone//r;\nif($flags!~/$one/||$flags!~/$two/){print \"fantasy\\n\";}\nelse{\n    if($fone=~/$two/&&$ftwo=~/$two/) {print \"both\\n\";}\n    else{\n\tif($fone!~/$two/&&$ftwo!~/$two/){print \"fantasy\\n\";}\n\telse{\n\t    if($fone=~/$two/){print \"forward\\n\";}\n\t    else{ print \"backward\\n\";}\n\t}\n    }\n}"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nuse strict;\n\nmy $flags=<STDIN>;chomp($flags);my $one=<STDIN>;chomp($one);my $two=<STDIN>;chomp($two);\nmy $fone=$flags=~s/\\A.*$one//r;my $ftwo=$flags=~s/$fone//r;\nif($fone=~/$two/&&$ftwo=~/$two/) {print \"both\\n\";}\nelse{\n    if($fone!~/$two/&&$ftwo!~/$two/){print \"fantasy\\n\";}\n    else{\n\tif($fone=~/$two/){print \"forward\\n\";}\n\telse{ print \"backward\\n\";}\n    }\n}"}, {"source_code": "#!usr/bin/perl\nuse warnings;\nuse strict;\n\nmy $flags=<STDIN>;chomp($flags);my $one=<STDIN>;chomp($one);my $two=<STDIN>;chomp($two);\nmy $fone=$flags=~s/\\A.*?$one//r;my $ftwo=$flags=~s/$fone//r;\nif($flags!~/$one/||$flags!~/$two/){print \"fantasy\\n\";}\nelse{\n    if($fone=~/$two/&&$ftwo=~/$two/) {print \"both\\n\";}\n    else{\n\tif($fone!~/$two/&&$ftwo!~/$two/){print \"fantasy\\n\";}\n\telse{\n\t    if($fone=~/$two/){print \"forward\\n\";}\n\t    else{ print \"backward\\n\";}\n\t}\n    }\n}"}], "src_uid": "c3244e952830643938d51ce14f043d7d"}
{"source_code": "print substr 'aabb' x ($_ / 4 + 1), 0, $_ for <>", "positive_code": [{"source_code": "print substr 'aabb' x 5e4, 0, <>"}, {"source_code": "    $\\ = $/;\n     \n    while(<>){\n    \tprint substr 'aabb' x ($_ / 4 + 1), 0,  $_;\n     \n    \t}"}], "negative_code": [], "src_uid": "fbde86a29f416b3d83bcc63fb3776776"}
{"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t( $n ) = split;\n\t\n\t$_ = <>, <>;\n\t\n\tprint /\\b$n\\b/ ? \"YES\" : \"NO\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k1, $k2 ) = split;\n\t\n\tchomp( my $s1 = <> );\n\tchomp( my $s2 = <> );\n\t\n\tprint $s1 =~ /\\b$n\\b/ ? \"YES\" : \"NO\";\n\t}"}], "negative_code": [], "src_uid": "3ef23f114be223255bd10131b2375b86"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $d) = split;\n\t$max = 0;\n\t\n\tfor (1 .. $d){\n\t\t$m =()=<>=~ /1/g;\n\n\t\t$m != $n ? \n\t\t\tdo {\n\t\t\t\t$c ++;\n\t\t\t\t$c > $max and $max = $c;\n\t\t\t}\n\t\t:\n\t\t\tdo {\n\t\t\t\t$c = 0;\n\t\t\t\t}\n\t\t\n\t\t}\n\t\n\tprint $max\n\t}", "positive_code": [{"source_code": "($n, $d) = split ' ', <>;\n$d1 = '1' x $n;\nfor (<>) {\n\tchomp; \n\t$period .= ($_ eq $d1? '1': '0');\n}\n$maxlen = 0;\nwhile ($period =~ /0+/g) {\n\t$len = length($&);\n\t$maxlen = $len > $maxlen? $len: $maxlen;\n}\nprint $maxlen, \"\\n\";\n"}, {"source_code": "<>; ( $c += /0/ ? 1 : -$c )\n\t\n\t> $m and $m = $c for <>;\n\nprint 0 + $m"}], "negative_code": [], "src_uid": "a6ee741df426fd2d06fdfda4ca369397"}
{"source_code": "$n=<>;\nfor(1..$n){\n   $d=<>;\n   $delta=$d*($d-4);\n   if ($delta<0){print \"N\\n\";next;}\n   print(\"Y \",($d+sqrt $delta)/2,' ',($d -sqrt $delta)/2,\"\\n\");\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tif( $_ ** 2 < 4 * $_ ){\n\t\tprint 'N';\n\t\t}\n\telse{\n\t\tmy $D = $_ ** 2 - 4 * $_;\n\t\tmy $B = ( $_ + sqrt $D ) / 2;\n\t\tprint join ' ', 'Y', $B, $_ - $B;\n\t\t}\n\t\n\t}"}], "negative_code": [], "src_uid": "6f5d41346419901c830233b3bf5c9e65"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tchomp;\r\n\t( $A, $B, @A ) = ( ~~<>, ~~<> );\r\n\t\r\n\tif( $A ne $B and $A =~ y/10/01/r ne $B ){\r\n\t\tprint \"NO\";\r\n\t\tnext\r\n\t\t}\r\n\t\r\n\t$A =~ m/1(?{ push @A, \"$+[0] $+[0]\" })(?!)/;\r\n\t\r\n\t1 != ( $A eq $B ) + @A % 2 and \r\n\t\tpush @A, \"1 $_\", \"1 1\", \"2 $_\";\r\n\t\r\n\tprint for YES, 0 + @A, @A\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\tmy $A = <>;\n\tchomp $A;\n\tmy $B = <>;\n\tchomp $B;\n\t\n\tmy $invA = $A =~ y/10/01/r;\n\t\n\tif( $A ne $B and $invA ne $B ){\n\t\tprint 'NO';\n\t\tnext;\n\t\t}\n\t\n\tprint 'YES';\n\t\n\tmy $cA = () = $A =~ m/1/g;\n\t\n\tmy @ans;\n\t\n\twhile( $A =~ m/1/g ){\n\t\tpush @ans, join ' ', map $_ + 1, $-[0], $+[0] - 1;\n\t\t}\n\t\n\tif( $A eq $B ){\n\t\tif( $cA % 2 == 1 ){\n\t\t\tpush @ans, \"1 $_\", \"1 1\", \"2 $_\";\n\t\t\t}\n\t\telse{\n\t\t\t;\n\t\t\t}\n\t\t}\n\telse{\n\t\tif( $cA % 2 == 1 ){\n\t\t\t;\n\t\t\t}\n\t\telse{\n\t\t\tpush @ans, \"1 $_\", \"1 1\", \"2 $_\";\n\t\t\t}\n\t\t}\n\t\n\tprint for 0 + @ans, @ans;\n\t}"}, {"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tchomp;\r\n\t( $A, $B, $cA, @A ) = ( ~~<>, ~~<> );\r\n\t\r\n\tif( $A ne $B and $A =~ y/10/01/r ne $B ){\r\n\t\tprint 'NO';\r\n\t\tnext;\r\n\t\t}\r\n\t\r\n\twhile( $A =~ m/1/g ){\r\n\t\t$cA ++;\r\n\t\tpush @A, $-[0] + 1 . \" $+[0]\";\r\n\t\t}\r\n\t\r\n\t1 != ( $A eq $B ) + $cA % 2 and \r\n\t\tpush @A, \"1 $_\", \"1 1\", \"2 $_\";\r\n\t\r\n\tprint for 'YES', 0 + @A, @A;\r\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tchomp;\r\n\t( $A, $B, $cA, @A ) = ( ~~<>, ~~<> );\r\n\t\r\n\tif( $A ne $B and $A =~ y/10/01/r ne $B ){\r\n\t\tprint 'NO';\r\n\t\tnext;\r\n\t\t}\r\n\t\r\n\twhile( $A =~ m/1/g ){\r\n\t\t$cA ++;\r\n\t\tpush @A, $-[0] + 1 . \" $+[0]\";\r\n\t\t}\r\n\t\r\n\t1 != ( $A eq $B ) + $cA % 2 and \r\n\t\tpush @A, \"1 $_\\n1 1\\n2 $_\";\r\n\t\r\n\tprint for 'YES', 0 + @A, @A;\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\tmy $A = <>;\n\tchomp $A;\n\tmy $B = <>;\n\tchomp $B;\n\t\n\tmy $invA = $A =~ y/10/01/r;\n\t\n\tif( $A ne $B and $invA ne $B ){\n\t\tprint 'NO';\n\t\tnext;\n\t\t}\n\t\n\tprint 'YES';\n\t\n\tmy $cA = () = $A =~ m/1/g;\n\t\n\tmy @ans;\n\t\n\twhile( $A =~ m/1/g ){\n\t\tpush @ans, join ' ', map $_ + 1, $-[0], $+[0] - 1;\n\t\t}\n\t\n\tif( $A eq $B ){\n\t\tif( $cA % 2 == 1 ){\n\t\t\tpush @ans, \"1 $_\", \"1 1\", \"2 $_\";\n\t\t\t}\n\t\telse{\n\t\t\t;\n\t\t\t}\n\t\t}\n\telse{\n\t\tif( $cA % 2 == 1 ){\n\t\t\t;\n\t\t\t}\n\t\telse{\n\t\t\tpush @ans, \"1 $_\", \"1 1\", \"2 $_\";\n\t\t\t}\n\t\t}\n\t\n\tprint for @ans;\n\t}"}], "src_uid": "cc9abcff3224118b533881335e4c582b"}
{"source_code": "my $t=readline STDIN;\nchomp $t;\nwhile ($t) {\n    my $line= readline STDIN; chomp $line;\n    my ($a,$b)=split / /,$line;\n        \n    if ($a<$b) { ($b,$a)=($a,$b); }\n    if ($a==$b) { print (($a<<1)**2)}\n    elsif ($b==1) { print (($a)**2); }\n    elsif (($a/2) >= $b) {  print ($a**2); }\n    else {\n        print (($b<<1)**2);\n    }\n    print \"\\n\";\n    $t--;\n}", "positive_code": [{"source_code": "#perl 5.26.1 \n\n$n = <STDIN>;\nchomp $n;\n@ip = <STDIN>;\nchomp @ip;\nforeach (@ip) {\n    @test = split(' ', $_);\n    if ($test[0] > $test[1]) {\n        $dummy = 2*$test[1];\n        if ($dummy > $test[0] || $dummy == $test[0]) {\n            $ans = $dummy*$dummy;\n            print \"$ans\\n\";\n        }else {\n            $ans = $test[0]*$test[0];\n            print \"$ans\\n\";\n        }    \n    }elsif ($test[0] < $test[1]) {\n        $dummy = 2*$test[0];\n        if ($dummy > $test[1] || $dummy == $test[1]) {\n            $ans = $dummy*$dummy;\n            print \"$ans\\n\";\n        }else {\n            $ans = $test[1]*$test[1];\n            print \"$ans \\n\";\n        }\n    }else {\n        $ans = (2*$test[0])*(2*$test[0]);\n        print \"$ans \\n\";\n    }\n}"}], "negative_code": [{"source_code": "my $t=readline STDIN;\nchomp $t;\nwhile ($t) {\n    my $line= readline STDIN; chomp $line;\n    my ($a,$b)=split / /,$line;\n    \n    # if ($print ($a<<1)^2,\"\\n\" if ($a==$b);\n    \n    if ($a<$b) { ($b,$a)=($a,$b); }\n    if ($a==$b) { print (($a<<1)**2)}\n    elsif (($a/2) >= $b) {  print ($a**2); }\n    else {\n        print (($a+1)**2);\n    #print (($a>=$b)?(($b==1)?$a:$b<<1)**2:($b+1)**2);\n    }\n    print \"\\n\";\n    $t--;\n}"}], "src_uid": "3bb093fb17d6b76ae340fab44b08fcb8"}
{"source_code": "$\\ = $/;\n\n$_ = <>, chomp;\n\n$len = length;\n\n$p = 1;\n\n$p ++ while $len / $p > 20;\n\n$ch = int $len / $p;\n$ch2 = $ch + !! ( $len % $p );\n\n$re = \"(.{$ch,$ch2})\" x $p;\n\n/ ^ $re $ /x;\n\n@_ = map s/(.{$ch2}).?/$1/r, map \"$_*\", \n\tgrep length, $1, $2, $3, $4, $5;\n\nprint join ' ', ~~ @_, length $_[ 0 ];\n\nprint join \"\\n\", @_", "positive_code": [{"source_code": "$\\ = $/;\n\n<> =~\n\n/\n\t^\n\t(.{0,20})\n\t(?: (?{ $h{ length $1 } ++ }) | (?{ $h{ length $1 } -- }) (*FAIL) )\n\t(.{0,20})\n\t(?: (?{ $h{ length $2 } ++ }) | (?{ $h{ length $2 } -- }) (*FAIL) )\n\t(.{0,20})\n\t(?: (?{ $h{ length $3 } ++ }) | (?{ $h{ length $3 } -- }) (*FAIL) )\n\t(.{0,20})\n\t(?: (?{ $h{ length $4 } ++ }) | (?{ $h{ length $4 } -- }) (*FAIL) )\n\t(.{0,20})\n\t$\n\t(?: (?{ $h{ length $5 } ++ }) | (?{ $h{ length $5 } -- }) (*FAIL) )\n\t(?(?{ @_ = grep $_, grep $h{ $_ }, keys %h; @_ < 3 and 2 > abs( $_[ -1 ] - $_[ 0 ] ) }) | (*FAIL) )\n/x;\n\n@_ = grep length, $1, $2, $3, $4, $5;\n\n$_ = substr $_ . '*' x 100, 0, 99 for @_;\n\nmap chop, @_ while @_ == grep /\\*/, @_;\n\nprint join ' ', ~~ @_, length $_[ 0 ];\n\nprint join \"\\n\", @_"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $len = length;\n\t\n\t$debug and print $len;\n\t\n\tmy $part = 1;\n\t\n\twhile( $len / $part > 20 ){\n\t\t$part ++;\n\t\t}\n\t\n\t$debug and print $part;\n\t\n\tmy $chunk = $len / $part;\n\t$debug and print $chunk;\n\t\n\tif( $chunk !~ /\\./ ){\n\t\t;\n\t\t}\n\telse{\n\t\tmy $plus = ( 1 + int $chunk ) * $part - $len;\n\t\t\n\t\t$debug and print $plus;\n\t\t\n\t\tmy $int = int $chunk;\n\t\t\n\t\ts/.{$int}\\K/ $plus -- > 0 ? '*' : '' /eg;\n\t\t$chunk = 1 + int $chunk;\n\t\t}\n\t\n\t$debug and print;\n\t\n\t@_ = /.{$chunk}/g;\n\t\n\tprint join ' ', ~~ @_, $chunk;\n\t\n\tprint for @_;\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\n$_ = <>;\n\n$len = length;\n\n$p = 1;\n\n$p ++ while $len / $p > 20;\n\n$ch = int $len / $p;\n$ch2 = $ch + !! ( $len % $p );\n\n$re = \"(.{$ch,$ch2})\" x $p;\n\n/ ^ $re $ /x;\n\n@_ = map s/(.{$ch2}).?/$1/r, map \"$_*\", \n\tgrep length, $1, $2, $3, $4, $5;\n\nprint join ' ', ~~ @_, length $_[ 0 ];\n\nprint join \"\\n\", @_"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $len = length;\n\t\n\t$debug and print $len;\n\t\n\tmy $part = 1;\n\t\n\twhile( $len / $part > 20 ){\n\t\t$part ++;\n\t\t}\n\t\n\t$debug and print $part;\n\t\n\tmy $chunk = $len / $part;\n\t$debug and print $chunk;\n\t\n\tif( $chunk !~ /\\./ ){\n\t\t;\n\t\t}\n\telse{\n\t\tmy $plus = ( 1 + int $chunk ) * $part - $len;\n\t\t\n\t\t$debug and print $plus;\n\t\t\n\t\tmy $int = int $chunk;\n\t\t\n\t\t$plus --, s/.{$int}\\K/\\*/ while $plus;\n\t\t$chunk = 1 + int $chunk;\n\t\t}\n\t\n\t$debug and print;\n\t\n\t@_ = /.{$chunk}/g;\n\t\n\tprint join ' ', ~~ @_, $chunk;\n\t\n\tprint for @_;\n\t}"}, {"source_code": "$\\ = $/;\n\n$len = length;\n\n$p = 1;\n\n$p ++ while $len / $p > 20;\n\n$ch = int $len / $p;\n$ch2 = $ch + !! ( $len % $p );\n\n$re = \"(.{$ch,$ch2})\" x $p;\n\n/ ^ $re $ /x;\n\n@_ = map s/(.{$ch2}).?/$1/r, map \"$_*\", \n\tgrep length, $1, $2, $3, $4, $5;\n\nprint join ' ', ~~ @_, length $_[ 0 ];\n\nprint join \"\\n\", @_"}], "src_uid": "ac047ceede246b40892c80dbd696e6b4"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\tprint for $_, join ' ', ( 1 ) x $_;\n\t}", "positive_code": [{"source_code": " \nuse 5.20.1;\nuse strict;\nmy $n = <STDIN>;\nsay $n;\nsay \"1\" until ($n-- < 1);"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = sort { $a <=> $b } split ' ', <>;\n\t\n\tmy @cand;\n\t\n\tfor my $cand ( 1 .. 100 ){\n\t\tmy $sum = 0;\n\t\tfor( @_ ){\n\t\t\tmy $x = abs( $cand - $_ ) - 1;\n\t\t\t$x < 0 and $x = 0;\n\t\t\t$sum += $x;\n\t\t\t}\n\t\tpush @cand, [ $cand, $sum ];\n\t\t}\n\t\n\tprint \"@{ ( sort { $a->[ 1 ] <=> $b->[ 1 ] } @cand )[ 0 ] }\";\n\t}"}], "src_uid": "7c483498f497f4291e3d33375c0ebd53"}
{"source_code": "for (1..<>) {\r\n        chomp (my $n = <>);\r\n        if ($n%3 == 0) {\r\n                print $n/3, \" \", $n/3;\r\n        } elsif ($n%3 == 1) {\r\n                print int($n/3)+1, \" \", int($n/3);\r\n        } elsif ($n%3 == 2) {\r\n                print int($n/3), \" \", int($n/3)+1;\r\n        }\r\n        print \"\\n\";\r\n}\r\nexit;", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy $A = int $_ / 3;\n\tmy $B = $_ % 3;\n\t\n\tprint join ' ', do {\n\t\tif( 0 ){ ; }\n\t\telsif( $B == 0 ){\n\t\t\t$A + 0, $A + 0\n\t\t\t}\n\t\telsif( $B == 1 ){\n\t\t\t$A + 1, $A + 0\n\t\t\t}\n\t\telsif( $B == 2 ){\n\t\t\t$A + 0, $A + 1\n\t\t\t}\n\t\t};\n\t}"}], "negative_code": [], "src_uid": "71335a9489f0985f4e16435b14d6a34a"}
{"source_code": "<>;\n@a = sort {$a <=> $b} split \" \", <>;\n@b = split \" \", <>;\n@c = sort {$a <=> $b} split \" \", <>;\n$i = 0;\nfor (@a){\n$_ == $c[$i] ? ($i++) : (push @ans, $_)\n}\n$aa = $bb = 0;\n$ans[0] == $_ and $aa++ for @a;\n$ans[0] == $_ and $bb++ for @b;\n$, = $/;\nprint $aa == $bb ? (reverse @ans): @ans", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\n\nmy $N = <>+0;\n\nmy $line = <>;\nchomp $line;\nmy @A = split ' ', $line;\nmy %S = ();\nforeach my $x (@A) {\n   ++$S{ int($x) };\n}\n\n$line = <>;\nchomp $line;\nmy @B = split ' ', $line;\nforeach my $x (@B) {\n   --$S{ int($x) };\n   delete $S{ int($x) } unless $S{ int($x) }\n}\nforeach my $k (keys(%S)) {\n   print $k, \"\\n\"\n}\n\n%S = ();\nforeach my $x (@B) {\n   ++$S{ int($x) };\n}\n\n$line = <>;\nchomp $line;\nmy @C = split ' ', $line;\nforeach my $x (@C) {\n   --$S{ int($x) };\n   delete $S{ int($x) } unless $S{ int($x) }\n}\nforeach my $k (keys(%S)) {\n   print $k, \"\\n\"\n}\n"}, {"source_code": "<>;\nmy %hash;\nmy %hash2;\n$hash{int$_}++ for(split / /, <>);\n$hash2{int$_}++, $hash{int$_}-- for(split / /, <>);\n$hash2{int$_}-- for(split / /, <>);\nprint grep{$hash{$_} == 1} keys %hash;\nprint \"\\n\";\nprint grep{$hash2{$_} == 1} keys %hash2;"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = sort { $a <=> $b } split / /, <>;\n@b = sort { $a <=> $b } split / /, <>;\n@c = sort { $a <=> $b } split / /, <>;\nfor ($i=0; $i<$n-1; $i++) {\n\t$a[$i]!=$b[$i] and say $a[$i] and last;\n}\n$i>=$n-1 and say $a[$n-1];\nfor ($i=0; $i<$n-2; $i++) {\n\t$b[$i]!=$c[$i] and say $b[$i] and last;\n}\n$i>=$n-2 and say $b[$n-2];\n"}, {"source_code": "chomp (my @s = split /\\s+/, <STDIN>);\nchomp (my @i = sort {$a <=> $b} split /\\s+/, <STDIN>);\nchomp (my @j = sort {$a <=> $b} split /\\s+/, <STDIN>);\nchomp (my @k = sort {$a <=> $b} split /\\s+/, <STDIN>);\n\nmy $x;\nfor ($x = 0; $x < @j; $x++) {\n  if ($i[$x] != $j[$x]) {\n    printf \"$i[$x]\\n\";\n    last;\n  }\n}\nprintf \"$i[$x]\\n\" if ($x == @j);\nfor ($x = 0; $x < @k; $x++) {\n  if ($j[$x] != $k[$x]) {\n    printf \"$j[$x]\\n\";\n    last;\n  }\n}\nprintf \"$j[$x]\\n\" if ($x == @k);\n"}, {"source_code": "use strict;\nuse warnings;\n\n<>;\nmy (%a, %b, %c);\n\nfor my $ref (\\%a, \\%b, \\%c) {\n    for my $elt (split ' ', <>) {\n        $$ref{$elt}++;\n    }\n}\n\nmy ($x) = grep { ($b{$_} || 0) != $a{$_} } keys %a;\nmy ($y) = grep { ($c{$_} || 0) != $b{$_} } keys %b;\n\n$\\ = \"\\n\";\nprint $x;\nprint $y;\n"}, {"source_code": "$n = <>;\n@ar = sort {$a <=> $b} split /\\s+/, <>;\n@br = sort {$a <=> $b} split /\\s+/, <>; push(@br, 2**30);\nfor ($i = 0; $i < $n; ++$i) {\n\tif ($ar[$i] != $br[$i]) {\n\t\tprint $ar[$i], \"\\n\";\n\t\tlast;\n\t}\n}\n@cr = sort {$a <=> $b} split /\\s+/, <>; push(@cr, 2**30);\nfor ($i = 0; $i < $n - 1; ++$i) {\n\tif ($br[$i] != $cr[$i]) {\n\t\tprint $br[$i], \"\\n\";\n\t\tlast;\n\t}\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nsub get_missing{\n    my ($total, $cur) = ($_[0], $_[1]);\n    my %hash1; my %hash2;\n    foreach(@{$total}){\n        $hash1{$_} = 0 unless exists $hash1{$_};\n        $hash2{$_} = 0 unless exists $hash2{$_};\n        $hash1{$_}++;\n    }\n    foreach(@{$cur}){\n        $hash2{$_}++;\n    }\n    foreach(keys %hash1){\n        return $_ if $hash2{$_} < $hash1{$_};\n    }\n    return -1;\n}\n###############################\n\nmy $n = <>;\nmy @total = split ' ',<>;\nmy @cur = split ' ' , <>;\nmy $res1 = get_missing(\\@total,\\@cur);\n\n@total = @cur;\n@cur = split ' ' , <>;\nmy $res2 = get_missing(\\@total,\\@cur);\n\nprint \"$res1\\n$res2\";\n"}, {"source_code": "<>;\n$sum1 += $_ for split(/ /, <>);\n$sum2 += $_ for split(/ /, <>);\n$sum3 += $_ for split(/ /, <>);\nprint(($sum1-$sum2).\"\\n\".($sum2-$sum3).\"\\n\");"}, {"source_code": "<>;\nprint join $/, map eval, (join '-', map {eval join '+', split} <>) =~ /(?=(\\d+-\\d+))/g"}], "negative_code": [{"source_code": "<>;\nmy %hash;\n$hash{int$_}++ for(split / /, <>);\n$hash{int$_}++ for(split / /, <>);\n$hash{int$_}++ for(split / /, <>);\nprint grep{$hash{$_} == 1} keys %hash;\nprint \"\\n\";\nprint grep{$hash{$_} == 2} keys %hash;\n"}, {"source_code": "<>;\nmy $n = <>;\nmy %hash;\n$hash{int$_}++ for(split / /, <>);\n$hash{int$_}++ for(split / /, <>);\n$hash{int$_}++ for(split / /, <>);\nprint grep{$hash{$_} == 1} keys %hash;\nprint \"\\n\";\nprint grep{$hash{$_} == 2} keys %hash;\n"}, {"source_code": "<>;\n@a = sort {$a <=> $b} split \" \", <>;\n@b = split \" \", <>;\n@c = sort {$a <=> $b} split \" \", <>;\n$i = 0;\nfor (@a){\n$_ == $c[$i] ? ($i++) : (push @ans, $_)\n}\n$f = 0;\n$ans[0] == $_ and $f++ for @b;\n$, = $/;\nprint $f ? (reverse @ans): @ans"}], "src_uid": "1985566215ea5a7f22ef729bac7205ed"}
{"source_code": "$\\ = $/;\n$n = <>;\n\nfor (<>){\n\t($x, $y) = split;\n\t$X{$x} ++;\n\t$Y{$y} ++;\n\tprint eval join '*', map {$n - keys %$_} \\%X, \\%Y;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse strict;\n\nmy ($n, $m) = split (\" \",<STDIN>);\nmy (%rows,%cols,@result);\nfor (my $i=0;$i<$m;$i++){\n    my ($row, $col) = split(\" \",<STDIN>);\n    $rows{$row} = 1;\n    $cols{$col} = 1;\n    push @result,(($n - keys(%rows))*($n - keys(%cols)));\n}\nprint join \" \", @result;\n\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\tfor $i (1 .. $m){\n\t\t($x, $y) = split ' ', <>;\n\t\t$X{$x} ++;\n\t\t$Y{$y} ++;\n\t\tprint +($n - keys %X) * ($n - keys %Y);\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "faf1abdeb6f0cf34972d5cb981116186"}
{"source_code": "<>;print\" \",$_+2*(-1&$_/2+(-1&$_/3))for(<>)", "positive_code": [{"source_code": "<>;print\" \",$_+2*(-1&$_/2+(-1&$_/3))for(<>)\r\n"}, {"source_code": "<>;print\" \",$_+2*(-1&$_/2+(-1&$_/3))for(<>)"}], "negative_code": [], "src_uid": "a6b6d9ff2ac5c367c00a64a387cc9e36"}
{"source_code": "<>; print 0 + ( () = s/^0+|0+$//gr =~ /0/g ), $/ for <>", "positive_code": [{"source_code": "#!/bin/perl\n\nuse strict;\n\nmy $cases = +<>;\n\nwhile ($cases--) {\n  my $line = <>;\n\n  my ($a, $b, $found1) = (0, 0, 0);\n  for (my $i = 0; $i < length($line) - 1; $i++) {\n    if (substr($line, $i, 1) eq '1') {\n      $found1 = 1;\n      $b = $a;\n    } elsif ($found1) {\n      $a++;\n    }\n  }\n  print \"$b\\n\";\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n\nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n\nsub sum_of_digits {\n    my $n = shift;\n    my @numbers = split q{}, $n;\n\n    my $sum = 0;\n\n    for (@numbers) {\n        $sum += $_;\n    }\n\n    return $sum;\n}\n\n# solution\n\nsub count_zero {\n    my $str = shift;\n    my @chars = split q{}, $str;\n    my $count = 0;\n    for (@chars) {\n        $count++ if $_ eq '0';\n    }\n    return $count;\n}\n\nmy $n = read_token;\n\nfor (1..$n) {\n    my $s = read_line;\n    while ($s and substr($s, 0, 1) eq '0') {\n        $s = substr($s, 1);\n    }\n    if (!$s) {\n        say 0;\n        next;\n    }\n\n    while ($s and substr($s, length($s)-1, 1) eq '0') {\n        $s = substr($s, 0, length($s)-1);\n    }\n\n    say count_zero($s);\n}\n"}, {"source_code": "<>;print 0 + ( () = s/^0+|0+$//gr =~ /0/g ),$/ for <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\ts/^0+//;\n\ts/0+$//;\n\t\n\tprint length y/1//dr;\n\t}"}], "negative_code": [], "src_uid": "5de66fbb594bb317654366fd2290c4d3"}
{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nchomp (my $line = <STDIN>);\nmy $t = $line;\n\nfor ( 1..$t ) {\n    chomp ($line = <STDIN>);\n    my ($a, $b, $n) = split q{ }, $line;\n    my $c = int($a) ^ int($b);\n    my $mod = $n % 3;\n    if ( $mod == 0 ) {\n        say $a;\n    }\n    elsif ( $mod == 1 ) {\n        say $b;\n    }\n    else {\n        say $c;\n    }\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $A, $B, $n ) = split;\n\t\n\t@_ = ( $A, $B );\n\t\n\tfor my $i ( 2 .. 2 ){\n\t\tpush @_, ( 0 + $_[ $i - 2 ] ) ^ ( 0 + $_[ $i - 1 ] );\n\t\t}\n\t\n\t$debug and print \"[@_]\";\n\t\n\tprint $_[ $n % 3 ];\n\t}"}], "negative_code": [], "src_uid": "64a375c7c49591c676dbdb039c93d218"}
{"source_code": "( $u, $v ) = ( split ' ', <> ),\n\t$h{ $u }{ $v } = $h{ $v }{ $u } = 1 for 2 .. ( $_ = <> );\n\t\n@K = ( ( keys %h )[ 0 ], 0 );\n\nwhile( @K ){\n\tif( $k = shift @K ){\n\t\t$C[ $i % 2 ] ++;\n\t\tdelete $h{ $_ }{ $k } for @nk = keys %{ $h{ $k } };\n\t\tpush @K, @nk;\n\t\t}\n\telse{\n\t\tpush @K, 0 if @K * $K[ -1 ];\n\t\t$i ++;\n\t\t}\n\t}\n\t\nprint 1 - $_ + $C[ 0 ] * $C[ 1 ]", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t\n\tmy %h;\n\t\n\tmap {\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t$h{ $u }{ $v } = 1;\n\t\t$h{ $v }{ $u } = 1;\n\t\t} 1 .. $_ - 1;\n\t\n\tmy $color = 'C';\n\tmy @keys;\n\t( $keys[ 0 ] ) = sort keys %h;\n\tpush @keys, $color;\n\t\n\tmy @color;\n\tmy $i = 0;\n\twhile( @keys ){\n\t\t$debug and print \"keys:[@keys]\";\n\t\tmy $key = shift @keys;\n\t\t$key eq $color and do {\n\t\t\tpush @keys, $color if @keys and $keys[ -1 ] ne $color;\n\t\t\t$i ++;\n\t\t\tnext;\n\t\t\t};\n\t\t$color[ $i % 2 ] ++;\n\t\tmy @new_keys = keys %{ $h{ $key } };\n\t\tdelete $h{ $_ }{ $key } for @new_keys;\n\t\tpush @keys, @new_keys;\n\t\t}\n\t\t\n\t$debug and print \"color:[@color]\";\n\tprint 1 - $_ + eval join ' * ', @color;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_ - 1;\n\t\n\tprint 1 - $_ + ( $_ % 2 == 0 ? ( $_ / 2 ) ** 2 : ( int $_ / 2 ) * ( 1 + int $_ / 2 ) );\n\t}"}], "src_uid": "44b9adcc9d672221bda3a1cada81b3d0"}
{"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n", "positive_code": [{"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}, {"source_code": "use v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\n$ans = '';\nforeach (0 .. $n-2) {\n\t$c = $a[$_];\n\t$ans .= 'PRL' while ($c-- > 0);\n\t$ans .= 'R';\n}\n$c = $a[$#a];\n$ans .= 'PLR' while ($c-- > 0);\nsay $ans;"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}, {"source_code": "\n$n = <>;\n$line = <>;\n@list = split(/\\s/, $line);\n$total = 0;\nforeach $x (@list) {\n    $total += $x;   \n}\n$i = 0;\n$len = $n - 1;\n$dir = 1;\nwhile ($total) {\n    if ($list[$i]) {\n        $list[$i] -= 1;\n        $total -= 1;\n        print 'P';\n    }\n    if ($i == 0) {\n        $dir = 1;\n    }\n    elsif ($i == $len) {\n        $dir = -1;\n    }\n    $i += $dir;\n    if ($dir > 0) {print 'R';}\n    else {print 'L';}\n}"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint"}, {"source_code": "<>;\n$_=<>;\ns/(\\d+) /(\"RLP\"x$1).\"R\"/eg;\ns/\\d+$/\"LRP\"x$&/e;\nprint\n"}], "negative_code": [], "src_uid": "50e88225d8b081d63eebe446f48057f4"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n$maxn = 10 ** 6 + 5;\n@visit = (0) x $maxn;\nfor ($i=2; $i<$maxn; ++$i) {\n\tif ($visit[$i] == 0) {\n\t\t$tb{$i*$i} = 1;\n\t\tfor ($j=$i*$i; $j<$maxn; $j+=$i) {\n\t\t\t$visit[$j] = 1;\n\t\t}\n\t}\n}\nchomp($n = <>);\n$tb{int($_)} and say \"YES\" or say \"NO\" foreach (split / /, <>);", "positive_code": [{"source_code": "for(2..1000000)\n{\n\tnext if $pr[$_];\n\tfor($i = 2 * $_ ; $i <= 1000000 ; $i += $_)\n\t{\n\t\t$pr[$i] = 1;\n\t}\n}\n$pr[1] = 1;\n<>;\nforeach(split(' ', <>))\n{\n\t$r = int(sqrt($_));\n\tprint \"NO\\n\" and next if($r * $r != $_ or $pr[$r]);\n\tprint \"YES\\n\";\n}"}, {"source_code": "#!/usr/bin/perl -w\n\n$n=<STDIN>; chomp $n;\n$a=<STDIN>; chomp $a;\n@a=split(' ',$a);\n\n@p=(0..1000000);\n$p[1]=0;\nfor (2..1000000){\n  if($p[$_]){\n    $i=$_*2;\n    while($i<=1000000){\n      $p[$i]=0;\n      $i+=$_;\n    }\n  }\n}\nforeach (@a){\n  $x=int(sqrt($_));\n  if($x*$x==$_ && $p[$x]){print \"YES\\n\";}\n  else{print \"NO\\n\";}\n}\n"}, {"source_code": "for(2..1000000){\n\tnext if $pr[$_];\n\tfor($i = 2 * $_ ; $i <= 1000000 ; $i += $_){\n\t\t$pr[$i] = 1;}\n}\n$pr[1] = 1;\n<>;\nforeach(split(' ', <>)){\n\t$r = int(sqrt($_));\n\tprint \"NO\\n\" and next if($r * $r != $_ or $pr[$r]);\n\tprint \"YES\\n\";\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n$maxn = 10 ** 5 + 5;\n@visit = (0) x $maxn;\nfor ($i=2; $i<$maxn; ++$i) {\n\tif ($visit[$i] == 0) {\n\t\t$tb{$i*$i} = 1;\n\t\tfor ($j=$i*$i; $j<$maxn; $j+=$i) {\n\t\t\t$visit[$j] = 1;\n\t\t}\n\t}\n}\nchomp($n = <>);\n$tb{int($_)} and say \"YES\" or say \"NO\" foreach (split / /, <>);"}, {"source_code": "for(2..1000000){\n\tnext if $pr[$_];\n\tfor($i = 2 * $_ ; $i <= 1000000 ; $i += $_){\n\t\t$pr[$i] = 1;}\n}\n$pr[1] = 1;\n<>;\nforeach(split(' ', <>)){\n\t$r = sqrt($_);\n\tprint \"NO\\n\" and next if($r * $r != $_ or $pr[$r]);\n\tprint \"YES\\n\";\n}"}, {"source_code": "for(2..1000000){\n\tnext if $pr[i];\n\tfor($i = 2 * $_ ; $i <= 1000000 ; $i += $_){\n\t\t$pr[i] = 1;}\n}\n$pr[1] = 1;\n<>;\nforeach(split(' ', <>)){\n\t$r = sqrt($_);\n\tprint \"NO\\n\" and next if($r * $r != $_ or $pr[$r]);\n\tprint \"YES\\n\";\n}"}, {"source_code": "for(1..1000000){\n\tnext if $pr[i];\n\tfor($i = 2 * $_ ; $i <= 1000000 ; $i += $_){\n\t\t$pr[i] = 1;}\n}\n<>;\nforeach(split(' ', <>)){\n\t$r = sqrt($_);\n\tprint \"NO\\n\" and next if($r * $r != $_ or $pr[$r]);\n\tprint \"YES\\n\";\n}"}, {"source_code": "#!/usr/bin/perl -w\n\n$n=<STDIN>; chomp $n;\n$a=<STDIN>; chomp $a;\n@a=split(' ',$a);\n\n@p=(0..1000000);\n$p[1]=0;\nfor (2..1000000){\n  if($p[$_]){\n    $i=$_*2;\n    while($i<1000000){\n      $p[$i]=0;\n      $i+=$_;\n    }\n  }\n}\nforeach (@a){\n  $x=int(sqrt($_));\n  if($x*$x==$_ && $p[$x]){print \"YES\\n\";}\n  else{print \"NO\\n\";}\n}\n"}], "src_uid": "6cebf9af5cfbb949f22e8b336bf07044"}
{"source_code": "use warnings;\nuse strict;\n\nmy $n = <>;\nprint join \" \", $n..$n*2-1;\n", "positive_code": [{"source_code": "my $n = <>;\n\nwhile ($n--)\n{\n\tprint 10000000 - $n . \" \";\n}"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "print$_+1e5,\" \"for 1..<>"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "print$_+1e5,\" \"for 1..<>"}, {"source_code": "print$_+99999,\" \"for 1..<>"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "#!/usr/bin/perl\nopen I, \"<input.txt\";\n#open O, \">output.txt\";\n#$\\ = \"\\n\";\n$n = <>;\nfor(0..$n-1){\n\tprint 10**6 +$_,\" \";\n}"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "use warnings;\n\nmy $n = <STDIN>;\n\nfor (my $i = 1e+6; $i < 1e+6 + $n; $i++) {\n    print $i . \" \";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\n\nmy $n = <>;\n\nprint join \" \", $n .. $n * 2 - 1;\n"}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}, {"source_code": "@_=1..<>;\nfor(@_){$_+=@_}\nprint\"@_\""}, {"source_code": "print$_+1e5,\" \"for 1..<>\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nopen I, \"<input.txt\";\n#open O, \">output.txt\";\n#$\\ = \"\\n\";\n$n = <I>;\nfor(0..$n-1){\n\tprint 10**6 +$_,\" \";\n}"}, {"source_code": "use warnings;\n\nmy $n = <STDIN>;\n\nmy @b = ('1') x 5e+5;\n\n$b[0] = $b[1] = '';\n\nfor (my $i = 2; $i * $i < @b; $i++) {\n    if ($b[$i]) {\n        for (my $j = $i * $i; $j < @b; $j += $i) {\n            $b[$j] = '';\n        }\n    }\n}\n\nmy @ans = ();\n\nfor (my $i = 0; $i < @b && $n > 0; $i++) {\n    if ($b[$i]) {\n        push @ans, $i;\n        $n--;\n    }\n}\n\nprint join \" \", @ans;\n"}, {"source_code": "use warnings;\n\nmy $n = <STDIN>;\n\nfor (my $i = 1e+7; $i < 1e+7 + $n; $i++) {\n    print $i . \" \";\n}\n"}], "src_uid": "c047040426e736e9085395ed9666135f"}
{"source_code": "#!usr/bin/perl\n\nuse strict;\nuse warnings;\n\n<> =~ m/(d+)/;\nmy $n = $1;\n\nmy @inputlog = ();\nmy @flaglog = ();\nmy @log = ();\n\n\nmy @pairrefs = ([\"\", \"\"]);\nwhile (<>) {\n\tchomp;\n\tpush @inputlog, $_;\n\tunless (defined $pairrefs[length]) {\n\t\t$pairrefs[length] = [$_];\n\t\tpush @flaglog, \"first-in-its-length\";\n\t} else {\n\t\tpush @{$pairrefs[length]}, $_;\n\t\tpush @flaglog, \"second-in-its-length\";\n\t}\n}\n\n#print \"- @{$pairrefs[0]}\\n\";\n#print \"- @{$pairrefs[1]}\\n\";\n#print \"- @{$pairrefs[2]}\\n\";\n#print \"- @{$pairrefs[3]}\\n\";\n\n#my @pairrefs2 = ([\"e\", \"k\"], [\"te\", \"ko\"], [\"kor\", \"rte\"], [\"orte\", \"kort\"]);\n\nmy @prefs = (\"\");\nmy @suffs = (\"\");\n\n\nmy $flag = \"prefix-suffox-order\";\n \nif ($flag eq \"prefix-suffox-order\") {\n\tmy $length = 0;\n\t@log = (\"-\");\n\tforeach my $pairref (@pairrefs) {\n\t\tmy ($string1, $string2) = @$pairref; #print \"$string1 | $string2\\n\";\n\n\t\tif ($length > 0) {\n\t\t\tmy $previously = $length - 1;\n\t\t\tif (is_prefix_of($prefs[$previously], $string1) && is_suffix_of($suffs[$previously], $string2)) {\n\t\t\t\t$prefs[$length] = $string1;\n\t\t\t\t$suffs[$length] = $string2;\n\t\t\t\t$log[$length] = \"PS\";\n\t\t\t} elsif (is_prefix_of($prefs[$previously], $string2) && is_suffix_of($suffs[$previously], $string1)) {\n\t\t\t\t$prefs[$length] = $string2;\n\t\t\t\t$suffs[$length] = $string1;\n\t\t\t\t$log[$length] = \"SP\";\n\t\t\t} else {\n\t\t\t\t$flag = \"suffix-prefix-order\";\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t$length++;\n\t}\n}\n\nif ($flag eq \"suffix-prefix-order\") {\n\tmy $length = 0;\n\t@log = (\"-\");\n\tforeach my $pairref (@pairrefs) {\n\t\tmy ($string1, $string2) = @$pairref; #print \"$string1 | $string2\\n\";\n\n\t\tif ($length > 0) {\n\t\t\tmy $previously = $length - 1;\n\t\t\tif (is_prefix_of($prefs[$previously], $string2) && is_suffix_of($suffs[$previously], $string1)) {\n\t\t\t\t$prefs[$length] = $string2;\n\t\t\t\t$suffs[$length] = $string1;\n\t\t\t\tpush @log, \"SP\";\n\t\t\t} elsif (is_prefix_of($prefs[$previously], $string1) && is_suffix_of($suffs[$previously], $string2)) {\n\t\t\t\t$prefs[$length] = $string1;\n\t\t\t\t$suffs[$length] = $string2;\n\t\t\t\tpush @log, \"PS\";\n\t\t\t} else {\n\t\t\t\t$flag = \"prefix-suffix-order\";\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t$length++;\n\t}\n}\n\n\n#print \"Prefs: \"; print join \", \", @prefs; print \"\\n\";\n#print \"Suffs: \"; print join \", \", @suffs; print \"\\n\";\n#print \"Order: $flag\\n\";\n#print \"Log: @log\\n\";\n\n#print \"Result: \";\nforeach my $i (keys @inputlog) {\n\tmy $length = length $inputlog[$i];\n\tif ($flaglog[$i] eq 'first-in-its-length') {\n\t\tprint substr($log[$length], 0, 1);\n\t} else {\n\t\tprint substr($log[$length], 1, 1);\n\t}\n}\nprint \"\\n\";\n\nsub is_prefix_of {\n\tmy ($part, $whole) = @_;\n\treturn (substr $whole, 0, length $part) eq $part; \n}\n\n\nsub is_suffix_of {\n\tmy ($part, $whole) = @_;\n\treturn 1 if $part eq \"\";\n\treturn (substr $whole, -length $part) eq $part; \n}", "positive_code": [{"source_code": "#!usr/bin/perl\n\nuse strict;\nuse warnings;\n\n<> =~ m/(d+)/;\nmy $n = $1;\n\nmy @inputlog = ();\nmy @flaglog = ();\nmy @log = ();\n\n\nmy @pairrefs = ([\"\", \"\"]);\nwhile (<>) {\n\tchomp;\n\tpush @inputlog, $_;\n\tunless (defined $pairrefs[length]) {\n\t\t$pairrefs[length] = [$_];\n\t\tpush @flaglog, \"first-in-its-length\";\n\t} else {\n\t\tpush @{$pairrefs[length]}, $_;\n\t\tpush @flaglog, \"second-in-its-length\";\n\t}\n}\n\n#print \"- @{$pairrefs[0]}\\n\";\n#print \"- @{$pairrefs[1]}\\n\";\n#print \"- @{$pairrefs[2]}\\n\";\n#print \"- @{$pairrefs[3]}\\n\";\n\n#my @pairrefs2 = ([\"e\", \"k\"], [\"te\", \"ko\"], [\"kor\", \"rte\"], [\"orte\", \"kort\"]);\n\nmy @prefs = (\"\");\nmy @suffs = (\"\");\n\n\nmy $flag = \"prefix-suffox-order\";\n \nif ($flag eq \"prefix-suffox-order\") {\n\tmy $length = 0;\n\t@log = (\"-\");\n\tforeach my $pairref (@pairrefs) {\n\t\tmy ($string1, $string2) = @$pairref; #print \"$string1 | $string2\\n\";\n\n\t\tif ($length > 0) {\n\t\t\tmy $previously = $length - 1;\n\t\t\tif (is_prefix_of($prefs[$previously], $string1) && is_suffix_of($suffs[$previously], $string2)) {\n\t\t\t\t$prefs[$length] = $string1;\n\t\t\t\t$suffs[$length] = $string2;\n\t\t\t\t$log[$length] = \"PS\";\n\t\t\t} elsif (is_prefix_of($prefs[$previously], $string2) && is_suffix_of($suffs[$previously], $string1)) {\n\t\t\t\t$prefs[$length] = $string2;\n\t\t\t\t$suffs[$length] = $string1;\n\t\t\t\t$log[$length] = \"SP\";\n\t\t\t} else {\n\t\t\t\t$flag = \"suffix-prefix-order\";\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t$length++;\n\t}\n}\n\nif ($flag eq \"suffix-prefix-order\") {\n\tmy $length = 0;\n\t@log = (\"-\");\n\tforeach my $pairref (@pairrefs) {\n\t\tmy ($string1, $string2) = @$pairref; #print \"$string1 | $string2\\n\";\n\n\t\tif ($length > 0) {\n\t\t\tmy $previously = $length - 1;\n\t\t\tif (is_prefix_of($prefs[$previously], $string2) && is_suffix_of($suffs[$previously], $string1)) {\n\t\t\t\t$prefs[$length] = $string2;\n\t\t\t\t$suffs[$length] = $string1;\n\t\t\t\tpush @log, \"SP\";\n\t\t\t} elsif (is_prefix_of($prefs[$previously], $string1) && is_suffix_of($suffs[$previously], $string2)) {\n\t\t\t\t$prefs[$length] = $string1;\n\t\t\t\t$suffs[$length] = $string2;\n\t\t\t\tpush @log, \"PS\";\n\t\t\t} else {\n\t\t\t\t$flag = \"prefix-suffix-order\";\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t$length++;\n\t}\n}\n\n\n#print \"Prefs: \"; print join \", \", @prefs; print \"\\n\";\n#print \"Suffs: \"; print join \", \", @suffs; print \"\\n\";\n#print \"Order: $flag\\n\";\n#print \"Log: @log\\n\";\n\n#print \"Result: \";\nforeach my $i (keys @inputlog) {\n\tmy $length = length $inputlog[$i];\n\tif ($flaglog[$i] eq 'first-in-its-length') {\n\t\tprint substr($log[$length], 0, 1);\n\t} else {\n\t\tprint substr($log[$length], 1, 1);\n\t}\n}\nprint \"\\n\";\n\nsub is_prefix_of {\n\tmy ($part, $whole) = @_;\n\treturn (substr $whole, 0, length $part) eq $part; \n}\n\n\nsub is_suffix_of {\n\tmy ($part, $whole) = @_;\n\treturn 1 if $part eq \"\";\n\treturn (substr $whole, -length $part) eq $part; \n}\n"}], "negative_code": [{"source_code": "#!usr/bin/perl\n\nuse strict;\nuse warnings;\n\n<> =~ m/(d+)/;\nmy $n = $1;\n\nmy @inputlog = ();\nmy @flaglog = ();\nmy @log = ();\n\n\nmy @pairrefs = ([\"\", \"\"]);\nwhile (<>) {\n\tchomp;\n\tpush @inputlog, $_;\n\tunless (defined $pairrefs[length]) {\n\t\t$pairrefs[length] = [$_];\n\t\tpush @flaglog, \"first-in-its-length\";\n\t} else {\n\t\tpush @{$pairrefs[length]}, $_;\n\t\tpush @flaglog, \"second-in-its-length\";\n\t}\n}\n\n#print \"- @{$pairrefs[0]}\\n\";\n#print \"- @{$pairrefs[1]}\\n\";\n#print \"- @{$pairrefs[2]}\\n\";\n#print \"- @{$pairrefs[3]}\\n\";\n\n#my @pairrefs2 = ([\"e\", \"k\"], [\"te\", \"ko\"], [\"kor\", \"rte\"], [\"orte\", \"kort\"]);\n\nmy @prefs = (\"\");\nmy @suffs = (\"\");\n\n\nmy $flag = \"prefix-suffox-order\";\n \nif ($flag eq \"prefix-suffox-order\") {\n\tmy $length = 0;\n\t@log = (\"-\");\n\tforeach my $pairref (@pairrefs) {\n\t\tmy ($string1, $string2) = @$pairref; #print \"$string1 | $string2\\n\";\n\n\t\tif ($length > 0) {\n\t\t\tmy $previously = $length - 1;\n\t\t\tif (is_prefix_of($prefs[$previously], $string1) && is_suffix_of($suffs[$previously], $string2)) {\n\t\t\t\t$prefs[$length] = $string1;\n\t\t\t\t$suffs[$length] = $string2;\n\t\t\t\t$log[$length] = \"PS\";\n\t\t\t} elsif (is_prefix_of($prefs[$previously], $string2) && is_suffix_of($suffs[$previously], $string1)) {\n\t\t\t\t$prefs[$length] = $string2;\n\t\t\t\t$suffs[$length] = $string1;\n\t\t\t\t$log[$length] = \"SP\";\n\t\t\t} else {\n\t\t\t\t$flag = \"suffix-prefix-order\";\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t$length++;\n\t}\n}\n\nif ($flag eq \"suffix-prefix-order\") {\n\tmy $length = 0;\n\t@log = (\"-\");\n\tforeach my $pairref (@pairrefs) {\n\t\tmy ($string1, $string2) = @$pairref; print \"$string1 | $string2\\n\";\n\n\t\tif ($length > 0) {\n\t\t\tmy $previously = $length - 1;\n\t\t\tif (is_prefix_of($prefs[$previously], $string2) && is_suffix_of($suffs[$previously], $string1)) {\n\t\t\t\t$prefs[$length] = $string2;\n\t\t\t\t$suffs[$length] = $string1;\n\t\t\t\tpush @log, \"SP\";\n\t\t\t} elsif (is_prefix_of($prefs[$previously], $string1) && is_suffix_of($suffs[$previously], $string2)) {\n\t\t\t\t$prefs[$length] = $string1;\n\t\t\t\t$suffs[$length] = $string2;\n\t\t\t\tpush @log, \"PS\";\n\t\t\t} else {\n\t\t\t\t$flag = \"prefix-suffix-order\";\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\t$length++;\n\t}\n}\n\n\n#print \"Prefs: \"; print join \", \", @prefs; print \"\\n\";\n#print \"Suffs: \"; print join \", \", @suffs; print \"\\n\";\n#print \"Order: $flag\\n\";\n#print \"Log: @log\\n\";\n\n#print \"Result: \";\nforeach my $i (keys @inputlog) {\n\tmy $length = length $inputlog[$i];\n\tif ($flaglog[$i] eq 'first-in-its-length') {\n\t\tprint substr($log[$length], 0, 1);\n\t} else {\n\t\tprint substr($log[$length], 1, 1);\n\t}\n}\nprint \"\\n\";\n\nsub is_prefix_of {\n\tmy ($part, $whole) = @_;\n\treturn (substr $whole, 0, length $part) eq $part; \n}\n\n\nsub is_suffix_of {\n\tmy ($part, $whole) = @_;\n\treturn 1 if $part eq \"\";\n\treturn (substr $whole, -length $part) eq $part; \n}\n"}], "src_uid": "ddbde202d00b928a858e9f4ff461e88c"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B, $k ) = split;\n\t\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy %h;\n\tmy %g;\n\t\n\twhile( @A ){\n\t\tmy $A = shift @A;\n\t\tmy $B = shift @B;\n\t\t\n\t\t$h{ $A }{ $B } ++;\n\t\t$g{ $B }{ $A } ++;\n\t\t}\n\t\n\tmy $cnt = 0;\n\t\n\tfor my $key ( sort { $a <=> $b } keys %h ){\n\t\tmy $k1 = $k - keys %{ $h{ $key } };\n\t\t\n\t\tfor my $key_back ( sort { $a <=> $b } keys %{ $h{ $key } } ){\n\t\t\t$cnt += $k1 - ( keys %{ $g{ $key_back } } ) + 1;\n\t\t\t}\n\t\t}\n\t\n\tprint $cnt / 2;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $k, %h, %g, $c ) = ( split )[ 2 ];\r\n\t\r\n\t$_ = <>;\r\n\t@B = split ' ', <>;\r\n\t\r\n\twhile( /\\d+/g ){\r\n\t\t$B = shift @B;\r\n\t\t\r\n\t\t$h{ $B }{ $& } =\r\n\t\t$g{ $& }{ $B } ++;\r\n\t\t}\r\n\t\r\n\tfor( sort keys %h ){\r\n\t\t$q = $k - ( @j = sort keys %{ $h{ $_ } } );\r\n\t\t\r\n\t\tfor $j ( @j ){\r\n\t\t\t$c += 1 + $q - keys %{ $g{ $j } };\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tprint $c / 2\r\n\t}"}], "negative_code": [], "src_uid": "14ce451a31c0dbc2b2f4e04a939b199d"}
{"source_code": "chomp($_=<>);\n@_=split//;\n$max=0;\nfor $j('-','+'){\n$m=0;\nfor $i(0..@_-1){\n\tif ($_[$i] eq $j){$m++; $m>$max and $max=$m}\n\telse {$m--; $m<0 and $m=0}\n\t}\n}\nprint $max", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\nuse List::Util qw(max min);\n\nchomp($_ = <>);\nmy ($max, $min, $count) = (0, 0, 0);\nfor my $i (split //) {\n    if ($i eq '+') {\n        ++$count;\n    } else {\n        --$count;\n    }\n    $max = max($max, $count);\n    $min = min($min, $count);\n}\nprint $max - $min, \"\\n\";\n"}], "negative_code": [], "src_uid": "a9cd99d74418b5f227b358a910496b02"}
{"source_code": "\tuse integer;\n\t\n\twhile(<>){\n\t\tchomp;\n\t#\t($n,$m)=split/ /,$_;\n\t#\tchomp ($n = <>);\n\t\tchomp ($a = <>);\n\t\tchomp ($m = <>);\n\t\tchomp ($b = <>);\n\t\t@a = sort {$a <=> $b} split/ /,$a;\n\t\t@b = sort {$a <=> $b} split/ /,$b;\n\t\t\n\t\t$c=0;\n\t\t$i=$j=0;\n\t\twhile ($i < @a and $j < @b){\n\t\t\t$dir = $a[$i] <=> $b[$j];\n\t\t\tif (abs($a[$i] - $b[$j]) < 2){\n\t\t\t\t$c++;\n\t\t\t\t$i++;\n\t\t\t\t$j++;\n\t\t\t\t}\n\t\t\telsif ($dir == -1){\n\t\t\t\t$i++;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\t$j++;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\n\t\t\n\t\tprint $c,$/\n\t\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = sort {$a <=> $b} split / /, <>;\nchomp($m = <>);\n@b = sort {$a <=> $b} split / /, <>;\n($ans, $i, $j) = (0) x 3;\nwhile ($i < $n && $j < $m) {\n\tif (abs($a[$i]-$b[$j]) <= 1) {\n\t\t++$i;\n\t\t++$j;\n\t\t++$ans;\n\t} elsif ($a[$i] > $b[$j]) {\n\t\t++$j;\n\t} else {\n\t\t++$i;\n\t}\n}\nsay $ans;"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\n<>;\nmy @boys = sort { $a <=> $b } split ' ', <>;\n<>;\nmy @girls = sort { $a <=> $b } split ' ', <>;\n\nmy $c = 0;\n\nwhile (@boys && @girls) {\n  if (abs($boys[0] - $girls[0]) <= 1) {\n    shift @boys;\n    shift @girls;\n    $c++;\n  } elsif ($boys[0] < $girls[0]) {\n    shift @boys;\n  } else {\n    shift @girls;\n  }\n}\n\nsay $c;\n"}], "negative_code": [], "src_uid": "62766ef9a0751cbe7987020144de7512"}
{"source_code": "# Find out how many Bulbasaurs we can catch\n# Solution: \nuse strict;\nuse warnings;\nmy $newspaper = <>;\nmy %letter;\nmy $bulbies = 0;\nforeach(split//,$newspaper)\n{\n\tif(exists($letter{$_}))\n\t{\n\t\t$letter{$_} += 1;\n\t\tif($bulbies < $letter{$_})\n\t\t{\n\t\t\t$bulbies = $letter{$_};\n\t\t}\n\t}\n\telse\n\t{\n\t\t$letter{$_} = 1;\n\t\tif($bulbies == 0)\n\t\t{\n\t\t\t$bulbies = 1;\n\t\t}\n\t}\n}\nif(exists($letter{\"a\"}))\n{\n\t$letter{\"a\"} = int($letter{\"a\"}/2);\n}\nif(exists($letter{\"u\"}))\n{\n\t$letter{\"u\"} = int($letter{\"u\"}/2);\n}\nforeach(split//,\"Bulbasr\")\n{\n\tif(exists($letter{$_}))\n\t{\n\t\tif($bulbies > $letter{$_})\n\t\t{\n\t\t\t$bulbies = $letter{$_}\n\t\t}\n\t}\n\telse\n\t{\n\t\t$bulbies = 0;\n\t}\n}\nprint int($bulbies);\n", "positive_code": [{"source_code": "use v5.20;\nuse warnings;\n\nsub min {\n\tmy $ret = $_[0];\n\tforeach my $it (@_) {\n\t\tif ($ret > $it) { \n\t\t\t$ret = $it;\n\t\t}\n\t}\n\treturn $ret;\n}\n\nmy @fr = (0) x 300;\n\n$_ = <>;\n\nforeach my $it (split '') {\n\t$fr[ord $it] += 1;\n}\n\nsay min($fr[ord 'B'],int ($fr[ord 'a']/2),$fr[ord 'b'],$fr[ord 's'],$fr[ord 'l'],$fr[ord 'r'],int ($fr[ord 'u']/2));\n\n"}, {"source_code": "use v5.20;\nmy $input = <>;\nchomp( $input );\nmy @s = split //, $input;\nmy $word = \"uaBlbsur\";\nmy @rez = split //, $word;\nmy $h = {};\nfor(my $j = 0; $j < length $word; $j++){\n\t$h->{ $rez[$j] } = 0;}\nmy $ans = 1000000000;\nfor(my $i = 0; $i < length $input; $i++){\n\t$h->{ $s[$i] }++;}\n$h->{ $rez[1] } /= 2;\n$h->{ $rez[0] } /= 2;\nfor(my $j = 0; $j < length $word; $j++){\n\tif($ans > $h->{ $rez[$j] }){\n\t\t$ans = $h->{ $rez[$j] };}}\nsay int($ans);"}, {"source_code": "use v5.20;\n\n\nsub minn {\n\tmy ($a, $b) = @_;\n\tif ($a < $b) {\n\t\treturn $a;\n\t}\n\treturn $b;\n}\n\nmy $target = \"uaBlbsr\";\nmy %ap = map { $_ => 0 } (0..length($target));\n\nmy $text = <>;\nfor (my $i = 0; $i < length $text; $i++) {\n\tmy $ind = index($target, substr($text, $i, 1));\n\tif ($ind != -1) {\n\t\t$ap{$ind}++;\n\t}\n}\n\nmy $mn = int(minn($ap{0} / 2, $ap{1} / 2));\nfor (my $i = 2; $i < length $target; $i++) {\n\t$mn = minn($mn, $ap{$i});\n}\n\nsay $mn;"}, {"source_code": "use warnings;\n\nsub min {\n\tmy $ans = $_[0];\n\t\n\tforeach my $i (@_) {\n\t\tif ($ans > $i) {\n\t\t\t$ans = $i;\n\t\t}\n\t}\n\t\n\treturn $ans;\n}\n\nmy @fr = (0) x 128;\n\n\nmy $text = <STDIN>;\nchomp($text);\n\nfor (my $i = 0; $i < length $text; ++$i) {\n\t++$fr[ord(substr($text, $i, 1))];\n#\tprint substr($text, $i, 1);\n}\n\nprintf(\"%d\", min($fr[ord('B')], $fr[ord 'a']/2, $fr[ord 'b'], $fr[ord 's'], $fr[ord 'l'], $fr[ord 'r'], $fr[ord 'u']/2));\n"}, {"source_code": "#use v5.24;\nuse warnings;\nmy %fr;\n\nmy $line=<stdin>;\nchomp($line);\nmy @word=split(//,$line);\nfor (my $i=ord(\"A\");$i<=ord(\"z\");$i++){\n\t$fr{chr($i)}=0;\n}\nforeach my $lit (@word){\n\t$fr{$lit}++;\n}\n$fr{\"u\"}=int $fr{\"u\"}/2;\n$fr{\"a\"}=int $fr{\"a\"}/2;\nmy @key=(\"B\",\"u\",\"l\",\"b\",\"a\",\"s\",\"a\",\"u\",\"r\");\nmy $min=100006;\nforeach my $lit (@key){\n\tif ($min>$fr{$lit}) {$min=$fr{$lit}};\n}\nprint $min;\n<stdin>;\nexit(0);\n\n#Bulbasaur"}, {"source_code": "$_ = <>;\nfor $c (qw(B u l b a s r)) {\n\t$h{$c} = () = /$c/g;\n}\n$h{u} /= 2;\n$h{a} /= 2;\n@ans = sort {$a <=> $b} values %h;\nprint int $ans[0] || 0;\n"}, {"source_code": "use v5.20.1;\nuse warnings;\n\n=pod\nmy $filename = \"date.in\";\nopen(my $fh, '<:encoding(UTF-8)', $filename)\n\tor die \"Could not open the file\";\n=cut\n\nmy $line = <STDIN>;\nchomp($line);\n\nmy @input = split('', $line);\n\nmy %letters = (\n\n\t'B' => 0,\n\t'u' => 0,\n\t'l' => 0,\n\t'b' => 0,\n\t'a' => 0,\n\t's' => 0,\n\t'r' => 0,\n\n);\n\nfor(my $i = 0; $i < @input; $i++){\n\n\tif( index(\"Bulbasr\", $input[$i]) != -1 ){\n\n\t\t$letters{$input[$i]}++;\n\n\t}\n\n}\n\nmy $mini = 100002;\n\nwhile(my ($key, $value) = each(%letters)){\n\n\n\tif( ($key eq 'a' || $key eq 'u') && int($value/2) < $mini ){\n\n\t\t$mini = int($value/2);\n\n\t}elsif($key ne 'a' && $key ne 'u' && $value < $mini){\n\n\t\t$mini = $value;\n\n\t}\n\n\n}\n\nsay $mini;\n"}, {"source_code": "use warnings;\n\nuse v5.20;\n\nmy @frecv;\nmy @word = ('B','u','l','b','a','s','a','u','r');\nmy $solution = 1000000;\n\nmy $input = <STDIN>;\nchomp $input;\nmy @chars = split(\"\", $input);\n\nfor(my $i = 0; $i < length $input; $i += 1){\n    my $c = ord($chars[$i]);\n    $frecv[$c]++;\n}\n\nfor(my $i = 0; $i < 9; $i += 1){\n    my $c = $word[$i];\n    my $poz = ord($word[$i]);\n    unless(defined $frecv[$poz]) {   \n        $solution = 0;\n        last;\n    }\n    if($c eq 'a' || $c eq 'u'){\n        if(int($frecv[$poz] / 2) < $solution){\n            $solution = int($frecv[$poz] / 2);\n        }\n    }\n    elsif($frecv[$poz] < $solution){\n        $solution = $frecv[$poz];\n    }\n    \n}\nprint(\"$solution\\n\");"}, {"source_code": "use feature \"say\";\n\n$text = <>;\n@matches;\n@target = ( \"B\", \"u\", \"l\", \"b\", \"a\", \"s\", \"r\" );\nfor ($i = 0; $i < scalar ( @target ); ++$i) {\n\t$matches[$i] = () = $text =~ /$target[$i]/g;\n}\n$matches[1] /= 2;\n$matches[4] /= 2;\n@matches = sort( { $a <=> $b } @matches );\nsay int $matches[0];\n"}, {"source_code": "use feature \"say\";\n\n$text = <>;\n@sir;\n\n$h{B} = () = $text =~ /B/g;\npush(@sir,$h{B});\n\n$h{u} = () =$text =~  /u/g;\npush(@sir,$h{u} / 2 );\n\n$h{l} = () =$text =~  /l/g;\npush(@sir,$h{l});\n\n$h{b} = () =$text =~  /b/g;\npush(@sir,$h{b});\n\n$h{a} = () =$text =~  /a/g;\npush(@sir,$h{a} / 2);\n\n$h{s} = () =$text =~  /s/g;\npush(@sir,$h{s});\n\n$h{r} = () =$text =~  /r/g;\npush(@sir,$h{r});\n\n@sir = sort ( {$a <=> $b} @sir );\n\nsay int $sir[0];"}, {"source_code": "$,=\" \";\n\nmy %c;\nmap {$c{$_}++ }split //, \"Bulbasaur\";\nmy %d;\n\nmy $w=<>;\nchomp($w);\nmap {$d{$_}++ if $c{$_}}split //, $w;\nfor my $t (keys %c)\n{\n$d{$t}=int($d{$t}/$c{$t});\n}\n\nprint min([values %d]) , \"\\n\";\n\nsub min_{\n\treturn $_[0] > $_[1] ? $_[1] : $_[0];\n}\n\nsub max_{\n\treturn $_[1] > $_[0] ? $_[1] : $_[0];\n}\n\nsub min{\n\tmy $a=shift;\n\tmy $mm=$a->[0];\n\tfor(my $i=1;$i<@{$a};$i++)\n\t{\n\t\t$mm=min_($mm,$a->[$i]);\n\t}\n\treturn $mm;\n}\n\nsub max{\n\tmy $a=shift;\n\tmy $mm=$a->[0];\n\tfor(my $i=1;$i<@{$a};$i++)\n\t{\n\t\t$mm=max_($mm,$a->[$i]);\n\t}\n\treturn $mm;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $string = <>;\nchomp($string);\n\nmy %validLetters = ('B' => 0, 'u' => 0, 'l' => 0, 'b' => 0, 'a' => 0, 's' => 0, 'r' => 0);\nfor (my $i = 0; $i < length($string); $i++) {\n  my $char = substr($string, $i, 1);\n  if (exists($validLetters{$char})) {\n    $validLetters{$char} += 1;\n  }\n}\n\nmy $count = 0;\n\nmy $possible = 1;\nwhile ($possible) {\n  foreach my $key (keys(%validLetters)) {\n    if ($key eq 'a' || $key eq 'u') {\n      if ($validLetters{$key} < 2) {\n        $possible = 0;\n      } else {\n        $validLetters{$key} -= 2;\n      }\n    } else {\n      if ($validLetters{$key} < 1) {\n        $possible = 0;\n      } else {\n        $validLetters{$key} -= 1;\n      }\n    }\n  }\n\n  if ($possible) {\n    $count++;\n  }\n}\n\nprint $count, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tchomp;\n\tmy %h;\n\t\n\tmap { ++$h{ $_ } } split //;\n\t\n\tmy @occ;\n\t\n\tpush @occ, 2 * $h{ $_ } for split //, 'Blbsr';\n\tpush @occ, $h{ $_ } for split //, 'au';\n\t\n\tmy $min = ( sort { $a <=> $b } @occ )[ 0 ];\n\tprint int $min / 2;\n\t\n\t}"}, {"source_code": "%h = map { $_ => 0 } @m = split //, 'Bulbasaur';\nmap $h{ $_ } += !/a|u/ + 1, <> =~ /[@m]/g;\n\nprint( ( sort { $a <=> $b } values %h )[ 0 ] >> 1 )"}], "negative_code": [{"source_code": "use warnings;\n\nmy $line = <>;\nchomp($line);\nmy($muie, $cuie, $c) = split(' ', $line);\n\nmy $i;\nmy @v1;\nmy @v2;\nmy $m = <>;\nchomp($m);\n\nfor($i=1;$i<=$m;++$i) {\n\tmy $line = <>;\n\tchomp($line);\n\tmy($x, $y) = split(' ', $line);\n\t\n\tif($y eq \"USB\") {\n\t\tpush(@v1, $x);\n\t}\n\telse {\n\t\tpush(@v2, $x);\n\t}\n}\n\n@v1 = sort {$a <=> $b} @v1;\n@v2 = sort {$a <=> $b} @v2;\n\n$i=0;\nmy $nr=0;\nwhile($i < scalar @v1 && $i < $muie) {\n\t$nr++;\n\t\n\t$total+=$v1[$i];\n\t$i++;\n}\n\nmy $j=0;\nwhile($j < scalar @v2 && $j < $cuie) {\n\t$nr++;\n\t\n\t$total+=$v2[$j];\n\t$j++;\n}\n\n#for($i=0;$i<scalar @v2;++$i) {\n#\tprintf(\"%d\\n\", $v2[$i]);\n#}\n\nwhile(($i < scalar @v1 || $j < scalar @v2) && $c > 0) {\n#\tprintf(\"%d %d %d %d\\n\", $i, $j, scalar @v1, scalar @v2);\n\t\n\tif($j >= scalar @v2 || ($v1[$i] <= $v2[$j] && $i < scalar @v1)) {\n\t\t$total+=$v1[$i];\n\t\t++$i;\n\t}\n\telse {\n\t\t$total+=$v2[$j];\n\t\t++$j;\n\t}\n\t\n\t++$nr;\n\t--$c;\n}\n\n\nprintf(\"%d %d\\n\", $nr, $total);\n"}, {"source_code": "$w = \"Bulbbasaur\";\n$h{$_} = 0 for split //, $w;\nwhile ( sysread(STDIN, $c, 1) ) {\n\t$n = () = $w =~ /$c/g;\n\tif ($n) {\n\t\t$h{$c} += 1/$n;\n\t}\n}\n@ans = sort {$a <=> $b} values %h;\n$ans = $ans[0] || 0;\nprint $ans;\n"}, {"source_code": "while ( sysread(STDIN, $c, 1) ) {\n\t$n = () = \"Bulbasaur\" =~ /$c/g;\n\tif ($n) {\n\t\t$h{$c} += 1/$n;\n\t}\n}\n@ans = sort {$a <=> $b} values %h;\n$ans = $ans[0] || 0;\nprint $ans;\n"}, {"source_code": "# Find the biggest subarray with GCD higher than 1\n# Solution: http://codeforces.com/problemset/submission/757/55701579\nmy $poke_nr = <>;\nmy %pokemons;\nmy @numbers = split(\" \", <>);\nmy $biggest_poke = 0;\nmy $max_poke = 0;\nmy $current_max = 0;\nforeach(@numbers)\n{\n\tif(exists($pokemons{$_}))\n\t{\n\t\t$pokemons{$_} = $pokemons{$_} + 1;\n\t}\n\telse\n\t{\n\t\t$pokemons{$_} = 1;\n\t\tif($_ > $biggest_poke)\n\t\t{\n\t\t\t$biggest_poke = $_;\n\t\t}\n\t}\n}\nforeach my $i(2 .. $biggest_poke)\n{\n\t$current_max = 0;\n\tfor(my $j = $i; $j <= $biggest_poke; $j += $i)\n\t{\n\t\tif(exists($pokemons{$j}))\n\t\t{\n\t\t\t$current_max += $pokemons{$j};\n\t\t}\n\t}\n\tif($current_max > $max_poke)\n\t{\n\t\t$max_poke = $current_max;\n\t}\n}\nif($max_poke > 0)\n{\n\tprint $max_poke;\n}\nelse\n{\n\tif(exists($pokemons{1}))\n\t{\n\t\tprint 1;\n\t}\n\telse\n\t{\n\t\tprint 0;\n\t}\n\n}\n"}, {"source_code": "# Find out how many Bulbasaurs we can catch\n# Solution: \nuse strict;\nuse warnings;\nmy $newspaper = <>;\nmy %letter;\nmy $bulbies = 0;\nforeach(split//,$newspaper)\n{\n\tif(exists($letter{$_}))\n\t{\n\t\t$letter{$_} = $letter{$_} + 1;\n\t\tif($bulbies < $letter{$_})\n\t\t{\n\t\t\t$bulbies = $letter{$_};\n\t\t}\n\t}\n\telse\n\t{\n\t\t$letter{$_} = 1;\n\t\tif($bulbies == 0)\n\t\t{\n\t\t\t$bulbies = 1;\n\t\t}\n\t}\n}\nforeach(split//,\"Bulbasr\")\n{\n\tif(exists($letter{$_}))\n\t{\n\t\tif($_ eq \"a\" or $_ eq \"b\"){\n\t\t\tif($bulbies > $letter{$_} / 2)\n\t\t\t{\n\t\t\t\t$bulbies = $letter{$_} / 2;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif($bulbies > $letter{$_})\n\t\t\t{\n\t\t\t\t$bulbies = $letter{$_}\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t$bulbies = 0;\n\t}\n}\nprint $bulbies;\n"}, {"source_code": "$,=\" \";\n\nmy %c;\nmap {$c{$_}++ }split //, \"Bulbasaur\";\nmy %d;\n\nmy $w=<>;\nchomp($w);\nmap {$d{$_}++ }split //, $w;\nfor my $t (keys %c)\n{\n$d{$t}=int($d{$t}/$c{$t});\n}\n\nprint min(values %d) , \"\\n\";\n\nsub min\n{\nmy $ans=shift;\nwhile(@_)\n{\nmy $temp=shift;\n$ans=$temp if($ans>$temp);\n}\nreturn $ans;\n}\n"}, {"source_code": "$,=\" \";\n\nmy %c;\nmap {$c{$_}++ }split //, \"Bulbasaur\";\nmy %d;\n\nmy $w=<>;\nchomp($w);\nmap {$d{$_}++ }split //, $w;\nfor my $t (keys %c)\n{\n$d{$t}=int($d{$t}/$c{$t});\n}\n\nprint min([values %d]) , \"\\n\";\n\nsub min_{\n\treturn $_[0] > $_[1] ? $_[1] : $_[0];\n}\n\nsub max_{\n\treturn $_[1] > $_[0] ? $_[1] : $_[0];\n}\n\nsub min{\n\tmy $a=shift;\n\tmy $mm=$a->[0];\n\tfor(my $i=1;$i<@{$a};$i++)\n\t{\n\t\t$mm=min_($mm,$a->[$i]);\n\t}\n\treturn $mm;\n}\n\nsub max{\n\tmy $a=shift;\n\tmy $mm=$a->[0];\n\tfor(my $i=1;$i<@{$a};$i++)\n\t{\n\t\t$mm=max_($mm,$a->[$i]);\n\t}\n\treturn $mm;\n}\n"}, {"source_code": "$_ = <>;\n$B = 'Bulbasaur' x 2e1;\n$i += $c eq 'B' while ($c = chop $B) && s/$c//;\nprint 0 + $i"}, {"source_code": "map $h{ $_ } += !/a|u/ + 1, <> =~ /[Bulbasaur]/g;\n\nprint( ( sort { $a <=> $b } values %h )[ 0 ] >> 1 )"}, {"source_code": "$B = 'Bulbasaur' x 2e4;\n$i += $c eq 'B' while ($c = chop $B) && s/$c//;\nprint 0 + $i"}, {"source_code": "use v5.20;\nmy $buffer = <>;\nchomp( $buffer );\nmy @arr = split //, $buffer;\nmy @fv = ();\nfor( my $i = 0 ; $i < length $buffer ; $i++ ) {\n\t$fv [$arr[ $i ]] ++;\n}\nmy $ans = @fv[ ord('B') ];\n$ans = $ans <= $fv[ ord('u') ] / 2 ? $ans : $fv[ ord('u') ] / 2;\n$ans = $ans <= $fv[ ord('l') ] ? $ans : $fv[ ord('l') ];\n$ans = $ans <= $fv[ ord('b') ] ? $ans : $fv[ ord('b') ];\n$ans = $ans <= $fv[ ord('a') ] / 2 ? $ans : $fv[ ord('a') ] / 2;\n$ans = $ans <= $fv[ ord('s') ] ? $ans : $fv[ ord('s') ];\n$ans = $ans <= $fv[ ord('r') ] ? $ans : $fv[ ord('r') ];\nsay int($ans);"}, {"source_code": "use v5.20;\nmy $buffer = <>;\nchomp( $buffer );\nmy @arr = split //, $buffer;\nmy @fv = ();\nfor( my $i = 0 ; $i < length $buffer ; $i++ ) {\n\t$fv [$arr[ $i ]] ++;\n}\nmy $ans = @fv[ ord('B') ];\n$ans = $ans <= $fv[ 'u'] / 2 ? $ans : $fv[ 'u' ] / 2;\n$ans = $ans <= $fv[ 'l' ] ? $ans : $fv[ 'l' ];\n$ans = $ans <= $fv[ 'b' ] ? $ans : $fv[ 'b' ];\n$ans = $ans <= $fv[ 'a'] / 2 ? $ans : $fv[ 'a' ] / 2;\n$ans = $ans <= $fv[ 's'] ? $ans : $fv[ 's' ];\n$ans = $ans <= $fv[ 'r' ] ? $ans : $fv[ 'r' ];\nsay int($ans);"}, {"source_code": "use v5.20;\nuse warnings;\n\nsub min {\n\tmy $ret = shift @_;\n\tforeach my $it (@_) {\n\t\tif ($ret > $it) { \n\t\t\t$ret = $it;\n\t\t}\n\t}\n\treturn $ret;\n}\n\nmy @fr = (0) x 300;\n\n$_ = <>;\n\nforeach my $it (split '') {\n\t$fr[ord $it] += 1;\n}\n\nsay min($fr[ord 'B'],int ($fr[ord 'a']/2),$fr[ord 'b'],$fr[ord 's'],$fr[ord 'l'],$fr[ord 'r'],int ($fr[ord 'u']));\n\n"}, {"source_code": "use v5.20;\n\n\nsub minn {\n\tmy ($a, $b) = @_;\n\tif ($a < $b) {\n\t\treturn $a;\n\t}\n\treturn $b;\n}\n\nmy $target = \"uaBlbsr\";\nmy %ap = map { $_ => 0 } (0..length($target));\n\nmy $text = <>;\nfor (my $i = 0; $i < length $text; $i++) {\n\tmy $ind = index($target, substr($text, $i, 1));\n\tif ($ind != -1) {\n\t\t$ap{$ind}++;\n\t}\n}\n\nmy $mn = minn($ap{0} / 2, $ap{1} / 2);\nfor (my $i = 2; $i < length $target; $i++) {\n\t$mn = minn($mn, $ap{$i});\n}\n\nsay $mn;"}, {"source_code": "#use v5.24;\nuse warnings;\nmy %fr;\n\nmy $line=<stdin>;\nchomp($line);\nmy @word=split(//,$line);\nfor (my $i=ord(\"A\");$i<=ord(\"z\");$i++){\n\t$fr{chr($i)}=0;\n}\nforeach my $lit (@word){\n\t$fr{$lit}++;\n}\nmy @key=(\"B\",\"u\",\"l\",\"b\",\"a\",\"s\",\"a\",\"u\",\"r\");\nmy $min=100006;\nforeach my $lit (@key){\n\tif ($min>$fr{$lit}) {$min=$fr{$lit}};\n}\nprint $min;\n<stdin>;\nexit(0);\n\n#Bulbasaur"}, {"source_code": "use v5.20.1;\nuse warnings;\n\n=pod\nmy $filename = \"date.in\";\nopen(my $fh, '<:encoding(UTF-8)', $filename)\n\tor die \"Could not open the file\";\n=cut\n\nmy $line = <STDIN>;\nchomp($line);\n\nmy @input = split('', $line);\n\nmy %letters = (\n\n\t'B' => 0,\n\t'u' => 0,\n\t'l' => 0,\n\t'b' => 0,\n\t'a' => 0,\n\t's' => 0,\n\t'r' => 0,\n\n);\n\nfor(my $i = 0; $i < @input; $i++){\n\n\tif( index(\"Bulbasr\", $input[$i]) != -1 ){\n\n\t\t$letters{$input[$i]}++;\n\n\t}\n\n}\n\nmy $mini = 100002;\n\nwhile(my ($key, $value) = each(%letters)){\n\n\n\tif( ($key eq 'a' || $key eq 'u') && $value/2 < $mini ){\n\n\t\t$mini = $value/2;\n\n\t}elsif($key ne 'a' && $key ne 'u' && $value < $mini){\n\n\t\t$mini = $value;\n\n\t}\n\n\n}\n\nsay $mini;\n"}], "src_uid": "9c429fd7598ea75acce09805a15092d0"}
{"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @a = sort {$b <=> $a} split ' ', <>;\nmy $sum = 0;\nfor (@a) {\n    $sum += $_;\n}\n\nmy $res = 0;\nmy $curr = 0;\n\nfor (@a) {\n    $res++;\n    $curr += $_;\n    last if (2*$curr > $sum);\n}\n\nprint \"$res\\n\";\n", "positive_code": [{"source_code": "$n=<>;\n@arr=split(' ',<STDIN>);\n#@arr=sort(@arr);\n@arr = sort {$a <=> $b} @arr;\n$som=0;\nfor($i=0;$i<$n;$i++){\n$som+=$arr[$i];\n}\n#print \"@arr\\n\";\n$ok=1;\n$i=$n-2;\n$profit=$arr[$n-1];\n$nb=1;\n\nwhile($ok && $i>=0){\nif($profit<=$som/2){\n$nb++;\n$profit+=$arr[$i];\n}\nelse{\n$ok=0;\n}\n$i--;\n}\nprint $nb;"}, {"source_code": "<STDIN>;\n@num = sort { $b <=> $a } split(/ +/, <STDIN>);\n\n$s = $sum = $count = 0;\nforeach(@num) { $sum += $_ }\n\nforeach(@num) \n{\n\t$s += $_; \n\t++$count; \n\tlast if ($s > $sum / 2);\n}\n\nprint $count;\n"}, {"source_code": "$n = <>;\n@a = sort {$b <=> $a} split(\" \", <>);\n$sum = 0;\nfor (@a) {\n    $sum += $_;\n}\n$tmp = 0;\nfor (my $i = 0; $i < $n; ++$i) {\n    $tmp += $a[$i];\n    if ($tmp > $sum - $tmp) {\n        print $i + 1;\n        last;\n    }\n}\n"}, {"source_code": "$n = <>;\n@a = sort {$b <=> $a} split ' ', <>;\nfor ($i = 0; $i < $n; ++$i) {\n    $sum += $a[$i];\n}\nfor ($i = 0; $i < $n; ++$i) {\n    $suma += $a[$i];\n    if ($suma > $sum - $suma) {\n        print $i + 1;\n        exit;\n    }\n}"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n\n$inpt = <STDIN>;\nchomp $inpt;\n\n@nums = split / +/, $inpt;\n@nums = sort {$b <=> $a} @nums;\n\n$s = 0;\n\nfor($i=0;$i<@nums;$i++)\n{\n\n  $s += @nums[$i];\n\n}\n\n$s /= 2;\n\n$s2 = 0;\n$it = 0;\n\nwhile( $s2 <= $s )\n{\n\n  $s2 += @nums[$it];\n  $it++;\n\n}\n\nprint $it;\n"}, {"source_code": "sub TakeInput\n{\n    $n = <STDIN>;\n    $values = <STDIN>;\n    @values = split(\" \",$values);\n    return @values;\n}\n\nsub sortArray\n{\n    @Array = @_;\n    $l = @Array;\n    for($i=0;$i<$l;$i++)\n    {\n        for($j=0;$j<($l-$i);$j++)\n        {\n            if(@Array[$j+1]>@Array[$j])\n            {\n\n                $tmp = @Array[$j];\n                @Array[$j] = @Array[$j+1];\n                @Array[$j+1] = $tmp;\n            }\n        }       \n    }\n    return @Array;  \n}\nsub sum\n{\n    my @Array = @_;\n    my $l = @Array;\n    $sm = 0;\n    for($i=0;$i<$l;$i++)\n    {   \n        \n        $sm = $sm+@Array[$i];\n\n    }\n    return $sm;\n}\n\n@values = TakeInput();\n@sorted = sortArray(@values);\n$l = @sorted;\n$flag = 0;\nwhile($flag==0)\n{\n\n    for($counter=0;$counter<$l-1;$counter++)\n    {   \n\n        @list1 = @sorted[0..$counter];\n        @list2 = @sorted[$counter+1..$l-1];\n        $s1 = sum(@list1);\n        $s2 = sum(@list2);\n        if($s1>$s2)\n        {   \n            $v =  scalar @list1;\n            print $v;\n            $flag = 1;\n            last;\n        }\n\n    }\n\n    if($flag == 0)\n    {\n        print scalar @sorted;\n        $flag = 1;\n    }\n}\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = sort {$b <=> $a} split ' ', <>;\n\t$sum = eval join '+', @_;\n\t$mysum = 0;\n\t\n\t$i = 0;\n\tfor (@_){\n\t\t$i ++;\n\t\t$mysum += $_;\n\t\t$mysum * 2 > $sum and last\n\t\t}\n\t\n\tprint $i\n\t}"}, {"source_code": "my $num = <>;\nmy $coin = <>;\nchomp $coin;\nmy @coin = sort {$b<=>$a} split / /, $coin;\nmy $sum=0;\n$sum += $_ foreach @coin;\nmy $count;\nmy $val=0;\nuntil ($val > $sum/2) {\n    $count++;\n    $val += shift @coin;\n}\nprint $count;"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\n@a = sort { $b<=>$a } split / /, <>;\n$tot += $_ foreach (@a);\n$ans = 0;\n$tmp = 0;\nforeach (@a) {\n\t$tmp += $_;\n\t++$ans;\n\t$tmp>$tot-$tmp and last;\n}\nsay $ans;"}, {"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nmy $n = <>;\nchomp(my $s = <>);\nmy @c = split / /, $s;\n@c = sort { $b <=> $a } @c;\n\nsub sum {\n\tmy $ref = shift;\n\tmy $sum;\n\t$sum += $_ for @$ref;\n\treturn $sum;\n}\n\nmy $cnt = 0;\nmy $sum = 0;\nwhile ($sum <= sum \\@c) {\n\t$sum += shift @c;\n\t$cnt++;\n\tlast unless @c;\n}\nprint $cnt;\n"}, {"source_code": "my $n = <>;\nmy @arr = reverse sort { $a <=> $b } split \" \", <>;\nmy ($mid, $ans, $sum) = (0, 0, 0);\n$mid += $_ foreach(@arr);\n$mid = int($mid / 2);\n\nforeach(@arr) {\n    $sum += $_;\n    $ans++;\n    last if ($sum > $mid);\n}\nprint \"$ans\\n\";"}, {"source_code": "$n=<>;\nchomp($n);\n$c=<>;\nchomp($c);\n\n#print $c;\n\n@c=split ' ',$c;\n\n#print @c;\n\n@c = reverse (sort {$a <=> $b} @c);\n\nforeach (@c)\n{\n    $sum+=$_;\n}\n$mid=$sum/2;\n\n#print $mid;\n#print @c;\n$myC=1;\n\nforeach(@c)\n{\n    $me+=$_;\n    if ($me>$mid)\n    {\n        print $myC;   \n        exit; \n    }\n    $myC++;\n}"}, {"source_code": "#!/usr/bin/perl\n# Codeforces Practice - 160A Twins\nuse warnings;\nuse strict;\n\nmy $num = <STDIN>;\nchomp $num;\n\nmy @coins = split(\" \",<STDIN>);\nmy $sum = 0;\n$sum += $_ for @coins;\n\n@coins = sort {$b<=>$a} @coins;\n\nmy $sum2 = 0;\nfor(my $i = 1; @coins > 0; $i++){\n    my $temp = shift @coins;   \n    $sum2 += $temp;\n    $sum -= $temp;\n    if($sum2>$sum){\n        print $i;\n        last;\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\n@a = sort { $b<=>$a } split / /, <>;\n$tot += $_ foreach (@a);\n$ans = 0;\n$tmp = 0;\nforeach (@a) {\n\t$tmp += $_;\n\t++$ans;\n\t$tmp>$tot-$tmp and last;\n}\nsay $ans;\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy @x = sort { $a <=> $b } split ' ', <>;\nmy $s = 0;\n$s += $_ for @x;\nmy $t = 0;\n$t += pop @x while $t * 2 <= $s;\nprint $n - @x, \"\\n\";\n"}, {"source_code": "chomp($n = <STDIN>);\nchomp($l = <STDIN>);\n\n@coins = split /\\s+/, $l;\n@coins = sort { $b <=> $a } @coins;\n\n$total = 0;\nmap { $total += $_; } @coins;\n$taken_sum = 0;\n$taken = 0;\nwhile($taken_sum <= ($total - $taken_sum)) {\n\t$taken_sum += shift @coins;\n\t$taken++;\n#\tprint \"after taking $taken coins we have \".$taken_sum.\" and there's \".($total-$taken_sum).\" left\\n\";\n}\n\nprint \"$taken\\n\";"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nchomp(my $n = <>);\nchomp(my $s = <>);\n\n$s =~ /((.)\\1)/;\nsay $2;\n"}, {"source_code": "my $n = <>;\nmy @arr = reverse sort split \" \", <>;\nmy ($mid, $ans, $sum) = (0, 0, 0);\n$mid += $_ foreach(@arr);\n$mid = int($mid / 2);\n\nforeach(@arr) {\n    $sum += $_;\n    $ans++;\n    last if ($sum > $mid);\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n# Codeforces Practice - 160A Twins\nuse warnings;\nuse strict;\n\nmy $num = <STDIN>;\nchomp $num;\n\nmy @coins = split(\" \",<STDIN>);\nmy $sum = 0;\n$sum += $_ for @coins;\n\n@coins = sort {$b<=>$a} @coins;\n\nprint \"@coins\\n\";\n\nmy $sum2 = 0;\nfor(my $i = 1; @coins > 0; $i++){\n    my $temp = shift @coins;   \n    $sum2 += $temp;\n    $sum -= $temp;\n    if($sum2>$sum){\n        print $i;\n        last;\n    }\n}"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy @x = sort split ' ', <>;\nmy $s = 0;\n$s += $_ for @x;\nmy $t = 0;\n$t += pop @x while $t * 2 <= $s;\nprint $n - @x, \"\\n\";\n"}, {"source_code": "chomp($n = <STDIN>);\nchomp($l = <STDIN>);\n\n@coins = split /\\s+/, $l;\nsort { $b <=> $a } @coins;\n\n$total = 0;\nmap { $total += $_; } @coins;\n$taken_sum = 0;\n$taken = 0; \nwhile($taken_sum <= ($total - $taken_sum)) {\n\t$taken_sum += shift @coins;\n\t$taken++;\n}\n\nprint \"$taken\\n\";"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @a = split ' ', <>;\nmy $sum = 0;\nfor (@a) {\n    $sum += $_;\n}\n\nmy $res = 0;\nmy $curr = 0;\n\nfor (@a) {\n    last if (2*$curr > $sum);\n    $res++;\n    $curr += $_;\n}\n\nprint \"$res\\n\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @a = reverse sort split ' ', <>;\nmy $sum = 0;\nfor (@a) {\n    $sum += $_;\n}\n\nmy $res = 0;\nmy $curr = 0;\n\nfor (@a) {\n    last if (2*$curr > $sum);\n    $res++;\n    $curr += $_;\n}\n\nprint \"$res\\n\";\n"}, {"source_code": "$n=<>;\n@arr=split(' ',<STDIN>);\n@arr=sort(@arr);\n$som=0;\nfor($i=0;$i<$n;$i++){\n$som+=$arr[$i];\n}\n$ok=1;\n$i=$n-2;\n$profit=$arr[$n-1];\n$nb=1;\n\nwhile($ok && $i>=0){\nif($profit<=$som/2){\n$nb++;\n$profit+=$arr[$i];\n}\nelse{\n$ok=0;\n}\n$i--;\n}\nprint $nb;"}, {"source_code": "$n=<>;\n@arr=split(' ',<STDIN>);\n#@arr=sort(@arr);\n@arr = sort {$a <=> $b} @arr;\n$som=0;\nfor($i=0;$i<$n;$i++){\n$som+=$arr[$i];\n}\nprint \"@arr\\n\";\n$ok=1;\n$i=$n-2;\n$profit=$arr[$n-1];\n$nb=1;\n\nwhile($ok && $i>=0){\nif($profit<=$som/2){\n$nb++;\n$profit+=$arr[$i];\n}\nelse{\n$ok=0;\n}\n$i--;\n}\nprint $nb;"}, {"source_code": "<STDIN>;\n@num = reverse sort split(/ +/, <STDIN>);\n$s = $sum = $count = 0;\nforeach(@num) { $sum += $_ }\n\nforeach(@num) \n{\n    $s += $_; \n    ++$count; \n    if ($s < $sum / 2) { last; }\n}\n\nprint STDOUT $count;"}, {"source_code": "<STDIN>;\n@num = reverse sort split(/ +/, <STDIN>);\n$s = $sum = $count = 0;\nforeach(@num) { $sum += $_ }\n\nforeach(@num) \n{\n    $s += $_; \n    ++$count; \n    if ($s > $sum / 2) { last; }\n}\n\nprint STDOUT $count;"}, {"source_code": "$n = <>;\n@a = sort {$b <=> $a} split(\" \", <>);\n$sum = 0;\nfor (@a) {\n    $sum += $_;\n}\n$tmp = 0;\nfor (my $i = 0; $i < $n; ++$i) {\n    $tmp += $a[i];\n    if ($tmp > $sum - $tmp) {\n        print $i + 1;\n        last;\n    }\n}\n\n    "}, {"source_code": "$n = <>;\n@a = sort {$b <=> $a} split '', <>;\nfor ($i = 0; $i < $n; ++$i) {\n    $sum += $a[$i];\n}\nfor ($i = 0; $i < $n; ++$i) {\n    $suma += $a[$i];\n    if ($suma > $sum - $suma) {\n        print $i + 1;\n        exit;\n    }\n}\n"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n\n@nums = split / +/, <STDIN>;\n@nums = sort {$b cmp $a} @nums;\n\n$s = 0;\n\nfor($i=0;$i<@nums;$i++)\n{\n\n  $s += @nums[$i];\n\n}\n\n$s /= 2;\n\n$s2 = 0;\n$it = 0;\n\nwhile( $s2 <= $s )\n{\n\n  $s2 += @nums[$it];\n  $it++;\n\n}\n\nprint $it;\n"}, {"source_code": "sub TakeInput\n{\n    $n = <STDIN>;\n    $values = <STDIN>;\n    @values = split(\" \",$values);\n    return @values;\n}\n\nsub sortArray\n{\n    @Array = @_;\n    $l = @Array;\n    for($i=0;$i<$l;$i++)\n    {\n        for($j=0;$j<($l-$i);$j++)\n        {\n            if(@Array[$j+1]>@Array[$j])\n            {\n\n                $tmp = @Array[$j];\n                @Array[$j] = @Array[$j+1];\n                @Array[$j+1] = $tmp;\n            }\n        }       \n    }\n    return @Array;  \n}\nsub sum\n{\n    @Array = @_;\n    my $l = @Array;\n    $sum = 0;\n    for($i=0;$i<$l;$i++)\n    {\n        $sum = $sum+@Array[i];\n    }\n    return $sum;\n}\n@values = TakeInput();\n@sorted = sortArray(@values);\n$l = @sorted;\n$flag = 0;\nwhile($flag==0)\n{\n\n    for($counter=0;$counter<$l-1;$counter++)\n    {   \n\n        @list1 = @sorted[0..$counter];\n        @list2 = @sorted[$counter+1..$l-1];\n        $s1 = sum(@list1);\n        $s2 = sum(@list2);\n        if($s1>$s2)\n        {\n            print scalar @list1;\n            $flag = 1;\n        }\n\n    }\n\n    if($flag == 0)\n    {\n        print scalar @sorted;\n        $flag = 1;\n    }\n}\n"}, {"source_code": "sub TakeInput\n{\n    $n = <STDIN>;\n    $values = <STDIN>;\n    @values = split(\" \",$values);\n    return @values;\n}\n\nsub sortArray\n{\n    @Array = @_;\n    $l = @Array;\n    for($i=0;$i<$l;$i++)\n    {\n        for($j=0;$j<($l-$i);$j++)\n        {\n            if(@Array[$j+1]>@Array[$j])\n            {\n\n                $tmp = @Array[$j];\n                @Array[$j] = @Array[$j+1];\n                @Array[$j+1] = $tmp;\n            }\n        }       \n    }\n    return @Array;  \n}\nsub sum\n{\n    @Array = @_;\n    my $l = @Array;\n    $sum = 0;\n    for($i=0;$i<$l;$i++)\n    {\n        $sum = $sum+@Array[i];\n    }\n    return $sum;\n}\n@values = TakeInput();\n@sorted = sortArray(@values);\n$l = @sorted;\n$flag = 0;\nwhile($flag==0)\n{\n\n    for($counter=0;$counter<$l-1;$counter++)\n    {   \n\n        @list1 = @sorted[0..$counter];\n        @list2 = @sorted[$counter+1..$l-1];\n        $s1 = sum(@list1);\n        $s2 = sum(@list2);\n        if($s1>$s2)\n        {\n\n            $v =  scalar @list1;\n            print $v + 1;\n            $flag = 1;\n            last;\n        }\n\n    }\n\n    if($flag == 0)\n    {\n        print scalar @sorted;\n        $flag = 1;\n    }\n}\n"}, {"source_code": "my $num = <>;\nmy $coin = <>;\nchomp $coin;\nmy @coin = reverse sort split / /, $coin;\nmy $sum;\n$sum += $_ foreach @coin;\nmy $count;\nmy $val=0;\nuntil ($val > $sum/2) {\n    $count++;\n    $val += shift @coin;\n}\nprint $count;"}], "src_uid": "ee535e202b7662dbaa91e869c8c6cee1"}
{"source_code": "@_=split/ /,<>;\n$d[$_]=abs($_[$_]-$_[$_-2]) for 0..1;\n\n\t$_[$_] += $d[($_+1) % 2] * ($d[0]-$d[1] ? 1: ++$ok*0),\n\t$d[$_ % 2] or $ok++\n\tfor 0..@_;\n\nprint $ok? \"@_[0,3,2,1]\" :-1", "positive_code": [{"source_code": "my ($x1, $y1, $x2, $y2) = split / /, <>;\nif ($x1 != $x2 && $y1 != $y2) {\n    if (abs($x2 - $x1) != abs($y2 - $y1)) {\n        print -1 . \"\\n\";\n    }\n    else {\n        print \"$x2 $y1 $x1 $y2\";\n    }\n}\nelse {\n    if ($x1 == $x2) {\n        print (($x1 + abs($y2 - $y1)) . \" \" . $y1 . \" \");\n        print (($x2 + abs($y2 - $y1)) . \" \" . $y2);     # \\n does not needed because we didn't chomp $y2\n    }\n    else {\n        print $x1 . \" \" . ($y1 + abs($x2 - $x1)) . \" \";\n        print $x2 . \" \" . ($y2 + abs($x2 - $x1)) . \"\\n\";\n    }\n}\n"}, {"source_code": "($x,$y,$X,$Y)=split/ /,<>;\n$dx=abs($x-$X);\n$dy=abs($y-$Y);\nif (!$dx or !$dy){\nprint $x+$dy,\" \",$Y+$dx,\" \",$X+$dy,\" \",$y+$dx\n}\nelsif ($dx==$dy){\nprint \"$x $Y $X $y\"\n}\nelse {print -1};"}, {"source_code": "@_=split/ /,<>;\nchomp @_;\nif ($_[0]==$_[2]){\n$d=abs($_[1]-$_[3]);\nprint $_[0]+$d,\" \",$_[1],\" \",$_[0]+$d,\" \",$_[3];\nexit\n}\nif ($_[1]==$_[3]){\n$d=abs($_[0]-$_[2]);\nprint $_[0],\" \",$_[1]+$d,\" \",$_[2],\" \",$_[1]+$d;\nexit\n}\nif (abs($_[0]-$_[2])==abs($_[1]-$_[3])){\nprint \"$_[0] $_[3] $_[2] $_[1]\"\n}\nelse {print -1}"}, {"source_code": "#!/perl -w\n\nuse strict ;\n\nmy ($x1,$y1,$x2,$y2) = split /\\s+/ , <STDIN>;\n\nif    ( $x1 == $x2 && $y1 != $y2 ){\n    my $distance  =  abs($y2-$y1) ;\n    print $x1+$distance,\" \",$y1,\" \",$x2+$distance,\" \",$y2,\"\\n\" ;\n}elsif( $y1 == $y2 && $x1 != $x2 ){\n    my $distance  =  abs($x2-$x1) ;\n    print $x1,\" \",$y1+$distance,\" \",$x2,\" \",$y2+$distance,\"\\n\" ;\n}elsif( $x1 != $x2 && $y1 != $y2 && abs($x2-$x1)==abs($y2-$y1) ){\n    print $x1,\" \",$y2,\" \",$x2,\" \",$y1,\"\\n\";\n}else{\n    print \"-1\\n\" ;\n}"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nour ($x2, $y2, $x3, $y3) = (0, 0, 0, 0);\n\nsub judgex {\n\tmy $x = shift;\n\t($x>=-1000 && x<=1000) and return 1 or return 0;\n}\n\nsub judge {\n\tif (judgex($x2) && judgex($y2) && judgex($x3) && judgex($y3)) {\n\t\treturn 1;\n\t} else {\n\t\treturn 0;\n\t}\n} \n\n($x0, $y0, $x1, $y1) = split / /, <>;\nif ($x0 == $x1) {\n\t$d = abs($y0 - $y1);\n\t$x2 = $x3 = $x0 + $d;\n\t$y2 = $y0;\n\t$y3 = $y1;\n\tif (!judge()) {\n\t\t$x2 = $x3 = $x0 - d;\n\t}\n} elsif ($y0 == $y1) {\n\t$d = abs($x0 - $x1);\n\t$y2 = $y3 = $y0 + $d;\n\t$x2 = $x0;\n\t$x3 = $x1;\n\tif (!judge()) {\n\t\t$y2 = $y3 = $y0 - $d;\n\t}\n} else {\n\tif (abs($x0 - $x1) == abs($y0 - $y1)) {\n\t\t$x2 = $x0;\n\t\t$y2 = $y1;\n\t\t$x3 = $x1;\n\t\t$y3 = $y0;\n\t} else {\n\t\tsay -1 and exit;\n\t}\n}\n\njudge() and say \"$x2 $y2 $x3 $y3\" or say -1;\n\n\n"}, {"source_code": "($x,$y,$X,$Y)=split/ /,<>;\n$dx=abs($x-$X);\n$dy=abs($y-$Y);\nif (!$dx or !$dy){\nprint $x+$dy,\" \",$Y+$dx,\" \",$X+$dy,\" \",$y+$dx\n}\nelsif ($dx==$dy){\nprint \"$x $Y $X $y\"\n}\nelse {print -1}"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nmy ($x1, $y1, $x2, $y2) = split ' ', <>;\n\nmy $d = abs($x1 - $x2) || abs($y1 - $y2);\n\nif ($y1 != $y2 && $d != abs($y1 - $y2)) {\n  say -1;\n  exit;\n}\n\nmy ($x3, $y3, $x4, $y4);\n\nif ($x1 == $x2) {\n  ($x3, $y3, $x4, $y4) = ($x1 + $d, $y1, $x1 + $d, $y2);\n} elsif ($y1 == $y2) {\n  ($x3, $y3, $x4, $y4) = ($x1, $y1 + $d, $x2, $y1 + $d);\n} else {\n  ($x3, $y3, $x4, $y4) = ($x1, $y2, $x2, $y1);\n}\n\nsay \"$x3 $y3 $x4 $y4\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $l = <>;\nchomp $l;\n\n$l =~ /^(-?\\d+) (-?\\d+) (-?\\d+) (-?\\d+)/;\n\nmy ($x1, $y1, $x2, $y2) = ($1, $2, $3, $4);\n\nmy $size = abs($x1 - $x2);\nif (abs($y1 - $y2) > $size) {\n    $size = abs($y1 - $y2);\n}\n\nmy $x_align = 0;\nif ($x1 == $x2) {\n    $x_align = 1;\n}\n\nmy $y_align = 0;\nif ($y1 == $y2) {\n    $y_align = 1;\n}\n\nif ($x_align && $y_align) {\n    print \"-1\\n\";\n    exit 0;\n}\n\nif (!$x_align && !$y_align) {\n    if (abs($x1 - $x2) != abs($y1 - $y2)) {\n        print \"-1\\n\";\n        exit 0;\n    }\n}\n\nif ($x_align) {\n    my $x = $x1;\n    if ($x+$size <= 1000) {\n        print \"\".($x+$size).\" \".($y1).\" \".($x+$size).\" \".($y2).\"\\n\";\n    } elsif ($x-$size >= -1000) {\n        print \"\".($x-$size).\" \".($y1).\" \".($x-$size).\" \".($y2).\"\\n\";\n    } else {\n        print \"-1\\n\";\n    }\n    exit 0;\n}\n\nif ($y_align) {\n    my $y = $y1;\n    if ($y+$size <= 1000) {\n        print \"\".($x1).\" \".($y+$size).\" \".($x2).\" \".($y+$size).\"\\n\";\n    } elsif ($y-$size >= -1000) {\n        print \"\".($x1).\" \".($y-$size).\" \".($x2).\" \".($y-$size).\"\\n\";\n    } else {\n        print \"-1\\n\";\n    }\n    exit 0;\n}\n\nif ($x1 < $x2) {\n    if ($y1 < $y2) {\n        if ($y1+$size <= 1000 && $y2-$size >= -1000) {\n            print \"\".($x1).\" \".($y1+$size).\" \".($x2).\" \".($y2-$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    } else {\n        if ($y2+$size <= 1000 && $y1-$size >= -1000) {\n            print \"\".($x1).\" \".($y1-$size).\" \".($x2).\" \".($y2+$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    }\n} else {\n    if ($y1 < $y2) {\n        if ($y1+$size <= 1000 && $y2-$size >= -1000) {\n            print \"\".($x1).\" \".($y1+$size).\" \".($x2).\" \".($y2-$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    } else {\n        if ($y2+$size <= 1000 && $y1-$size >= -1000) {\n            print \"\".($x1).\" \".($y1-$size).\" \".($x2).\" \".($y2+$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    }\n}\n\n"}], "negative_code": [{"source_code": "@_=split/ /,<>;\nchomp @_;\nif ($_[0]==$_[2]){\n$d=abs($_[1]-$_[3]);\nprint $_[0]+$d,\" \",$_[1],\" \",$_[0]+$d,\" \",$_[3];\nexit\n}\nif ($_[1]==$_[3]){\n$d=abs($_[0]-$_[2]);\nprint $_[0],\" \",$_[1]+$d,\" \",$_[2],\" \",$_[1]+$d;\nexit\n}\nif (abs($_[0]-$_[2])==abs($_[1]-$_[3])){\nprint \"$_[0] $_[3] $_[1] $_[2]\"\n}\nelse {print -1}"}, {"source_code": "@_=split/ /,<>;\nchomp @_;\nif ($_[0]==$_[2]){\n$d=abs($_[1]-$_[3]);\nprint $_[0]+$d,\" \",$_[1],\" \",$_[0]+$d,\" \",$_[1];\nexit\n}\nif ($_[1]==$_[3]){\n$d=abs($_[0]-$_[2]);\nprint $_[0],\" \",$_[1]+$d,\" \",$_[0],\" \",$_[1]+$d;\nexit\n}\nif (abs($_[0]-$_[2])==abs($_[1]-$_[3])){\nprint \"$_[0] $_[3] $_[1] $_[2]\"\n}\nelse {print -1}"}, {"source_code": "my ($x1, $y1, $x2, $y2) = split / /, <>;\nif ($x1 != $x2 && $y1 != $y2) {\n    if (abs($x2 - $x1) != abs($y2 - $y1)) {\n        print -1 . \"\\n\";\n    }\n    else {\n        print \"$x2 $y1 $x1 $y2\";\n    }\n}\nelse {\n    if ($x1 == $x2) {\n        print $x1 + abs($y2 - $y1) . \" \" . $y1 . \" \";\n        print $x2 + abs($y2 - $y1) . \" \" . $y2;     # \\n does not needed because we didn't chomp $y2\n    }\n    else {\n        print $x1 . \" \" . $y1 + abs($x2 - $x1) . \" \";\n        print $x2 . \" \" . $y2 + abs($x2 - $x1) . \"\\n\";\n    }\n}\n"}, {"source_code": "my ($x1, $y1, $x2, $y2) = split / /, <>;\n\nif ($x1 != $x2 && $y1 != $y2) {\n    if (abs($x2 - $x1) != abs($y2 - $y1)) {\n        print -1 . \"\\n\";\n    }\n    else {\n        print \"$x2 $y1 $x1 $y2\";\n    }\n}\nelse {\n    if ($x1 == $x2) {\n        print abs($y2 - $y1) . \" \" . $y1 . \" \";\n        print abs($y2 - $y1) . \" \" . $y2;     # \\n does not needed because we didn't chomp $y2\n    }\n    else {\n        print $x1 . \" \" . abs($x2 - $x1) . \" \";\n        print $x2 . \" \" . abs($x2 - $x1) . \"\\n\";\n    }\n}\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nmy ($x1, $y1, $x2, $y2) = split ' ', <>;\n\nmy $d = abs($x1 - $x2) || abs($y1 - $y2);\n\nif ($d != abs($y1 - $y2)) {\n  say -1;\n  exit;\n}\n\nmy ($x3, $y3, $x4, $y4);\n\nif ($x1 == $x2) {\n  ($x3, $y3, $x4, $y4) = ($x1 + $d, $y1, $x1 + $d, $y2);\n} elsif ($y1 == $y2) {\n  ($x3, $y3, $x4, $y4) = ($x1, $y1 + $d, $x2, $y1 + $d);\n} else {\n  ($x3, $y3, $x4, $y4) = ($x1, $y2, $x2, $y1);\n}\n\nsay \"$x3 $y3 $x4 $y4\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $l = <>;\nchomp $l;\n\n$l =~ /^(\\d+) (\\d+) (\\d+) (\\d+)/;\n\nmy ($x1, $y1, $x2, $y2) = ($1, $2, $3, $4);\n\nmy $size = abs($x1 - $x2);\nif (abs($y1 - $y2) > $size) {\n    $size = abs($y1 - $y2);\n}\n\nmy $x_align = 0;\nif ($x1 == $x2) {\n    $x_align = 1;\n}\n\nmy $y_align = 0;\nif ($y1 == $y2) {\n    $y_align = 1;\n}\n\nif ($x_align && $y_align) {\n    print \"-1\\n\";\n    exit 0;\n}\n\nif (!$x_align && !$y_align) {\n    if (abs($x1 - $x2) != abs($y1 - $y2)) {\n        print \"-1\\n\";\n        exit 0;\n    }\n}\n\nif ($x_align) {\n    my $x = $x1;\n    print \"\".($x+$size).\" \".($y1).\" \".($x+$size).\" \".($y2).\"\\n\";\n    exit 0;\n}\n\nif ($y_align) {\n    my $y = $y1;\n    print \"\".($x1).\" \".($y+$size).\" \".($x2).\" \".($y+$size).\"\\n\";\n    exit 0;\n}\n\nif ($x1 < $x2) {\n    if ($y1 < $y2) {\n        print \"\".($x1).\" \".($y1+$size).\" \".($x2).\" \".($y2-$size).\"\\n\";\n    } else {\n        print \"\".($x1).\" \".($y1-$size).\" \".($x2).\" \".($y2+$size).\"\\n\";\n    }\n} else {\n    if ($y1 < $y2) {\n        print \"\".($x1).\" \".($y1+$size).\" \".($x2).\" \".($y2-$size).\"\\n\";\n    } else {\n        print \"\".($x1).\" \".($y1-$size).\" \".($x2).\" \".($y2+$size).\"\\n\";\n    }\n}\n\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $l = <>;\nchomp $l;\n\n$l =~ /^(\\d+) (\\d+) (\\d+) (\\d+)/;\n\nmy ($x1, $y1, $x2, $y2) = ($1, $2, $3, $4);\n\nmy $size = abs($x1 - $x2);\nif (abs($y1 - $y2) > $size) {\n    $size = abs($y1 - $y2);\n}\n\nmy $x_align = 0;\nif ($x1 == $x2) {\n    $x_align = 1;\n}\n\nmy $y_align = 0;\nif ($y1 == $y2) {\n    $y_align = 1;\n}\n\nif ($x_align && $y_align) {\n    print \"-1\\n\";\n    exit 0;\n}\n\nif (!$x_align && !$y_align) {\n    if (abs($x1 - $x2) != abs($y1 - $y2)) {\n        print \"-1\\n\";\n        exit 0;\n    }\n}\n\nif ($x_align) {\n    my $x = $x1;\n    if ($x+$size <= 1000) {\n        print \"\".($x+$size).\" \".($y1).\" \".($x+$size).\" \".($y2).\"\\n\";\n    } elsif ($x-$size >= -1000) {\n        print \"\".($x-$size).\" \".($y1).\" \".($x-$size).\" \".($y2).\"\\n\";\n    } else {\n        print \"-1\\n\";\n    }\n    exit 0;\n}\n\nif ($y_align) {\n    my $y = $y1;\n    if ($y+$size <= 1000) {\n        print \"\".($x1).\" \".($y+$size).\" \".($x2).\" \".($y+$size).\"\\n\";\n    } elsif ($y-$size >= -1000) {\n        print \"\".($x1).\" \".($y-$size).\" \".($x2).\" \".($y-$size).\"\\n\";\n    } else {\n        print \"-1\\n\";\n    }\n    exit 0;\n}\n\nif ($x1 < $x2) {\n    if ($y1 < $y2) {\n        if ($y1+$size <= 1000 && $y2-$size >= -1000) {\n            print \"\".($x1).\" \".($y1+$size).\" \".($x2).\" \".($y2-$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    } else {\n        if ($y2+$size <= 1000 && $y1-$size >= -1000) {\n            print \"\".($x1).\" \".($y1-$size).\" \".($x2).\" \".($y2+$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    }\n} else {\n    if ($y1 < $y2) {\n        if ($y1+$size <= 1000 && $y2-$size >= -1000) {\n            print \"\".($x1).\" \".($y1+$size).\" \".($x2).\" \".($y2-$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    } else {\n        if ($y2+$size <= 1000 && $y1-$size >= -1000) {\n            print \"\".($x1).\" \".($y1-$size).\" \".($x2).\" \".($y2+$size).\"\\n\";\n        } else {\n            print \"-1\\n\";\n        }\n    }\n}\n\n"}], "src_uid": "71dea31e1244797f916adf5f526f776e"}
{"source_code": "($n,$m)=split/ /,<>;\nif ($n>$m+1 or $m>$n*2+2){print -1; exit}\nif ($n==$m+1){print ('0'.('10'x $m)); exit}\n$_.=1 while $m-->$n*2;\nprint $_,'011'x(++$m-$n),'01'x(2*$n-$m)", "positive_code": [{"source_code": "\nwhile(<>){\n\t\n\t($n,$m)=split/ /;\n\tchomp $m;\n\t$_='';\n\tif ($n>$m+1){print \"-1\\n\"; next}\n\tif ($m>$n*2+2){print \"-1\\n\"; next}\n\tif ($n==$m+1){print ('0'.('10'x --$n)); print \"\\n\"; next}\n\twhile ($m>$n*2){$m--; $_.=\"1\"}\n\tprint;\n\tprint ('011'x($m-$n),'01'x($n+$n-$m));\n\tprint \"\\n\"\n\t}\n\t\n"}], "negative_code": [{"source_code": "\nwhile(<>){\n\t\n\t($n,$m)=split/ /;\n\tchomp$m;\n\tprint \"$n $m  \";\n\t$_='';\n\tif ($n>$m+1){print \"-1\\n\"; next}\n\tif ($m>$n*2+2){print \"-1\\n\"; next}\n\tif ($n==$m+1){print ('0'.('10'x --$n)); print \"\\n\"; next}\n\twhile ($m>$n*2){$m--; $_.=\"1\"}\n\tprint;\n\tprint ('011'x($m-$n),'01'x($n+$n-$m));\n\tprint \"\\n\"\n\t}\n\t\n"}], "src_uid": "854c561539596722b1dbc8f99cbdca78"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\n# send argument as array, not reference, to function requiring list\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy $answer = 'NO';\n\nmy $lines = [];\n\nfor (1..$n) {\n    my $line = read_line;\n    my ($left, $right) = split q/\\|/, $line;\n    $left = '++', $answer = 'YES' if $answer eq 'NO' and $left eq 'OO';\n    $right = '++', $answer = 'YES' if $answer eq 'NO' and $right eq 'OO';\n    push @$lines, join q{|}, ($left, $right);\n}\n\nsay $answer;\n\nexit(0) if $answer eq 'NO';\n\nfor (@$lines) {\n    say $_;\n}\n", "positive_code": [{"source_code": "$sum = \"\";\nforeach $s (<STDIN>) {\n  if ($s =~ /\\|/) {\n    $sum = $sum . $s;\n  }\n}\nif ($sum =~ /OO/) {\n  print \"YES\\n\";\n  $sum =~ s/OO/\\+\\+/;\n  print $sum;\n} else {\n  print \"NO\\n\";\n}"}, {"source_code": "use warnings;\n#use FileHandle;\n\n#my $in = FileHandle->new(\"input.txt\", \"r\");\n#my $out = FileHandle->new(\"output.txt\", \"w\");\n\nsub solve {\n\tmy $in = shift;\n\tmy $out = shift;\n\tmy $n = <$in>;\n\tmy ($str, $str1, $str2, $yes); \n\tmy @mas;\n\t$yes = 0;\n\n\tfor my $i (0..$n - 1){\n\t\t$str = <$in>;\n\t\t$str1 = substr($str, 0, 2);\n\t\tif (($yes == 0) and ($str1 eq 'OO')){\n\t\t\t$yes = 1;\n\t\t\t$str1 = '++';\t\t\n\t\t}\n\t\t$str2 = substr($str, 3, 2);\n\t\tif (($yes == 0) and ($str2 eq 'OO')){\n\t\t\t$yes = 1;\n\t\t\t$str2 = '++';\t\t\n\t\t}\n\n\t\tpush(@mas, $str1 . '|' . $str2 . \"\\n\"); \n\t}\n\n\tif ($yes == 1){\n\t\tprint $out \"YES\\n\";\n\t} else {\n\t\tprint $out \"NO\\n\";\n\t\treturn 1;\n\t}\n\n\tfor (@mas){\n\t\tprint $out $_;\n\t}\n\treturn 1;\n}\n\nsolve(STDIN, STDOUT);\n\n1;\n"}, {"source_code": "use 5.020;\nuse warnings;\n<>;\nundef $/;\n$_ = <>;\nif (s/OO/++/) {\n  say 'YES';\n  say;\n}\nelse { say 'NO' }\n"}, {"source_code": "my $n = <>;\nmy @pairs;\nfor (1..$n) {\n    my $line = <>;\n    chomp $line;\n    push @pairs, [split /\\|/, $line];\n}\nmy $ok = 0;\n\nOUTER: for my $pair (@pairs) {\n    for my $seats (@$pair) {\n        if ($seats eq 'OO') {\n            $seats = '++';\n            $ok = 1;\n            last OUTER;\n        }\n    }\n}\n\nif (!$ok) {\n    print \"NO\\n\";\n    exit;\n}\n\nprint \"YES\\n\";\n$, = \"\\n\";\n$\\ = \"\\n\";\nprint map { join \"|\", @$_ } @pairs;\n"}, {"source_code": "use strict;\nuse warnings;\n\nuse Data::Dumper;\n\nmy $in = <>;\nchomp $in;\n\nmy $n = $in;\ndie('invalid size') unless $n>=1 and $n<=1000;\nmy $bus = [];\nforeach my $row (0..$in-1) {\n  $in = <>;\n  chomp $in;\n  push(@$bus, $in);\n}\n\nmy $can_sit_together = find_seats($bus);\nif ($can_sit_together) {\n  print \"YES\\n\";\n  print_bus($bus);\n} else {\n  print \"NO\\n\";\n}\n\nsub find_seats {\n  my $bus = shift;\n  foreach my $bus_row (@$bus) {\n    my @row = split(//, $bus_row);\n    if ($row[0] eq 'O' and $row[1] eq 'O') {\n      $row[0] = $row[1] = '+';\n      $bus_row = join('', @row);\n      return 1;\n    } elsif ($row[3] eq 'O' and $row[4] eq 'O') {\n      $row[3] = $row[4] = '+';\n      $bus_row = join('', @row);\n      return 1;\n    }\n  }\n  return 0;\n}\n\nsub print_bus {\n  my $bus = shift;\n  foreach my $row (@$bus) {\n    print \"$row\\n\";\n  }\n}\n\n"}, {"source_code": "use 5.020;\nuse warnings;\n<>;\nundef $/;\n$_ = <>;\nif (s/OO/++/) {\n  say 'YES';\n  say;\n}\nelse { say 'NO' }\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\nuse Carp;\n\n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n\nsub toggle {\n    my $ref = shift;\n    croak '$ref does not reference to scalar' if !ref_ref_scalar($ref);\n\n    $$ref = !$$ref;\n}\n\n# solve\n\n\nmy $n = read_token;\n\nmy $answer = 0;\n\nmy $lines = [];\n\nfor (1..$n) {\n    my $line = read_line;\n    my ($left, $right) = split q/\\|/, $line;\n    $left = '++', toggle(\\$answer) if !$answer and $left eq 'OO';\n    $right = '++', toggle(\\$answer) if !$answer and $right eq 'OO';\n    push @$lines, join q{|}, ($left, $right);\n}\n\nsay 'NO' and exit(0) if !$answer;\n\nsay 'YES';\nfor (@$lines) {\n    say $_;\n}\n"}, {"source_code": "<>;\n$/ = $\\; $_ = <>;\nprint s/OO/++/ ? \"YES\\n$_\" : \"NO\""}, {"source_code": "use strict;\n# cf711a # solution courtesy 20253198 rsFalse\n<>;\n$/='';\n$_ = <>;\nprint s/OO/++/ ? \"YES\\n$_\" : \"NO\";\n"}, {"source_code": "use strict;\n\n# cf711a\n=item\n\nA. Bus to Udayland\ntime limit per test\n2 seconds\nmemory limit per test\n256 megabytes\ninput\nstandard input\noutput\nstandard output\n\nZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occupied.\n\nZS and Chris are good friends. They insist to get a pair of neighbouring empty seats. Two seats are considered neighbouring if they are in the same row and in the same pair. Given the configuration of the bus, can you help ZS and Chris determine where they should sit?\nInput\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of rows of seats in the bus.\n\nThen, n lines follow. Each line contains exactly 5 characters, the first two of them denote the first pair of seats in the row, the third character denotes the walkway (it always equals '|') and the last two of them denote the second pair of seats in the row.\n\nEach character, except the walkway, equals to 'O' or to 'X'. 'O' denotes an empty seat, 'X' denotes an occupied seat. See the sample cases for more details.\nOutput\n\nIf it is possible for Chris and ZS to sit at neighbouring empty seats, print \"YES\" (without quotes) in the first line. In the next n lines print the bus configuration, where the characters in the pair of seats for Chris and ZS is changed with characters '+'. Thus the configuration should differ from the input one by exactly two charaters (they should be equal to 'O' in the input and to '+' in the output).\n\nIf there is no pair of seats for Chris and ZS, print \"NO\" (without quotes) in a single line.\n\nIf there are multiple solutions, you may print any of them.\nExamples\nInput\n\n6\nOO|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n\nOutput\n\nYES\n++|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n\nInput\n\n4\nXO|OX\nXO|XX\nOX|OX\nXX|OX\n\nOutput\n\nNO\n\nInput\n\n5\nXX|XX\nXX|XX\nXO|OX\nXO|OO\nOX|XO\nOutput\nYES\nXX|XX\nXX|XX\nXO|OX\nXO|++\nOX|XO\nNote\nNote that the following is an incorrect configuration for the first sample case because the seats must be in the same pair.\nO+|+X\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n=cut\n\nmy $n=<>;\nmy @ls=<>;\n\nmy @rs;\nmy $qFound=0;\nforeach my $l (@ls) {\n  chomp $l;\n  my @vs=split('',$l);\n  if((!$qFound) && ($vs[0] eq 'O') && ($vs[1] eq 'O')) {\n    $vs[0]=$vs[1]='+';\n    $qFound=1;\n  }\n  if((!$qFound) && ($vs[3] eq 'O') && ($vs[4] eq 'O')) {\n    $vs[3]=$vs[4]='+';\n    $qFound=1;\n  }\n  push @rs,join('',@vs);\n}\nif($qFound) {\n  print \"YES\\n\";\n  foreach my $r (@rs) {\n    print $r,\"\\n\";\n  }\n} else {\n  print \"NO\\n\";\n}\n"}], "negative_code": [{"source_code": "$sum = \"\";\nforeach $s (<STDIN>) {\n  if ($s =~ /\\|/) {\n    $sum = $sum . $s;\n  }\n}\n$sum =~ s/OO/\\+\\+/;\nprint $sum;\n"}, {"source_code": "use strict;\nuse warnings;\n\nuse Data::Dumper;\n\n# rows 10\n# per row: 2x2\n# find to seats next to each other...\n\n\nmy $n = <>;\nchomp($n);\n\ndie('wrong number or rows') unless $n >=0 && $n <= 100;\n\n# store input as array with length n * 2\n# loop array, find first seat with OO.\n# found: change 00 to ++\n# exit and print result\n\nmy @buss;\nmy @left;\nmy @right;\nfor (0..$n-1) {\n    my $in = <>;\n    chomp($in);\n    my @seats = split('\\|', $in);\n#    print Dumper \\@seats;\n    push @left, $seats[0];\n    push @right, $seats[1];\n}\n@buss = (@left, @right);\n\nfor (@buss) {\n    if ($_ eq 'OO') {\n        print \"YES\\n\";\n        print_bus(\\@buss, $n);\n        exit;\n    }\n}\nprint \"NO\\n\";\n\n\nsub print_bus {\n    my ($buss, $n) = @_;\n\n    for (my $i=0; $i<$n; $i++) {\n        my $row = $buss->[$i] . '|' . $buss->[$n + $i];\n        print $row . \"\\n\";\n    }\n}\n\n"}, {"source_code": "use 5.020;\nuse warnings;\nundef $/;\n$_ = <>;\nif (s/OO/++/) {\n  say 'YES';\n  say;\n}\nelse { say 'NO' }\n"}, {"source_code": "use strict;\n\n# cf711a\n=item\n\nA. Bus to Udayland\ntime limit per test\n2 seconds\nmemory limit per test\n256 megabytes\ninput\nstandard input\noutput\nstandard output\n\nZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occupied.\n\nZS and Chris are good friends. They insist to get a pair of neighbouring empty seats. Two seats are considered neighbouring if they are in the same row and in the same pair. Given the configuration of the bus, can you help ZS and Chris determine where they should sit?\nInput\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of rows of seats in the bus.\n\nThen, n lines follow. Each line contains exactly 5 characters, the first two of them denote the first pair of seats in the row, the third character denotes the walkway (it always equals '|') and the last two of them denote the second pair of seats in the row.\n\nEach character, except the walkway, equals to 'O' or to 'X'. 'O' denotes an empty seat, 'X' denotes an occupied seat. See the sample cases for more details.\nOutput\n\nIf it is possible for Chris and ZS to sit at neighbouring empty seats, print \"YES\" (without quotes) in the first line. In the next n lines print the bus configuration, where the characters in the pair of seats for Chris and ZS is changed with characters '+'. Thus the configuration should differ from the input one by exactly two charaters (they should be equal to 'O' in the input and to '+' in the output).\n\nIf there is no pair of seats for Chris and ZS, print \"NO\" (without quotes) in a single line.\n\nIf there are multiple solutions, you may print any of them.\nExamples\nInput\n\n6\nOO|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n\nOutput\n\nYES\n++|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n\nInput\n\n4\nXO|OX\nXO|XX\nOX|OX\nXX|OX\n\nOutput\n\nNO\n\nInput\n\n5\nXX|XX\nXX|XX\nXO|OX\nXO|OO\nOX|XO\nOutput\nYES\nXX|XX\nXX|XX\nXO|OX\nXO|++\nOX|XO\nNote\nNote that the following is an incorrect configuration for the first sample case because the seats must be in the same pair.\nO+|+X\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n=cut\n\nmy $n=<>;\nmy @ls=<>;\n\nmy @rs;\nmy $qFound=0;\nforeach my $l (@ls) {\n  chomp $l;\n  my @vs=split('',$l);\n  if((!$qFound) && ($vs[0] eq 'O') && ($vs[1] eq 'O')) {\n    $vs[0]=$vs[1]='+';\n    $qFound=1;\n  }\n  if((!$qFound) && ($vs[3] eq 'O') && ($vs[4] eq 'O')) {\n    $vs[3]=$vs[4]='+';\n    $qFound=1;\n  }\n  push @rs,join('',@vs);\n}\nprint ($qFound ? \"YES\" : \"NO\");\nprint \"\\n\";\nforeach my $r (@rs) {\n  print $r,\"\\n\";\n}"}, {"source_code": "use strict;\n\n# cf711a\n=item\n\nA. Bus to Udayland\ntime limit per test\n2 seconds\nmemory limit per test\n256 megabytes\ninput\nstandard input\noutput\nstandard output\n\nZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occupied.\n\nZS and Chris are good friends. They insist to get a pair of neighbouring empty seats. Two seats are considered neighbouring if they are in the same row and in the same pair. Given the configuration of the bus, can you help ZS and Chris determine where they should sit?\nInput\n\nThe first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of rows of seats in the bus.\n\nThen, n lines follow. Each line contains exactly 5 characters, the first two of them denote the first pair of seats in the row, the third character denotes the walkway (it always equals '|') and the last two of them denote the second pair of seats in the row.\n\nEach character, except the walkway, equals to 'O' or to 'X'. 'O' denotes an empty seat, 'X' denotes an occupied seat. See the sample cases for more details.\nOutput\n\nIf it is possible for Chris and ZS to sit at neighbouring empty seats, print \"YES\" (without quotes) in the first line. In the next n lines print the bus configuration, where the characters in the pair of seats for Chris and ZS is changed with characters '+'. Thus the configuration should differ from the input one by exactly two charaters (they should be equal to 'O' in the input and to '+' in the output).\n\nIf there is no pair of seats for Chris and ZS, print \"NO\" (without quotes) in a single line.\n\nIf there are multiple solutions, you may print any of them.\nExamples\nInput\n\n6\nOO|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n\nOutput\n\nYES\n++|OX\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n\nInput\n\n4\nXO|OX\nXO|XX\nOX|OX\nXX|OX\n\nOutput\n\nNO\n\nInput\n\n5\nXX|XX\nXX|XX\nXO|OX\nXO|OO\nOX|XO\nOutput\nYES\nXX|XX\nXX|XX\nXO|OX\nXO|++\nOX|XO\nNote\nNote that the following is an incorrect configuration for the first sample case because the seats must be in the same pair.\nO+|+X\nXO|XX\nOX|OO\nXX|OX\nOO|OO\nOO|XX\n=cut\n\nmy $n=<>;\nmy @ls=<>;\n\nmy @rs;\nmy $qFound=0;\nforeach my $l (@ls) {\n  chomp $l;\n  my @vs=split('',$l);\n  if((!$qFound) && ($vs[0] eq 'O') && ($vs[1] eq 'O')) {\n    $vs[0]=$vs[1]='X';\n    $qFound=1;\n  }\n  if((!$qFound) && ($vs[3] eq 'O') && ($vs[4] eq 'O')) {\n    $vs[3]=$vs[4]='X';\n    $qFound=1;\n  }\n  push @rs,join('',@vs);\n}\nprint ($qFound ? \"YES\" : \"NO\");\nprint \"\\n\";\nforeach my $r (@rs) {\n  print $r,\"\\n\";\n}"}], "src_uid": "e77787168e1c87b653ce1f762888ac57"}
{"source_code": "$,=\" \";\nmy $n=<>;\nchomp($n);\n$_=<>;\nchomp;\nmy @A=sort {$a <=> $b } split / /;\nif($n%2==0)\n{\nprint $A[int($n/2)-1] , \"\\n\";\n}\nelse\n{\nprint $A[int($n/2)] , \"\\n\";\n}\n", "positive_code": [{"source_code": "$/ = \"\"; $_ = <>; ($n, @x) = split;\n\n@x = sort { $a<=>$b } @x;\n\nfor ($i=0; $i<$n; $i++) {\n\t$a[$i] = $s1 += $x[-1] - $x[$i];\n\t$b[$i] = $s2 += $x[$i] - $x[0];\n}\n\n$x=$x[0]; $min=$b[-1];\nfor ($i=1; $i<$n-1; $i++) {\n\t$s1 = $a[$i-1] - ($x[-1] - $x[$i]) * $i;\n\t$s2 = $b[-1] - $b[$i] - ($x[$i] - $x[0]) * ($n-$i-1);\n\t$s = $s1 + $s2;\n\tif ($s < $min) {\n\t\t$min = $s;\n\t\t$x = $x[$i];\n\t}\n}\n\nprint $x;\n"}], "negative_code": [{"source_code": "$/ = \"\"; $_ = <>; ($n, @x) = split;\n$sum += $_ for @x; $med = $sum/$n;\n@y = sort {\n\tabs($a - $med) <=> abs($b - $med) || $a <=> $b\n} @x;\nprint $y[0]"}], "src_uid": "fa9cc3ba103ed1f940c9e80a7ea75f72"}
{"source_code": "#!/usr/bin/perl\nuse warnings;\nuse strict;\n\nchomp(my $n = <STDIN>);\nmy @scores = split / /,<STDIN>;\n\nmy $min = $scores[0];\nmy $max = $scores[0];\nmy $count = 0;\nforeach my $score (@scores) {\n    if($score > $max){\n        $max = $score;\n        $count++;\n    } elsif($score <$min){\n        $min = $score;\n        $count++;\n    }\n}\nprint $count;", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\n<>;\nmy @a = split ' ', <>;\nmy $max = shift @a;\nmy $min = $max;\nmy $amaze = 0;\n\nfor (@a) {\n    if ($_ > $max) {\n        $amaze++;\n        $max = $_;\n    } elsif ($_ < $min) {\n        $amaze++;\n        $min = $_;\n    }\n}\n\nprint $amaze, \"\\n\";\n"}, {"source_code": "$n=<>;\n@array=split(' ',<>);\n$maxi=$array[0];\n$mini=$array[0];\n$score=0;\nfor($i=1;$i<$n;$i++){\nif($array[$i]>$maxi){\n$maxi=$array[$i];\n$score++;\n}\nelsif($array[$i]<$mini){\n$mini=$array[$i];\n$score++;\n}\n}\nprint $score;"}, {"source_code": "<>; $m = -1, $n = 9 ** 6;\n@a = split(' ', <>);\n\nforeach(@a){\n\t$s += ($_ > $m or $_ < $n) ? 1 : 0;\n\t$m = $_ > $m ? $_ : $m;\n\t$n = $_ < $n ? $_ : $n;}\nprint $s - 1;\n\n"}, {"source_code": "my $n = int<>;\nmy ($min, $max, $ans) = (10001, -1, 0);\n\nforeach(split / /, <>) {\n    if ($_ < $min) {\n        $ans++;\n        $min = $_;\n    }\n    if ($_ > $max) {\n        $ans++;\n        $max = $_;\n    }\n}\nprint $ans - 2 . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\n($mn, $mx) = (10x5, -10x5);\nforeach (split / /, <>) {\n\t($_<$mn || $_>$mx) and $ans++;\n\t$mn = $_<$mn ? $_:$mn;\n\t$mx = $_>$mx ? $_:$mx;\n}\nsay $ans-1;"}, {"source_code": "#!perl\n\n$n = <>;\n@arr = split /\\D/, <>;\n$result = 0;\n$min = $max = $arr[0];\nfor $i (1..$n-1) {\n\tif ($arr[$i] > $max) {\n\t\t$max = $arr[$i];\n\t\t$result++;\n\t} elsif ($arr[$i] < $min) {\n\t\t$min = $arr[$i];\n\t\t$result++;\n\t}\n}\nprint $result;\n\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\nchomp ($_ = <>);\n\nmy @arr = split / /;\nsub find($) { \n    my $val = $arr[ $_[0] ];\n\n    my ($c1, $c2) = (0,0);\n\n    return 0 if (!$_[0]);\n\n    for (0..$n-1)\n    {\n        last if ($_ eq $_[0]);\n\n        $c1++ if ($arr[$_] > $val);\n        $c2++ if ($arr[$_] < $val);\n    }\n\n    return (($c1 eq $_[0]) or ($c2 eq $_[0]));\n}\n\n$/ = 0;\nfor(0..$n-1)\n{\n    $/++ if (find($_));\n}\n\nprint \"$/\\n\";"}, {"source_code": "$line = <>;\n$line = <>;\nchomp $line;\nmy $max, $min;\n$ans = 0;\nforeach my $num (split(/ /, $line)) {\n    if (!defined($max)) {\n        $max = $num;\n        $min = $num;\n    }\n    if ($num > $max) {\n        $ans++;\n        $max = $num;\n    }\n    if ($num < $min) {\n        $ans++;\n        $min = $num;\n    }\n}\nprint \"$ans\\n\";\n"}, {"source_code": "<>;\nmy @score = grep /\\w/, split ' ', <>;\nmy $count = 0;\nmy ($max, $min) = (0, 0);\nforeach (1..$#score) {\n    if ($score[$_] > $score[$max]) {\n        $count++;\n        $max = $_;\n    } elsif ($score[$_] < $score[$min]) {\n        $count++;\n        $min = $_;\n    }\n}\nprint $count;"}], "negative_code": [{"source_code": "#!perl\n\n$n = <>;\n@arr = <>;\n$result = 0;\n$max = $min = $arr[0];\nfor $i (1..$n-1) {\n\tif ($arr[$i] > $max) {\n\t\t$max = $arr[$i];\n\t\t$result++;\n\t} elsif ($arr[$i] < $min) {\n\t\t$min = $arr[$i];\n\t\t$result++;\n\t}\n}\nprint $result;\n\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $n = <>);\nchomp ($_ = <>);\n\nmy @arr = split / /;\nsub find($) { \n    my $val = $arr[ $_[0] ];\n\n    my ($c1, $c2) = (0,0);\n\n    return 0 if (!$_[0]);\n\n    for (0..$n-1)\n    {\n        last if ($_ eq $_[0]);\n\n        $c1++ if ($arr[$_] > $val);\n        $c2++ if ($arr[$_] < $val);\n    }\n\n    return (($c1 eq $_[0]) or ($c2 eq $_[0]));\n}\n\n\nfor(0..$n-1)\n{\n    $/++ if (find($_));\n}\n\nprint \"$/\\n\";"}, {"source_code": "<>;\nmy @score = grep /\\w/, split ' ', <>;\nmy $count;\nmy ($max, $min) = (0, 0);\nforeach (1..$#score) {\n    if ($score[$_] > $score[$max]) {\n        $count++;\n        $max = $_;\n    } elsif ($score[$_] < $score[$min]) {\n        $count++;\n        $min = $_;\n    }\n}\nprint $count;"}], "src_uid": "a61b96d4913b419f5715a53916c1ae93"}
{"source_code": "\tuse integer;\n\twhile(<>){\n\t\tchomp;\n\t\tundef %h;\n\t\t($n,$p)=split/ /;\n\t\t$p--;\n\t\t$_=<>, chomp;\n\t\t$sz = @_ = split//;\n\t\t$ans = 0;\n\t\t@a = ();\n\t\t\n\t\tfor $i(0..@_/2-(@_ % 2 == 0)){\n\t\t\tif ($_[$i] ne $_[$sz - $i -1]){\n\t\t\t\t$a=$_[$i];\n\t\t\t\t$b=$_[$sz - $i -1];\n\t\t\t\t$a[$i]=1;\n\t\t\t\t$c = abs ((ord $a) - ord $b);\n\t\t\t\t26 - $c < $c and $c = 26 - $c;\n\t\t\t\t$ans += $c;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\tif (!@a){\n\t\t\tprint 0;\n\t\t\tnext;\n\t\t\t}\n\t\t$p2 = $sz - $p -1;\n\t\t$p2 < $p and $p = $p2;\n\t\t$j=0;\n\t\tfor $i(0..@_/2-(@_ % 2 == 0)){\n\t\t\tif ($a[$i]){$j or $st = $i; $j++; $fn = $i}\n\t\t\t}\n\t\t$diff = $fn-$st;\n\t\t$min = abs ($st - $p);\n\t\t$min >  abs ($fn - $p) and \t$min =  abs ($fn - $p);\n\t\t$p > $st and $p < $fn and $diff += $min;\n\t\t$p <= $st and $diff += $st - $p;\n\t\t$p >= $fn and $diff += $p - $fn;\n\t\tprint $ans += $diff ,$/\n\t\t}", "positive_code": [{"source_code": "\tuse integer;\n\tlocal $SIG{__WARN__} = sub { $w = shift };\n\t\n\twhile(<>){\n\t\tchomp;\n\t\tundef %h;\n\t\t($n,$p)=split/ /;\n\t\t$p--;\n\t\t$_=<>, chomp;\n\t\t$sz = @_ = split//;\n\t\t$ans = 0;\n\t\t@a = ();\n\t\t\n\t\tfor $i(0..@_/2-(@_ % 2 == 0)){\n\t\t\tif ($_[$i] ne $_[$sz - $i -1]){\n\t\t\t\t$a=$_[$i];\n\t\t\t\t$b=$_[$sz - $i -1];\n\t\t\t\t$a[$i]=1;\n\t#\t\t\t$a[$sz - $i -1]=1;\n\t#\t\t\tprint \"$a $b \";\n\t\t\t\t$c = abs ((ord $a) - ord $b);\n\t\t\t\t26 - $c < $c and $c = 26 - $c;\n#\t\t\t\tprint \" \", $c, $/;\n\t\t\t\t$ans += $c;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\tif (!@a){\n\t\t\tprint 0;\n\t\t\tnext;\n\t\t\t}\n\t\t$p2 = $sz - $p -1;\n\t\t$p2 < $p and $p = $p2;\n#\t\tprint \"p $p\",$/;\n\t\t$j=0;\n\t\tfor $i(0..@_/2-(@_ % 2 == 0)){\n\t#\t\tprint $i,$/;\n\t\t\tif ($a[$i]){$j or $st = $i; $j++; $fn = $i}\n\t\t\t}\n#\t\tprint \"$st $fn\",$/;\n\t\t$diff = $fn-$st;\n#\t\tprint $diff,$/;\n\t\t$min = abs ($st - $p);\n#\t\tprint $p,$min;\n\t\t$min >  abs ($fn - $p) and \t$min =  abs ($fn - $p);\n#\t\tprint $min;\n\t\t$p > $st and $p < $fn and $diff += $min;\n\t\t$p <= $st and $diff += $st - $p;\n\t\t$p >= $fn and $diff += $p - $fn;\n#\t\tprint \"diff: $diff\",$/;\n#\t\tprint \"ans: $ans\",$/;\n#\t\tprint \"@a\",$/;\n#\t\tprint $_,\" \";\n\t\tprint $ans += $diff ,$/\n\t\t}"}], "negative_code": [], "src_uid": "ebacd748147b50b20d39b4d8cfde39ec"}
{"source_code": "$|=1; ($p,@p)=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47); # 15\nwhile ($p) {\n\tprint \"$p\\n\";\n\t$a=<>; chomp($a);\n\tif ($a eq \"yes\") {\n\t\tif (++$c==2) {\n\t\t\tprint \"composite\\n\";\n\t\t\texit;\n\t\t}\n\t\tif ($p<10) {\n\t\t\t$p*=$p;\n\t\t\tnext;\n\t\t}\n\t}\n\t$p=shift(@p);\n}\nprint \"prime\\n\";\n\n", "positive_code": [{"source_code": "$\\ = $/;\n$|++;\n\nprint xor\n$e +=<>=~ /e/\nfor qw( \n2\n3\n5\n7\n11\n13\n17\n19\n23\n29\n31\n37\n41\n43\n47\n4\n9\n25\n49\n);\n\nprint 1 < $e ? 'composite' : 'prime'"}, {"source_code": "$| = 1; $\\ = $/;\n\nprint xor\n$e +=<>=~ /e/\nfor qw( 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 4 9 25 49 );\n\nprint 1 < $e ? 'composite' : 'prime'"}, {"source_code": "$\\ = $/;\n$| ++;\n\nfor my $i (qw( \n2\n3\n5\n7\n11\n13\n17\n19\n23\n29\n31\n37\n41\n43\n47\n4\n9\n25\n49\n) ) {\n\tprint $i;\n\tpush @_, scalar <>;\n\t}\n\nprint +(1 < grep /yes/, @_) ? 'composite' : 'prime'"}], "negative_code": [{"source_code": "$|=1; ($p,@p)=qw(2 3 5 7);\nwhile (@p) {\n\tprint \"$p\\n\";\n\t$a=<>; chomp($a);\n\tif ($a eq \"yes\") {\n\t\tif (++$c==2) {\n\t\t\tprint \"composite\\n\";\n\t\t\texit;\n\t\t}\n\t\t$p*=$p;\n\t} else {\n\t\t$p=shift(@p);\n\t}\n}\nprint \"prime\\n\";\n\n"}, {"source_code": "$|=1; ($p,@p)=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47);\nwhile (@p) {\n\tprint \"$p\\n\";\n\t$a=<>; chomp($a);\n\tif ($a eq \"yes\") {\n\t\tif (++$c==2) {\n\t\t\tprint \"composite\\n\";\n\t\t\texit;\n\t\t}\n\t\t$p*=$p;\n\t} else {\n\t\t$p=shift(@p);\n\t}\n}\nprint \"prime\\n\";\n\n"}, {"source_code": "$\\ = $/;\n$| ++;\n\nfor my $i (qw( \n2\n3\n5\n7\n11\n13\n17\n19\n23\n29\n31\n37\n41\n43\n47\n) ) {\n\tprint $i;\n\tpush @_, scalar <>;\n\t}\n\nprint +(1 < grep /yes/, @_) ? 'composite' : 'prime'"}], "src_uid": "8cf479fd47050ba96d21f3d8eb43c8f0"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n@dir = (\n\t[-1,0],\n\t[1,0],\n\t[0, -1],\n\t[0, 1],\n);\nchomp($n = <>);\npush @a, [split //, '*' x ($n+2)];\nforeach\t(1..$n) {\n\tchomp($line = <>);\n\tpush @a, [split //, '*' . $line . '*'];\n}\npush @a, [split //, '*' x ($n+2)];\nforeach $i (1..$n) {\n\tforeach $j (1..$n) {\n\t\t$c = 0;\n\t\t$c+=$a[$i+$dir[$_][0]][$j+$dir[$_][1]] eq 'o' ? 1:0 foreach(0..3);\n\t\t# say \"$i $j $c\";\n\t\t$c%2>0 and say \"NO\" and exit;\n\t}\n}\nsay \"YES\";", "positive_code": [{"source_code": "my $n = int<>;\nmy @arr = [split //, 0 x ($n+2)];\n($arr[$_]='0'.<>.'0') =~ tr/xo\\n/01/d for(1..$n);\n$arr[$_] = [split //,$arr[$_]] for(1..$n);\n# push @arr, [split //,0 x ($n+2)];\nmy $ans = \"YES\\n\";\nOuter:\nfor my $i(1..$n) {\n    for my $j(1..$n) {\n        if (($arr[$i - 1][$j] + $arr[$i + 1][$j] + $arr[$i][$j - 1] + $arr[$i][$j + 1]) % 2 != 0) {\n            $ans = \"NO\\n\";\n            last Outer;\n        }\n    }\n}\nprint $ans;\n"}], "negative_code": [], "src_uid": "03fcf7402397b94edd1d1837e429185d"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( @_, $t, $o ) = split ' ', <>;\r\n\t\r\n\tfor( @_ ){\r\n\t\t$_ /= 2, ++ $t until $_ % 2;\r\n\t\t}\r\n\t\r\n\tmy @i = 1 .. @_;\r\n\t\r\n\tfor( @i ){\r\n\t\t$c = 0;\r\n\t\t$_ /= 2, ++ $c until $_ % 2;\r\n\t\t$_ = $c;\r\n\t\t}\r\n\t\r\n\t@i = sort { $b <=> $a } grep $_, @i;\r\n\t\r\n\t$t += shift @i while $t < @_ and @i && ++ $o;\r\n\t\r\n\tprint $t >= @_ ? 0 + $o : -1\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $twos = 0;\n\t\n\tfor( @_ ){\n\t\t$_ /= 2, ++ $twos while $_ % 2 == 0;\n\t\t}\n\t\n\tmy @idxs = 1 .. @_;\n\t\n\tfor( @idxs ){\n\t\tmy $cnt = 0;\n\t\t$_ /= 2, ++ $cnt while $_ % 2 == 0;\n\t\t$_ = $cnt;\n\t\t}\n\t\n\t@idxs = sort { $b <=> $a } grep $_, @idxs;\n\t\n\tmy $ops = 0;\n\t\n\twhile( $twos < @_ and @idxs ){\n\t\t$twos += shift @idxs;\n\t\t$ops ++;\n\t\t}\n\t\n\tprint $twos >= @_ ? $ops : -1;\n\t}"}], "negative_code": [], "src_uid": "96f0df1c8e014229e5ef773789aa2205"}
{"source_code": "while(<>){\n\tchomp;\n\t($n,$k)=split/ /;\n\t@_=sort {$a<=>$b} split/ /,<>;\n\t$ans=0;\n\twhile (@_){\n\t\t$e=pop @_;\n\t\tfor $i(1..$k-1){\n\t\t\tpop @_\n\t\t\t}\n\t\t$ans += $e*2-2\n\t\t}\n\tprint \"$ans\\n\"\n\t}", "positive_code": [{"source_code": "my ($n, $k) = split ' ', <>;\nmy @arr = sort { $a <=> $b } split (' ', <>);\nmy ($ans, $i) = (0,$n-1);\n\nwhile($i >= 0){\n    $ans += 2*($arr[$i]-1);\n    $i -= $k;\n}\nprint $ans;\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($n, $k) = split / /, <>;\n@a = sort {$b <=> $a} split / /, <>;\nfor ($i=0; $i<$n; $i+=$k) {\n\t$ans += ($a[$i]-1) * 2;\n}\nsay $ans;"}, {"source_code": "use List::Util qw(first max maxstr min minstr reduce shuffle sum);\nchomp (my ($n, $k) = split /\\s+/, <>);\nchomp (my @targets = sort {$b <=> $a} split /\\s+/, <>);\n\nmy $cnt = 0;\nwhile (scalar @targets) {\n    $cnt += ((&max(splice(@targets, 0, $k))) - 1) << 1;\n}\nprintf \"$cnt\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy ($n, $k) = split ' ', <>;\nmy @arr = sort { $a <=> $b } split (' ', <>);\nmy ($res, $idx) = (0,$n-1);\n\nwhile($idx >= 0){\n    $res += 2*($arr[$idx]-1);\n    $idx -= $k;\n}\nprint $res;\n\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy ($n, $k) = split ' ', <>;\nmy @arr = sort { $b <=> $a } split (' ', <>);\nmy ($res, $idx) = (0,0);\n\nwhile($idx < $n){\n    $res += 2*($arr[$idx]-1);\n    $idx += $k;\n}\nprint $res;\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy ($n, $k) = split ' ', <>;\nmy @arr = sort { $b <=> $a } split (' ', <>);\nmy ($res, $idx) = (0,$n-1);\nwhile($idx >= 0){\n    $res += 2*($arr[$idx]-1);\n    $idx -= $k;\n}\nprint $res;\n\n"}], "src_uid": "b8d8f0e86ecb600f7559a6aec629946e"}
{"source_code": "($n, $k) = split(/ /, <>);\n@b = @a = split(/ /, <>);\n$ch = 0;\nfor($i=0;$i<$n-1;$i++)\n{\n\tif($b[$i] + $b[$i+1] < $k)\n\t{\n\t\t$b[$i+1] = $k - $b[$i];\n\t}\n}\nfor($i=0;$i<$n;$i++)\n{\n\t$ch += $b[$i] - $a[$i];\n}\nprint(\"$ch\\n@b\\n\");", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $k) = split;\n\t@_ = ($k, (split ' ', <>), $k);\n\t$sum = 0;\n\t\n\tfor $i (0 .. @_ - 2){\n\t\t$two = $_[$i] + $_[$i+1];\n\t\t$diff = $k - $two;\n\t\t$diff < 1 and next;\n\t\t$_[$i+1] += $diff;\n\t\t$sum += $diff;\n\t\t\n\t\t}\n\t\n\tprint $sum;\n\tprint \"@_[1 .. @_-2]\";\n\t}"}, {"source_code": "($k, $_) = (<> =~ /\\d+$/g, <>);\n\nNOP while s/\\b(\\d+) \\K(\\d+)\\b(??{ 'F' x ($1 + $2 >= $k) })/ \n\t\t\t$sum += $k - $1 - $2, $k - $1 \n\t\t/e;\n\nprint 0 + $sum . \"\\n$_\""}], "negative_code": [], "src_uid": "1956e31a9694b4fd7690f1a75028b9a1"}
{"source_code": "($n, $k, $q, @t) = split ' ', <>.<>;\n\nprint join \"\\n\", grep !/-/, map {\n\t($_, $id) = split;\n\tif (/2/){ ! $h[$id] || $m6[$k-1] > $t[$id-1] ? 'NO' : 'YES' }\n\telse {\n\t\t$h[$id] -= @m6 = (sort {$b <=> $a} @m6, $t[$id-1])[0 .. $k-1]\n\t\t}\n\t} map ~~<>, 1 .. $q", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $k, $q) = split;\n\t@t = split ' ', <>;\n\t@max6 = ();\n\t%h = ();\n\tfor (map ~~<>, 1 .. $q){\n\t\t($_, $id) = split;\n\t\tif (/2/){ print ! exists $h{$id} || $max6[$k-1] > $t[$id-1] ? 'NO' : 'YES' }\n\t\telse {\n\t\t\t@max6 = map {0 + $_} (sort {$b <=> $a} @max6, $t[$id-1])[0 .. $k-1];\n\t\t\tundef $h{$id};\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "7c778289806ceed506543ef816c587c9"}
{"source_code": "use POSIX qw(mktime);\n\nmy $line = <STDIN>;\nchomp $line;\n\n$line =~ /^(\\d+)\\s+(\\d+)/;\nmy ($n, $m) = ($1, $2);\n\nmy @on;\nmy $cur = 0;\nmy $curts;\n\nuse Data::Dumper;\n\nwhile (<STDIN>) {\n    chomp;\n    /^(2012)-(\\d{2})-(\\d{2}) (\\d{2}):(\\d{2}):(\\d{2}):/;\n    $curts = mktime($6, $5, $4, $3, $2-1, $1-1900);\n    push(@on, $curts+$n);\n    $cur++;\n    while (scalar @on > 0 && $on[0] <= $curts) {\n        $cur--;\n        shift @on;\n    }\n\n    if ($cur >= $m) {\n        print \"$1-$2-$3 $4:$5:$6\\n\";\n        exit;\n    }\n}\n\nprint \"-1\\n\";\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy @d = (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\n\nsub gao {\n    $_ = shift;\n    my ($month, $day, $hour, $minute, $second) =\n        /^\\d+-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)/;\n    my ($f) = /^([\\d-]* [\\d:]*):/;\n    my $time = $day - 1;\n    $time += $d[$_] for (1 .. $month - 1);\n    $time = $time * 24 + $hour;\n    $time = $time * 60 + $minute;\n    $time = $time * 60 + $second;\n    return ($time, $f);\n}\n\nchomp($_ = <>);\nmy ($n, $m) = split;\nmy @a = ();\nmy @b = ();\nfor (<>) {\n    my ($a, $b) = gao($_);\n    push @a, $a;\n    push @b, $b;\n}\nfor (my ($i, $j) = (0, 0); $j < @a; ++$j) {\n    for (; $i < $j && $a[$j] - $a[$i] >= $n; ++$i) {\n        1;\n    }\n    if ($j - $i + 1 >= $m) {\n        print $b[$j], \"\\n\";\n        exit 0;\n    }\n}\nprint \"-1\\n\";\n"}], "negative_code": [], "src_uid": "c3f671243f0aef7b78a7e091b0e8f75e"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\tfor (1 .. $n){\n\t\t($name, $region, $pts) = split ' ', <>;\n\t\t$h{$region}{$name} = $pts;\n\t\t}\n\tfor $i (sort {$a <=> $b} keys %h){\n\t\t@values = sort {$b <=> $a} values %{ $h{$i} };\n\t\tprint do { \n\t\t\t\tif ($values[1] eq $values[2]){\n\t\t\t\t\t'?'\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t@keys = sort {$h{$i}{$b} <=> $h{$i}{$a}} keys %{ $h{$i} };\n\t\t\t\t\tjoin ' ', @keys[0 .. 1];\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}", "positive_code": [{"source_code": "$\\ = $/; <>;\n\nfor (<>){\n\t($N, $R, $P) = split;\n\t$h[$R]{$N} = $P;\n\t}\n\t\nshift @h;\nfor (@h){\n\t@V = sort {$_->{$b} <=> $_->{$a}} keys %{ $_ };\n\tprint $_->{ $V[1] } eq $_->{ $V[2] } ? \n\t\t\t'?'\n\t\t:\n\t\t\tjoin ' ', @V[0 .. 1]\n\t}\n"}, {"source_code": "$\\ = $/; <>;\n\nfor (<>){\n\t($N, $R, $P) = split;\n\t$h[$R]{$N} = $P;\n\t}\n\t\nshift @h;\nfor (@h){\n\t@V = sort {$_->{$b} <=> $_->{$a}} keys %{ $_ };\n\tprint $_->{ $V[1] } eq $_->{ $V[2] } ? \n\t\t\t'?'\n\t\t:\n\t\t\tjoin ' ', @V[0 .. 1]\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\tfor (1 .. $n){\n\t\t($name, $region, $pts) = split ' ', <>;\n\t\t$h{$region}{$name} = $pts;\n\t\t}\n\tfor $i (keys %h){\n\t\t@values = sort {$b <=> $a} values %{ $h{$i} };\n\t\tprint do { \n\t\t\t\tif (@values < 2 || $values[1] == $values[2]){\n\t\t\t\t\t'?'\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t@keys = sort {$h{$i}{$b} <=> $h{$i}{$a}} keys %{ $h{$i} };\n\t\t\t\t\tjoin ' ', @keys[0 .. 1];\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $m) = split;\n\tfor (1 .. $n){\n\t\t($name, $region, $pts) = split ' ', <>;\n\t\t$h{$region}{$name} = $pts;\n\t\t}\n\tfor $i (sort {$a <=> $b} keys %h){\n\t\t@values = sort {$b <=> $a} values %{ $h{$i} };\n\t\tprint do { \n\t\t\t\tif (@values < 2 || $values[1] == $values[2]){\n\t\t\t\t\t'?'\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t@keys = sort {$h{$i}{$b} <=> $h{$i}{$a}} keys %{ $h{$i} };\n\t\t\t\t\tjoin ' ', @keys[0 .. 1];\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}"}], "src_uid": "a1ea9eb8db25289958a6f730c555362f"}
{"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp; <>;\n\t@a = sort {$a <=> $b} split \" \", <>;\n\t@A = ();\n\t$a[ $_ ] == $a[ $_+1 ] and $a[ $_ ] = $a[ $_+1 ] = -1 for 0 .. @a - 2;\n\t$_ > -1 and push @A, $_ for @a;\n\t@a = @A;\n\t@b = (0) x ((length) / 2);\n\t$j = 0;\n\tfor $i (0 .. @b-1){\t\n\t\t$i == $a[ 0 ]-1 and do {\n\t\t\t++$j;\n\t\t\tshift @a if @a;\n\t\t\t};\n\t\t$b[ $i ] = $j % 2;\n\t\t}\n\tfor $i (0 .. @b-1){\n\t\t$b[ $i ] and do {\n\t\t\t$r = substr $_, $i, 1;\n\t\t\tsubstr $_, $i, 1, (substr $_, (length)-$i-1, 1);\n\t\t\tsubstr $_, (length)-$i-1, 1, $r;\n\t\t\t}\n\t\t}\n\tprint\n\t}", "positive_code": [{"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp;\n\t<>;\n\t@a = split \" \", <>;\n\t@a = sort {$a <=> $b} @a;\n\t$a = \"@a\";\n#\t$a =~ s/(\\b\\d+\\b) \\1//g;\n#\t@a = split \" \", $a;\n\t@A = ();\n\tfor $i (0 .. @a-2){\n\t\t$a[ $i ] == $a[ $i+1 ] and do {$a[ $i ] = $a[ $i+1 ] = -1} ;\n\t\t}\n\t$_ > -1 and push @A, $_ for @a;\n\t@a = @A;\n\t@b = (0) x ((length) / 2);\n#\tprint \"@b\";\n#\tprint \"@a\";\n\t$j = 0;\n\tfor $i (0 .. @b-1){\n#\t\tprint \"($i == \".($a[0]-1).\")\";\n\t\t\n\t\t$i == $a[ 0 ]-1 and do {\n\t\t\t++$j;\n\t\t\tshift @a if @a;\n\t\t\t};\n#\t\t\tprint \"<$j>\";\n\t\t$b[ $i ] = $j % 2;\n#\t\t@a || last;\n\t\t}\n#\tprint \"[@b]\";\n#\tprint;\n\tfor $i (0 .. @b-1){\n\t\t$b[ $i ] and do {\n\t\t\t$r = substr $_, $i, 1;\n\t\t\tsubstr $_, $i, 1, (substr $_, (length)-$i-1, 1);\n\t\t\tsubstr $_, (length)-$i-1, 1, $r;\n\t\t\t};\n\t\t\n\t\t}\n\tprint \"$_\";\n\t}"}, {"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp; <>;\n\t@a = sort {$a <=> $b} split \" \", <>;\n\t@A = ();\n\t$a[ $_ ] == $a[ $_+1 ] and $a[ $_ ] = $a[ $_+1 ] = -1 for 0 .. @a - 2;\n\t$_ > -1 and push @A, $_ for @a;\n\t@a = @A;\n\t@b = (0) x ((length) / 2);\n\t$j = 0;\n\tfor $i (0 .. @b-1){\t\n\t\t$i == $a[ 0 ]-1 and do {\n\t\t\t++$j;\n\t\t\tshift @a if @a;\n\t\t\t};\n\t\t$b[ $i ] = $j % 2;\n\t\t}\n\tfor $i (0 .. @b-1){\n\t\t$b[ $i ] and do {\n\t\t\t$r = substr $_, $i, 1;\n\t\t\tsubstr $_, $i, 1, (substr $_, (length)-$i-1, 1);\n\t\t\tsubstr $_, (length)-$i-1, 1, $r;\n\t\t\t}\n\t\t}\n\tprint\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp;\n\t<>;\n\t@a = split \" \", <>;\n\t@a = sort {$a <=> $b} @a;\n\t$a = \"@a\";\n\t$a =~ s/(\\b\\d+\\b) \\1//g;\n\t@a = split \" \", $a;\n#\tfor $i (0 .. @a-2){\n#\t\t$a[ $i ] == $a[ $i+1 ] ? $i++ : do{ push @A, $a[ $i ] } ;\n#\t\t\n#\t\t}\n#\t@a = @A;\n\t@b = (0) x ((length) / 2);\n#\tprint \"@b\";\n#\tprint \"@a\";\n\t$f = 0;\n\tfor $i (0 .. @b-1){\n#\t\tprint \"($i == \".($a[0]-1).\")\";\n\t\t@a || last;\n\t\t$i == $a[ 0 ]-1 and do {\n\t\t\t++$j;\n\t\t\t\n\t\t\tshift @a;\n\t\t\t};\n#\t\t\tprint \"<$j>\";\n\t\t$b[ $i ] = $j % 2;\n\t\t}\n#\tprint \"[@b]\";\n#\tprint;\n\tfor $i (0 .. @b-1){\n\t\t$b[ $i ] and do {\n\t\t\t$r = substr $_, $i, 1;\n\t\t\tsubstr $_, $i, 1, (substr $_, (length)-$i-1, 1);\n\t\t\tsubstr $_, (length)-$i-1, 1, $r;\n\t\t\t};\n\t\t\n\t\t}\n\tprint \"$_\";\n\t}"}, {"source_code": "$\\ = $/;\nwhile(<>){\n\t<>;\n\t@a = sort {$a <=> $b} split \" \", <>;\n\t@A = ();\n\t$a[ $_ ] == $a[ $_+1 ] and $a[ $_ ] = $a[ $_+1 ] = -1 for 0 .. @a - 2;\n\t$_ > -1 and push @A, $_ for @a;\n\t@a = @A;\n\t@b = (0) x ((length) / 2);\n\t$j = 0;\n\tfor $i (0 .. @b-1){\t\n\t\t$i == $a[ 0 ]-1 and do {\n\t\t\t++$j;\n\t\t\tshift @a if @a;\n\t\t\t};\n\t\t$b[ $i ] = $j % 2;\n\t\t}\n\tfor $i (0 .. @b-1){\n\t\t$b[ $i ] and do {\n\t\t\t$r = substr $_, $i, 1;\n\t\t\tsubstr $_, $i, 1, (substr $_, (length)-$i-1, 1);\n\t\t\tsubstr $_, (length)-$i-1, 1, $r;\n\t\t\t}\n\t\t}\n\tprint\n\t}"}, {"source_code": "$\\ = $/;\nwhile(<>){\n\tchomp;\n\t<>;\n\t@a = split \" \", <>;\n\t@a = sort {$a <=> $b} @a;\n\t@b = (0) x ((length) / 2);\n#\tprint \"@b\";\n#\tprint \"@a\";\n\t$f = 0;\n\tfor $i (0 .. @b-1){\n#\t\tprint \"($i == \".($a[0]-1).\")\";\n\t\t$i == $a[ 0 ]-1 and do {\n\t\t\t++$j;\n\t\t\t@a || last;\n\t\t\tshift @a;\n\t\t\t};\n#\t\t\tprint \"<$j>\";\n\t\t$b[ $i ] = $j % 2;\n\t\t}\n#\tprint \"[@b]\";\n#\tprint;\n\tfor $i (0 .. @b-1){\n\t\t$b[ $i ] and do {\n\t\t\t$r = substr $_, $i, 1;\n\t\t\tsubstr $_, $i, 1, (substr $_, (length)-$i-1, 1);\n\t\t\tsubstr $_, (length)-$i-1, 1, $r;\n\t\t\t};\n\t\t\n\t\t}\n\tprint \"$_\";\n\t}"}], "src_uid": "9d46ae53e6dc8dc54f732ec93a82ded3"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>;\n\t%h = ();\n\t\n\tmap { \n\t\t$_ /= 2 while not $_ % 2;\n\t\t$_ /= 3 while not $_ % 3;\n\t\t$h{ $_ } ++\n\t\t} split;\n\t\n\tprint qw(No Yes)[ not not 1 == keys %h ]\n\t\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = split / /, <>;\nforeach (0 .. $n-1) {\n\t$a[$_]/=2 while ($a[$_]%2 == 0);\n\t$a[$_]/=3 while ($a[$_]%3 == 0);\n}\n$a[$_]!=$a[0] and say \"No\" and exit foreach (1 .. $n-1);\nsay \"Yes\";"}, {"source_code": "<>, $_ = <>;\n\nmap { \n\t$_ /= 2 while not $_ % 2;\n\t$_ /= 3 while not $_ % 3;\n\t$h{ $_ } ++\n\t} split;\n\nprint qw(No Yes)[ !! (1 == keys %h) ]"}], "negative_code": [], "src_uid": "2bb893703cbffe9aeaa0bed02f42a05c"}
{"source_code": "sub f {\n\t\t$_[$_ - 1] < $_[$_] and $_[$_] = $_[$_ - 1] + 1\n\t\tfor 1 .. @_ - 1; \n\t\t@_\n\t}\n\nprint + (sort {$b <=> $a} \n\tf(reverse \n\t\tf(<> * 0, (split ' ', <>), 0)\n\t\t)\n\t)[ 0 ]", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>;\n\t@_ = (0, split, 0);\n\n\tfor $i (1 .. @_ - 1){\n\t\t$_[$i - 1] < $_[$i] and $_[$i] = $_[$i - 1] + 1\n\t\t}\n\tfor $i (reverse 1 .. @_ - 1){\n\t\t$_[$i - 1] > $_[$i] and $_[$i - 1] = $_[$i] + 1\n\t\t}\n\t\t\n\tprint ( (sort {$b <=> $a} @_)[0] );\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>;\n\t@_ = (0, split, 0);\n\t$cnt = 0;\n\twhile (@_ > 1){\n\t\t$cnt ++;\n\t\t@A = ();\n\t\tfor $i (1 .. @_ - 2){\n\t\t\t$minN = (sort {$a <=> $b} map $_[$i + $_], -1, 1)[ 0 ];\n\t\t\t$A[$i] = $minN < $_[$i] ? $minN : $_[$i] && $_[$i] - 1;\n\t\t\t}\n\t\t@B = ($A[1]);\n\t\tfor $i (1 .. @_ - 3){\n\t\t\tprint $i;\n\t\t\t$A[$i] + $A[$i + 1] and push @B, $A[$i + 1];\n\t\t\t}\n\t\t@_ = grep defined, @B;\n\t\t}\n\t\n\tprint $cnt;\n\t}"}], "src_uid": "a548737890b4bf322d0f8989e5cd25ac"}
{"source_code": "($n,$d,$k)=split/ /,<>;\n\nif ($d**$k < $n){print -1; exit}\n\nfor $i(0..$k-1){\n\t\n\tfor $j(0..$n-1){\n\t\t\n\t\t$_.= $j / $d ** $i % $d +1;\n\t\t$_.= \" \";\n\t\t\n\t\t}\n\t\t\n\tchop;\n\t$_.=\"\\n\"\n\t\n\t}\n\t\nprint", "positive_code": [{"source_code": "($n,$d,$k)=split/ /,<>;\n\nif ($d**$k < $n){print -1; exit}\n\nfor $i(0..$k-1){\n\t\n\tfor $j(0..$n-1){\n\t\t\n\t\t$_.= $j / $d ** $i % $d +1 .\" \"\n\t\t\n\t\t}\n\t\t\n\ts/ $/\\n/\n\t\n\t}\n\t\nprint"}, {"source_code": "($n,$d,$k)=split/ /,<>;\n\nif ($d**$k < $n){print -1; exit}\n\nfor $i(0..$k-1){\n\t\n\tfor $j(0..$n-1){\n\t\t\n\t\tpush @_, $j / $d ** $i % $d +1 .\" \"\n\t\t\n\t\t}\n\n\t}\n\n$,=\"\\n\";\nprint @_"}], "negative_code": [{"source_code": "($n,$k,$d)=split/ /,<>;\n\nif ($d**$k < $n){print -1; exit}\n\nfor $i(0..$k-1){\n\t\n\tfor $j(0..$n-1){\n\t\t\n\t\t$_.= $j / $d ** $i % $d +1;\n\t\t$_.= \" \";\n\t\t\n\t\t}\n\t\t\n\tchop;\n\t$_.=\"\\n\"\n\t\n\t}\n\t\nprint"}], "src_uid": "4dddcf0ded11672a4958fb0d391dbaf5"}
{"source_code": "$\\ = $/;\n\ns/>.*<//, print +( sort { $a <=> $b } y/<//, y/>// )[ 0 ] for grep !/\\d/, <>", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\t@_ = ();\n\t\n\t/^\\<*/;\n\tpush @_, length $&;\n\t\n\t/\\>*$/;\n\tpush @_, length $&;\n\t\t\n\tprint +( sort { $a <=> $b } @_ )[ 0 ];\n\t}"}], "negative_code": [{"source_code": "s/>.*<//, print +( sort { $a <=> $b } y/<//, y/>// )[ 0 ] for grep /\\D/, <>"}, {"source_code": "<>;\n\n$_ = <>, s/>.*<//, print +( sort { $a <=> $b } y/<//, y/>// )[ 0 ] for <>"}], "src_uid": "0ba97bcfb5f539c848f2cd097b34ff33"}
{"source_code": "$n=<>;\n$h{<>}++ for 1..$n;\n($a,$b)=keys %h;\nprint $h{$a}>$h{$b}?$a:$b", "positive_code": [{"source_code": "$h{<>}++ for 1..<>;\n($a,$b)=keys %h;\nprint $h{$a}>$h{$b}?$a:$b;"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy %goals = ();\nfor (1..<>) {\n\t$goals{<>}++;\n}\nmy ($winner) = sort {$goals{$b}<=>$goals{$a}} keys %goals;\nprint $winner;"}, {"source_code": "<>;\n$a=<>;$i++;$j=0;\nchomp($a);\nwhile(<>){\nchomp;\nif ($_ eq $a) { $i++} elsif ($j) {$j++} else {$j++; $b=$_}\n \n}\nif($i>$j) {$b=$a;}\n \nprint$b"}], "negative_code": [{"source_code": "<>;\n$a=<>;$i++;\nchomp($a);\nwhile(<>){\nchomp;\n$_ eq $a ? $i++:$j++\n \n}\n$i>$j and $_=$a;\n \nprint"}, {"source_code": "<>;\n$a=<>;$i++;\nchomp($a);\nwhile(<>){\nchomp;\n$_ eq $a ? $i++:$j++\n \n}\n$i-$j and $_=$a;\n \nprint\n"}], "src_uid": "e3dcb1cf2186bf7e67fd8da20c1242a9"}
{"source_code": "($n, $t) = split \" \", <>;\n@_       = split \" \", <>;\n@a = (1) x 2;\nwhile (@_){\n\t$_ = shift @_;\n\tshift @_ for 1 .. $_ - 1;\n\tpush @a, $a[-1] += $_;\n\t}\n$t == $_ and $f++ for @a;\nprint $f ? q(YES) : q(NO)", "positive_code": [{"source_code": "($a, $b) = split \" \", <>;\nmy @arr = split \" \", <>;\nmy $i = 0;\nuntil ($i >= $b-1) {\n    $i += $arr[$i];\n}\nprint $i == $b-1? \"YES\" : \"NO\";"}, {"source_code": "my ($n, $t) = split \" \", <>;\nmy @arr = split \" \", <>;\nunshift @arr, 0;\nmy $pos = 1;\n$pos += $arr[$pos] while ($pos < $t);\nprint ($pos == $t ? \"YES\\n\" : \"NO\\n\");\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nour $flag = 0;\nour ($n, $t) = split / /, <>;\nour @adj = ([()]) x $n+1;\nour @visit = (0) x $n+1;\n\nsub dfs {\n\tmy $u = shift;\n\t\n\t# say $u;\n\t$visit[$u] = 1;\n\t$u==$t and return 1;\n\tforeach my $v (@{$adj[$u]}) {\n\t\t$visit[$v]==0 and dfs($v) and return 1;\n\t}\n\treturn 0;\n}\n\nmy $i = 1;\nforeach (split / /, <>) {\n\tpush @{$adj[$i]}, $_+$i;\n\t++$i;\n}\n\ndfs(1) and say \"YES\" or say \"NO\";\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nour $flag = 0;\nour ($n, $t) = split / /, <>;\nour @adj = ([]) x $n+1;\nour @visit = (0) x $n+1;\n\nsub dfs {\n\tmy $u = shift;\n\t\n\t# say $u;\n\t$visit[$u] = 1;\n\t$u==$t and return 1;\n\tforeach my $v (@{$adj[$u]}) {\n\t\t$visit[$v]==0 and dfs($v) and return 1;\n\t}\n\treturn 0;\n}\n\nmy $i = 1;\nforeach (split / /, <>) {\n\tpush @{$adj[$i]}, $_+$i;\n\t++$i;\n}\n\ndfs(1) and say \"YES\" or say \"NO\";\n"}, {"source_code": "use Data::Dumper;\nmy ($n, $t) = split ' ', <>;\nmy @indices = split ' ', <>;\nmy @a = ();\npush @a, 0 for (1 .. $n);\n\n$a[0] = 1;\n\nfor my $i (0 .. $n - 2) {\n    my $j = shift @indices;\n    $a[$i + $j] = 1 if $a[$i];\n}\n\nprint $a[$t - 1] == 1 ? \"YES\\n\" : \"NO\\n\";\n"}, {"source_code": "my ($n, $t) = split ' ', scalar <>;\nmy @a = split ' ', scalar <>;\nmy @used = (0) x scalar @a;\nmy $i;\nfor($i=0; $i<$t-1; $i += $a[$i]){}\nprint (($i == $t-1) ? \"YES\\n\" : \"NO\\n\");\n"}, {"source_code": "($n, $t, @_) = split /\\s/, <> . '1 ' . <>;\n($s += $_[$s]) == $t && $f++ while $s < $t;\nprint $f ? YES : NO"}, {"source_code": "($n, $t) = split \" \", <>;\n@_ = (1,   split \" \", <>);\n($s += $_[$s]) == $t && $f++ while $s < $t;\nprint $f ? q(YES) : q(NO)"}, {"source_code": "$\\ = $/;\nwhile (<>){\n\t($n, $t)=split;\n\t$_ = <>;\n\t@_ = split;\n\t$f = 0;\n\t@a = (1) x 2;\n#\tprint \"@_\";\n\twhile (@_){\n\t\t$_ = shift @_;\n\t\tfor $i (1 .. $_ - 1){shift @_};\n\t\tpush @a, $a[-1] += $_;\n\t\t}\n#\t\tprint \"@a\";\n\t$t == $_ and $f++ for @a;\n\tprint $f ? q(YES) : q(NO)\n\t}"}], "negative_code": [{"source_code": "my ($n, $t) = split \" \", <>;\nmy @arr = split \" \", <>;\nmy $pos = 1;\n$pos += $arr[$pos] while ($pos < $t);\nprint ($pos == $t ? \"YES\\n\" : \"NO\\n\");\n"}, {"source_code": "my ($n, $t) = split \" \", <>;\nmy @arr = split \" \", <>;\nmy @mark = (0) x $n+1;\n$mark[1] = 1;\nfor (my $pos = 1; $pos != $t; $pos++) {\n    $pos += int $arr[$pos];\n    if ($pos >= $n-1 || $mark[$pos]) {\n        print \"NO\\n\";\n        exit;\n    }\n    $mark[$pos] = 1;\n}\nprint \"YES\\n\";\n"}, {"source_code": "use Data::Dumper;\nmy ($n, $t) = split ' ', <>;\nmy @indices = split ' ', <>;\nmy @a = ();\npush @a, 0 for (1 .. $n);\n\nfor my $i (0 .. $n - 2) {\n    my $j = shift @indices;\n    $a[$i + $j] = 1 if $a[$i];\n}\n\nprint $a[$t - 1] == 1 ? \"YES\\n\" : \"NO\\n\";\n"}], "src_uid": "9ee3d548f93390db0fc2f72500d9eeb0"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\n\n$\\ = $/;\n\nwhile(<>){\n\t$A = 0, $B = 1023;\n\t\n\tfor( map ~~<>, 1 .. $_ ){\n\t\tchomp;\n\t\t/ /;\n\t\t$` eq '&' and map $_ &= $', $A, $B;\n\t\t$` eq '|' and map $_ |= $', $A, $B;\n\t\t$` eq '^' and map $_ ^= $', $A, $B;\n\t\t}\n\t\n\tprint 3;\n\tprint \"& \", ( 1023 & $A ) | $B;\n\tprint \"^ \", $A & ( 1023 ^ $B );\n\tprint \"| \", $A & $B;\n\t}", "positive_code": [{"source_code": "# a -> b               0 1  ^ | &\n# & 1 = | 0 = as is    0 1  0 0 1\n# & 0 = to 0           0 0  0 0 0\n# | 1 = to 1           1 1  0 1 1\n# ^ 1 = flip           1 0  1 0 1\n\n%outbit = (\n\t\"01\" => \"001\",\n\t\"00\" => \"000\",\n\t\"11\" => \"011\",                                                              \n\t\"10\" => \"101\"\n);\n\n<>; $/ = undef; $_ = <>; @input = split; $k = @input;\n$a = 0; $b = 1023; \nfor ($i = 0; $i < $k; $i += 2) { \n\t$op = $input[$i]; $val = $input[$i + 1];\n\tif ($op eq \"|\") { $a |= $val; $b |= $val; }\n\tif ($op eq \"&\") { $a &= $val; $b &= $val; }\n\tif ($op eq \"^\") { $a ^= $val; $b ^= $val; }\n}\n\n@a = reverse(split(//, sprintf(\"%010b\", $a))); \n@b = reverse(split(//, sprintf(\"%010b\", $b))); \n\nfor $bit (0..9) {\n\t$i = $a[$bit];\n\t$j = $b[$bit];\n\t@outbit = split //, $outbit{\"$i$j\"};\n\t$v1 += ($outbit[0] << $bit); \n\t$v2 += ($outbit[1] << $bit); \n\t$v3 += ($outbit[2] << $bit); \n}\n\n$\\ = \"\\n\";\nprint 3;\nprint \"^ $v1\";\nprint \"| $v2\";\nprint \"& $v3\";\n\t     "}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\n\n$\\ = $/;\n\nwhile(<>){\n\t$A = 0, $B = 1023;\n\t\n\tfor( map ~~<>, 1 .. $_ ){\n\t\t/ /;\n\t\t$` eq '&' and map $_ &= $', $A, $B;\n\t\t$` eq '|' and map $_ |= $', $A, $B;\n\t\t$` eq '^' and map $_ ^= $', $A, $B;\n\t\t}\n\t\n\tprint 3;\n\tprint \"& \", ( 1023 & $A ) | $B;\n\tprint \"| \", $A & ( 1023 ^ $B );\n\tprint \"^ \", $A & $B;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tmy $and = -1;\n\t\n\tfor my $i ( reverse 0 .. @_ - 1 ){\n\t\t$_[ $i ] =~ /&/ and do {\n\t\t\t$and = $i;\n\t\t\tlast;\n\t\t\t};\n\t\t}\n\t\n\tmy $AND = 1023;\n\tmy $OR = 0;\n\tmy $XOR = 0;\n\t\n\tfor my $i ( 0 .. $and ){\n\t\t$_[ $i ] =~ /^&/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$AND &= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\|/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$OR |= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\^/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$XOR ^= $&;\n\t\t\t};\n\t\t}\n\t\n\tprint 5;\n\t\n\tprint \"^ $XOR\";\n\tprint \"| $OR\";\n\tprint \"& $AND\";\n\t\n\tmy $OR2 = 0;\n\tmy $XOR2 = 0;\n\t\n\tfor my $i ( $and + 1 .. @_ - 1 ){\n\t\t$_[ $i ] =~ /^\\|/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$OR2|= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\^/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$XOR2 ^= $&;\n\t\t\t};\n\t\t}\n\t\n\tprint \"^ $XOR2\";\n\tprint \"| $OR2\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tmy $and = -1;\n\t\n\tfor my $i ( reverse 0 .. @_ - 1 ){\n\t\t$_[ $i ] =~ /&/ and do {\n\t\t\t$and = $i;\n\t\t\tlast;\n\t\t\t};\n\t\t}\n\t\n\tmy $AND = 1023;\n\tmy $OR = 0;\n\tmy $XOR = 0;\n\t\n\tfor my $i ( 0 .. $and ){\n\t\t$_[ $i ] =~ /^&/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$AND &= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\|/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$OR |= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\^/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$XOR ^= $&;\n\t\t\t};\n\t\t}\n\t\n\tprint 5;\n\t\n\tprint \"^ $XOR\";\n\tprint \"| $OR\";\n\tprint \"& $AND\";\n\t\n\tmy $OR2 = 0;\n\tmy $XOR2 = 0;\n\t\n\tfor my $i ( $and + 1 .. @_ - 1 ){\n\t\t$_[ $i ] =~ /^\\|/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$OR2|= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\^/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$XOR2 ^= $&;\n\t\t\t};\n\t\t}\n\t\n\tprint \"| $OR2\";\n\tprint \"^ $XOR2\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\t\n\tmy $and = -1;\n\t\n\tfor my $i ( reverse 0 .. @_ - 1 ){\n\t\t$_[ $i ] =~ /&/ and do {\n\t\t\t$and = $i;\n\t\t\tlast;\n\t\t\t};\n\t\t}\n\t\n\tmy $AND = 1023;\n#\tprintf \"%b\\n\", 1023;\n\tmy $OR = 0;\n\tmy $XOR = 0;\n\t\n\tfor my $i ( 0 .. $and ){\n\t\t$_[ $i ] =~ /^&/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$AND &= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\|/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$OR |= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\^/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$XOR ^= $&;\n\t\t\t};\n\t\t}\n\t\n\tprint 5;\n\t\n\tprint \"| $OR\";\n\tprint \"^ $XOR\";\n\tprint \"& $AND\";\n\t\n\tmy $OR2 = 0;\n\tmy $XOR2 = 0;\n\t\n\tfor my $i ( $and + 1 .. @_ - 1 ){\n\t\t$_[ $i ] =~ /^\\|/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$OR2|= $&;\n\t\t\tnext;\n\t\t\t};\n\t\t$_[ $i ] =~ /^\\^/ and do {\n\t\t\t$_[ $i ] =~ /\\d+/;\n\t\t\t$XOR2 ^= $&;\n\t\t\t};\n\t\t}\n\t\n\tprint \"| $OR2\";\n\tprint \"^ $XOR2\";\n\t}"}, {"source_code": "<>; $_ = join \"\", <>, \"\\n\";\n\nm{\n\t(\n\t\t\\& \\s ( \\d+ (\\n \\& \\s \\d+)* ) \\n\n\t)?\n\t(\n\t\t([|^]) \\s ( \\d+ (\\n [&|^] \\s \\d+)* )\n\t)?\n}x;                            \n\n$v1 = eval($2) || 1023; $op = $5 || \"|\"; $v2 = eval($6) || 0;\nprint \"2\\n& $v1\\n$op $v2\";\n"}, {"source_code": "# a -> b               0 1  ^ | &\n# & 1 = | 0 = as is    0 1  0 0 1\n# & 0 = to 0           0 0  0 0 0\n# | 1 = to 1           1 1  0 1 1\n# ^ 1 = flip           1 0  1 0 1\n\n%outbit = (\n\t\"01\" => \"001\",\n\t\"00\" => \"000\",\n\t\"11\" => \"011\",                                                              \n\t\"10\" => \"101\"\n);\n\n$n = <>; $/ = undef; $_ = <>; @input = split;\n$a = 0; $b = 1023; \nfor ($i = 0; $i < $n; $i += 2) { \n\t$op = $input[$i]; $val = $input[$i + 1];\n\tif ($op eq \"|\") { $a |= $val; $b |= $val; }\n\tif ($op eq \"&\") { $a &= $val; $b &= $val; }\n\tif ($op eq \"^\") { $a ^= $val; $b ^= $val; }\n}\n\n@a = reverse(split(//, sprintf(\"%010b\", $a))); \n@b = reverse(split(//, sprintf(\"%010b\", $b))); \n\nfor $bit (0..9) {\n\t$i = $a[$bit];\n\t$j = $b[$bit];\n\t@outbit = split //, $outbit{\"$i$j\"};\n\t$v1 += ($outbit[0] << $bit); \n\t$v2 += ($outbit[1] << $bit); \n\t$v3 += ($outbit[2] << $bit); \n}\n\n$\\ = \"\\n\";\nprint 3;\nprint \"^ $v1\";\nprint \"| $v2\";\nprint \"& $v3\";\n\t     "}], "src_uid": "19c32b8c1d3db5ab10aca271135aa9b8"}
{"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n", "positive_code": [{"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n"}, {"source_code": "($n, $m) = split ' ', <>;\n\nfor (1..$n) {\n\t$s = <>;\n\tfor ($i = 0; $i < 4 * $m; $i += 4) {\n\t\t$c++ if substr($s, $i, 3) ne \"0 0\";\n\t}\n}\n\nprint 0 + $c, \"\\n\";"}, {"source_code": "my ($n, $m) = split / /, <>;\n($n, $m) = (int $n,int $m);\nmy @arr;\nmy $ans = 0;\nfor (1..$n) {\n    @arr = split / /, <>;\n    for (my $j = 0 ; $j < 2 * $m; $j+=2) {\n        $ans++ if ($arr[$j] == '1' || $arr[$j + 1] == '1');\n    }\n}\nprint \"$ans\\n\";\n"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs\n"}, {"source_code": "<>;\n$_ = join '', split ' ', join '', <>;\nprint 0 + grep 0 + $_, /\\G../g"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>, $/ = $\\, <>) =~ /\\G.{4}/gs"}], "negative_code": [{"source_code": "($n, $m) = split ' ', <>;\n\nfor (1..$n) {\n\t$s = <>;\n\tfor ($i = 0; $i < 4 * $m; $i += 4) {\n\t\t$c++ if substr($s, $i, 3) ne \"0 0\";\n\t}\n}\n\nprint $c, \"\\n\";"}, {"source_code": "my ($n, $m) = split / /, <>;\n($n, $m) = (int $n,int $m);\nmy @arr;\nmy $ans = 0;\nfor (1..$n) {\n    @arr = split / /, <>;\n    for (my $j = 0 ; $j < 2 * $m; $j+=2) {\n        $ans++ if ($arr[$j] || $arr[$j + 1]);\n    }\n}\nprint \"$ans\\n\";\n"}, {"source_code": "<>;\nprint 0 + grep 0 + $_, map y/ //dr, (<>.<>) =~ /\\G....?/gs"}, {"source_code": "<>;\nprint 0 + (() = <> =~ /[^0]{2}/gm)"}, {"source_code": "print 0 + grep 0 + $_, map y/ //dr, (<>,<>.<>) =~ /\\G....?/gs"}, {"source_code": "<>;\n$_ = join '', split ' ', join '', <>;\nprint 0 + (() = /01|10|11/g)"}], "src_uid": "5b9aed235094de7de36247a3b2a34e0f"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t$_ = <>, chomp;\n\t\n\t$debug and print \"\\$_:[$_]\";\n\t\n\tmy @A = ( 1 ) x ( 1 + length );\n\t\n\tfill_array_with_counts_of_forward_nodes(\n\t\t$_, \\@A\n\t\t);\n\t\n\t$debug and print \"\\@A:[@A]\";\n\t\n\t$_ = reverse;\n\t$_ =~ y/RL/LR/;\n\t@A = reverse @A;\n\t\n\tfill_array_with_counts_of_forward_nodes(\n\t\t$_, \\@A\n\t\t);\n\t\n\t@A = reverse @A;\n\t\n\t$debug and print \"\\@A:[@A]\";\n\t\n\tprint \"@A\";\n\t}\n\nsub fill_array_with_counts_of_forward_nodes {\n\tmy( $line, $ref_array ) = @_;\n\t\n\tmy $len = 0;\n\t\n\t$line =~ /\t\n\t\t(?{\n\t\t\t$debug and print \">[$-[0]][$`][$&][$'][@{ $ref_array }][$len]\";\n\t\t\t})\n\t\t(?=R)\n\t\t(?{ $len > 0 and $len -= 2; })\n\t\t(?(?{ $len <= 0; })\n\t\t\t(?: (?:RL)*+ ){0,10}+\n\t\t\tR?+\n\t\t\t(?{ $len = length $&; })\n\t\t\t)\n\t\t(?{\n\t\t\t$debug and print \"[$-[ 0 ]], len:[$len]\";\n\t\t\t${ $ref_array }[ $-[ 0 ] ] += $len;\n\t\t\t})\n\t\t(*FAIL)\n\t\t/x;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\t@A = ( 1 ) x ( 1 + length );\n\t\n\t&add_forward_cities;\n\t&add_forward_cities;\n\t\n\tprint \"@A\";\n\t}\n\nsub add_forward_cities {\n\t$_ = reverse;\n\ty/RL/LR/;\n\t@A = reverse @A;\n\t\n\t$length = 0;\n\t\n\t/\t\n\t\t(?=R)\n\t\t(?{ $length > 0 and $length -= 2 })\n\t\t(?(?{ $length <= 0 })\n\t\t\t(?: (?:RL)*+ ){0,10}+\n\t\t\tR?+\n\t\t\t(?{ $length = length $& })\n\t\t\t)\n\t\t(?{\n\t\t\t$A[ $-[ 0 ] ] += $length\n\t\t\t})\n\t\t(*F)\n\t\t/x;\n\t}"}, {"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>, chomp;\r\n\t\r\n\t@A = ( 1 ) x ( 1 + length );\r\n\t\r\n\t&fill;\r\n\t&fill;\r\n\t\r\n\tprint \"@A\";\r\n\t}\r\n\r\nsub fill {\r\n\t$_ = reverse;\r\n\ty/RL/LR/;\r\n\t@A = reverse @A;\r\n\t\r\n\t$L = 0;\r\n\t\r\n\t/\t\r\n\t\t(?=R)\r\n\t\t(?{ $L > 0 and $L -= 2 })\r\n\t\t(?(?{ $L <= 0 })\r\n\t\t\t(?: (?:RL)*+ ){0,10}+\r\n\t\t\tR?+\r\n\t\t\t(?{ $L = length $& })\r\n\t\t\t)\r\n\t\t(?{\r\n\t\t\t$A[ $-[ 0 ] ] += $L\r\n\t\t\t})\r\n\t\t(*F)\r\n\t\t/x;\r\n\t}"}, {"source_code": "#!/usr/bin/perl\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $s = <STDIN>;\r\n  \r\n  my @f = ();\r\n  my $st = '';\r\n  my $st_i = -1;\r\n  my $st_l = 0;\r\n  for(my $i=0;$i<$n;$i++){\r\n    my $c1 = substr($s,$i,1);\r\n    if( $st ne '' ){\r\n      if( ( $i - $st_i ) % 2 == 1 ){\r\n        if( $st eq $c1 ){\r\n          push(@f,+[$st_i,$i-$st_i]);          $st = '';\r\n        }\r\n      } else {\r\n        if( $st ne $c1 ){\r\n          push(@f,+[$st_i,$i-$st_i]);          $st = '';\r\n        }\r\n      }\r\n    }\r\n    if( $st eq '' ){\r\n      $st = $c1;\r\n      $st_i = $i;\r\n    }\r\n  }\r\n  push(@f,+[$st_i,$n-$st_i]);\r\n  \r\n  my $j = 0;\r\n  for(my $i=0;$i<=$n;$i++){\r\n    my $r1 = 0; my $r2 = 0;\r\n    $j++ if $i >= $f[$j]->[0] + $f[$j]->[1];\r\n    #$jは右と中\r\n    if( $j<=$#f ){\r\n      my ($k,$l) = ($f[$j]->[0],$f[$j]->[1]);\r\n      my $c1 = substr($s,$k,1);\r\n      if( ( $c1 eq 'L' and ($i-$k) % 2 == 1 ) or ( $c1 eq 'R' and ($i-$k) % 2 == 0 ) ){\r\n        $r1 = $l + 1;\r\n      }\r\n    }\r\n    if( $j>0 ){ # 左のみ\r\n      my ($k,$l) = ($f[$j-1]->[0],$f[$j-1]->[1]);\r\n      if( $k + $l == $i ){ # 隣接時のみ\r\n        my $c1 = substr($s,$k,1);\r\n        if( ( $c1 eq 'L' and ($i-$k) % 2 == 1 ) or ( $c1 eq 'R' and ($i-$k) % 2 == 0 ) ){\r\n          $r2 = $l + 1;\r\n        }\r\n      }\r\n    }\r\n    my $r = $r1 + $r2;\r\n    $r -- if $r1>0 and $r2>0;\r\n    $r = 1 if $r == 0;\r\n    if( $i > 0 ){ print \" \"; }\r\n    print \"$r\";\r\n  }\r\n  print \"\\n\";\r\n  \r\n}\r\n\r\nexit(0);\r\n\r\n"}], "negative_code": [], "src_uid": "f51a46e87b8871c3f581786f84e5e6d1"}
{"source_code": "use strict;\n#use warnings;\n<>;\nmy @matrix;\npush @matrix, [];\nfor(<>)\n{\n\tchomp;\n\tpush @matrix, [0,split(//,$_ ),0];\n}\npush @matrix, [];\n\nfor my $x (1..$#matrix-1)\n{\n\tfor my $y (1..$#{$matrix[$x]}-1)\n\t{\n\t\tif($matrix[$x][$y])\n\t\t{\n\t\t\tmy $toDel = [[]];\n\t\t\tfunc($x,$y,0,$toDel);\n\t\t\tDel($toDel);\n\t\t}\n\t}\n}\nprint \"No\";\nsub Del\n{\n\tmy $toDel = shift;\n\tfor my $x (0..$#matrix)\n\t{\n\t\tfor my $y (0..$#{$matrix[$x]})\n\t\t{\n\t\t\t$matrix[$x][$y] = 0 if($toDel->[$x][$y]);\n\t\t\t\n\t\t}\n\t}\n}\nsub func\n{\n\tmy ($x,$y, $dir,$path) = @_;\n\t\n\tif(!defined $path->[$x][$y])\n\t{\n\t\tmy $color = $matrix[$x][$y];\n\t\t$path->[$x][$y] = 1;\n\t\tcheckWin($x,$y,$dir,$path);\n\t\tif($dir ne 'r' and $color eq $matrix[$x-1][$y])\n\t\t{\n\t\t\tfunc($x-1, $y, 'l', $path);\n\t\t}\n\t\tif($dir ne 'l' and $color eq $matrix[$x+1][$y])\n\t\t{\n\t\t\tfunc($x+1, $y, 'r', $path);\n\t\t}\n\t\tif($dir ne 'd' and $color eq $matrix[$x][$y+1])\n\t\t{\n\t\t\tfunc($x, $y+1, 'u', $path);\n\t\t}\n\t\tif($dir ne 'u' and $color eq $matrix[$x][$y-1])\n\t\t{\n\t\t\tfunc($x, $y-1, 'd', $path);\n\t\t}\n\t}\n}\nsub checkWin\n{\n\tmy ($x,$y, $dir,$path) = @_;\n\tif($matrix[$x][$y] eq $matrix[$x+1][$y] and $path->[$x+1][$y] and $dir ne 'l' ){ print \"Yes\" and exit 0;}\n\tif($matrix[$x][$y] eq $matrix[$x-1][$y] and $path->[$x-1][$y] and  $dir ne 'r' ){ print \"Yes\" and exit 0;}\n\tif($matrix[$x][$y] eq $matrix[$x][$y+1] and $path->[$x][$y+1] and $dir ne 'd' ){ print \"Yes\" and exit 0;}\n\tif($matrix[$x][$y] eq $matrix[$x][$y-1] and $path->[$x][$y-1] and $dir ne 'u' ){ print \"Yes\" and exit 0;}\n\treturn 0;\n}\n", "positive_code": [{"source_code": "while(<>){\n\t($n, $m) = split;\n\tundef *A;\n\tfor $i (1 .. $n){\n\t\t$_ = <>, chomp;\n\t\t$j = 0;\n\t\t$A[ $i ][ ++$j ] = $_ for split//;\n\t\t}\n\t\n\t$f = 1; \n\tWH:\n\twhile (1){\n\t\n\tfor $i (1 .. $n){\n\t\tfor $j (1 .. $m){\n\t\t\t$A = $A[ $i ][ $j ];\n\t\t\t$A eq '.' and next;\n\t\t\t$u = 0;\n\t\t\t$A eq $A[ $i-1 ][ $j ] and $u++;\n\t\t\t$A eq $A[ $i+1 ][ $j ] and $u++;\n\t\t\t$A eq $A[ $i ][ $j-1 ] and $u++;\n\t\t\t$A eq $A[ $i ][ $j+1 ] and $u++;\n\t\t\tif ($u < 2){ $A[ $i ][ $j ] = '.' ; next WH }\n\t\t\t}\n\t\t}\n\tlast\n\t}\n\tfor $i (1 .. $n){\n\t\tfor $j (1 .. $m){\n\t\t\tif ($A[ $i ][ $j ] ne '.'){ $f = 0 }\n\t\t\t}\n\t\t}\t\n\t\t\n\tprint qw(Yes No)[ $f ]\n\t}"}], "negative_code": [], "src_uid": "73930603e440eef854da4ba51253a5a7"}
{"source_code": "my @input;\nwhile(<>) {chomp; push(@input, $_);}\nmy @list = map{ {}; } (1..20);\nshift(@input);\nmy ($l, $c, $i);\nmy $regexp = qr//o;\nfor $l (@input) {\n\t$i = 0;\n  foreach $c (split($regexp, $l)) {\n    $list[$i++]{$c} = 1;\n  }\n}\n$i = 0;\n$i++ while( scalar(keys(%{$list[$i]}) == 1 ) );\nprint $i;", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy @phones;\nmy $n;\nsub isvalid{\n    my $start = shift;\n    my $len = shift;\n    my $cmp = substr $phones[0], $start, $len-$start;\n    for my $i(1..$n-1){\n        return 0 if $cmp ne substr $phones[$i], $start, $len-$start;\n    }\n    return 1;\n}\n#==================================\n\n$n = <>;\nfor(1..$n){ \n    chomp (my $val = <>);\n    push @phones, $val;\n}\n\nmy ($low, $high) = (0,40000);\nwhile($low < $high){\n    my $mid = int(($low + $high + 1) / 2);\n    if(isvalid($low, $mid)){$low = $mid;}\n    else {$high = $mid-1;}\n}\nprint $low;\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy @phones;\nmy $n;\n$n = <>;\nfor(1..$n){ \n    my @val = (<> =~ /\\w/g);\n    push @phones, \\@val;\n}\nfor my $j(0..40000){\n    my $char = $phones[0][$j];\n    for my $i(0..$n-1){\n        if($char ne $phones[$i][$j]){\n            print $j;\n            exit 0;\n        }\n    }\n}\n"}, {"source_code": "@_=<>;\nshift @_;\nchomp @_;\n$a = shift @_;\nfor $j(1..length $_[0]){\n    $i=0;\n    for (@_){\n        $a eq $_ or $i=1;\n        chop;\n        }\n    chop $a;\n    $i or last\n    }\nprint 1 - $i + length $a"}, {"source_code": "$k = <>;\n$p = <>;\nwhile (<>) {\n    for ($i = length $p; $i >= 0; $i--) {\n        if (substr($_, 0, $i) eq substr($p, 0, $i)) {\n            $p = substr($_, 0, $i);\n            last;\n        }\n    }\n}\nprint length $p, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nchomp($n = <STDIN>);\n$nums;\nfor ($i = 0; $i < $n; $i++)\n{\n    chomp($num = <STDIN>);\n    push(@nums, $num);\n    #print $num . \"\\n\";\n}\n\n$numlen = length $nums[0];\n#$res = 0;\nfor ($i = $numlen - 1; $i >= 0; $i--)\n{\n    #print $i . \"\\n\";\n    #print $nums[$i] . \"\\n\";\n    $head = substr($nums[0], 0, $i + 1);\n    #print $head . \"\\n\";\n    $isok = 1;\n    for ($j = 1; $j < $n; $j++)\n    {\n        #print \"tmp: \" . substr($nums[j], 0, $i + 1) . \"\\n\";\n        if (substr($nums[$j], 0, $i + 1) ne $head)\n        {\n            $isok = 0;\n            last;\n        }\n    }\n\n    if ($isok)\n    {\n        print $i + 1;\n        exit;\n    }\n    elsif (!$isok && $i == 0)\n    {\n        print 0;\n        exit;\n    }\n}"}, {"source_code": "my $c = <>;\n\nmy @num = ();\nfor ( my $i = 0; $i < $c; $i++) {\n    push @num, [split(//o, <>)];\n}\n\nif ($c == 1 ) {\n    print @{$num[0]};\n    exit;\n}\nmy $ok = 1;\nmy $len = 0;\n\nwhile ( $ok ) {\n    my $c = $num[0][$len];\n    for (my $i = 1; $i < @num; $i++) {\n        if ($num[$i][$len] != $c) {\n            $ok = 0;\n            last;\n        }\n    }\n    $len++;\n}\n\nprint $len-1;"}, {"source_code": "my $n = <STDIN>;\nmy @a;\nfor (my $i = 0; $i < $n; $i++) {\n    my $q = <STDIN>;\n    push(@a, $q);\n}\n\nmy $l = length $a[0];\nmy $ans = 0;\n\nfor (my $i = $l; $i > 0; $i--) {\n    my $substr = substr $a[0], 0, $i;\n    my $flag = 1;\n    for my $t (@a) {\n        if (!($t =~ /^$substr/)) {\n            $flag = 0;\n            last;\n        }\n    }\n    if ($flag) {\n        $ans = $i;\n        last;\n    }\n}\n\nprint \"$ans\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\n######z1\n\nmy $count = <STDIN>;\nmy $pref = <STDIN>;\nmy $len = length($pref);\nforeach (my $i=1;$i<$count;$i++) {\n    my $num = <STDIN>;\n    while ($pref ne substr($num, 0, $len)) {\n        $len--;\n        $pref = substr($pref, 0, $len);\n    }\n}\nprint $len.\"\\n\";\n1;"}], "negative_code": [{"source_code": "$k = <>;\n$p = <>;\nwhile (<>) {\n    for ($i = length; $i > 0; $i--) {\n        if (substr($_, 0, $i) eq substr($p, 0, $i)) {\n            $p = substr($_, 0, $i);\n            last;\n        }\n    }\n}\nprint length $p, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nchomp($n = <STDIN>);\n$nums;\nfor ($i = 0; $i < $n; $i++)\n{\n    chomp($num = <STDIN>);\n    push(@nums, $num);\n    #print $num . \"\\n\";\n}\n\n$numlen = length $nums[0];\n#$res = 0;\nfor ($i = $numlen - 1; $i >= 0; $i--)\n{\n    #print $i . \"\\n\";\n    #print $nums[$i] . \"\\n\";\n    $head = substr($nums[0], 0, $i + 1);\n    #print $head . \"\\n\";\n    #$isok = 1;\n    for ($j = 1; $j < $n; $j++)\n    {\n        #print \"tmp: \" . substr($nums[j], 0, $i + 1) . \"\\n\";\n        if (substr($nums[$j], 0, $i + 1) ne $head)\n        {\n            last;\n        }\n\n        if ($j == $n - 1)\n        {\n            print $i + 1;\n            exit;\n        }\n    }\n}"}], "src_uid": "081b35620952bd32ce6d8ddc756e5c9d"}
{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>, chomp;\r\n\t\r\n\tprint m/^(1|0|10|01)$/ ? 'YES' : 'NO';\r\n\t}", "positive_code": [{"source_code": "for (1..<>) {\r\n      chomp(my $n = <>);\r\n      chomp(my $in = <>);\r\n      my @a = split //, $in;\r\n      scalar(@a) == 1 and print \"YES\\n\" and next;\r\n      scalar(@a) > 2 and print \"NO\\n\" and next;\r\n      my $a = shift @a;\r\n      my $b = shift @a;\r\n      $a != $b and print \"YES\\n\";\r\n      $a == $b and print \"NO\\n\";\r\n}"}], "negative_code": [], "src_uid": "354658f565e265c2a1ce37355d6466e1"}
{"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(1..$n-2){$q++if$k>1?@a[$_]>@a[$_-1]+@a[$_+1]:$_%2}print$q,\" \"}", "positive_code": [{"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(1..$n-2){$q++if$k>1?@a[$_]>@a[$_-1]+@a[$_+1]:$_%2}print$q,\" \"}"}, {"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(1..$n-2){$q++if$k>1?@a[$_]>@a[$_-1]+@a[$_+1]:$_%2}print$q,\" \"}"}], "negative_code": [{"source_code": "for(1..<>){<>;$s=<>;$s=~s/\\s.*//;print$s}"}, {"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(1..$n-1){$q++if@a[$_]>@a[$_-1]+@a[$_+1]||$k==1&&$_%2}print$q,\" \"}"}, {"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(0..$n-1){$q++if@a[$_]>@a[$_-1]+@a[$_+1]||($k==1&&$_%2)}print$q,\" \"}\r\n"}, {"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(0..$n-1){$q++if@a[$_]>@a[$_-1]+@a[$_+1]||$k==1&&$_%2}print$q,\" \"}"}, {"source_code": "for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(0..$n-1){$q++if@a[$_]>@a[$_-1]+@a[$_+1]||!$k&&$_%2}print$q,\" \"}"}, {"source_code": "use POSIX;for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(0..$n-1){$q++if@a[$_]>@a[$_-1]+@a[$_+1]}print$k-1?$q:-1&($n-2)/2+$n%2,\" \"}"}, {"source_code": "use POSIX;for(1..<>){($n,$k)=split/\\s/,<>;@a=split/\\s/,<>;$q=0;for(0..$n-1){$q++if@a[$_]>@a[$_-1]+@a[$_+1]}print$k-1?$q:ceil($n/2-1),\" \"}"}], "src_uid": "4d5d20fd586ddbea2adeab104a6c2aec"}
{"source_code": "chomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc, $_ } @words;\n\n$list = join '|', map { scalar reverse lc } @words;\n\nm/^ (?: ($list | $ | (?{ pop @submatches }) (?!) ) (?{ push @submatches, $^N }) )+ $/x;\n\npop @submatches;\n\nprint join ' ', map { $restore_case{ scalar reverse } } @submatches", "positive_code": [{"source_code": "# Eily+\n\nchomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc reverse, $_ } @words; \n\n$list = join '|', keys %restore_case;\n\nm/^ (?: ($list | $ | (?{ pop @submatches }) (?!) ) (?{ push @submatches, $^N }) )+ $ (?{ pop @submatches })/x;\n\nprint join ' ', map { $restore_case{ $_ } } @submatches"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t@w = @ww = @ans = @ANS = ();\n\t\n\tfor (1 .. <>){\n\t\tpush @w, scalar <>;\n\t\t}\n\tchomp @w;\n\t\n\t%h = map { (scalar reverse lc) => 1 } @w;\n\t%H = map { lc, $_ } @w;\n\t\n\t$re = join '|', keys %h;\n\t\n\t/^(?:($re)(?{push @ww, $^N}))+$/;\n\t\n\tfor $st (@ww){\n\t\ts/^$st/ (push @ans, scalar reverse $&) , ''/e;\n\t\t}\n\n\tfor (@ans){\n\t\tpush @ANS, $H{ $_ };\n\t\t}\n\t\t\n\tprint \"@ANS\";\n\t}"}, {"source_code": "chomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc, $_ } @words;\n\n$list = join '|', map { scalar reverse lc } @words;\n\nm/^ (?: ($list) (?{ push @sub_matches, $^N }) )+ $/x;\n\nfor $sub_match (@sub_matches){\n\ts/^$sub_match// and push @ans, $restore_case{ reverse $& }\n\t}\n\t\nprint \"@ans\""}, {"source_code": "chomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc, $_ } @words;\n\n$list = join '|', map { scalar reverse lc } sort { length $a <=> length $b } @words;\n\nm/^ (?: ($list) (?{ unshift @sub_matches, $^N }) )+ $/x;\n\nfor $sub_match (@sub_matches){\n\ts/$sub_match$// and unshift @ans, $restore_case{ reverse $& }\n\t}\n\t\nprint \"[$_]\" if $_;\nprint \"@ans\""}, {"source_code": "chomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc, $_ } @words;\n\n$list = join '|', map { scalar reverse lc } @words;\n\nm/^ (?: ($list) (?{ unshift @sub_matches, $^N }) )+ $/x;\n\nfor $sub_match (@sub_matches){\n\ts/$sub_match$// and unshift @ans, $restore_case{ reverse $& }\n\t}\n\t\nprint \"[$_]\" if $_;\nprint \"@ans\""}, {"source_code": "chomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc, $_ } @words;\n\n$list = join '|', map { scalar reverse lc } @words;\n\nm/^ (?: ($list) (?{ push @sub_matches, $^N }) )+ $/x;\n\nfor $sub_match (reverse @sub_matches){\n\ts/$sub_match$// and unshift @ans, $restore_case{ reverse $& }\n\t}\n\t\nprint \"@ans\""}, {"source_code": "chomp( (undef, $_, undef, @words) = <> );\n\n%restore_case = map { lc, $_ } @words;\n\n$list = join '|', map { scalar reverse lc } @words;\n\nm/^ (?: ($list) (?{ push @sub_matches, $^N }) )+ $/x;\n\nfor $sub_match (@sub_matches){\n\ts/^$sub_match// and push @ans, $restore_case{ reverse $& }\n\t}\n\t\nprint \"@ans\";"}], "src_uid": "5d3fc6a6c4f53d53c38ab4387282a55c"}
{"source_code": "$_ = <>;\nchomp;\ns/^0+//;\n$E = /\\./g ? ~- pos : length;\ny/.//d;\n/[^0]/g;\n$E -= pos;\ns/^0+//;\ns/0+$//;\ns/\\B/./;\n$_ .= \"E$E\" if $E;\n$_ ||= 0;\nprint", "positive_code": [{"source_code": "$_ = <>,\nchomp,\ns/^0+//,\ns/\\./ $i = pos, '' /e,\n$i //= length,\n/[1-9]/g,\n$j = pos,\ns/\\.//,\ns/^0+//,\ns/0+$//,\ns/\\B/./,\n$_ .= 'E' . ($i - $j),\ns/E0//,\n$_ ||= 0,\nprint,"}, {"source_code": "while(<>){\n\tchomp;\n\ts/^0+//;\n\t/\\./ or s/$/./;\n\t$i = index $_, '.';\n\t$j = index s/[1-9]/A/r, 'A';\n\ts/\\.//;\n\ts/^0+//;\n\ts/0+$//;\n\ts/.\\K/./;\n\t$_ .= 'E' . ($i - $j - ($i > $j));\n\ts/\\.E/E/;\n\ts/E0//;\n\t$_ ||= 0;\n\tprint;\n\t}"}, {"source_code": "chomp($_ = <>); \n($a, $b) = /\\./? ($`, $'): $_;\n$a =~ s/^0+//; $b =~ s/0+$//;\nif ($a or $b) {\n\tif (length $a) {\n\t\t$a =~ /^./; $a = $&; $b = $'.$b; $e = length $';\n\t} else {\n\t\t$b =~ s/^0+// and $e = -length $&;\n\t\t$b =~ /^./; $a = $&; $b = $'; $e--;\n\t}\n\t$e = $e? \"E$e\": \"\";\n\t$b =~ s/0+$//; $b = $b? \".$b\": \"\";\n\t$r = \"$a$b$e\";\n} else {\n\t$r = \"0\";\n}\nprint $r;\n"}], "negative_code": [{"source_code": "chomp($_ = <>); s/^0+|0+$//g;\n($a, $b) = /\\./? ($`, $'): $_;\nif ($a or $b) {\n\tif (length $a) {\n\t\t$a =~ /^./; $a = $&; $b = $'.$b; $e = length $';\n\t} else {\n\t\t$b =~ s/^0+// and $e = -length $&;\n\t\t$b =~ /^./; $a = $&; $b = $'; $e--;\n\t}\n\t$e = $e? \"E$e\": \"\";\n\t$b =~ s/0+$//; $b = $b? \".$b\": \"\";\n\t$r = \"$a$b$e\";\n} else {\n\t$r = \"0\";\n}\nprint $r;\n"}], "src_uid": "b1eebb3928925b84a95b9f1e5a31e4f3"}
{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\tprint <> =~ s/(?=.)/ chr 40 + shift @_ /ger \r\n\t\t\t =~ m/(.)([a-z]).*\\1(?!\\2)/ ? \"NO\\n\" : \"YES\\n\"\r\n    }", "positive_code": [{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\tprint <> =~ s/()/ chr 130 + shift @_ /ger \r\n\t\t\t =~ m/(.)(\\w).*\\1(?!\\2)/ ? \"NO\\n\" : \"YES\\n\"\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t$_ = <>, chomp;\n\t\n\tmy %h;\n\tmy $f = 0;\n\t\n\twhile( @_ ){\n\t\tmy $i = pop @_;\n\t\tmy $j = chop;\n\t\t\n\t\tif( exists $h{ $i } ){\n\t\t\tif( $h{ $i } ne $j ){\n\t\t\t\t$f = 1;\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\telse{\n\t\t\t$h{ $i } = $j;\n\t\t\t}\n\t\t}\n\t\n\tprint $f ? 'NO' : 'YES';\n\t}"}], "negative_code": [{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t@_ = split ' ', <>;\r\n\tprint <> =~ s// chr 40 + shift @_ /ger \r\n\t\t\t =~ m/(.)([a-z]).*\\1(?!\\2)/ ? \"NO\\n\" : \"YES\\n\"\r\n\t}"}], "src_uid": "485d5984e34a479f2c074a305ae999ae"}
{"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n", "positive_code": [{"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n"}, {"source_code": "$\\ = $/;\n\n<>;\n$c = 0;\n$max = 0;\nwhile(<>){\n\tchomp;\n\t($n, $m) = split;\n\t$n eq '+' and ++ $h{$m} and ++ $c; # and $c > $max and $max = $c;\n\t$n eq '-' and do {\n\t\t$h{$m} // $max ++;\n\t\tdefined $h{$m} and $c --;\n\t\t$h{$m} and delete $h{$m};\n\t};\n\t$c > $max and $max = $c;\n#\tprint $_,' ',$max;\n#\tprint qw(NO YES)[]\n\t}\nprint $max;"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n@c = (0) x (10**6+5);\nchomp($n = <>);\npush @a, [split / /, <>] foreach (0 .. $n-1);\n$tot = 0;\nforeach (0 .. $n-1) {\n\t$id = $a[$_][1];\n\tif ($a[$_][0] eq '+') {\n\t\t$c[$id] = 1;\n\t} elsif ($c[$id]) {\n\t\t$c[$id] = 0;\n\t} else {\n\t\t++$tot;\n\t}\n}\n$ans = $tot;\nforeach (0 .. $n-1) {\n\tif ($a[$_][0] eq '+') {\n\t\t++$tot;\n\t\t$ans = $ans>$tot ? $ans:$tot;\n\t} else {\n\t\t--$tot;\n\t}\n}\nsay $ans;"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += /-/? ( $h{$r} --||++ $m, -1 <=> $h{$r} )\n\t\t\t: ( $h{$r} = 1 )\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n@c = (0) x (10**6+5);\nchomp($n = <>);\npush @a, [split / /, <>] foreach (0 .. $n-1);\n$tot = 0;\nforeach (0 .. $n-1) {\n\t$id = $a[$_][1];\n\tif ($a[$_][0] eq '+') {\n\t\t$c[$id] = 1;\n\t} elsif ($c[$id]) {\n\t\t$c[$id] = 0;\n\t} else {\n\t\t++$tot;\n\t}\n}\n$ans = $tot;\nforeach (0 .. $n-1) {\n\tif ($a[$_][0] eq '+') {\n\t\t++$tot;\n\t\t$ans = $ans>$tot ? $ans:$tot;\n\t} elsif ($c[$id]) {\n\t\t--$tot;\n\t}\n}\nsay $ans;"}, {"source_code": "<>;\nfor(<>){\n\t($s, $r) = split;\n\t$s eq '+' ? (++ $h{$r}, ++ $c)\n\t\t: ( $h{$r} //++ $m && -- $c or delete $h{$r} );\n\t$c > $m and $m = $c\n\t}\nprint 0 + $m"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += $s !~/-/? $h{$r} = 1\n\t\t\t: ( $h{$r} --||++ $m, -1)\n\t\t) > $m and $m = $c\n\twhile <>;\n\t\nprint 0 + $m"}, {"source_code": "<>;\n\t($s, $r) = split,\n\t\t( $c += $s !~/-/? $h{$r} = 1\n\t\t\t: ( $h{$r} --||++ $m xor -1)\n\t\t) > $m and $m = $c\n\tfor <>;\n\t\nprint 0 + $m"}, {"source_code": "<>;\nfor(<>){\n\t($s, $r) = split;\n\t$s eq '+' ? (++ $h{$r}, ++ $c)\n\t\t: $h{$r} //++ $m && -- $c or delete $h{$r};\n\t$c > $m and $m = $c\n\t}\nprint 0 + $m"}], "src_uid": "6cfd3b0a403212ec68bac1667bce9ef1"}
{"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n", "positive_code": [{"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n = <>;\nchomp $n;\n\nmy $moves_s = <>;\nchomp $moves_s;\nmy @moves = split(//, $moves_s);\n\nmy $res = 0;\n\nfor (my $i = 0; $i <= $#moves; $i += $n) {\n  if ($i >= 4) {\n    if ($moves[$i-3] eq $moves[$i-2]\n      && $moves[$i-2] eq $moves[$i-1]) {\n      $res++;\n    }\n  }\n}\n\nprint \"$res\\n\";\n"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "while ($n=<>) {\n    chomp ($n);\n    $_=<>;\n    chomp;\n    s/.//;\n    $i=0;\n    while (s/.{$n}//){\n        $a=$&;\n        $a=~s/.$//;\n   #     print \" $a\\n\";\n        $a=~/aaa$|bbb$/ and $i++\n        }\n    print \"$i\\n\"\n    }"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0\n"}, {"source_code": "$n=<>;$s=<>;$t+=substr($s,$i-3,3)=~/aaa|bbb/ while(($i+=$n)+1<length($s));print$t||0"}, {"source_code": "$n=<>;@a=split'',<>;$i+=$n and$t+=(join'',@a[$i-3..$i-1])=~/aaa|bbb/?1:0 while($i+$n+1<@a);print$t||0"}], "negative_code": [{"source_code": "$n=<>;@a=split'',<>;$i+=$n and$t+=(join'',@a[$i-3..$i-1])=~/aaa|bbb/?1:0 while($i+$n+1<@a);print$t"}, {"source_code": "while ($n=<>) {\n    chomp ($n);\n    $_=<>;\n    chomp;\n    s/.//;\n    $i=0;\n    while (s/.{$n}//){\n        $a=$&;\n        $a=~s/.$//;\n   #     print \" $a\\n\";\n        $a eq \"aaa\" || $a eq \"bbb\" and $i++\n        }\n    print \"$i\\n\"\n    }"}], "src_uid": "5606799ab5345bb9501fa6535e5abef9"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = grep $_ <= 2048, split ' ', <>;\n\t\n\tmy %h;\n\t\n\tmap { $h{ $_ } ++ } @_;\n\t\n\tmy $ok = 0;\n\t\n\tfor my $i ( 0 .. 11 ){\n\t\t$h{ 2 ** $i } //= 0;\n\t\t$h{ 2048 } and $ok = 1;\n\t\t$h{ 2 ** ( $i + 1 ) } += ( $h{ 2 ** $i } >> 1 );\n\t\t}\n\t\n\tprint $ok ? \"YES\" : \"NO\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>; chomp $n;\nmy $rB = [];\nfor my $j ( 1 .. $n ) {\n   my $a = <STDIN>; chomp $a;\n   my $str = <STDIN>; my @r = split(/\\s+/, $str);\n   pop @r unless ( $#r+1 eq $a );\n   $rB->[$j] = \\@r;\n}\nfor my $j ( 1 .. $n ) {\n    my @q = sort { $a <=> $b } @{ $rB->[$j] };\n    my $change = 1; my $flag = 0;\n    while ( $change eq 1 ) {\n     @q = sort { $a <=> $b } @q;\n     $change = 0;\n     $flag = 1 if ( $q[$#q] eq \"2048\" );\n     if ( $flag eq 0 ) {\n     for my $t ( 0 .. $#q - 1 ) {\n        if ( $q[$t] eq \"2048\" ) {\n            $flag = 1; last;\n        }\n        if ( $q[$t] eq $q[$t+1] ) {\n            $change = 1;\n            $q[$t] = 2*$q[$t];\n            for my $p ( $t + 1 .. $#q - 1 ) {\n               $q[$p] = $q[$p+1];\n            }\n            pop @q;\n            if ( $q[$t] eq \"2048\" ) {\n                $flag = 1; last;\n            }\n            last;\n        }\n     }\n     }\n     last if ( $flag eq 1 );\n    }\n    if ( $flag eq 1 ) { print \"YES\\n\";\n    } else { print \"NO\\n\"; }\n}\n"}], "negative_code": [{"source_code": "my $n = <STDIN>; chomp $n;\nmy $rB = [];\nfor my $j ( 1 .. $n ) {\n   my $a = <STDIN>; chomp $a;\n   my $str = <STDIN>; my @r = split(/\\s+/, $str);\n   pop @r unless ( $#r+1 eq $a );\n   $rB->[$j] = \\@r;\n}\nfor my $j ( 1 .. $n ) {\n    my @q = sort { $a <=> $b } @{ $rB->[$j] };\n    my $change = 1; my $flag = 0;\n    while ( $change eq 1 ) {\n     $change = 0;\n     $flag = 1 if ( $q[$#q] eq \"2048\" );\n     if ( $flag eq 0 ) {\n     for my $t ( 0 .. $#q - 1 ) {\n        if ( $q[$t] eq \"2048\" ) {\n            $flag = 1; last;\n        }\n        if ( $q[$t] eq $q[$t+1] ) {\n            $change = 1;\n            $q[$t] = 2*$q[$t];\n            for my $p ( $t + 1 .. $#q - 1 ) {\n               $q[$p] = $q[$p+1];\n            }\n            pop @q;\n            if ( $q[$t] eq \"2048\" ) {\n                $flag = 1; last;\n            }\n            last;\n        }\n     }\n     }\n     last if ( $flag eq 1 );\n    }\n    if ( $flag eq 1 ) { print \"YES\\n\";\n    } else { print \"NO\\n\"; }\n}\n"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>; chomp $n;\nmy $rB = [];\nfor my $j ( 1 .. $n ) {\n   my $a = <STDIN>; chomp $a;\n   my $str = <STDIN>; my @r = split(/\\s+/, $str);\n   pop @r unless ( $#r+1 eq $a );\n   $rB->[$j] = \\@r;\n}\nfor my $j ( 1 .. $n ) {\n    my @q = sort { $a <=> $b } @{ $rB->[$j] };\n    my $change = 1; my $flag = 0;\n    while ( $change eq 1 ) {\n     $change = 0;\n     $flag = 1 if ( $q[$#q] eq \"2048\" );\n     for my $t ( 0 .. $#q - 1 ) {\n        if ( $q[$t] eq \"2048\" ) {\n            $flag = 1; last;\n        }\n        if ( $q[$t] eq $q[$t+1] ) {\n            $change = 1;\n            $q[$t] = 2*$q[$t];\n            for my $p ( $t + 1 .. $#q - 1 ) {\n               $q[$p] = $q[$p+1];\n            }\n            pop @q;\n            if ( $q[$t] eq \"2048\" ) {\n                $flag = 1; last;\n            }\n            last;\n        }\n     }\n     last if ( $flag eq 1 );\n    }\n    if ( $flag eq 1 ) { print \"YES\\n\";\n    } else { print \"NO\\n\"; }\n}\n\n"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\n\nmy $n = <STDIN>; chomp $n;\nmy $rA = []; my $rB = [];\nfor my $j ( 1 .. $n ) {\n   $rA->[$j] = <STDIN>;\n   my $str = <STDIN>; my @r = split(/\\s+/, $str);\n   $rB->[$j] = \\@r;\n}\nfor my $j ( 1 .. $n ) {\n    my @q = sort { $a <=> $b } @{ $rB->[$j] };\n    my $change = 1; my $flag = 0;\n    while ( $change eq 1 ) {\n     $change = 0;\n     $flag = 1 if ( $q[$#q] eq \"2048\" );\n     for my $t ( 0 .. $#q - 1 ) {\n        if ( $q[$t] eq \"2048\" ) {\n            $flag = 1; last;\n        }\n        if ( $q[$t] eq $q[$t+1] ) {\n            $change = 1;\n            $q[$t] = 2*$q[$t];\n            for my $p ( $t + 1 .. $#q - 1 ) {\n               $q[$p] = $q[$p+1];\n            }\n            pop @q;\n            if ( $q[$t] eq \"2048\" ) {\n                $flag = 1; last;\n            }\n            last;\n        }\n     }\n     last if ( $flag eq 1 );\n    }\n    if ( $flag eq 1 ) { print \"YES\\n\";\n    } else { print \"NO\\n\"; }\n}\n"}], "src_uid": "b40059fe9cbdb0cc3b64c3e463900849"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nW1:\r\nwhile(<>){\r\n\t( $n, $m, @A, $k, $p ) = split;\r\n\t\r\n\t@_ = map ~~<>, 1 .. $n;\r\n\tchomp @_;\r\n\t\r\n\tpush @A, [ split // ] for @_;\r\n\t\r\n\tfor $i ( 0 .. $n - 1 ){\r\n\t\tfor $j ( $i + 1 .. $n - 1 ){\r\n\t\t\tif( $A[ $i ][ $j ] eq $A[ $j ][ $i ] ){\r\n\t\t\t\tprint for 'YES', join ' ', \r\n\t\t\t\t\t( ( $i + 1, $j + 1 ) x $m )[ 0 .. $m ];\r\n\t\t\t\tnext W1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tif( $m % 2 ){\r\n\t\t$n < 4 and $p = join ' ', ( ( 1 .. $n ) x $m )[ 0 .. $m ];\r\n\t\t\r\n\t\tfor( @_ ){\r\n\t\t\t$k ++;\r\n\t\t\tnext if ! m/(.).*\\1/;\r\n\t\t\t$p = join ' ', \r\n\t\t\t\t$k, ( $+[ 1 ], $k ) x ( $m >> 1 ), $+[ 0 ];\r\n\t\t\tlast;\r\n\t\t\t}\r\n\t\t}\r\n\telse{\r\n\t\tfor( @_ ){\r\n\t\t\t$k ++;\r\n\t\t\tnext if 1\r\n\t\t\t\t&& ! m/(a).*b/\r\n\t\t\t\t&& ! m/(b).*a/\r\n\t\t\t\t;\r\n\t\t\t$m /= 2;\r\n\t\t\t$p = join ' ', ( ( map { $k, $_ } @+ ) x $m )\r\n\t\t\t\t[ 0 + $m % 2 .. 2 * $m + $m % 2 ];\r\n\t\t\tlast;\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tprint $p ? \"YES\\n$p\" : \"NO\";\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $m ) = split;\n\t\n\t@_ = map ~~<>, 1 .. $n;\n\tchomp @_;\n\t\n\t$debug and print \"n:[$n], m:[$m]\";\n\t$debug and print for @_;\n\t\n\tmy @A;\n\t\n\tfor( @_ ){\n\t\tpush @A, [ split // ];\n\t\t}\n\t\n\tmy $eq;\n\t\n\tOUTER:\n\tfor my $i ( 0 .. $n - 1 ){\n\t\tfor my $j ( $i .. $n - 1 ){\n\t\t\tnext if $i == $j;\n\t\t\tif( $A[ $i ][ $j ] eq $A[ $j ][ $i ] ){\n\t\t\t\t$eq = [ map $_ + 1, $i, $j ];\n\t\t\t\tlast OUTER;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\n\tif( defined $eq ){\n\t\t$debug and print \"\\@{ \\$eq }:[@{ $eq }]\";\n\t\tprint 'YES';\n\t\tprint join ' ', ( ( @{ $eq } ) x $m )[ 0 .. $m ];\n\t\tnext;\n\t\t}\n\t\n\tif( $m % 2 == 1 ){\n\t\tif( grep { m/(.).*\\1/ } @_ ){\n\t\t\tfor my $i ( 0 .. @_ - 1 ){\n\t\t\t\tnext if $_[ $i ] !~ m/(.).*\\1/;\n\t\t\t\tprint 'YES';\n\t\t\t\tprint join ' ', $i + 1, ( $+[ 1 ], $i + 1 ) x ( $m >> 1 ), $+[ 0 ];\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\telsif( $n <= 3 ){\n\t\t\tprint 'YES';\n\t\t\tprint join ' ', ( ( 1 .. $n ) x $m )[ 0 .. $m - 1 + 1 ];\n\t\t\t}\n\t\telse{\n\t\t\t\"impossible?\";\n\t\t\t}\n\t\t}\n\telse{\n\t\tif( grep { m/a.*b/ or m/b.*a/ } @_ ){\n\t\t\tfor my $i ( 0 .. @_ - 1 ){\n\t\t\t\tnext if 1\n\t\t\t\t\t&& $_[ $i ] !~ m/(a).*b/\n\t\t\t\t\t&& $_[ $i ] !~ m/(b).*a/\n\t\t\t\t\t;\n\t\t\t\tprint 'YES';\n\t\t\t\tprint join ' ', ( ( $i + 1, $+[ 1 ], $i + 1, $+[ 0 ] ) \n\t\t\t\t\tx ( $m >> 1 ) )[ 0 + !!( $m % 4 ) .. $m - 1 + 1 + !!( $m % 4 ) ];\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\telsif( $n == 2 ){\n\t\t\tprint 'NO';\n\t\t\t}\n\t\telse{\n\t\t\t\"impossible?\";\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "79b629047e674883a9bc04b1bf0b7f09"}
{"source_code": "$\\ = $/;\n<>;\n$_ = <>, chomp;\n@_ = split //;\n%h = map { $_, 0 } @_;\n$H = keys %h;\n$j = 0;\n$min = 1e10;\nfor $i (0 .. @_-1){\n    $g{ $_[$i] } ++;\n\n    while( $g{ $_[$j] } > 1){\n        $g{ $_[$j ++] } --;\n    }\n    ($H == grep $_, values %g)\n    and $min > $i - $j + 1\n    and $min = $i - $j + 1;\n}\nprint $min", "positive_code": [{"source_code": "use strict;\nour ($n, @c1, @c2, $C1, $C2, @f1, @f2, $F1, $F2, $start, $end, $minval);\n\nsub input {\n\t($n,my $s)=<>; chomp($s, $n); my @c=split //, $s; @c = map ord, @c;\n\tmy ($a, $A, $Z) = (ord(\"a\"), ord(\"A\"), ord(\"Z\"));\n\tmy ($c1, $c2);\n\t$C1 = $C2 = $F1 = $F2 = 1;\n\tfor (@c) {\n\t\tif ($_ <= $Z) {\n\t\t\t$c1 = $_-$A+1; $c2 = 0;\n\t\t} else {\n\t\t\t$c2 = $_-$a+1; $c1 = 0;\n\t\t}\n\t\tpush @c1, $c1; push @c2, $c2;\n\t\t$C1 |= 1 << $c1;\n\t\t$C2 |= 1 << $c2;\n\t}\n}\n\nsub min { $_[0] < $_[1]? $_[0]: $_[1] }\n\nsub adv_end {\n\t$end++;\n\tmy $v;\n\t$v = $c1[$end]; $f1[$v]++; $F1 |= 1 << $v;\n\t$v = $c2[$end]; $f2[$v]++; $F2 |= 1 << $v;\n}\n\nsub adv_start {\n\tmy $v;\n\t$v = $c1[$start]; if ($v) { $f1[$v]--; $F1 &= ~(1 << $v) if $f1[$v]==0 }\n\t$v = $c2[$start]; if ($v) { $f2[$v]--; $F2 &= ~(1 << $v) if $f2[$v]==0 }\n\t$start++;\n}\n\nsub has_all {\n\t$F1==$C1 && $F2==$C2;\n}\n\nsub calc_min {\n\t$minval = min($minval, $end - $start + 1);\n}\n\nsub iter {\n\t$start = 0; $end = -1; $minval = $n;\n\twhile ($start < $n - 1) {\n\t\tif (!has_all) {\n\t\t\twhile ($end < $n - 1) {\n\t\t\t\tadv_end;\n\t\t\t\tif (has_all) {\n\t\t\t\t\tcalc_min;\n\t\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tadv_start; calc_min if has_all;\n\t}\n}\n\ninput(); iter();\nprint $minval, \"\\n\";\n"}], "negative_code": [{"source_code": "use strict;\nour ($n, @c1, @c2, $C1, $C2, @f1, @f2, $F1, $F2, $start, $end, $minval);\n\nsub input {\n\t($n,my $s)=<>; chomp($s, $n); my @c=split //, $s; @c = map ord, @c;\n\tmy ($a, $A, $Z) = (ord(\"a\"), ord(\"A\"), ord(\"Z\"));\n\tmy ($c1, $c2);\n\tfor (@c) {\n\t\tif ($_ <= $Z) {\n\t\t\t$c1 = $_-$A+1; $c2 = 0;\n\t\t} else {\n\t\t\t$c2 = $_-$a+1; $c1 = 0;\n\t\t}\n\t\tpush @c1, $c1; push @c2, $c2;\n\t\t$C1 |= 1 << $c1;\n\t\t$C2 |= 1 << $c2;\n\t}\n}\n\nsub min { $_[0] < $_[1]? $_[0]: $_[1] }\n\nsub adv_end {\n\t$end++;\n\tmy $v;\n\t$v = $c1[$end]; $f1[$v]++; $F1 |= 1 << $v;\n\t$v = $c2[$end]; $f2[$v]++; $F2 |= 1 << $v;\n}\n\nsub adv_start {\n\tmy $v;\n\t$v = $c1[$start]; if ($v) { $f1[$v]--; $F1 &= ~(1 << $v) if $f1[$v]==0 }\n\t$v = $c2[$start]; if ($v) { $f2[$v]--; $F2 &= ~(1 << $v) if $f2[$v]==0 }\n\t$start++;\n}\n\nsub has_all {\n\t$F1==$C1 && $F2==$C2;\n}\n\nsub calc_min {\n\t$minval = min($minval, $end - $start + 1);\n}\n\nsub iter {\n\t$start = 0; $end = -1; $minval = $n;\n\twhile ($start < $n - 1) {\n\t\twhile ($end < $n - 1) {\n\t\t\tadv_end;\n\t\t\tif (has_all) {\n\t\t\t\tcalc_min;\n\t\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\tadv_start; calc_min if has_all;\n\t}\n}\n\ninput(); iter();\nprint $minval, \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\n$\\ = $/;\n<>;\n$_ = <>, chomp;\n@_ = split //;\n%h = map { $_, 0 } @_;\n$H = keys %h;\n$j = 0;\n$min = 1e10;\nfor $i (0 .. @_-1){\n    $g{ $_[$i] } ++;\n    for ( ; $H == keys %g ; $j ++ ){\n        $min > $i - $j + 1 and $min = $i - $j + 1;\n        -- $g{ $_[$j] } or do { delete $g{ $_[$j] }; last };\n    }\n}\nprint \"$min\";\n"}], "src_uid": "60776cefd6c1a2f3c16b3378ebc31a9a"}
{"source_code": "<>;\n$_ = <>;\n\nmap $h[ $_ ] ++, @_ = split;\n\n$j ++;\n\nfor $i (@_){\n\t\n\tpush @a, $i > @_ || $h[ $i ] --> 1 ? do {\n\t\t\tNOP while $h[ $j ++ ] =~ /./;\n\t\t\t++ $h[ -- $j ];\n\t\t\t$j\n\t\t}\n\t\t:\t$i\n\t\n\t}\n\nprint \"@a\"", "positive_code": [{"source_code": "$n = <>;\n$_ = <>;\n@_ = split;\n\nmap $h{ $_ } ++, @_;\n\n$j = 0;\n$h{ $j } = Not_important;\n\nfor $i (@_){\n\t\n\tpush @a, $i > $n || $h{ $i } --> 1 ? do {\n\t\twhile ( exists $h{ $j } ){\n\t\t\t$j ++\n\t\t\t}\n\t\t\t++ $h{ $j } and $j\n\t\t}\n\t\t:\t$i\n\t\n\t}\n\nprint \"@a\""}], "negative_code": [], "src_uid": "1cfd0e6504bba7db9ec79e2f243b99b4"}
{"source_code": "my $n = <STDIN>;\n\nmy $FIN = <STDIN>;\nmy ($x0, $y0) = split(/ /, $FIN);\n\nmy @figures = [];\nfor my $i (0..$n-1)\t{\n\tmy $line = <STDIN>;\n\tmy @figure = split(/ /, $line);\n\t$figures[$i] = \\@figure;\n}\nmy $min = -1e10;\nmy $minS = '';\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = -1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] < $x0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] > $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n\n\n$min = -1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = -1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e10;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\nprint 'NO';\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $X, $Y ) = split ' ', <>;\n\t\t\n\tmy $check = 0;\n\n\tmy @top = (~0) x 5;\n\tmy @bot = (-~0) x 5;\n\tmy @topF;\n\tmy @botF;\n\t\n\tfor (1 .. $_){\n\t\tmy( $fig, $x, $y ) = split ' ', <>;\n\t\t\n\t\tmy $D = $x == $X ? 1 :\n\t\t\t$y == $Y ? 2 :\n\t\t\t$x + $y == $X + $Y ? 3 :\n\t\t\t$x - $X == $y - $Y ? 4 : 0;\n\t\t\t\n\t\t$D or next;\n\t\tmy $M = $X;\n\t\t$D == 1 and do { $x = $y ; $M = $Y };\n\t\t\n\t\tif( $x > $M and $x < $top[$D]){\n\t\t\t$top[$D] = $x;\n\t\t\t$topF[$D] = $fig;\n\t\t\t}\n\t\tif( $x < $M and $x > $bot[$D]){\n\t\t\t$bot[$D] = $x;\n\t\t\t$botF[$D] = $fig;\n\t\t\t}\t\t\n\t\t}\n\t\t\n\t$check += grep /[QR]/, grep defined, @topF[1,2], @botF[1,2];\n\t$check += grep /[QB]/, grep defined, @topF[3,4], @botF[3,4];\n\t\n\tprint $check ? \"YES\" : \"NO\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $X, $Y ) = split ' ', <>;\n\t\n\tmy( @X, @Y, @a8h1, @a1h8 );\n\t\n\tfor (1 .. $_){\n\t\tmy( $fig, $x, $y ) = split ' ', <>;\n\t\t\n\t\tif( $x == $X ){\n\t\t\tpush @X, [$fig, $x, $y];\n\t\t\t}\n\t\tif( $y == $Y ){\n\t\t\tpush @Y, [$fig, $x, $y];\n\t\t\t}\n\t\tif( $x + $y == $X + $Y ){\n\t\t\tpush @a8h1, [$fig, $x, $y];\n\t\t\t}\n\t\tif( $x - $X == $y - $Y ){\n\t\t\tpush @a1h8, [$fig, $x, $y];\n\t\t\t}\t\t\n\t\t}\n\n\tmy $check = 0;\n\n\tmy $top = ~0;\n\tmy $bottom = -~0;\n\tmy $topFig;\n\tmy $bottomFig;\n\t\n\tfor( @X ){\n\t\tif( $_->[2] > $Y and $_->[2] < $top){\n\t\t\t$top = $_->[2];\n\t\t\t$topFig = $_->[0];\n\t\t\t}\n\t\tif( $_->[2] < $Y and $_->[2] > $bottom){\n\t\t\t$bottom = $_->[2];\n\t\t\t$bottomFig = $_->[0];\n\t\t\t}\t\t\n\t\t}\n\t\t\n\t$check += grep /[QR]/, grep defined, $topFig, $bottomFig;\n\t\n#\tprint \"check X: $check\";\n\t\n\t\n\tmy $top = ~0;\n\tmy $bottom = -~0;\n\tmy $topFig;\n\tmy $bottomFig;\n\t\n\tfor( @Y ){\n\t\tif( $_->[1] > $X and $_->[1] < $top){\n\t\t\t$top = $_->[1];\n\t\t\t$topFig = $_->[0];\n\t\t\t}\n\t\tif( $_->[1] < $X and $_->[1] > $bottom){\n\t\t\t$bottom = $_->[1];\n\t\t\t$bottomFig = $_->[0];\n\t\t\t}\t\t\n\t\t}\n\t\t\n\t$check += grep /[QR]/, grep defined, $topFig, $bottomFig;\n\t\n#\tprint \"check Y: $check\";\n\t\n\t\n\tmy $top = ~0;\n\tmy $bottom = -~0;\n\tmy $topFig;\n\tmy $bottomFig;\n\t\n\tfor( @a8h1 ){\n\t\tif( $_->[1] > $X and $_->[1] < $top){\n\t\t\t$top = $_->[1];\n\t\t\t$topFig = $_->[0];\n\t\t\t}\n\t\tif( $_->[1] < $X and $_->[1] > $bottom){\n\t\t\t$bottom = $_->[1];\n\t\t\t$bottomFig = $_->[0];\n\t\t\t}\t\t\n\t\t}\n\t\t\n\t$check += grep /[QB]/, grep defined, $topFig, $bottomFig;\n\t\n#\tprint \"check a8h1: $check\";\n\t\n\n\tmy $top = ~0;\n\tmy $bottom = -~0;\n\tmy $topFig;\n\tmy $bottomFig;\n\t\n\tfor( @a1h8 ){\n\t\tif( $_->[1] > $X and $_->[1] < $top){\n\t\t\t$top = $_->[1];\n\t\t\t$topFig = $_->[0];\n\t\t\t}\n\t\tif( $_->[1] < $X and $_->[1] > $bottom){\n\t\t\t$bottom = $_->[1];\n\t\t\t$bottomFig = $_->[0];\n\t\t\t}\t\t\n\t\t}\n\t\t\n\t$check += grep /[QB]/, grep defined, $topFig, $bottomFig;\n\t\n#\tprint \"check a1h8: $check\";\n\t\n\tprint $check ? \"YES\" : \"NO\";\n}\n"}], "negative_code": [{"source_code": "my $n = <STDIN>;\n\nmy $FIN = <STDIN>;\nmy ($x0, $y0) = split(/ /, $FIN);\n\nmy @figures = [];\nfor my $i (0..$n-1)\t{\n\tmy $line = <STDIN>;\n\tmy @figure = split(/ /, $line);\n\t$figures[$i] = \\@figure;\n}\nmy $min = -1e9;\nmy $minS = '';\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = -1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] < $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] > $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n\n\n$min = -1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = -1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n$minS = '';\nprint 'NO';\n"}, {"source_code": "my $n = <STDIN>;\n\nmy $FIN = <STDIN>;\nmy ($x0, $y0) = split(/ /, $FIN);\n\nmy @figures = [];\nfor my $i (0..$n-1)\t{\n\tmy $line = <STDIN>;\n\tmy @figure = split(/ /, $line);\n\t$figures[$i] = \\@figure;\n}\nmy $min = 0;\nmy $minS;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 0;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] < $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] > $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n\n\n$min = 0;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 0;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\nprint 'NO';\n"}, {"source_code": "my $n = <STDIN>;\n\nmy $FIN = <STDIN>;\nmy ($x0, $y0) = split(/ /, $FIN);\n\nmy @figures = [];\nfor my $i (0..$n-1)\t{\n\tmy $line = <STDIN>;\n\tmy @figure = split(/ /, $line);\n\t$figures[$i] = \\@figure;\n}\nmy $min = -1e9;\nmy $minS;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[1] == $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[2]) {\n\t\t\t$min = $figures[$i]->[2];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = -1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] < $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] == $y0 && $figures[$i]->[1] > $x0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'R' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n\n\n$min = -1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] - $figures[$i]->[1] == $y0 - $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = -1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] < $x0 && $figures[$i]->[2] > $y0) {\n\t\tif ($min < $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\n$min = 1e9;\nfor my $i (0..$n-1) {\n\tif ($figures[$i]->[2] + $figures[$i]->[1] == $y0 + $x0 && $figures[$i]->[1] > $x0 && $figures[$i]->[2] < $y0) {\n\t\tif ($min > $figures[$i]->[1]) {\n\t\t\t$min = $figures[$i]->[1];\n\t\t\t$minS = $figures[$i]->[0];\n\t\t}\n\t}\n}\nif ($minS eq 'B' || $minS eq 'Q') {\n\tprint 'YES';\n\texit;\n}\n\nprint 'NO';\n"}], "src_uid": "b389750613e9577b3abc9e5e5902b2db"}
{"source_code": "<>=~/ (\\d+) /;\n$c=($'*$`*$1 - $'*$`*$1 % 100) / 100;\n$c>=$1?($_.=\"$1 \",$c-=$1):($_.=\"$c \",$c=0) while $i++<$`;\nchop, print", "positive_code": [{"source_code": "<>=~/ (\\d+) /;\n\n$c=$'*$`*$1/100;\n$c%=$c+1;\n\nwhile ($i++<$`){\n$c>=$1?($_.=\"$1 \",$c-=$1):($_.=\"$c \",$c=0);\n}\nchop, print"}], "negative_code": [], "src_uid": "0ad96b6a8032d70df400bf2ad72174bf"}
{"source_code": "$n=<STDIN>;\n$_ = <STDIN>; @a=split;\n$prvval=-1;\n$cur=0;\n$curv=$a[0];\n$isok=1;\nforeach $x (@a)\n{\n    if($curv!=$x) {\n        if($prvval!=-1){\n            if($cur!=$prvval) {\n                $isok = 0;\n            }\n        }\n        $prvval = $cur;\n        $cur = 0;\n        $curv = $x;\n \n    }\n    $cur=$cur+1;\n}\n\nif($prvval!=-1){\n    if($cur!=$prvval) {\n        $isok = 0;\n    }\n}\n\nif($isok==1){\n    print \"YES\";\n}\nelse\n{\n    print \"NO\";\n}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\n\nmy $N = <>+0;\nmy $line = <>;\nchomp $line;\n$line =~ s/ +//g;\n$line =~ s/01/0#1/g;\n$line =~ s/10/1#0/g;\n\n#print $line, \"\\n\";\n\nmy @A = split '#', $line;\n\nmy $M = scalar(@A);\nfor (my $i = 1; $i < $M; ++$i) {\n   if (length($A[$i]) != length($A[0])) {\n      print \"NO\\n\";\n      exit(0);\n   }\n}\n\nprint \"YES\\n\";\n"}, {"source_code": "$t = <>;\n@arr = split(/\\s+/, <>);\n\n$slc = 0;\n$a = 0;\n\nfor (my $i = 0; $i < (scalar @arr) - 1; $i++) {\n  if (@arr[$i] != @arr[$i + 1]) {\n    if ($a == 0) {\n      $a = $i + 1;\n    } else {\n      if ($i - $slc != $a) {\n        print \"NO\";\n        exit;\n      }\n    }\n    $slc = $i;\n  }\n}\n\nif ((scalar @arr) - $slc - 1 != $a && $a != 0) {\n  print \"NO\";\n  exit;\n}\n\nprint \"YES\";\n"}, {"source_code": "$n = <STDIN>;\n@bits = split / /, <STDIN>;\n\n$first = @bits[0];\n$mb_len = 1;\n$mb_len_done = 0;\n\nfor ($curr = 1; $curr < $n; $curr++) {\n\tif (@bits[$curr] != @bits[$curr-1]) {\n\t\t$mb_len_done = 1;\n\t}\n\tif (!$mb_len_done) {\n\t\t$mb_len += 1;\n\t}\n}\n\nif ($mb_len == $n) {\n\tprint \"Yes\";\n\texit();\n}\n\n$result = 1; # true\n$curr_color = $first;\n$last = 0;\n\nfor ($i = 0; $i < $n;) {\n\t$last = 0;\n\tfor ($j = 0; $j < $mb_len && $i < $n; $j++) {\n\t\t$last += 1;\n\t\tif ($curr_color != @bits[$i]) {\n\t\t\t$result = 0;\t\t\t\n\t\t}\n\t\t$i += 1;\n\t}\n\t$curr_color = ($curr_color + 1) % 2;\n}\n\nif ($result && $last == $mb_len) {\n\tprint \"Yes\";\n} else {\n\tprint \"No\";\n}"}, {"source_code": "$n = <STDIN>;\n$string = <STDIN>;\n \n@a = split(//, $string);\n$i = 2;\n$cur = @a[0];\n$f = 5;\n$ans = 1;\n$prev_c = 1;\n$now_c = 0;\nwhile ($n > 1) {\n    $n = $n - 1;\n    if ($f == 5) {\n        if (@a[$i] == $cur) {\n            $prev_c = $prev_c + 1;\n        }\n        else {\n            $now_c = 1;\n            $f = 0;\n            $cur = @a[$i];\n        }\n    } else {\n        if (@a[$i] == $cur) {\n            $now_c = $now_c + 1;\n        } else {\n            if ($now_c != $prev_c) {\n                $ans = 0;\n            }\n            else {\n                $prev_c = $now_c;\n                $now_c = 1;\n                $cur = @a[$i];\n            }\n        }\n        \n    }\n    $i = $i + 2;\n}\nif ($now_c != 0) {\n        if ($now_c != $prev_c) {\n        $ans = 0;\n    }\n}\n\nif ($ans == 1) {\n    print \"YES\";\n} else {\n    print \"NO\";\n}"}], "negative_code": [], "src_uid": "75a00d8a614fd0bcb8504b0268a121e0"}
{"source_code": "chomp(my $t = <STDIN>);\nforeach (1..$t)\n{\n    my @a = split /\\s+/, <STDIN>;\n    my @x = sort { $b <=> $a } @a;\n    if ($x[0] != $x[1])\n    {\n        print \"NO\\n\";\n    }\n    else\n    {\n        my ($a, $b) = ($x[0], $x[2]);\n        print \"YES\\n$a $b $b\\n\";\n    }\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy ($t) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nfor( my $t_loop=0; $t_loop<$t; $t_loop++ ){\n  \n  my @x = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  $#x = 2;\n  my @sx = sort { $b <=> $a } @x;\n  \n  if( $sx[0] != $sx[1] ){\n    print \"NO\\n\";\n    next;\n  }\n  \n  my $a = $sx[0];\n  my $b = $sx[2];\n  print \"YES\\n\";\n  print \"$a $b $b\\n\";\n  \n}\n\nexit(0);\n\n"}], "negative_code": [{"source_code": "chomp(my $t = <STDIN>);\nprint $t;\nforeach (1..$t)\n{\n    my @a = split /\\s+/, <STDIN>;\n    my @x = sort { $b <=> $a } @a;\n    if ($x[0] != $x[1])\n    {\n        print \"NO\\n\";\n    }\n    else\n    {\n        my ($a, $b) = ($x[0], $x[2]);\n        print \"YES\\n$a $b $b\\n\";\n    }\n}"}], "src_uid": "f4804780d9c63167746132c35b2bdd02"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\tmy @q;\n\t\n\tfor( @_ ){\n\t\tnext if exists $h{ $_ };\n\t\t\n\t\tif( $k == @q ){\n\t\t\tmy $del = shift @q;\n\t\t\tdelete $h{ $del };\n\t\t\t}\n\t\t\n\t\tpush @q, $_;\n\t\t$h{ $_ } = 1;\n\t\t}\n\t\n\tprint ~~ @q;\n\tprint join ' ', reverse @q;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n   \nchomp (my $line = <STDIN>);\n\nmy ($n, $k) = split q{ }, $line;\n\nmy @inputs = split q{ }, <STDIN>;\n\nmy $set = {};\nmy @answer = ();\n\nfor my $input ( @inputs ) {\n    if ( defined $set->{$input} ) {\n        next;\n    }\n    else {\n        if ( @answer == $k ) {\n            my $id = shift @answer;\n            delete $set->{$id};\n        }\n        push @answer, $input;\n        $set->{$input} = 1;\n    }\n}\n\nsay scalar @answer;\n@answer = reverse @answer;\nsay \"@answer\";\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\tmy @q;\n\t\n\tfor( @_ ){\n\t\tnext if exists $h{ $_ };\n\t\t\n\t\tif( $k == @q ){\n\t\t\tmy $del = shift @q;\n\t\t\tdelete $h{ $del };\n\t\t\t}\n\t\t\n\t\tpush @q, $_;\n\t\t$h{ $_ } = 1;\n\t\t}\n\t\n\tprint ~~ @q;\n\tprint join ' ', reverse @q;\n\t}"}, {"source_code": "#!/usr/bin/env perl\n\nmy ($messages, $limit) = split /\\s/, <>;\nmy @IDs   = split /\\s/, <>;\nmy @shown = ();\n\nfor my $id (@IDs) {\n    unless (grep { $_ == $id } @shown ) {\n        pop @shown unless @shown < $limit;\n        unshift @shown, $id;\n    }\n}\n\n$\\ = \"\\n\";\nprint scalar @shown;\nprint join(\" \", @shown);"}], "negative_code": [], "src_uid": "485a1ecf8f569b85327b99382bda9466"}
{"source_code": "<>;\n\n$M = ~0;\n\nwhile( <> ){\n\t( $A, $B ) = sort { $b <=> $a } split;\n\t$A = $B if $A > $M;\n\t$f += $A > $M;\n\t$M = $A;\n\t}\n\nprint $f ? \"NO\" : \"YES\"", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $max = ~0;\n\tmy $f = 0;\n\t\n\tfor( 1 .. $_ ){\n\t\tmy( $A, $B ) = sort { $b <=> $a } split ' ', <>;\n\t\tif( $A > $max ){ $A = $B; }\n\t\tif( $A > $max ){ $f ++; }\n\t\t$max = $A;\n\t\t}\n\t\n\tprint $f ? \"NO\" : \"YES\";\n\t}"}], "negative_code": [], "src_uid": "162fa942bc6eeb5164b19598da2f8bef"}
{"source_code": "<>;\n\n$_ = <>;\n\n0 while 0 ||\n\ts/\\b(\\d+)A\\b.*?\\b\\1\\b\\K/A/ ||\n\ts/\\b(\\d+)\\b\\K(.*?\\b\\1\\b)/A$2/ ||\n\t0;\n\n( () = /\\d\\b/g ) % 2 and s/\\b(\\d+)A\\b.*\\b\\1A\\b.*\\b\\1\\KA\\b/B/ || $f ++;\n\n0 while 0 ||\n\ts/\\b(\\d+)\\b\\K/ qw( A B )[ $i ++ % 2 ] /e ||\n\t0;\n\nprint $f ? \"NO\\n\" : \"YES\\n\" . y/ 0-9//dr", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy %h;\n\t\n\t$h{ $_ } ++ for @_;\n\t\n\tmy %ones;\n\tmy %twos;\n\tmy %mores;\n\t\n\tfor( keys %h ){\n\t\tif( $h{ $_ } == 1 ){\n\t\t\t$ones{ $_ } = 1;\n\t\t\t}\n\t\telsif( $h{ $_ } == 2 ){\n\t\t\t$twos{ $_ } = 1;\n\t\t\t}\n\t\telse{\n\t\t\t$mores{ $_ } = 1;\n\t\t\t}\n\t\t}\n\t\n\tmy %convert;\n\t\n\tfor( keys %twos ){\n\t\t$convert{ $_ } = 'A';\n\t\t}\n\t\n\tfor( keys %mores ){\n\t\t$convert{ $_ } = 'A';\n\t\t}\n\t\n\tif( ( keys %ones ) % 2 == 1 and 0 == keys %mores ){\n\t\tprint \"NO\";\n\t\t}\n\telse{\n\t\tif( ( keys %ones ) % 2 == 1 ){\n\t\t\tmy $to_split = ( sort { $a <=> $b } keys %mores )[ 0 ];\n\t\t\t\n\t\t\tfor( @_ ){\n\t\t\t\t$_ == $to_split and do { $_ = 0 ; last; };\n\t\t\t\t}\n\t\t\t$ones{ 0 } = 1;\n\t\t\t}\n\t\t\n\t\tmy @ones = ( sort { $a <=> $b } keys %ones );\n\t\t\n\t\tfor my $i ( 0 .. @ones - 1 ){\n\t\t\t$convert{ $ones[ $i ] } = $i % 2 ? 'A' : 'B';\n\t\t\t}\n\t\t\n\t\tmy $ans = '';\n\t\t\n\t\tfor( @_ ){\n\t\t\t$ans .= $convert{ $_ };\n\t\t\t}\n\t\t\n\t\tprint \"YES\";\n\t\tprint $ans;\n\t\t}\n\t\n\t}"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=$j if($p[$j]>=3);\n}\nmy $l=0;\nmy %h=();\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\telse{\n\t    if($l<$q/2){\n\t\t$h{$i}=\"A\";\n\t\t$l++;\n\t    }\n\t    else {$h{$i}= \"B\"};\n\t}\n    }\n    print $h{$_} for(0..$#in);\n}\nelse{\n    if($t!=0){\n\tprint \"YES\\n\";\n\t$q++;\n\tmy $set=\"o\";\n\tfor my $i(0..$#in){\n\t    if($t==$in[$i]){\n\t\tif($set eq \"o\"){\n\t\t    $h{$i}=\"A\" if($l<$q/2);\n\t\t    $h{$i}=\"B\" if($l>=$q/2);\n\t\t    $l++;\n\t\t    $set=$h{$i};\n\t\t}\n\t\telse{\n\t\t    $h{$i}=($set eq \"A\")?\"B\":\"A\";\n\t\t}\n\t    }\n\t    else{\n\t\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\t\telse{\n\t\t    if($l<$q/2){\n\t\t\t$h{$i}= \"A\";\n\t\t\t$l++;\n\t\t    }\n\t\t    else{$h{$i}= \"B\";}\n\t\t}\n\t    }\n\t}\n\tprint $h{$_} for(0..$#in);\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}], "negative_code": [{"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=1 if($p[$j]>=3);\n}\nmy $l=0;\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($l<$q/2){\n\t    print \"A\";\n\t    $l++ if($p[$in[$i]]==1);\n\t}\n\telse {print \"B\"};\n    }\n}\nelse{\n    if($t==1){\n\tprint \"YES\\n\";\n\t$q++;\n\tfor my $i(0..$#in){\n\t    if($l<$q/2){\n\t\tprint \"A\";\n\t\t$l++ if($p[$in[$i]]==1);\n\t\tif($p[$in[$i]]>=3&&$t==1){\n\t\t    $l++;\n\t\t    $t=0;\n\t\t}\n\t    }\n\t    else{print \"B\";}\n\t}\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=$j if($p[$j]>=3);\n}\nmy $l=0;\nmy %h=();\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\telse{\n\t    if($l<$q/2){\n\t\t$h{$i}=\"A\";\n\t\t$l++;\n\t    }\n\t    else {$h{$i}= \"B\"};\n\t}\n    }\n    print $h{$_} for(0..$#in);\n}\nelse{\n    if($t!=0){\n\tprint \"YES\\n\";\n\t$q++;\n\tmy $set=0;\n\tfor my $i(0..$#in){\n\t    if($t==$in[$i]){\n\t\tif($set==0){\n\t\t    $h{$i}=\"A\" if($l<$q/2);\n\t\t    $h{$i}=\"B\" if($l>=$q/2);\n\t\t    $l++;\n\t\t    $set=$h{$i};\n\t\t}\n\t\telse{\n\t\t    $h{$i}=($set eq \"A\")?\"B\":\"A\";\n\t\t}\n\t    }\n\t    else{\n\t\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\t\telse{\n\t\t    if($l<$q/2){\n\t\t\t$h{$i}= \"A\";\n\t\t\t$l++;\n\t\t    }\n\t\t    else{$h{$i}= \"B\";}\n\t\t}\n\t    }\n\t}\n\tprint $h{$_} for(0..$#in);\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=1 if($p[$j]>=3);\n}\nmy $l=0;\nmy %h=();\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\telse{\n\t    if($l<$q/2){\n\t\t$h{$i}=\"A\";\n\t\t$l++;\n\t    }\n\t    else {$h{$i}= \"B\"};\n\t}\n    }\n    print values %h;\n}\nelse{\n    if($t==1){\n\tprint \"YES\\n\";\n\t$q++;\n\tfor my $i(0..$#in){\n\t    if($t==1&&$p[$in[$i]]>=3){$h{$i}=\"A\";$t=0;$l++;}\n\t    else{\n\t\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\t\telse{\n\t\t    if($l<$q/2){\n\t\t\t$h{$i}= \"A\";\n\t\t\t$l++;\n\t\t    }\n\t\t    else{$h{$i}= \"B\";}\n\t\t}\n\t    }\n\t}\n\tprint values %h;\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=1 if($p[$j]>=3);\n}\nmy $l=0;\nmy %h=();\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\telse{\n\t    if($l<$q/2){\n\t\t$h{$i}=\"A\";\n\t\t$l++;\n\t    }\n\t    else {$h{$i}= \"B\"};\n\t}\n    }\n    print $h{$_} for(0..$#in);\n}\nelse{\n    if($t==1){\n\tprint \"YES\\n\";\n\t$q++;\n\tfor my $i(0..$#in){\n\t    if($t==1&&$p[$in[$i]]>=3){\n\t\t$h{$i}=\"A\" if($l<$q/2);\n\t\t$h{$i}=\"B\" if($l>=$q/2);\n\t\t$t=0;$l++;\n\t    }\n\t    else{\n\t\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\t\telse{\n\t\t    if($l<$q/2){\n\t\t\t$h{$i}= \"A\";\n\t\t\t$l++;\n\t\t    }\n\t\t    else{$h{$i}= \"B\";}\n\t\t}\n\t    }\n\t}\n\tprint $h{$_} for(0..$#in);\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=$j if($p[$j]>=3);\n}\nmy $l=0;\nmy %h=();\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\telse{\n\t    if($l<$q/2){\n\t\t$h{$i}=\"A\";\n\t\t$l++;\n\t    }\n\t    else {$h{$i}= \"B\"};\n\t}\n    }\n    print $h{$_} for(0..$#in);\n}\nelse{\n    if($t!=0){\n\tprint \"YES\\n\";\n\t$q++;\n\tmy $set=0;\n\tfor my $i(0..$#in){\n\t    if($t==$in[$i]){\n\t\tif($set==0){\n\t\t    $h{$i}=\"A\" if($l<$q/2);\n\t\t    $h{$i}=\"B\" if($l>=$q/2);\n\t\t    $l++;\n\t\t    $set=1;\n\t\t}\n\t\telse{\n\t\t    $h{$i}=\"B\" if($l<$q/2);\n\t\t    $h{$i}=\"A\" if($l>=$q/2);\n\t\t}\n\t    }\n\t    else{\n\t\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\t\telse{\n\t\t    if($l<$q/2){\n\t\t\t$h{$i}= \"A\";\n\t\t\t$l++;\n\t\t    }\n\t\t    else{$h{$i}= \"B\";}\n\t\t}\n\t    }\n\t}\n\tprint $h{$_} for(0..$#in);\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=1 if($p[$j]>=3);\n}\nmy $l=0;\nmy %h=();\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\telse{\n\t    if($l<$q/2){\n\t\t$h{$i}=\"A\";\n\t\t$l++;\n\t    }\n\t    else {$h{$i}= \"B\"};\n\t}\n    }\n    print $h{$_} for(0..$#in);\n}\nelse{\n    if($t==1){\n\tprint \"YES\\n\";\n\t$q++;\n\tfor my $i(0..$#in){\n\t    if($t==1&&$p[$in[$i]]>=3){$h{$i}=\"A\";$t=0;$l++;}\n\t    else{\n\t\tif($p[$in[$i]]!=1){$h{$i}=\"B\";}\n\t\telse{\n\t\t    if($l<$q/2){\n\t\t\t$h{$i}= \"A\";\n\t\t\t$l++;\n\t\t    }\n\t\t    else{$h{$i}= \"B\";}\n\t\t}\n\t    }\n\t}\n\tprint $h{$_} for(0..$#in);\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}, {"source_code": "#!usr/bin/perl -w\nuse strict;\nuse integer;\n\nmy $n=<STDIN>;\nmy @in=split/ /,<STDIN>;chomp($n,$in[-1]);\nmy @p=()x100;my $r=join ' ',@in;my $q=0;my $t=0;\nfor my $j(1..100){\n    $p[$j]=($r=~s/\\b$j\\b//g);\n    ++$q if($p[$j]==1);\n    $t=1 if($p[$j]>=3);\n}\nif($q%2==0){\n    print \"YES\\n\";\n    for my $i(0..$#in){\n\tif($q>=$n/2){\n\t    print \"A\";\n\t    $q-- if($p[$in[$i]]==1);\n\t}\n\telse {print \"B\"};\n    }\n}\nelse{\n    if($t==1){\n\tprint \"YES\\n\";\n\t$q++;\n\tfor my $i(0..$#in){\n\t    if($q>=$n/2){\n\t\tprint \"A\";\n\t\t$q-- if($p[$in[$i]]==1);\n\t\tif($p[$in[$i]]>=3&&$t==1){\n\t\t    $q--;\n\t\t    $t=0;\n\t\t}\n\t    }\n\t    else{print \"B\";}\n\t}\n    }\n    else{print \"NO\";}\n}\nprint \"\\n\";"}], "src_uid": "d126ef6b94e9ab55624cf7f2a96c7ed1"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tmy( $line ) = ( '10' x 20 ) =~ /.{$m}/g;\n\t\n\t@_ = ( ( '0' x $m, '1' . '0' x ( $m - 2 ) . '1' ) x 20 )[ 0 .. $n - 1 - 2 ];\n\t\n\t$_[ @_ - 1 ] =~ y/1/0/ if $n % 2 == 0;\n\t\n\t@_ = ( $line, @_, $line );\n\t\n\tprint join \"\\n\", @_;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $n, $m ) = split;\r\n\t\r\n\tprint for \r\n\t\t( $_ ) = ( 10 x 10 ) =~ /.{$m}/g,\r\n\t\t( ( 0 x $m, 1 . 0 x ( $m - 2 ) . 1 ) x 11 )[ 4 .. $n, 0 ],\r\n\t\t$_;\r\n\t}"}, {"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\nuse integer;   ### important!\r\nmy $mod = 10 ** 9 + 7;\r\n# my $mod = 998244353;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($h,$w) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @mp = ( ( '0' x $w ) x $h );\r\n  \r\n  for(my $i = 0; $i< $w-2; $i+=2){\r\n    substr($mp[0],$i,1) = '1';\r\n    substr($mp[$h-1],$w-1-$i,1) = '1';\r\n  }\r\n  for(my $i = 0; $i< $h-2; $i+=2){\r\n    substr($mp[$i],$w-1,1) = '1';\r\n    substr($mp[$h-1-$i],0,1) = '1';\r\n  }\r\n  print (join(\"\\n\",@mp) . \"\\n\");\r\n}\r\n\r\nexit(0);\r\n\r\n"}], "negative_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $n, $m ) = split;\r\n\t\r\n\tprint for \r\n\t\t( $_ ) = ( 10 x 10 ) =~ /.{$m}/g,\r\n\t\t( ( 0 x $m, 1 . 0 x ( $m - 2 ) . 1 ) x 10 )[ 4 .. $n, 0 ],\r\n\t\t$_;\r\n\t}"}], "src_uid": "730cc4be2656c1dcdbda220b8778cdbf"}
{"source_code": "#!/usr/bin/perl\n\n$ans = 0;\n\n@str1 = split(' ', <STDIN>);\n\n$n = @str1[0];\n$k = @str1[1];\n\n@str2 = split(' ', <STDIN>);\n\nfor my $now (@str2) {\n    $counter = 0;\n    while($now > 0) {\n        $digit = $now % 10;\n        if($digit == 4 || $digit == 7) {\n            $counter += 1;          \n        }       \n        $now /= 10;\n    }\n    if($counter <= $k) {\n        $ans += 1;\n    }\n}\n\nprint $ans;", "positive_code": [{"source_code": "($n, $k) = split(' ', <>); $a = 0;\nforeach(split(' ', <>)){\n\t$t = 0;\n\tuntil($_ == 0){\n\t$t += ($_ % 10 == 4 or $_ % 10 == 7);\n\t$_ = int($_ / 10);}\n\t$a ++ if $t <= $k;\n\t}\nprint $a;"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy ($n, $k) = map int, split '\\D', <>;\nmy @numbers = map int, split '\\D', <>;\n\nmy $answer = 0;\n\nfor (@numbers) {\n    if ($_ =~ tr/[47]/L/ <= $k) {\n\t$answer++;\n    }\n}\n\nprint \"$answer\\n\";\n"}], "negative_code": [{"source_code": "($n, $k) = split(' ', <>);\n\nforeach(split(' ', <>)){\n\t$t = 0;\n\tuntil($_ == 0){\n\t$t += ($_ % 10 == 4 or $_ % 10 == 7);\n\t$_ = int($_ / 10);}\n\t$a ++ if $t <= $k;\n\t}\nprint $a;"}], "src_uid": "6bb26991c9ea70e51a6bda5653de8131"}
{"source_code": "chomp($s = <>);\nchomp($k = <>);\n($i, $mark) = (0, 1);\n$len = length $s;\n$mark = 0 if $len % $k != 0;\nwhile ($mark == 1 && $i < $len) {\n\t$su = substr($s, $i, $len / $k);\n\t$mark = 0 unless ($su eq reverse $su);\n\t$i += $len / $k;\n}\nprint qw(NO YES)[$mark == 1];\n", "positive_code": [{"source_code": "$_ = <>, chop, $n = <>;\n$re = '.' x ((length) / $n);\n$i ++, $j += $& eq reverse $& while /$re/g;\nprint qw(NO YES)[$i == $n && $j == $n && !((length) % $n)]"}, {"source_code": "use integer;\nwhile(<>){\n\tchomp;\n\t$n = <>;\n\t$m = (length) / $n;\n\t$re = '.' x $m;\n\t$rq = qr/$re/;\n\t$i = $j = 0;\n\twhile(/$rq/g){\n\t\t$i ++;\n\t\t$j += $& eq reverse $&;\n\t\t}\n\tprint qw(NO YES)[$i == $n && $j == $n && $m * $n == length]\n\t}"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($line = <>);\n$len = length $line;\n@a = split //, $line;\nchomp($k = <>);\n$len%$k>0 and say \"NO\" and exit;\n$l = $len / $k;\nfor ($b=0,$e=$l; $b<$len; $b=$e,$e+=$l) {\n\tfor ($i=$b,$j=$e-1; $i<$j; ++$i,--$j) {\n\t\t$a[$i] ne $a[$j] and say \"NO\" and exit;\n\t}\n}\nsay \"YES\";"}, {"source_code": "chomp($s = <>);\nchomp($k = <>);\n$i = 0;\n$mark = 1;\n$len = length $s;\n$mark = 0 if $len % $k != 0;\nwhile ($mark == 1 && $i < $len)\n{\n\t$su = substr($s, $i, $len / $k);\n\t$mark = 0 unless ($su eq reverse $su);\n\t$i += $len / $k;\n}\n$mark == 1 ? print \"YES\" : print \"NO\";\nprint \"\\n\";\n"}], "negative_code": [{"source_code": "chomp($s = <>);\nchomp($k = <>);\n$i = 0;\n$mark = 1;\n$len = length $s;\n$mark = 0 if $len % $k != 0;\nwhile ($mark == 1 && $i < length $s)\n{\n\t$su = substr($s, 0, (length $s) / $k);\n\t$mark = 0 unless ($su eq reverse $su);\n\t$i += length $s / $k;\n}\n$mark == 1 ? print \"YES\" : print \"NO\";\nprint \"\\n\";\n"}, {"source_code": "chomp($s = <>);\nchomp($k = <>);\n$i = 0;\n$mark = 1;\nwhile ($i < length $s)\n{\n\t$su = substr($s, 0, (length $s) / $k);\n\t$mark = 0 unless ($su eq reverse $su);\n\t$i += length $s / $k;\n}\n$mark == 1 ? print \"YES\" : print \"NO\";\nprint \"\\n\";\n"}], "src_uid": "43bb8fec6b0636d88ce30f23b61be39f"}
{"source_code": "use strict;\nuse warnings;\n\nmy ($n,$m)=split / /,<>;\nchomp($n,$m);\nmy @d=split / /,<>;\nchomp(@d);\nmy @sums;\nmy $ans=0;\nwhile($m--)\n{\n  my ($s,$e)=split / /,<>;\n  chomp($s,$e);\n  push(@sums,sum($s,$e,\\@d));\n}\n\nfor my $val (@sums)\n{\n  $ans=max_($ans,$ans+$val);\n}\n\nprint $ans . \"\\n\";\n\nsub sum{\n  my $si=shift;\n  my $ei=shift;\n  my $arr=shift;\n  my $aa=0;\n  for(my $i=$si-1;$i<$ei;$i++)\n  {\n    $aa+=$arr->[$i];\n  }\n  return $aa;\n}\n\nsub min_{\n\treturn $_[0] > $_[1] ? $_[1] : $_[0];\n}\n\nsub max_{\n\treturn $_[1] > $_[0] ? $_[1] : $_[0];\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\tmy( $n, $m ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tprint 0 + eval join '+', grep !/-/, map { \n\t\t\t0 + eval join '+', map \"($_)\",\n\t\t\t@_[ eval join '..', map $_ - 1, split ' ', <> ]\n\t\t} 1 .. $m;\n\t\n\t}"}], "negative_code": [], "src_uid": "6d7364048428c70e0e9b76ab1eb8cc34"}
{"source_code": "$_ = <>, chomp;\n\nwhile( $c = chop ){\n\t( $c . (s/.// ? $& : $c) ) =~ /bd|db|pq|qp|([ovwxAHIMOT-Y])\\1/ or $f ++\n\t}\n\nprint $f ? \"NIE\" : \"TAK\"", "positive_code": [{"source_code": "$F = 1;\n$F &&= f( <> );\n\nprint ! $F ? \"NIE\" : \"TAK\";\n\nsub f {\n\tmy ($A) = shift;\n\t$A =~ s/\\B.*\\B// &&$&&& ( $F &&= f($&) );\n\t$F &&= \n\t$A =~ /bd|db|pq|qp|^([ovwxAHIMOT-Y])\\1?$/;\n\t}"}, {"source_code": "chomp, \n(substr $_, substr $_, 0, (length) / 2, \n(substr $_, 0, (length) / 2) =~ y/bdpq/dbqp/r), \n( (length) % 2 and (substr $_, (length) / 2, 1) =~ /[bdpq]/ and $_ = 'a' ),\nprint qw(NIE TAK)[ !/[^ovwxAHIMOT-Ybdpq]/ * ($_ eq reverse) ] \nfor <>"}, {"source_code": "$class = \"[AHIMOoTUVvWwXxY]\";\n$a = \"($class)(?1)\\\\2\";\n$b = \"b(?1)d\";\n$c = \"d(?1)b\";\n$d = \"p(?1)q\";\n$e = \"q(?1)p\";\n$f = \"$class?\";\n$expr = qr(^($a|$b|$c|$d|$e|$f|\\n)$);\n\n$s = <>;\n$r = ($s =~ /$expr/);\nprint $r? \"TAK\": \"NIE\";\n"}], "negative_code": [{"source_code": "$class = \"[AHIMOoTUVvWwXxY]\";\n$a = \"($class)(?1)\\\\2\";\n$b = \"b(?1)d\";\n$c = \"d(?1)b\";\n$d = \"p(?1)q\";\n$e = \"q(?1)p\";\n$f = \"$class?\";\n$expr = qr(^($a|$b|$c|$d|$e|$f|\\n)$);\n\n$s = <>;\n$r = ($s =~ /$expr/);\nprint $r? \"YES\": \"NO\";\n"}, {"source_code": "chomp, print qw(NIE TAK)[ !/[^ovwxAHIMOT-Y]/ * ($_ eq reverse) ] for <>"}, {"source_code": "chomp, \n(substr $_, substr $_, 0, (length) / 2, \n(substr $_, 0, (length) / 2) =~ y/bdpq/dbqp/r), \nprint qw(NIE TAK)[ !/[^ovwxAHIMOT-Ybdpq]/ * ($_ eq reverse) ] for <>"}, {"source_code": "chomp, \n(substr $_, substr $_, 0, (length) / 2, \n(substr $_, 0, (length) / 2) =~ y/bdpq/dbqp/r), \n( (length) % 2 and (substr $_, 0, (length) / 2 + 1) =~ /[bdpq]/ and $_ = 'a' ),\nprint qw(NIE TAK)[ !/[^ovwxAHIMOT-Ybdpq]/ * ($_ eq reverse) ] \nfor <>"}], "src_uid": "bec2349631158b7dbfedcaededf65cc2"}
{"source_code": "($n,$h,@a)=((split$\",<>.<>),2e9);\nfor(0..$n){\n@x=sort{$b<=>$a}@x,$a[$_];\n$s=$i=0;\nwhile($i<@x){\n$s+=$x[$i];$i+=2\n}\nprint&&last if$s>$h\n}\n", "positive_code": [{"source_code": "($n,$h,@a)=(<>.<>)=~/\\w+/g;map{$s=$i=0;map{$s+=$_ if$i^=1}@x=sort{$b<=>$a}@x,$_;$s>$h||$\\++}@a;print\n"}, {"source_code": "($n,$h,@a)=(<>.<>)=~/\\w+/g;\nmap{\n$s=0;\n@x=sort{$b<=>$a}@x,$_;\n$s+=$x[$_*2]for 0..@x;\n$s>$h||$\\++\n}@a;\nprint\n"}, {"source_code": "($n,$h)=split$\",<>;\n@a=((split$\",<>),1e10);\nfor(@a) {\n$c++;\n@x=sort{$b<=>$a}(@x,$_);\n$s=0;\n$i=0;\nwhile($i<@x) {\n$s+=$x[$i];\n$i+=2;\n}\nif($s>$h) {\nprint$c-1;\nlast;\n}\n}\n"}, {"source_code": "($n,$h,@a)=(<>.<>)=~/\\w+/g;\nmap{\n$s=$i=0;\nmap{$s+=$_ if$i^=1}@x=sort{$b<=>$a}@x,$_;\n$s>$h||$\\++\n}@a;\nprint\n"}, {"source_code": "($n,$h) = split' ',<>;\n@a = split' ',<>;\npush @a, 1e10;\nfor (@a) {\n    $c++;\n    push @x, $_;\n    @x = sort { $b <=> $a } @x;\n    $s = 0;\n    $i = 0;\n    while($i<@x) {\n        $s += $x[$i];\n        $i+=2;\n    }\n    if ($s > $h) {\n        print $c - 1;\n        last;\n    }\n}\n"}, {"source_code": "($n,$h,@a)=(<>.<>)=~/\\w+/g;\nmap{\n@x=sort{$b<=>$a}@x,$_;\n$s=$i=0;\nmap{$s+=$_ if$i^=1}@x;\n$s>$h||$\\++\n}@a;\nprint\n"}, {"source_code": "($n,$h,@a)=(<>.<>)=~/\\w+/g;\nfor(@a){\n@x=sort{$b<=>$a}@x,$_;\n\n$s=$i=0;\nfor(@x){\n$s+=$_ if$i^=1\n}\n\n$\\++if$s<=$h\n}\nprint\n"}, {"source_code": "($n,$h,@a)=((split$\",<>.<>),2e9);\nfor(@a){\n@x=sort{$b<=>$a}@x,$_;\n\n$s=$i=0;\nfor(@x){\n$s+=$_ if$i^=1\n}\n\n$\\++if$s<=$h\n}\nprint\n"}, {"source_code": "($n,$h,@a)=((split$\",<>.<>),2e9);\nfor(@a){\n@x=sort{$b<=>$a}@x,$_;\n\n$s=$i=0;\nwhile($i<@x){\n$s+=$x[$i];$i+=2\n}\n\n$f++if$s<=$h\n}\nprint$f\n"}, {"source_code": "($n,$h,@a)=((<>.<>)=~/\\w+/g);\nfor(@a){\n@x=sort{$b<=>$a}@x,$_;\n\n$s=$i=0;\nfor(@x){\n$s+=$_ if$i^=1\n}\n\n$\\++if$s<=$h\n}\nprint\n"}, {"source_code": "($n,$h)=split$\",<>;\n@a=((split$\",<>),1e10);\nfor(0..$n) {\n@x=sort{$b<=>$a}@x,$a[$_];\n$s=0;\n$i=0;\nwhile($i<@x) {\n$s+=$x[$i];\n$i+=2;\n}\nprint&&last if$s>$h\n}\n\n"}], "negative_code": [{"source_code": "($n,$h,@a)=split$\",<>.<>,2e9;\nfor(0..$n){\n@x=sort{$b<=>$a}@x,$a[$_];\n$s=$i=0;\nwhile($i<@x){\n$s+=$x[$i];$i+=2\n}\nprint&&last if$s>$h\n}\n"}, {"source_code": "($n,$h,@a)=((split$\",<>.<>),2e9);\nprint \"$n  $h  @a\";\nfor(0..$n){\n@x=sort{$b<=>$a}@x,$a[$_];\n$s=$i=0;\nwhile($i<@x){\n$s+=$x[$i];$i+=2\n}\nprint&&last if$s>$h\n}\n"}], "src_uid": "2ff0919ee7dfdfb916b23c26fb2caf20"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $last = 'x';\nmy $number = 0;\n\nmy $n = <>;\nforeach (1..$n)\n{\n    my $piece = <>;\n    chomp $piece;\n    if ($last eq 'x')\n    {\n        $number++;\n    }\n    elsif ($last eq substr($piece, 0, 1))\n    {\n        $number++;\n    }\n    $last = substr($piece, -1);\n}\n\nprint $number;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nchomp(my $n = <>);\nmy $last;\nmy $groups = 1;\nwhile ($n--) {\n\tuse integer;\n\tchomp(my $m = <>);\n\tmy $first = $m / 10;\n\t$groups++ if defined $last && $last eq $first;\n\t$last = $m % 10;\n}\nprint $groups;\n"}, {"source_code": "my $n = <>;\nmy ($now, $last, $ans) = (\"0\", \"0\", 0);\n\nfor (1..$n) {\n    $now = <>;\n    $ans++ if ($now ne $last);\n    $last = $now;\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\n$n = <> + 0;\n$groups = 1;\n$previous = <>;\n\nfor ($i = 0; $i < ($n-1); $i++) {\n    $magnet = <>;\n    if ($magnet ne $previous) {\n        $groups++;\n    }\n\n    $previous = $magnet;\n}\n\nprint \"$groups\\n\";"}, {"source_code": "chomp($n=<>);\nmy $pre = \"\";\nwhile (<>) {\n\tchomp;\n\t++$cnt if $_ != $pre;\n\t$pre = $_;\n}\nprint \"$cnt\\n\";"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($t = <>);\nmy $ans = 0;\nwhile (<>) {\n\tchomp;\n\t$_ ne $s and $ans++;\n\t$s = $_;\n}\nsay $ans;"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nmy $n = <>;\nmy $cur = '00';\nmy $g = 0;\n\nfor (1..$n) {\n    my $s = <>;\n    if ($s ne $cur) {\n        $g++;\n        $cur = $s;\n    }\n}\n\nprint $g, \"\\n\";\n"}, {"source_code": "$n=<>;while($n--){$l=$i and$g++if($i=<>)ne$l}print$g"}, {"source_code": "#!/usr/bin/perl\n\n#  Copyright 2013 Anton Leontiev <bunder@t-25.ru>\n#\n#  Redistribution and use in source and binary forms, with or without\n#  modification, are permitted provided that the following conditions are\n#  met:\n#\n#  * Redistributions of source code must retain the above copyright\n#    notice, this list of conditions and the following disclaimer.\n#  * Redistributions in binary form must reproduce the above\n#    copyright notice, this list of conditions and the following disclaimer\n#    in the documentation and/or other materials provided with the\n#    distribution.\n#  * Neither the name of the  nor the names of its\n#    contributors may be used to endorse or promote products derived from\n#    this software without specific prior written permission.\n#\n#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n#  \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n\nuse v5.12;\nuse warnings;\nuse English qw(-no_match_vars);\n\n$OUTPUT_FIELD_SEPARATOR = \" \";\n\nmy $num = <>;\nmy $last = '';\nmy $islands;\n\nmap { $islands++, $last = $_ if $last ne $_ } <>;\n\nsay $islands;\n"}, {"source_code": "use strict;\nmy $n = <>;\nmy @a;\nfor (my $i = 0; $i < $n; $i++){\n  my $kek = <>;\n#  print $kek;\n  push(@a, $kek);\n}\nmy $ans = 1;\nsub solve{\n  my ($a, $n) = @_;\n  for (my $i = 0; $i < $n - 1; $i++){\n    if($a[$i] != $a[$i + 1]){\n      $ans++;\n    }\n  }\n  print $ans;\n}\nsolve (\\@a, $n);\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy $latest_token = read_token;\n\nmy $answer = 1;\n\nfor (1..$n-1) {\n    my $token = read_token;\n    if ($latest_token ne $token) {\n        $answer++;\n        $latest_token = $token;\n    }\n}\n\nsay $answer;\n"}, {"source_code": "$n = <>;\nwhile ($n--) {\n  $now = <>;\n  $groups += $now != $last;\n  $last = $now;\n}\nprint \"$groups\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nchomp(my $tc = <>);\n\nmy $ans = 1;\nchomp(my $now = <>);\nmy $temp = $now;\n\n\nfor( my $i = 1; $i<$tc ;$i++){\n\tchomp($now = <>);\n\tif($now != $temp){\n\t\t$ans++;\n\t}\n\t$temp = $now\n}\nprint $ans;"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$t=<>;\nwhile (<>){\n\t$t!=$_ and $c++; \n\t$t=$_;\n\t}\nprint $c+1;\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "my $num = <>;\nchomp $num;\nmy $count = 1;\nmy $magnet = <>;\nfor (2..$num) {\n    $next = <>;\n    if (!($magnet eq $next)) {\n        $count++;\n        $magnet = $next;\n    }\n}\nprint $count;"}], "negative_code": [{"source_code": "chomp($n=<>);\nmy $pre = \"\";\nwhile (<>) {\n\tchomp;\n\t$cnt++ if $_ == $pre;\n\t$pre = $_;\n}\nprint \"$cnt\\n\";"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nchomp(my $tc = <>);\n\nmy $ans = 1;\nchomp(my $now = <>);\nmy @arr = split(\"\", $now);\nmy $temp = $arr[1];\n\n\nfor( my $i = 1; $i<$tc ;$i++){\n\tchomp(my $now = <>);\n\t@arr = split(\"\", $now);\n\tif($arr[0] == $temp){\n\t\t$ans++;\n\t}\n\telse{\n\t\t$temp = $arr[1];\n\t}\n}\nprint $ans;"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nchomp(my $tc = <>);\n\nmy $ans = 1;\nchomp(my $now = <>);\nmy $temp = $now;\n\n\nfor( my $i = 1; $i<$tc ;$i++){\n\tchomp(my $now = <>);\n\tif($now == $temp){\n\t\t$ans++;\n\t}\n\telse{\n\t\t$temp = $now;\n\t}\n}\nprint $ans;"}], "src_uid": "6c52df7ea24671102e4c0eee19dc6bba"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>;\n$_=<>;\n$_[20]=0;\ns/-?\\d+/$_[$&]++/eg;\nfor (1..10){\n\t$ats += $_[-$_]*$_[$_]\n\t}\n$ats += $_[0]*($_[0]-1)/2;\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n<>;\n$_=<>;\ns/-?\\d+/$_[$&+10]++/eg;\nfor (1..10){\n\t$ats += $_[10-$_]*$_[10+$_]\n\t}\n$ats += $_[10]*($_[10]-1)/2;\nprint $ats;\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [], "src_uid": "f3dde329830d8c479b3dab9d5df8baf5"}
{"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }", "positive_code": [{"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}, {"source_code": "$_ = <>;\n$m =-~ 0;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }"}, {"source_code": "$_ = <>;\n$m =-~ 0;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n$_ = $h{ (sort {$b <=> $a} keys %h)[0] };\nuse bigint;\nprint eval"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }"}, {"source_code": "$_ = <>; # readline\ns/(^|\\*)\\K/ $pre_match = $`, ($post_match = $') =~ s!(?=\\*)|$! $hash{eval \"$pre_match($`)$'\"} = \"$pre_match($`)$'\", '' !ge, '' /ge;\n\nuse bigint;\nprint eval $hash{ (sort {$b <=> $a} keys %hash)[0] }"}, {"source_code": "$_ = <>;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! $n = \"$pr($`)$'\", $h{eval $n} = $n, '' !ge, '' /ge;\n\nuse bigint;\nprint eval $h{ (sort {$b <=> $a} keys %h)[0] }\n"}], "negative_code": [{"source_code": "$_ = <>;\n$m =-~ 0;\ns/(^|\\*)\\K/ $pr = $`, ($po = $') =~ s!(?=\\*)|$! ( ($r = eval \"$pr($`)$'\") > $m and $m = $r), '' !ge, '' /ge;\nprint $m"}], "src_uid": "39dbd405be19c5a56c2b97b28e0edf06"}
{"source_code": "#!/usr/bin/perl -w\nwhile (<STDIN>)\n{\n    s/\\s+/ /g;\n    s/\\s+$//g;\n    s/\\s*([?,.!])\\s*/$1 /g;\n\n    print $_, \"\\n\";\n}", "positive_code": [{"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "$_=<>;s/( )+/ /g;s/ ?([\\.!\\?,]) ?/$1 /g;print;"}, {"source_code": "#!/usr/bin/env perl\n$_=<>;s/( )+/ /g;s/ ?([\\.!\\?,]) ?/$1 /g;print;\n"}, {"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::_;\nuse v5.10;\nuse strict;\nuse warnings;\n\nsub min{my($a,$b)=@_;if($a<$b){return$a;}else{return$b;}}\nsub max{my($a,$b)=@_;if($a>$b){return$a;}else{return$b;}}\nsub out{foreach my$c(@_){print\"$c \";}print(\"\\n\");}\n\nsub solve {\n    my $s = <>;\n    $s =~ s/( )+/ /g;\n    $s =~ s/ ?([\\.,!\\?]) ?/$1 /g;\n    say $s;\n}\n\nsub main {\n    my $t = 1;\n#    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main(@ARGV));\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nwhile (<STDIN>) {\n    s/(\\s)+/$1/g;\n    s/\\s*([\\.,\\?!])\\s*/$1 /g;\n    s/^( *)|( *)$//g;\n    print;\n}\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;"}, {"source_code": "use strict;\n \nwhile (<STDIN>) {\n    s/(\\s)+/$1/g;\n    s/\\s*([\\.,\\?!])\\s*/$1 /g;\n    s/^( *)|( *)$//g;\n    print;\n}"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nwhile (<STDIN>) {\n    s/(\\s)+/$1/g;\n    s/\\s*([\\.,\\?!])\\s*/$1 /g;\n    s/^( *)|( *)$//g;\n    print;\n}"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nwhile (<STDIN>) {\n    s/(\\s)+/$1/g;\n    s/\\s*([\\.,\\?!])\\s*/$1 /g;\n    s/^( *)|( *)$//g;\n    print;\n}\n"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nwhile (<STDIN>) {\n    s/(\\s)+/$1/g;\n    s/\\s*([\\.,\\?!])\\s*/$1 /g;\n    s/^( *)|( *)$//g;\n    print;\n}"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "while (<>){\n\ts/([,.!?])( {2,})?(\\w)/$1 $3/g;\n\ts/ +/ /g;\n\ts/(\\w) +([,.!?])/$1$2/g;\n\tprint;\n\t}"}, {"source_code": "$_=<>;\nchomp;\ns/\\s+/ /g;\ns/\\s*([,\\.\\?!])\\s*/$1 /g;\nprint;\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}, {"source_code": "#!perl -lp\ns/\\s+/ /g;\ns/\\s*([,.?!])\\s*/$1 /g;\n"}, {"source_code": "$_=<>;\nchomp;\ns/\\s+/ /g;\ns/ ([,\\.\\?!])/$1/g;\ns/([,\\.\\?!])(?=\\w)/$1 /g;\nprint;\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n"}, {"source_code": "#!perl -pl\ns/\\s+/ /g;\ns/\\s*([.,!?])\\s*/$1 /g;\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse utf8;\n\nmy $str = <>;\n\n# Clear text\n$str =~ s/\\s+/ /g;\n$str =~ s/\\s*([?,.!])\\s*/$1 /g;\n\nprint $str;"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $str = <>;\n\n# Clear text\n$str =~ s/\\s+/ /g;\n$str =~ s/\\s([.,!?:;])/$1/g;\n$str =~ s/([.,!?:;])/$1 /g;\n\nprint $str, \"\\n\";"}, {"source_code": "#!/usr/bin/perl -w\n# Почему не работает-то?\nwhile (<STDIN>)\n{\n    s/\\s+/ /g;\n    s/\\s*([?,.!])\\s*/$1 /g;\n\n    print $_, \"\\n\";\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $str = <>;\n\n# Clear text\n$str =~ s/\\s+/ /g;\n$str =~ s/\\s([.,!?:;])/$1/g;\n$str =~ s/([.,!?:;])/$1 /g;\n$str =~ s/\\s+/ /g;\n\nprint $str, \"\\n\";"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse utf8;\n\nmy $str = <>;\n\n# Clear text\n$str =~ s/\\s+/ /g;\n$str =~ s/\\s*([?,.!])\\s*/$1 /g;\n\nprint $str, \"\\n\";"}, {"source_code": "#!/usr/bin/perl -w\nwhile (<STDIN>)\n{\n    s/\\s+/ /g;\n    s/\\s*([?,.!])\\s*/$1 /g;\n\n    print $_;\n}"}, {"source_code": "while (<>){\n\ts/([,.!?])( {2,})?(\\w)/$1 $3/g;\n\ts/(\\w) +(\\w)/$1 $2/g;\n\ts/(\\w) +([,.!?])/$1$2/g;\n\tprint;\n\t}"}, {"source_code": "$_=<>;\ns/\\s+/ /g;\ns/ ([,\\.\\?!])/$1/g;\ns/([,\\.\\?!])(?=\\w)/$1 /g;\nprint;\n"}], "src_uid": "8c26daa1eed2078af3b32737da0a0f84"}
{"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\nsub min {\n    my ($a, $b) = @_;\n    if ($a < $b) {\n\t\treturn $a;\n\t} else {\n        return $b;\n    }\n}\nsub max {\n    my ($a, $b) = @_;\n    if ($a > $b) {\n        return $a;\n    } else {\n        return $b;\n    }\n}\n\n\nsub solve {\n    my ($h, $m) = map(int, split(\" \", <>));\n    print 24 * 60 - $m - 60 * $h, \"\\n\";\n}\n\nsub main {\n    my $t = 1;\n    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main(@ARGV));\n\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $h, $min ) = split;\n\t\n\tprint 24 * 60 - ( $h * 60 + $min );\n\t}"}], "negative_code": [], "src_uid": "f4982de28aca7080342eb1d0ff87734c"}
{"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n", "positive_code": [{"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "use List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nchomp (my $n = <>);\n\nmy @names = (q/junk/);\nwhile (<>) {\n    chomp;\n    push @names, $_;\n}\nmy @order = split /\\s+/, pop @names;\n\nmy $rsp = q/YES/;\n\nmy @h;\nmy $lH = '-';\nforeach (@order) {\n    @h = sort {$a cmp $b} split /\\s+/, $names[$_];\n    if ($lH lt $h[0]) {\n        $lH = $h[0]; next;\n    } elsif ($lH lt $h[1]) {\n        $lH = $h[1]; next;\n    } else {\n        $rsp = q/NO/; last;\n    }\n}\n\nprintf \"$rsp\\n\";"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}, {"source_code": "<>;\nchomp(@_=<>);\n@i=split/ /,pop @_;\n$j='';\n$f=0;\nfor (@i){\n($a,$b) = sort split/ /,$_[$_-1];\nif ($a gt $j){$j=$a}\nelsif ($b gt $j){$j=$b}\nelse {$f++; last}\n}\nprint $f ? NO:YES\n\n"}], "negative_code": [], "src_uid": "a48ef749bf54d673772e09025ae806de"}
{"source_code": "<>;\nwhile(<>){\nchomp;\npush @_, $n{$_}? ($_.$n{$_}) : OK ;\n$n{$_}++\n}\n$,=\"\\n\";\nprint @_", "positive_code": [{"source_code": "$len = <STDIN>;\n$hashMap;\n\nfor my $val (1 .. $len) {\n\t$input = <STDIN>;\n\t$input =~ s/\\s//g;\n\n\tif ($hashMap->{$input}) {\n\t\tprint $input.$hashMap->{$input}.\"\\n\";\n\t\t++$hashMap->{$input};\n\t} else {\n\t\t$hashMap->{$input} = 1;\n\t\tprint \"OK\\n\";\n\t}\n}"}, {"source_code": "\n#!/usr/bin/perl\n\nmain();\n\nsub main {\n    my $n = int <>;\n    my %hash = ();\n    for(1..$n) {\n        my $name = <>;\n        $name =~ s/[\\W]//;\n        my $add = \"\";\n        if (exists $hash{$name}) {\n            $add = $hash{$name};\n            print(\"$name$add\\n\");\n            $hash{$name} = $add + 1;    \n        } else {\n            print(\"OK\\n\");\n            $hash{$name} = 1;\n        }\n    }\n}\n"}, {"source_code": "chomp($count = <STDIN>);\nfor ($i = 0; $i < $count; ++$i)\n{\n    chomp($newName = <STDIN>);\n    push @names, $newName;\n}\nforeach (@names)\n{\n    if ( ! exists $logins{$_} )\n    {\n        $logins{$_}++;\n        print \"OK\\n\";\n    }\n    else\n    {\n        print \"$_$logins{$_}\\n\";\n        $logins{$_}++;\n    }\n}\n"}, {"source_code": "my %hash;\nfor my $i(1..int<>) {\n    chomp($_ = <>);\n    if (not exists $hash{$_}) {\n        print \"OK\\n\";\n        $hash{$_} = 1;\n        next;\n    }\n    print $_ . $hash{$_} . \"\\n\";\n    $hash{$_}++;\n}\n"}, {"source_code": "$\\=\"\\n\";\nfor$i(1..<>)\n{\n    chomp($_=<>);\n    if (!defined($h{$_}))\n    {\n        print \"OK\";\n        $h{$_}=1;\n    } else\n    {\n        print $_,$h{$_}++;\n    }\n}"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\nforeach (1 .. $n) {\n\tchomp($line = <>);\n\tdefined $tb{$line} and say $line,$tb{$line} or say \"OK\";\n\t++$tb{$line};\n}"}, {"source_code": "my $n = <>;\nmy %names;\n\nfor (1..$n) {\n    my $name = <>;\n    chomp $name;\n    if (exists $names{$name}) {\n        print $name, $names{$name}++, \"\\n\";\n    } else {\n        $names{$name} = 1;\n        print \"OK\\n\";\n    }\n}\n"}, {"source_code": " \n<>;\nwhile(<>){\nchomp;\npush @_, $n{$_}? ($_.$n{$_}) : OK ;\n$n{$_}++\n}\n$,=\"\\n\";\nprint @_"}, {"source_code": "<>;\n\nwhile(<>)\n{\n\tchomp();\n\tif(not exists $h{$_}){\n\t\tprint \"OK\\n\";\n\t}\n\telse{\n\t\tprint $_, $h{$_}, \"\\n\";\n\t}\n\t$h{$_} ++;\n\t\n}"}, {"source_code": "#!perl\n\nfor (1..<STDIN>) {\n\tchomp ($name = <STDIN>);\n\tif (!defined($names{$name})) {\n\t\tprint \"OK\\n\";\n\t\t$names{$name} = 0;\n\t} else {\n\t\tprint $name, ++$names{$name}, \"\\n\";\n\t}\n}"}, {"source_code": "#!usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n=<STDIN>;\nmy %list;my $p=0;\nmy @output;\nfor my $i(0..$n-1){\n    my $name=<STDIN>;\n    chomp($name);\n    if(!defined($list{$name})){\n\t$list{$name}=$name;\n\t$output[$i]=\"OK\\n\";\n    }\n    else{\n\t$p=$list{$name}=~s/[a-z]+/0/r+1;\n\t$list{$name}=$name.$p;\n\t$output[$i]=$list{$name}.\"\\n\";\n    }\n}\nprint @output;"}, {"source_code": "#!/usr/bin/perl\n\n$n=<STDIN>;\n$n=int($n);\n\n%db=();\n\nfor($i=0;$i<$n;$i++) {\n\t$name=<STDIN>;\n\tchomp($name);\n\tif($db{$name}) {\n\t\t$name2=$name . $db{$name};\n\t\t$db{$name}=$db{$name}+1;\n\t\tprint \"$name2\\n\";\n\t} else {\n\t\t$db{$name}=1;\n\t\tprint \"OK\\n\";\n\t}\n}"}, {"source_code": "\nchomp($n = <STDIN>);\n\n%dic = {};\n@userlist = [];\npop @userlist;\n\nfor( $i = 0; $i < $n; $i++){\n    chomp($name = <STDIN>);\n    if (exists $dic{$name}) {\n        #$dic{$name} = $dic{$name} + 1;\n        $dic{$name}++;\n        $string = $name.$dic{$name};\n        push @userlist , ($string);\n    }\n    else\n    {\n        $dic{$name} = 0;\n        push @userlist, \"OK\";\n    }\n}\n\n\nforeach $name(@userlist){\n\tprint \"$name\\n\";\n}\n\n\n"}], "negative_code": [{"source_code": "#!perl\n\nfor (1..<STDIN>) {\n\tchomp ($name = <STDIN>);\n\tif (!defined($names{$name})) {\n\t\tprint \"OK\";\n\t\t$names{$name} = 0;\n\t} else {\n\t\tprint $name, ++$names{$name}, \"\\n\";\n\t}\n}"}, {"source_code": "#!perl\n\nfor (1..<STDIN>) {\n\tchomp ($name = <STDIN>);\n\tif (!defined($names{$name})) {\n\t\tprint \"OK\";\n\t\t$names{$name} = 0;\n\t} else {\n\t\tprint $name, ++$names{$name};\n\t}\n}"}, {"source_code": "#!usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n=<STDIN>;\nmy %list;\nmy @output;\nfor my $i(0..$n-1){\n    my $name=<STDIN>;\n    chomp($name);\n    if(!defined($list{$name})){\n\t$list{$name}=$name;\n\t$output[$i]=\"OK\\n\";\n    }\n    else{\n\tmy $p=$name=~s/\\w+/0/r;\n\t$list{$name}=$name.($p+1);\n\t$output[$i]=$list{$name}.\"\\n\";\n    }\n}\nprint @output;"}, {"source_code": "<>;\nwhile(<>){\nchomp;\npush @_, $n{$_}? ($_.$n{$_}++) : OK\n}\n$,=\"\\n\";\nprint @_"}], "src_uid": "24098df9c12d9704391949c9ff529c98"}
{"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n", "positive_code": [{"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a\n"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\t$j=-1;\n\t\twhile(/./g){\n\t\t\t(($a=$a[++$j]) eq 'X' or $& eq '?') && next;\n\t\t\t$& eq $a or ($a[$j]= $a ne '?'? X: $&)\n\t\t\t}\n\t\t}\n\n\t$_=join\"\",@a;\n\ts/\\?/x/g;\n\ts/X/?/g;\nprint"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\ty/?X/x?/ for @a;\n\t\nprint @a"}, {"source_code": "<>;\t\n$_=<>;\n@a=split//;\n\t\n\twhile(<>){\n\t\tchomp;\n\t\t$j=-1;\n\t\tfor (split//){\n\t\t\t(($a=$a[++$j]) eq 'X' or $_ eq '?') && next;\n\t\t\t$_ eq $a or ($a[$j]= $a ne '?'? X: $_)\n\t\t\t}\n\t\t}\n\n\t$_=join\"\",@a;\n\ts/\\?/x/g;\n\ts/X/?/g;\nprint"}, {"source_code": "while($n=<>){\n\t$_=<>;\n\tchomp;\n\t@a=split//;\n\t\n\tfor $i(2..$n){\n\t\t$_=<>;\n\t\tchomp;\n\t\t@_=split//;\n\t\t\n\t\tfor $j(0..@_-1){\n\t\t\t$a[$j] eq 'X' and next;\n\t\t\t$_[$j] eq '?' and next;\n\t\t\tif ($_[$j] ne $a[$j]){ \n\t\t\t\t\t if ($a[$j] ne '?') { $a[$j]='X'}\n\t\t\t\t\t else { $a[$j]=$_[$j]  }\n\t\t\t\t\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\n\t\t\t}\n\t\n\t\t\n\t\t}\n#\tprint \"@a\\n\";\n\t$a=join\"\",@a;\n\t$a=~s/\\?/x/g;\n\t$a=~s/X/?/g;\n\tprint \"$a\\n\";\n\t\n\t}"}], "negative_code": [], "src_uid": "a51d2e6e321d7db67687a594a2b85e47"}
{"source_code": "use strict;\n\nuse List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nmy ($n, $m) = split / /, <>;\nmy $b;\nmy @bs;\n$#bs = $n-1;\n\nmy @i = split / /, <>;\n$b = shift @i;\nfor(@i)\n{\n    $bs[$_] = 1;\n}\nmy @gs;\n$#gs = $m-1;\n@i = split / /, <>;\n\nmy $g = shift @i;\nfor(@i)\n{\n    $gs[$_] = 1;\n}\nif($b == 0 and $g == 0){ print \"No\";exit 0; }\n\nmy $nod = nod($m, $n);\n\nmy @t; $#t = $nod-1;\n\nfor (0..max ($n, $m))\n{\n    $t[$_ % $nod] = $bs[$_ % $n] || $gs[$_ % $m] || $t[$_ % $nod];\n}\nmy $flag = 1;\nfor(@t)\n{\n    $flag *= $_;\n}\n\nprint \"Yes\" if ($flag);\nprint \"No\" unless ($flag);\n\n\n\n\n\n\n\n\n\n\nsub nod\n {\n return  $_[0] != 0  ?  nod ( ( $_[1] % $_[0] ), $_[0] )  :  $_[1];\n };\n\n\n\n\n\n\n\n\n\n\n\n\n", "positive_code": [{"source_code": "$\\ = $/;\nwhile(<>){\n\t($B,$G)=split;\n\t$b=<>;\n\t$g=<>;\n\t@b = (0) x $B;\n\t@g = (0) x $G;\n\t@B = (split \" \", $b);shift @B;\n\t@G = (split \" \", $g);shift @G;\n\t$b[$_] = 1 for @B;\n\t$g[$_] = 1 for @G;\n\tfor $i (0 .. 2e4){\n\t\t$b[$i % $B] || $g[$i % $G] and $b[$i % $B] = 1 and $g[$i % $G] = 1;\n\t\t}\n\tprint \"@b@g\" =~ /0/ ? \"No\":\"Yes\"\n\t}"}, {"source_code": "sub gcf {\n  my ($x, $y) = @_;\n  ($x, $y) = ($y, $x % $y) while $y;\n  return $x;\n}\n\nsub lcm {\n  return($_[0] * $_[1] / gcf($_[0], $_[1]));\n}\n\nchomp (my ($n, $m) = split /\\s+/, <>);\nmy @boys  = (0) x $n;\nmy @girls = (0) x $m;\nchomp (my @hb = split /\\s+/, <>);\nchomp (my @hg = split /\\s+/, <>);\n\nmy $hcnt = 0;\n$hcnt += shift @hb;\n$hcnt += shift @hg;\n\n$boys[$_]   = 1 foreach (@hb);\n$girls[$_]  = 1 foreach (@hg);\n\nmy $prevhcnt;\nmy ($i, $j);\n\nrepeat:\n\n$prevhcnt = $hcnt;\n($i, $j) = (0, 0);\nforeach my $x (0 .. &lcm($n, $m) - 1) {\n  $i++;\n  $j++;\n  $i = ($n > $i) ? $i : 0;\n  $j = ($m > $j) ? $j : 0;\n  if ($boys[$i] ^ $girls[$j]) {\n    $boys[$i] = 1;\n    $girls[$j] = 1;\n    $hcnt++;\n  }\n}\n# printf \"@boys\\n@girls\\n$hcnt\\n$prevhcnt\\n\";\ngoto repeat if ($hcnt > $prevhcnt);\n\nif ($hcnt == ($m + $n)) {\n  printf \"YES\\n\";\n} else {\n  printf \"NO\\n\";\n}\n"}], "negative_code": [{"source_code": "chomp (my ($n, $m) = split /\\s+/, <>);\nmy @boys  = (0) x $n;\nmy @girls = (0) x $m;\nchomp (my @hb = split /\\s+/, <>);\nchomp (my @hg = split /\\s+/, <>);\n\nmy $hcnt = 0;\n$hcnt += shift @hb;\n$hcnt += shift @hg;\n\n$boys[$_]   = 1 foreach (@hb);\n$girls[$_]  = 1 foreach (@hg);\n\nmy $prevhcnt;\n\n$n--;\n$m--;\n\nrepeat:\n$prevhcnt = $hcnt;\nforeach my $i (0 .. $n) {\n  foreach my $j (0 .. $m) {\n    if ($boys[$i] ^ $girls[$j]) {\n      $girls[$j] = 1;\n      $boys[$i] = 1;\n      $hcnt++;\n    }\n  }\n}\n# printf \"@boys\\n@girls\\n$hcnt\\n$prevhcnt\\n\";\ngoto repeat if ($hcnt > $prevhcnt);\n\nif ($hcnt == ($m + $n + 2)) {\n  printf \"YES\\n\";\n} else {\n  printf \"NO\\n\";\n}"}, {"source_code": "sub gcf {\n  my ($x, $y) = @_;\n  ($x, $y) = ($y, $x % $y) while $y;\n  return $x;\n}\n\nsub lcm {\n  return($_[0] * $_[1] / gcf($_[0], $_[1]));\n}\n\nchomp (my ($n, $m) = split /\\s+/, <>);\nmy @boys  = (0) x $n;\nmy @girls = (0) x $m;\nchomp (my @hb = split /\\s+/, <>);\nchomp (my @hg = split /\\s+/, <>);\n\nmy $hcnt = 0;\n$hcnt += shift @hb;\n$hcnt += shift @hg;\n\n$boys[$_]   = 1 foreach (@hb);\n$girls[$_]  = 1 foreach (@hg);\n\nmy $prevhcnt;\nmy ($i, $j);\n\nrepeat:\n\n$prevhcnt = $hcnt;\n($i, $j) = (0, 0);\nforeach my $x (0 .. &lcm($n, $m) - 1) {\n  $i++;\n  $j++;\n  $i = ($n > $i) ? $i : 0;\n  $j = ($m > $j) ? $j : 0;\n  if ($boys[$i] ^ $girls[$j]) {\n    $boys[$i] = 1;\n    $girls[$j] = 1;\n    $hcnt++;\n  }\n}\nprintf \"@boys\\n@girls\\n$hcnt\\n$prevhcnt\\n\";\ngoto repeat if ($hcnt > $prevhcnt);\n\nif ($hcnt == ($m + $n + 2)) {\n  printf \"YES\\n\";\n} else {\n  printf \"NO\\n\";\n}\n"}], "src_uid": "65efbc0a1ad82436100eea7a2378d4c2"}
{"source_code": "$\\ = $/;\n<>;\n\n@_ = split ' ', <>;\n\n$h = 1;\n\nfor( split ' ', <> ){\n\t\n\twhile( @_ and $_[ 0 ] + $c < $_ ){\n\t\t$h ++;\n\t\t$c += shift @_;\n\t\t}\n\t\n\tprint \"$h \" . ( $_ - $c )\n\t}", "positive_code": [{"source_code": "# author : Gabriel Hofer\nuse warnings;\nuse strict;\nuse constant NL => qq/\\n/;\n\nmy ($n, $m) = ( <STDIN> =~ m /(\\d+)\\s(\\d+)/ );\nmy @one = split qq/ /, <STDIN>;\nmy @two = split qq/ /, <STDIN>;\nmy @three = @one;\nfor ( my $i = 1; $i <= $#three; $i += 1 ) { \n    $three [ $i ] += $three [ $i - 1 ] }\n\nAA: for my $i ( @two ) {\n    my ($left, $right, $mid);\n    $left = 0;\n    $right = $#three;\n    AB: while ( $left < $right ) {\n        $mid = int ( ( $left + $right ) / 2 );\n        if ( $i < $three [ $mid ] ) { $right = $mid }\n        elsif ( $i > $three [ $mid ] ) { $left = $mid + 1 }\n        else { last AB }\n    }\n    $mid = int ( ( $left + $right ) / 2 );\n    print ( $mid + 1, qq/ / );\n    if ( $mid == 0 ) { print qq/$i/ } \n    else { print ( $i - $three [ $mid - 1 ] ) }\n    print NL;\n}\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "$\\ = $/;\n<>;\n\n@_ = split ' ', <>;\n\n$h = 1;\n\nfor( split ' ', <> ){\n\t\n\twhile( @_ and $_[ 0 ] + $c < $_ ){\n\t\t$h ++;\n\t\t$c += shift @_;\n\t\t}\n\t\n\tprint \"$h \" . ( $_ - $c )\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $house = 1;\n\tmy $accum = 0;\n\t\n\tfor my $i ( split ' ', <> ){\n\t\t\n\t\twhile( @_ and $_[ 0 ] + $accum < $i ){\n\t\t\t$house ++;\n\t\t\t$accum += $_[ 0 ];\n\t\t\tshift @_;\n\t\t\t}\n\t\t\n\t\tprint $house . ' ' . ( $i - $accum );\n\t\t}\n\t\n\t}"}], "negative_code": [], "src_uid": "56bdab2019ee12e18d4f7e17ac414962"}
{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tmy( $n, $x ) = split;\r\n\t\r\n\t@_ = split ' ', <>;\r\n\t\r\n\tmy %h;\r\n\t\r\n\tmap $h{ $_ } ++, @_;\r\n\t\r\n\tfor my $key ( sort { $b <=> $a } keys %h ){\r\n\t\tif( $key % $x == 0 and exists $h{ $key / $x } ){\r\n\t\t\twhile( $h{ $key } > 0 and $h{ $key / $x } > 0 ){\r\n\t\t\t\t$h{ $key } --;\r\n\t\t\t\t$h{ $key / $x } --;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\tprint 0 + eval join '+', values %h;\r\n\t}", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $n, $x, %h ) = split;\r\n\t\r\n\tmap $h{ $_ } ++, @_ = split ' ', <>;\r\n\t\r\n\tfor $key ( sort { $a <=> $b } keys %h ){\r\n\t\tmap $h{ $key * $_ } --, 1, $x while $h{ $key * $x } && $h{ $key }\r\n\t\t}\r\n\t\r\n\tprint 0 + eval join '+', values %h;\r\n\t}"}], "negative_code": [], "src_uid": "c19500d867fd0108fdeed2cbd00bc970"}
{"source_code": "<>=~/ /;\n@_=sort {$a<=>$b} (split/ /,<>);\n$s=0;\nfor (1..$'){\n$a=shift @_;\n$s+=$a<0?(-$a):(0);\n}\nprint $s", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nsub min{\n    return $_[0] < $_[1]? $_[0]:$_[1];\n}\nmy $n;my $m;\n($n, $m) = split(' ', <>);\n\nmy @arr = split(' ', <>);\n@arr = sort {$a <=> $b}@arr;\n\nmy $res = 0;\nfor(my $i = 0; $i < min($n,$m); $i++){\n    if($arr[$i] < 0){$res += -$arr[$i];}\n    else {last;}\n}\nprint $res;\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nsub min{\n    return $_[0] < $_[1]? $_[0]:$_[1];\n}\nmy $n;my $m;\n($n, $m) = split(' ', <>);\n\nmy @arr = split(' ', <>);\n@arr = sort @arr;\n\nmy $res = 0;\nfor(my $i = 0; $i < min($n,$m); $i++){\n    if($arr[$i] < 0){$res += -$arr[$i];}\n    else {last;}\n}\nprint $res;\n"}], "src_uid": "9a56288d8bd4e4e7ef3329e102f745a5"}
{"source_code": "use strict;\n\nmy $try = <>;\nwhile($try-- > 0)\n{\n    my $val = <>;\n    if($val < 31){\n        print \"NO\\n\";\n    } elsif($val == 36) {\n        print \"YES\\n\";\n        printf(\"15 10 6 %d\\n\", $val-31);\n    } elsif($val == 40 || $val == 44) {\n        print \"YES\\n\";\n        printf(\"15 10 14 %d\\n\", $val-39);\n    } else {\n        print \"YES\\n\";\n        printf(\"6 10 14 %d\\n\", $val-30);\n    }\n}", "positive_code": [{"source_code": "use bigint;\nchomp(my $t = <STDIN>);\nforeach (1..$t)\n{\n    chomp (my $n = <STDIN>);\n    if ($n <= 30)\n    {\n        print \"NO\\n\";\n    }\n    elsif ($n == 36 || $n == 40 || $n == 44)\n    {\n        print \"YES\\n6 10 15 \", $n - 31, \"\\n\";\n    }\n    else\n    {\n        print \"YES\\n6 10 14 \", $n - 30, \"\\n\";\n    }\n}"}], "negative_code": [{"source_code": "use bigint;\nchomp(my $t = <STDIN>);\nforeach (1..$t)\n{\n    chomp (my $n = <STDIN>);\n    if ($n <= 30)\n    {\n        print \"NO\\n\";\n    }\n    elsif ($n == 36 || $n == 40 || $n == 44)\n    {\n        print \"6 10 15 \", $n - 31, \"\\n\";\n    }\n    else\n    {\n        print \"6 10 14 \", $n - 30, \"\\n\";\n    }\n}"}, {"source_code": "use strict;\n\nmy $try = <>;\nwhile($try-- > 0)\n{\n    my $val = <>;\n\n    if($val < 31 || $val == 36){\n        print \"NO\\n\";\n    } elsif($val == 40 || $val == 44) {\n        print \"YES\\n\";\n        printf(\"15 10 14 %d\\n\", $val-39);\n    } else {\n        print \"YES\\n\";\n        printf(\"6 10 14 %d\\n\", $val-30);\n    }\n}"}], "src_uid": "8a6c3436f73286ca54f51fb90017a299"}
{"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n", "positive_code": [{"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}, {"source_code": "$n=<>;\n$n2=$n*$n;\n$m=0;\nfor ($i=0; $i<$n2; $i++)\n{\n\t($a,$b)=split \" \",<>;\n\tif ($v[$a]==0 and $h[$b]==0)\n\t{\n\t\t$v[$a]=1;\n\t\t$h[$b]=1;\n\t\t$rez[$m]=$i+1;\n\t\t$m++;\n\t}\n}\nprint \"@rez\";"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}, {"source_code": "\nmy $n = int<>;\nmy ($x, $y);\nmy @arr = (0 x 200);\nfor(1..$n*$n) {\n    ($x, $y) = split / /, <>;\n    if (!$arr[$x] && !$arr[60 + $y]) {\n        print $_ . \" \";\n        $arr[$x] = 1;\n        $arr[60 + $y] = 1;\n    }\n}\n"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>"}, {"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$g{$y} and $h{$x}++, $g{$y}++, print \"$i \" for <>\n"}], "negative_code": [{"source_code": "<>;\n$i ++, ($x, $y) = split, !$h{$x} && !$h{$y} and $h{$x}++, $h{$y}++, print \"$i \" for <>"}], "src_uid": "c611808e636d9307e6df9ee0e706310b"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tmy $start = 0;\n\t\n\tfor( @_ ){\n\t\tmy( $s, $d ) = split;\n\t\t$start ++;\n\t\t\n\t\tmy $n = ( $start - $s ) / $d;\n\t\t$debug and print '  ', $n;\n\t\t$start = $s + $d * ( $n =~ s/-.*/0/r =~ s/(\\d+)\\..*/ $1 + 1 /er );\n\t\t$debug and print '       ', $start;\n\t\t}\n\t\n\tprint $start;\n\t}", "positive_code": [{"source_code": "<>;\n\n$Z = 0;\n\nfor( <> ){\n\t( $s, $d ) = split;\n\t$Z ++;\n\t\n\t$Z = $s + $d * ( ( $Z - $s ) / $d ) =~ s/-.*/0/r =~ s/(\\d+)\\..*/ $1 + 1 /er;\n\t}\n\nprint $Z"}, {"source_code": "<>;\n\nfor( <> ){\n\t( $s, $d ) = split;\n\t\n\t$s += 1e3 * $d while $Z >= $s + 1e3 * $d;\n\t$s += $d while $Z >= $s;\n\t$Z = $s;\n\t}\n\nprint $Z"}, {"source_code": "use integer;\n<>; while (<>) {\n\t($s, $d) = split;\n\t# a < s + dx, (a - s)/d < x \n\tif ($a >= $s) {\n\t\t$x = ($a - $s) / $d + 1;\n\t\t$a = $s + $d * $x;\n\t} else {\n\t\t$a = $s;\n\t}\n}\nprint $a;\n"}], "negative_code": [], "src_uid": "d324617c86423d86cdcb839894e00e1a"}
{"source_code": "$\\ = $/;\n\n<>;\n\nmap { ($l, $r) = split; push @L, $l; push @R, $r; } <>;\n\n($L, $R) = map { unpack '%32i' . ~~ @$_, pack 'i' . ~~ @$_, @$_ } \\@L, \\@R;\n\n$beauty = abs($L - $R);\n\nfor $i (1 .. @L) {\n\t$beauty_2 = abs(\n\t\t($L + $R[$i-1] - $L[$i-1]) -\n\t\t($R + $L[$i-1] - $R[$i-1])\n\t);\n\t$beauty_2 > $beauty and do {\n\t\t$beauty = $beauty_2;\n\t\t$index = $i;\n\t};\n}\n\nprint $index // 0", "positive_code": [{"source_code": "<>;\n\nmap { ($l, $r) = split; push @L, $l; push @R, $r; } <>;\n\n($L, $R) = map { unpack '%123d*', pack 'd*', @$_ } \\@L, \\@R;\n\n$B = abs($L - $R);\n\nfor (1 .. @L) {\n\t$b2 = abs($L - $R + 2 * ($R[$_-1] - $L[$_-1]) );\n\t$b2 > $B and $B = $b2 and $I = $_;\n}\n\nprint $I // 0"}, {"source_code": "<>;\n\n@_ = map [split, eval join '-', split], <>;\n\n$L += $_->[0] for @_;\n$R += $_->[1] for @_;\n$B = abs($L - $R);\n\nfor (1 .. @_) {\n\t$b2 = abs($R - $L + 2 * $_[$_-1][2] );\n\t$b2 > $B and $B = $b2 and $I = $_;\n}\n\nprint $I // 0"}], "negative_code": [], "src_uid": "2be73aa00a13be5274cf840ecd3befcb"}
{"source_code": "#!/usr/local/bin/perl\n \nmy @ttt = split(/\\s+/, <>);\nmy @arr = split(/\\s+/, <>);\n\n$odd = 0;\n$even = 0;\n\nforeach $a (@arr) {\n\n    $c = int($a) % 2;\n\n    \n    if ($c == 1) {\n        $odd = $odd + 1;\n    } else {\n        $even = $even + 1;\n    }\n\n}\n\nif ($odd <= $even)\n{\n    print($odd)\n}\nelse\n{\n    print($even + int(($odd - $even) / 3 + 1e-12))\n}", "positive_code": [{"source_code": "my $x = <STDIN>;\nchomp $x;\n\nmy $line = <STDIN>;\nchomp $line;\n\nmy @splits = split / /, $line;\n\nmy $odd = 0;\nmy $even = 0;\nfor my $split (@splits) {\n    if (int($split) % 2 == 0) {\n        $even += 1;\n    } else {\n        $odd += 1;\n    }\n}\n\nmy $pair;\n\nif ($even < $odd) {\n    $pair = $even;\n} else {\n    $pair = $odd;\n}\n\n$odd -= $pair;\n$even -= $pair;\n\nmy $ans = $pair + int($odd / 3);\n\nprint $ans . \"\\n\";\n"}, {"source_code": "my $n = <>;\n\n$inp = [split / /, <>];\n\n@a = (0, 0, 0);\n\n$ans = 0;\n\nforeach (@$inp) {\n    if ($_ % 2 == 0) {\n        $a[1]++;\n    }\n    else {\n        $a[2]++;        \n    }\n}\n\nmy $d;\nif ($a[1] < $a[2]) {\n    $d = $a[1];\n}\nelse {\n    $d = $a[2];\n}\n\n$ans += $d;\n$a[1] -= $d;\n$a[2] -= $d;\n\n$a[2] -= $a[2] % 3;\n\n$ans += ($a[2]) / 3;\n\nprint $ans;"}, {"source_code": "chomp ($n = <STDIN>);\nchomp ($str = <STDIN>);\n$odd = 0;\n$even = 0;\n$len = length($str);\nfor $x(0..($len - 1)) {\n    $c = substr($str, $x, 1);\n    if (($c eq '0' || $c eq '2' || $c eq '4' || $c eq '6' || $c eq '8') && (substr($str, $x + 1, 1) eq ' ' || $x + 1 == $len)) { $even = $even + 1; }\n    if (($c eq '1' || $c eq '3' || $c eq '5' || $c eq '7' || $c eq '9') && (substr($str, $x + 1, 1) eq ' ' || $x + 1 == $len)) { $odd = $odd + 1; }\n}\n$min = $odd;\nif ($min > $even) { $min = $even; }\n$odd -= $min;\n$even -= $min;\nprint($min + int($odd / 3));"}, {"source_code": "$_ = <STDIN>; my ($n) = split;\n$_ = <STDIN>; my @A = split;\n\n$odd = 0;\n$even = 0;\nfor($i=0; $i < $n ; $i=$i+1){\n    \n\tif( $A[$i] %2 == 0){\n\t    $even = $even+1;\n\t}else{\n\t    $odd = $odd+1;\n\t}\n}\n\n$mn = $odd;\nif ($even < $mn) {\n    $mn = $even;\n}\n\n$df = $odd - $mn;\n$kk = $df / 3;\n$qq = int($kk);\n$ans = $mn + $qq;\n\nprint \"$ans\\n\"\n\n"}], "negative_code": [{"source_code": "$_ = <STDIN>; my ($n) = split;\n$_ = <STDIN>; my @A = split;\n\n@P = grep($_ > 0 && $_ % 2 > 0, @A);\nprint @P . \"\\n\";"}, {"source_code": "my $n = <>;\n\n$inp = [split / /, <>];\n\n@a = (0, 0, 0);\n\n$ans = 0;\n\nforeach (@$inp) {\n    if ($_ % 2 == 0) {\n        $a[1]++;\n    }\n    else {\n        $a[2]++;        \n    }\n}\n\nmy $d;\nif ($a[1] < $a[2]) {\n    $d = $a[1];\n}\nelse {\n    $d = $a[2];\n}\n\n$ans += $d;\n$a[1] -= $d;\n$a[2] -= $d;\n\n$ans += ($a[2]) / 3;\n\nprint $ans;"}, {"source_code": "my $n = <>;\n\n$inp = [split / /, <>];\n\n@a = (0, 0);\n\n$ans = 0;\n\nforeach (@$inp) {\n    if ($_ == 1) {\n        $a[0]++;\n    }\n    elsif ($_ % 2 == 0) {\n        $a[1]++;\n    }\n    else {\n        $ans++;        \n    }\n}\n\nmy $d;\nif ($a[0] < $a[1]) {\n    $d = $a[0];\n}\nelse {\n    $d = $a[1];\n}\n\n$ans += $d;\n\n$ans += ($a[0] - $d) / 3;\n\nprint $ans;"}, {"source_code": "chomp ($n = <STDIN>);\nchomp ($str = <STDIN>);\n$odd = 0;\n$even = 0;\n$len = length($str);\nfor $x(0..($len - 1)) {\n    $c = substr($str, $x, 1);\n    if (($c eq '0' || $c eq '2' || $c eq '4' || $c eq '6' || $c eq '8') && (substr($str, $x + 1, 1) eq ' ' || $x + 1 == $len)) { $even = $even + 1; }\n    if (($c eq '1' || $c eq '3' || $c eq '5' || $c eq '7' || $c eq '9') && (substr($str, $x + 1, 1) eq ' ' || $x + 1 == $len)) { $odd = $odd + 1; }\n}\nif ($odd < $even) { print($odd); }\nelse { print($even); }"}, {"source_code": "my $x = <STDIN>;\nchomp $x;\n\nmy $line = <STDIN>;\nchomp $line;\n\nmy @splits = split / /, $line;\n\nmy $odd = 0;\nmy $even = 0;\nfor my $split (@splits) {\n    if (int($split) % 2 == 0) {\n        $even += 1;\n    } else {\n        $odd += 1;\n    }\n}\n\nif ($even < $odd) {\n    print $even . \"\\n\";\n} else {\n    print $odd . \"\\n\";\n}\n"}, {"source_code": "my $x = <STDIN>;\nchomp $x;\n\nmy $line = <STDIN>;\nchomp $line;\n\nmy @splits = split /,/, $line;\n\nmy $odd = 0;\nmy $even = 0;\nfor my $split (@splits) {\n    if (int($split) % 2 == 0) {\n        $even += 1;\n    } else {\n        $odd += 1;\n    }\n}\n\nif ($even < $odd) {\n    print $even . \"\\n\";\n} else {\n    print $odd . \"\\n\";\n}\n"}], "src_uid": "61e6fd68d7568c599204130b102ea389"}
{"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO", "positive_code": [{"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "print qw(YES NO)[$_ = <> xor /AB.*BA/ || /BA.*AB/ ]"}, {"source_code": "$_ = <>;\nif (/AB.*BA/ || /BA.*AB/) {\n\tprint 'YES';\n} else {\n\tprint 'NO';\n}\n"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "print qw(YES NO)[$_ = <> xor /AB.*BA/ || /BA.*AB/ ]"}, {"source_code": "print qw(YES NO)[$_ = <> xor /AB.*BA/ || /BA.*AB/ ]"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "$_=<>;\nprintf \"%s\", (/AB.*BA/ or /BA.*AB/)?'YES':'NO'"}, {"source_code": "$_=<>;\nprint qw/NO YES/[ 0+(/AB.*BA/ or /BA.*AB/) ]"}, {"source_code": "$_=<>;\nif(/AB.*BA/ or /BA.*AB/) {                                                      \n  print \"YES\";\n} else {\n  print \"NO\";\n}"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "\n$_ = <>;\nmy $ans = \"NO\\n\";\n$ans = \"YES\" if (/AB.*BA/ || /BA.*AB/);\nprint $ans;\n"}, {"source_code": "print qw(YES NO)[$_ = <> xor /AB.*BA/ || /BA.*AB/ ]"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n"}, {"source_code": "$_=<>;print/AB.*BA/||/BA.*AB/?YES:NO\n\n"}, {"source_code": "$a = <>; \nif ($a =~ m[AB.*BA]||$a =~ m[BA.*AB])  \n{ \n    print \"YES\"; \n} \nelse \n{ \n    print \"NO\"; \n}"}, {"source_code": "$ch=<>;\nchomp$ch;\n$occ1=0;\n$occ2=0;\n$n=length$ch;\nfor($i=0;$i<$n-1;$i++){\nif(substr($ch,$i,2)eq \"AB\"){\n$occ1++;\n$ind1=$i;\n\n}\nif(substr($ch,$i,2)eq \"BA\"){\n$occ2++;\n$ind2=$i;\n\n}\n\n}\nif($occ1==0 || $occ2==0 || ($occ1<=2 && $occ2==1 && abs($ind1-$ind2)==1)||($occ2<=2 && $occ1==1 && abs($ind1-$ind2)==1)){\nprint \"NO\";\n}\nelse{\nprint \"YES\";\n}"}], "negative_code": [{"source_code": "$_=<>;\nprint qw/NO YES/[ /AB.*BA/ or /BA.*AB/ ]"}, {"source_code": "$ch=<>;\nchomp$ch;\n$occ1=0;\n$occ2=0;\n$n=length$ch;\nfor($i=0;$i<$n-1;$i++){\nif(substr($ch,$i,2)eq \"AB\"){\n$occ1++;\n$ind1=$i;\n\n}\nif(substr($ch,$i,2)eq \"BA\"){\n$occ2++;\n$ind2=$i;\n\n}\n\n}\nif($occ1==0 || $occ2==0 || ($occ1==1 && $occ2==1 && abs($ind1-$ind2)==1)){\nprint \"NO\";\n}\nelse{\nprint \"YES\";\n}"}, {"source_code": "print qw(YES NO)[$_ = <>, ! (/AB.*BA/ || /BA.*AB/) ]"}], "src_uid": "33f7c85e47bd6c83ab694a834fa728a2"}
{"source_code": "<>&do{print((map{++$c%2?'a'eq$_?'b':'a':'z'eq$_?'y':'z'}split'',$_),\"\\n\")until$c=!chomp($_=<>)}", "positive_code": [{"source_code": "for (1..<>) {\r\n    chomp($_=<>);\r\n    my $c = 0;\r\n    for my $s (split'', $_) {\r\n        print ++$c % 2 ? ($s eq 'a' ? 'b' : 'a') : ($s eq 'z' ? 'y' : 'z')\r\n    }\r\n    print \"\\n\"\r\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\ts/(.)(.)?/\n\t\tmy( $_1, $_2 ) = ( $1, $2 );\n\t\t$_1 =~ y!ab-z!ba!;\n\t\t$_2 =~ y!za-y!yz!;\n\t\t$_1 . $_2;\n\t\t/ge;\n\t\n\tprint;\n\t}"}], "negative_code": [], "src_uid": "c02357c4d959e300f970f66f9b3107eb"}
{"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n", "positive_code": [{"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($n, $m) = split / /, <>;\npush @a, [split //, <>] foreach(1 .. $n);\n($n<2 || $m<2) and say 0 and exit;\n$ans = 0;\nforeach $i (0 .. $n-2) {\n\tforeach $j (0 .. $m-2) {\n\t\t$f = ($a[$i][$j]eq'f' || $a[$i][$j+1]eq'f' || $a[$i+1][$j]eq'f' || $a[$i+1][$j+1]eq'f');\n\t\t$a = ($a[$i][$j]eq'a' || $a[$i][$j+1]eq'a' || $a[$i+1][$j]eq'a' || $a[$i+1][$j+1]eq'a');\n\t\t$c = ($a[$i][$j]eq'c' || $a[$i][$j+1]eq'c' || $a[$i+1][$j]eq'c' || $a[$i+1][$j+1]eq'c');\n\t\t$e = ($a[$i][$j]eq'e' || $a[$i][$j+1]eq'e' || $a[$i+1][$j]eq'e' || $a[$i+1][$j+1]eq'e');\n\t\t# say \"[$i, $j]: $f $a $c $e\";\n\t\t$ans += ($f && $a && $c && $e) ? 1:0;\n\t}\n}\nsay $ans;\n"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i\n"}, {"source_code": "$m = (split \" \", <>)[1] - 1;\nlocal $/;\n$_ = <>;\n$i += \"acef\" eq join '', sort split //, \"$1$2$3\" while /([face])(?=([face]).{$m}([face]{2}))/sg;\nprint 0 + $i"}], "negative_code": [], "src_uid": "742e4e6ca047da5f5ebe5d854d6a2024"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n#use bigint;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n    \n\tchomp;\n    \n\tmy $cnt = 0;\n    my $dec;\n    my $bin;\n    \n\t/\n\t\t(?{ $dec = 0; })\n\t\t#(?{ $bin = ''; })\n\t\t0*+\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.{0,17}?)(.)\n\t\t#\t(?(?{ $+[0] - $-[0] + 2 < $+[2] - $-[1] << 1 }) (*F) )\n\t\t\t\n\t\t\t(?{\n\t\t        $dec <<= 1;\n\t\t\t    $dec |= $2;\n\t\t\t#    $bin .= $2;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t#\t$cnt ++ if $+[0] - $-[0] >= eval \"0b$bin\";\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t\n\tchomp;\n\t\n\tmy $cnt = 0;\t\n\tmy $dec;\n\t\n\t/\n\t\t(?{ $dec = 0; })\n\t\t0*+\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.{0,17}?)(.)\n\t\t\t(?{\n\t\t\t\t$dec <<= 1;\n\t\t\t\t$dec |= $2;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n    \n\tchomp;\n    \n\tmy $cnt = 0;\n    my $dec;\n    \n\t/\n\t\t(?{ $dec = 0; })\n\t\t0*+\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.*?)(.)\n\t\t\t(?(?{ $+[0] - $-[0] + 2 < $+[2] - $-[1] << 1 }) (*F) )\n\t\t\t(?{\n\t\t\t    $dec <<= 1;\n\t\t\t    $dec |= $2;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n    \n\tchomp;\n    \n\tmy $cnt = 0;\n    my $dec;\n    \n\t/\n\t\t(?{ $dec = 0; })\n\t\t(0*+)\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.*?)(.)\n\t\t\t(?(?{ $+[0] - $-[0] + 2 < $+[3] - $+[1] << 1 }) (*F) )\n\t\t\t(?{\n\t\t\t    $dec <<= 1;\n\t\t\t    $dec |= $3;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n#use bigint;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n    \n\tchomp;\n    \n\tmy $cnt = 0;\n    my $dec;\n    my $bin;\n    \n\t/\n\t\t(?{ $dec = 0; })\n\t\t(?{ $bin = ''; })\n\t\t0*+\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.*?)(.)\n\t\t\t(?(?{ $+[2] - $-[1] > 20 }) (*PRUNE) (*F) )\n\t\t\t(?(?{ $+[0] - $-[0] + 2 < $+[2] - $-[1] << 1 }) (*F) )\n\t\t\t\n\t\t\t(?{\n\t\t        $dec <<= 1;\n\t\t\t    $dec |= $2;\n\t\t\t#    $bin .= $2;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t#\t$cnt ++ if $+[0] - $-[0] >= eval \"0b$bin\";\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n#use bigint;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n    \n\tchomp;\n    \n\tmy $cnt = 0;\n    my $dec;\n    my $bin;\n    \n\t/\n\t\t(?{ $dec = 0; })\n\t\t(?{ $bin = ''; })\n\t\t0*+\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.*?)(.)\n\t\t\t(?(?{ $+[2] - $-[1] > 20 }) (*SKIP) (*F) )\n\t\t\t(?(?{ $+[0] - $-[0] + 2 < $+[2] - $-[1] << 1 }) (*F) )\n\t\t\t\n\t\t\t(?{\n\t\t        $dec <<= 1;\n\t\t\t    $dec |= $2;\n\t\t\t#    $bin .= $2;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t#\t$cnt ++ if $+[0] - $-[0] >= eval \"0b$bin\";\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n    \n\tchomp;\n    \n\tmy $cnt = 0;\n    my $dec;\n    \n\t/\n\t\t(?{ $dec = 0; })\n\t\t0*+\n\t\t(*SKIP)\n\t\t(?=\n\t\t\t(.*?)(.)\n\t\t\t(?(?{ $+[0] - $-[0] + 2 < $+[2] - $-[1] << 1 }) (*F) )\n\t\t\t(?{\n\t\t\t    $dec <<= 1;\n\t\t\t    $dec += $2;\n\t\t\t\t$cnt ++ if $+[0] - $-[0] >= $dec;\n\t\t\t\t})\n\t\t\t(*F)\n\t\t\t)\n\t\t(*F)\n\t\t/x;\n\t\n\t$cnt -= () = /01/g;\n\t$cnt -= () = /01(?=0)/g;\n\t\n\tprint $cnt;\n\t}"}], "src_uid": "3c93a76f986b1ef653bf5834716ac72a"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tprint /([13579]).*?([13579])/ ? $1 . $2 : -1;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n<>;\n\nprint <> =~ /[13579].*?[13579]/ ? $& : -1 while <>;\nprint <> =~ y/02468//dr =~ /../ ? $& : -1 while <>; # alt\n"}, {"source_code": "<>;<>;while(<>){if(/([13579].*?[13579])/){print \"$1\\n\";}else{print -1,\"\\n\";}<>;}"}, {"source_code": "$\\ = $/;\n\n<>;\n\nprint <> =~ /([13579]).*?([13579])/ ? $1 . $2 : -1 while <>;"}], "negative_code": [{"source_code": "<>;<>;while(<>){if(/([13579].*[13579])/){print \"$1\\n\";}else{print -1,\"\\n\";}<>;}"}, {"source_code": "$\\ = $/;\n\n<>;\n\nprint <> =~ /[13579].*[13579]/ ? $& : -1 while <>;\nprint <> =~ y/02468//dr =~ /../ ? $& : -1 while <>; # alt\n"}], "src_uid": "8f00837e04627e445dfb8b6cd0216640"}
{"source_code": "my $n = <>;\n\n# my @m = split \" \", scalar <>;\n\nmy @A = map {my @tmp = split \" \"; shift (@tmp) == @tmp or die \"???\"; [@tmp];} <>;\n\n# (scalar @A) == (scalar @m) or die ((scalar @A) . ' ' . (scalar @m));\n\nmy @B = map{\n    my @tmp = ();\n    $tmp[100] = undef;\n    @tmp[@$_] = (1) x @$_;\n    \\@tmp;\n    } @A;\n\nforeach my $curr (@B){\n    my $good = 2;\n    foreach my $chk (@A){\n        # continue if $_ == $curr;\n        $good-- unless grep {not $_} @$curr[@$chk];\n        }\n    print $good > 0 ? \"YES\\n\" : \"NO\\n\";\n    }\n1;", "positive_code": [{"source_code": "\nmy $n = <>;\n\n# my @m = split \" \", scalar <>;\n\nmy @A = map {my @tmp = split \" \"; shift (@tmp) == @tmp or die \"???\"; [@tmp];} <>;\n\n# (scalar @A) == (scalar @m) or die ((scalar @A) . ' ' . (scalar @m));\n\nmy @B = map{\n    my @tmp = ();\n    $tmp[100] = undef;\n    @tmp[@$_] = (1) x @$_;\n    \\@tmp;\n    } @A;\n\nforeach my $curr (@B){\n    my $good = 2;\n    foreach my $chk (@A){\n        # continue if $_ == $curr;\n        $good-- unless grep {not $_} @$curr[@$chk];\n        }\n    print $good > 0 ? \"YES\\n\" : \"NO\\n\";\n    }\n\n1;\n\n\n"}], "negative_code": [{"source_code": "$n = <>;\n@A = map {@tmp = split \" \"; shift (@tmp) == @tmp or die \"???\"; [@tmp];} <>;\n\n@B = map{\n    @tmp = ();\n    $tmp[100] = undef;\n    @tmp[@$_] = (1) x @$_;\n    \\@tmp;\n    } @A;\n\nforeach $curr (@B){\n    $good = 2;\n    foreach $chk (@A){\n        $good-- unless grep {not $_} @$curr[@$chk];\n        }\n    print $good > 0 ? \"YES\\n\" : \"NO\\n\";\n    }"}], "src_uid": "90a47422f7ae53beb0a817422d760c6e"}
{"source_code": "use feature ':all';\n\nwhile(<>){\n\t@_ = ('+');\n\t/0/ and say \"@_\" and next;\n\tfor $i (1 .. $_){\n\t\t@new = ();\n\t\tfor $line (@_){\n\t\t\t@syms = split //, $line;\n\t\t\t$doubled = '';\n\t\t\tfor $k (@syms){ $doubled .= $k . $k };\n\t\t\t$mixed = '';\n\t\t\tfor $k (@syms){ $mixed .= $k . ($k eq '+' ? '*' : '+') };\n\t\t\tpush @new, $doubled, $mixed;\n\t\t\t}\n\t\t@_ = @new;\n\t\t}\n\tsay join \"\\n\", @_;\n\t}", "positive_code": [{"source_code": "$, = $/;\n\n@_ = ('+');\n\n@_ = map {\n\ts/./$&$&/rg,\n\ts/./$& eq '+' ? '+*':'*+'/rge\n} @_ for 1 .. <>;\n\t\nprint @_"}], "negative_code": [], "src_uid": "4e25d49e8a50dacc1cfcc9413ee83db6"}
{"source_code": "print-1&(1+(<>-1||3))/3+0.9,\" \"for(1..<>)", "positive_code": [{"source_code": "print-1&(1+(<>-1||3))/3+0.9,\" \"for(1..<>)"}], "negative_code": [], "src_uid": "208e285502bed3015b30ef10a351fd6d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $t ) = split;\n\t\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @_;\n\t\n\tmy $cnt = 0;\n\t\n\tmy $i = 0;\n\t\n\twhile( @_ ){\n\t\tif( 0 < int $t / $sum ){\n\t\t\t$cnt += @_ * ( int $t / $sum );\n\t\t\t$t -= $sum * ( int $t / $sum );\n\t\t\t}\n\t\tmy $this = shift @_;\n\t\tif( $this > $t ){\n\t\t\t$sum -= $this;\n\t\t\tnext;\n\t\t\t}\n\t\telse{\n\t\t\t$t -= $this;\n\t\t\t$cnt ++;\n\t\t\tpush @_, $this;\n\t\t\tnext;\n\t\t\t}\n\t\t}\n\t\n\tprint $cnt;\n\t}", "positive_code": [{"source_code": "( $n, $t, @_ ) = split ' ', <> . <>;\n\n$s += $_ for @_;\n\nwhile( @_ ){\n\t$m = int $t / $s;\n\tif( $m ){\n\t\t$c += @_ * $m;\n\t\t$t -= $s * $m;\n\t\t}\n\t$i = shift @_;\n\tif( $i > $t ){\n\t\t$s -= $i;\n\t\t}\n\telse{\n\t\t$t -= $i;\n\t\t$c ++;\n\t\tpush @_, $i;\n\t\t}\n\t}\n\nprint 0 + $c"}], "negative_code": [], "src_uid": "92db85bb3880b9d11f93cacd566ecda7"}
{"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\n#    int ans = 0, cur = -1e5;\n#    for (char c : $s) {\n#        if (c == 'A') {ans = max(ans, cur);cur = 0;}else {++cur;}\n#    }\n#    answer(max(ans,cur));\n\nsub solve {\n    my ($ans, $n) = (0, int(<>));\n    my @s = split(\"\", <>); \n    my $p = $n - 1;\n    for (my $i = $n - 1; $i > -1; $i--) {\n        if ($s[$i] eq \"A\") {\n            if ($ans < $p - $i)\n                { $ans = $p - $i; }\n            $p = $i - 1;\n\t\t}\n\t}\n    print \"$ans\\n\";\n}\n\nsub main {\n    my $t = 1;\n    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main());\n", "positive_code": [{"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\nsub solve {\n    my ($ans, $n) = (0, int(<>));\n    my @s = split(\"\", <>); \n    my $p = $n - 1;\n    for (my $i = $n - 1; $i > -1; $i--) {\n        if ($s[$i] eq \"A\") {\n            if ($ans < $p - $i)\n                { $ans = $p - $i; }\n            $p = $i - 1;\n\t\t}\n\t}\n    print \"$ans\\n\";\n}\n\nsub main {\n    my $t = 1;\n    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main());\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    while($q > 0) {\n        $q--;\n        my $s= <$in>;\n        my $z= <$in>;\n        my @l= split('', $z);\n\n        my $i= -1;\n        for my $stud (@l) {\n            last if($stud eq 'A');\n            if($i==-1) {\n                $i= 0;\n            } else {\n                $i++;\n            }\n        }\n\n        $i++;\n\n        if($i == -1) {\n            print \"0\\n\";\n            next;\n        }\n\n        my $c= 0;\n        my $max= 0;\n        for(my $j=$i; $j < $#l; $j++) {\n            if($l[$j] eq 'A') {\n                $c= 0;\n            } else {\n                $c++;\n                if($max < $c) {\n                    $max = $c;\n                }\n            }\n\n        }\n\n        print \"$max\\n\";\n\n    }\n\n}\n\nmain() unless caller();\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\nsub solve {\n    my ($ans, $n) = (0, int(<>));\n    my @s = split(\"\", <>); \n    my $f = 0;\n    for (my $i = $n - 1; $i > -1; $i--) {\n\t\tif ($s[$i] eq 'A') {\n            $f = 1;\n\t\t    last;\n\t\t}\n        $ans++;\n\t}\n\t$ans *= $f;\n    print \"$ans\\n\";\n}\n\nsub main {\n    my $t = 1;\n    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main());\n"}, {"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\nsub solve {\n    my ($ans, $n) = (0, int(<>));\n    my @s = split(\"\", <>); \n    for (my $i = $n - 1; $i > -1; $i--) {\n\t\tif ($s[$i] eq 'A') {\n\t\t    last;\n\t\t}\n        $ans++;\n\t}\n    print \"$ans\\n\";\n}\n\nsub main {\n    my $t = 1;\n    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main());\n"}, {"source_code": "#!/usr/bin/env perl\npackage Codeforces::Task::A;\nuse v5.10;\nuse strict;\nuse warnings;\n\n#    int ans = 0, cur = -1e5;\n#    for (char c : $s) {\n#        if (c == 'A') {ans = max(ans, cur);cur = 0;}else {++cur;}\n#    }\n#    answer(max(ans,cur));\n\nsub solve {\n    my ($ans, $n) = (0, int(<>));\n    my @s = split(\"\", <>); \n    push(@s, \"A\");\n    my $p = $n - 1;\n    for (my $i = $n - 1; $i > -1; $i--) {\n        if ($s[$i] eq \"A\") {\n            if ($ans < $p - $i)\n                { $ans = $p - $i; }\n            $p = $i;\n\t\t}\n\t}\n    print \"$ans\\n\";\n}\n\nsub main {\n    my $t = 1;\n    $t = int(<>);\n    while ($t--) {\n        solve();\n    }\n    return 0;\n}\n\nexit(main());\n"}], "src_uid": "1539fc8ef4f4cdcd1e14faf4f1b4ee8b"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub max {\n\tmy ($x, $y) = (shift, shift);\n\treturn $x>$y ? $x:$y;\n}\n\n($n, $t) = split / /, <>;\n$ans = -1000000005;\nforeach (1 .. $n) {\n\t@a = split / /, <>;\n\tif ($a[1] > $t) {\n\t\t$ans = max($ans, $a[0]-$a[1]+$t);\n\t} else {\n\t\t$ans = max($ans, $a[0]);\n\t}\n}\nsay $ans;", "positive_code": [{"source_code": "#!/bin/perl\nuse strict;\nuse warnings;\n\nmy ($n, $k) = map int, split '\\D', <>;\nmy $p = 0;\nfor my $i (1..$n) {\n  my ($f, $t) = map int, split '\\D', <>;\n  my $np = ($k < $t)? $f - $t + $k: $f;\n  if ( ($i == 1) || ($p < $np) ) {\n    $p = $np;\n  }\n}\nprint $p;"}], "negative_code": [], "src_uid": "1bb5b64657e16fb518d49d3c799d4823"}
{"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ .= <>;\r\n\t\r\n\tmy $max_len = 0;\r\n\t\r\n\tm/\r\n\t\t(.*) .*\r\n\t\t\\n\r\n\t\t.* \\1\r\n\t\t(?{ \r\n\t\t\t$max_len < length $1 and $max_len = length $1;\r\n\t\t\t})\r\n\t\t(*FAIL)\r\n\t\t/x;\r\n\t\r\n\tprint +( length ) - 2 - $max_len * 2;\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$_ .= <>;\n\t\n\tmy %h;\n\t\n\tm/\n\t\t(.*) .*\n\t\t\\n\n\t\t.* \\1\n\t\t(?{ $h{ $1 } ++; })\n\t\t(*FAIL)\n\t\t/x;\n\t\n\tmy( $L ) = sort { $b <=> $a } map length, keys %h;\n\t\n\tprint +( length ) - ( $L + 1 ) * 2;\n\t}"}, {"source_code": "#!/usr/bin/perl\r\n\r\nmy ($t) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $t -- > 0 ){\r\n  ( my $a = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  ( my $b = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  \r\n  my %a = ();\r\n  my %b = ();\r\n  my %k = ();\r\n  for(my $i=0;$i<length($a);$i++){\r\n    for(my $j=$i;$j<length($a);$j++){\r\n      my $s1 = substr($a,$i,$j-$i+1);\r\n      $a{$s1} = &min($a{$s1} eq '' ? 1000000000 : $a{$s1},length($a) - ($j-$i+1));\r\n      $k{$s1} = 1;\r\n    }\r\n  }\r\n  for(my $i=0;$i<length($b);$i++){\r\n    for(my $j=$i;$j<length($b);$j++){\r\n      my $s1 = substr($b,$i,$j-$i+1);\r\n      $b{$s1} = &min($b{$s1} eq '' ? 1000000000 : $b{$s1},length($b) - ($j-$i+1));\r\n      $k{$s1} = 1;\r\n    }\r\n  }\r\n  my $mn = length($a) + length($b);\r\n  foreach my $kk (keys %k){\r\n    if( exists($a{$kk}) and exists($b{$kk}) ){\r\n      my $v = $a{$kk} + $b{$kk};\r\n      $mn = $v if $v < $mn;\r\n    }\r\n  }\r\n  print \"$mn\\n\";\r\n}\r\n\r\nexit(0);\r\n\r\nsub min {\r\n  my ($x,$y) = @_;\r\n  return ( $x < $y ? $x : $y );\r\n}\r\n\r\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\n\r\nmy ($t) = map { $_ - 0 } split(/\\s+/o,<STDIN>);\r\n\r\nwhile( $t -- > 0 ){\r\n  ( my $a = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  ( my $b = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  \r\n  my %a = ();\r\n  my %b = ();\r\n  my %k = ();\r\n  for(my $i=0;$i<length($a);$i++){\r\n    for(my $j=$i;$j<length($a);$j++){\r\n      my $s1 = substr($a,$i,$j-$i+1);\r\n      $a{$s1} = &min($a{$s1} eq '' ? 1000000000 : $a{$s1},length($a) - ($j-$i+1));\r\n      $k{$s1} = 1;\r\n    }\r\n  }\r\n  for(my $i=0;$i<length($b);$i++){\r\n    for(my $j=$i;$j<length($b);$j++){\r\n      my $s1 = substr($b,$i,$j-$i+1);\r\n      $b{$s1} = &min($b{$s1} eq '' ? 1000000000 : $b{$s1},length($b) - ($j-$i+1));\r\n      $k{$s1} = 1;\r\n    }\r\n  }\r\n  my $mn = 10000000000;\r\n  foreach my $kk (keys %k){\r\n    if( exists($a{$kk}) and exists($b{$kk}) ){\r\n      my $v = $a{$kk} + $b{$kk};\r\n      $mn = $v if $v < $mn;\r\n    }\r\n  }\r\n  print \"$mn\\n\";\r\n}\r\n\r\nexit(0);\r\n\r\nsub min {\r\n  my ($x,$y) = @_;\r\n  return ( $x < $y ? $x : $y );\r\n}\r\n\r\n"}], "src_uid": "36aec7a06c02052f562ea3d44d4a62e4"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t\n\tmy %h;\n\t\n\tfor my $i (2 .. $_){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ v }{ $v } ++;\n\t\t$h{ $v }{ v }{ $u } ++;\n\t\t}\n\t\n\tmy $i = 0;\n\tmap { $i ++; $h{ $i }{ c } = $_ } split ' ', <>;\n\t\n\tmy @sorted = grep { keys %{ $h{ $_ }{ v } } == 1 } \n\t\tsort { keys %{ $h{ $a }{ v } } <=> keys %{ $h{ $b }{ v } } } keys %h;\n\t$debug and print \"@sorted\";\n\t\n\tmy $i;\n\t\n\twhile( @sorted ){ \n\t\t$i = shift @sorted;\n\t\tmy( $key ) = keys %{ $h{ $i }{ v } };\n\t\tif( $h{ $i }{ c } != $h{ $key }{ c } ){\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tdelete $h{ $key }{ v }{ $i };\n\t\tkeys %{ $h{ $key }{ v } } == 1 and unshift @sorted, $key;\n\t\tdelete $h{ $i }{ v };\n\t\t}\n\t\n\t$debug and print \"keys: \", map { ~~ keys %{ $h{ $_ }{ v } } } keys %h;\n\tmy @g = grep $_ > 1, map { ~~ keys %{ $h{ $_ }{ v } } } keys %h;\n\t$debug and print \"[@sorted]\";\n\t\n\tif( @g > 1 ){\n\t\tprint \"NO\";\n\t\t}\n\telsif( @g == 0 ){\n\t\tprint \"YES\";\n\t\tprint $i;\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\tmy $j;\n\t\tfor my $k (keys %h){\n\t\t\tkeys %{ $h{ $k }{ v } } > 1 and $j = $k;\n\t\t\t}\n\t\tprint $j;\n\t\t}\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\tmy %h;\n\t\n\tfor my $i (2 .. $_){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ v }{ $v } ++;\n\t\t$h{ $v }{ v }{ $u } ++;\n\t\t}\n\t\n\tmy $i = 0;\n\tmap { $i ++; $h{ $i }{ c } = $_ } split ' ', <>;\n\t\n\tmy @s = grep keys %{ $h{ $_ }{ v } } == 1, keys %h;\n\t\n\tmy $j;\n\t\n\twhile( @s ){ \n\t\t$j = shift @s;\n\t\tmy( $key ) = keys %{ $h{ $j }{ v } };\n\t\tif( $h{ $j }{ c } != $h{ $key }{ c } ){\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tdelete $h{ $key }{ v }{ $j };\n\t\tkeys %{ $h{ $key }{ v } } == 1 and unshift @s, $key;\n\t\tdelete $h{ $j }{ v };\n\t\t}\n\t\t\n\tmy $g = 0;\n\t\n\tfor (keys %h){\n\t\tkeys %{ $h{ $_ }{ v } } > 1 and ++ $g and $j = $_;\n\t\t}\n\t\t\n\tprint $g > 1 ? \"NO\" : \"YES\\n$j\";\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\t\n\tmy %h;\n\t\n\tfor my $i (2 .. $_){\n\t\tmy( $u, $v ) = split ' ', <>;\n\t\t\n\t\t$h{ $u }{ v }{ $v } ++;\n\t\t$h{ $v }{ v }{ $u } ++;\n\t\t}\n\t\n\tmy $i = 0;\n\tmap { $i ++; $h{ $i }{ c } = $_ } split ' ', <>;\n\t\n\tmy @sorted = grep { keys %{ $h{ $_ }{ v } } == 1 } \n\t\tsort { keys %{ $h{ $a }{ v } } <=> keys %{ $h{ $b }{ v } } } keys %h;\n\t$debug and print \"@sorted\";\n\t\n\twhile( @sorted ){ \n\t\tmy $i = shift @sorted;\n\t\tmy( $key ) = keys %{ $h{ $i }{ v } };\n\t\tif( $h{ $i }{ c } != $h{ $key }{ c } ){\n\t\t\tnext;\n\t\t\t}\n\t\t\n\t\tdelete $h{ $key }{ v }{ $i };\n\t\tkeys %{ $h{ $key }{ v } } == 1 and unshift @sorted, $key;\n\t\tdelete $h{ $i }{ v };\n\t\t}\n\t\n\t$debug and print \"keys: \", map { ~~ keys %{ $h{ $_ }{ v } } } keys %h;\n\tmy @g = grep $_ > 1, map { ~~ keys %{ $h{ $_ }{ v } } } keys %h;\n\t$debug and print \"[@sorted]\";\n\t\n\tif( @g > 1 ){\n\t\tprint \"NO\";\n\t\t}\n\telsif( @g == 0 ){\n\t\tprint \"YES\";\n\t\tprint 1;\n\t\t}\n\telse{\n\t\tprint \"YES\";\n\t\tmy $j;\n\t\tfor my $k (keys %h){\n\t\t\tkeys %{ $h{ $k }{ v } } > 1 and $j = $k;\n\t\t\t}\n\t\tprint $j;\n\t\t}\n\t}"}], "src_uid": "aaca5d07795a42ecab210327c1cf6be9"}
{"source_code": "$n = <STDIN>;\n@l = split ' ', <STDIN>;\n$ans = 0;\n$cmp = $n;\nfor ($i = $n - 1; $i >= 0; $i--) {\n  if ($i < $cmp) {\n    $ans++;\n  }\n  if ($i - @l[$i] < $cmp) {\n    $cmp = $i - @l[$i];\n  }\n}\nprint($ans);", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy $knife = 0;\n\tmy $alive = 0;\n\t\n\tfor my $i ( reverse 0 .. @_ - 1 ){\n\t\t$knife --;\n\t\t$knife < 0 and $alive ++;\n\t\t$_[ $i ] > $knife and $knife = $_[ $i ];\n\t\t}\n\t\n\tprint $alive;\n\t}"}], "negative_code": [], "src_uid": "beaeeb8757232b141d510547d73ade04"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nmy $vv = 10**9 + 7;\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my @A = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $n2 = int($n/2);\r\n  my @ot = ();\r\n  for(my $i=0;$i<$n2;$i++){\r\n    my $mn = &min($A[2*$i],$A[1+2*$i]);\r\n    push(@ot,+[1+2*$i,2+2*$i,$mn,$vv]);\r\n  }\r\n  print \"$n2\\n\";\r\n  for(my $i=0;$i<$n2;$i++){\r\n    my $o = $ot[$i];\r\n    print sprintf(\"%d %d %d %d\\n\",$o->[0],$o->[1],$o->[2],$o->[3]);\r\n  }\r\n}\r\n\r\nexit(0);\r\n\r\nsub min {\r\n  my ($x,$y) = @_;\r\n  return ( $x > $y ? $y : $x );\r\n}\r\n\r\n", "positive_code": [{"source_code": "$, = \" \";\r\nchomp($t = <STDIN>);\r\nforeach (1..$t)\r\n{\r\n    chomp($n = <STDIN>);\r\n    chomp($inp = <STDIN>);\r\n    @a = split / /, $inp;\r\n    ($mn, $p) = (1E9 + 7, -1);\r\n    $n -= 1;\r\n    foreach (0..$n)\r\n    {\r\n        if ($a[$_] < $mn)\r\n        {\r\n            $mn = $a[$_];\r\n            $p = $_;\r\n        }\r\n    }\r\n    print $n, \"\\n\";\r\n    foreach (0..$n)\r\n    {\r\n        next if $_ == $p;\r\n        print $p + 1, $_ + 1, $mn, $mn + abs($_ - $p), \"\\n\";\r\n    }\r\n}"}], "negative_code": [{"source_code": "$, = \" \";\r\nchomp($t = <STDIN>);\r\nforeach (1..$t)\r\n{\r\n    chomp($n = <STDIN>);\r\n    chomp($inp = <STDIN>);\r\n    @a = split / /, $inp;\r\n    ($mn, $p) = (1E9 + 7, -1);\r\n    $n -= 1;\r\n    foreach (0..$n)\r\n    {\r\n        if ($a[$_] < $mn)\r\n        {\r\n            $mn = $a[$_];\r\n            $p = $_;\r\n        }\r\n    }\r\n    print $n, \"\\n\";\r\n    foreach (0..$n)\r\n    {\r\n        next if $_ == $p;\r\n        print $p + 1, $_ + 1, $mn, $mn + abs($i - $p), \"\\n\";\r\n    }\r\n}"}, {"source_code": "$, = \" \";\r\nchomp($t = <STDIN>);\r\nforeach (1..$t)\r\n{\r\n    chomp($n = <STDIN>);\r\n    chomp($inp = <STDIN>);\r\n    @a = split / /, $inp;\r\n    ($mn, $p) = (1E9 + 7, -1);\r\n    $n -= 1;\r\n    foreach (0..$n)\r\n    {\r\n        if ($a[$_] < $mn)\r\n        {\r\n            $mn = $a[$_];\r\n            $p = $_;\r\n        }\r\n    }\r\n    print $n - 1, \"\\n\";\r\n    foreach (0..$n)\r\n    {\r\n        next if $_ == $p;\r\n        print $p + 1, $_ + 1, $mn, $mn + abs($i - $p), \"\\n\";\r\n    }\r\n}"}], "src_uid": "8b2b7208630af1d086420513a437a914"}
{"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n", "positive_code": [{"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES"}, {"source_code": "@a=split'|',<>;@b=split'|',<>;$f+=$_ for(@a);$s+=$_ for(@b);print\"NO\"and exit if($f%2&&$s>$f+1)or(!($f%2)&&$s>$f);print \"YES\"\n"}, {"source_code": "$f+=$_ for split'|',<>;$s+=$_ for split'|',<>;print((($f%2&&$s>$f+1)or(!($f%2)&&$s>$f))?NO:YES)"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}, {"source_code": "for($f,$s){$_=grep$_,(split'|',<>)}print$s-1>$f-$f%2?NO:YES\n"}], "negative_code": [{"source_code": "$f+=$_ for split'|',<>;$s+=$_ for split'|',<>;print(($f%2&&$s>$f+1)or(!($f%2)&&$s>$f)?NO:YES)\n"}], "src_uid": "cf86add6c92fa8a72b8e23efbdb38613"}
{"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    my @nums = split(/ /, <>);\n    my @odds;\n    my $sum = 0;\n\n    $_ & 1 ? push @odds, $_ : ($sum += $_) for @nums;\n\n    if (@odds & 1) {\n        @odds = sort {$a <=> $b} @odds;\n        shift @odds;\n    }\n    $sum += $_ for @odds;\n    \n    print \"$sum\";\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    my @nums = split(/ /, <>);\n    my @odds;\n    my $sum = 0;\n\n    $_ & 1 ? push @odds, $_ : ($sum += $_) for @nums;\n\n    if (@odds & 1) {\n        @odds = sort {$a <=> $b} @odds;\n        $sum += $_ for @odds[1..$#odds];\n    } else {\n        $sum += $_ for @odds;\n    }\n    \n    print \"$sum\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    my @nums = split(/ /, <>);\n    my @odds;\n    my $sum = 0;\n\n    $_ & 1 ? push @odds, $_ : ($sum += $_) for @nums;\n\n    if (@odds & 1) {\n        @odds = sort {$a <=> $b} @odds;\n        $sum += $_ for @odds[-$#odds..-1];\n    } else {\n        $sum += $_ for @odds;\n    }\n    \n    print \"$sum\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nmy $line = <>;\nchomp($line);\n\nmy @nums = split(/ /, $line);\nmy @odds;\nmy $sum = 0;\n\n$_ & 1 ? push @odds, $_ : ($sum += $_) for @nums;\n\nif (@odds % 2 == 0) {\n    $sum += $_ for @odds;\n} else {\n    @odds = sort {$a <=> $b} @odds;\n    shift @odds;\n    $sum += $_ for @odds;\n}\n\nprint \"$sum\";\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nmy $line = <>;\nchomp($line);\n\nmy @nums = split(/ /, $line);\n\nmy @odds;\nmy $sum = 0;\nfor (@nums) {\n    if ($_ % 2 == 0) {\n        $sum += $_;\n    } else {\n        push @odds, $_;\n    }\n}\n\nif (@odds % 2 == 0) {\n    for (@odds) {\n        $sum += $_;\n    }\n} else {\n    @odds = sort {$a <=> $b} @odds;\n    shift @odds;\n    for (@odds) {\n        $sum += $_;\n    }\n}\n\nprint \"$sum\";\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@_ = split ' ', <>;\n\t$sum = 0;\n\t@odd = ();\n\t\n\t$_ & 1 ? (push @odd, $_) : ($sum += $_) for @_;\n\t\n\t@odd = sort {$a <=> $b} @odd;\n\t@odd & 1 and shift @odd;\n\t$sum += $_ for @odd;\n\t\n\tprint $sum\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t\n\t@_ = split ' ', <>;\n\t$sum = 0;\n\t@odd = ();\n\t\n\t$_ & 1 ? (push @odd, $_) : ($sum += $_) for @_;\n\t\n\t@odd = sort {$a <=> $b} @odd;\n\t@odd & 1 and shift @odd;\n\t$sum += $_ for @odd;\n\t\n\tprint $sum\n\t}"}, {"source_code": "$n = <>;\n$n--;\n$nums = <>;\n@tab = split(' ',$nums);\n@tab = sort{$b <=> $a} @tab;\n$m = 0;\n$sum = 0;\nforeach my $num (@tab){\n\tif ($num % 2 == 1){\n\t\t$m = $num;\n\t}\n\t\n\t$sum += $num;\n}\n\nif ($sum % 2 == 1){\n\t$sum -= $m;\n}\n\nprint $sum;"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nmy $line = <>;\nchomp($line);\n\nmy @nums = split(/ /, $line);\n\nmy (@evens, @odds);\n\nfor (@nums) {\n    if ($_ % 2 == 0) {\n        push @evens, $_;\n    } else {\n        push @odds, $_;\n    }\n}\n\n\nmy $sum = 0;\n\nfor (@evens) {\n    $sum += $_;\n}\n\nif (@odds % 2 == 0) {\n    for (@odds) {\n        $sum += $_;\n    }\n} else {\n    @odds = reverse sort @odds;\n    for (@odds[-$#odds..-1]) {\n        $sum += $_;\n    }\n}\n\nprint \"$sum\";\n"}, {"source_code": "#!/usr/bin/perl\n\nwhile (<>) {\n    my @nums = split(/ /, <>);\n    my @odds;\n    my $sum = 0;\n\n    $_ & 1 ? push @odds, $_ : ($sum += $_) for @nums;\n\n    if (@odds & 1) {\n        @odds = sort @odds;\n        $sum += $_ for @odds[1..$#odds];\n    } else {\n        $sum += $_ for @odds;\n    }\n    \n    print \"$sum\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\nmy $line = <>;\nchomp($line);\n\nmy @nums = split(/ /, $line);\n\nmy (@evens, @odds);\n\nfor (@nums) {\n    if ($_ % 2 == 0) {\n        push @evens, $_;\n    } else {\n        push @odds, $_;\n    }\n}\n\n\nmy $sum = 0;\n\nfor (@evens) {\n    $sum += $_;\n}\n\nif (@odds % 2 == 0) {\n    for (@odds) {\n        $sum += $_;\n    }\n} else {\n    @odds = sort @odds;\n    for (@odds[-$#odds..-1]) {\n        $sum += $_;\n    }\n}\n\nprint \"$sum\";\n"}], "src_uid": "adb66b7b22d70bb37cb625d531d8865f"}
{"source_code": "#!/usr/bin/perl -w\nuse strict;\nuse warnings;\nuse List::Util qw{sum min};\n\nmy $n = int <>;\nmy @d = map int, split /\\D/, <>;\nmy ($s, $t) = map int, split /\\D/, <>;\nif ($s > $t) {\n    my $tmp = $t;\n    $t = $s;\n    $s = $tmp;\n}\nmy $s1 = 0;\nfor ($s-1 .. $t-2) {\n    $s1 += $d[$_];\n}\nmy $s2 = (sum @d) - $s1;\nprint min ($s1, $s2);\n", "positive_code": [{"source_code": "my $n = int<>;\nmy @arr = (0, split / /, <>);\nmy ($s, $t) = split / /, <>;\n($s, $t) = ($t, $s) if ($s > $t);\nmy ($temp, $ans) = (0, 0);\n$ans += $arr[$_] for ($s..$t-1);\n$temp += $arr[$_] for (1..$s-1);\n$temp += $arr[$_] for ($t..$n);\nprint $ans < $temp ? $ans : $temp;\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = (0, split / /, <>);\n$a[$_]+=$a[$_-1] foreach(1..$n);\n($s, $t) = split / /, <>;\n$s>$t and ($s,$t)=($t,$s);\n$s==$t and say 0 and exit;\n$tmp = $a[$t-1]-$a[$s-1];\n# say \"$s $t $tmp\";\n$ans = $tmp<$a[$n]-$tmp ? $tmp:$a[$n]-$tmp;\nsay $ans;"}, {"source_code": "#!usr/bin/perl\n#use warnings;\n#use strict;\n#use autodie;\n#use diagnostics;\nuse utf8;\nuse 5.010;\nuse 5.012;\nuse 5.014;\nmy($n,$ss,@arr,$s,$t,$count,$max);\nchomp($n=<STDIN>);\nchomp($ss=<STDIN>);\n@arr=split / /,$ss;\nchomp($ss=<STDIN>);\n($s,$t)=split / /,$ss;\n$count=$s;\n$max=999999999;\n$ss=0;\nwhile($count ne $t)\n{\n    $ss+=$arr[$count-1];\n    $count=0 if $count eq $n;\n    $count++;\n}\n$max=$ss if $max > $ss;\n($ss,$count)=(0,$s);\nwhile($count ne $t)\n{\n    $count=$n+1 if $count eq 1;\n    $count--;\n    $ss+=$arr[$count-1];\n}\n$max=$ss if $max > $ss;\nsay $max;\n"}, {"source_code": "<>;\n@a = split(\" \",<>);\n($s, $t) = split(\" \",<>);\nif ($s > $t)\n    {$tmp = $s; $s = $t; $t = $tmp}\n    \nif ($s == $t){print 0 ;exit}\n\n#print \"$s, $t,\\n\";\n\nfor ($s..$t-1){\n    $sum1 += $a[$_-1];\n    \n#    print \" $_: $a[$_-1]\\n\";\n}\n#print \"$sum1\\n\";\n\nfor (@a){\n    $sum2 += $_\n}\n#print \"$sum2\\n\";\n\nprint $sum1 > $sum2-$sum1 ? ($sum2-$sum1):($sum1)"}, {"source_code": "my $num = <>;\nchomp $num;\nmy @dist = grep /\\w/, split ' ', <>;\nmy ($s, $t) = sort {$a <=> $b} split ' ', <>;\n\nmy $r = 0;\n$r += $dist[$_-1] for $s..$t-1;\nmy $total;\n$total += $dist[$_-1] for 1..$num;\nmy $l = $total - $r;\nprint $r < $l ? $r : $l; "}], "negative_code": [], "src_uid": "22ef37041ebbd8266f62ab932f188b31"}
{"source_code": "for (<>){\n\ts/(.)= (-?\\d+)/$1.($2+(\"=\"cmp$1))/e;\n\n\tif (/N/){/</ and /-?\\d+/ and push @m, $&-1;\n\t\t\t />/ and /-?\\d+/ and push @M, $&+1}\n\telse{\t /</ and push @M, /-?\\d+/ && $&;\n\t\t\t />/ and push @m, /-?\\d+/ && $&}\n}\n@M=sort {$a<=>$b} @M;\n@m=sort {$a<=>$b} @m;\n\n$M= @M?$M[0]:2e9;\n$m= @m?$m[@m-1]:-2e9;\n\nprint $M>++$m?$m:Impossible", "positive_code": [{"source_code": "$up   = 1000000001;\n$down = -1000000001;\n$n    = <>;\n$flag = 0;\nwhile ( $n-- ) {\n    @array = split / /, <>;\n    chomp(@array);\n\n    if ( $array[2] eq \"N\" ) {\n        if ( $array[0] eq \"<=\" ) {\n            $array[0] = \">\";\n        }            \n        elsif ( $array[0] eq \">=\" ) {\n            $array[0] = \"<\";\n        }         \n        elsif ( $array[0] eq \"<\" ) {\n            $array[0] = \">=\";\n        }          \n        elsif ( $array[0] eq \">\" ) {\n            $array[0] = \"<=\";\n        }          \n    }\n\n    if ( $array[0] eq \"<=\" ) {\n        if ( $up > $array[1] ) { $up = $array[1]; }\n    }\n    elsif ( $array[0] eq \"<\" ) {\n        if ( $up > $array[1] - 1 ) { $up = $array[1] - 1; }\n    }\n\n    elsif ( $array[0] eq \">=\" ) {\n        if ( $down < $array[1] ) { $down = $array[1]; }\n    }\n    elsif ( $array[0] eq \">\" ) {\n        if ( $down < $array[1] + 1 ) { $down = $array[1] + 1; }\n    }\n\n    if ( $up < $down ) { $flag = 1; }\n\n}\n\n( $flag eq 1 ) ? print \"Impossible\" : print $up;"}, {"source_code": "\nwhile(<>){\n\t\n\t@_=<>;\n\t\n\t@max=@min=();\n\t\n\tfor (@_){\n\t\t\n\t\ts/<= (-?\\d+)/\"< \".($1+1)/e;\n\t\ts/>= (-?\\d+)/\"> \".($1-1)/e;\n\n#\t\tprint;\n\t\t\n\t\t/N/ and (s/< (-?\\d+)/\"> \".($1-1)/e or \n\t\ts/> (-?\\d+)/\"< \".($1+1)/e);\n\t\t\n\t#\t/Y/ and s/>/</;\n\t\t\n#\t\tprint;\n\t\t\n\t\t/</ and /-?\\d+/ and push @max, $&;\n\t\t/>/ and /-?\\d+/ and push @min, $&;\n\t\n\t\t}\n#\tprint \"@min\\n\", \"@max\\n\";\n\t\n\t@max=sort {$a<=>$b} @max;\n\t@min=sort {$a<=>$b} @min;\n\t\n\tif (@max) {$max=shift @max}\n\telse {$max=2*10**9}\n\t\n\tif (@min) {$min=pop @min}\n\telse {$min=-2*10**9}\n\t\n#\tprint \"\\n$max $min\";\n\t\n\tif ($max>$min+1){print $min+1}\n\telse {print \"Impossible\"}\n\t}\n\t\n"}, {"source_code": "#!/perl -w\n\nuse strict ;\n\nchomp ( my $n = <STDIN> );\nmy($gmax,$gmin) = (2*10**9,-2*10**9) ;\nwhile($n-- ){\n    my($symbol,$guess,$answer) = split /\\s+/s , <STDIN> ;\n    if($answer eq 'N'){\n        my $temp = $symbol ;\n        $symbol = '<'  if $temp eq '>=' ;\n        $symbol = '<=' if $temp eq '>'  ;\n        $symbol = '>'  if $temp eq '<=' ;\n        $symbol = '>=' if $temp eq '<' ;\n    }\n    \n    $gmin = ($guess > $gmin)? $guess : $gmin  if $symbol eq '>=' ;\n    $gmin = ($guess + 1 > $gmin)? $guess +1 : $gmin  if $symbol eq '>' ;\n    $gmax = ($guess < $gmax)? $guess : $gmax  if $symbol eq '<=' ;\n    $gmax = ($guess - 1 < $gmax)? $guess -1 : $gmax  if $symbol eq '<' ;\n}\n\nif($gmax < $gmin){\n    print \"Impossible\\n\" ;\n}else{\n    print \"$gmin\\n\";\n}\n\n\n"}], "negative_code": [{"source_code": "$up   = 1000000001;\n$down = -1000000001;\n$n    = <>;\n$flag = 0;\nwhile ( $n-- ) {\n    @array = split / /, <>;\n    chomp(@array);\n\n    if ( $array[2] eq \"N\" ) {\n        if ( $array[0] eq \"<=\" ) {\n            $array[0] = \">\";\n        }            \n        elsif ( $array[0] eq \">=\" ) {\n            $array[0] = \"<\";\n        }         \n        elsif ( $array[0] eq \"<\" ) {\n            $array[0] = \">=\";\n        }          \n        elsif ( $array[0] eq \">\" ) {\n            $array[0] = \"<=\";\n        }          \n    }\n\n    if ( $array[0] eq \"<=\" ) {\n        if ( $up > $array[1] ) { $up = $array[1]; }\n    }\n    elsif ( $array[0] eq \"<\" ) {\n        if ( $up > $array[1] - 1 ) { $up = $array[1] - 1; }\n    }\n\n    elsif ( $array[0] eq \">=\" ) {\n        if ( $down < $array[1] ) { $down = $array[1]; }\n    }\n    elsif ( $array[0] eq \">\" ) {\n        if ( $down < $array[1] + 1 ) { $down = $array[1] + 1; }\n    }\n\n    if ( $up < $down ) { $flag = 1; }\n\n}\n\n( $flag eq 1 ) ? print \"Impossoble\" : print $up;"}, {"source_code": "for (<>){\n\ts/(.)= (-?\\d+)/$1.($2+(\"=\"cmp$1))/e;\nprint \"=\"cmp$1,\"\\n\";\n\tif (/N/){/</ and /-?\\d+/ and push @m, $&-1;\n\t\t\t />/ and /-?\\d+/ and push @M, $&+1}\n\telse{\t /</ and push @M, /-?\\d+/ && $&;\n\t\t\t />/ and push @m, /-?\\d+/ && $&}\n}\n@M=sort {$a<=>$b} @M;\n@m=sort {$a<=>$b} @m;\n\n$M= @M?$M[0]:2e9;\n$m= @m?$m[@m-1]:-2e9;\n\nprint $M>++$m?$m:Impossible"}, {"source_code": "\nwhile(<>){\n\t\n\t@_=<>;\n\t\n\t@max=@min=();\n\t\n\tfor (@_){\n\t\t\n\t\ts/<= (-?\\d+)/\"< \".($1-1)/e;\n\t\ts/>= (-?\\d+)/\"> \".($1+1)/e;\n\n\t\t\n\t\t\n\t\t/N/ and tr/<>/></;\n\t#\t/Y/ and s/>/</;\n\t\t\n#\t\tprint;\n\t\t\n\t\t/</ and /-?\\d+/ and push @max, $&;\n\t\t/>/ and /-?\\d+/ and push @min, $&;\n\t\n\t\t}\n#\tprint \"@min\\n\", \"@max\\n\";\n\t\n\t@max=sort {$a<=>$b} @max;\n\t@min=sort {$a<=>$b} @min;\n\t\n\tif (@max) {$max=shift @max}\n\telse {$max=2*10**9}\n\t\n\tif (@min) {$min=pop @min}\n\telse {$min=-2*10**9}\n\t\n#\tprint \"\\n$max $min\";\n\t\n\tif ($max>$min+1){print $min+1}\n\telse {print \"Impossible\"}\n\t}\n\t\n"}, {"source_code": "for (<>){\n\ts/(.)= (-?\\d+)/$1.($2+($1cmp\"=\"))/e;\n\n\tif (/N/){/</ and /-?\\d+/ and push @m, $&-1;\n\t\t\t />/ and /-?\\d+/ and push @M, $&+1}\n\telse{\t /</ and push @M, @q=/-?\\d+/;\n\t\t\t />/ and push @m, @q=/-?\\d+/}\n}\n@M=sort {$a<=>$b} @M;\n@m=sort {$a<=>$b} @m;\n\n$M= @M?$M[0]:2e9;\n$m= @m?$m[@m-1]:-2e9;\n\nprint $M>++$m?$m:Impossible"}], "src_uid": "6c6f29e1f4c951cd0ff15056774f897d"}
{"source_code": "chomp($i=<>);\n$i=~tr/{} //d;\nprint scalar(do{ \n    %s; \n    grep{\n        !$s{$_\n    }++;\n    } \nsplit(/,/,$i); \n}\n);", "positive_code": [{"source_code": "chomp($i=<STDIN>);$i=~tr/{} //d;print scalar(do{%s;grep{!$s{$_}++}split(/,/,$i)});"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nmy %st;\nchomp($line = <>);\n$st{$_}++ foreach(split \", \", substr $line, 1, length($line)-2);\nsay scalar(keys %st);\n"}, {"source_code": "$a = <>;\n$a =~ /$_/ and $ans++ for 'a'..'z';\nprint 0+$ans, \"\\n\";\n"}, {"source_code": "$_ = <>; chomp;\ns/[\\{\\}\\s]//g;\n%h = map {$_ => 1;} split /,/;\nprint (scalar keys %h);"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\n\nmy $s = <>;\nchomp $s;\n\n$s = substr(substr($s, 0, -1), 1);\n\nmy %set;\n\nforeach my $letter (split(', ', $s))\n{\n    $set{$letter} = 1;\n}\n\nmy $result = keys %set;\n\nprint $result\n"}, {"source_code": "$_=join'',sort@_=<>=~/\\w/g; s/(.)\\1+/$1/g;\nprint length"}, {"source_code": "$a=<>;\n$a=~/$_/ and $ans++ for 'a'..'z';\nprint 0+$ans"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nno warnings 'uninitialized';\n\n\nmy $line = <>;\n\n$line =~ s/[^a-z]//g;\n\nmy %seen;\nforeach my $c (split(//, $line))\n{\n   $seen{$c} = 1\n}\n\nprint scalar(keys %seen), \"\\n\"\n\n"}, {"source_code": "my $s = <>;\n$s = substr ($s, 1, (length $s) - 3);\n%k = ();\ngrep { $k{$_} = $_ } split \", \", $s;\nprint scalar (keys %k);"}, {"source_code": "#! usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $line = readline();\n\nmy $count = {};\n\nwhile ($line =~ m/(\\w),/g) {\n    $count->{$1} = 1;\n#   print $1 . \"\\n\";\n}\nif ($line =~ m/(\\w)\\}/g) {\n    $count->{$1} = 1;\n}\n\nmy @keys = keys %$count;\n\nmy $size = @keys;\n\nprint $size . \"\\n\";\n"}, {"source_code": "my $str = <>;\nmy $reg = \"{([^{}]*)}\\n\";\n$str =~ s/$reg/$1/;\nmy %hash = map { $_, 1 } split \", \", $str;\nprint scalar keys %hash;"}, {"source_code": "my $str = <>;\n$str =~ s/{([^{}]*)}\\n/$1/;\nmy %hash = map { $_, 1 } split \", \", $str;\nprint scalar keys %hash;"}], "negative_code": [{"source_code": "$a = <>;\n$a =~ /$_/ and $ans++ for 'a'..'z';\nprint \"$ans\\n\";\n"}], "src_uid": "1cbbffd1941ed83b5f04e1ee33c77f61"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>;\n\tchomp;\n\ty/br/10/;\n\t@_ = ();\n\t\n\tfor $init (0, 1){\n\t\t$i = $init;\n\t\tmy %h;\n\t\ts/./ $& eq $i ++ % 2 ? '' : $h{$&}++ /ger;\n\t\tpush @_, 0 + (sort {$b <=> $a} values %h)[ 0 ]\n\t\t}\n\t\n\tprint +(sort {$a <=> $b} @_)[ 0 ]\n\t\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\ty/br/10/;\n\t\n\t$min = ~0;\n\t\n\tfor $init (0, 1){\n\t\t$_0 = $_1 = 0;\n\t\t\n\t\twhile(/(.)(.)?/g){\n\t\t\t$_0 += $1 eq (1 - $init);\n\t\t\t$_1 += $2 eq (0 + $init);\n\t\t}\n\t\t\n\t\t$max = $_0 > $_1 ? $_0 : $_1;\n\t\t$min = $max if $max < $min;\n\t}\n\t\n\tprint $min\n}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t$_ = <>;\n\tchomp;\n\ty/br/10/;\n\t@_ = ();\n\t\n\tfor $init (0, 1){\n\t\t$i = $init;\n\t\tmy %h;\n\t\ts/./ $& eq $i ++ % 2 ? '' : $h{$&}++ /ger;\n\t\tpush @_, (sort {$b <=> $a} values %h)[ 0 ]\n\t\t}\n\t\n\tprint +(sort {$a <=> $b} @_)[ 0 ]\n\t\n\t}"}, {"source_code": "<>, $_ = <>;\ny/br/10/;\n\t\nfor $init (0, 1){\n\t$i = $init;\n\tpush @_, scalar( () = s/./ $& eq ++ $i % 2 ? 1 : 0 /ger =~ /0{1,2}/g );\n\t}\n\t\nprint +(sort {$a <=> $b} @_)[ 0 ]"}], "src_uid": "3adc75a180d89077aa90bbe3d8546e4d"}
{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\t\r\n\ts/(.)\\K \\1//g;\r\n\t\r\n\tprint m/ / ? s/ //r : s/^/a/r;\r\n\t}", "positive_code": [{"source_code": "<>;\r\nwhile(<>){\r\n\t$_ = <>;\r\n\ts/(.)\\K \\1//g;\r\n\tprint m/ / ? s/ //r : s/^/a/r;\r\n}"}, {"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\t\r\n\ts|(.)\\K \\1||g;\r\n\t\r\n\tprint m| | ? s| ||r : s|^|a|r;\r\n\t}"}, {"source_code": "#!/usr/bin/perl\r\n\r\nuse warnings;\r\nuse strict;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t$_ = <>;\r\n\t\r\n\ts/(.)\\K \\1//g;\r\n\t\r\n\tprint m/ / ? s/ //r : s/^/a/r;\r\n\t}"}], "negative_code": [], "src_uid": "565056bfe716ee89230270bdc14c9051"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $r ) = split;\n\tmy( $x1, @x ) = split ' ', <>;\n\t\n\tmy %y;\n\t$y{ $x1 } = $r;\n\tmy @y;\n\tpush @y, $r;\n\t\n\tmy $sqr = ( $r * 2 ) ** 2;\n\t\n\tfor my $x ( @x ){\n\t\t\n\t\tmy $Y = 0;\n\t\t\n\t\tfor my $xkey ( keys %y ){\n\t\t\t\n\t\t\tmy $B = $sqr - ( $x - $xkey ) ** 2;\n\t\t\tnext if $B < 0;\n\t\t\t\n\t\t\tmy $y = $y{ $xkey } + sqrt( $B );\n\t\t\t\n\t\t\tif( $y >= $Y ){\n\t\t\t\t$Y = $y;\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\n\t\t$Y ||= $r;\n\t\t$y{ $x } = $Y;\n\t\tpush @y, $Y;\n\t\t}\n\t\n\tprint \"@y\";\n\t}", "positive_code": [{"source_code": "( $n, $r, @x ) = split ' ', <>.<>;\n\nfor $x ( @x ){\n\t\n\t$Y = $r;\n\t\n\tfor $k ( keys %y ){\n\t\t\n\t\t$_ = $r ** 2 * 4 - ( $x - $k ) ** 2;\n\t\tnext if /-/;\n\t\t\n\t\t$y = $y{ $k } + sqrt;\n\t\t\n\t\t$y >= $Y and $Y = $y;\n\t\t}\n\t\n\tpush @y, $y{ $x } = $Y;\n\t}\n\nprint \"@y\""}, {"source_code": "\n\n\nmy $n, $r;\nmy $f = <STDIN>;\nchomp ( $f );\n($n, $r) = split m/ /, $f;\n$f = <STDIN>;\nchomp ( $f );\nmy @disks = split m/ /, $f;\n\n\n\n\nmy @placed = ();\nmy $elem;\nmy $found;\nmy @yy = ();\nmy $val;\nmy $height;\n\nmy $j = 0;\nmy $max;\nwhile ( @disks > 0 ) {\n\n    $elem = shift @disks;\n    $found = 0;\n    \n    $max = 0;\n    for ( my $i = 0; $i < @placed; $i += 1 ) {\n\n\tif ( abs ( $elem - $placed[ $i ][ 0 ] ) <= (2 * $r) ) { # if there's a collision\n\t    $found = 1;\n\n\t    $height = sqrt (abs( ((2 * $r) ** 2) - (abs ( $elem - $placed[ $i ][ 0 ] ) ** 2)));\n\t    $val = $placed[ $i ][ 1 ] + $height;\n\t    if ( $val > $max ) {\n\t\t$max = $val;}\n\t}\n    }\n\n    if ( $found == 1 ) {\n\tunshift @placed, [ $elem, $max, $j ];\n    }\n    \n    if ( $found == 0 ) {\t# if there's no collision\n\tunshift @placed, [ $elem, $r, $j ];\n    }\n\n    @placed = sort { ${ $a }[ 1 ] <=> ${ $b }[ 1 ] } @placed;\n    @placed = reverse @placed;\n\n    $j += 1;\n}\n\n\nmy @answer = sort { ${ $a }[ 2 ] <=> ${ $b }[ 2 ] } @placed;\n\n\nfor ( my $i = 0; $i < @answer; $i += 1 ) {\n    print $answer[ $i ][ 1 ];\n    print \" \";}\nprint \"\\n\";\n\n\n\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nmy (undef, $r) = split ' ', <>;\nmy @x = split ' ', <>;\n\nmy %y;\nmy @y;\n\nfor my $x (@x) {\n  my $max = $r;\n  while (my ($x2, $y2s) = each %y) {\n    for my $y2 (@$y2s) {\n      if (abs($x2 - $x) <= 2 * $r) {\n        # collision\n\n        # dx^2 + dy^2 = (2r)^2\n        my $dy = sqrt(4 * $r**2 - ($x2 - $x)**2);\n        my $y = $y2 + $dy;\n\n        $max = $y if $y > $max;\n      }\n    }\n  }\n\n  push @y, $max;\n  push @{$y{$x}}, $max;\n}\n\nsay join ' ', @y;\n"}], "negative_code": [{"source_code": "\n\n\nmy $n, $r;\nmy $f = <STDIN>;\nchomp ( $f );\n($n, $r) = split m/ /, $f;\n$f = <STDIN>;\nchomp ( $f );\nmy @disks = split m/ /, $f;\n\n\n\n\nmy @placed = ();\nmy $elem;\nmy $found;\nmy @yy = ();\nmy $val;\nmy $height;\n\nmy $j = 0;\nwhile ( @disks > 0 ) {\n\n    $elem = shift @disks;\n    $found = 0;\n    \n    for ( my $i = 0; not $found and $i < @placed; $i += 1 ) {\n\tif ( abs ( $elem - $placed[ $i ][ 0 ] ) <= (2 * $r) ) { # if there's a collision\n\t    $found = 1;\n\n\t    $height = sqrt (abs( ((2 * $r) ** 2) - (abs ( $elem - $placed[ $i ][ 0 ] ) ** 2)));\n\t    $val = $placed[ $i ][ 1 ] + $height;\n\t    unshift @placed, [ $elem, $val, $j ];\n\t}\n    }\n    \n    if ( $found == 0 ) {\t# if there's no collision\n\tunshift @placed, [ $elem, $r, $j ];\n    }\n\n    @placed = sort { ${ $a }[ 1 ] <=> ${ $b }[ 1 ] } @placed;\n    @placed = reverse @placed;\n    $j += 1;\n}\n\n\nmy @answer = sort { ${ $a }[ 2 ] <=> ${ $b }[ 2 ] } @placed;\n\n\nfor ( my $i = 0; $i < @answer; $i += 1 ) {\n    print $answer[ $i ][ 1 ];\n    print \" \";}\nprint \"\\n\";\n\n\n\n"}, {"source_code": "\n\n\nmy $n, $r;\nmy $f = <STDIN>;\nchomp ( $f );\n($n, $r) = split m/ /, $f;\n$f = <STDIN>;\nchomp ( $f );\nmy @disks = split m/ /, $f;\n\n\n\n\nmy @placed = ();\nmy $elem;\nmy $found;\nmy @yy = ();\nmy $val;\nmy $height;\n\nwhile ( @disks > 0 ) {\n\n    $elem = shift @disks;\n    $found = 0;\n    \n    for ( my $i = 0; not $found and $i < @placed; $i += 1 ) {\n\tif ( abs ( $elem - $placed[ $i ][ 0 ] ) <= (2 * $r) ) { # if there's a collision\n\t    $found = 1;\n\n\t    $height = sqrt (abs( ((2 * $r) ** 2) - (abs ( $elem - $placed[ $i ][ 0 ] ) ** 2)));\n\t    $val = $placed[ $i ][ 1 ] + $height;\n\t    unshift @placed, [ $elem, $val ];\n\t}\n    }\n\n    if ( $found == 0 ) {\t# if there's no collision\n\tunshift @placed, [ $elem, $r ];\n    }\n}\n\n\nmy @answer = reverse @placed;\n\n\nfor ( my $i = 0; $i < @answer; $i += 1 ) {\n    print $answer[ $i ][ 1 ];\n    print \" \"; }\nprint \"\\n\";\n\n\n\n"}], "src_uid": "3cd019d1016cb3b872ea956c312889eb"}
{"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n\nfor (@_){\n\t$_=(reverse \"0\"x(1+$x-length).$_),\n\ts!11(01)*0!\"0\"x(length($&)-1).\"1\"!ge,\n\ts!((11)+)0!\"0\".\"01\"x(length($1)/2)!ge,\n\t$_=reverse $_\n\t}\n\n$ans = $_[0] cmp $_[1];\nprint $ans? ( $ans>0? \">\" : \"<\" ): \"=\"", "positive_code": [{"source_code": "chomp($a=<>);\nchomp($b=<>);\n$d=length($a)-length($b);\n$a.=\"000\";\n$b.=\"000\";\n$d>0? ($b=\"0\"x $d.$b):($a=\"0\"x (-$d).$a);\n\n@a=split//,$a;\n@b=split//,$b;\n\nfor $i(0..@a-1){\n\t\n\tif (!$f && !$g){\n\t\t$f=$g=$a[$i]<=>$b[$i]\n\t\t}\n\telsif ($f>0 && $g){\n\t\t$a[$i]<$b[$i]?($f--):(++$F)\n\t\t\n\t\t}\n\telsif (!$f && $g>0){\n\t\t($ab=$a[$i]<=>$b[$i])?($ab>0?(++$F):($g--)):($f++)\n\t\t}\n\telsif ($f<0 && $g){\n\t\t$a[$i]>$b[$i]?($f++):(--$F)\n\t\t\n\t\t}\n\telsif (!$f && $g<0){\n\t\t($ab=$a[$i]<=>$b[$i])?($ab<0?(--$F):($g++)):($f--)\n\t\t}\n\t$F && last\n\t}\n\n\nprint $F? ( $F>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=\"0\".(\"0\"x($max-$la)).$a.\"000\";\n$b=\"0\".(\"0\"x($max-$lb)).$b.\"000\";\n\n#print \"$a=$b\\n\";\n\n@a=split//,$a;\n@b=split//,$b;\n\n#print \"@a  @b\\n\";\n\n$F=0;\n$f=$g=0;\n\nfor $i(0..(@a-1)){\n\t\n\tif ($f==0 and $g==0){\n\t\tif ($a[$i]>$b[$i]){\n\t\t\t$f++, $g++\n\t\t\t\n\t\t\t}\n\t\tif ($a[$i]<$b[$i]){\n\t\t\t$f--, $g--\n\t\t\t\n\t\t\t}\n\t\t}\n\telsif ($f==1 and $g==1){\n\t\tif ($a[$i]>=$b[$i]){ $F=1; last}\n\t\telsif ($a[$i]<$b[$i]){\n\t\t\t$f--\n\t\t\t}\n\t\t\n\t\t}\n\telsif ($f==0 and $g==1){\n\t\tif ($a[$i]>$b[$i]){ $F=1; last}\n\t\telsif ($a[$i]<$b[$i]){\n\t\t\t$g--\n\t\t\t}\n\t\telse {\n\t\t\t$f++\n\t\t\t}\n\t\t}\n\t\t\n\telsif ($f==-1 and $g==-1){\n\t\tif ($a[$i]<=$b[$i]){ $F=-1; last}\n\t\telsif ($a[$i]>$b[$i]){\n\t\t\t$f++\n\t\t\t}\n\t\t\n\t\t}\n\telsif ($f==0 and $g==-1){\n\t\tif ($a[$i]<$b[$i]){ $F=-1; last}\n\t\telsif ($a[$i]>$b[$i]){\n\t\t\t$g++\n\t\t\t}\n\t\telse {\n\t\t\t$f--\n\t\t\t}\n\t\t}\n\t\n\t\n\t}\n\n\n#print \"$a=$b\";\n#$ans = $a cmp $b;\nprint $F? ( $F>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n\nfor (@_){\n\t$_=(reverse \"0\"x(1+$x-length).$_),\n\ts!11(01)*0!\"0\"x(length($&)-1).\"1\"!ge,\n\ts!(1+)0!\"1\"x(length($1)%2).\"0\".\"01\"x(length($1)/2)!ge,\n\t$_=reverse $_\n\t}\n\n$ans = $_[0] cmp $_[1];\nprint $ans? ( $ans>0? \">\" : \"<\" ): \"=\""}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=\"0\"x($x-length).$_.\"000\" for @_;\n($a,$b)=@_;\n\n@a=split//,$a;\n@b=split//,$b;\n\nfor $i(0..@a-1){\n\t\n\t$cmp = $a[$i]<=>$b[$i];\n\t\n\tif (!$f && !$g){\n\t\t$f= $g= $cmp\n\t\t}\n\telsif ($f && $g){\n\t\t$f+= $cmp || $f\n\t\t}\n\telse {\n\t\t$f+= $g+= $cmp\n\t\t}\n\t\n\tabs $f > 1 && last\n\t}\n\nprint $f? ( $f>0? \">\" : \"<\" ): \"=\""}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=reverse (\"0\"x(1+$x-length).$_) for @_;\n($a,$b)=@_;\n\n$a=~s#11(01)*0#\"0\"x(length($&)-1).\"1\"#ge;\n$a=~s#((11)+)0#\"0\".\"01\"x(length($1)/2)#ge;\n$b=~s#11(01)*0#\"0\"x(length($&)-1).\"1\"#ge;\n$b=~s#((11)+)0#\"0\".\"01\"x(length($1)/2)#ge;\n\n$a= reverse $a;\n$b= reverse $b;\n\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? \">\" : \"<\" ): \"=\""}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=\"0\"x($x-length).$_ for @_;\n($a,$b)=@_;\n\n@a=split//,$a;\n@b=split//,$b;\n\nfor $i(0..@a-1){\n\t\n\t$cmp = $a[$i]<=>$b[$i];\n\t\n\tif (!$f && !$g){\n\t\t$f= $g= $cmp\n\t\t}\n\telsif ($f && $g){\n\t\t$f+= $cmp || $f\n\t\t}\n\telse {\n\t\t$f+= $g+= $cmp\n\t\t}\n\t\n\tabs $f > 1 && last\n\t}\n\nprint $g? ( $g>0? \">\" : \"<\" ): \"=\""}, {"source_code": "for (<>){\n\t$_=(reverse sprintf \"%0100001s\", $_),\n\ts!11(01)*0!\"0\"x(length($&)-1).\"1\"!ge,\n\ts!((11)+)0!\"0\".\"01\"x(length($1)/2)!ge,\n\tpush @_, $_=reverse $_\n\t}\n\nprint qw(= > <)[$_[0] cmp $_[1]]"}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=\"0\"x($x-length).$_ for @_;\n\n@b=split//,pop @_;\n@a=split//,pop @_;\n\nfor $i(0..@a-1){\n\t\n\t$cmp = $a[$i]<=>$b[$i];\n\t\n\tif (!$f && !$g){\n\t\t$f= $g= $cmp\n\t\t}\n\telsif ($f && $g){\n\t\t$f+= $cmp || $f\n\t\t}\n\telse {\n\t\t$f+= $g+= $cmp\n\t\t}\n\t\n\tabs $f > 1 && last\n\t}\n\nprint $g? ( $g>0? \">\" : \"<\" ): \"=\""}, {"source_code": "$x<length and $x=length for @_=<>;\n\nfor (@_){\n\t$_=(reverse \"0\"x($x-length).$_),\n\ts!11(01)*0!\"0\"x(length($&)-1).\"1\"!ge,\n\ts!((11)+)0!\"0\".\"01\"x(length($1)/2)!ge,\n\t$_=reverse $_\n\t}\n\nprint qw(= > <)[$_[0] cmp $_[1]]"}, {"source_code": "$x<length and $x=length for @_=<>;\n\nfor (@_){\n\t$_=(reverse \"0\"x($x-length).$_),\n\ts!11(01)*0!\"0\"x(length($&)-1).\"1\"!ge,\n\ts!((11)+)0!\"0\".\"01\"x(length($1)/2)!ge,\n\t$_=reverse $_\n\t}\n\nprint qw(= > <)[$_[0] cmp $_[1]]"}], "negative_code": [{"source_code": "for (<>){\n\t$_=(reverse sprintf \"%0100001s\", $_),\n\ts!11(01)*0!\"0\"x(length($&)-1).\"1\"!ge,\n\ts!((11)+)0!\"0\".\"01\"x(length($1)/2)!ge,\n\tpush @_, reverse $_\n\t}\n\nprint qw(= > <)[$_[0] cmp $_[1]]"}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=(\"0\"x($max-$la)).$a;\n$b=(\"0\"x($max-$lb)).$b;\n#print \"$a=$b\\n\";\n$a=~s#0((11)+)#(\"10\"x((length($1))/2)).\"0\"#ge;\n$b=~s#0((11)+)#(\"10\"x((length($1))/2)).\"0\"#ge;\n#print \"$a=$b\";\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=\"0\".(\"0\"x($max-$la)).$a.\"000\";\n$b=\"0\".(\"0\"x($max-$lb)).$b.\"000\";\n\n#print \"$a=$b\\n\";\n\n@a=split//,$a;\n@b=split//,$b;\n\n#print \"@a  @b\\n\";\n\n$F=0;\n$f=$g=0;\n\nfor $i(0..(@a-1)){\n\t\n\tif ($f==0 and $g==0){\n\t\tif ($a[$i]>$b[$i]){\n\t\t\t$f++, $g++\n\t\t\t\n\t\t\t}\n\t\tif ($a[$i]<$b[$i]){\n\t\t\t$f--, $g--\n\t\t\t\n\t\t\t}\n\t\t}\n\telsif ($f==1 and $g==1){\n\t\tif ($a[$i]>=$b[$i]){ $F=1; last}\n\t\telsif ($a[$i]<$b[$i]){\n\t\t\t$f--\n\t\t\t}\n\t\t\n\t\t}\n\telsif ($f==0 and $g==1){\n\t\tif ($a[$i]>$b[$i]){ $F=1; last}\n\t\telsif ($a[$i]<$b[$i]){\n\t\t\t$g--\n\t\t\t}\n\t\telse {\n\t\t\t$f++\n\t\t\t}\n\t\t}\n\t\t\n\telsif ($f==-1 and $g==-1){\n\t\tif ($a[$i]<=$b[$i]){ $F=-1; last}\n\t\telsif ($a[$i]>$b[$i]){\n\t\t\t$f++\n\t\t\t}\n\t\t\n\t\t}\n\telsif ($f==0 and $g==-1){\n\t\tif ($a[$i]<$b[$i]){ $F=-1; last}\n\t\telsif ($a[$i]<$b[$i]){\n\t\t\t$g++\n\t\t\t}\n\t\telse {\n\t\t\t$f--\n\t\t\t}\n\t\t}\n\t\n\t\n\t}\n\n\n#print \"$a=$b\";\n#$ans = $a cmp $b;\nprint $F? ( $F>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=(\"0\"x($max-$la)).$a;\n$b=(\"0\"x($max-$lb)).$b;\nprint \"$a-$b\\n\";\n$a=~s/011/100/g;\n$b=~s/011/100/g;\nprint \"$a-$b\\n\";\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=\"0\"x($x-length).$_.\"000\" for @_;\n($a,$b)=@_;\n\n@a=split//,$a;\n@b=split//,$b;\n\nfor $i(0..@a-1){\n\t\n\t$cmp = $a[$i]<=>$b[$i];\n\t\n\tif (!$f && !$g){\n\t\t$f= $g= $cmp\n\t\t}\n\telsif ($f && $g){\n\t\t$f+= $cmp || $f\n\t\t}\n\telse {\n\t\t$g+ $cmp ? ($f+=$g):($g=0)\n\t\t}\n\t\n\tabs $f > 1 && last\n\t}\n\nprint $f? ( $f>0? \">\" : \"<\" ): \"=\""}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=(\"0\"x($max-$la)).$a;\n$b=(\"0\"x($max-$lb)).$b;\n$a=~s/011/100/g;\n$b=~s/011/100/g;\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=reverse (\"0\"x($x-length).$_) for @_;\n($a,$b)=@_;\n\n$a=~s#11(01)*0#\"0\"x(length($&)-1).\"1\"#ge;\n$a=~s#((11)+)0#\"0\".\"01\"x(length($1)/2)#ge;\n$b=~s#11(01)*0#\"0\"x(length($&)-1).\"1\"#ge;\n$b=~s#((11)+)0#\"0\".\"01\"x(length($1)/2)#ge;\n\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? \">\" : \"<\" ): \"=\""}, {"source_code": "chomp(@_=<>);\n$x<length and $x=length for @_;\n$_=\"0\"x($x-length).$_.\"000\" for @_;\n($a,$b)=@_;\n\n@a=split//,$a;\n@b=split//,$b;\n\nfor $i(0..@a-1){\n\t\n\t$cmp = $a[$i]<=>$b[$i];\n\t\n\tif (!$f && !$g){\n\t\t$f= $g= $cmp\n\t\t}\n\telsif ($f && $g){\n\t\t$f+= $cmp || $f\n\t\t}\n\telse {\n\t\t$g+ $cmp ? ($f+=$g):($g+=$g)\n\t\t}\n\t\n\tabs $f > 1 && last\n\t}\n\nprint $f? ( $f>0? \">\" : \"<\" ): \"=\""}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=\"0\".(\"0\"x($max-$la)).$a;\n$b=\"0\".(\"0\"x($max-$lb)).$b;\n#print \"$a=$b\\n\";\n$a=~s#((01)*)1((11)*)#(\"1\".(\"0\"x(length($1)-1)).\"10\"x((length($3))/2)).($1 || $2? \"0\":\"\")#ge;\n$b=~s#((01)*)1((11)*)#(\"1\".(\"0\"x(length($1)-1)).\"10\"x((length($3))/2)).($1 || $2? \"0\":\"\")#ge;\n#print \"$a=$b\";\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? (\">\"):(\"<\") ):(\"=\")"}, {"source_code": "chomp($a=<>);\nchomp($b=<>);\n$la=length($a);\n$lb=length($b);\n$max=$la;\n$max=$lb if $lb>$max;\n$a=(\"0\"x($max-$la)).$a;\n$b=(\"0\"x($max-$lb)).$b;\nprint \"$a-$b\\n\";\n$a=~s/011/100/g;\n$b=~s/011/100/g;\n$ans = $a cmp $b;\nprint $ans? ( $ans>0? (\">\"):(\"<\") ):(\"=\")"}], "src_uid": "7c0a288a2777894bdfd75cb9703346e9"}
{"source_code": "my ($n, $x) = split / /, <>;\nmy $sum = 0;\n$sum += $_ for(split / /, <>);\nprint int((abs($sum)+$x - 1) / $x);\n", "positive_code": [{"source_code": "my ($n, $x) = split / /, <>;\nmy @arr = split / /, <>;\nmy $sum;\n$sum += $_ for(@arr);\nprint int((abs($sum)+$x - 1) / $x);\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\nuse integer;\n\n($n, $x) = split / /, <>;\n$tot+=$_ foreach (split / /, <>);\nsay ((abs($tot) + $x-1)/$x);"}, {"source_code": "use integer;\n\n\nwhile(<>){\n\t\n\t($n,$x)=split/ /;\n\t$_=<>;\n\t$sum=0;\n\ts/-?\\d+/$sum+=$&/ge;\n#\tprint \"$sum\\n\"; \n\t\n\t$sum=abs $sum;\n#\tprint \"$sum\\n\"; \n\t$answer=$sum/$x + ($sum%$x? 1:0) ;\n\t\n\tprint \"$answer\\n\"; \n\n\t}\n\t\n"}, {"source_code": "use integer;\n($n,$x)=split/ /,<>;\n$_=<>;\ns/-?\\d+/$s+=$&/ge;\n$s=~s/-//;\nprint $s/$x + ($s%$x?1:0)\n\t"}], "negative_code": [{"source_code": "use integer;\n($n,$x)=split/ /,<>;\n$_=<>;\ns/-?\\d+/$s+=$&/ge;\n$s=~s/-//;\nprint $s/$x + ($s%$x)**0"}], "src_uid": "066906ee58af5163636dac9334619ea7"}
{"source_code": "\t<>;\n\t\n\t@A = split ' ', <>;\n\t\t\n\tfor $c ( $A[1] - $A[0], $A[2] - $A[1], ($A[2] - $A[0]) / 2 ){\n\t\t\n\t\tmy $j;\n\t\tmy $f;\n\t\t\n\t\tfor $i ( 1 .. @A - 1 ){\n\t\t\t$d = $A[ $i ] - $A[ $i-1 ];\n\t\t\t\n\t\t\tif( $d != $c ){\n\t\t\t\t! $j ?\n\t\t\t\t\t( $j = $d - $c )\n\t\t\t\t\t:\n\t\t\t\t-$j == $d - $c ?\n\t\t\t\t\t( $j *= -1 )\n\t\t\t\t\t:\n\t\t\t\t\t++ $f\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t$ok += ! $f && $j;\n\t\t\n\t\t}\n\t\n\tprint $ok ? \"YES\" : \"NO\";", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\t\n\tmy @cand;\n\tpush @cand, $A[1] - $A[0], $A[2] - $A[1], ($A[2] - $A[0]) / 2;\n\t$debug and print \"cand:[@cand]\";\n\t\n\tmy $ok = 0;\n\t\n\tfor my $cand ( @cand ){\n\t\t\n\t\tmy $jump;\n\t\tmy $f = 0;\n\t\t\n\t\tfor( my $i = 0; $i < @A - 1; $i ++ ){\n\t\t\tmy $diff = $A[ $i+1 ] - $A[ $i ];\n\t\t\t\n\t\t\tif( $diff != $cand ){\n\t\t\t\tif( not defined $jump ){\n\t\t\t\t\t$jump = $diff - $cand;\n\t\t\t\t\t}\n\t\t\t\telsif( -$jump == $diff - $cand ){\n\t\t\t\t\t$jump *= -1;\n\t\t\t\t\t#OK\n\t\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$f ++;\n\t\t\t\t\tlast;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\tif( $f == 0 and defined $jump ){\n\t\t\t$ok = 1;\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tprint $ok ? \"YES\" : \"NO\";\n\t\n\t}"}], "negative_code": [], "src_uid": "c54042eebaef01783a74d31521db9baa"}
{"source_code": "#!/usr/bin/perl\n\nmy $test_count = <STDIN>;\nchomp $test_count;\nmy @final_results;\n\nfor ($i = 0; $i < $test_count; ++$i) {\n  my $seq_length = <STDIN>;\n  chomp($seq_length);\n  my $line = <STDIN>;\n  chomp($line);\n  my @elements = split(/ /,$line);\n  my %seen;\n  my @result;\n  foreach (@elements) {\n    unless ($seen{$_}) {\n      $seen{$_} = true;\n      push(@result,$_);\n    }\n  }\n  push(@final_results,join(' ',@result));\n}\n\nprint join(\"\\n\", @final_results).\"\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy ($t) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nfor( my $t_loop=0; $t_loop<$t; $t_loop++ ){\n  \n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  my @a = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  \n  my @r = ();\n  \n  for(my $i=0;$i<$n;$i++){\n    my $v = shift @a;\n    push(@r,$v);\n    last if( $#a <= 0 );\n    for(my $j=0;$j<=$#a;$j++){\n      if( $a[$j] == $v ){\n        my @newa = ();\n        push(@newa,@a[0..$j-1]) if $j-1>=0;\n        push(@newa,@a[$j+1..$#a]) if $j+1<=$#a;\n        @a = (@newa);\n        last;\n      }\n    }\n  }\n  print ( join(\" \",@r) . \"\\n\" );\n  \n}\n\n"}], "negative_code": [], "src_uid": "aaf91874cf5aa0fa302ffed2ccecdc76"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $n1, $n2 ) = sort {$b <=> $a} split;\n\t\n\t@_ = sort {$b <=> $a} split ' ', <>;\n\t\n#%\tprint \"my( $n, $n1, $n2 )|@_\";\n\tprint\n\t\t+\n\t\t(  eval join '+', @_[0 .. $n2 - 1] ) / $n2\n\t\t+\n\t\t(  eval join '+', @_[$n2 .. $n2 + $n1 - 1] ) / $n1\n\t\t;\n\t\n\t}", "positive_code": [{"source_code": "$/ = \"\"; $_ = <STDIN>; ($n, $n1, $n2, @a) = split;\n\n@a = sort { $b <=> $a } @a;\n$i1 = $n1; $i2 = $n2;\n\nwhile ($i1 + $i2) {\n\t$v = $a[$i++];\n\t$f = ($v / $n1 > $v / $n2);\n\tif ( $f && !$i1) { $f = 0 }\n\tif (!$f && !$i2) { $f = 1 } \n\tif ($f) {\n\t\t$sum1 += $v;\n\t\t$i1--;\n\t} else {\n\t\t$sum2 += $v;\n\t\t$i2--;\n\t}\n}\n\n$ans = ($sum1 / $n1) + ($sum2 / $n2);\nprint $ans;"}, {"source_code": "use strict;\nuse warnings;\n#use Data::Dumper;\n\nmy ($n,$n1,$n2)=split / /,<>;\nchomp($n,$n1,$n2);\nmy @data=split / /,<>;\nchomp(@data);\n@data=sort {$b <=> $a } @data;\n($n1,$n2)=(min($n1,$n2),max($n1,$n2));\n#print STDERR $n1 . \",\" . $n2 . \"\\n\";\nmy $ans=0;\nmy $sum=0;\nmy $i=0;\nfor($i=0;$i<$n1;$i++)\n{\n  $sum+=shift @data;\n}\n$ans=$sum/$n1;\n$sum=0;\nfor($i=0;$i<$n2;$i++)\n{\n  $sum+=shift @data;\n}\n$ans+=$sum/$n2;\n\n$ans = sprintf(\"%.8f\", $ans);\n\nprint $ans . \"\\n\";\n\nsub min{\n\treturn $_[0] > $_[1] ? $_[1] : $_[0];\n}\n\nsub max{\n\treturn $_[1] > $_[0] ? $_[1] : $_[0];\n}\n"}, {"source_code": "( undef, $n[1], $n[2], @_ ) = map { sort {$b <=> $a} split } <>;\n\nprint 0 + eval join '+', map { \n        ( eval join '+', @_[ $n[$_ + 1 ] .. $n[$_ + 1] + $n[$_] - 1 ] ) / $n[$_] \n    } 2, 1"}], "negative_code": [], "src_uid": "822e8f394a59329fa05c96d7fb35797e"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t$_ = <>, chomp;\n\tmy $ok = <>;\n\tchomp $ok;\n\t\n\tprint eval join '+', 0, map $_ * ( $_ + 1 ) / 2, map length, split /[^$ok]/, $_;\n\t}", "positive_code": [{"source_code": "<>;\n$_ = <>, chomp;\n$ok = <>;\n\t\nprint eval join '+', 0, map $_ * ( $_ + 1 ) / 2, map length, split /[^$ok]/"}], "negative_code": [], "src_uid": "4c260e7c6fd9c573ee4f3b1822f3c7c3"}
{"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n", "positive_code": [{"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X\n"}, {"source_code": "use bigint;\n<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X"}], "negative_code": [{"source_code": "<>;\n@_=split/ /,<>;\n$_=<>;\nwhile(/\\d+/g){\n\t\n\t$X=$_[$&-1] if $_[$&-1]>$X;\n\t$_[$&-1]=0;\n\t\n\t}\n\t\n$Z+=$_ for @_;\n\n$Z > $X ? ($X=$Z,s/^/ /):($X+=$Z);\n\n$X*=2 while / /g;\n\nprint $X"}], "src_uid": "913925f7b43ad737809365eba040e8da"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $q ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t$sum += $_ for @_;\n\t\n\tmy $N = grep $_ % 2, @_;\n\tmy $L = @_ - $N;\n\t\n\tfor( 1 .. $q ){\n\t\tmy( $t, $x ) = split ' ', <>;\n\t\t\n\t\tif( !$t ){\n\t\t\t$sum += $L * $x;\n\t\t\tif( $x % 2 ){\n\t\t\t\t$L = 0;\n\t\t\t\t$N = @_;\n\t\t\t\t}\n\t\t\t}\n\t\tif( $t ){\n\t\t\t$sum += $N * $x;\n\t\t\tif( $x % 2 ){\n\t\t\t\t$L = @_;\n\t\t\t\t$N = 0;\n\t\t\t\t}\n\t\t\t}\n\t\tprint $sum;\n\t\t}\n\t}", "positive_code": [{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t( $n, $q, $Z, @L ) = split;\r\n\t\r\n\t$Z += $_, ++ $L[ $_ % 2 ] for split ' ', <>;\r\n\t\r\n\tfor( 1 .. $q ){\r\n\t\t( $t, $x ) = split ' ', <>;\r\n\t\t\r\n\t\t$Z += $x * $L[ $t % 2 ];\r\n\t\t$x % 2 and @L[ $t % 2, 1 - $t % 2 ] = ( 0, $n );\r\n\t\t\r\n\t\tprint $Z . $/\r\n\t\t}\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\nmy $debug = 0;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $q ) = split;\n\t@_ = split ' ', <>;\n\t$debug and print \"[@_]\";\n\t\n\tmy $sum = 0;\n\t$sum += $_ for @_;\n\t\n\tmy $LYG = grep $_ % 2 == 0, @_;\n\tmy $NELYG = @_ - $LYG;\n\t$debug and print \"LYG[$LYG], NELYG:[$NELYG]\";\n\t\n\tfor my $qq ( 1 .. $q ){\n\t\tmy( $t, $x ) = split ' ', <>;\n\t\t\n\t\tif( $t == 0 ){\n\t\t\t$sum += $LYG * $x;\n\t\t\tif( $x % 2 == 1 ){\n\t\t\t\t$LYG = 0;\n\t\t\t\t$NELYG = @_;\n\t\t\t\t}\n\t\t\t}\n\t\tif( $t == 1 ){\n\t\t\t$sum += $NELYG * $x;\n\t\t\tif( $x % 2 == 1 ){\n\t\t\t\t$LYG = @_;\n\t\t\t\t$NELYG = 0;\n\t\t\t\t}\n\t\t\t}\n\t\tprint $sum;\n\t\t}\n\t}"}], "negative_code": [], "src_uid": "d15cffca07768f8ce6fab7e13a6e7976"}
{"source_code": "#!usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $row;my ($n,$m,$c)=split/ /,<STDIN>;my $ps=\"\";my $ns=\"\";my @s;\nchomp($c);\nfor my $i(1..$n){\n    $row=<STDIN>;\n    chomp($row);\n    if($row=~/$c/){push @s,$row;}\n    elsif(scalar @s){$ns=$row;last;}\n    else{$ps=$row;}\n}\nmy %t;my $f=0;\nfor(0..@s-1){\n    if($s[$_]=~/([^$c\\.])$c/){$t{$1}=1;}\n    if($s[$_]=~/$c([^$c\\.])/){$t{$1}=1;}\n}\nmy @ps=split //,$ps;my @ns=split //,$ns;my @fs=split //,$s[0];my @ls=split //,$s[-1];\nif($ps ne \"\"){\n    for(0..$#ps){\n\tif($ps[$_] ne \".\"&&$fs[$_]eq$c){$t{$ps[$_]}=1;}\n    }\n}\nif($ns ne \"\"){for(0..$#ns){if($ns[$_] ne \".\"&&$ls[$_]eq$c){$t{$ns[$_]}=1;}}}\n$f=keys %t;\nprint \"$f\\n\";", "positive_code": [{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy ($n, $m, $color) = (split / /, <>);\nchomp $color;\nmy ($ps, $ns) = ('', '');\nmy @s;\nfor (1..$n) {\n    my $rs = <>;\n    chomp $rs;\n    if ($rs =~ /$color/) {\n\tpush @s, $rs;\n    } elsif (@s) {\n\t$ns = $rs;\n\tlast;\n    } else {\n\t$ps = $rs;\n    }\n}\n\nmy %tables;\n# left and right tables\nfor (@s) {\n    if (/([^$color])$color/) {\n\t$tables{$1} = 1 if $1 ne '.';\n    }\n    if (/$color([^$color])/) {\n\t$tables{$1} = 1 if $1 ne '.';\n    }\n}\n\n# tables in previous row\nif ($ps ne '') {\n    my @ps = split //, $ps;\n    my @fs = split //, $s[0];\n    for (0..$#ps) {\n\tif ($fs[$_] eq $color and $ps[$_] ne '.') {\n\t    $tables{$ps[$_]} = 1;\n\t}\n    }\n}\n# tables in next row\nif ($ns ne '') {\n    my @ns = split //, $ns;\n    my @ls = split //, $s[$#s];\n    for (0..$#ns) {\n\tif ($ls[$_] eq $color and $ns[$_] ne '.') {\n\t    $tables{$ns[$_]} = 1;\n\t}\n    }\n}\n# all tables\n\nmy $sum = keys %tables;\nprint \"$sum\\n\";\n"}], "negative_code": [{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy ($n, $m, $color) = (split / /, <>);\nchomp $color;\nmy ($ps, $s, $ns) = ('', '', '');\nfor (1..$n) {\n    $s = <>;\n    chomp $s;\n    if ($s =~ /$color/) {\n\t$ns = <> if $_ < $n;\n\tchomp $ns;\n\tlast;\n    } else {\n\t$ps = $s;\n    }\n}\n\nmy %tables;\n# left table\nif ($s =~ /([^$color])$color/) {\n    $tables{$1} = 1 if $1 ne '.';\n}\n# right table\nif ($s =~ /$color([^$color])/) {\n    $tables{$1} = 1 if $1 ne '.';\n}\n\n# tables in previous row\nif ($ps ne '') {\n    my @ps = split //, $ps;\n    my @s = split //, $s;\n    for (0..$#ps) {\n\tif ($s[$_] eq $color and $ps[$_] ne '.') {\n\t    $tables{$ps[$_]} = 1;\n\t}\n    }\n}\n# tables in next row\nif ($ns ne '') {\n    my @ns = split //, $ns;\n    my @s = split //, $s;\n    for (0..$#ns) {\n\tif ($s[$_] eq $color and $ns[$_] ne '.') {\n\t    $tables{$ns[$_]} = 1;\n\t}\n    }\n}\n# all tables\n\nmy $sum = keys %tables;\nprint \"$sum\\n\";\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy ($n, $m, $color) = (split / /, <>);\nchomp $color;\nmy ($ps, $ns) = ('', '');\nmy @s;\nfor (1..$n) {\n    my $rs = <>;\n    chomp $rs;\n    if ($rs =~ /$color/) {\n\tpush @s, $rs;\n    } elsif (@s) {\n\t$ns = $rs;\n\tlast;\n    } else {\n\t$ps = $rs;\n    }\n}\n\nmy %tables;\n# left and right tables\nfor (@s) {\n    if (/([^$color])$color/) {\n\t$tables{$1} = 1 if $1 ne '.';\n    }\n    if (/$color(^$color])/) {\n\t$tables{$1} = 1 if $1 ne '.';\n    }\n}\n\n# tables in previous row\nif ($ps ne '') {\n    my @ps = split //, $ps;\n    my @fs = split //, $s[0];\n    for (0..$#ps) {\n\tif ($fs[$_] eq $color and $ps[$_] ne '.') {\n\t    $tables{$ps[$_]} = 1;\n\t}\n    }\n}\n# tables in next row\nif ($ns ne '') {\n    my @ns = split //, $ns;\n    my @ls = split //, $s[$#s];\n    for (0..$#ns) {\n\tif ($ls[$_] eq $color and $ns[$_] ne '.') {\n\t    $tables{$ns[$_]} = 1;\n\t}\n    }\n}\n# all tables\n\nmy $sum = keys %tables;\nprint \"$sum\\n\";\n"}, {"source_code": "#!usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $row;my ($n,$m,$c)=split/ /,<STDIN>;my $ps=\"\";my $ns=\"\";my @s;\nchomp($c);\nfor my $i(1..$n){\n    $row=<STDIN>;\n    chomp($row);\n    if($row=~/$c/){push @s,$row;}\n    elsif(scalar @s){$ns=$row;last;}\n    else{$ps=$row;}\n}\nmy %t;my $f=0;\nfor(0..@s-1){\n    if($s[$_]=~/([^$c\\.])$c/){$t{$1}=1;}\n    if($s[$_]=~/$c([^$c\\.])/){$t{$1}=1;}\n}\nmy @ps=split//,$ps;my @ns=split//,$ns;my @fs=split //,$s[0];my @ls=split //,$s[-1];\nif(scalar @ps){\n    for my $i(0..@ps-1){\n\tif($ps[$i]ne\".\"&&$fs[$i]eq$c){$t{$ps[$i]}=1;}\n    }\n}\nif(scalar @ns){for my $i(0..@ps-1){if($ns[$i]ne \".\"&&$ls[$i]eq$c){$t{$ps[$i]}=1;}}}\n$f++ for(keys %t);\nprint \"$f\\n\";"}], "src_uid": "d7601c9bb06a6852f04957fbeae54925"}
{"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>", "positive_code": [{"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>; print abs eval <> =~ s/\\s/+/gr . 0, $/ while <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\tmy $s1 = 0;\n\t$s1 += $_ for grep $_ > 0, @_;\n\tmy $s2 = 0;\n\t$s2 -= $_ for grep $_ < 0, @_;\n\t\n\tprint abs( $s1 - $s2 );\n\t}"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}, {"source_code": "<>;print abs eval<>=~s/\\s/+/gr.0,$/while<>"}], "negative_code": [], "src_uid": "f59f92a80f719cdb87ad92cd8c211942"}
{"source_code": "my ($na, $nb) = split / /, <>;\nmy ($k, $m) = split / /, <>;\nmy @a = split / /, <>;\nmy @b = split / /, <>;\n\nif ($a[$k - 1] < $b[-$m]) {\n    print \"YES\\n\";\n}\nelse {\n    print \"NO\\n\";\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\n($na, $nb) = split / /, <>;\n($k, $m) = split / /, <>;\n@a = split / /, <>;\n@b = split / /, <>;\n($pa, $pb) = ($a[$k-1], $b[$nb-$m]);\n$pa<$pb and say \"YES\" or say \"NO\";"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\n<>;\nmy ($k, $m) = split ' ', <>;\nmy @x = split ' ', <>;\nmy @y = split ' ', <>;\n\nmy $x = $x[$k - 1];\nmy $y = $y[-$m];\n\nsay $x < $y ? 'YES' : 'NO';\n"}, {"source_code": "print qw(NO YES)[ !! eval join '<', map { (split \" \", <>)[ (-1) ** ($i++) * $_ + $i - 2 ] } split \" \", (<>, <>) ]"}], "negative_code": [], "src_uid": "8e0581cce19d6bf5eba30a0aebee9a08"}
{"source_code": "for(1..<>){($x,$y)=split' ',<>;print$x*$y.\"\\n\";}", "positive_code": [{"source_code": "for(1..<>){($x,$y)=split' ',<>;print$x*$y.\"\\n\";}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split;\n\t@_ = sort { $a <=> $b } @_;\n\t\n\tprint +( $_[ 1 ] ) * $_[ 0 ];\n\t}"}], "negative_code": [], "src_uid": "806dcdab8364f5169334e172a192598a"}
{"source_code": "<>;\n\nmap $h{ $_ } = ++ $i, split ' ', <>;\n\n$_ = $h{ $_ } for @B = split ' ', <>;\n\n$m = pop @B;\n\nfor( reverse @B ){\n\t$_ > $m and $c ++;\n\t$_ < $m and $m = $_;\n\t}\n\nprint 0 + $c", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\t$debug and print \"\\@A: [@A]\";\n\t$debug and print \"\\@B: [@B]\";\n\t\n\tmy %h;\n\t\n\tmy $i = 0;\n\t\n\tmap $h{ $_ } = ++ $i, @A;\n\t\n\t$_ = $h{ $_ } for @A;\n\t$_ = $h{ $_ } for @B;\n\t\n\t$debug and print \"\\@A: [@A]\";\n\t$debug and print \"\\@B: [@B]\";\n\t\n\tmy $cnt = 0;\n\t\n\t@B = reverse @B;\n\t\n\tmy $min = $B[ 0 ];\n\t\n\tfor( @B ){\n\t\tif( $_ > $min ){\n\t\t\t$cnt ++;\n\t\t\t}\n\t\tif( $_ < $min ){\n\t\t\t$min = $_;\n\t\t\t}\n\t\t}\n\t\n\tprint $cnt;\n\t}"}], "negative_code": [], "src_uid": "f5178609cc7782edd40bc50b8797522e"}
{"source_code": "use warnings;\nuse strict;\nchomp ( my $n = <STDIN> );\nmy @a = ();\nmy $s;\nfor ( 1 .. $n ) {\n    $s = <STDIN>;\n    chomp ( $s );\n    push @a, $s;\n}\n$, = qq/\\n/, $\\ = qq/\\n/;\n@a = sort { $a =~ m/$b/ ? 1 : -1 } @a;\nfor my $i ( 1 .. $#a ) { if ( not $a[$i] =~ m/$a[$i-1]/ ) { print \"NO\\n\"; exit; }}\nprint \"YES\";\nprint @a;\n", "positive_code": [{"source_code": "$\" = $/;\n\n<>;\n\n$k ++;\n\n@_ = sort { $k &&= $a =~ $b } sort { $b =~ $a * 2 - 1 } map s/\\n//r, <>;\n\nprint $k ? \"YES\\n@_\" : \"NO\""}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n$\" = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\tmy $ok = 1;\n\t\n\t@_ = sort { $ok &&= $a =~ $b } sort { $b =~ $a * 2 - 1 } @_;\n\t\n\tprint $ok ? \"YES\\n@_\" : \"NO\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\n$input_line = <STDIN>;\nchop($input_line);\n$n=$input_line;\n@s=();\nfor ($counter = 0; $counter <$n; $counter++){\n\t$input_line = <STDIN>;\n\tchop($input_line);\n\t$s[$counter] = $input_line;\n}\n$counter = $n;\nwhile ($counter > 0){\n\t$i = 1;\n\twhile ($i < $counter){\n\t\tif (length($s[$i])< length($s[$i-1])){($s[$i],$s[$i-1]) = ($s[$i-1], $s[$i])}\n\t\t$i++;\n\t}\n\t$counter--;\n}\n$check = 1;\nfor ($i = 1; $i <$n; $i++){\n\tif ($s[$i] !~ /${s[$i-1]}/){$check = 0}\n}\nif ($check == 0){print (\"NO\\n\");}\nelse{\n\tprint(\"YES\\n\");\n\tfor ($i = 0; $i <$n; $i++){\n\t\tprint (\"$s[$i]\\n\");}\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\t@_ = sort { length $a <=> length $b } @_;\n\t\n\tmy $f = 0;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\t$_[ $i + 1 ] =~ $_[ $i ] or $f ++;\n\t\t}\n\t\n\tnext if $f and print \"NO\";\n\t\n\tprint for \"YES\", @_;\n\t}"}], "negative_code": [{"source_code": "use warnings;\nuse strict;\nchomp ( my $n = <STDIN> );\nmy @a = ();\nmy $s;\nfor ( 1 .. $n ) {\n    $s = <STDIN>;\n    chomp ( $s );\n    push @a, $s;\n}\n$, = qq/\\n/, $\\ = qq/\\n/;\n@a = sort { $a =~ m/$b/ ? 1 : -1 } @a;\nfor my $i ( 1 .. $#a ) { if ( not $a[$i] =~ m/$a[$i-1]/ ) { print \"NO\\n\"; exit; }}\nprint @a;\n"}, {"source_code": "$\" = $/;\n\n<>;\n\n@_ = sort { $k ||= $a !~ $b } sort { $b =~ $a * 2 - 1 } map s/\\n//r, <>;\n\nprint $k ? \"YES\\n@_\" : \"NO\""}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map ~~<>, 1 .. $_;\n\tchomp @_;\n\t\n\t@_ = sort { length $a <=> length $b } @_;\n\t\n\tmy $f = 0;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\t$_[ $i + 1 ] =~ $_[ $i ] or $f ++;\n\t\t}\n\t\n\tnext if $f and print \"NO\";\n\t\n\tprint for @_;\n\t}"}], "src_uid": "5c33d1f970bcc2ffaea61d5407b877b2"}
{"source_code": "#!/usr/bin/perl -l\nuse warnings;\nuse strict;\nchomp(my $n=<STDIN>);\nmy %mapp=('purple'=>'Power','green'=>'Time','blue'=>'Space','orange'=>'Soul','red'=>'Reality','yellow'=>'Mind');\nfor(my $i=0;$i<$n;$i++)\n{\n\tchomp(my $s=<STDIN>);\n        delete $mapp{$s};\n}\nmy $ss=keys %mapp;\nprint $ss;\nforeach my $value(values %mapp) \n{\n\tprint $value;\n}", "positive_code": [{"source_code": "use warnings;\nuse strict;\nuse integer;\nuse constant NL => qq/\\n/;\n$\\ = qq/\\n/, $, = qq/\\n/;\nchomp ( my $n = <STDIN> );\nmy %gems = ( \n    'purple' => 'Power',\n    'green' => 'Time',\n    'blue' => 'Space',\n    'orange' => 'Soul',\n    'red' => 'Reality',\n    'yellow' => 'Mind' \n);\nfor my $val ( 1 .. $n ) {\n    chomp ( my $str = <STDIN> );\n    delete $gems { $str };\n}\nprint scalar values %gems;\nprint values %gems;\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl -l\nuse warnings;\nuse strict;\nchomp(my $n=<STDIN>);\nmy %mapp=('purple'=>'Power','green'=>'Time','blue'=>'Space','orange'=>'Soul','red'=>'Reality','yellow'=>'Mind');\nfor(my $i=0;$i<$n;$i++)\n{\n\tchomp(my $s=<STDIN>);\n        delete $mapp{$s};\n}\nforeach my $value(values %mapp) \n{\n\tprint $value;\n}"}], "src_uid": "7eff98fbcf4e4a3284e2d2f98351fe4a"}
{"source_code": "#!/usr/bin/perl\n\nmy ($t) = map { $_ - 0 } split(/\\s+/,<STDIN>);\nwhile($t-->0){\n  my ($x1,$y1,$x2,$y2) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  \n  my $d;\n  if( $x1 == $x2 or $y1 == $y2 ){\n    $d = abs($x1 - $x2) + abs($y1 - $y2);\n  } else {\n    $d = 2+ abs($x1 - $x2) + abs($y1 - $y2);\n  }\n  print \"$d\\n\";\n}\n\n\n", "positive_code": [{"source_code": "<>;\nwhile(<>){\n    ($a,$b,$c,$d)=split;\n    $a=abs $a-$c;\n    $b=abs $b-$d;\n    $a+=2if $a&&$b;\n    print $a+$b,\"\\n\"\n}"}], "negative_code": [], "src_uid": "6a333044e2ed8f9f4fa44bc16b994418"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $n;\n\t( $n, @_ ) = split;\n\t\n\t$_ = join ' ', ( @_ ) x 2;\n\t\n\tmy $pm = $n - 1;\n\t\n\tmy $fail = 0\n\t\t|| m/\\b$n 0\\b/\n\t\t|| m/\\b0 $n\\b/\n\t\t|| m/\\b$n 1 $n\\b/\n\t\t\n\t\t|| m/\\b$n 1 $pm 1\\b/\n\t\t|| m/\\b$pm 1 $n 1\\b/\n\t\t\n\t\t|| m/\\b$pm 0 $pm 1\\b/\n\t\t|| m/\\b$pm 1 $pm 0\\b/\n\t\t|| m/\\b0 $pm 0\\b/\n\t\t;\n\t\n\tprint $fail ? 'NO' : 'YES';\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $n;\n\t( $n, @_ ) = split;\n\t\n\t$_ = join ' ', map { +\n\t\t',', ( sort { $_ * ( $a + $b ) } @_ ) x 3 \n\t\t} 0 .. 1;\n\t\n\tmy $pm = $n - 1;\n\t\n\tmy $fail = m/\n\t\t| $n 0 |\n\t\t| $n 1 $n |\n\t\t| $n 1 $pm 1 |\n\t\t| $pm 0 $pm 1 |\n\t\t| 0 $pm 0 |\n\t\t/\n\t\t;\n\t\n\tprint $fail ? 'NO' : 'YES';\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $n;\n\t( $n, @_ ) = split;\n\t\n\t$_ = join ' ', ( @_ ) x 3, ',', ( reverse @_ ) x 3;\n\t\n\tmy $pm = $n - 1;\n\t\n\tmy $fail = 0\n\t\t|| m/ $n 0 /\n\t\t|| m/ $n 1 $n /\n\t\t|| m/ $n 1 $pm 1 /\n\t\t|| m/ $pm 0 $pm 1 /\n\t\t|| m/ 0 $pm 0 /\n\t\t;\n\t\n\tprint $fail ? 'NO' : 'YES';\n\t}"}, {"source_code": "#سحر 2\r\nuse warnings;\r\nuse strict;\r\n\r\n$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\tmy $n;\r\n\t( $n, @_ ) = split;\r\n\t\r\n\t$_ = join ' ', map { +\r\n\t\t',', ( sort { $_ * ( $a + $b ) } @_ ) x 3 \r\n\t\t} 0 .. 1;\r\n\t\r\n\tmy $pm = $n - 1;\r\n\t\r\n\tmy $fail = m/\r\n\t\t| $n 0 |\r\n\t\t| $n 1 $n |\r\n\t\t| $n 1 $pm 1 |\r\n\t\t| $pm 0 $pm 1 |\r\n\t\t| 0 $pm 0 |\r\n\t\t/\r\n\t\t;\r\n\t\r\n\tprint $fail ? 'NO' : 'YES';\r\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $n;\n\t( $n, @_ ) = split;\n\t\n\tmy @A = '';\n\t\n\tfor my $B ( @_, @_ ){\n\t\tmy @new;\n\t\t\n\t\t$_ = 1 x $B . 0 x ( $n - $B );\n\t\tpush @new, $_;\n\t\ts/(.)(.*)/$2$1/;\n\t\tpush @new, $_;\n\t\ts/(.*)(.)/$2$1/;\n\t\ts/(.*)(.)/$2$1/;\n\t\tpush @new, $_;\n\t\ts/(.*)(.)/$2$1/;\n\t\tpush @new, $_;\n\t\t\n\t\tmy %C;\n\t\t\n\t\tfor my $A ( @A ){\n\t\t\tfor my $new ( @new ){\n\t\t\t\tnext if \"$A,$new\" =~ m/(.),(?!\\1)/;\n\t\t\t\t$C{ $A . $new } = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t@A = keys %C;\n\t\t}\n\t\n\t$_ = ( length ) / $n for @A;\n\t\n\t$_ = grep { $_ == 8 } @A;\n\t\n\tprint $_ ? 'YES' : 'NO';\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $n;\n\t( $n, @_ ) = split;\n\t\n\t$_ = join ' ', ( @_ ) x 2;\n\t\n\tmy $pm = $n - 1;\n\t\n\tmy $fail = 0\n\t\t|| m/\\b$n $n $n [01]\\b/\n\t\t|| m/\\b$n 0\\b/\n\t\t|| m/\\b0 $n\\b/\n\t\t|| m/\\b$n 1 $n\\b/\n\t\t\n\t\t|| m/\\b$pm 0 $pm 0\\b/\n\t\t|| m/\\b$pm 0 $pm 1\\b/\n\t\t|| m/\\b$pm 1 $pm 0\\b/\n\t\t|| m/\\b0 $pm 0\\b/\n\t\t;\n\t\n\tprint $fail ? 'NO' : 'YES';\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy $n;\n\t( $n, @_ ) = split;\n\t\n\t$_ = join ' ', ( @_ ) x 2;\n\t\n\tmy $pm = $n - 1;\n\t\n\tmy $fail = 0\n\t\t|| m/\\b$n $n $n [01]\\b/\n\t\t|| m/\\b$n 0\\b/\n\t\t|| m/\\b0 $n\\b/\n\t\t\n\t\t|| m/\\b$pm 0 $pm 0\\b/\n\t\t|| m/\\b$pm 0 $pm 1\\b/\n\t\t|| m/\\b$pm 1 $pm 0\\b/\n\t\t|| m/\\b0 $pm 0\\b/\n\t\t;\n\t\n\tprint $fail ? 'NO' : 'YES';\n\t}"}], "src_uid": "1c94596da439c56b56e59da36734a912"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\tmy @C;\n\tmy $sum = 0;\n\t\n\tfor my $A (@A){\n\t\tmy $B = shift @B;\n\t\tpush @C, [ $A, $B, $A - $B ];\n\t\t}\n\t\n\t@C = sort { $a->[2] <=> $b->[2] } @C;\n\t\n#%\tprint \"    @$_\" for @C;\n\t\n\t$sum += eval join ' + ', map { $_->[0] } @C[ 0 .. $k - 1 ];\n\t$sum += eval join ' + ', map { $_->[2] > 0 ? $_->[1] : $_->[0] } @C[ $k .. $n - 1 ];\n\t\n\tprint $sum;\n\t}", "positive_code": [{"source_code": "sub input { split \" \", <> }\n($n, $k) = input; @a = input; @b = input;\n\nfor ($i = 0; $i < $n; $i++) {\n\t$c[$i] = {a => $a[$i], b => $b[$i], diff => abs($a[$i] - $b[$i])};\n}\n\n@c = sort {$b->{diff} <=> $a->{diff}} @c;\n$l = $n - $k;\nwhile ($l && @c) {\n\t$c = shift @c;\n\tif ($c->{a} < $c->{b}) {\n\t\t$sum += $c->{a};\n\t} else {\n\t\t$sum += $c->{b};\n\t\t$l--;\n\t}\n}\n\n$sum += $_->{a} for @c;\n\nprint $sum;"}, {"source_code": "( $n, $k ) = split ' ', <>;\n\n@A = split ' ', <>;\n@A = sort { $a->[2] <=> $b->[2] } map { [ $A[$i], $_, $A[$i] - $_, $i++ ] } split ' ', <>;\n\nmap { $sum += $A[$_][2] > 0 && $_ >= $k ? $A[$_][1] : $A[$_][0] } 0 .. $#A;\n\nprint $sum"}], "negative_code": [{"source_code": "sub input { split \" \", <> }\n($n, $k) = input; @a = input; @b = input;\nfor ($i = 0; $i < $n; $i++) {\n\t$c = $c[$i] = {a => $a[$i], b => $b[$i], use => 0};\n\tpush @d, {c => $c, value => $c->{a}, k2 => 0};\n\tpush @d, {c => $c, value => $c->{b}, k2 => 1};\n}\n@d = sort { $a->{value} <=> $b->{value}} @d;\n$k2 = $n - $k;\nfor $d (@d) {\n\t$c = $d->{c};\n\tif (!$c->{use}) {\n\t\tif ($d->{k2}) {\n\t\t\tnext if !$k2;\n\t\t\t$k2--;\n\t\t}\n\t\t$sum += $d->{value};\t\n\t\t$c->{use} = 1;\n\t}\n}\nprint $sum;"}, {"source_code": "sub input { split \" \", <> }\n($n, $k) = input; @a = input; @b = input;\nfor ($i = 0; $i < $n; $i++) {\n\t$c = $c[$i] = {a => $a[$i], b => $b[$i], use => 0};\n\tpush @d, {c => $c, value => $c->{a}, k2 => 0};\n\tpush @d, {c => $c, value => $c->{b}, k2 => 1};\n}\n@d = sort { $a->{value} <=> $b->{value}} @d;\n$k2 = $n - $k;\nfor $d (@d) {\n\t$c = $d->{c};\n\tif (!$c->{use}) {\n\t\t$k2-- if $d->{k2} && $k2;\n\t\t$sum += $d->{value};\t\n\t\t$c->{use} = 1;\n\t}\n}\nprint $sum;"}], "src_uid": "b5355e1f4439b198d2cc7dea01bc4bc3"}
{"source_code": "\n$l = <>;\n($n,$m) = ( $l =~ m/(\\d+)\\s+(\\d+)/ );\n\nmy %h;\nwhile ( $l = <> ) {\n\tmy @b = split( /\\s/, $l );\n\tshift @b;\n\tforeach (@b) {\n\t\t$h{$_} = 1;\n\t}\n}\nprint scalar( keys %h ) == $m? \"YES\" : \"NO\";\n", "positive_code": [{"source_code": "($n, $m) = &{ $input = sub { split ' ', <> } };\n$r = '0' x $m;\nfor (1..$n) {\n\t(undef, @lamps) = &$input;\n\tsubstr($r, $_ - 1, 1, '1') for @lamps;\n}\nprint $r =~ /0/? 'NO': 'YES', \"\\n\";\n"}, {"source_code": "(undef, $m) = split ' ', <>;\n@_ = <>;\nfor (@_){\n@A = split;\nshift @A;\nmap $B[$_] = 1, @A;\n}\n$f = 0;\n$B[ $_ ] or $f ++ for 1 .. $m;\nprint $f ? \"NO\" : \"YES\""}], "negative_code": [{"source_code": "\n$l = <>;\n($n,$m) = ( $l =~ m/(\\d+)\\s+(\\d+)/ );\n\nmy %h;\nwhile ( $l = <> ) {\n\tmy @b = split( /\\s/, $l );\n\tforeach (@b) {\n\t\t$h{$_} = 1;\n\t}\n}\nprint scalar( keys %h ) == $m? \"YES\" : \"NO\""}], "src_uid": "9438ce92e10e846dd3ab7c61a1a2e3af"}
{"source_code": "for (1..<>) {\r\n        chomp (my $x = <>);\r\n        my $flag = 0;\r\n        my $i = 0;\r\n\r\n        while (2**$i < 10**14) {\r\n                (2**$i++ == $x) and $flag = 1;\r\n        }\r\n\r\n        print $flag ? \"NO\\n\" : \"YES\\n\";\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\t$_ = sprintf \"%b\", $_;\n\t\n\tmy $ones = () = /1/g;\n\t\n\tprint $ones == 1 ? \"NO\" : \"YES\";\n\t}"}], "negative_code": [{"source_code": "chomp (my $x = <>);\r\nmy $flag = 0;\r\nmy $i = 0;\r\n\r\nwhile (2**$i < 10**14) {\r\n        (2**$i++ == $x) and $flag = 1;\r\n}\r\n\r\nprint $flag ? \"NO\\n\" : \"YES\\n\";\r\n\r\nexit;"}], "src_uid": "f4958b4833cafa46fa71357ab1ae41af"}
{"source_code": "( $n, $A, $B, $_ ) = split ' ', <>.<>;\n@_ = split //;\n\t\nprint $_[$A-1] - $_[$B-1] ? 1 : 0", "positive_code": [{"source_code": "use strict;\n\n$,=\" \";\nmy ($n,$ax,$bx)=split / /,<>;\nchomp($n,$ax,$bx);\n$ax--;\n$bx--;\n$n--;\nmy $str=<>;\nchomp($str);\nmy @aa=split //,$str;\n\nif($aa[$ax]==$aa[$bx]){\n\tprint \"0 \\n\";\n}else{\n\tprint \"1 \\n\";\n\t}\n\n\n\n\n\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $A, $B ) = split;\n\t$_ = <>, chomp;\n\t\n\tmy $CA = substr $_, $A - 1, 1;\n\tmy $CB = substr $_, $B - 1, 1;\n\t\n\tprint do {\n\t\tif( abs( $CA - $CB ) == 1 ){\n\t\t\t1;\n\t\t\t}\n\t\telse{\n\t\t\t0;\n\t\t\t}\n\t\t};\n\t}"}, {"source_code": "$/ = \"\"; $_ = <>; ($n, $a, $b, $s) = split;\n$a = substr $s, $a - 1, 1;\n$b = substr $s, $b - 1, 1;\nprint $a eq $b? 0: 1;\n\n"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $tmp = <>;\n$tmp =~ s/\\s+$//;\nmy ($n, $fs, $sn) = split /\\s+/, $tmp;\n\nmy $s = <>;\n$s =~ s/\\s+$//;\n\nif (substr($s, $fs - 1, 1) eq substr($s, $sn - 1, 1)) {\n    print \"0\";\n} else {\n    print \"1\";\n}"}], "negative_code": [{"source_code": "use strict;\nuse Data::Dumper;\nuse warnings;\n\n\nmy ($n,$ax,$bx)=split / /,<>;\nchomp($n,$ax,$bx);\n$ax--;\n$bx--;\n$n--;\nmy $str=<>;\nchomp($str);\nmy @aa=split //,$str;\nmy %b_cost;\nmy %a_cost;\nfor my $k(0..$n){\n    $b_cost{$k}->[0]=$aa[$k]-$aa[$bx];\n\t$b_cost{$k}->[1]=abs($bx-$k);\t\t\n}\n\n\n\n\nif($b_cost{$ax}->[0]==0){\n\tprint \"0\\n\";\n}\nelse{\n\nfor my $k (sort { $b_cost{$a}->[1] <=> $b_cost{$b}->[1]  } keys %b_cost){\nif($b_cost{$k}->[0]==1){\n\tprint $b_cost{$k}->[1] . \"\\n\";\n\tlast;\n}\n}\n}\n"}, {"source_code": "use strict;\nuse Data::Dumper;\nuse warnings;\n\n\nmy ($n,$ax,$bx)=split / /,<>;\nchomp($n,$ax,$bx);\n$ax--;\n$bx--;\n$n--;\nmy $str=<>;\nchomp($str);\nmy @aa=split //,$str;\nmy %b_cost;\nmy %a_cost;\nfor my $k(0..$n){\n    $b_cost{$k}->[0]=abs($aa[$k]-$aa[$bx]);\n\t$b_cost{$k}->[1]=abs($bx-$k);\t\t\n}\n\n\n\n\nif($b_cost{$ax}->[0]==0){\n\tprint \"0\\n\";\n}\nelse{\nfor my $k (sort { $b_cost{$a}->[1] <=> $b_cost{$b}->[1]  } keys %b_cost){\nif($b_cost{$k}->[0]==1){\n\tprint $b_cost{$k}->[1] . \"\\n\";\n\tlast;\n}\n}\n}\n\n"}, {"source_code": "use strict;\n\n$,=\" \";\nmy ($n,$ax,$bx)=split / /,<>;\nchomp($n,$ax,$bx);\n$ax--;\n$bx--;\n$n--;\nmy $str=<>;\nchomp($str);\nmy @aa=split //,$str;\n\nmy $b_cost=0; \nmy $ans=10000000000;\nif($aa[$ax]==$aa[$bx])\n{\n\tprint \"0\\n\";\n}\nelse\n{\nfor my $k(0..$n){ \n$b_cost=0; \nmy $a_to_vertx=0;\nmy $b_to_vertx=0;\n if($aa[$k]==$aa[$ax]){\n \t$a_to_vertx=0;\n }else{\n \t$a_to_vertx=abs($ax-$k);\n }\n if($aa[$k]==$aa[$bx]){\n \t$b_to_vertx=0;\n }else{\n \t$b_to_vertx=abs($bx-$k);\n }\n #print $a_to_vertx,$b_to_vertx . \"\\n\";\n    $b_cost=$a_to_vertx+$b_to_vertx;\n    $ans=min($b_cost,$ans);\n}\nprint $ans . \"\\n\";\n}\n\n\n\nsub min{\n\treturn $_[0]>$_[1] ? $_[1] : $_[0];\n}\n\n\n\n\n\n"}], "src_uid": "081f30ac27739002855e9d2aebe804c7"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$_=<>;\nchomp;\n@_=split//;\n$_ eq'x'and $x++ for@_;\n$y=@_-$x;\nprint (($x>$y?'x':'y')x($x+$y-min($x,$y)*2));\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Sun Dec 16 21:13:10 IST 2012\n# File Name: b\n# USAGE: \n#       b \n# \n# \n#------------------------------------------------\nchomp (my $str = <STDIN>);\n\n#$str = 'x';\n#$str .= 'x' x 10 ** 6;\n#$str .= 'y' x 10 ** 6;\n\n$cnt = 0;\nforeach (split /\\s*/, $str) { if ($_ eq 'x') { $cnt++ } else { $cnt-- } }\n\nif ( $cnt > 0 ) { $sol = 'x' } else { $sol = 'y'; $cnt = 0 - $cnt }\n\nprint $sol x $cnt;\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=split//,<>;\n$_ eq'x'and $x++ for@_;\n$y=@_-$x;\nprint (($x>$y?'x':'y')x($x+$y-min($x,$y)*2));\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=split//,<>;chomp$_[@_-1];\n$_ eq'x'and $x++ for@_;\n$y=@_-$x;\nprint (($x>$y?'x':'y')x($x+$y-min($x,$y)*2));\n\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "528459e7624f90372cb2c3a915529a23"}
{"source_code": "for (1..<>) {\r\n        chomp (my $in = <>);\r\n        my ($a, $b, $n) = split / /, $in;\r\n\r\n        $t = 0;\r\n        until ($a%2) {\r\n                $t++;\r\n                $a /= 2;\r\n        }\r\n        until ($b%2) {\r\n                $t++;\r\n                $b /= 2;\r\n        }\r\n        print 2**$t >= $n ? \"YES\\n\" : \"NO\\n\";\r\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\n \r\nuse warnings;\r\nuse strict;\r\n \r\n$\\ = $/;\r\n\r\n<>;\r\n \r\nwhile(<>){\r\n\tmy( $w, $h, $n ) = split;\r\n\t\r\n\tmy @m = map { length s/.*?(0*)$/$1/r } \r\n\t\tmap { eval sprintf \"%0b\", $_ } $w, $h;\r\n\t\r\n\tfor( @m ){\r\n\t\t$_ > 13 and $_ = 13;\r\n\t\t}\r\n\t\r\n\tmy $m = eval join '*', map 2 ** $_, @m;\r\n\t\r\n\tprint $m >= $n ? \"YES\" : \"NO\";\r\n\t}"}, {"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($w,$h,$n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $c1 = 1; my $c2 = 1;\r\n  while( $w % 2 == 0 ){\r\n    $c1 *= 2;\r\n    $w /= 2;\r\n  }\r\n  while( $h % 2 == 0 ){\r\n    $c2 *= 2;\r\n    $h /= 2;\r\n  }\r\n  if( $c1 * $c2 >= $n ){\r\n    print \"YES\\n\";\r\n  } else {\r\n    print \"NO\\n\";\r\n  }\r\n\r\n}\r\n\r\nexit(0);\r\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $w, $h, $n ) = split;\n\t\n\tmy @m = map { length s/.*?(0*)$/$1/r } \n\t\tmap { eval sprintf \"%0b\", $_ } $w, $h;\n\t\n\tfor( @m ){\n\t\t$_ > 11 and $_ = 11;\n\t\t}\n\t\n\tmy $m = eval join '*', map 2 ** $_, @m;\n\t\n\tprint $m >= $n ? \"YES\" : \"NO\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $w, $h, $n ) = split;\n\t\n\tmy $m = length join '', map { s/.*?(0*)$/$1/r } \n\t\tmap { eval sprintf \"%0b\", $_ } $w, $h;\n\t\n\tif( $m < 11 ){\n\t\t$m = 2 ** $m;\n\t\t}\n\t\n\tprint $m >= $n ? \"YES\" : \"NO\";\n\t}"}], "src_uid": "a8201326dda46542b23dc4e528d413eb"}
{"source_code": "$\\ = $/;\n\n<>;\n\n@_ = <>;\n\n$i = 0;\nfor (@_){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\tpush @{ $H{$A}{$B} }, [$i, $C];\n\tpush @{ $H{$A}{$C} }, [$i, $B];\n\tpush @{ $H{$B}{$C} }, [$i, $A];\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor (keys %{ $H{ $h } }){\n\t@s = grep defined, (sort { $b->[1] <=> $a->[1] } @{ $H{ $h }{ $_ } })[0, 1];\n\t$c = @s > 1 ? $s[0][1] + $s[1][1] : $s[0][1];\n\t$c > $h and $c = $h;\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = map $_->[0], @s;\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n", "positive_code": [{"source_code": "$\\ = $/;\n\n<>;\n\n$i = 0;\nfor (<>){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\t$H{$A}{$B}{$i} = $C;\n\t$H{$A}{$C}{$i} = $B;\n\t$H{$B}{$C}{$i} = $A;\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor $k (keys %{ $H{ $h } }){\n\t$hh = \\%{ $H{ $h }{ $k } };\n\t@s = grep defined, (sort { $hh->{ $b } <=> $hh->{ $a } } keys $hh)[0, 1];\n\t$c = @s > 1 ? $hh->{ $s[0] } + $hh->{ $s[1] } : $hh->{ $s[0] };\n\t$c > $h and $c = $h;\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = @s;\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\n$i = 0;\nfor (<>){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\t$H{$A}{$B}{$i} = $C;\n\t$H{$A}{$C}{$i} = $B;\n\t$H{$B}{$C}{$i} = $A;\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor $k (keys %{ $H{ $h } }){\n\t@s = grep defined, (sort { $H{ $h }{ $k }{ $b } <=> $H{ $h }{ $k }{ $a } } keys %{ $H{ $h }{ $k } })[0, 1];\n\t$c = @s > 1 ? $H{ $h }{ $k }{ $s[0] } + $H{ $h }{ $k }{ $s[1] } : $H{ $h }{ $k }{ $s[0] };\n\t$c > $h and $c = $h;\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = @s;\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\n$i = 0;\nfor (<>){\n\t$i ++;\n\t($A, $B, $C) = split;\n\t$A > $B and ($A, $B) = ($B, $A);\n\t$B > $C and ($C, $B) = ($B, $C);\n\t$A > $B and ($A, $B) = ($B, $A);\n\tpush @{ $H{$A}{$B} }, [$i, $C];\n\tpush @{ $H{$A}{$C} }, [$i, $B];\n\tpush @{ $H{$B}{$C} }, [$i, $A];\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor (keys %{ $H{ $h } }){\n\t@s = grep defined, (sort { $b->[1] <=> $a->[1] } @{ $H{ $h }{ $_ } })[0, 1];\n\t$c = @s > 1 ? $s[0][1] + $s[1][1] : $s[0][1];\n\t$c > $h and $c = $h;\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = map $_->[0], @s;\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n"}], "negative_code": [{"source_code": "$\\ = $/;\n\n<>;\n\n@_ = <>;\n\n$i = 0;\nfor (@_){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\tpush @{ $H{\"$A $B\"} }, [$i, $C];\n\tpush @{ $H{\"$A $C\"} }, [$i, $B];\n\tpush @{ $H{\"$B $C\"} }, [$i, $A];\n\t}\n\n$max = 0;\n\nfor (keys %H){\n\t@s = ($s1, $s2) = sort { $b->[1] <=> $a->[1] } @{ $H{ $_ } };\n\t$c = (sort {$a <=> $b} (split ' '), eval join '+', map $_->[1], @s)[ 0 ];\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = map $_->[0], @s;\n\t\t$ans[0] == $ans[1] and pop @ans;\n\t\t}\n\t}\n\t\nprint ~~ @ans, \"\\n@ans\"\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\n@_ = <>;\n\n$i = 0;\nfor (@_){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\tpush @{ $H{$A}{$B} }, [$i, $C];\n\tpush @{ $H{$A}{$C} }, [$i, $B];\n\tpush @{ $H{$B}{$C} }, [$i, $A];\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor (keys %{ $H{ $h } }){\n\t@s = grep defined, (sort { $b->[1] <=> $a->[1] } @{ $H{ $h }{ $_ } })[0, 1];\n\t$c = (sort {$a <=> $b} $h, eval join '+', map $_->[1], @s)[ 0 ];\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = map $_->[0], @s;\n\t\tprint \">>@ans\";\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\n$i = 0;\nfor (<>){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\t$H{$A}{$B}{$i} = $C;\n\t$H{$A}{$C}{$i} = $B;\n\t$H{$B}{$C}{$i} = $A;\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor $k (keys %{ $H{ $h } }){\n\t$hh = \\%{ $H{ $h }{ $k } };\n\t@s = grep defined, (sort { $hh{ $b } <=> $hh{ $a } } keys $hh)[0, 1];\n\t$c = @s > 1 ? $hh->{ $s[0] } + $hh->{ $s[1] } : $hh->{ $s[0] };\n\t$c > $h and $c = $h;\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = @s;\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n"}, {"source_code": "$\\ = $/;\n\n<>;\n\n@_ = <>;\n\n$i = 0;\nfor (@_){\n\t$i ++;\n\t($A, $B, $C) = sort {$a <=> $b} split;\n\tpush @{ $H{$A}{$B} }, [$i, $C];\n\tpush @{ $H{$A}{$C} }, [$i, $B];\n\tpush @{ $H{$B}{$C} }, [$i, $A];\n\t}\n\n$max = 0;\n\nfor $h (keys %H){\nfor (keys %{ $H{ $h } }){\n\t@s = grep defined, (sort { $b->[1] <=> $a->[1] } @{ $H{ $h }{ $_ } })[0, 1];\n\t$c = @s > 1 ? $s[0] + $s[1] : $s[0];\n\t$c > $h and $c = $h;\n\tif( $c > $max ){\n\t\t$max = $c;\n\t\t@ans = map $_->[0], @s;\n\t\t}\n\t}\n\t}\n\n$ans[0] == $ans[1] and pop @ans;\nprint ~~ @ans, \"\\n@ans\"\n"}], "src_uid": "ef82292a6591de818ddda9f426208291"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\nuse integer;\n\n($n, $k) = split / /, <>;\n($tot, $k) = (0, 5 - $k);\n$_<=$k and ++$tot foreach (split / /, <>);\nsay $tot/3;", "positive_code": [{"source_code": "($n, $k) = split ' ', <>;\nmap { ++$s if $_ <= 5 - $k } split ' ', <>;\nprint int($s / 3);\n"}, {"source_code": "my ($n, $k) = split / /, <>;\nmy @arr = split / /, <>;\nmy $count = 0;\n$_ += $k for(@arr);\n$count = $count + ($_ <=5 ? 1:0) for(@arr);\nprint int($count / 3);"}, {"source_code": "my ($n, $k) = split / /, <>;\nmy $count = 0;\n$_ <= 5 - $k && $count++ for(split / /, <>);\nprint int($count / 3);\n"}, {"source_code": "my ($n, $k) = split ' ', <>;\nmy @people = split ' ', <>;\nmy @rem = map { 5 - $_ } @people;\n\nmy $ok = int((scalar grep { $_ >= $k } @rem) / 3);\n\nprint \"$ok\\n\";\n"}, {"source_code": "my @firstline = split (' ', <>);\nmy @secondline = split (' ', <>);\nmy @goodguys;\nmy $n = $firstline[0];\nmy $k = $firstline[1];\nmy $goodguys = 0;\nforeach (@secondline){\n    if (($k+$_) <= 5){\n        $goodguys++;\n\n}\n}\nprint int($goodguys / 3);"}, {"source_code": "($n,$k)=split/ /,<>;\n$_<=5-$k && $i++ for split/ /,<>;\n$_=$i/3;\ns/\\./a/;\nprint 0+$_"}], "negative_code": [{"source_code": "$n, $k = split ' ', <>;\nmap { ++$s if $_ <= 5 - $k } split ' ', <>;\nprint int($s / 3);\n"}], "src_uid": "fbde1e2ee02055592ff72fb04366812b"}
{"source_code": "$s = <>;\nsub m1 {\n\tif ($s =~ s/.*$_//) {\n\t\t$w = $&;\n\t\t$n = $w =~ s/$_//g;\n\t\t$u .= $_ x $n;\n\t\t$t .= $w;\n\t}\n}\nsub m2 {\n\tif ($t =~ s/[a-$_]+$//) {\n\t\t$u .= reverse $&;\n\t}\n}\nm2, m1, m2 for a..z;\nprint $u;", "positive_code": [{"source_code": "\n# function returns true if the current\n# character is the smallest in the rest\n# otherwise, it returns false\n# of string s\n# parameters are the character and\n# the hash\nsub is_small {\n    my $chr = shift @_;\n    my $h_ref = shift @_;\n    for my $i ( keys %{ $h_ref } ) {\n\tif ( ($i lt $chr) and ${ $h_ref }{ $i } > 0 ) {\n\t    return 0;}}\t\t# return false if character is less than\n    return 1;\t\t\t# chr and there are still chrs in the string\n}\n\n\n\n# initialize hash\nmy $h;\nfor my $i (a..z) {\n    $h{ $i } = 0; }\n\n# read input\nmy $f = <STDIN>;\nchomp ( $f );\n# put the string into an array\nmy @s = split m//, $f;\n\n# calculate frequencies for each character\n# in the string and store in the hash\nfor (@s) {\n    $h{ $_ } += 1;}\n\n# strings described in problem statement\nmy @t;\nmy @u;\n\n# temporary varaibles for pushing and poping and shifting\nmy $front;\nmy $back;\n\n# main algorithm with two operations\nwhile ( @s > 0 ) {\n    \n    # remove character from front of string\n    $front = shift @s;\t\t\n\n    # decrement value for $front character\n    $h { $front } -= 1;\n\n    # remove key - value pair if value become zero\n    if ( $h { $front } == 0 ) {\n\tdelete $h { $front }; }\n\n    # push character to the end of @t string\n    push @t, $front;\n\n    # take advantage of short circuiting\n    while ( @t > 0 and &is_small ( $t[ @t-1 ], \\%h ) ) {\n\n\t$back = pop @t;\n\tpush @u, $back;}\n}\n\n# put the remainder of @t onto @u\nwhile ( @t > 0 ) {\n    $back = pop @t;\n    push @u, $back; }\n\n# print the resuling string\nprint @u;\nprint \"\\n\";\n\n\n\n\n\n\n\n\n"}], "negative_code": [{"source_code": "\n# function returns true if the current\n# character is the smallest in the rest\n# otherwise, it returns false\n# of string s\n# parameters are the character and\n# the hash\nsub is_small {\n    my $chr = shift @_;\n    my $h_ref = shift @_;\n    for my $i ( keys %{ $h_ref } ) {\n\tif ( ($i lt $chr) and ${ $h_ref }{ $i } > 0 ) {\n\t    return 0;}}\t\t# return false if character is less than\n    return 1;\t\t\t# chr and there are still chrs in the string\n}\n\n\n\n# initialize hash\nmy $h;\nfor my $i (a..z) {\n    $h{ $i } = 0; }\n\n# read input\nmy $f = <STDIN>;\nchomp ( $f );\n# put the string into an array\nmy @s = split m//, $f;\n\n# calculate frequencies for each character\n# in the string and store in the hash\nfor (@s) {\n    $h{ $_ } += 1;}\n\n# strings described in problem statement\nmy @t;\nmy @u;\n\n# temporary varaibles for pushing and poping and shifting\nmy $front;\nmy $back;\n\n# main algorithm with two operations\nwhile ( @s > 0 ) {\n    \n    $front = shift @s;\n    push @t, $front;\n    if ( &is_small ( $front, \\%h ) ) {\n\t$back = pop @t;\n\tpush @u, $back;}\n}\n\n# put the remainder of @t onto @u\nwhile ( @t > 0 ) {\n    $back = pop @t;\n    push @u, $back; }\n\n# print the resuling string\nprint @u;\nprint \"\\n\";\n\n\n\n\n\n\n\n\n"}, {"source_code": "$s = <>;\nfor $c (\"a\"..\"z\") {\n\tif ($s =~ s/.*$c//) {\n\t\t$w = $&;\n\t\t$n = $w =~ s/$c//g;\n\t\t$u .= $c x $n;\n\t\t$t .= $w;\n\t}\n\tif ($t =~ s/[a-$c]+$//) {\n\t\t$u .= reverse $&;\n\t}\n}\nprint $u;\t\n\n"}], "src_uid": "e758ae072b8aed53038e4593a720276d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B, $C ) = sort { $a <=> $b } split;\n\t\n\t$A ++ if $C - $A > 1;\n\t$C -- if $C - $A > 0;\n\t\n\tprint 2 * ( $C - $A );\n\t}", "positive_code": [{"source_code": "my $tests = <>;\n#printf(\"tests:$tests\\n\");\nchomp ($tests);\nforeach my $t (1..$tests) {\n my $in = <>;\n chomp($in);\n my @arr = split(\" \",$in);\n my @sorted = sort { $a <=> $b } @arr;\n my $a = $sorted[0];\n my $b = $sorted[1];\n my $c = $sorted[2];\n #print \"a,b,c:$a,$b,$c\\n\";\n if ($a != $b) {\n     $a++;\n     if ($b != $c) {\n      $c--;   \n     } elsif ($a != $b) {\n         $c--;\n         $b--;\n     }\n } elsif ($b != $c) {\n     $c--;\n     if ($c != $b) {\n         $b++;\n         $a++;\n     }\n }\n \n #print \"a,b,c:$a,$b,$c\\n\";\n my $d = ($c - $b) + ($b - $a) + ($c - $a);\n print \"$d\\n\";\n}"}], "negative_code": [{"source_code": "my $tests = <>;\n#printf(\"tests:$tests\\n\");\nchomp ($tests);\nforeach my $t (1..$tests) {\n my $in = <>;\n chomp($in);\n my @arr = split(\" \",$in);\n my @sorted = sort { $a <=> $b } @arr;\n my $a = $sorted[0];\n my $b = $sorted[1];\n my $c = $sorted[2];\n #print \"a,b,c:$a,$b,$c\\n\";\n if ($a != $b) {\n     $a++;\n     if ($b != $c) {\n      $c--;   \n     } else {\n         $c--;\n         $b--;\n     }\n }\n #print \"a,b,c:$a,$b,$c\\n\";\n my $d = ($c - $b) + ($b - $a) + ($c - $a);\n print \"$d\\n\";\n}"}, {"source_code": "my $tests = <>;\n#printf(\"tests:$tests\\n\");\nchomp ($tests);\nforeach my $t (1..$tests) {\n my $in = <>;\n chomp($in);\n my @arr = split(\" \",$in);\n my @sorted = sort { $a <=> $b } @arr;\n my $a = $sorted[0];\n my $b = $sorted[1];\n my $c = $sorted[2];\n #print \"a,b,c:$a,$b,$c\\n\";\n if ($a != $b) {\n     $a++;\n     if ($b != $c) {\n      $c--;   \n     } else {\n         $c--;\n         $b--;\n     }\n } elsif ($b != $c) {\n     $c--;\n }\n \n #print \"a,b,c:$a,$b,$c\\n\";\n my $d = ($c - $b) + ($b - $a) + ($c - $a);\n print \"$d\\n\";\n}"}, {"source_code": "my $tests = <>;\n#printf(\"tests:$tests\\n\");\nchomp ($tests);\nforeach my $t (1..$tests) {\n my $in = <>;\n chomp($in);\n my @arr = split(\" \",$in);\n my @sorted = sort { $a <=> $b } @arr;\n my $a = $sorted[0];\n my $b = $sorted[1];\n my $c = $sorted[2];\n #print \"a,b,c:$a,$b,$c\\n\";\n if ($a != $b) {\n     $a++;\n     if ($b != $c) {\n      $c--;   \n     } elsif ($a != $b) {\n         $c--;\n         $b--;\n     }\n } elsif ($b != $c) {\n     $c--;\n }\n \n #print \"a,b,c:$a,$b,$c\\n\";\n my $d = ($c - $b) + ($b - $a) + ($c - $a);\n print \"$d\\n\";\n}"}], "src_uid": "18f2e54e4147e8887da737d5b6639473"}
{"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n", "positive_code": [{"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}, {"source_code": "chomp($n=<>);\nmy %cnt = {};\nwhile (<>) {\n\tchomp;\n\tpush @a, [split / /];\n\t++$cnt[$a[-1][0]];\n}\nmy $m = 2*($n-1);\nfor my $s (@a) {\n\t$v = $n-1;\n\t$v += $cnt[@$s[1]];\n\tprint $v, ' ', $m-$v, \"\\n\";\n}"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}, {"source_code": "<>;\nwhile(<>){\n\t($a,$_[$i++])=split/ /;\n\t$k[$a]++\n\t}\n\npush @p, (@_-1+$k[$_[$j]],).\" \".(@_-1-$k[$_[$j]]).\"\\n\" and $j++ for @_;\nprint @p"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_"}, {"source_code": "<>;\n$k[(($a,$_[$i++])=split/ /)[0]]++ for <>;\nprint @_-1+$k[$_[$j]],\" \",@_-1-$k[$_[$j]],\"\\n\" and $j++ for @_\n"}], "negative_code": [], "src_uid": "7899a22cee29bb96d671f6188f246c21"}
{"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $line = <STDIN>);\n\nmy ($n, $m) = split q{ }, $line;\n\nmy $a;\nfor my $y ( 1..$n ) {\n    chomp ($line = <STDIN>);\n    my @x = (1, split (q{ }, $line), 1);\n    $a->[$y] = \\@x;\n}\n$a->[$n+1] = [(1)x($m+2)];\n\nmy $b;\n\nfor my $y ( 1..$n ) {\n    my @x = ( (0)x($m+1), 1 );\n    $b->[$y] = \\@x;\n}\n$b->[$n+1] = [(1)x($m+2)];\n\nmy $same_flag = TRUE;\n\nCHECKSAME:\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            $same_flag = FALSE;\n            last CHECKSAME;\n        }\n    }\n}\n\nif ( $same_flag == TRUE ) {\n    say 0;\n    exit(0);\n}\n\n\nmy $answer = [];\n\nfor my $y ( 1..$n-1 ) {\n    for my $x ( 1..$m-1 ) {\n        if ( converter_check($a, $y, $x) \n             && !same($a, $b, $y, $x) ) {\n            convert($b, $y, $x);\n            push @$answer, [$y, $x];\n        }\n    }\n}\n\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            say -1;\n            exit(0);\n        }\n    }\n}\n\nsay scalar @$answer;\nfor ( @$answer ) {\n    say \"$_->[0] $_->[1]\";\n}\n\nsub converter_check {\n    my ($a, $y, $x) = @_;\n    return FALSE \n        if $a->[$y][$x] == 0 \n            or $a->[$y][$x+1] == 0\n            or $a->[$y+1][$x] == 0\n            or $a->[$y+1][$x+1] == 0;\n    return TRUE;\n}\n\nsub convert {\n    my ($b, $y, $x) = @_;\n    $b->[$y][$x] = 1;\n    $b->[$y][$x+1] = 1;\n    $b->[$y+1][$x] = 1;\n    $b->[$y+1][$x+1] = 1;\n}\n\nsub same {\n    my ($a, $b, $y, $x) = @_;\n    return TRUE \n        if $a->[$y][$x] == $b->[$y][$x] \n            and $a->[$y][$x+1] == $b->[$y][$x+1]\n            and $a->[$y+1][$x] == $b->[$y+1][$x]\n            and $a->[$y+1][$x+1] == $b->[$y+1][$x+1];\n    return FALSE;\n}\n", "positive_code": [{"source_code": "( $n, $m, @c ) = split ' ', <>;\n\n$_ = join '', <>;\ny! !!d;\n\n$g = $m - 1;\n\n0 while\n\ts/\n\t\t[1,]{2} (.{$g})\n\t\t[1,]{2}\n\t\t(?{\n\t\t\tpush @c, join \" \", map int, ( pos ) \\/ ( $m + 1 ), ( pos ) % ( $m + 1 ) - 1;\n\t\t\t})\n\t/\n\t\t\":,\" . $1 .\n\t\t\",,\"\n\t/xse;\n\nprint /1/ ? -1 : join \"\\n\", ~~ @c, @c;"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print \"-\" x 15;\n\t\n\tmy( $n, $m ) = split;\n\t\n\t$_ = join '', map ~~<>, 1 .. $n;\n\ty/ //d;\n\tchomp;\n\t\n\t$debug and print;\n\t\n\tmy $gap = $m - 2 + 1;\n\t\n\t0 while\n\t\ts/\n\t\t\t[1,]{2} (.{$gap})\n\t\t\t[1,]{2}\n\t\t/\n\t\t\t\":,\" . $1 .\n\t\t\t\",,\"\n\t\t/xse;\n\t\n\t$debug and print;\n\t\t\n\t/1/ and print -1 and next;\n\t\n\t@_ = split \"\\n\", $_;\n\t\n\tmy @coords;\n\t\n\tfor my $i ( 0 .. $n - 1 ){\n\t\twhile( $_[ $i ] =~ /:/g ){\n\t\t\tpush @coords, join \" \", $i + 1, pos $_[ $i ];\n\t\t\t}\n\t\t}\n\t\n\tprint for ~~ @coords, @coords;\n\t}"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    my ($n, $m)= split(' ', $q);\n\n    my @ma;\n    my @mb;\n\n    my $only_zeros= 1;\n    for (my $i = 0; $i < $n; $i++) {\n        $q= <$in>; chomp($q);\n        push(@ma, [ split(' ', $q) ]);\n\n        my @empty_row;\n        for (my $j = 0; $j < $m; $j++) {\n            $only_zeros=0 if($ma[$i][$j] > 0);\n            push(@empty_row, 0);\n        }\n\n        push(@mb, \\@empty_row);\n    }\n\n    (print('0') && return) if($only_zeros);\n\n    (print('-1') && return) if($n < 2 || $m < 2);\n    # (print('-1') && return) if(!possible(\\@ma, $n, $m));\n    #\n    bar($n,$m,\\@ma,\\@mb);\n\n    # print STDERR Dumper \\@ma;\n    # print STDERR Dumper \\@mb;\n    # print \"only_zeros $only_zeros\\n\";\n\n\n}\n\nsub possible {\n    my ($m, $r, $c)= @_;\n\n    my $possible= 1;\n\n    OUT: for (my $i = 0; $i < $r; $i++) {\n        for (my $j=0; $j < $c; $j++) {\n            # print \"i: $i, j:$j\\n\";\n            if(\n                ( # case 1 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i+1 < $r) && ($j+1 < $c) && ($m->[$i+1][$j+1] == 1))\n                ) || ( # case 2 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i+1 < $r) && ($j-1 >= 0) && ($m->[$i+1][$j-1] == 1))\n                ) || ( # case 3 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i-1 >= 0) && ($j+1 < $c) && ($m->[$i-1][$j+1] == 1))\n                ) || ( # case 4\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i-1 >= 0) && ($j-1 >= 0) && ($m->[$i-1][$j-1] == 1))\n                ) || ($m->[$i][$j] == 0)\n            ) {\n                # all good\n            } else {\n                # print \"Not Possible\\n\";\n                $possible= 0;\n                last OUT;\n            }\n        }\n    }\n\n    return $possible;\n}\n\nsub bar {\n    my ($r, $c, $ma, $mb)= @_;\n\n    my @changes;\n\n    # print STDERR Dumper $ma;\n\n    for (my $i = 0; $i < $r; $i++) {\n        for (my $j = 0; $j < $c; $j++) {\n            # print \"i: $i, j: $j r: $r, c: $c \";\n            # print \"maij= \" . $ma->[$i][$j];\n            # print $/;\n            if(\n                ($ma->[$i][$j] == 1) &&\n                (\n                    (\n                        (($j<($c-1)) && ($ma->[$i][$j+1] == 1))\n                    ) &&\n                    (\n                        ($j<($c-1) && $i<($r-1)) && ($ma->[$i+1][$j+1] == 1)\n                    ) &&\n                    (\n                        (($i<($r-1)) && ($ma->[$i+1][$j] == 1))\n                    )\n                )\n            ) {\n                push(@changes, [ $i+1, $j+1 ]);\n                $mb->[$i][$j]=1;\n                $mb->[$i+1][$j]=1;\n                $mb->[$i][$j+1]=1;\n                $mb->[$i+1][$j+1]=1;\n            } else {\n               (print('-1') && return) unless(\n                    $ma->[$i][$j] == $mb->[$i][$j]\n                );\n            }\n        }\n    }\n    # $m->[$x][$y]= 1;\n    # $m->[$x+1][$y]= 1;\n    # $m->[$x][$y+1]= 1;\n    # $m->[$x+1][$y+1]= 1;\n\n    # print STDERR Dumper \\@changes;\n\n    (print(-1) &&  return) if(scalar(@changes)>2500);\n\n    print scalar(@changes);\n    print $/;\n    for my $a (@changes) {\n        print join(' ', @{$a});\n        print $/;\n    }\n}\n\nmain() unless caller();\n\n"}], "negative_code": [{"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    my ($n, $m)= split(' ', $q);\n\n    my @ma;\n    my @mb;\n\n    my $only_zeros= 1;\n    for (my $i = 0; $i < $n; $i++) {\n        $q= <$in>; chomp($q);\n        push(@ma, [ split(' ', $q) ]);\n\n        my @empty_row;\n        for (my $j = 0; $j < $m; $j++) {\n            $only_zeros=0 if($ma[$i][$j] > 0);\n            push(@empty_row, 0);\n        }\n\n        push(@mb, \\@empty_row);\n    }\n\n    (print('0') && return) if($only_zeros);\n\n    (print('-1') && return) if($n < 2 || $m < 2);\n    # (print('-1') && return) if(!possible(\\@ma, $n, $m));\n\n    bar($n,$m,\\@ma,\\@mb);\n\n    # print STDERR Dumper \\@ma;\n    # print STDERR Dumper \\@mb;\n    # print \"only_zeros $only_zeros\\n\";\n\n\n}\n\nsub possible {\n    my ($m, $r, $c)= @_;\n\n    my $possible= 1;\n\n    OUT: for (my $i = 0; $i < $r; $i++) {\n        for (my $j=0; $j < $c; $j++) {\n            # print \"i: $i, j:$j\\n\";\n            if(\n                ( # case 1 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i+1 < $r) && ($j+1 < $c) && ($m->[$i+1][$j+1] == 1))\n                ) || ( # case 2 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i+1 < $r) && ($j-1 >= 0) && ($m->[$i+1][$j-1] == 1))\n                ) || ( # case 3 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i-1 >= 0) && ($j+1 < $c) && ($m->[$i-1][$j+1] == 1))\n                ) || ( # case 4\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i-1 >= 0) && ($j-1 >= 0) && ($m->[$i-1][$j-1] == 1))\n                ) || ($m->[$i][$j] == 0)\n            ) {\n                # all good\n            } else {\n                # print \"Not Possible\\n\";\n                $possible= 0;\n                last OUT;\n            }\n        }\n    }\n\n    return $possible;\n}\n\nsub bar {\n    my ($r, $c, $ma, $mb)= @_;\n\n    my @changes;\n\n    # print STDERR Dumper $ma;\n\n    for (my $i = 0; $i < $r; $i++) {\n        for (my $j = 0; $j < $c; $j++) {\n            # print \"i: $i, j: $j r: $r, c: $c \";\n            # print \"maij= \" . $ma->[$i][$j];\n            # print $/;\n            if(\n                ($ma->[$i][$j] == 1) &&\n                (\n                    (\n                        (($j<($c-1)) && ($ma->[$i][$j+1] == 1))\n                    ) &&\n                    (\n                        ($j<($c-1) && $i<($r-1)) && ($ma->[$i+1][$j+1] == 1)\n                    ) &&\n                    (\n                        (($i<($c-1)) && ($ma->[$i+1][$j] == 1))\n                    )\n\n                    # ( # either first col or col before is 0\n                        # ($j==0) ||\n                        # (($j>0) && ($ma->[$i][$j-1] == 0))\n                    # ) &&\n                    # ( # either first col and row, or before is 0\n                        # (\n                        #     ($j==0 && $i==0)\n                        # ) ||\n                        # (($i>0 && $j>0) && ($ma->[$i-1][$j-1] == 0))\n                    # ) &&\n                    # ( # either first row or row before is 0\n                        # ($i==0) ||\n                        # (($i>0) && ($ma->[$i-1][$j] == 0))\n                    # )\n                )\n            ) {\n                push(@changes, [ $i+1, $j+1 ]);\n                $mb->[$i][$j]=1;\n                $mb->[$i+1][$j]=1;\n                $mb->[$i][$j+1]=1;\n                $mb->[$i+1][$j+1]=1;\n            } else {\n                (print(-1) && return) unless(\n                    $ma->[$i][$j] == $mb->[$i][$j]\n                );\n            }\n        }\n    }\n    # $m->[$x][$y]= 1;\n    # $m->[$x+1][$y]= 1;\n    # $m->[$x][$y+1]= 1;\n    # $m->[$x+1][$y+1]= 1;\n\n    # print STDERR Dumper \\@changes;\n\n    (print(-1) &&  return) if(scalar(@changes)>2500);\n\n    print scalar(@changes);\n    print $/;\n    for my $a (@changes) {\n        print join(' ', @{$a});\n        print $/;\n    }\n}\n\nmain() unless caller();\n\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    my ($n, $m)= split(' ', $q);\n\n    my @ma;\n    my @mb;\n\n    my $only_zeros= 1;\n    for (my $i = 0; $i < $n; $i++) {\n        $q= <$in>; chomp($q);\n        push(@ma, [ split(' ', $q) ]);\n\n        my @empty_row;\n        for (my $j = 0; $j < $m; $j++) {\n            $only_zeros=0 if($ma[$i][$j] > 0);\n            push(@empty_row, 0);\n        }\n\n        push(@mb, \\@empty_row);\n    }\n\n    (print('0') && return) if($only_zeros);\n\n    (print('-1') && return) if($n < 2 || $m < 2);\n    # (print('-1') && return) if(!possible(\\@ma, $n, $m));\n    #\n    bar($n,$m,\\@ma,\\@mb);\n\n    # print STDERR Dumper \\@ma;\n    # print STDERR Dumper \\@mb;\n    # print \"only_zeros $only_zeros\\n\";\n\n\n}\n\nsub possible {\n    my ($m, $r, $c)= @_;\n\n    my $possible= 1;\n\n    OUT: for (my $i = 0; $i < $r; $i++) {\n        for (my $j=0; $j < $c; $j++) {\n            # print \"i: $i, j:$j\\n\";\n            if(\n                ( # case 1 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i+1 < $r) && ($j+1 < $c) && ($m->[$i+1][$j+1] == 1))\n                ) || ( # case 2 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i+1 < $r) && ($j-1 >= 0) && ($m->[$i+1][$j-1] == 1))\n                ) || ( # case 3 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i-1 >= 0) && ($j+1 < $c) && ($m->[$i-1][$j+1] == 1))\n                ) || ( # case 4\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i-1 >= 0) && ($j-1 >= 0) && ($m->[$i-1][$j-1] == 1))\n                ) || ($m->[$i][$j] == 0)\n            ) {\n                # all good\n            } else {\n                # print \"Not Possible\\n\";\n                $possible= 0;\n                last OUT;\n            }\n        }\n    }\n\n    return $possible;\n}\n\nsub bar {\n    my ($r, $c, $ma, $mb)= @_;\n\n    my @changes;\n\n    # print STDERR Dumper $ma;\n\n    for (my $i = 0; $i < $r; $i++) {\n        for (my $j = 0; $j < $c; $j++) {\n            # print \"i: $i, j: $j r: $r, c: $c \";\n            # print \"maij= \" . $ma->[$i][$j];\n            # print $/;\n            if(\n                ($ma->[$i][$j] == 1) &&\n                (\n                    (\n                        (($j<($c-1)) && ($ma->[$i][$j+1] == 1))\n                    ) &&\n                    (\n                        ($j<($c-1) && $i<($r-1)) && ($ma->[$i+1][$j+1] == 1)\n                    ) &&\n                    (\n                        (($i<($r-1)) && ($ma->[$i+1][$j] == 1))\n                    )\n                )\n            ) {\n                push(@changes, [ $i+1, $j+1 ]);\n                $mb->[$i][$j]=1;\n                $mb->[$i+1][$j]=1;\n                $mb->[$i][$j+1]=1;\n                $mb->[$i+1][$j+1]=1;\n            } else {\n               (print('-11') && return) unless(\n                    $ma->[$i][$j] == $mb->[$i][$j]\n                );\n            }\n        }\n    }\n    # $m->[$x][$y]= 1;\n    # $m->[$x+1][$y]= 1;\n    # $m->[$x][$y+1]= 1;\n    # $m->[$x+1][$y+1]= 1;\n\n    # print STDERR Dumper \\@changes;\n\n    (print(-1) &&  return) if(scalar(@changes)>2500);\n\n    print scalar(@changes);\n    print $/;\n    for my $a (@changes) {\n        print join(' ', @{$a});\n        print $/;\n    }\n}\n\nmain() unless caller();\n\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    my ($n, $m)= split(' ', $q);\n\n    my @ma;\n    my @mb;\n\n    my $only_zeros= 1;\n    for (my $i = 0; $i < $n; $i++) {\n        $q= <$in>; chomp($q);\n        push(@ma, [ split(' ', $q) ]);\n\n        my @empty_row;\n        for (my $j = 0; $j < $m; $j++) {\n            $only_zeros=0 if($ma[$i][$j] > 0);\n            push(@empty_row, 0);\n        }\n\n        push(@mb, \\@empty_row);\n    }\n\n    (print('0') && return) if($only_zeros);\n\n    (print('-1') && return) if($n < 3 || $m < 3);\n    (print('-1') && return) if(!possible(\\@ma, $n, $m));\n\n    bar($n,$m,\\@ma,\\@mb);\n\n    # print STDERR Dumper \\@ma;\n    # print STDERR Dumper \\@mb;\n    # print \"only_zeros $only_zeros\\n\";\n\n\n}\n\nsub possible {\n    my ($m, $r, $c)= @_;\n\n    my $possible= 1;\n\n    OUT: for (my $i = 0; $i < $r; $i++) {\n        for (my $j=0; $j < $c; $j++) {\n            # print \"i: $i, j:$j\\n\";\n            if(\n                ( # case 1 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i+1 < $r) && ($j+1 < $c) && ($m->[$i+1][$j+1] == 1))\n                ) || ( # case 2 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i+1 < $r) && ($j-1 >= 0) && ($m->[$i+1][$j-1] == 1))\n                ) || ( # case 3 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i-1 >= 0) && ($j+1 < $c) && ($m->[$i-1][$j+1] == 1))\n                ) || ( # case 4\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i-1 >= 0) && ($j-1 >= 0) && ($m->[$i-1][$j-1] == 1))\n                ) || ($m->[$i][$j] == 0)\n            ) {\n                # all good\n            } else {\n                # print \"Not Possible\\n\";\n                $possible= 0;\n                last OUT;\n            }\n        }\n    }\n\n    return $possible;\n}\n\nsub bar {\n    my ($r, $c, $ma, $mb)= @_;\n\n    my @changes;\n\n    # print STDERR Dumper $ma;\n\n    for (my $i = 0; $i < $r; $i++) {\n        for (my $j = 0; $j < $c; $j++) {\n            # print \"i: $i, j: $j r: $r, c: $c \";\n            # print \"maij= \" . $ma->[$i][$j];\n            # print $/;\n            if(\n                ($ma->[$i][$j] == 1) &&\n                (\n                    (\n                        (($j<($c-1)) && ($ma->[$i][$j+1] == 1))\n                    ) &&\n                    (\n                        ($j<($c-1) && $i<($r-1)) && ($ma->[$i+1][$j+1] == 1)\n                    ) &&\n                    (\n                        (($i<($c-1)) && ($ma->[$i+1][$j] == 1))\n                    )\n\n                    # ( # either first col or col before is 0\n                        # ($j==0) ||\n                        # (($j>0) && ($ma->[$i][$j-1] == 0))\n                    # ) &&\n                    # ( # either first col and row, or before is 0\n                        # (\n                        #     ($j==0 && $i==0)\n                        # ) ||\n                        # (($i>0 && $j>0) && ($ma->[$i-1][$j-1] == 0))\n                    # ) &&\n                    # ( # either first row or row before is 0\n                        # ($i==0) ||\n                        # (($i>0) && ($ma->[$i-1][$j] == 0))\n                    # )\n                )\n            ) {\n                push(@changes, [ $i+1, $j+1 ]);\n            }\n        }\n    }\n    # $m->[$x][$y]= 1;\n    # $m->[$x+1][$y]= 1;\n    # $m->[$x][$y+1]= 1;\n    # $m->[$x+1][$y+1]= 1;\n\n    # print STDERR Dumper \\@changes;\n\n    print scalar(@changes);\n    print $/;\n    for my $a (@changes) {\n        print join(' ', @{$a});\n        print $/;\n    }\n}\n\nmain() unless caller();\n\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    my ($n, $m)= split(' ', $q);\n\n    my @ma;\n    my @mb;\n\n    my $only_zeros= 1;\n    for (my $i = 0; $i < $n; $i++) {\n        $q= <$in>; chomp($q);\n        push(@ma, [ split(' ', $q) ]);\n\n        my @empty_row;\n        for (my $j = 0; $j < $m; $j++) {\n            $only_zeros=0 if($ma[$i][$j] > 0);\n            push(@empty_row, 0);\n        }\n\n        push(@mb, \\@empty_row);\n    }\n\n    (print('0') && return) if($only_zeros);\n\n    (print('-1') && return) if($n < 2 || $m < 2);\n    (print('-1') && return) if(!possible(\\@ma, $n, $m));\n\n    bar($n,$m,\\@ma,\\@mb);\n\n    # print STDERR Dumper \\@ma;\n    # print STDERR Dumper \\@mb;\n    # print \"only_zeros $only_zeros\\n\";\n\n\n}\n\nsub possible {\n    my ($m, $r, $c)= @_;\n\n    my $possible= 1;\n\n    OUT: for (my $i = 0; $i < $r; $i++) {\n        for (my $j=0; $j < $c; $j++) {\n            # print \"i: $i, j:$j\\n\";\n            if(\n                ( # case 1 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i+1 < $r) && ($j+1 < $c) && ($m->[$i+1][$j+1] == 1))\n                ) || ( # case 2 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i+1 < $r) && ($j-1 >= 0) && ($m->[$i+1][$j-1] == 1))\n                ) || ( # case 3 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i-1 >= 0) && ($j+1 < $c) && ($m->[$i-1][$j+1] == 1))\n                ) || ( # case 4\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i-1 >= 0) && ($j-1 >= 0) && ($m->[$i-1][$j-1] == 1))\n                ) || ($m->[$i][$j] == 0)\n            ) {\n                # all good\n            } else {\n                # print \"Not Possible\\n\";\n                $possible= 0;\n                last OUT;\n            }\n        }\n    }\n\n    return $possible;\n}\n\nsub bar {\n    my ($r, $c, $ma, $mb)= @_;\n\n    my @changes;\n\n    # print STDERR Dumper $ma;\n\n    for (my $i = 0; $i < $r; $i++) {\n        for (my $j = 0; $j < $c; $j++) {\n            # print \"i: $i, j: $j r: $r, c: $c \";\n            # print \"maij= \" . $ma->[$i][$j];\n            # print $/;\n            if(\n                ($ma->[$i][$j] == 1) &&\n                (\n                    (\n                        (($j<($c-1)) && ($ma->[$i][$j+1] == 1))\n                    ) &&\n                    (\n                        ($j<($c-1) && $i<($r-1)) && ($ma->[$i+1][$j+1] == 1)\n                    ) &&\n                    (\n                        (($i<($c-1)) && ($ma->[$i+1][$j] == 1))\n                    )\n\n                    # ( # either first col or col before is 0\n                        # ($j==0) ||\n                        # (($j>0) && ($ma->[$i][$j-1] == 0))\n                    # ) &&\n                    # ( # either first col and row, or before is 0\n                        # (\n                        #     ($j==0 && $i==0)\n                        # ) ||\n                        # (($i>0 && $j>0) && ($ma->[$i-1][$j-1] == 0))\n                    # ) &&\n                    # ( # either first row or row before is 0\n                        # ($i==0) ||\n                        # (($i>0) && ($ma->[$i-1][$j] == 0))\n                    # )\n                )\n            ) {\n                push(@changes, [ $i+1, $j+1 ]);\n            }\n        }\n    }\n    # $m->[$x][$y]= 1;\n    # $m->[$x+1][$y]= 1;\n    # $m->[$x][$y+1]= 1;\n    # $m->[$x+1][$y+1]= 1;\n\n    # print STDERR Dumper \\@changes;\n\n    (print(-1) &&  return) if(scalar(@changes)>2500);\n\n    print scalar(@changes);\n    print $/;\n    for my $a (@changes) {\n        print join(' ', @{$a});\n        print $/;\n    }\n}\n\nmain() unless caller();\n\n"}, {"source_code": "\nuse strict;\nuse warnings;\n\nuse Data::Dumper;\n\nsub main {\n\n    my $in= *STDIN;\n    my $q= <$in>; chomp($q);\n\n    my ($n, $m)= split(' ', $q);\n\n    my @ma;\n    my @mb;\n\n    my $only_zeros= 1;\n    for (my $i = 0; $i < $n; $i++) {\n        $q= <$in>; chomp($q);\n        push(@ma, [ split(' ', $q) ]);\n\n        my @empty_row;\n        for (my $j = 0; $j < $m; $j++) {\n            $only_zeros=0 if($ma[$i][$j] > 0);\n            push(@empty_row, 0);\n        }\n\n        push(@mb, \\@empty_row);\n    }\n\n    (print('0') && return) if($only_zeros);\n\n    (print('-1') && return) if($n < 2 || $m < 2);\n    (print('-1') && return) if(!possible(\\@ma, $n, $m));\n\n    bar($n,$m,\\@ma,\\@mb);\n\n    # print STDERR Dumper \\@ma;\n    # print STDERR Dumper \\@mb;\n    # print \"only_zeros $only_zeros\\n\";\n\n\n}\n\nsub possible {\n    my ($m, $r, $c)= @_;\n\n    my $possible= 1;\n\n    OUT: for (my $i = 0; $i < $r; $i++) {\n        for (my $j=0; $j < $c; $j++) {\n            # print \"i: $i, j:$j\\n\";\n            if(\n                ( # case 1 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i+1 < $r) && ($j+1 < $c) && ($m->[$i+1][$j+1] == 1))\n                ) || ( # case 2 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i+1 < $r) && ($m->[$i+1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i+1 < $r) && ($j-1 >= 0) && ($m->[$i+1][$j-1] == 1))\n                ) || ( # case 3 is true\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j+1 < $c) && ($m->[$i][$j+1] == 1)) &&\n                    (($i-1 >= 0) && ($j+1 < $c) && ($m->[$i-1][$j+1] == 1))\n                ) || ( # case 4\n                    ($m->[$i][$j] == 1) &&\n                    (($i-1 >= 0) && ($m->[$i-1][$j] == 1)) &&\n                    (($j-1 >= 0) && ($m->[$i][$j-1] == 1)) &&\n                    (($i-1 >= 0) && ($j-1 >= 0) && ($m->[$i-1][$j-1] == 1))\n                ) || ($m->[$i][$j] == 0)\n            ) {\n                # all good\n            } else {\n                # print \"Not Possible\\n\";\n                $possible= 0;\n                last OUT;\n            }\n        }\n    }\n\n    return $possible;\n}\n\nsub bar {\n    my ($r, $c, $ma, $mb)= @_;\n\n    my @changes;\n\n    # print STDERR Dumper $ma;\n\n    for (my $i = 0; $i < $r; $i++) {\n        for (my $j = 0; $j < $c; $j++) {\n            # print \"i: $i, j: $j r: $r, c: $c \";\n            # print \"maij= \" . $ma->[$i][$j];\n            # print $/;\n            if(\n                ($ma->[$i][$j] == 1) &&\n                (\n                    (\n                        (($j<($c-1)) && ($ma->[$i][$j+1] == 1))\n                    ) &&\n                    (\n                        ($j<($c-1) && $i<($r-1)) && ($ma->[$i+1][$j+1] == 1)\n                    ) &&\n                    (\n                        (($i<($c-1)) && ($ma->[$i+1][$j] == 1))\n                    )\n\n                    # ( # either first col or col before is 0\n                        # ($j==0) ||\n                        # (($j>0) && ($ma->[$i][$j-1] == 0))\n                    # ) &&\n                    # ( # either first col and row, or before is 0\n                        # (\n                        #     ($j==0 && $i==0)\n                        # ) ||\n                        # (($i>0 && $j>0) && ($ma->[$i-1][$j-1] == 0))\n                    # ) &&\n                    # ( # either first row or row before is 0\n                        # ($i==0) ||\n                        # (($i>0) && ($ma->[$i-1][$j] == 0))\n                    # )\n                )\n            ) {\n                push(@changes, [ $i+1, $j+1 ]);\n            }\n        }\n    }\n    # $m->[$x][$y]= 1;\n    # $m->[$x+1][$y]= 1;\n    # $m->[$x][$y+1]= 1;\n    # $m->[$x+1][$y+1]= 1;\n\n    # print STDERR Dumper \\@changes;\n\n    print scalar(@changes);\n    print $/;\n    for my $a (@changes) {\n        print join(' ', @{$a});\n        print $/;\n    }\n}\n\nmain() unless caller();\n\n"}, {"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $line = <STDIN>);\n\nmy ($n, $m) = split q{ }, $line;\n\nmy $a;\nfor my $y ( 1..$n ) {\n    chomp ($line = <STDIN>);\n    my @x = (1, split (q{ }, $line), 1);\n    $a->[$y] = \\@x;\n}\n$a->[$n+1] = [(1)x($m+2)];\n\nmy $b;\n\nfor my $y ( 1..$n ) {\n    my @x = ( (0)x($m+1), 1 );\n    $b->[$y] = \\@x;\n}\n$b->[$n+1] = [(1)x($m+2)];\n\nmy $same_flag = TRUE;\n\nCHECKSAME:\nfor my $y (1..$n-1) {\n    for my $x (1..$m-1) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            $same_flag = FALSE;\n            last CHECKSAME;\n        }\n    }\n}\n\nif ( $same_flag == TRUE ) {\n    say 0;\n    exit(0);\n}\n\n\nmy $answer = [];\n\nfor my $y ( 1..$n ) {\n    for my $x ( 1..$m ) {\n        if ( converter_check($a, $y, $x) \n             && !same($a, $b, $y, $x) ) {\n            convert($b, $y, $x);\n            push @$answer, [$y, $x];\n        }\n    }\n}\n\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            say -1;\n            exit(0);\n        }\n    }\n}\n\nsay scalar @$answer;\nfor ( @$answer ) {\n    say \"$_->[0] $_->[1]\";\n}\n\nsub converter_check {\n    my ($a, $y, $x) = @_;\n    return FALSE \n        if $a->[$y][$x] == 0 \n            or $a->[$y][$x+1] == 0\n            or $a->[$y+1][$x] == 0\n            or $a->[$y+1][$x+1] == 0;\n    return TRUE;\n}\n\nsub convert {\n    my ($b, $y, $x) = @_;\n    $b->[$y][$x] = 1;\n    $b->[$y][$x+1] = 1;\n    $b->[$y+1][$x] = 1;\n    $b->[$y+1][$x+1] = 1;\n}\n\nsub same {\n    my ($a, $b, $y, $x) = @_;\n    return TRUE \n        if $a->[$y][$x] == $b->[$y][$x] \n            and $a->[$y][$x+1] == $b->[$y][$x+1]\n            and $a->[$y+1][$x] == $b->[$y+1][$x]\n            and $a->[$y+1][$x+1] == $b->[$y+1][$x+1];\n    return FALSE;\n}\n"}, {"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $line = <STDIN>);\n\nmy ($n, $m) = split q{ }, $line;\n\nmy $a;\nfor my $y ( 1..$n ) {\n    chomp ($line = <STDIN>);\n    my @x = (1, split (q{ }, $line), 1);\n    $a->[$y] = \\@x;\n}\n$a->[$n+1] = [(1)x($m+2)];\n\nmy $b;\n\nfor my $y ( 1..$n ) {\n    my @x = ( (0)x($m+1), 1 );\n    $b->[$y] = \\@x;\n}\n$b->[$n+1] = [(1)x($m+2)];\n\nmy $same_flag = TRUE;\n\nCHECKSAME:\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            $same_flag = FALSE;\n            last CHECKSAME;\n        }\n    }\n}\n\nif ( $same_flag == TRUE ) {\n    say 0;\n    exit(0);\n}\n\n\nmy $answer = [];\n\nfor my $y ( 1..$n ) {\n    for my $x ( 1..$m ) {\n        if ( converter_check($a, $y, $x) \n             && !same($a, $b, $y, $x) ) {\n            convert($b, $y, $x);\n            push @$answer, [$y, $x];\n        }\n    }\n}\n\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            say -1;\n            exit(0);\n        }\n    }\n}\n\nsay scalar @$answer;\nfor ( @$answer ) {\n    say \"$_->[0] $_->[1]\";\n}\n\nsub converter_check {\n    my ($a, $y, $x) = @_;\n    return FALSE \n        if $a->[$y][$x] == 0 \n            or $a->[$y][$x+1] == 0\n            or $a->[$y+1][$x] == 0\n            or $a->[$y+1][$x+1] == 0;\n    return TRUE;\n}\n\nsub convert {\n    my ($b, $y, $x) = @_;\n    $b->[$y][$x] = 1;\n    $b->[$y][$x+1] = 1;\n    $b->[$y+1][$x] = 1;\n    $b->[$y+1][$x+1] = 1;\n}\n\nsub same {\n    my ($a, $b, $y, $x) = @_;\n    return TRUE \n        if $a->[$y][$x] == $b->[$y][$x] \n            and $a->[$y][$x+1] == $b->[$y][$x+1]\n            and $a->[$y+1][$x] == $b->[$y+1][$x]\n            and $a->[$y+1][$x+1] == $b->[$y+1][$x+1];\n    return FALSE;\n}\n"}, {"source_code": "#!/usr/bin/env perl \nuse strict;\nuse warnings;\nuse feature qw/ say /;\nuse constant TRUE => 1;\nuse constant FALSE => 0;\n\nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \n\n# start\n\nchomp (my $line = <STDIN>);\n\nmy ($n, $m) = split q{ }, $line;\n\nmy $a;\nfor my $y ( 1..$n ) {\n    chomp ($line = <STDIN>);\n    my @x = (1, split (q{ }, $line), 1);\n    $a->[$y] = \\@x;\n}\n$a->[$n+1] = [(1)x($m+2)];\n\nmy $b;\n\nfor my $y ( 1..$n ) {\n    my @x = ( (0)x($m+1), 1 );\n    $b->[$y] = \\@x;\n}\n$b->[$n+1] = [(1)x($m+2)];\n\nmy $same_flag = TRUE;\n\nCHECKSAME:\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            $same_flag = FALSE;\n            last CHECKSAME;\n        }\n    }\n}\n\nif ( $same_flag == TRUE ) {\n    say 0;\n    exit(0);\n}\n\n\nmy $answer = [];\n\nfor my $y ( 1..$n ) {\n    for my $x ( 1..$m ) {\n        if ( converter_check($a, $y, $x) \n             && !same($a, $b, $y, $x) ) {\n            convert($b, $y, $x);\n            push @$answer, [$y, $x];\n        }\n    }\n}\n\nfor my $y (1..$n) {\n    for my $x (1..$m) {\n        if ( $b->[$y][$x] != $a->[$y][$x] ) {\n            say -1;\n            exit(0);\n        }\n    }\n}\n\nfor ( @$answer ) {\n    say \"$_->[0] $_->[1]\";\n}\n\nsub converter_check {\n    my ($a, $y, $x) = @_;\n    return FALSE \n        if $a->[$y][$x] == 0 \n            or $a->[$y][$x+1] == 0\n            or $a->[$y+1][$x] == 0\n            or $a->[$y+1][$x+1] == 0;\n    return TRUE;\n}\n\nsub convert {\n    my ($b, $y, $x) = @_;\n    $b->[$y][$x] = 1;\n    $b->[$y][$x+1] = 1;\n    $b->[$y+1][$x] = 1;\n    $b->[$y+1][$x+1] = 1;\n}\n\nsub same {\n    my ($a, $b, $y, $x) = @_;\n    return TRUE \n        if $a->[$y][$x] == $b->[$y][$x] \n            and $a->[$y][$x+1] == $b->[$y][$x+1]\n            and $a->[$y+1][$x] == $b->[$y+1][$x]\n            and $a->[$y+1][$x+1] == $b->[$y+1][$x+1];\n    return FALSE;\n}\n"}], "src_uid": "ad641a44ecaf78ca253b199f3d40ef96"}
{"source_code": " my $n = <STDIN>;\n\n  my $found = 0;\n\n  my $level = 0;\n\n  my $throwLevel = -1; \n\n  my $e = \"\"; \n\n  foreach (1 .. $n) {\n\n      my $line = <STDIN>;\n\n      if ($line =~ /^\\s*try/) {\n\n          $level ++; \n\n      } elsif ($line =~ /^\\s*throw\\s*\\(\\s*(\\w+)\\s*\\)/) {\n\n          $e = $1; \n\n          $throwLevel = $level;\n\n          # print \"throw $e at level $throwLevel\\n\";\n\n      } elsif ($line =~ /^\\s*catch\\s*\\(\\s*(\\w+)\\s*,\\s*\"(.+)\"\\s*\\)/) {\n\n          my $ce = $1; \n\n          my $msg = $2; \n\n          if ($ce eq $e && $level <= $throwLevel) {\n\n              $found = 1;\n\n              print \"$msg\\n\";\n\n              last;\n\n          }   \n\n          $level --; \n\n          if ($throwLevel > $level) {\n\n              $throwLevel = $level;\n\n              # print \"decrease throwLevel to $throwLevel\\n\";\n\n          }   \n\n      }   \n\n  }\n\n  if (!$found) {\n\n      print \"Unhandled Exception\";\n\n  }\n\n", "positive_code": [{"source_code": "#!/usr/local/bin/perl\n$n              = <>;\n$openBlocks     = 0;\n$needlessBlocks =\n  0;    #это блоки, открытые после эксепшена TODO\n$wasThrow = 0;\n$eType;\nfor ( 1 .. $n ) {\n    my $line = <>;\n\n    if ( $line =~ /\\s*throw\\s*\\(\\s*(\\w+)\\s*\\)/ ) {\n        $wasThrow = 1;\n        $eType    = $1;\n        maybeError();\n        next;\n    }\n    if ( $line =~ /\\s*catch\\s*\\(\\s*(\\w+)\\s*,\\s*\"(.+)\"\\s*\\)/ ) {\n        if ( $needlessBlocks > 0 ) {\n            $needlessBlocks--;\n            next;\n        }\n        $openBlocks--;\n        if ( $wasThrow != 0 && $eType eq $1 ) {\n            print $2. \"\\n\";\n            exit;\n        }\n        if ( $wasThrow != 0 ) {\n            maybeError();\n        }\n        next;\n    }\n    if ( $line =~ /\\s*try\\s*/ ) {\n        if ( $wasThrow == 0 ) {\n            $openBlocks++;\n        }\n        else {\n            $needlessBlocks++;\n        }\n        next;\n    }\n}\nprint \"Unhandled Exception\\n\";\n\nsub maybeError {\n    if ( $openBlocks == 0 ) {\n        print \"Unhandled Exception\\n\";\n        exit;\n    }\n}\n"}, {"source_code": "\n#!/usr/bin/perl\n\nuse 5.006;\nuse strict;\nuse warnings;\n\nsub getMessage {\n    my $t = shift;\n    my $s = $t;\n    $s =~ s/^[\\w (,]+\\\"//g;\n    $s =~ s/\\\"[\\w) ]+$//g;    \n    $s =~ s/^[\\s]+//g;\n    $s =~ s/[\\s]+$//g;\n    return $s;\n}\n\nsub getException {\n    my $t = shift;\n    my $s = $t;\n    $s =~ s/^[\\w ]+\\(//g;\n    $s =~ s/,[\\w )\\\"]+$//g;    \n    $s =~ s/^[\\s]+//g;\n    $s =~ s/[\\s]+$//g;\n    return $s;\n}\n\nsub startsWith {\n    my $t = shift;\n    my $tok = shift;\n    my $s = $t;\n    $s =~ s/^[\\s]+//g;\n    return 1 if ($s =~ /^$tok/);\n    return 0;\n}\n\nsub getThrowExc {\n    my $t = shift;\n    my $s = $t;\n    $s =~ s/^[\\w ]+\\(//g;\n    $s =~ s/[)]//g;\n    $s =~ s/^[\\s]+//g;\n    $s =~ s/[\\s]+$//g;\n    return $s;\n}\n\nsub blank {\n    my $t = shift;\n    my $s = $t;\n    $s =~ s/[\\s]+//g;\n    return length($s) == 0;    \n}\n\nmy $n = <>;\nmy $line;\nmy $level = 0;\nmy $throwLevel = -1;\nmy $left = 0;\nmy $haveAnswer = 0;\nmy $exc;\nwhile ($line = <>) {\n    next if (blank($line));\n    if ($throwLevel == -1) {\n        if (startsWith($line, \"try\")) {\n            $level++;\n            next;\n        }\n        if (startsWith($line, \"catch\")) {\n            $level--;\n            next;\n        }\n        $exc = getThrowExc($line);          \n        $throwLevel = $level;\n    } else {\n        if (startsWith($line, \"try\")) {\n            $left++;\n            next;                    \n        } \n        my $e = getException($line);\n        if ($left == 0 && $exc eq $e) {\n            $haveAnswer = 1;\n            print getMessage($line);            \n            last;\n        }\n        if ($left > 0) {\n            $left--;\n        }\n            \n\n    }\n}\n\nif ($haveAnswer != 1) {\n    print \"Unhandled Exception\";\n}"}, {"source_code": "#!perl\nuse strict;\nuse warnings;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    my ($tries, $ltries, $type, $message) = (0, 0, \"\", 'Unhandled Exception');\ntc: for (1..$n) {\n        my $str = <>;\n        chomp($str);\n        $str =~ s/[(),]/ /g;\n        $str =~ s/^[ \\t]*//g;\n        $str =~ s/ +/ /g;\n        my ($cmd, $ttype, $cmessage) = split / /, $str, 3;\n        if (! $cmd) { next tc; }\n        if ($cmd eq 'try') {\n            if ($type) {\n                $ltries++;\n            } else {\n                $tries++;\n            }\n        } elsif ($cmd eq 'catch') {\n            if ($ltries) {\n                $ltries--;\n            } else {\n                if ($type) {\n                    if ($type eq $ttype) {\n                        $message = $cmessage;\n                        $message =~ s/ +$//g;\n                        $message =~ s/\"//g;\n                        last tc;\n                    }\n                } else {\n                    $tries--;\n                }\n            }\n        } elsif ($cmd eq 'throw') {\n            $type = $ttype;\n        }\n    }\n    print $message;\n}\n\n__END__\n\n8\ntry\n    try\n        throw ( AE ) \n    catch ( BE, \"BE in line 3\")\n\n    try\n    catch(AE, \"AE in line 5\") \ncatch(AE,\"AE somewhere\")\n"}], "negative_code": [{"source_code": "#!perl\nuse strict;\nuse warnings;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    my ($tries, $ltries, $type, $message) = (0, 0, \"\", 'Unhandled Exception');\ntc: for (1..$n) {\n        my $str = <>;\n        chomp($str);\n        $str =~ s/[(),]/ /g;\n        $str =~ s/^[ \\t]*//g;\n        $str =~ s/ +/ /g;\n        my ($cmd, $ttype, $cmessage) = split / /, $str, 3;\n        if (! $cmd) { next tc; }\n        if ($cmd eq 'try') {\n            if ($type) {\n                $ltries++;\n            } else {\n                $tries++;\n            }\n        } elsif ($cmd eq 'catch') {\n            if ($ltries) {\n                $ltries--;\n            } else {\n                if ($type) {\n                    if ($type eq $ttype) {\n                        $message = $cmessage;\n                        last tc;\n                    }\n                } else {\n                    $tries--;\n                }\n            }\n        } elsif ($cmd eq 'throw') {\n            $type = $ttype;\n        }\n    }\n    print $message;\n}\n\n__END__\n\n"}, {"source_code": "#!perl\nuse strict;\nuse warnings;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    my ($tries, $ltries, $type, $message) = (0, 0, \"\", 'Unhandled Exception');\ntc: for (1..$n) {\n        my $str = <>;\n        chomp($str);\n        $str =~ s/[(),]/ /g;\n        $str =~ s/^[ \\t]*//g;\n        $str =~ s/ +/ /g;\n        my ($cmd, $ttype, $cmessage) = split / /, $str, 3;\n        if (! $cmd) { next tc; }\n        if ($cmd eq 'try') {\n            if ($type) {\n                $ltries++;\n            } else {\n                $tries++;\n            }\n        } elsif ($cmd eq 'catch') {\n            if ($ltries) {\n                $ltries--;\n            } else {\n                if ($type) {\n                    if ($type eq $ttype) {\n                        $message = $cmessage;\n                        $message =~ s/\"//g;\n                        last tc;\n                    }\n                } else {\n                    $tries--;\n                }\n            }\n        } elsif ($cmd eq 'throw') {\n            $type = $ttype;\n        }\n    }\n    print $message;\n}\n\n__END__\n\n"}, {"source_code": "#!/usr/local/bin/perl\n$n              = <>;\n$openBlocks     = 0;\n$needlessBlocks =\n  0;    #это блоки, открытые после эксепшена TODO\n$wasThrow = 0;\n$eType;\nfor ( 1 .. $n ) {\n    my $line = <>;\n\n    if ( $line =~ /\\s*try\\s*/ ) {\n        if ( $wasThrow == 0 ) {\n            $openBlocks++;\n        }\n        else {\n            $needlessBlocks++;\n        }\n        next;\n    }\n    if ( $line =~ /\\s*throw\\s*\\(\\s*(\\w+)\\s*\\)/ ) {\n        $wasThrow = 1;\n        $eType    = $1;\n        maybeError();\n        next;\n    }\n    if ( $line =~ /\\s*catch\\s*\\(\\s*(\\w+)\\s*,\\s*\"(.+)\"\\s*\\)/ ) {\n        if ( $needlessBlocks > 0 ) {\n            $needlessBlocks--;\n            next;\n        }\n        $openBlocks--;\n        if ( $wasThrow != 0 && $eType eq $1 ) {\n            print $2. \"\\n\";\n            exit;\n        }\n        if ($wasThrow != 0){            \n        maybeError();\n        }       \n\n    }\n}\nprint \"Unhandled Exception\\n\";\n\nsub maybeError {\n    if ( $openBlocks == 0 ) {\n        print \"Unhandled Exception\\n\";\n        exit;\n    }\n}\n"}, {"source_code": "#!/usr/local/bin/perl\n$n              = <>;\n$openBlocks     = 0;\n$needlessBlocks =\n  0;    #это блоки, открытые после эксепшена TODO\n$wasThrow = 0;\n$eType;\nfor ( 1 .. $n ) {\n    my $line = <>;\n\n\n    if ( $line =~ /\\s*try\\s*/ ) {\n        if ( $wasThrow == 0 ) {\n            $openBlocks++;\n        }\n        else {\n            $needlessBlocks++;\n        }\n        next;\n    }\n    if ( $line =~ /\\s*throw\\s*\\(\\s*(\\w+)\\s*\\)/ ) {\n        $wasThrow = 1;\n        $eType    = $1;\n        maybeError();\n        next;\n    }\n    if ( $line =~ /\\s*catch\\s*\\(\\s*(\\w+)\\s*,\\s*\"(.+)\"\\s*\\)/ ) {     \n        if ( $needlessBlocks > 0 ) {\n            $needlessBlocks--;\n            next;\n        }\n        $openBlocks--;\n        if ( $wasThrow != 0 && $eType eq $1 ) {\n            print $2. \"\\n\";\n            exit;\n        }\n        $wasThrow != 0 && maybeError();\n        next;\n\n    }\n}\n\nsub maybeError {\n    if ( $openBlocks == 0 ) {\n        print \"Unhandled Exception\\n\";\n        exit;\n    }\n}\n"}], "src_uid": "320e6c06194f8b1ccf1f4218d0757d2f"}
{"source_code": "$_ = <>, chomp;\n\n$o = 'O';\n\n$o =~ s/(o*O?o*)O$/$&\\L$1\\UO/ for 1 .. 14;\n\n\"O$o\" =~ /.{$_}/; \n\nprint $&", "positive_code": [{"source_code": "$_ = <>, chomp;\n\t\n$o = 'O';\n\n$o =~ s/o*O?o*O$/ $& . reverse ucfirst lc $& /e for 1 .. 14;\n\nprint 'O' . substr $o, 0, $_ - 1"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy $n = $_;\n\t$_ = 'o' x 1e3;\n\t\n\ts/o/O/;\n\t\n\tmy $i = 1;\n\tmy $j = 1;\n\t\n\twhile( $j < 1 + length ){\n\t\tsubstr $_, $j - 1, 1, 'O';\n\t\tmy $tmp = $j;\n\t\t$j += $i;\n\t\t$i = $tmp;\n\t\t}\n\t\n\tprint substr $_, 0, $n;\n\t}"}], "negative_code": [], "src_uid": "a7c0484275e62f0bc70d9edaac27d7d6"}
{"source_code": "my $n = <STDIN>;\nmy @a = split(/\\s/, <STDIN>);\nmy $total = 0;\nmap{ $total += $_ } @a;\nprintf(\"%.12f\", $total/$n);", "positive_code": [{"source_code": "while (<>){\n    @_=split/ /,<>;\n    $sum=0;\n    for (@_){\n        $sum+=$_\n        }\n    print $sum/@_;\n    print \"\\n\"\n    }"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "my $m = 100 * int<>;\nmy $sum = 0;\n$sum += $_ for(split / /, <>);\nprint 100 * $sum / $m;"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n$tot+=$_ foreach (split / /, <>);\n$ans = $tot / $n;\nsay $ans;"}, {"source_code": "<>;\nmy $s = 0;\nmy $c = 0;\nfor my $p (split ' ', <>) {\n    $s += $p;\n    $c++;\n}\n\nprint $s / $c, \"\\n\";\n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n"}, {"source_code": "$n=<>;@a=split' ',<>;$s+=$_ for(@a);print$s/$n;"}, {"source_code": "$n=<>;$s+=$_ for(split' ',<>);print$s/$n;"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n"}, {"source_code": "$n=<>;$s+=$_ for(split' ',<>);print$s/$n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "#!perl\nuse strict;\n\nmain();\n\nsub main {\n    my $n = int <>;\n    my @arr = map int, split /\\D/, <>;\n    my $res = 0;\n    for (@arr) {\n        $res += $_;\n    }\n    $res /= $n;\n    print $res;\n}\n\n__END__\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy @percents = split q{ }, read_line;\n\nmy @proportions = map { $_ / 100 } @percents;\n\nmy $sums = sum(@proportions);\n\nsay $sums / $n * 100;\n"}, {"source_code": "$n=<>;\n$s+=$_ for split' ',<>; \nprint$s/$n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}, {"source_code": "$n=<>;$s+=$_ for split' ',<>;print$s/$n\n"}], "negative_code": [], "src_uid": "580596d05a2eaa36d630d71ef1055c43"}
{"source_code": "#!perl\n$\\ = \"\\n\";\n\n$n = <>;\n\n@a = split /\\s/, <>;\n\npush @result, (abs @a[0] - @a[1]).' '.(abs @a[0] - @a[$#a]);\n\nfor my $i (1..$#a - 1)\n{\n    my $minLeft = abs @a[$i] - @a[$i - 1];\n    my $minRight = abs @a[$i] - @a[$i + 1];\n    \n    my $maxLeft = abs @a[$i] - @a[0];\n    my $maxRight = abs @a[$i] - @a[$#a];\n    \n    my $min = $minLeft < $minRight ? $minLeft : $minRight;\n    my $max = $maxLeft > $maxRight ? $maxLeft : $maxRight;\n    \n    push @result, $min.' '.$max;\n}\n\npush @result, (abs @a[$#a - 1] - @a[$#a]).' '.(abs @a[0] - @a[$#a]);\n\nprint join \"\\n\", @result;", "positive_code": [{"source_code": "<>;\n$_ = <>;\n@_ = (-~0, split, ~0);\n\nfor (1 .. @_ - 2){\n\t$L = $_[$_] - $_[$_-1];\n\t$R = $_[$_+1] - $_[$_];\n\t$L < $R and $R = $L;\n\t$Q = $_[$_] - $_[1];\n\t$W = $_[@_ - 2] - $_[$_];\n\t$Q > $W and $W = $Q;\n\tpush @e, \"$R $W\\n\"\n\t}\nprint @e"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nmy %min;\nmy %max;\n\n<>;\nmy @cities = split ' ', <>;\n\nfor my $i (1..$#cities) {\n  my $d = abs($cities[$i - 1] - $cities[$i]);\n  $min{$i - 1} = $d if !exists $min{$i - 1} || $d < $min{$i - 1};\n  $min{$i}     = $d if !exists $min{$i}     || $d < $min{$i};\n}\n\nfor my $i (0..$#cities) {\n  my $left = $cities[$i] - $cities[0];\n  my $right = $cities[-1] - $cities[$i];\n  $max{$i} = $left > $right ? $left\n                            : $right;\n}\n\nfor my $i (0..$#cities) {\n  say \"$min{$i} $max{$i}\"\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n#$, = \" \";\n\nsub min{\n    return $_[0] < $_[1]? $_[0] : $_[1];\n}\nsub max{\n    return $_[0] > $_[1]? $_[0] : $_[1];\n}\n\nmy $n = <>;\nchomp($n);\nmy @arr = split ' ',<>;\nmy @s = sort {$a <=> $b} @arr;\nmy %find;\n@find{@s} = (0..$#s);\nfor my $i(0..@arr-1){\n    my $j = $find{$arr[$i]};\n\n    my $lm =  $j-1>=0? abs($s[$j] - $s[$j-1]) : 2e9;\n    my $rm =  $j+1<$n? abs($s[$j] - $s[$j+1]) : 2e9;\n\n    my $lx = $j==0? 0 : abs($s[$j] - $s[0]);\n    my $rx = $j==$n-1? 0 : abs($s[$j] - $s[$n-1]);\n\n    my $r1 = min($lm, $rm);\n    my $r2 = max($lx, $rx);\n    print \"$r1 $r2\\n\";\n}\n"}, {"source_code": "$, = $/;\n$/ = $\\;\n$_ = <>;\n@_ = split;\nshift @_;\nunshift @_, ($min = shift @_) x 2;\npush    @_, ($max = pop   @_) x 2;\n\nfor $i (1 .. @_ - 2){\n\tpush @e, join ' ',\n\t\t( grep $_, sort {$a <=> $b} map abs $_[$i + $_] - $_[$i],   -1,    1 )[ 0 ],\n\t\t( grep $_, sort {$b <=> $a} map abs $_          - $_[$i], $min, $max )[ 0 ];\n\t}\nprint @e"}, {"source_code": "$, = $/;\n<>;\n$_ = <>;\n@_ = (-9e17, split, 9e17);\n\nfor $i (1 .. @_ - 2){\n\tpush @e, join ' ', ( grep !/e|^0/, sort {$a <=> $b} map abs $_[$i] - $_[$_], $i - 1, $i + 1, 1, @_ - 2 )[0, -1]\n\t}\nprint @e"}], "negative_code": [{"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nmy %min;\nmy %max;\n\n<>;\nmy @cities = split ' ', <>;\n\nfor my $i (1..$#cities) {\n  my $d = abs($cities[$i - 1] - $cities[$i]);\n  $min{$i - 1} = $d if !exists $min{$i - 1} || $d < $min{$i - 1};\n  $min{$i}     = $d if !exists $min{$i}     || $d < $min{$i};\n}\n\nfor my $i (0..$#cities) {\n  my $left = $cities[$i] - $cities[0];\n  my $right = $cities[-1] - $cities[0];\n  $max{$i} = $left > $right ? $left\n                            : $right;\n}\n\nfor my $i (0..$#cities) {\n  say \"$min{$i} $max{$i}\"\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n#$, = \" \";\n\nsub min{\n\treturn $_[0] < $_[1]? $_[0] : $_[1];\n}\nsub max{\n\treturn $_[0] > $_[1]? $_[0] : $_[1];\n}\n\nmy $n = <>;\nchomp($n);\nmy @arr = split ' ',<>;\nmy @s = sort {$a <=> $b} @arr;\nmy %find;\n@find{@s} = (0..$#s);\nfor my $i(0..@arr-1){\n\tmy $j = $find{$arr[$i]};\n\n\tmy $lm =  $j-1>=0? abs($s[$j] - $s[$j-1]) : 1<<27;\n\tmy $rm =  $j+1<$n? abs($s[$j] - $s[$j+1]) : 1<<27;\n\n\tmy $lx = $j==0? 0 : abs($s[$j] - $s[0]);\n\tmy $rx = $j==$n-1? 0 : abs($s[$j] - $s[$n-1]);\n\n\tmy $r1 = min($lm, $rm);\n\tmy $r2 = max($lx, $rx);\n\tprint \"$r1 $r2\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n#$, = \" \";\n\nsub min{\n\treturn $_[0] < $_[1]? $_[0] : $_[1];\n}\nsub max{\n\treturn $_[0] > $_[1]? $_[0] : $_[1];\n}\n\nmy $n = <>;\nchomp($n);\nmy @arr = split ' ',<>;\nmy @s = sort {$a <=> $b} @arr;\nmy %find;\n@find{@s} = (0..$#s);\nfor my $i(0..@arr-1){\n\tmy $j = $find{$arr[$i]};\n\n\tmy $lm =  $j-1>=0? abs($s[$j] - $s[$j-1]) : 1<<60;\n\tmy $rm =  $j+1<$n? abs($s[$j] - $s[$j+1]) : 1<<60;\n\n\tmy $lx = $j==0? 0 : abs($s[$j] - $s[0]);\n\tmy $rx = $j==$n-1? 0 : abs($s[$j] - $s[$n-1]);\n\n\tmy $r1 = min($lm, $rm);\n\tmy $r2 = max($lx, $rx);\n\tprint \"$r1 $r2\\n\";\n}\n"}, {"source_code": "$, = $/;\n<>;\n$_ = <>;\n@_ = (-9e9, split, 9e9);\n\nfor $i (1 .. @_ - 2){\n\tpush @e, join ' ', ( grep !/e|^0/, sort {$a <=> $b} map abs $_[$i] - $_[$_], $i - 1, $i + 1, 1, @_ - 2 )[0, -1]\n\t}\nprint @e"}, {"source_code": "$, = $/;\n<>;\n$_ = <>;\n@_ = (-~0, split, ~0);\n\nfor $i (1 .. @_ - 2){\n\tpush @e, join ' ', ( grep !/e|^0/, sort {$a <=> $b} map abs $_[$i] - $_[$_], $i - 1, $i + 1, 1, @_ - 2 )[0, -1]\n\t}\nprint @e"}], "src_uid": "55383f13c8d097408b0ccf5653c4563d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $A, $B ) = split;\n\t$_ = <>, chomp;\n\t\n\tmy $reverse = reverse;\n\t\n\tfor my $i ( 0 .. -1 + length ){\n\t\tmy $c1 = substr $_, $i, 1;\n\t\tmy $c2 = substr $reverse, $i, 1;\n\t\tif( 0 ){ ; }\n\t\telsif( $c1 eq '?' and $c2 eq '?' ){\n\t\t\t;\n\t\t\t}\n\t\telsif( $c1 eq '?' and $c2 eq '0' ){\n\t\t\tsubstr $_, $i, 1, 0;\n\t\t\t}\n\t\telsif( $c1 eq '0' and $c2 eq '?' ){\n\t\t\tsubstr $reverse, $i, 1, 0;\n\t\t\t}\n\t\telsif( $c1 eq '?' and $c2 eq '1' ){\n\t\t\tsubstr $_, $i, 1, 1;\n\t\t\t}\n\t\telsif( $c1 eq '1' and $c2 eq '?' ){\n\t\t\tsubstr $reverse, $i, 1, 1;\n\t\t\t}\n\t\t}\n\t\n\tif( $_ ne reverse ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy $_0 = () = m/0/g;\n\tmy $_1 = () = m/1/g;\n\t\n\t$A -= $_0;\n\t$B -= $_1;\n\t\n\tif( $A < 0 or $B < 0 ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tmy @change;\n\t\n\tif( ( length ) % 2 == 1 ){\n\t\tif( $A % 2 == 1 ){\n\t\t\t$A --;\n\t\t\tpush @change, 0;\n\t\t\t}\n\t\telsif( $B % 2 == 1 ){\n\t\t\t$B --;\n\t\t\tpush @change, 1;\n\t\t\t}\n\t\t}\n\t\n\tif( $A % 2 == 1 or $B % 2 == 1 ){\n\t\tprint -1;\n\t\tnext;\n\t\t}\n\t\n\tpush @change, ( 0 ) x ( $A / 2 ), ( 1 ) x ( $B / 2 );\n\tunshift @change, ( 1 ) x ( $B / 2 ), ( 0 ) x ( $A / 2 );\n\t\n\ts/\\?/shift @change/ge;\n\t\n\tprint;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  \r\n  my ($a,$b) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $n = $a + $b;\r\n  my $n2 = int($n/2);\r\n  \r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  my @s = split(//,$s);\r\n  $#s = $n-1;\r\n  \r\n  my %cnt = ();  $cnt{'0'} = 0;  $cnt{'1'} = 0;\r\n  \r\n  my $err = undef;\r\n  for(my $i=0;$i<$n2;$i++){\r\n    my $c1 = $s[$i];\r\n    my $c2 = $s[$n-1-$i];\r\n    if( $c1 eq '?' and $c2 ne '?' ){\r\n      $s[$i] = $c2;\r\n      $c1 = $c2;\r\n    }\r\n    if( $c2 eq '?' and $c1 ne '?' ){\r\n      $s[$n-1-$i] = $c1;\r\n      $c2 = $c1;\r\n    }\r\n    if( $c1 ne $c2 ){\r\n      $err = 1; last;\r\n    }\r\n    $cnt{$c1} += 2 if $c1 ne '?';\r\n  }\r\n  if( $err ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  if( $n % 2 == 1 ){\r\n    $cnt{$s[$n2]} ++ if $s[$n2] ne '?';\r\n  }\r\n  \r\n  if( ($cnt{'0'} > $a) or ($cnt{'1'} > $b) ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  my $l_a = $a - $cnt{'0'};\r\n  my $l_b = $b - $cnt{'1'};\r\n  \r\n  if( ( ($n % 2 == 0) or ($n % 2 == 1 and $s[$n2] ne '?' ) ) and ( ( $l_a % 2 == 1 ) or ( $l_b % 2 == 1 ) ) ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  if( $n % 2 == 1 and $s[$n2] eq '?' ){\r\n    if( $l_a % 2 == 1 ){\r\n      $s[$n2] = '0';\r\n      $l_a --;\r\n    }\r\n    if( $l_b % 2 == 1 ){\r\n      $s[$n2] = '1';\r\n      $l_b --;\r\n    }\r\n  }\r\n  if( ( $l_a % 2 == 1 ) or ( $l_b % 2 == 1 ) ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  for(my $i=0;$i<$n2;$i++){\r\n    if( $s[$i] eq '?' ){\r\n      if( $l_a > 0 ){\r\n        $s[$i] = '0';\r\n        $s[$n-1-$i] = '0';\r\n        $l_a -= 2;\r\n      } elsif( $l_b > 0 ){\r\n        $s[$i] = '1';\r\n        $s[$n-1-$i] = '1';\r\n        $l_b -= 2;\r\n      }\r\n    }\r\n  }\r\n  print ( join('',@s) . \"\\n\" );\r\n}\r\n\r\nexit(0);\r\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  \r\n  my ($a,$b) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $n = $a + $b;\r\n  my $n2 = int($n/2);\r\n  \r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  my @s = split(//,$s);\r\n  $#s = $n-1;\r\n  \r\n  my %cnt = ();  $cnt{'0'} = 0;  $cnt{'1'} = 0;\r\n  \r\n  my $err = undef;\r\n  for(my $i=0;$i<$n2;$i++){\r\n    my $c1 = $s[$i];\r\n    my $c2 = $s[$n-1-$i];\r\n    if( $c1 eq '?' and $c2 ne '?' ){\r\n      $s[$i] = $c2;\r\n      $c1 = $c2;\r\n    }\r\n    if( $c2 eq '?' and $c1 ne '?' ){\r\n      $s[$n-1-$i] = $c1;\r\n      $c2 = $c1;\r\n    }\r\n    if( $c1 ne $c2 ){\r\n      $err = 1; last;\r\n    }\r\n    $cnt{$c1} += 2 if $c1 ne '?';\r\n  }\r\n  if( $err ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  if( $n % 2 == 1 ){\r\n    $cnt{$s[$n2]} ++ if $s[$n2] ne '?';\r\n  }\r\n  \r\n  if( ($cnt{'0'} > $a) or ($cnt{'1'} > $b) ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  my $l_a = $a - $cnt{'0'};\r\n  my $l_b = $b - $cnt{'1'};\r\n  \r\n  #if( ($n % 2 == 0) and ( ( $l_a % 2 == 1 ) or ( $l_b % 2 == 1 ) ) ){\r\n  #  print \"-1\\n\"; next;\r\n  #}\r\n  if( $n % 2 == 1 ){\r\n    if( $l_a % 2 == 1 ){\r\n      $s[$n2] = '0';\r\n      $l_a --;\r\n    }\r\n    if( $l_b % 2 == 1 ){\r\n      $s[$n2] = '1';\r\n      $l_b --;\r\n    }\r\n  }\r\n  for(my $i=0;$i<$n2;$i++){\r\n    if( $s[$i] eq '?' ){\r\n      if( $l_a > 0 ){\r\n        $s[$i] = '0';\r\n        $s[$n-1-$i] = '0';\r\n        $l_a -= 2;\r\n      } elsif( $l_b > 0 ){\r\n        $s[$i] = '1';\r\n        $s[$n-1-$i] = '1';\r\n        $l_b -= 2;\r\n      }\r\n    }\r\n  }\r\n  print ( join('',@s) . \"\\n\" );\r\n}\r\n\r\nexit(0);\r\n"}, {"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($a,$b) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  my $n = $a + $b;\r\n  my $n2 = int($n/2);\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  my @s = split(//,$s);\r\n  \r\n  my %cnt = ( '0'=>0, '1'=>0 );\r\n  \r\n  my $err = undef;\r\n  for(my $i=0;$i<$n2;$i++){\r\n    my $c1 = $s[$i];\r\n    my $c2 = $s[$n-1-$i];\r\n    if( $c1 ne '?' and $c2 ne '?' and $c1 ne $c2 ){\r\n      $err = 1; last;\r\n    }\r\n    if( $c1 eq '?' and $c2 ne '?' ){\r\n      $s[$i] = $c2;\r\n      $c1 = $c2;\r\n    }\r\n    if( $c2 eq '?' and $c1 ne '?' ){\r\n      $s[$n-1-$i] = $c1;\r\n      $c2 = $c1;\r\n    }\r\n    $cnt{$c1} ++ if $c1 ne '?';\r\n    $cnt{$c2} ++ if $c2 ne '?';\r\n  }\r\n  if( $err ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  if( $n % 2 == 1 ){\r\n    $cnt{$s[$n2]} ++ if $s[$n2] ne '?';\r\n  }\r\n  if( $cnt{'0'} > $a or $cnt{'1'} > $b ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  my $l_a = $a - $cnt{'0'};\r\n  my $l_b = $b - $cnt{'1'};\r\n  \r\n  if( $n % 2 == 0 and ( ( $l_a % 2 == 1 ) or ( $l_b % 2 == 1 ) ) ){\r\n    print \"-1\\n\"; next;\r\n  }\r\n  if( $n % 2 == 1 ){\r\n    if( $l_a % 2 == 1 ){\r\n      $s[$n2] = '0';\r\n      $l_a --;\r\n    }\r\n    if( $l_b % 2 == 1 ){\r\n      $s[$n2] = '1';\r\n      $l_b --;\r\n    }\r\n  }\r\n  for(my $i=0;$i<$n2;$i++){\r\n    if( $s[$i] eq '?' ){\r\n      if( $l_a > 0 ){\r\n        $s[$i] = '0';\r\n        $s[$n-1-$i] = '0';\r\n        $l_a -= 2;\r\n      } elsif( $l_b > 0 ){\r\n        $s[$i] = '1';\r\n        $s[$n-1-$i] = '1';\r\n        $l_b -= 2;\r\n      }\r\n    }\r\n  }\r\n  $#s = $n-1;\r\n  print ( join('',@s) . \"\\n\" );\r\n}\r\n\r\nexit(0);\r\n"}], "src_uid": "001ac8bce4e44e9266a13eb27760906c"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\tmy $RD = 0;\n\t\n\ts/\n\t\t(.) \n\t\t(?{ $1 eq 'R' ? $RD ++ : $RD -- })\n\t\n\t/\n\t\t$debug and print \"[$1|$RD]\";\n\t\t\n\t\t$1 eq 'R' ? \n\t\t\t( $RD > 0 ? $1 : '' )\n\t\t\t:\n\t\t\t( $RD < 0 ? $1 : '' )\n\t/xge \n\t\twhile /R/ and /D/;\n\t\n\tprint /R/ ? 'R' : 'D';\n\t\n\t}", "positive_code": [{"source_code": "\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\n\nmy @RINDEX;\nmy @DINDEX;\n\nfor(my $i=0;$i<length($s);$i++)\n{\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\tpush(@RINDEX,$i)\n\t}\n\tif(substr($s,$i,1) eq \"D\")\n\t{\n\tpush(@DINDEX,$i)\n\t}\n}\nmy $j=0;\nwhile(scalar(@RINDEX) and scalar(@DINDEX)){\n\n\tif($RINDEX[0]==$j)\n\t   {\n\t   \t\tshift @DINDEX;\n\t   \t\tpush(@RINDEX,shift @RINDEX);\n\t\t}elsif($DINDEX[0]==$j){\n\t   \t\tshift @RINDEX;\n\t   \t\tpush(@DINDEX,shift @DINDEX);\n\t\t}\n$j++;\nif($j>=length($s)){\n\t$j=0;\n}\n}\n\n\nif(scalar(@RINDEX)){\n\tprint \"R \\n\";\n}\nif(scalar(@DINDEX)){\n\tprint \"D \\n\";\n}\n"}, {"source_code": "<>;\n\n$_ = <>;\n\ns/./ $J = $& cmp 'J', $& x ( 0 < ($RD += $J ) * $J ) /ge \n\twhile /R/ and /D/;\n\n/./, print $&"}, {"source_code": "use strict;\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\nmy $i=0;\nmy @RINDEX;\nmy @DINDEX;\n\nfor(my $i=0;$i<length($s);$i++)\n{\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\tpush(@RINDEX,$i)\n\t}\n\tif(substr($s,$i,1) eq \"D\")\n\t{\n\tpush(@DINDEX,$i)\n\t}\n}\nmy $j=0;\nwhile(scalar(@RINDEX)>0 and scalar(@DINDEX)>0 ){\n\n\tif($RINDEX[0]==$j)\n\t   {\n\t   \t\tshift @DINDEX;\n\t   \t\tpush(@RINDEX,shift @RINDEX);\n\t\t}elsif($DINDEX[0]==$j){\n\t   \t\tshift @RINDEX;\n\t   \t\tpush(@DINDEX,shift @DINDEX);\n\t\t}\n$j++;\nif($j>=length($s)){\n\t$j=0;\n}\n}\n\n\nif(scalar(@RINDEX)>0){\n\tprint \"R \\n\";\n}\nif(scalar(@DINDEX)>0){\n\tprint \"D \\n\";\n}\n\n\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\nmy $i=0;\n\nwhile(index($s,\"D\") >=0 and index($s,\"R\") >=0)\n{\n\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\t\tmy $ind=index($s,\"D\");\n\t\tsubstr($s,$ind,1,\"0\");\n\t}\n\telsif(substr($s,$i,1) eq \"D\")\n\t{\n\t\tmy $ind=index($s,\"R\");\n\t\tsubstr($s,$ind,1,\"0\");\n\t}\n\t$i++;\n\t$s =~ s/0//g;\n\tif($i>=length($s)){\n\t\t$i=0;\n\t}\n\n}\n\n\nif(index($s,\"D\")>=0){\n\tprint \"D\\n\";\n}\nif(index($s,\"R\")>=0){\n\tprint \"R\\n\";\n}\n\n"}, {"source_code": "use strict;\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\nmy $i=0;\nmy @RINDEX;\nmy @DINDEX;\nmy $j=0;\nmy $k=0;\nfor(my $i=0;$i<length($s);$i++)\n{\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\t$RINDEX[$j++]=$i;\n\t}\n\tif(substr($s,$i,1) eq \"D\")\n\t{\n\t$DINDEX[$k++]=$i;\n\t}\n}\n\n$i=0;\n$j=0;\n$k=0;\nwhile(scalar(@RINDEX)>0 and scalar(@DINDEX)>0 ){\nif($RINDEX[$i] == $j ){\n\tshift @DINDEX;\n\tif($k>0){\n\t\t$k--;\n\t}\n    $i++;\n}elsif( $DINDEX[$k] == $j){\n\tshift @RINDEX;\n\tif($i>0){\n\t\t$i--;\n\t}\n\t$k++;\n}\n$j++;\nif($j>=length($s)){\n$i=0;\n$j=0;\n$k=0;\n}\n}\n\nif(scalar(@RINDEX)>0){\n\tprint \"R \\n\";\n}\nif(scalar(@DINDEX)>0){\n\tprint \"D \\n\";\n}\n\n\n"}, {"source_code": "use strict;\nuse warnings;\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\nmy $i=0;\nmy @RINDEX;\nmy @DINDEX;\nmy $j=0;\nmy $k=0;\nfor(my $i=0;$i<length($s);$i++)\n{\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\t$RINDEX[$j++]=$i;\n\t}\n\tif(substr($s,$i,1) eq \"D\")\n\t{\n\t$DINDEX[$k++]=$i;\n\t}\n}\n\n$i=0;\nwhile(scalar(@RINDEX)>0 and scalar(@DINDEX)>0){\nif($RINDEX[$i] > $DINDEX[$i]){\n\tshift @DINDEX;\n}else{\n\tshift @RINDEX;\n}\n}\n\nif(scalar(@RINDEX)>0){\n\tprint \"R \\n\";\n}\nif(scalar(@DINDEX)>0){\n\tprint \"D \\n\";\n}\n\n\n"}, {"source_code": "use strict;\nuse warnings;\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\nmy $i=0;\nmy @RINDEX;\nmy @DINDEX;\nmy $j=0;\nmy $k=0;\nfor(my $i=0;$i<length($s);$i++)\n{\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\t$RINDEX[$j++]=$i;\n\t}\n\tif(substr($s,$i,1) eq \"D\")\n\t{\n\t$DINDEX[$k++]=$i;\n\t}\n}\n\n$i=0;\nwhile(scalar(@RINDEX)>0 and scalar(@DINDEX)>0){\nif($RINDEX[$i] < $DINDEX[$i]){\n\tshift @DINDEX;\n}elsif($RINDEX[$i] > $DINDEX[$i]){\n\tshift @RINDEX;\n}\n}\n\nif(scalar(@RINDEX)>0){\n\tprint \"R \\n\";\n}\nif(scalar(@DINDEX)>0){\n\tprint \"D \\n\";\n}\n\n\n"}, {"source_code": "use strict;\nuse warnings;\nmy $n=<>;\nchomp($n);\nmy $s=<>;\nchomp($s);\n\nmy $i=0;\nmy @RINDEX;\nmy @DINDEX;\nmy $j=0;\nmy $k=0;\nfor(my $i=0;$i<length($s);$i++)\n{\n\tif(substr($s,$i,1) eq \"R\")\n\t{\n\t$RINDEX[$j++]=$i;\n\t}\n\tif(substr($s,$i,1) eq \"D\")\n\t{\n\t$DINDEX[$k++]=$i;\n\t}\n}\n\n$i=0;\nwhile(scalar(@RINDEX)>0 and scalar(@DINDEX)>0){\nprint \"@RINDEX \\n\";\nprint \"@DINDEX \\n\";\nif($RINDEX[$i] < $DINDEX[$i]){\n\tshift @DINDEX;\n}elsif($RINDEX[$i] > $DINDEX[$i]){\n\tshift @RINDEX;\n}\n}\n\nif(scalar(@RINDEX)>0){\n\tprint \"R \\n\";\n}\nif(scalar(@DINDEX)>0){\n\tprint \"D \\n\";\n}\n\n\n"}], "src_uid": "cc50eef15726d429cfc2e76f0aa8cd19"}
{"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\n\nsub isPrime{\n        my $num = shift;\n        my $count = 0;\n        for(my $i = 1 ; $i <= int(sqrt($num)) ; $i++){\n                if($num % $i == 0){\n                        $count++;\n                }\n        }\n        if($count > 1){\n                return 0;\n        }else{\n                return 1;\n        }\n}\n\nfor(my $j = 2 ;;$j++){\n        my $p = $n - $j;\n        if(!isPrime($p) && !isPrime($j)){\n                print \"$j $p\";\n                last;\n        }\n}\n", "positive_code": [{"source_code": "my $a = <>;\nforeach (map { $_ * 3 } 2 .. int $a / 3)\n{\n    if (($a - $_) % 2 == 0)\n    {\n        print $_, \" \", $a-$_;\n        last;\n    }\n}"}, {"source_code": "my $n = int(<>);\nif ($n % 2) {\n    print \"9 \" . ($n - 9) . \"\\n\";\n}\nelse {\n    print \"4 \" . ($n - 4) . \"\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nmy $n = <>;\n\nsub isPrime($) {\n\tmy $arg = $_[0];\n\tmy $res = 1;\n\tfor (my $i = 2; $i <= sqrt($arg); $i++) {\n\t\tunless ($arg % $i) {\n\t\t\t$res = 0;\n\t\t}\n\t}\n\t\n\treturn $res;\n}\n\nfor (my $i = 4; $i <= ($n / 2); $i++) {\n\tif (!isPrime($i) && !isPrime($n - $i)) {\n\t\tprint($i . \" \" . ($n - $i));\n\t\texit;\n\t}\n}\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp($n = <>);\n$n%2==0 and say 4,' ',$n-4 or say 9,' ',$n-9;"}, {"source_code": "chomp (my $n = <>);\nif ($n & 1) {\n  printf \"%d %d\\n\", 9, $n - 9;\n} else {\n  printf \"%d %d\\n\", 4, $n - 4;\n}"}, {"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nsub primeq {\n    my $n = shift;\n    return '' if $n < 2;\n    for (2 .. sqrt($n) + 1) {\n        return '' if $n % $_ == 0;\n    }\n    return 1;\n}\n\nmy $n = <>;\nfor (4 .. $n / 2) {\n    if (!primeq($_) && !primeq($n - $_)) {\n        print \"$_ \", $n - $_, \"\\n\";\n        last;\n    }\n}\n"}, {"source_code": "chomp($n = <>);\nprint($n & 1 ? \"9 \".($n-9).\"\\n\" : \"4 \".($n-4).\"\\n\");\n"}, {"source_code": "while(<>){\n\t\n\t$_-=12;\n\tfor $i(4,6,8..10){\n\t\t$a=$i;\n\t\t$b=$_+12-$i;\n\t\tif (($a=~/[024685]$/ or !($a %3))\n\t\t\t\tand $b!=2\n\t\t\t\tand $b!=5\n\t\t\t\tand $b!=3\n\t\t\t\tand $b!=7\n\t\t\t\tand \n\t\t\t($b=~/[024685]$/ or !($b %3))){\n\t\t\t\n\t\t\tprint \"$a $b\\n\";\n\t\t\tlast\n\t\t\t}\n\t\t}\n\t}"}], "negative_code": [{"source_code": "my $n = int(<>);\nif ($n % 2) {\n    print \"7 \" . $n - 7 . \"\\n\";\n}\nelse {\n    print \"4 \" . $n - 4 . \"\\n\";\n}\n"}, {"source_code": "my $n = int(<>);\nif ($n % 2) {\n    print \"7 \" . ($n - 7) . \"\\n\";\n}\nelse {\n    print \"4 \" . ($n - 4) . \"\\n\";\n}"}, {"source_code": "while(<>){\n\t\n\t$_-=12;\n\tfor $i(4,6,8..10){\n\t\t$a=$i;\n\t\t$b=$_+12-$i;\n\t\tif ($a=~/[024685]$/\n\t\t\t\tand $b!=2\n\t\t\t\tand $b!=5\n\t\t\t\tand \n\t\t\t$b=~/[024685]$/){\n\t\t\t\n\t\t\tprint \"$a $b\\n\";\n\t\t\tlast\n\t\t\t}\n\t\t}\n\t}"}, {"source_code": "$_-=<>-12;\nfor $i(1..11){\n\t$a=(12-$i);\n\t$b=$_+$i;\n\tif ($a=~/[024685]$/\n\t\t\tand \n\t\t$b=~/[024685]$/){\n\t\t\t\n\t\tprint \"$a $b\";\n\t\tlast\n\t\t}\n\t}"}], "src_uid": "3ea971165088fae130d866180c6c868b"}
{"source_code": "<>;\n\nprint <> =~ s/\\n//r eq (join ' ', map y/yaeiou//d, <>) ? \"YES\" : \"NO\"", "positive_code": [{"source_code": "\nmy $n = <> + 0;\nmy $P = <>;\nmy @pp = split ' ', $P;\n\nfor (my $i = 0; $i < $n; ++$i) {\n\tmy $line = <>;\n\tmy @lets = split //, $line;\n\tforeach (@lets) {\n\t\t--$pp[$i] if /a|e|i|o|u|y/;\n\t}\n\tif ($pp[$i] != 0){\n\t\tprint \"NO\\n\";\n\t\texit 0;\n\t}\n}\nprint \"YES\\n\";\n\n"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t$f = 0;\n\twhile(<>){\n\t\t(shift @_) == ( () = /[aeiouy]/g ) or $f++\n\t\t\n\t\t}\n\t\n\tprint $f ? \"NO\" : \"YES\"\n\t}"}, {"source_code": "<>;\n\n@_ = split ' ', <>;\n\nwhile(<>){\n\t(shift @_) == ( () = /[aeiouy]/g ) or $f++\n\t\t\n\t}\n\t\nprint $f ? \"NO\" : \"YES\""}, {"source_code": "<>;\n\n@_ = split ' ', <>;\n\ny/yaeiou//d == shift @_ or $f++ while <>;\n\t\nprint $f ? \"NO\" : \"YES\""}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n = <>;\nmy @arr = split \" \", <>;\n# print \"@arr\";\nmy $ans = \"YES\";\nfor (0..$n-1) {\n  my $count = 0;\n  chomp(my $line = <>);\n  $count = () = $line =~ /[aeiouy]/g;\n  if ($count != $arr[$_]) {\n    $ans = \"NO\";\n    last;\n  }\n}\nprint \"$ans\\n\";\n"}, {"source_code": "$n = int(<STDIN>);\n@k = split(/ /, <STDIN>);\nmy $i = 0;\nwhile(<STDIN>) {\n    if(($_ =~ tr/[aeiouy]//) != $k[$i]) {\n        print \"NO\\n\";\n        exit 0;\n    }\n    $i++;\n}\nprint \"YES\\n\";"}, {"source_code": "$,=\" \";\nmy %v=map {$_=> 1} ('a','e','i','o','u','y');\nmy $N=<>;\nchomp($N);\nmy @counts=split / /,<>;\nchomp(@counts);\nfor my $i (1..$N)\n{\n  my $s=<>;\n  chomp($s);\n  my $k=0;\n  map {$k+=$v{$_}} split //,$s;\n  if($k!=$counts[$i-1])\n  {\n    print \"NO\\n\";\n    exit(0);\n  }\n}\nprint \"YES\\n\";\n"}], "negative_code": [], "src_uid": "cf595689b5cbda4f1d629524ad275650"}
{"source_code": "($n, $m) = split \" \", <>;\nprint 4 x $n, \"5\\n\";\nprint 5 x $n, \"5\\n\";", "positive_code": [{"source_code": "print+(\"4\"x998).\"5\\n\".(\"5\"x999)"}], "negative_code": [], "src_uid": "bba30bd91f085471f624c0f723b78a82"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t@_ = map ~~<>, 1 .. $_;\r\n\t\r\n\tprint 2 * eval join '+', f( 0, @_ ), f( 1, @_ );\r\n\t}\r\n\r\nsub f {\r\n\tmy( $i ) = shift @_;\r\n\t\r\n\tmap abs, ( sort { $a <=> $b } 0, map { ( split )[ $i ] } @_ )[ 0, ~~ @_ ];\r\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy @x;\n\tmy @y;\n\tmap { my( $x, $y ) = split ' ', <>; push @x, $x; push @y, $y; } 1 .. $_;\n\t\n\t@x = sort { $a <=> $b } @x, 0;\n\t@y = sort { $a <=> $b } @y, 0;\n\t\n\tmy $sum = 0;\n\t\n\tmap $sum += abs, @x[ 0, @x - 1 ], @y[ 0, @y - 1 ];\n\t\n\tprint $sum * 2;\n\t}"}], "negative_code": [], "src_uid": "4af206ae108a483bdb643dc24e4bedba"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tmy @n = map ~~<>, 1 .. $n;\n\tchomp @n;\n\tmy %n = map { $_, undef } @n;\n\n\tmy @m = map ~~<>, 1 .. $m;\n\tchomp @m;\n\tmy %m = map { $_, undef } @m;\n\t\n\tmy $i = 0;\n\t\n\tfor (@m){\n\t\texists $n{$_} or next;\n\t\t$i ++;\n\t\tif( $i % 2 ){\n\t\t\tdelete $m{$_}\n\t\t\t}\n\t\telse {\n\t\t\tdelete $n{$_}\n\t\t\t}\n\t\t}\n\t\n\tprint qw(NO YES)[ (~~ keys %n) > (~~ keys %m) ];\n\t}", "positive_code": [{"source_code": "( $n, $m ) = split ' ', <>;\n$S += $h{$_} ++ for <>;\nprint qw(NO YES)[ $n + $S % 2 > $m ]"}, {"source_code": "( $n, $m ) = split ' ', <>;\n\t\n$S += $h{$_} ++ for <>;\n\t\nprint qw(NO YES)[ $n + $S % 2 > $m ]"}], "negative_code": [], "src_uid": "4b352854008a9378551db60b76d33cfa"}
{"source_code": "$_=lc<>.<>.<>;\ns/[^a-z\\n]//gm;\n@s = split/\\n/;\npush @t, $s[0].$s[1].$s[2], $s[0].$s[2].$s[1], $s[1].$s[0].$s[2], \n$s[1].$s[2].$s[0], $s[2].$s[1].$s[0], $s[2].$s[0].$s[1];\n<>;\n@_=<>;\nfor (@_){\n\t$_=lc;\n\ts/[^a-z]//ig;\n\t}\nfor (@_){\n\t$F=0;\n\tfor $i(@t){\n\t\t$i eq $_ and $F++;\n\t\t}\n\t# /[^-\\n]/ and $F++;\n\tprint !$F?\"WA\\n\":\"ACC\\n\";\n\t}", "positive_code": [{"source_code": "$a=<>;\n$b=<>;\n$c=<>;\nchomp($a,$b,$c);\n$a=~s/[_;-]//g;\n$b=~s/[_;-]//g;\n$c=~s/[_;-]//g;\n<>;\nwhile(<>){\n  s/[_;-]//g;\n  printf \"%s\\n\", /$a$b$c|$a$c$b|$b$a$c|$b$c$a|$c$a$b|$c$b$a/i?\"ACC\":\"WA\";\n}\n"}], "negative_code": [{"source_code": "$_=lc<>.<>.<>;\ns/[^a-z\\n]//gm;\n@s = split/\\n/;\n<>;\n@_=<>;\nfor (@_){\n\t$_=lc;\n\ts/[^a-z\\n]//ig;\n\t}\nfor (@_){\n\t$F=0;\n\tfor $i(@s){\n\t\ts/$i/-/ or $F++;\n\t\t}\n\t/[^-\\n]/ and $F++;\n\tprint $F?\"WA\\n\":\"ACC\\n\";\n\t}"}], "src_uid": "95ccc87fe9e431f9c6eeffeaf049f797"}
{"source_code": "use warnings;\n\nsub max {\n\tif($_[0] >= $_[1]) {\n\t\treturn $_[0];\n\t}\n\treturn $_[1];\n}\n\nmy $NMAX = 100005;\nmy @fr = (0) x 100005;\nmy $n = int (<>);\nforeach my $it (split(' ',<>)) {\n\t++$fr[$it];\n}\n\nmy $ans = 1;\nfor(my $i=2; $i<=$NMAX; ++$i) {\n\tmy $aux=0;\n\t\n\tfor(my $j=$i; $j<$NMAX; $j+=$i) {\n\t\t$aux+=$fr[$j];\n\t}\n\t\n\t$ans=max($ans,$aux);\n}\n\nprintf(\"%d\", $ans);\n", "positive_code": [{"source_code": "my $poke_nr = <>;\nmy %pokemons;\nmy @numbers = split(\" \", <>);\nmy $biggest_poke = 0;\nmy $max_poke = 0;\nmy $current_max = 0;\nforeach(@numbers)\n{\n\tif(exists($pokemons{$_}))\n\t{\n\t\t$pokemons{$_} = $pokemons{$_} + 1;\n\t}\n\telse\n\t{\n\t\t$pokemons{$_} = 1;\n\t\tif($_ > $biggest_poke)\n\t\t{\n\t\t\t$biggest_poke = $_;\n\t\t}\n\t}\n}\nforeach my $i(2 .. $biggest_poke)\n{\n\t$current_max = 0;\n\tfor(my $j = $i; $j <= $biggest_poke; $j += $i)\n\t{\n\t\tif(exists($pokemons{$j}))\n\t\t{\n\t\t\t$current_max += $pokemons{$j};\n\t\t}\n\t}\n\tif($current_max > $max_poke)\n\t{\n\t\t$max_poke = $current_max;\n\t}\n}\nif($max_poke > 0)\n{\n\tprint $max_poke;\n}\nelse\n{\n\tif(exists($pokemons{1}))\n\t{\n\t\tprint 1;\n\t}\n\telse\n\t{\n\t\tprint 0;\n\t}\n\n}\n"}, {"source_code": "use v5.20;\nuse warnings;\n\nsub max {\n\treturn $_[0] > $_[1] ? $_[0] : $_[1];\n}\n\nmy @fr = (0) x 100001;\nmy @prime = (1) x 100001;\n\nmy $n = int (<>);\nforeach my $it (split(' ',<>)) {\n\t$fr[$it] += 1;\n}\n\nmy $sol = 1;\n\nfor my $i (2..100000) {\n\tif ($prime[$i]) {\n\t\tmy $curr = $fr[$i];\n\t\tfor (my $j = $i * 2; $j <= 100000; $j += $i) {\n\t\t\t$prime[$j] = 0;\n\t\t\t$curr += $fr[$j];\n\t\t}\n\t\t$sol = max($sol,$curr);\n\t}\n}\n\nsay $sol;\n\n"}], "negative_code": [{"source_code": "use warnings;\n\nsub max {\n\tif($_[0] >= $_[1]) {\n\t\treturn $_[0];\n\t}\n\treturn $_[1];\n}\n\nmy $NMAX = 100005;\nmy @fr = (0) x 100005;\nmy $n = int (<>);\nforeach my $it (split(' ',<>)) {\n\t++$fr[$it];\n}\n\nmy $ans = 0;\nfor(my $i=2; $i<=$NMAX; ++$i) {\n\tmy $aux=0;\n\t\n\tfor(my $j=$i; $j<$NMAX; $j+=$i) {\n\t\t$aux+=$fr[$j];\n\t}\n\t\n\t$ans=max($ans,$aux);\n}\n\nprintf(\"%d\", $ans);\n"}, {"source_code": "my $poke_nr = <>;\nmy %pokemons;\nmy @numbers = split(\" \", <>);\nmy $biggest_poke = 0;\nmy $max_poke = 0;\nmy $current_max = 0;\nforeach(@numbers)\n{\n\tif(exists($pokemons{$_}))\n\t{\n\t\t$pokemons{$_} = $pokemons{$_} + 1;\n\t}\n\telse\n\t{\n\t\t$pokemons{$_} = 1;\n\t\tif($_ > $biggest_poke)\n\t\t{\n\t\t\t$biggest_poke = $_;\n\t\t}\n\t}\n}\nforeach my $i(1 .. $biggest_poke)\n{\n\t$current_max = 0;\n\tfor(my $j = $i; $j <= $biggest_poke; $j += $i)\n\t{\n\t\tif(exists($pokemons{$j}))\n\t\t{\n\t\t\t$current_max += $pokemons{$j};\n\t\t}\n\t}\n\tif($current_max > $max_poke)\n\t{\n\t\t$max_poke = $current_max;\n\t}\n}\nprint $max_poke;\n"}, {"source_code": "my $poke_nr = <>;\nmy %pokemons;\nmy @numbers = split(\" \", <>);\nmy $biggest_poke = 0;\nmy $max_poke = 0;\nmy $current_max = 0;\nforeach(@numbers)\n{\n\tif(exists($pokemons{$_}))\n\t{\n\t\t$pokemons{$_} = $pokemons{$_} + 1;\n\t}\n\telse\n\t{\n\t\t$pokemons{$_} = 1;\n\t\tif($_ > $biggest_poke)\n\t\t{\n\t\t\t$biggest_poke = $_;\n\t\t}\n\t}\n}\nforeach my $i(2 .. $biggest_poke)\n{\n\t$current_max = 0;\n\tfor(my $j = $i; $j <= $biggest_poke; $j += $i)\n\t{\n\t\tif(exists($pokemons{$j}))\n\t\t{\n\t\t\t$current_max += $pokemons{$j};\n\t\t}\n\t}\n\tif($current_max > $max_poke)\n\t{\n\t\t$max_poke = $current_max;\n\t}\n}\nprint $max_poke;\n"}], "src_uid": "eea7860e6bbbe5f399b9123ebd663e3e"}
{"source_code": "<>;\n$_=<>;\ns/\\s//g;\nwhile(/1/g){push @a, pos}\nwhile(/2/g){push @b, pos}\nwhile(/3/g){push @c, pos}\n$min = (sort {$a <=> $b} (0+@a, 0+@b, 0+@c) )[0];\nprint $min, $/;\nwhile($min--){\n\tprintf \"%d %d %d\\n\", shift @a, shift @b, shift @c\n\t}", "positive_code": [{"source_code": "my $n = <>;\nmy @arr = ([],[],[],[]);\nmy @inp = split \" \", <>;\nfor (0..$#inp) {\n    push @{$arr[$inp[$_]]}, $_+1;\n}\nmy $ans = (sort{$a <=>$b}(scalar @{$arr[1]}, scalar @{$arr[2]}, scalar @{$arr[3]}))[0];\nprint $ans . \"\\n\";\n\nfor (0..$ans-1) {\n    print \"@{$arr[1]}[$_] @{$arr[2]}[$_] @{$arr[3]}[$_]\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub min {\n\tmy ($x, $y) = (shift, shift);\n\treturn $x<$y ? $x:$y;\n}\n\nchomp($n = <>);\nour @N = (0) x 4;\nour @arr = ((1..$n)) x 4;\nour $id = 1;\nforeach my $i (split / /, <>) {\n\tpush @{$arr[$i]}, $id;\n\t++$N[$i];\n\t++$id;\n\t\n\t# say $i, \" \", $N[$i];\n\t# foreach my $j (0..$N[$i]-1) {\n\t\t# print $arr[$i]->[$j],\" \";\n\t# }\n\t# say \"\\n\";\n\t\n}\n$ans = min(min($N[1], $N[2]), $N[3]);\nsay $ans;\nforeach (0..$ans-1) {\n\tsay $arr[1][$_],\" \", $arr[2][$_],\" \", $arr[3][$_];\n}"}, {"source_code": "use strict;\nuse warnings;\n\n<>;\nmy @kids = split ' ', <>;\nmy @teams;\nmy %kinds;\n\nfor my $i (0..$#kids) {\n    push @{$kinds{$kids[$i]}}, $i + 1;\n}\n\nOUTER: for (;;) {\n    my @line;\n    for (1..3) {\n        my $m = shift @{$kinds{$_}};\n        last OUTER unless defined $m;\n        push @line, $m;\n    }\n    push @teams, \\@line;\n}\n\n$\\ = \"\\n\";\n$, = ' ';\n\nprint scalar @teams;\nprint @$_ for @teams;\n"}, {"source_code": "#!/usr/bin/perl\n#use warnings;\n#use strict;\n\n<>;\nmy @students = split(' ', <>);\nmy @pro; my @ma; my @pre;\nmy $idx;\nfor my $el(@students){\n\t++$idx;\n\tif($el == 1){push (@pro, $idx);}\n\telsif($el == 2){push (@ma, $idx);}\n\telse{push (@pre, $idx);}\n}\n\n$idx = $#pro;\tif($#ma < $idx){$idx = $#ma;} if($#pre < $idx){$idx = $#pre;} $idx ++;\nprint \"$idx\\n\";\nwhile($#pro >= 0 && $#ma >= 0 && $#pre >= 0){\n\tprint ((pop @pro), \" \", (pop @ma), \" \", (pop @pre), \"\\n\");\n}"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nsub min{\n    return (sort {$a <=> $b} @_)[0];\n}\nsub len{\n    return scalar @{$_[0]};\n}\n\nmy $n = <>;\nmy @list = split ' ',<>;\nmy @arr;\npush @arr,[] for 0..3;\nfor my $i(0..$n-1){\n    my $val = $list[$i];\n    push @{$arr[$val]}, $i+1;\n}\nmy $min = min(len($arr[1]), len($arr[2]), len($arr[3]));\nprint $min, \"\\n\";\nfor my $i(0..$min-1){\n    print \"$arr[1][$i] $arr[2][$i] $arr[3][$i]\\n\";\n}\n"}], "negative_code": [{"source_code": "my $n = <>;\nmy @arr;\nmy @inp = split \" \", <>;\nfor (0..$#inp) {\n    push @{$arr[$inp[$_]]}, $_+1;\n}\nmy $ans = (sort{$a <=>$b}(scalar @{$arr[1]}, scalar @{$arr[2]}, scalar @{$arr[3]}))[0];\nprint $ans . \"\\n\";\n\nfor (0..$ans-1) {\n    print \"@{$arr[1]}[$_] @{$arr[2]}[$_] @{$arr[3]}[$_]\\n\";\n}"}, {"source_code": "#!/usr/bin/perl\n#use warnings;\n#use strict;\n\n<>;\nmy @students = split(' ', <>);\nmy @pro; my @ma; my @pre;\nmy $idx;\nfor my $el(@students){\n\t++$idx;\n\tif($el == 1){push (@pro, $idx);}\n\telsif($el == 2){push (@ma, $idx);}\n\telse{push (@pre, $idx);}\n}\n\nwhile($#pro >= 0 && $#ma >= 0 && $#pre >= 0){\n\tprint ((pop @pro), \" \", (pop @ma), \" \", (pop @pre), \"\\n\");\n}\n\n\t\n"}, {"source_code": "#!/usr/bin/perl\n#use warnings;\n#use strict;\n\n<>;\nmy @students = split(' ', <>);\nmy @pro; my @ma; my @pre;\nmy $idx;\nfor my $el(@students){\n\t++$idx;\n\tif($el == 1){push (@pro, $idx);}\n\telsif($el == 2){push (@ma, $idx);}\n\telse{push (@pre, $idx);}\n}\n$idx = scalar @pro; $idx < scalar @ma ? $idx : $idx = scalar @ma;  $idx < scalar @pre ? $idx : $idx = scalar @pre;\nprint \"$idx\\n\";\nwhile($#pro >= 0 && $#ma >= 0 && $#pre >= 0){\n\tprint ((pop @pro), \" \", (pop @ma), \" \", (pop @pre), \"\\n\");\n}"}, {"source_code": "#!/usr/bin/perl\n#use warnings;\n#use strict;\n\n<>;\nmy @students = split(' ', <>);\nmy @pro; my @ma; my @pre;\nmy $idx;\nfor my $el(@students){\n\t++$idx;\n\tif($el == 1){push (@pro, $idx);}\n\telsif($el == 2){push (@ma, $idx);}\n\telse{push (@pre, $idx);}\n}\n$idx = $#pro; $idx < $#ma ? $idx : $idx = $#ma;  $idx < $#pre ? $idx : $idx = $#pre; $idx++;\nprint \"$idx\\n\";\nwhile($#pro >= 0 && $#ma >= 0 && $#pre >= 0){\n\tprint ((pop @pro), \" \", (pop @ma), \" \", (pop @pre), \"\\n\");\n}"}], "src_uid": "c014861f27edf35990cc065399697b10"}
{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $d, $h) = split;\n\t@A = ();\n\t\n\tif ($h == 1) {\n\t\tif ($n == 2){\n\t\t\tprint '1 2'; next\n\t\t\t}\n\t\telsif ($n > 2){\n\t\t\tif ($d != 2){\n\t\t\t\tprint -1; next\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tprint join \"\\n\", map { 1 . ' ' . ($_ + 1) } 1 .. $n - 1;\n\t\t\t\tnext\n\t\t\t\t}\n\t\t\t} \n\t\t}\n\t\t\n\t$i = 1;\n\tfor (1 .. $h){\n\t\tpush @A, $i . ' ' . ($i + 1);\n\t\t$i++\n\t\t}\n\tif ($d > $h){\n\t\tpush @A, 1 . ' ' . ++$i;\n\t\t}\n\tfor (1 .. $d - $h - 1){\n\t\tpush @A, $i . ' ' . ($i + 1);\n\t\t$i++\n\t\t}\n\tfor (1 .. $n - $d - 1){\n\t\tpush @A, 2 . ' ' . ++$i\n\t\t}\n\t\n\tprint $d > $h * 2 ? -1 : join \"\\n\", @A\n\t}", "positive_code": [{"source_code": "while(<>){\n\t($n, $d, $h) = split;\n\n\tprint $d > $h * 2 ? -1 : $h == 1 ?\n\t\tdo {\n\t\t\t$n == 2 ? '1 2' :\n\t\t\t\t$d != 2 ? -1 :\n\t\t\t\t\tjoin \"\\n\", map \"1 $_\", 2 .. $n;\n\t\t\t}\n\t\t:\n\t\tdo {\n\t\t\t$i = 1;\n\t\t\tjoin \"\\n\", grep / /,\n\t\t\t\t( map { \"$i \" . ++ $i } 1 .. $h ),\n\t\t\t\t( $d > $h ?  \"1 \" . ++ $i : \"\" ),\n\t\t\t\t( map { \"$i \" . ++ $i } 1 .. $d - $h - 1 ),\n\t\t\t\t( map { \"2 \"  . ++ $i } 1 .. $n - $d - 1 );\n\t\t\t}\n\t}"}], "negative_code": [{"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $d, $h) = split;\n\t@A = ();\n\t\n\t$i = 1;\n\tfor (1 .. $h){\n\t\tpush @A, $i . ' ' . ($i + 1);\n\t\t$i++\n\t\t}\n\tif ($d > $h){\n\t\tpush @A, 1 . ' ' . ++$i;\n\t\t}\n\tfor (1 .. $d - $h - 1){\n\t\tpush @A, $i . ' ' . ($i + 1);\n\t\t$i++\n\t\t}\n\tfor (1 .. $n - $d - 1){\n\t\tpush @A, 1 . ' ' . ++$i\n\t\t}\n\t\n\tprint $d > $h * 2 ? -1 : join \"\\n\", @A\n\t}"}, {"source_code": "$\\ = $/;\n\nwhile(<>){\n\t($n, $d, $h) = split;\n\t@A = ();\n\t\n\tif ($h == 1) {\n\t\tif ($n == 2){\n\t\t\tprint '1 2'; next\n\t\t\t}\n\t\telsif ($n > 2){\n\t\t\tif ($d != 2){\n\t\t\t\tprint -1; next\n\t\t\t\t}\n\t\t\t} \n\t\t}\n\t\t\n\t$i = 1;\n\tfor (1 .. $h){\n\t\tpush @A, $i . ' ' . ($i + 1);\n\t\t$i++\n\t\t}\n\tif ($d > $h){\n\t\tpush @A, 1 . ' ' . ++$i;\n\t\t}\n\tfor (1 .. $d - $h - 1){\n\t\tpush @A, $i . ' ' . ($i + 1);\n\t\t$i++\n\t\t}\n\tfor (1 .. $n - $d - 1){\n\t\tpush @A, 2 . ' ' . ++$i\n\t\t}\n\t\n\tprint $d > $h * 2 ? -1 : join \"\\n\", @A\n\t}"}], "src_uid": "32096eff277f19d227bccca1b6afc458"}
{"source_code": "while(<>){\n\t( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t@_ = split //;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\t@az = sort keys %h;\n\t\n\t( $min, $max ) = @az[ 0, -1 ];\n\t\t\t\n\tif( $k > $n ){\n\t\tprint $_ . $min x ( $k - $n );\n\t\t}\n\telse{\n\t\t$_ = reverse substr $_, 0, $k;\n\t\tprint ~~ reverse\n\t\ts/(.*?)([^$max])/\n\t\t\t( $min x length $1 ) . \n\t\t\t( grep $_ gt $2, @az )[ 0 ]\n\t\t/er;\n\t\t}\n\t}", "positive_code": [{"source_code": "( $n, $k ) = split ' ', <>;\n\n$_ = <>, chomp;\n@_ = split //;\n\nmap $h{ $_ } ++, @_;\n\n@az = sort keys %h;\n\n( $min, $max ) = @az[ 0, -1 ];\n\nif( $k > $n ){\n\tprint $_ . $min x ( $k - $n );\n\t}\nelse{\n\tfor $i ( reverse 0 .. $k - 1 ){\n\t\tif( $_[ $i ] ne $max ){\n\t\t\tprint @_[ 0 .. $i - 1 ],\n\t\t\t\t( grep $_ gt $_[ $i ], @az )[ 0 ],\n\t\t\t\t( $min ) x ( $k - $i - 1 );\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t@_ = split //;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, @_;\n\t\n\tmy @az = sort keys %h;\n\t\n\tmy( $min, $max ) = @az[ 0, -1 ];\n\t\n\tmy $az = join '', @az;\n\t\n\t$debug and print \"[$min]\";\n\t\n\tif( $k > $n ){\n\t\t$debug and print '>';\n\t\tprint $_ . $min x ( $k - $n );\n\t\t}\n\telse{\n\t\tfor my $i ( reverse 0 .. $k - 1 ){\n\t\t\tif( $_[ $i ] ne $max ){\n\t\t\t\tprint @_[ 0 .. $i - 1 ],\n\t\t\t\t\t( grep $_ gt $_[ $i ], @az )[ 0 ],\n\t\t\t\t\t( $min ) x ( $k - $i - 1 );\n\t\t\t\tlast;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}"}, {"source_code": "( $n, $k ) = split ' ', <>;\n\n$_ = <>, chomp;\n\n@az = sort split //;\n\n( $min, $max ) = @az[ 0, -1 ];\n\t\t\nif( $k > $n ){\n\tprint $_ . $min x ( $k - $n );\n\t}\nelse{\n\t$_ = reverse substr $_, 0, $k;\n\tprint ~~ reverse\n\ts/(.*?)([^$max])/\n\t\t( $min x length $1 ) . \n\t\t( grep $_ gt $2, @az )[ 0 ]\n\t/er;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\t$_ = <>, chomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split //;\n\t\n\tmy @az = sort keys %h;\n\t\n\tmy( $min, $max ) = @az[ 0, -1 ];\n\t\n\t$debug and print \"[$min|$max]\";\n\t\n\tmy $pos = -1;\n\t\n\t/\n\t\t(?= (.)(.) )\n\t\t(?{\n\t\t\t$1 lt $2 and $pos = pos;\n\t\t})\n\t\t(*FAIL)\n\t/x;\n\t\t\n\tmy $next = 0;\n\tmy $ans = '';\n\t\n\tif( $k > $n ){\n\t\t$debug and print '>';\n\t\tprint $_ . $az[ 0 ] x ( $k - $n );\n\t\t}\n\telse{\n\t\tfor my $lett ( reverse( ( split // )[ 0 .. $k - 1 ] ) ){\n\t\t\t$debug and print $lett;\n\t\t\t$next and do {\n\t\t\t\t$ans .= $lett;\n\t\t\t\tnext;\n\t\t\t\t};\n\t\t\t\t\n\t\t\tif( $lett eq $max ){\n\t\t\t\t$ans .= $min;\n\t\t\t\t}\n\t\t\telse{\n\t\t\t\t$ans .= $max;\n\t\t\t\t$next = 1;\n\t\t\t\t}\n\t\t\t}\n\t\tprint scalar reverse $ans;\n\t\t}\n\t}"}], "src_uid": "ea2dc6309e704d04cfdd6c79161c67f7"}
{"source_code": "$n = <STDIN>;\n$nums = <STDIN>;\nchomp($nums);\n@a = split(/ /g, $nums);\n@a = sort { $a <=> $b } @a;\n$max = $a[-1];\n$ans = 0;\nfor($i=0;$i<@a;$i++)\n{\n\tif($a[$i] < $max)\n\t{\n\t\t$ans += $max-$a[$i];\n\t}\n}\nprint(\"$ans\\n\");\n", "positive_code": [{"source_code": "$n = int(<>);\n$sum = 0;\n$ma = 0;\nforeach $i (split(/\\s/, <>)) {\n    $ma = $ma > $i ? $ma : $i;\n    $sum += $i;\n}\nprint $ma * $n - $sum, \"\\n\";\n"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub max {\n  my $max = shift;\n  local $_;\n\n  for (@_) {\n    $max = $_ if $_ > $max;\n  }\n  $max;\n}\n\nsub sum {\n  local $_;\n  my $sum = 0;\n  $sum += $_ for @_;\n  $sum;\n}\n\n<>;\nmy @welfare = split ' ', <>;\nmy $max = max(@welfare);\n\nsay sum map { $max - $_ } @welfare;\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n\n# send argument as array, not reference, to function requiring list\n    \n# essential\nmy @tokens = ();\n\nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nmy $n = read_token;\n\nmy @welfares = split q{ }, read_line;\n\nmy $max = max(@welfares);\n\nmy $answer = 0;\n\nfor (@welfares) {\n    $answer += $max - $_;\n}\n\nsay $answer;\n"}], "negative_code": [], "src_uid": "a5d3c9ea1c9affb0359d81dae4ecd7c8"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\t@_ = split ' ', <>;\n\t\n\t$debug and print \"[@_]\";\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @_;\n\t\n\tmy $xor = 0;\n\t\n\t$xor ^= $_ for @_;\n\t\n\t$debug and print \"sum:[$sum]\";\n\t$debug and print \"xor:[$xor]\";\n\t\n\tmy $Bsum = sprintf \"%0b\", $sum;\n\tmy $Bxor = sprintf \"%0b\", $xor;\n\t\n\t$debug and print \"Bsum:[$Bsum]\";\n\t$debug and print \"Bxor:[$Bxor]\";\n\t\n\tmy @ans;\n\t\n\tpush @ans, $xor;\n\t\n\t$sum += $xor;\n\t$xor ^= $xor;\n\t\n\t$Bsum = sprintf \"%0b\", $sum;\n\t$Bxor = sprintf \"%0b\", $xor;\n\t\n\t$debug and print \"Bsum:[$Bsum]\";\n\t$debug and print \"Bxor:[$Bxor]\";\n\t\n\tpush @ans, $sum;\n\t\n\tprint for ~~ @ans, \"@ans\";\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t( $sum, $xor ) = ( 0 ) x 2;\n\t\n\t$sum += $_, $xor ^= $_ for split ' ', <>;\n\t\n\tprint for 2, join ' ', $xor, $sum + $xor;\n\t}"}], "negative_code": [], "src_uid": "cced3c3d3f1a63e81e36c94fc2ce9379"}
{"source_code": "#!/usr/bin/perl\n\nmain();\n\nsub main {\n    my %hash = ();\n    my $line;\n    my $ans = 0;\n    while ($line = <>) {\n        if ($line =~ /^\\+/) {\n            $line =~ s/^\\+//;\n            $hash{$line} = 1; \n            next;\n        } \n        if ($line =~ /^-/) {\n            $line =~ s/^-//;\n            delete $hash{$line};\n            next;\n        }\n        my $cnt = keys (%hash);\n        $line =~ s/^[\\S]+://g;\n        $line =~ s/[^\\w ]+//g;\n        $ans += length ($line) * $cnt;      \n    }\n    print (\"$ans\\n\");   \n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy @users;\nmy $total = 0;\nmy $len;\n\nwhile (<>) {\n    chomp $_;\n    if (/\\+/) {\n\t$_ =~ s/\\+//;\n\tpush @users, $_;\n    } elsif (/\\-/) {\n\t$_ =~ s/\\-//;\n\tfor my $i (0 .. $#users){\n\t    if ($users[$i] eq $_) {\n\t\tsplice(@users, $i, 1, ());\n\t    }\n\t}\n    } else {\n\t$_ =~ s/([\\w]*:)//;\n\t$total += (scalar @users) * (length $_);\n    }\n}\n\nprint $total\n"}, {"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy ($s, %h);\nmy $r = 0;\nwhile ($s = <>) {\n    chomp $s;\n    if ($s =~ m/\\+(.+)$/) {\n\t$h{$1} = 1;\n    } elsif ($s =~ m/-(.+)$/) {\n\tdelete $h{$1};\n    } elsif ($s =~ m/:(.+)$/) {\n\t$r += length($1) * keys %h;\n    }\n}\nprint \"$r\\n\";\n"}, {"source_code": "#!usr/bin/perl\nuse strict;\nuse warnings;\n\nmy %ch;my $snd;my $traf=0;my $com;my $msg;my $come;\nfor(1..100){\n    $come=<STDIN>;\n    chomp($come);\n    if($come eq \"\"){ last;}\n    if($come=~/\\A[\\+]/){$com=$come=~s/[\\+]//r; $ch{$com}=1;}\n    elsif($come=~/\\A[\\-]/){$com=$come=~s/[\\-]//r; $ch{$com}=0;}\n    elsif($come=~/:/){\n\t($snd,$msg)=split/:/,$come;chomp($msg);\n\tforeach(keys %ch){ if($ch{$_}==1){$traf+=length($msg);}}\n    }\n}\nprint $traf.\"\\n\";"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nmy @users;\nmy $total = 0;\nmy $len;\n\nwhile (<>) {\n    if (/\\+/) {\n\t$_ =~ s/\\+//;\n\tpush @users, $_;\n    } elsif (/\\-/) {\n\t$_ =~ s/\\-//;\n\tfor my $i (0 .. $#users){\n\t    if ($users[$i] =~ $_) {\n\t\tsplice(@users, $i, 1, ());\n\t    }\n\t}\n    } else {\n\t$_ =~ s/([\\w]*:)//;\n\t$total += (scalar @users) * ((length $_) - 1);\n    }\n}\n\nprint $total\n"}], "src_uid": "d7fe15a027750c004e4f50175e1e20d2"}
{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nchomp(my $n = <>);\nchomp($_ = <>);\nmy @a = split;\nmy @pos  = grep { $_ > 0 } @a;\nmy @neg  = grep { $_ < 0 } @a;\nmy @zero = grep { $_ == 0 } @a;\n\nmy @set1 = ();\nmy @set2 = ();\nmy @set3 = ();\n\nif (@pos) {\n    push @set1, shift @neg;\n    push @set2, shift @pos;\n    push @set3, @pos;\n    push @set3, @neg;\n    push @set3, @zero;\n} else {\n    push @set1, shift @neg;\n    push @set2, shift @neg;\n    push @set2, shift @neg;\n    push @set3, @pos;\n    push @set3, @neg;\n    push @set3, @zero;\n}\n\nunshift @set1, scalar @set1;\nunshift @set2, scalar @set2;\nunshift @set3, scalar @set3;\nprint \"@set1\\n@set2\\n@set3\\n\";\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n# \n\nwhile ($eil=<>) {\n\n$num = <>;\n@num = split/ /,$num;\nchomp @num;\n\n    \n$j=0;    \nforeach (@num){\n    /-/ and $j++;\n    }\n$j = $j % 2;\n# print $j, \"\\n\";\n    \n$i=0;\n@a1 = @a2 = @a3 = ();\nforeach (@num){\n    if ($_==0) {push @a3, $_} \n    elsif ($_<0 and $i==0) {push @a1, $_; $i++}\n    elsif ($_<0 and $j==0) {push @a3, $_; $j++}\n    else {push @a2, $_}\n    }\n\n\n# print \"@num\\n\";\nprint \"1 @a1\\n\";\nprint scalar @a2, \" @a2\\n\";\nprint scalar @a3, \" @a3\\n\";\n\n}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n# \n\nwhile ($eil=<>) {\n\n$num = <>;\n@num = split/ /,$num;\nchomp @num;\n\n$i=0;\n@a1 = @a2 = @a3 = ();\nforeach (@num){\n    if ($_==0) {push @a3, $_} \n    elsif ($_<0 and $i==0) {push @a1, $_; $i++}\n    else {push @a2, $_}\n    }\nprint \"@num\\n\";\nprint \"1 @a1\\n\";\nprint scalar @a2, \" @a2\\n\";\nprint scalar @a3, \" @a3\\n\";\n\n}"}, {"source_code": "#!/usr/bin/perl\n# \n\nwhile ($eil=<>) {\n\n$num = <>;\n@num = split/ /,$num;\nchomp @num;\n\n$i=0;\n@a1 = @a2 = @a3 = ();\nforeach (@num){\n    if ($_==0) {push @a3, $_} \n    elsif ($_<0 and $i==0) {push @a1, $_; $i++}\n    else {push @a2, $_}\n    }\n# print \"@num\\n\";\nprint \"1 @a1\\n\";\nprint scalar @a2, \" @a2\\n\";\nprint scalar @a3, \" @a3\\n\";\n\n}"}], "src_uid": "03cf2cc26c84aab685ee78a1d6318b30"}
{"source_code": "while ($n=<>){\n    chomp $n;\n    $h=0;\n    $t=-1;\n    while ($n--){\n        $_=<>;\n        chomp;\n        $t+=abs($_-$h);\n        $t+=2;\n        $h=$_;\n        }\n    print \"$t\\n\";\n    }", "positive_code": [{"source_code": "chomp ($n = <STDIN>);\nwhile ($n--) {\n\tchomp ($i = <STDIN>);\n\tpush @h, $i;\n}\n\n$time = 0;\n$myH = 0;\nfor ($i=0; $i<@h; $i++) {\n\t$time += $h[$i] - $myH;\n\t$myH = $h[$i];\n\n\t$time++;\n\n\tif ($i != $#h) {\n\t\tif ($h[$i] > $h[$i+1]) {\n\t\t\t$time += $h[$i] - $h[$i+1];\n\t\t\t$myH = $h[$i+1];\n\t\t}\n\t\t$time++;\n\t}\n\n\t#printf \"Tree: $i($h[$i]) Time: $time myH: $myH\\n\";\n}\n\nprint \"$time\\n\";\n"}], "negative_code": [{"source_code": "chomp ($n = <STDIN>);\nwhile ($n--) {\n\tchomp ($i = <STDIN>);\n\tpush @h, $i;\n}\n\n$time = 0;\nfor ($i=0; $i<@h; $i++) {\n\t$time += $h[$i];\n\t$time ++;\n\tif ($i != $#h) {\n\t\tif ($h[$i] > $h[$i+1]) {\n\t\t\t$time += $h[$i] - $h[$i+1];\n\t\t}\n\t}\n}\n\nprint \"$time\\n\";\n"}], "src_uid": "a20ca4b053ba71f6b2dc05749287e0a4"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy( $max, $smax ) = sort { $b <=> $a } @_;\n\t\n\t$_ -= $max for @_;\n\t\n\t$_ ||= $max - $smax for @_;\n\t\n\tprint \"@_\";\n\t}", "positive_code": [{"source_code": "<>;\r\n\r\nwhile(<>){\r\n\t( $m, $s ) = sort { $b <=> $a } @_ = split ' ', <>;\r\n\t\r\n\t$_ -= $_ == $m ? $s : $m for @_;\r\n\t\r\n\tprint \"@_\\n\"\r\n\t}"}], "negative_code": [], "src_uid": "7965b6ce237b02617b55dc175ffa0451"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $h1, $a1, $c ) = split;\n\tmy( $h2, $a2 ) = split ' ', <>;\n\t\n\tmy @moves;\n\t\n\twhile( 1 ){\n\t\tif( $h1 - $a2 > 0 || $a1 >= $h2 ){\n\t\t\tpush @moves, 'STRIKE';\n\t\t\t$h2 -= $a1;\n\t\t\t$h2 <= 0 and last;\n\t\t\t}\n\t\telse{\n\t\t\tpush @moves, 'HEAL';\n\t\t\t$h1 += $c;\n\t\t\t}\n\t\t$h1 -= $a2;\n\t\t}\n\t\n\tprint ~~ @moves;\n\tprint for @moves;\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n( $h1, $a1, $c, $h2, $a2 ) = split ' ', <>.<>;\n\nwhile( 1 ){\n\tpush @M, do {\n\t\tif( $h1 - $a2 > 0 || $a1 >= $h2 ){\n\t\t\t$h2 -= $a1;\n\t\t\t'STRIKE'\n\t\t\t}\n\t\telse{\n\t\t\t$h1 += $c;\n\t\t\t'HEAL'\n\t\t\t}\n\t\t};\n\t$h2 <= 0 and last;\n\t$h1 -= $a2;\n\t}\n\nprint for ~~ @M, @M"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $h1, $a1, $c ) = split;\n\tmy( $h2, $a2 ) = split ' ', <>;\n\t\n\tmy @moves;\n\t\n\twhile( 1 ){\n\t\tif( $h1 - $a2 > 0 ){\n\t\t\tpush @moves, 'STRIKE';\n\t\t\t$h2 -= $a1;\n\t\t\t$h2 <= 0 and last;\n\t\t\t}\n\t\telse{\n\t\t\tpush @moves, 'HEAL';\n\t\t\t$h1 += $c;\n\t\t\t}\n\t\t$h1 -= $a2;\n\t\t}\n\t\n\tprint ~~ @moves;\n\tprint for @moves;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $h1, $a1, $c ) = split;\n\tmy( $h2, $a2 ) = split ' ', <>;\n\t\n\tmy @moves;\n\t\n\twhile( 1 ){\n\t\tif( $h1 - $a2 > 0 ){\n\t\t\tpush @moves, 'STRIKE';\n\t\t\t$h2 -= $a1;\n\t\t\t$h2 <= 0 and last;\n\t\t\t$h1 -= $a2;\n\t\t\t}\n\t\telse{\n\t\t\tpush @moves, 'HEAL';\n\t\t\t$h1 += $c;\n\t\t\t}\n\t\t}\n\t\n\tprint ~~ @moves;\n\tprint for @moves;\n\t}"}], "src_uid": "d497431eb37fafdf211309da8740ece6"}
{"source_code": "#!perl\nwhile(<>){\n    ($n,$m)=split;\n    $len=100_009;\n    for(1..$m) { \n\tmy($l,$r)=split ' ',<>;\n\t$len=$r-$l+1 if($r-$l+1<$len);\n    }\n    print \"$len\\n\";\n    for my$i(0..$n-1) {\n\tprint $i%$len,' ';\n    }\n    print \"\\n\";\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\tmy( $n, $m ) = split;\n\t\t\n\tmy $min = (sort {$a <=> $b} map { 0 - eval join '-', split ' ', <> } 1 .. $m )[ 0 ];\n\t\n\tprint 1 + $min;\n\tprint join \" \", ( (0 .. $min) x (1 + $n / ( $min || 1 ) ) )[ 0 .. $n - 1 ];\n\t\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t\n\tmy( $n, $m ) = split;\n\t\t\n\tmy $min = (sort {$a <=> $b} map { 0 - eval join '-', split ' ', <> } 1 .. $m )[ 0 ];\n\t\n\tprint 1 + $min;\n\tprint do { local $, = \" \"; ( (0 .. $min) x (1 + $n / $min) )[ 0 .. $n - 1 ] };\n\t\n\t}"}, {"source_code": "#!perl\nwhile(<>){\n    ($n,$m)=split;\n    $len=100_009;\n    for(1..$m) { \n\tmy($l,$r)=split ' ',<>;\n\t$len=$r-$l+1 if($r-$l+1<$len);\n    }\n    print \"$len\\n\";\n    for my$i(0..$n-1) {\n\tprint $i%$m,' ';\n    }\n    print \"\\n\";\n}\n"}], "src_uid": "317891277a5393758bd3c8f606769070"}
{"source_code": "<>;$x = <>;\n$c = $x=~tr/0/0/ - $x=~tr/1/1/;\nprint ($c < 0 ? -$c : $c);\n\n", "positive_code": [{"source_code": "my $n = int<>;\nmy @arr = split //, <>;\nmy @stack = ();\nmy $ans = $n;\npush @stack, shift @arr;\nfor (2..$n) {\n    push @stack, shift @arr;\n    if (scalar @stack > 1 && $stack[-1] != $stack[-2]) {\n        pop @stack;\n        pop @stack;\n    }\n}\nprint scalar @stack;\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nmy ($n, $line, $on, $zn) = (<>, <>, 0, 0);\nchomp $line;\n$_>0 and ++$on or ++$zn foreach (split //, $line);\nsay abs($zn-$on);"}, {"source_code": "use 5.016;\nuse strict;\nuse warnings;\n\nsub abs {\n  my ($x) = @_;\n  $x < 0 ? -$x : $x;\n}\n\n<>;\nchomp (my $bits = <>);\n\nmy $zero = $bits =~ tr/0//d;\nmy $one = $bits =~ tr/1//d;\nsay abs($one - $zero);\n"}, {"source_code": "use strict;\nuse warnings;\n#!/usr/bin/perl\n#$, = \" \";\n\n$a = <>;\n$a = <>;\nchomp($a);\nmy ($zero, $one) = (0,0);\nforeach my $i (0..length($a)-1) {\n\t$zero += (substr($a,$i,1)=='0');\n\t$one += (substr($a,$i,1)=='1');\n}\nprint abs($zero-$one);"}, {"source_code": "<>;\n$_ = <>;\n$v = ( () = /1/g);\n$n = ( () = /0/g);\nprint abs ($v - $n)"}], "negative_code": [{"source_code": "$_ = <>;\n$v = ( () = /1/g);\n$n = ( () = /0/g);\nprint abs ($v - $n)"}], "src_uid": "fa7a44fd24fa0a8910cb7cc0aa4f2155"}
{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n$ans = 0;\n$ans=$_>$ans ? $_:$ans foreach (split / /, <>);\nsay $ans;", "positive_code": [{"source_code": "<>;\nmy $m = 0;\n$_ > $m and $m = $_ for(split / /, <>);\nprint $m;"}, {"source_code": "<>;\n@_=split/ /,<>;\n$_>$M and $M=$_ for @_;\nprint $M"}], "negative_code": [], "src_uid": "d03ad531630cbecc43f8da53b02d842e"}
{"source_code": "( $s, $p, $n, $k ) = ( 1, 1, split ' ', <> );\n    $n - $k < $k and $k = $n - $k;\n\nfor (1 .. $n){\n\t$L += $k;\n\t\t$p += $L > $n;\n\t\t\tpush @s, $s += $p;\n\t\t$p += $L > $n;\n\t$L %= $n;\n\t}\n\nprint \"@s\"", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t$k = ( sort { $a <=> $b } $n - $k, $k )[ 0 ];\n\t\n\tmy $L = 0;\n\tmy $sect = 1;\n\tmy $plus = 1;\n\tmy @sect;\n\t\n\tfor my $i (1 .. $n){\n\t\t$L += $k;\n\t\tif( $L > $n ){\n\t\t\t$plus ++;\n\t\t\tpush @sect, $sect += $plus;\n\t\t\t$plus ++;\n\t\t\t$L %= $n;\n\t\t\t}\n\t\telse{\n\t\t\tpush @sect, $sect += $plus;\t\t\t\n\t\t\t}\n\t\t\n\t\t}\n\t\n\tprint \"@sect\";\n\t}"}], "negative_code": [], "src_uid": "fc82362dbda74396ad6db0d95a0f7acc"}
{"source_code": "use strict;\n\nmy ($n, $a, $b);\n\nchomp ($n = <STDIN>);\n\n($n, $a, $b) = split /\\s+/, $n;\n\nif ($n > ($a * $b)) {\n  print \"-1\";\n  exit;\n}\n\nmy $arr;\nmy $k = 1;\n\nforeach my $i (0 .. $a - 1) {\n  foreach my $j (0 .. $b - 1) {\n    $arr->[$i][$j] = ($k > $n) ? 0 : $k;\n    $k++;\n  }\n  if (not ($b & 1)) {\n    unshift @{$arr->[$i]}, pop @{$arr->[$i]} if ($i & 1);\n  }\n}\n\nprint sprintf \"%s\", join \"\\n\", map {join \" \", @{$arr->[$_]}} (0 .. $a - 1);\n", "positive_code": [{"source_code": "#!/usr/bin/env perl \n#===============================================================================\n#         FILE: 1.pl\n#       AUTHOR: Phoenix Ikki (liuxueyang.github.io), liuxueyang457@gmail.com\n# ORGANIZATION: Hunan University\n#      CREATED: 03/16/2016 05:01:19 PM\n#===============================================================================\n\n#use strict;\n#use warnings;\n#use utf8;\n#use Data::Dumper;\n\nwhile (<>) {\n  my ($n, $a, $b) = split;\n  if ($a * $b < $n) {\n      print \"-1\\n\";\n  } else {\n      my $array;\n      my $cnt = 1;\n      for my $i (0..$a-1) {\n          for my $j (0..$b-1) {\n              if ($cnt > $n) {\n                  $array->[$i][$j] = 0;\n              } else {\n                  $array->[$i][$j] = $cnt++;\n              }\n          }\n      }\n      if ($b % 2) {\n          # odd\n          for (0..$a-1) {\n              print join ' ', @{$array->[$_]};\n              print \"\\n\";\n          }\n      } else {\n          # even\n          for (0..$a-1) {\n              if ($_ % 2) {\n                  print join ' ', reverse @{$array->[$_]};\n                  print \"\\n\";\n              } else {\n                  print join ' ', @{$array->[$_]};\n                  print \"\\n\";\n              }\n          }\n      }\n  }\n}\n\nexit 0;\n"}, {"source_code": "$\\ = $/;\n($n, $x, $y) = split ' ', <>;\n$n > $x * $y and print -1 and exit;\n$_ = join ' ', 1 .. $n, (0) x ($x * $y - $n);\n$re = '(?:\\d+ ??)' x $y;\n$i ++ % 2 and $_ = join ' ', reverse split xor print for /$re/g"}], "negative_code": [], "src_uid": "6e0dafeaf85e92f959c388c72e158f68"}
{"source_code": "$n = <>;\nwhile (<>) {\n\t@v = split; push @rc, [@v];\n\t$sum = 0; \n\tfor ($k=0; $k<$n; $k++) {\n\t\tif ($v[$k]) {\n\t\t\t$sum += $v[$k]; \n\t\t} else {\n\t\t\t$i=$.-2; $j=$k;\n\t\t}\n\t}\n\tpush @sum, $sum;\n}\n@sum = sort { $a<=>$b } @sum;\n$lost = $sum[-1]-$sum[0] || 123456789;\n$rc[$i][$j] = $lost;\n$magic = ($sum[1]>$sum[0]? $sum[1]: $sum[0]) || $lost;\nfor ($i=0; $i<$n; $i++) {\n\t$r=0; $c=0;\n\tfor ($j=0; $j<$n; $j++) {\n\t\t$r+=$rc[$i][$j];\n\t\t$c+=$rc[$j][$i];\n\t}\n\tpush @magic, $r, $c;\n\t$d1 += $rc[$i][$i];\n\t$d2 += $rc[$i][$n-$i-1];\n}\npush @magic, $d1, $d2;\n$ans = (grep($_!=$magic, @magic)? -1: $lost);\nprint $ans\n", "positive_code": [{"source_code": "$\\ = $/;\n\n$n = <>;\nmap { push @_, [ split ] } <>;\n\nif( $n == 1 ){\n\tprint 1;\n\t}\nelse{\n\t$sum = 0;\n\t$zero = 0;\n\tfor( @_ ){\n\t\tif( !$zero and grep !$_, @{$_} ){\n\t\t\t$zero = eval join '+', @{$_};\n\t\t\t}\n\t\tif( !$sum and not grep !$_, @{$_} ){\n\t\t\t$sum = eval join '+', @{$_};\n\t\t\t}\n\t\t}\n\t\n\tfor( @_ ){\n\t\tfor (@{$_}){\n\t\t\t$_ ||= $sum - $zero;\n\t\t\t}\n\t\t}\n\t\t\n\tfor( @_ ){\n\t\t$h{ eval join '+', @{$_} } ++;\n\t\t}\n\t\t\n\tfor $i ( 0 .. @_ - 1 ){\n\t\t$h{ eval join '+', map { @{$_}[$i] } @_ } ++;\n\t\t}\n\t\t\n\tmap { \n\t\t$i = 0; $s = 0;\n\t\tfor( @{$_} ){\n\t\t\t$s += @{$_}[$i++];\n\t\t\t}\n\t\t$h{$s} ++;\n\t} \\@_, [ reverse @_ ];\n\t\n\tprint +(1 == keys %h and 0 < $sum - $zero) ? $sum - $zero : -1;\n\t}"}], "negative_code": [{"source_code": "$n = <>;\nif ($n == 1) {\n\tprint 1;\n\texit;\n}\nfor (<>) {\n\t@v = split;\n\t$sum = 0; $sum += $_ for @v; $r{$sum} = 1;\n\t$c[$_] += $v[$_] for 0..$n-1;\n\t$d1 += $v[$i++]; $d2 += $v[-$i];\n}\n$c{$_} = 1 for @c;\nsub diff { abs($_[0]-$_[2]) }\n$num = diff(%r);\n$ok = (\n\tkeys(%r)==2 && keys(%c)==2 && \n\t$num==diff(%c) &&\n\t($d1==$d2 || abs($d1-$d2)==$num)\n);\nprint $ok? $num: -1\n\t\t\t"}, {"source_code": "$n = <>;\nwhile (<>) {\n\t@v = split; push @rc, [@v];\n\t$sum = 0; \n\tfor ($k=0; $k<$n; $k++) {\n\t\tif ($v[$k]) {\n\t\t\t$sum += $v[$k]; \n\t\t} else {\n\t\t\t$i=$.-2; $j=$k;\n\t\t}\n\t}\n\tpush @sum, $sum;\n}\n$lost = abs($sum[0]-$sum[1]) || 123456789;\n$rc[$i][$j] = $lost;\n$magic = ($sum[1]>$sum[0]? $sum[1]: $sum[0]);\nfor ($i=0; $i<$n; $i++) {\n\t$r=0; $c=0;\n\tfor ($j=0; $j<$n; $j++) {\n\t\t$r+=$rc[$i][$j];\n\t\t$c+=$rc[$j][$i];\n\t}\n\tpush @magic, $r, $c;\n\t$d1 += $rc[$i][$i];\n\t$d2 += $rc[$i][$n-$i-1];\n}\n$ans = (grep($_!=$magic, @magic, $d1, $d2)? -1: $lost);\nprint $ans\n"}, {"source_code": "$n = <>;\nwhile (<>) {\n\t@v = split; push @rc, [@v];\n\t$sum = 0; \n\tfor ($k=0; $k<$n; $k++) {\n\t\tif ($v[$k]) {\n\t\t\t$sum += $v[$k]; \n\t\t} else {\n\t\t\t$i=$.-2; $j=$k;\n\t\t}\n\t}\n\tpush @sum, $sum;\n}\n$lost = abs($sum[0]-$sum[1]) || 123456789;\n$rc[$i][$j] = $lost;\n$magic = ($sum[1]>$sum[0]? $sum[1]: $sum[0]) || $lost;\nfor ($i=0; $i<$n; $i++) {\n\t$r=0; $c=0;\n\tfor ($j=0; $j<$n; $j++) {\n\t\t$r+=$rc[$i][$j];\n\t\t$c+=$rc[$j][$i];\n\t}\n\tpush @magic, $r, $c;\n\t$d1 += $rc[$i][$i];\n\t$d2 += $rc[$i][$n-$i-1];\n}\n$ans = (grep($_!=$magic, @magic, $d1, $d2)? -1: $lost);\nprint $ans\n"}, {"source_code": "$\\ = $/;\n\n$n = <>;\nmap { push @_, [ split ] } <>;\n\nif( $n == 1 ){\n\tprint 1;\n\t}\nelse{\n\t$sum = 0;\n\t$zero = 0;\n\tfor( @_ ){\n\t\tif( !$zero and grep !$_, @{$_} ){\n\t\t\t$zero = eval join '+', @{$_};\n\t\t\t}\n\t\tif( !$sum and not grep !$_, @{$_} ){\n\t\t\t$sum = eval join '+', @{$_};\n\t\t\t}\n\t\t}\n\t\n\tfor( @_ ){\n\t\tfor (@{$_}){\n\t\t\t$_ ||= $sum - $zero;\n\t\t\t}\n\t\t}\n\t\t\n\tfor( @_ ){\n\t\t$h{ eval join '+', @{$_} } ++;\n\t\t}\n\t\t\n\tfor $i ( 0 .. @_ - 1 ){\n\t\t$h{ eval join '+', map { @{$_}[$i] } @_ } ++;\n\t\t}\n\t\t\n\tmap { \n\t\t$i = 0; $s = 0;\n\t\tfor( @{$_} ){\n\t\t\t$s += @{$_}[$i++];\n\t\t\t}\n\t\t$h{$s} ++;\n\t} \\@_, [ reverse @_ ];\n\t\n\tprint +(1 == keys %h and $sum - $zero) ? $sum - $zero : -1;\n\t}"}, {"source_code": "$\\ = $/;\n\n$n = <>;\nmap { push @_, [ split ] } <>;\n\nif( $n == 1 ){\n\tprint 1;\n\t}\nelse{\n\t$sum = 0;\n\t$zero = 0;\n\tfor( @_ ){\n\t\tif( !$zero and grep !$_, @{$_} ){\n\t\t\t$zero = eval join '+', @{$_};\n\t\t\t$i = 0;\n\t\t\tfor (@{$_}){\n\t\t\t\t$_ == 0 and last;\n\t\t\t\t$i ++;\n\t\t\t\t}\n\t\t\t}\n\t\tif( !$sum and not grep !$_, @{$_} ){\n\t\t\t$sum = eval join '+', @{$_};\n\t\t\t}\n\t\t}\n\n\t$vzero = 0;\n\tfor (@_){\n\t\t$vzero += @{$_}[$i];\n\t\t}\n\t\n\tprint $vzero == $zero ? $sum - $zero : -1;\n\t}"}, {"source_code": "$\\ = $/;\n\n$n = <>;\nmap { push @_, [ split ] } <>;\n\nif( $n == 1 ){\n\tprint 1;\n\t}\nelse{\n\t$sum = 0;\n\t$zero = 0;\n\tfor( @_ ){\n\t\tif( !$zero and grep !$_, @{$_} ){\n\t\t\t$zero = eval join '+', @{$_};\n\t\t\t$i = 0;\n\t\t\tfor (@{$_}){\n\t\t\t\t$_ == 0 and last;\n\t\t\t\t$i ++;\n\t\t\t\t}\n\t\t\t}\n\t\tif( !$sum and not grep !$_, @{$_} ){\n\t\t\t$sum = eval join '+', @{$_};\n\t\t\t}\n\t\t}\n\n\t$vzero = 0;\n\tfor (@_){\n\t\t$vzero += @{$_}[$i];\n\t\t}\n\t\n\tprint +($vzero == $zero and $sum - $zero) ? $sum - $zero : -1;\n\t}"}], "src_uid": "3bd5a228ed5faf997956570f96becd73"}
{"source_code": "$\\ = $/;\n\n( $n, $m, $l, @_ ) = ( ( split ' ', <> ), -~0, ( split ' ', <> ), -~0 );\n\n$x = $_ > $l ? ( $c += !$x, 1 ) : 0 for @_;\n\nfor( 1 .. $m ){\n\t( $t, $p, $d ) = split ' ', <>;\n\tif( $t ){\n\t\tif( 1 == grep $_[ $p ] + $_ > $l, 0, $d ){\n\t\t\t$c += 1 <=> grep $_ > $l, @_[ $p - 1, $p + 1 ];\n\t\t\t}\n\t\t$_[ $p ] += $d;\n\t\t}\n\telse{\n\t\tprint 0 + $c;\n\t\t}\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m, $l ) = split;\n\tmy @A = split ' ', <>;\n\t\n\tpush @A, -( 1e5 + 1 ) * 1e9;\n\tunshift @A, -( 1e5 + 1 ) * 1e9;\n\t\n#%\tprint \"@A\";\n\t\n\tmy $more = 0;\n\tmy $cnt = 0;\n\t\n\tfor( @A ){\n\t\tif( $_ > $l ){\n\t\t\tif( !$more ){ $cnt ++ }\n\t\t\t$more = 1;\n\t\t\t}\n\t\telse{\n\t\t\t$more = 0;\n\t\t\t}\n\t\t}\n\t\n\tfor( 1 .. $m ){\n\t\tmy( $t, $p, $d ) = split ' ', <>;\n\t\tif( $t == 0 ){\n\t\t\tprint $cnt;\n\t\t\t}\n\t\telse{\n\t\t\tif( $A[ $p ] <= $l and $A[ $p ] + $d > $l ){\n\t\t\t\tif( $A[ $p - 1 ] > $l and $A[ $p + 1 ] > $l ){\n\t\t\t\t\t$cnt --;\n\t\t\t\t\t}\n\t\t\t\tif( $A[ $p - 1 ] <= $l and $A[ $p + 1 ] <= $l ){\n\t\t\t\t\t$cnt ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t$A[ $p ] += $d;\n\t\t\t}\n\t\t}\n\t\n\t}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $input = <STDIN>;\nmy ($n, $m, $l) = map {$_+0} split / /, $input;\n$input = <STDIN>;\nmy @hairs = map {$_+0} split / /, $input;\nmy @res = ();\nmy $counter = 0;\nmy $r = 0;\nfor my $i (0 .. $m - 1) {\n    $input = <STDIN>;\n    my @req = map {$_+0} (split(/ /, $input));\n    if (scalar @req == 1 && $req[0] == 0) {\n        unless (@res) {\n            $r = f(\\@hairs, $n, $l);\n        }\n        push @res, $r;\n    } elsif (scalar @req == 3 && $req[0] == 1) {\n        my $j = $req[1] - 1;\n        my $d = $hairs[$j] + $req[2];\n        if (scalar @res > 0 && $hairs[$j] <= $l && $d > $l) {\n            if ($j == 0 && $n > 1 && $hairs[1] <= $l) {\n                $r++;\n            } elsif ($j == $n-1 && $n > 1 && $hairs[$n-2] <= $l) {\n                $r++;\n            } elsif ($j != $n-1 && $j != 0 && $hairs[$j-1] <= $l && $hairs[$j+1] <= $l) {\n                $r++;\n            } elsif ($j != $n-1 && $j != 0 && $hairs[$j-1] > $l && $hairs[$j+1] > $l) {\n                $r--;\n            } elsif ($n == 1) {\n                $r++;\n            }\n        }\n        $hairs[$req[1]-1] = $d;\n    }\n}\n\nmy $j = scalar @res;\nfor my $i (0..$j-1) {\n    print $res[$i];\n    print \"\\n\" if $i != $j-1;\n}\n\nsub f {\n    my $hairs = shift;\n    my $n = shift;\n    my $l = shift;\n    my $counter = 0;\n    my $flag = 0;\n    for my $i (0..$n-1) {\n        if ($hairs->[$i] > $l) {\n            $flag = 1;\n        } else {\n            $counter++ if $flag == 1;\n            $flag = 0;\n        }\n    }\n    $counter++ if ($flag == 1);\n    return $counter;\n}"}], "negative_code": [{"source_code": "use strict;\nuse warnings;\n\nmy $input = <STDIN>;\nmy ($n, $m, $l) = map {$_+0} split / /, $input;\n$input = <STDIN>;\nmy @hairs = map {$_+0} split / /, $input;\nmy @res = ();\nfor my $i (0 .. $m - 1) {\n    $input = <STDIN>;\n    my @req = map {$_+0} (split(/ /, $input));\n    if (scalar @req == 1 && $req[0] == 0) {\n        push @res, f(\\@hairs, $n, $l);\n    } elsif (scalar @req == 3 && $req[0] == 1) {\n        $hairs[$req[1]-1] += $hairs[$req[2]];\n    }\n}\n\nmy $j = scalar @res;\nfor my $i (0..$j-1) {\n    print $res[$i];\n    print \"\\n\" if $i != $j-1;\n}\n\nsub f {\n    my $hairs = shift;\n    my $n = shift;\n    my $l = shift;\n    my $counter = 0;\n    my $flag = 0;\n    for my $i (0..$n-1) {\n        if ($hairs->[$i] > $l) {\n            $flag = 1;\n        } else {\n            $counter++ if $flag == 1;\n            $flag = 0;\n        }\n    }\n    $counter++ if ($flag == 1);\n    return $counter;\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $input = <STDIN>;\nmy ($n, $m, $l) = map {$_+0} split / /, $input;\n$input = <STDIN>;\nmy @hairs = map {$_+0} split / /, $input;\nmy @res = ();\nmy $counter = 0;\nmy $r = 0;\nfor my $i (0 .. $m - 1) {\n    $input = <STDIN>;\n    my @req = map {$_+0} (split(/ /, $input));\n    if (scalar @req == 1 && $req[0] == 0) {\n        unless (@res) {\n            $r = f(\\@hairs, $n, $l);\n        }\n        push @res, $r;\n    } elsif (scalar @req == 3 && $req[0] == 1) {\n        my $j = $req[1] - 1;\n        my $d = $hairs[$j] + $req[2];\n        if (scalar @res > 0 && $hairs[$j] <= $l && $d > $l) {\n            if ($j == 0 && $n > 1 && $hairs[$j+1] <= $l) {\n                $r++;\n            } elsif ($j == $n-1 && $n > 1 && $hairs[$j-1] <= $l) {\n                $r++;\n            } elsif ($j != $n-1 && $j != 0 && $hairs[$j-1] <= $l && $hairs[$j+1] <= $l) {\n                $r++;\n            } elsif ($j != $n-1 && $j != 0 && $hairs[$j-1] > $l && $hairs[$j+1] > $l) {\n                $r--;\n            }\n        }\n        $hairs[$req[1]-1] = $d;\n    }\n}\n\nmy $j = scalar @res;\nfor my $i (0..$j-1) {\n    print $res[$i];\n    print \"\\n\" if $i != $j-1;\n}\n\nsub f {\n    my $hairs = shift;\n    my $n = shift;\n    my $l = shift;\n    my $counter = 0;\n    my $flag = 0;\n    for my $i (0..$n-1) {\n        if ($hairs->[$i] > $l) {\n            $flag = 1;\n        } else {\n            $counter++ if $flag == 1;\n            $flag = 0;\n        }\n    }\n    $counter++ if ($flag == 1);\n    return $counter;\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $input = <STDIN>;\nmy ($n, $m, $l) = map {$_+0} split / /, $input;\n$input = <STDIN>;\nmy @hairs = map {$_+0} split / /, $input;\nmy @res = ();\nfor my $i (0 .. $m - 1) {\n    $input = <STDIN>;\n    my @req = map {$_+0} (split(/ /, $input));\n    if (scalar @req == 1) {\n        push @res, f(\\@hairs, $n, $l);\n    } else {\n        $hairs[$req[1]-1] += $hairs[$req[2]];\n    }\n}\n\nmy $j = scalar @res;\nfor my $i (0..$j-1) {\n    print $res[$i];\n    print \"\\n\" if $i != $j-1;\n}\n\nsub f {\n    my $hairs = shift;\n    my $n = shift;\n    my $l = shift;\n    my $counter = 0;\n    my $flag = 0;\n    for my $i (0..$n-1) {\n        if ($hairs->[$i] > $l) {\n            $flag = 1;\n        } else {\n            $counter++ if $flag == 1;\n            $flag = 0;\n        }\n    }\n    $counter++ if ($flag == 1);\n    return $counter;\n}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m, $l ) = split;\n\tmy @A = split ' ', <>;\n\t\n\tpush @A, -( 1e5 + 1 ) * 1e9;\n\tunshift @A, -( 1e5 + 1 ) * 1e9;\n\t\n\tprint \"@A\";\n\t\n\tmy $more = 0;\n\tmy $cnt = 0;\n\t\n\tfor( @A ){\n\t\tif( $_ > $l ){\n\t\t\tif( !$more ){ $cnt ++ }\n\t\t\t$more = 1;\n\t\t\t}\n\t\telse{\n\t\t\t$more = 0;\n\t\t\t}\n\t\t}\n\t\n\tfor( 1 .. $m ){\n\t\tmy( $t, $p, $d ) = split ' ', <>;\n\t\tif( $t == 0 ){\n\t\t\tprint $cnt;\n\t\t\t}\n\t\telse{\n\t\t\tif( $A[ $p ] <= $l and $A[ $p ] + $d > $l ){\n\t\t\t\tif( $A[ $p - 1 ] > $l and $A[ $p + 1 ] > $l ){\n\t\t\t\t\t$cnt --;\n\t\t\t\t\t}\n\t\t\t\tif( $A[ $p - 1 ] <= $l and $A[ $p + 1 ] <= $l ){\n\t\t\t\t\t$cnt ++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t$A[ $p ] += $d;\n\t\t\t}\n\t\t}\n\t\n\t}"}, {"source_code": "$\\ = $/;\n\n( $n, $m, $l, @_ ) = ( ( split ' ', <> ), -~0, ( split ' ', <> ), -~0 );\n\n$x = $_ > $l ? ( $c += !$x, 1 ) : 0 for @_;\n\nfor( 1 .. $m ){\n\t( $t, $p, $d ) = split ' ', <>;\n\tif( $t ){\n\t\tif( 1 == grep $_[ $p ] + $_ > $l, 0, $d ){\n\t\t\t$c += 1 <=> grep $_ > $l, @_[ $p - 1, $p + 1 ];\n\t\t\t}\n\t\t$_[ $p ] += $d;\n\t\t}\n\telse{\n\t\tprint $c;\n\t\t}\n\t}"}], "src_uid": "1e17039ed5c48e5b56314a79b3811a40"}
{"source_code": " #!perl\n \n $\\ =\"\\n\";\n \n sub countPath\n {\n    my @result;\n    if($_[1] > $_[0])  \n    {\n        push @result, $_[1] - $_[0];\n        push @result, $_[1];\n    }\n    else \n    {\n        push @result, $_[0] - $_[1];\n        push @result, $_[0];\n    }\n        \n    return @result;\n  }\n \n sub count\n {\n    my $link = $_[0];\n    my @a = @{$link};\n    \n    if($_[2] > $_[3])\n    {\n        return countPath(@a[$_[1]], @a[$_[2]]);\n    }\n    else\n    {\n        my @left = count(\\@a, $_[1]*2 + 2, $_[1]*2 + 3, $_[3]);\n        my @right = count(\\@a, $_[2]*2 + 2, $_[2]*2 + 3, $_[3]);\n        \n        my @result = countPath(@left[1] + @a[$_[1]], @right[1] + @a[$_[2]]);\n        \n        return (@result[0] + @left[0] + @right[0], @result[1]);\n    }\n }\n \n $n = <>;\n my @lamps = split / /, <>;\n \n @answer = count(\\@lamps, 0, 1, $#lamps - 2**$n);\n\n print @answer[0];", "positive_code": [{"source_code": "use strict;\nuse warnings;\nuse List::Util qw(first max maxstr min minstr reduce shuffle sum);;\nour $ans = 0;\nmy $n = <>;\n\nmy @elm = split / /,<>;\nunshift @elm ,\"www\";\nreet(@elm);\nprint $ans;\nsub reet\n{\n    my @a = @_;\n    my $i = $#a;\n    if ($i <= 1)\n    {\n        return;\n    }\n    my @b = @a[0..($#a - 1)/2];\n    while ($i > $#a/2)\n    {\n        #print \"$i : \",$a[$i],\" \";\n        $b[($i - 1)/2] += max($a[$i], $a[$i - 1]);\n        $ans += abs($a[$i] - $a[$i - 1]);\n        $i -= 2;\n    }\n    \n    reet(@b);\n}"}], "negative_code": [{"source_code": " #!perl\n \n $\\ =\"\\n\";\n \n sub count\n {\n    my $link = shift;\n    my @a = @{$link};\n    \n    if($#a == 1)\n    {\n        return @a;\n    }\n    else\n    {\n        my $first = shift @a;\n        my $second = shift @a;\n        \n        my $p = ($#a + 1)/2 - 1;\n        my @branch_1 = @a[0..$p];\n        my @branch_2 = @a[($p + 1)..$#a];\n        \n        for my $i (@branch_1)\n        {\n            $i += $first;\n        }\n        \n        for my $j (@branch_2)\n        {\n            $j += $second;\n        }\n        \n        return (count(\\@branch_1), count(\\@branch_2));\n    }\n }\n \n sub  find_answer\n {\n    my $link = shift;\n    my @a = @{$link};\n    my $m = shift;\n    \n    if($#a == 1)\n    {\n        my $left = $m - @a[0];\n        my $right = $m - @a[1];\n        \n        return $left > $right ? $left : $right;\n    }\n    else\n    {\n        my $first = shift @a;\n        my $second = shift @a;\n        \n        my $p = ($#a + 1)/2 - 1;\n        my @branch_1 = @a[0..$p];\n        my @branch_2 = @a[($p + 1)..$#a];\n        \n        my $left = find_answer(\\@branch_1, $m) - $first;\n        my $right = find_answer(\\@branch_2, $m) - $second;\n        \n        return $left + $right;\n    }\n }\n \n $n = <>;\n @lamps = split / /, <>;\n \n @paths = count(\\@lamps);\n \n $max = 0;\n for my $item (@paths)\n {\n    $max = $item if $max < $item;\n }\n \n print find_answer(\\@lamps, $max);"}], "src_uid": "ae61e1270eeda8c30effc9ed999bf531"}
{"source_code": "#!/usr/bin/perl\nmy ($t) = map { $_ - 0 } split(/[\\s]+/,<STDIN>);\nfor(my $t1=0;$t1<$t;$t1++){\n  my ($n,$k) = map { $_ - 0 } split(/[\\s]+/,<STDIN>);\n  my $s = scalar(<STDIN>);\n  my @a = ();\n  $#a = $n - 1;\n  my $o1 = 0;\n  my $o2 = 0;\n  for(my $i=0;$i<$n;$i++){\n    if( substr($s,$i,1) eq '1' ){\n      $o1 = $k;\n      $a[$i] = 1;\n    } else {\n      $o1 --;\n      $a[$i] = 1 if $o1 >= 0;\n    }\n    if( substr($s,$n-1-$i,1) eq '1' ){\n      $o2 = $k;\n      $a[$n-1-$i] = 1;\n    } else {\n      $o2 --;\n      $a[$n-1-$i] = 1 if $o2 >= 0;\n    }\n  }\n  \n  my $tot = 0;\n  my $run = 0;\n  for(my $i=0;$i<$n;$i++){\n    if( $a[$i] != 1 ){\n      $tot++ if $run % ($k+1) == 0;\n      $run ++ ;\n    } else {\n      $run = 0;\n    }\n  }\n  print \"$tot\\n\";\n  \n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $k ) = split;\n\t$_ = <>, chomp;\n\t\n\tmy @k = partition( $k );\n\t\n\tmy $k_re = join '', map { \"0{0,$_}\" } @k;\n\t\n\t$debug and print \"k_re:[$k_re]\";\n\t\n\ts/1 \\K ( $k_re ) / \"1\" x length $1 /gex;\n\t\n\t$_ = reverse;\n\t\n\ts/1 \\K ( $k_re ) / \"1\" x length $1 /gex;\n\t\n\t$_ = reverse;\n\t\n\t$debug and print \"[$_]\";\n\t\n\tmy @free_rows = grep $_, map length, split /1+/, $_;\n\t\n\t$debug and print \"free_rows[@free_rows]\";\n\t\n\tmy $ans = 0;\n\t\n\tfor my $i ( @free_rows ){\n\t\twhile( $i >= $k + 1 ){\n\t\t\t$ans ++;\n\t\t\t$i -= $k + 1;\n\t\t\t}\n\t\t$i and $ans ++;\n\t\t}\n\t\n\tprint $ans;\n\t}\n\nsub partition {\n\tmy $i = shift;\n\t\n\tmy @arr;\n\tmy $max = 1e4;\n\t\n\twhile( $i > $max ){\n\t\tpush @arr, $max;\n\t\t$i -= $max;\n\t\t}\n\t\n\t$i > 0 and push @arr, $i;\n\t\n\t@arr;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t\n\tmy( $n, $k ) = split;\n\t$_ = <>, chomp;\n\t\n\tmy @k = partition( $k );\n\t\n\tmy $k_re = join '|', map { \"0{0,$_}\" } @k;\n\t\n\t$debug and print \"k_re:[$k_re]\";\n\t\n\ts/1 \\K ( $k_re ) / \"1\" x length $1 /gex;\n\t\n\t$_ = reverse;\n\t\n\ts/1 \\K ( $k_re ) / \"1\" x length $1 /gex;\n\t\n\t$_ = reverse;\n\t\n\t$debug and print \"[$_]\";\n\t\n\tmy @free_rows = grep $_, map length, split /1+/, $_;\n\t\n\t$debug and print \"free_rows[@free_rows]\";\n\t\n\tmy $ans = 0;\n\t\n\tfor my $i ( @free_rows ){\n\t\twhile( $i >= $k + 1 ){\n\t\t\t$ans ++;\n\t\t\t$i -= $k + 1;\n\t\t\t}\n\t\t$i and $ans ++;\n\t\t}\n\t\n\tprint $ans;\n\t}\n\nsub partition {\n\tmy $i = shift;\n\t\n\tmy @arr;\n\tmy $max = 1e4;\n\t\n\twhile( $i > $max ){\n\t\tpush @arr, $max;\n\t\t$i -= $max;\n\t\t}\n\t\n\t$i > 0 and push @arr, $i;\n\t\n\t@arr;\n\t}"}], "src_uid": "fd85ebe1dc975a71c72fac7eeb944a4a"}
{"source_code": "#!/usr/bin/perl\r\nuse Data::Dumper;\r\n\r\nmy ($test_case) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n\r\nwhile( $test_case -- > 0 ){\r\n  my ($px,$py) = map { $_ - 0 } split(/\\s+/,<STDIN>);\r\n  ( my $s = <STDIN> ) =~ s/[\\x00-\\x20]+$//ios;\r\n  my %c = +{ 'U' => 0, 'D'=>0, 'R'=>0, 'L'=>0 };\r\n  for(my $i=0;$i<length($s);$i++){\r\n    $c{substr($s,$i,1)} ++;\r\n  }\r\n  if( ( $px > 0 and $c{'R'} < $px ) or ( $px < 0 and $c{'L'} < abs($px) ) or \r\n      ( $py > 0 and $c{'U'} < $py ) or ( $py < 0 and $c{'D'} < abs($py) ) ){\r\n    print \"NO\\n\";\r\n  } else {\r\n    print \"YES\\n\";\r\n  }\r\n}\r\n\r\nexit(0);\r\n\r\n", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nwhile(<>){\r\n\t( $X, $Y, $_, %h ) = split ' ', $_ . <>;\r\n\t/.(?{ $h{ $& } ++ })(*F)/;\r\n\t\r\n\tprint\r\n\t\t+ ( $X < 0 ? -$h{L} <= $X : $h{R} >= $X )\r\n\t\t+ ( $Y < 0 ? -$h{D} <= $Y : $h{U} >= $Y )\r\n\t\t> 1 ? \"YES\" : \"NO\"\r\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $X, $Y ) = split;\n\t$_ = <>, chomp;\n\t\n\tmy $L = () = /L/g;\n\tmy $R = () = /R/g;\n\tmy $D = () = /D/g;\n\tmy $U = () = /U/g;\n\t\n\tmy $ok = 0;\n\t\n\tif( $X >= 0 ){\n\t\t$R >= $X and $ok += 1;\n\t\t}\n\telse{\n\t\t-$L <= $X and $ok += 1;\n\t\t}\n\t\n\tif( $Y >= 0 ){\n\t\t$U >= $Y and $ok += 1;\n\t\t}\n\telse{\n\t\t-$D <= $Y and $ok += 1;\n\t\t}\n\t\n\tprint $ok == 2 ? \"YES\" : \"NO\";\n\t}"}], "negative_code": [], "src_uid": "65a64ea63153fec4d660bad1287169d3"}
{"source_code": "$/ = undef; $_ = <>; ($n, $k, $b, @a) = split;\nfor $a (@a) {\n\tif ($a > $b) {\n\t\t$b = $a; $c = 0;\n\t}\n\tif (++$c == $k) {\n\t\tlast;\n\t}\n}\nprint $b;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t@_ = split ' ', <>;\n\tmy $pre = $_[ 0 ];\n\tmy $ok = 0;\n\tmy $cnt = 0;\n\t\n\tfor my $i ( 1 .. @_ - 1 ){\n\t\tmy $new = $_[ $i ] > $pre ? $_[ $i ] : $pre;\n\t\tif( $pre == $new ){\n\t\t\t$cnt ++;\n\t\t\t}\n\t\telse{\n\t\t\t$cnt = 1;\n\t\t\t}\n\t\t$cnt == $k and do {\n\t\t\t$ok = 1;\n\t\t\tlast;\n\t\t\t};\n\t#\tprint \"  pre: $pre, new: $new\";\n\t\t$pre = $new;\n\t\t}\n\t\n\tprint $pre;\n\t}"}, {"source_code": "<> =~ / /;\n\nfor( split ' ', <> ){\n\t$i ++ and $' == ( $c = 1 + $c * ( $_ <= $p ) ) and last;\n\t$_ > $p and $p = $_;\n\t}\n\nprint 0 + $p"}], "negative_code": [{"source_code": "$/ = undef; $_ = <>; ($n, $k, @a) = split;\nfor $a (@a) {\n\tif ($a > $b) {\n\t\t$b = $a;\n\t}\n\tif (++$c == $k) {\n\t\tlast;\n\t}\n}\nprint $b;\n"}, {"source_code": "<> =~ / /;\n\nfor( split ' ', <> ){\n\tlast if $' == ( $c = 1 + $c * ( $_ <= $p ) );\n\t$_ > $p and $p = $_;\n\t}\n\nprint 0 + $p"}], "src_uid": "8d5fe8eee1cce522e494231bb210950a"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $m ) = split;\n\t\n\tmy @N = split ' ', <>;\n\tmy @M = split ' ', <>;\n\t\n\tfor( 1 .. <> ){\n\t\t$_ = <>, chomp;\n\t\t\n\t\tprint $N[ ( $_ - 1 ) % @N ] . $M[ ( $_ - 1 ) % @M ]\n\t\t}\n\t\n\t}", "positive_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n\n# solve\n\nread_token;\nread_token;\n\nmy @a = split q{ }, read_line;\nmy @b = split q{ }, read_line;\nmy $length_of_a = @a;\nmy $length_of_b = @b;\n\nmy $q = read_line;\n\nfor (1..$q) {\n    my $year = read_line;\n    my $mod_of_a = $year % $length_of_a;\n    my $mod_of_b = $year % $length_of_b;\n    say \"$a[$mod_of_a-1]$b[$mod_of_b-1]\";\n}\n"}], "negative_code": [], "src_uid": "efa201456f8703fcdc29230248d91c54"}
{"source_code": "<>;\n$a = <>;\n($b = abs $_ - chop $a) =~ y/6-9/4321/, $s += $b for reverse <>=~/./gs;\nprint $s", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nmy $n = <>;\nchomp $n;\nmy $na = <>;\nchomp $na;\nmy $nb = <>;\nchomp $nb;\n\nmy $res = 0;\n\nmy @a = split(//, $na);\nmy @b = split(//, $nb);\n\nfor (my $i = 0; $i < $n; $i++) {\n    my ($m, $M);\n    my $c1 = abs($a[$i] - $b[$i]);\n    my $c2 = 10 - $c1;\n    if ($c1 < $c2) {\n        $res += $c1;\n    } else {\n        $res += $c2;\n    }\n}\n\nprint \"$res\\n\";\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nsub min{\n    return $_[0] < $_[1] ? $_[0] : $_[1];\n}\nmy $n = <>;\nmy @src = split '',<>;\nmy @dest = split '',<>;\nmy $res = 0;\nforeach my $i(0 .. $n-1){\n    my $d = abs($src[$i] - $dest[$i]);\n    $res += min($d, 10 - $d);\n}\nprint $res;\n"}, {"source_code": "<>;\n$a = <>;\n($b = abs $_ - chop $a) =~ y/6-9/4321/, $s += $b for reverse <>=~/./gs;\nprint $s"}, {"source_code": "$\\ = $/;\nwhile(<>){\n$sum = 0;\nchomp($a=<>);\nchomp($b=<>);\nfor (1 .. $_){\n$aa = chop $a;\n$bb = chop $b;\n$sum+=(sort {$a<=>$b} abs($aa - $bb), abs(10-abs($aa - $bb)) )[0];\n}\nprint $sum;\n}"}, {"source_code": "<>;@a=split'',<>;@b=split'',<>;$x=0;\n$t=abs($a[$_]-$b[$_]) and $x+=($t>5?10-$t:$t) for 0..@a;\nprint $x\n"}, {"source_code": "<>;$a=<>;$b=<>;\n@a=split'',$a;\n@b=split'',$b;\n$x=0;\n$t=abs($a[$_]-$b[$_]) and $x+=($t>5?10-$t:$t) for 0..@a;\nprint $x\n"}, {"source_code": "<>;\n$a=<>;\n$b=<>;\n@a=split'',$a;\n@b=split'',$b;\nfor(0..@a){\n  $t=$a[$_]-$b[$_];\n  $t=$t<0?-$t:$t;\n  $x+=($t>5?10-$t:$t);\n}\nprint $x\n"}, {"source_code": "sub min{\n    return $_[1] < $_[0] ? $_[1] : $_[0];\n}\nmy $n = int<>;\nmy @lock = split //, <>;\nmy @arr  = split //, <>;\nmy $ans  = 0;\nfor my $i(0..$n-1) {\n    $ans += min(abs($lock[$i] - $arr[$i]), abs(10 - abs($lock[$i] - $arr[$i])));\n}\nprint $ans . \"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nsub abs {\n\t$a = shift;\n\treturn $a>0 ? $a:-$a;\n};\n\nsub min {\n\t($a, $b) = (shift, shift);\n\treturn $a<$b ? $a:$b;\n};\n\nchomp($len = <>);\nchomp($l1 = <>);\nchomp($l2 = <>);\n$ans = 0;\nforeach (0..$len-1) {\n\t($a, $b) = (substr($l1, $_, 1), substr($l2, $_, 1));\n\t$tmp = abs($a-$b);\n\t$ans += min($tmp, 10-$tmp);\n}\nsay $ans;"}, {"source_code": "my $n = <>;\nmy @a = split '', <>;\nmy @b = split '', <>;\nmy $c = 0;\n\nfor (1..$n) {\n    my $a = shift @a;\n    my $b = shift @b;\n    my $x = ($a - $b) % 10;\n    my $y = ($b - $a) % 10;\n    my $z = $x < $y ? $x : $y;\n    $c += $z;\n}\n\nprint \"$c\\n\";\n"}, {"source_code": "#!perl\n\n<>;\nmy @start_state = split //, <>;\nmy @combination = split //, <>;\n\nmy $answer = 0;\nfor my $i (0..$#start_state - 1)\n{\n    (my $x1, my $x2) = @start_state[$i] < @combination[$i] ? (@start_state[$i], @combination[$i]) : (@combination[$i], @start_state[$i]);\n    my $a = $x2 - $x1;\n    my $b = 9 - $x2 + $x1 + 1;\n    $answer += $a < $b ? $a : $b; \n}\n\nprint $answer, \"\\n\";"}], "negative_code": [{"source_code": "<>;$a=<>;$b=<>;\n@a=split'',$a;\n@b=split'',$b;\n$t=abs($a[$_]-$b[$_]) and $x+=($t>5?10-$t:$t) for 0..@a;\nprint $x\n"}, {"source_code": "<>;\n$a +=<>;\n($b = abs $_ - chop $a) =~ y/6-9/4321/, $s += $b for reverse <>=~/./g;\nprint $s"}], "src_uid": "5adb1cf0529c3d6c93c107cf72fa5e0b"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t$_ = <>, chomp;\n\t\n\t@_ = map ord, split //;\n\t\n\tmy $j = @_ - 1;\n\t\n\tfor my $i ( 0 .. @_ - 2 ){\n\t\t$_[ $i ] > $_[ $i + 1 ] and do { $j = $i; last; };\n\t\t}\n\t\n\tsubstr $_, $j, 1, '';\n\t\n\tprint;\n\t}", "positive_code": [{"source_code": "$n=<>;\n$s=<>;\n$i=0;\n++$i while substr($s,$i,1) le substr($s,$i+1,1);\nsubstr($s,$i,1)='';\nprint $s;"}], "negative_code": [], "src_uid": "c01fc2cb6efc7eef290be12015f8d920"}
{"source_code": "#!perl\nuse strict;\nuse warnings;\n\n<>;\nmy $istr = <>;\nmy @arr = map int, split /\\D/, $istr;\nmy $min = shift @arr;\nmy $mini = 1;\nmy $double = 0;\nmy $index_shift = 2;\nfor my $i ( 0 .. @arr-1 ) {\n    if ( $arr[$i] == $min ) {\n        $double = 1;\n    } elsif ( $arr[$i] < $min ) {\n        $min = $arr[$i];\n        $mini = $i + $index_shift;\n        $double = 0;\n    }\n}\nif ( $double ) {\n    print 'Still Rozdil';\n} else {\n    print $mini;\n}\n\n__END__\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $num =<>;\nmy $min=10000000000;\nmy $min_num=0;\nmy $city;\nmy @cities=split(' ',<>);\nforeach my $i(1..$num){\n\tif($cities[$i-1]<$min){\n\t\t$min=$cities[$i-1];\n\t\t$city=$i;\n\t\t$min_num=1;\n\t}\t\n\telsif($cities[$i-1]==$min){\n\t\t$min_num++;\n\t}\t\n}\nif($min_num==1){\n\tprint $city;\n}else{\n\tprint\"Still Rozdil\";\n}\t\t\t\t"}, {"source_code": "chomp (my $n = <STDIN>);\nchomp (my @num = split /\\s+/, <STDIN>);\n\nmy ($min,$pos)=(1+(10**9),-1);\nfor (my $i=0; $i<$n; $i++) {\n  if ($num[$i]<$min) {\n    $min = $num[$i];\n    $pos = $i+1;\n  } elsif ($num[$i]==$min) {\n    $pos = -1;\n  }\n}\nif ($pos == -1) {\n  print \"Still Rozdil\\n\";\n} else {\n  print \"$pos\";\n}\n"}], "negative_code": [], "src_uid": "ce68f1171d9972a1b40b0450a05aa9cd"}
{"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"", "positive_code": [{"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "#!/usr/bin/perl/\n\nmy $n = <>;\nmy @s = split //, <>;\nmy @t = split //, <>;\n\nmy %pairs, %sh, %th;\nmy $dst = 0;\n\nfor (my $i = 0; $i < $n; $i++) {\n    if ($s[$i] ne $t[$i]) {\n        my $p = $s[$i] . $t[$i];\n        $dst++;\n        $pairs{$p} = $i + 1;\n        $sh{$s[$i]} = $i + 1;\n        $th{$t[$i]} = $i + 1;\n      #  print ($pairs{$p}) . \"\\n\";\n\n        if ($pairs{reverse $p}) {\n            for (my $j = $i + 1; $j < $n; $j++) {\n                if ($s[$j] ne $t[$j]) {\n                  $dst++;\n                }\n            }\n            print ($dst - 2);\n            print \"\\n$pairs{reverse $p} $pairs{$p}\";\n            exit;\n        }\n    }\n}\n\nfor (my $i = 0; $i < $n; $i++) {\n    if ($s[$i] ne $t[$i]) {\n        if ($th{$s[$i]}) {\n            print $dst - 1;\n            print \"\\n\";\n            print $i + 1;\n            print \" $th{$s[$i]}\";\n            exit;\n        }\n    }\n}\n\nprint \"$dst\\n-1 -1\";\n"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "use strict;\nuse warnings;\n<>;\nmy $a = 0;\n\nmy @first = split //, <>;\nmy @second = split //, <>;\nmy %s;\nmy @matrix;\nfor(0..$#first - 1)\n{\n    unless ($first[$_] eq $second[$_])\n    {\n        $s{$first[$_].$second[$_]} = $_ ;\n        $matrix[ord ($first[$_]) - (ord 'a')][ord ($second[$_]) - ord( 'a')] = $_;\n        $a++;   \n    }\n    \n    \n}\n\nfor my $key (keys %s)\n{\n    my $key2 = do{$key =~ /(.)(.)/; $2.$1}; \n    if (defined $s{$key2}) \n    {\n        print $a - 2,\"\\n\";\n        printf \"%i %i\\n\",  $s{$key}+1 ,$s{$key2}+1;\n        exit 0;\n    }\n}\n\nfor my $f (0..$#matrix)\n{\n    for my $s (0..$#{$matrix[$f]})\n    {\n        if(defined $matrix[$f][$s])\n        {\n            for my $f2 (0..$#matrix)\n            {\n                if(defined($matrix[$f2][$f])  )\n                {\n                    printf \"%i\\n%i %i\", $a - 1,$matrix[$f2][$f] + 1, $matrix[$f][$s] + 1;\n                    exit 0;\n                }\n            }\n        }\n    }\n}\nprintf \"%i\\n%i %i\", $a,-1, -1;"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "#!/usr/bin/perl/\n\nmy $n = <>;\nmy @s = split //, <>;\nmy @t = split //, <>;\n\nmy %pairs, %sh, %th;\nmy $dst = 0;\n\nfor (my $i = 0; $i < $n; $i++) {\n    if ($s[$i] ne $t[$i]) {\n        my $p = $s[$i] . $t[$i];\n        $dst++;\n        $pairs{$p} = $i + 1;\n        $sh{$s[$i]} = $i + 1;\n        $th{$t[$i]} = $i + 1;\n      #  print ($pairs{$p}) . \"\\n\";\n\n        if ($pairs{reverse $p}) {\n            for (my $j = $i + 1; $j < $n; $j++) {\n                if ($s[$j] ne $t[$j]) {\n                  $dst++;\n                }\n            }\n            print ($dst - 2);\n            print \"\\n$pairs{reverse $p} $pairs{$p}\";\n            exit;\n        }\n    }\n}\n\nfor (my $i = 0; $i < $n; $i++) {\n    if ($s[$i] ne $t[$i]) {\n        if ($th{$s[$i]}) {\n            print $dst - 1;\n            print \"\\n\";\n            print $i + 1;\n            print \" $th{$s[$i]}\";\n            exit;\n        }\n    }\n}\n\nprint \"$dst\\n-1 -1\";"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\"\n"}, {"source_code": "chomp(($n, $A, $B) = <>);\n$k = 0;\nfor $i (0 .. $n -1){\n\t$a = chop $A;\n\t$b = chop $B;\n\t$a eq $b or $k ++,\n\t$h{$a.$b} = $n - $i\n}\n\t\nOUT:\nfor $i (keys %h){\n\tfor $j (keys %h){\n\t\t($j.$i) =~ /(.)\\1/ and $ans = \"$h{$i} $h{$j}\" and \n\t\t($i.$j) =~ /(.)\\1/ and do {$k --; last OUT}\n\t}\t\t\n}\n\nprint $ans ? --$k.$/.$ans : \"$k\\n-1 -1\""}, {"source_code": "\n$\\ = $/;\nwhile(<>){\n\t$n = $_;\n\tchomp ($A=<>);\n\tchomp ($B=<>);\n\tundef %h;\n\tundef $ans;\n\t$k = 0;\n\tfor $i (0 .. -1 + length $A){\n\t\t$a = chop $A;\n\t\t$b = chop $B;\n\t#\tprint $a,\" \",$b;\n\t\t$a eq $b and $k ++;\n\t\t$a ne $b and do { $h{$a.$b} = $n - $i };\n\t\t\n\t}\n\t$, = $\";\n#\tprint %h;\n\t$k = $n - $k;\n\t\n\t\n\tOUT:\n\tfor $i (keys %h){\n\t\tfor $j (keys %h){\n\t\t\t$i eq (reverse $j) and do { $ans = $h{$i}.\" \".$h{$j}; $k --;  last OUT};\n\t\t\t(substr $i, 0, 1) eq (substr $j, 1, 1) and do { $ans = $h{$i}.\" \".$h{$j} };\n\t\t}\n\t\t\n\t}\n\t$ans and $k--;\n\tprint $k;\n\tprint $ans ? $ans : \"-1 -1\";\n}\n\t\n"}], "negative_code": [{"source_code": "use strict;\nuse warnings;use List::Util qw(first max maxstr min minstr reduce shuffle sum);\nuse Data::Dumper;\n<>;\nchomp (my $t = <>);\nmy @S = split //, $t;\n\nchomp ($t = <>);\nmy @T = split //, $t;\nmy $ans = 0;\n\nmy @di;\nmy %TT;\nmy %SS;\nfor(0.. $#S)\n{\n    if($S[$_] ne $T[$_])\n    {\n        $ans ++;\n        push @di, $_;\n        push @{$TT{$T[$_]}}, $_;\n        push @{$SS{$S[$_]}}, $_;        \n    }   \n}\n\nmy @TTL = keys %TT;\nmy @SSL = keys %SS;\nmy @sht;\n\nfor my $l ('a'..'z')\n{\n    my @tttl = grep {$_ eq $l} @TTL;\n    my @tssl = grep {$_ eq $l} @SSL;\n    \n    if($#tttl != -1 and $#tssl != -1)\n    {\n        push (@sht, $l);\n    }\n}\nif( $#sht == -1)\n{\n    print \"$ans\\n-1 -1\";    \n    exit 0;\n}\n\nif( $#sht == 0)\n{\n    $ans--;\n    my $let = $sht[0];\n    my $l =  $TT{$let}->[0];\n    my $r =  $SS{$let}->[0];\n    print $ans,\"\\n\";\n    \n    print min($l+1,$r+1),\" \", max($l+1,$r+1);\n    exit 0;\n}\nmy %rr = map {$_, 1} @sht;\nfor my $e (keys %rr)\n{\n    for(@{$TT{$e}})\n    {\n        if(defined $rr{$S[$_]})\n        {\n            print $ans-2,\"\\n\";\n            my $l = $_;\n            my $r = $TT{$S[$_]}->[0];\n            print    min($l+1,$r+1),\" \", max($l+1,$r+1);\n            exit 0;\n        }\n    }\n}\nprint \"такого я не ожидал( \";\n"}, {"source_code": "\n$\\ = $/;\nwhile(<>){\n\t$n = $_;\n\tchomp ($A=<>);\n\tchomp ($B=<>);\n\tundef %h;\n\tundef $ans;\n\tfor $i (0 .. -1 + length $A){\n\t\t$a = chop $A;\n\t\t$b = chop $B;\n\t#\tprint $a,\" \",$b;\n\t\t$a ne $b and do { $h{$a.$b} = $n - $i };\n\t\t\n\t}\n\t$, = $\";\n#\tprint %h;\n\t\n\tOUT:\n\tfor $i (keys %h){\n\t\tfor $j (keys %h){\n\t\t\t$i eq (reverse $j) and do { $ans = $h{$i}.\" \".$h{$j}; last OUT};\n\t\t\t(substr $i, 0, 1) eq (substr $j, 1, 1) and do { $ans = $h{$i}.\" \".$h{$j} };\n\t\t}\n\t\t\n\t}\n\tprint $ans ? $ans : \"-1 -1\";\n}\n\t\n"}], "src_uid": "2fa543c8b8f9dc500c36cf719800a6b0"}
{"source_code": "<>,<> =~ /.+/;\n$_ = join '', sort split //, $&;\nprint length > 26 ? -1 : (length) - length y///csr", "positive_code": [{"source_code": "$n = <>;\n%h = map { $_, 1 } <> =~ /./g;\nprint $n > 26 ? -1 : $n - keys %h"}], "negative_code": [{"source_code": "$n = <>;\n%h = map { $_, 1 } <> =~ /./g;\nprint $n > 26 ? -1 : $n - %h"}], "src_uid": "d9e9c53b391eb44f469cc92fdcf3ea0a"}
{"source_code": "($n,$v)=split/ /,<>;\nfor $i(1..$n){\n\t$_=<>;\n\t@_=split/ /;\n\tshift @_;\n\t@_= sort {$a<=>$b} @_;\n\t$_[0]<$v and push @ans, $i\n\t}\nprint 0+@ans,\"\\n@ans\"", "positive_code": [{"source_code": "my ($n, $money) = split / /, <>;\nmy @ans;\nfor(1..$n) {\n    push @ans, $_ if($money > (sort{$a <=> $b} split / /, <>)[1]);\n}\nprint scalar @ans . \"\\n@ans\";\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nsub min {\n\tmy ($x, $y) = (shift, shift);\n\treturn $x<$y ? $x:$y;\n}\n\n($m, $n, $x) = (0, split / /, <>);\n@ans = (0) x ($n + 1);\nforeach my $i (1..$n) {\n\t@a = split / /, <>;\n\t$mn = 10 x 7;\n\t$mn = min($mn, $a[$_]) foreach (1..$#a);\n\t$mn<$x and $ans[$m++] = $i;\n}\nsay $m;\nprint $ans[$_], \" \" foreach (0..$m-1);"}, {"source_code": "$i=0;\n$in = <>;\n( $n, $v ) = split( ' ', $in );\nwhile($n--){\n    $line = <>;\n    ( $item, @items ) = split( ' ', $line );\n    foreach (@items) {\n        if ( $_ < $v ) {\n            push( @res, ( $i + 1 ) );\n            last;\n        }\n    }\n$i++;\n}\nprint ($#res+1); print \"\\n\";\nprint join(' ',@res);"}, {"source_code": "( $n, $v ) = split( ' ', <> );\nfor $i ( 1 .. $n ) {\n    $line = <>;\n    ( $item, @items ) = split( ' ', $line );\n    foreach (@items) {\n        if ( $_ < $v ) {\n            push( @res, $i );\n            last;\n        }\n    }\n}\nprint( $#res+ 1 ) and print \"\\n@res\";"}, {"source_code": "while(<>){\n\tchomp;\n\t($n,$v)=split/ /;\n\t\n\t@ans=();\n\tfor $i(1..$n){\n\t\t$_=<>;\n\t\tchomp;\n\t\t@_=split/ /;\n\t\tshift @_;\n\t\t@_= sort {$a<=>$b} @_;\n\t#\tprint \"$_[0]\\n\";\n\t\t$_[0]<$v and (push @ans, $i);\n\t\t\n\t\t}\n\t\n\t\n\tprint 0+@ans;\n\t@ans and print \"\\n@ans\\n\";\n\t}"}], "negative_code": [], "src_uid": "7804152ee14264afef019c5ad33094f9"}
{"source_code": "# cf706a # solution courtesy 19744936\ts_p\nuse strict;\nmy $n=<>;\n$_=join(' that ',('I hate') x $n).\" it\";\nprint s/I hate that I hate/I hate that I love/gr;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $n = <> + 0;\nmy @feelings = ();\n\nfor (my $i = 0; $i < $n; $i++) {\n    if($i % 2 eq 0) {\n        push(@feelings, \"I hate\");\n    } else {\n        push(@feelings, \"I love\");\n    }\n}\n\nmy $result = join(\" that \", @feelings);\nprint $result . \" it\\n\";"}, {"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n = <>;\nmy @items = qw(hate love);\nmy $i = 0;\n\nmy @words;\n\nfor (1..$n) {\n    push @words, 'I', $items[$i], 'that';\n    $i = !$i;\n}\n\n$words[$#words] = 'it';\n\n$\\ = \"\\n\";\n$, = ' ';\nprint @words;\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \n# essential\nmy @tokens = ();\n\nmy $n = read_token();\n\nmy $answer = 'I hate ';\n$n--;\n\nmy $m = 0;\n\nwhile ( $n > 0 ) {\n    if ( $m % 2 == 0 ) {\n        $answer .= 'that I love ';\n    }\n    else {\n        $answer .= 'that I hate ';\n    }\n    $m++;\n    $n--;\n}\n\n$answer .= 'it';\n\nsay $answer;\n\n\n\n\nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n"}, {"source_code": "my$n=<>,$b=0,@s=(\"I hate \",\"I love \",\"that \");print\"@s[0]\";while(--$n){print\"@s[2]\",($b?\"@s[0]\":\"@s[1]\");$b=!$b;}print\"it\""}, {"source_code": "# cf706a\nuse strict;\n$_=<>;\nmy $i=0;\nwhile(--$_>=0) {\n  print \"I \",['hate','love']->[$i],\" \",($_!=0 ? \"that \" : \"it\");\n  $i=1-$i;\n}\n"}, {"source_code": "$n = <>; $_ = join \" that \", (\"I hate\") x $n;\ns/I hate that I hate/I hate that I love/g;\nprint \"$_ it\";"}], "negative_code": [], "src_uid": "7f2441cfb32d105607e63020bed0e145"}
{"source_code": "print-1&1+sqrt<>*1.4999999999,\" \"for(1..<>)", "positive_code": [{"source_code": "for(1..<>){print-1&sqrt(<>*1.5)-9e-9+1,\"\\n\"}"}, {"source_code": "for(1..<>){print 1+int(sqrt(<>*1.5)-9e-9),\"\\n\"}"}, {"source_code": "<>;while(<>){print 1+int(sqrt($_*1.5)-9e-9),\"\\n\"}"}, {"source_code": "<>;while(<>){print(int(sqrt($_*1.5)-9e-9)+1,\"\\n\")}"}, {"source_code": "print-1&1-9e-9+sqrt<>*1.5,$/for(1..<>)"}, {"source_code": "print-1&1-9e-9+sqrt<>*1.5,\" \"for(1..<>)"}, {"source_code": "print-1&sqrt(<>*1.5)-9e-9+1,\" \"for(1..<>)"}, {"source_code": "for(1..<>){print-1&sqrt(<>*1.5)-9e-9+1,\" \"}"}], "negative_code": [{"source_code": "print-1&1+sqrt<>*1.49999,\" \"for(1..<>)"}, {"source_code": "print-1&1+sqrt<>*1.4999,\" \"for(1..<>)"}, {"source_code": "<>;print-1&1+1.22474487*sqrt,\" \"for(<>)"}, {"source_code": "<>;print-1&1+1.2247449*sqrt,\" \"for(<>)"}, {"source_code": "<>;print-1&1+1.2247448*sqrt,\" \"for(<>)"}, {"source_code": "<>;print-1&1+1.225*sqrt,\" \"for(<>)"}, {"source_code": "<>;print-1&1+1.224*sqrt,\" \"for(<>)"}, {"source_code": "for(1..<>){print-1&sqrt<>*1.5-9e-9+1,\"\\n\"}"}, {"source_code": "for(1..<>){print-1&sqrt<>*1.5+1,\"\\n\"}"}, {"source_code": "for(1..<>){print-1&sqrt(<>*1.5)+1,\"\\n\"}"}, {"source_code": "<>;while(<>){print(int(sqrt($_*1.5)+0.99),\"\\n\")}"}], "src_uid": "fbc8d6564905fbe82f9f612b2da3484d"}
{"source_code": "#!/usr/bin/perl\n$_=<>;\n$_=<>;\ns/(a){2,}|(y){2,}|(i){2,}|(u){2,}|(e){3,}|(o){3,}|(.)/\\1\\2\\3\\4\\5\\6\\7/g;\nprint $_;", "positive_code": [{"source_code": "$n = <>;\n$s = <>;\n$s =~ s,a+,a,g;\n$s =~ s,eee+,e,g;\n$s =~ s,i+,i,g;\n$s =~ s,ooo+,o,g;\n$s =~ s,u+,u,g;\n$s =~ s,y+,y,g;\nprint $s;"}, {"source_code": "$i = 0;\nwhile (<>) {\n\tif ($i == 1) {\n\t\ts/([aiuy])\\1*/\\1/g;\n\t\ts/([eo])\\1{2,}/\\1/g;\n\t\tprint $_;\n\t} else {\n\t\t$i = 1;\n\t}\n}\n"}, {"source_code": "$a=<>;\nmy $i=<>;\n$i=~s/a{2,}/a/g;\n$i=~s/i{2,}/i/g;\n$i=~s/u{2,}/u/g;\n$i=~s/y{2,}/y/g;\n$i=~s/e{3,}/e/g;\n$i=~s/o{3,}/o/g;\nprint $i;\n"}, {"source_code": "my $first;\nwhile (<>) {\n    $first++ or next;\n    s/a+/a/g;\n    s/eee+/e/g;\n    s/i+/i/g;\n    s/ooo+/o/g;\n    s/u+/u/g;\n    s/y+/y/g;\n    print;\n}\n"}, {"source_code": "my $l, $s;\n\n\n$l = <STDIN>;\n\n$s = <STDIN>;\n\nchomp($s);\n\n\nmy @arr = split //, $s;\nmy @out;\nmy %v = ('a', 1, 'e', 1, 'i', 1, 'o', 1, 'u', 1, 'y', 1);\n\nfor ($i = 0; $i < scalar(@arr); $i++){\n    \n    $c =  $arr[$i];\n    \n    if (exists($v{$c})){\n       $j = $i;\n       $t = $arr[$j];\n       while(  ($t eq $c) and $j < scalar(@arr) ){\n    \n          $j++;\n          $t = $arr[$j];\n       }\n       if( ($c eq 'o' || $c eq 'e') && ($j-$i)>2 ){\n          push(@out, $c);\n          $i = $j-1;\n          next;\n       }\n       if( ($c ne 'o' && $c ne 'e') && ($j-$i)>1 ){\n          push(@out, $c);\n          $i = $j-1;\n          next;       \n       }\n    }\n    push(@out, $c);\n}\n\n$res = join('', @out);\n\nprint \"$res\\n\";\n\n\n"}, {"source_code": "use warnings;\nuse strict;\nmy $n = int <>;\nmy $s = <>;\nmy @s = split //, $s;\nmy $cur = '-';\nmy $cnt = 0;\nfor my $i (0..$n) {\n    if ($s[$i] eq $cur) {\n        $cnt += 1;\n    } else {\n        unless ($cur eq '-') {\n            if ($cnt == 2 and ($cur eq 'e' or $cur eq 'o')) {\n                print $cur;\n                print $cur;\n            } elsif ($cur eq 'e' or $cur eq 'o' or $cur eq 'i' or $cur eq 'a' or $cur eq 'y' or $cur eq 'u') {\n                print $cur;\n            } else {\n                for (0..$cnt-1) {\n                    print $cur;\n                }\n            }\n        }\n        $cnt = 1;\n        $cur = $s[$i];\n    }\n}\nprint \"\\n\";\n\n"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nmy $len = <STDIN>;\nmy $str = <STDIN>;\n$str =~ s/a+/a/g;\n$str =~ s/eee+/e/g;\n$str =~ s/i+/i/g;\n$str =~ s/ooo+/o/g;\n$str =~ s/u+/u/g;\n$str =~ s/y+/y/g;\nprint $str;"}, {"source_code": "<>;\n$line = <>;\n$line =~ s/(?!<=\\1)([aiuy])\\1+(?!=\\1)/\\1/g;\n$line =~ s/(?!<=\\1)([oe])\\1\\1+(?!=\\1)/\\1/g;\nprint \"$line\";\n"}, {"source_code": "$lineno = 0;\nwhile ($line = <STDIN>){\n    if ($lineno == 0) {\n        $lineno += 1;\n    } else {\n        $line =~ s/[a]+/a/g;\n        $line =~ s/[e]{3,}/e/g;\n        $line =~ s/[i]+/i/g;\n        $line =~ s/[o]{3,}/o/g;\n        $line =~ s/[u]+/u/g;\n        $line =~ s/[y]+/y/g;\n        print $line;\n        last;\n    }\n}"}, {"source_code": "$string = <>; $string = <>;\n$string =~ s/a+/a/g;\n$string =~ s/i+/i/g;\n$string =~ s/u+/u/g;\n$string =~ s/y+/y/g;\n$string =~ s/eee+/e/g;\n$string =~ s/ooo+/o/g;\nprint($string)\n"}, {"source_code": "#! /usr/bin/env perl\n\nuse strict;\nuse warnings;\n\n<>;\n$_ = <>;\n\ns/a+/a/g;\ns/eee+/e/g;\ns/i+/i/g;\ns/ooo+/o/g;\ns/u+/u/g;\ns/y+/y/g;\n\nprint $_;\n"}], "negative_code": [{"source_code": "<>;\n$line = <>;\n# $_ =~ s/i/j/e;\n$line =~ s/(?!<=\\1)([aiuny])\\1+(?!=\\1)/\\1/g;\n$line =~ s/(?!<=\\1)([oe])\\1\\1+(?!=\\1)/\\1/g;\n# s/(?!<=$1)([abcdfghijklmnpqrstuvwxyz])$1+(?!=$1)/$1/g\nprint \"$line\";\n"}, {"source_code": "$lineno = 0;\nwhile ($line = <STDIN>){\n    if ($lineno == 0) {\n        $lineno += 1;\n    } else {\n        $line =~ s/[a]+/a/g;\n        $line =~ s/[e]{3,}/e/g;\n        $line =~ s/[i]+/i/g;\n        $line =~ s/[o]{3,}/o/g;\n        $line =~ s/[u]+/u/g;\n        print $line;\n        last;\n    }\n}"}, {"source_code": "#! /usr/bin/env perl\n\nuse strict;\nuse warnings;\n\n<>;\n$_ = <>;\n\ns/a+/a/g;\ns/e+/e/g;\ns/i+/i/g;\ns/o+/o/g;\ns/u+/u/g;\ns/y+/y/g;\n\nprint $_;\n"}, {"source_code": "#! /usr/bin/env perl\n\nuse strict;\nuse warnings;\n\n# my $n = <>;\n# <>;\n$_ = <>;\n\ns/a+/a/g;\ns/e+/e/g;\ns/i+/i/g;\ns/o+/o/g;\ns/u+/u/g;\ns/y+/y/g;\n\nprint $_;\n"}], "src_uid": "8ff1b4cf9875f1301e603b47626d06b4"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $w ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\tmy $min = 0;\n\tmy $max = 0;\n\t\n\tfor( @_ ){\n\t\t$sum += $_;\n\t\t$sum < $min and $min = $sum;\n\t\t$sum > $max and $max = $sum;\n\t\t}\n\t\n#%\tprint \"[$min|$max]\";\n\t\n\tmy $ans = ( $w - $max + 1 ) - ( -$min );\n\t\n\tprint $ans < 0 ? 0 : $ans;\n\t}", "positive_code": [{"source_code": "# author : Gabriel Hofer\nuse strict;\nuse warnings;\nuse constant NL => qq/\\n/;\nsub max { $_ [ 0 ] > $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nmy ( $n, $w ) = split qq/ /, <STDIN>;\nmy @one = split qq/ /, <STDIN>;\n# assumption : 0 people are initially on the bus\nmy ($max, $min, $sum);\n$max = $min = $sum = 0;\nAA: for my $i ( @one ) {\n    $sum += $i;\n    if ( $sum < $min ) { $min = $sum }\n    if ( $sum > $max ) { $max = $sum }\n}\nprint (max (0, ($w - ($max - $min) + 1)), NL);\n\n\n"}, {"source_code": "( $n, $w ) = split ' ', <>;\n\nfor( split ' ', <> ){\n\t$s += $_;\n\t$s < $m and $m = $s;\n\t$s > $M and $M = $s;\n\t}\n\t\n$A = $w - $M + 1 + $m;\n\nprint $A < 0 ? 0 : $A"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy( $n, $w ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\tmy $min = 0;\n\tmy $max = 0;\n\t\n\tfor( @_ ){\n\t\t$sum += $_;\n\t\t$sum < $min and $min = $sum;\n\t\t$sum > $max and $max = $sum;\n\t\t}\n\t\n#%\tprint \"[$min|$max]\";\n\t\n\tprint 1 + $w - ( $max - $min );\n\t}"}], "src_uid": "8cf5d08a319672d9b767d3523eca4df6"}
{"source_code": "my $n = int<>;\nmy $odd = 0;\nmy @arr = split / /, <>;\n$odd += $_ % 2 for(@arr);\nmy %hash;\n$hash{$arr[$_ - 1] % 2} = $_ foreach(1..$n);\n\nif ($odd == 1) {\n    print $hash{1};\n}\nelse {\n    print $hash{0};\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@N = (0, 0);\n@a = (0, 0);\n$i = 1;\nforeach (split / /, <>) {\n\t$a[$_ & 1] = $i++;\n\t$N[$_ & 1]++;\n}\n$N[0]>1 and say $a[1] or say $a[0];\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\nmy ($odd, $even, $last_odd, $last_even) = (0, 0, 0, 0);\n$_ = <>;\nmy @numbers = split(' ', <>);\n\n\nforeach my $i (1..scalar(@numbers))\n{\n    my $number = $numbers[$i-1];\n    if ($number % 2 == 0)\n    {\n        $even++;\n        $last_even = $i;\n    }\n    else\n    {\n        $odd++;\n        $last_odd = $i;\n    }\n}\n\nprint $even > $odd ? $last_odd : $last_even;\n"}, {"source_code": "while (<>){\n    @_=@m=split/ /,<>;\n    $i=$j=0;\n    for (1..3){(shift @m) % 2 and $i++};\n    if ($i>1){\n        for (@_){\n            $j++;\n            $_ % 2 or last\n            }\n        }\n    else {\n        for (@_){\n            $j++;\n            $_ % 2 and last\n            }\n        }\n    print \"$j\\n\";\n    }"}], "negative_code": [], "src_uid": "dd84c2c3c429501208649ffaf5d91cee"}
{"source_code": "<>;\n\n$z += $_ for @_ = sort { $b <=> $a } split ' ', <>;\n\n<>;\n\t\nprint join $/, map { $z - $_[ $_ - 1 ] } split ' ', <>;", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = sort { $b <=> $a } split ' ', <>;\n\t\n\tmy $sum = 0;\n\t\n\t$sum += $_ for @_;\n\t\n\t<>;\n\t\n\tmy @ans;\n\t\n\tfor my $i ( split ' ', <> ){\n\t\tpush @ans, $sum - $_[ $i - 1 ];\n\t\t}\n\t\n\tprint for @ans;\n\t}"}], "negative_code": [], "src_uid": "c1608f6f71cac56690e31aa130c1990e"}
{"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n\n$m = 0;\n$s = 0;\n\nfor($i=0;$i<$n;$i++)\n{\n\n  ($a, $b) = split / +/, <STDIN>;\n\n  $s = $s - $a + $b;\n\n  if( $s > $m )\n  {\n\n    $m = $s;\n\n  }\n\n}\n\nprint $m;\n", "positive_code": [{"source_code": "/ /, ($c+=$'-$`) > $m and $m = $c\nfor <>;\nprint 0+$m"}, {"source_code": "#!/usr/bin/perl\n\nuse 5.012;\nuse warnings;\n\nchomp(my $stops = <>);\n\nmy $cnt = 0;\nmy $max = 0;\nwhile ($stops--) {\n\tchomp(my $line = <>);\n\tmy ($exit, $enter) = split / /, $line;\n\t$cnt = $cnt - $exit + $enter;\n\t$max = $cnt if $cnt > $max;\n}\nprint $max;\n"}, {"source_code": "my $n = <>;\nmy ($a, $b, $pas, $ans) = (0, 0, 0, 0);\nfor (1..$n) {\n    ($a, $b) = split \" \", <>;\n    $pas -= $a;\n    $pas += $b;\n    $ans = $pas if ($pas > $ans);\n}\nprint $ans ,\"\\n\";\n"}, {"source_code": "my $n = <STDIN>;\nmy $max = 0;\nmy $count = 0;\nwhile($n--) {\n    my($a, $b) = split(' ', <STDIN>);\n    $count = $count - $a + $b;\n    $max = ($max > $count) ? $max : $count;\n}\nprint $max;"}, {"source_code": "\n/ /, ($c+=$'-$`) > $m and $m = $c\nfor <>;\nprint 0+$m"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\n\n\nchomp($n = <>);\n$ans = 0;\n$tot = 0;\nwhile ($n-- > 0) {\n\t($a, $b) = split / /, <>;\n\t$tot += $b - $a;\n\t$ans = $tot>$ans ? $tot:$ans;\n}\nprint $ans;\n"}, {"source_code": "use strict;\nuse warnings;\n\n\nmy $n = <>;\nchomp($n);\ndie('n is wrong') unless $n >= 2 && $n <= 1000;\n\nmy $max = 0;\nmy $current = 0;\nfor (my $i = 0; $i < $n; $i++) {\n    my $line = <>;\n    chomp($line);\n    my ($a, $b) = split(' ', $line);\n    #check if a,b is 0<a,b<=1000\n    #max 1000 per stop for 1000 stops. mean max=1M passangers. fits in int\n\n    $current -= $a;\n    die('wrong input') if $current < 0;\n\n    $current += $b;\n\n    if ($current > $max) {\n        $max = $current;\n    }\n}\n\nprint $max;\n"}, {"source_code": "chomp($numstops=<STDIN>);\nmy $max = -1;\nmy $capa = 0;\nwhile($numstops-- > 0) {\n\tchomp($line = <STDIN>);\n\t($l, $b) = $line =~ /(\\d+)\\s+(\\d+)/;\n\t\n\t$capa = $capa - $l + $b;\n\t$max = $capa if($capa > $max);\t\n}\nprint \"$max\\n\";"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy $mx = 0;\nmy $curr = 0;\nfor (1..$n) {\n    my ($a, $b) = split ' ', <>;\n    $curr += $b - $a;\n    $mx = $curr if $mx < $curr;\n}\n\nprint \"$mx\\n\";\n"}, {"source_code": "chomp(my $testCase=<STDIN>);\nmy @maximum;\nmy $sum = 0;\nwhile($testCase){\n\tchomp(my $values = <STDIN>);\n\tmy @arr = split / /,$values;\n\t$sum -= $arr[0];\n\t$sum += $arr[1];\n\tpush (@maximum,$sum);\n\t$testCase--;\n}\nmy $answer;\nmy @articles = sort {$b <=> $a} @maximum;\n$answer = $articles[0];\nprint $answer;"}, {"source_code": "<stdin>; my ($count, $res)=(0,0); do{ chomp; my ($out, $in) = split(\" \"); $count-=$out; $count += $in; ;$res = ($res > $count ? $res : $count) } while <stdin>; print \"$res\\n\""}, {"source_code": "<stdin>; @res=(0,0); do{ chomp; my ($out, $in) = split \" \", $_; $res[0]-=$out; $res[0] += $in; $res[1] = $res[0] if $res[0] > $res[1] } while <stdin>; print \"$res[1]\\n\""}, {"source_code": "$n = <>;\n$mx = 0; $p = 0;\nfor ($i = 0; $i < $n; ++$i) {\n    ($out, $in) = split' ', <>;\n    $p += $in - $out;\n    if ($p > $mx) { $mx = $p; }\n}\nprint $mx;"}, {"source_code": "#!/usr/bin/perl\nuse strict; use warnings;\n\n<STDIN>; my ($max, $cap, $out, $in) = 0;\nwhile (<STDIN>)\n{ ($out, $in) = split ' ', $_; $cap += $in - $out;\n  $max = $cap if $max < $cap }\nprint $max . \"\\n\"\n"}], "negative_code": [{"source_code": "$i=<>;\nwhile($i--){\n$_=<>;\n/(\\d+) (\\d+)/;\n$in = -$1 + $2;\n$cap += $in;\nif ($cap > $max) {$max = $cap} \n}\nprint $max"}, {"source_code": "use warnings;\nuse strict;\n\n\n\nmy $in = <>;\nchomp($in);\ndie('to many chars') unless length($in) <= 1000;\n\nmy @chars = split('', $in);\n\n$chars[0] = uc($chars[0]);\nmy $out = join('', @chars);\n\n\nprint $out;\n"}, {"source_code": "chomp($numstops=<STDIN>);\nmy $maxcapa = -1;\nmy $capa = 0;\nwhile($numstops-- > 0) {\n\tchomp($line = <STDIN>);\n\t($l, $b) = $line =~ /(\\d+)\\s+(\\d+)/;\n\t\n\t$capa = $capa - $l + $b;\n\t$max = $capa if($capa > $max);\t\n}\nprint \"$max\\n\";"}], "src_uid": "74b90fe9458b147568ac9bd09f219aab"}
{"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m", "positive_code": [{"source_code": "<>;\nfor (split/ /,<>){\n    $j++;\n    $b[$i++]=$j for 1..$_\n    }\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = (0, split / /, <>);\n$a[$_]+=$a[$_-1] foreach (1..$n);\nchomp($m = <>);\n@b = split / /, <>;\npush @ans, [($_, $b[$_])] foreach (0..$m-1);\n@ans = sort { $a->[1] <=> $b->[1] } @ans;\n@arr = (0) x $m;\nfor (($i,$j)=(1,0); $i<=$n; ++$i) {\n\twhile ($j<$m && $ans[$j]->[1]<=$a[$i]) {\n\t\t$arr[$ans[$j]->[0]] = $i;\n\t\t++$j;\n\t}\n\t$j>=$m and last;\n}\nsay $_ foreach (@arr);"}, {"source_code": "chomp (my $n = <>);\nchomp (my @a = split /\\s+/, <>);\nchomp (my $m = <>);\nchomp (my @q = split /\\s+/, <>);\n\nfor (my $i = 1; $i < $n; $i++) {\n    $a[$i] += $a[$i-1];\n}\n\n# printf (join \" \", @a) . \"\\n\";\n\nsub find {\n    my $f = $_[0];\n    my $i = 0;\n    my $j = $n;\n    my $x;\n    \n    while ($i < $j) {\n        $x = ($i + $j) >> 1;\n        if ($f <= $a[$x]) {\n            if ($x == 0 || $a[$x-1] < $f) {\n                return $x;\n            } else {\n                $j = $x;\n            }\n        } else {\n            $i = $x;\n        }\n    }\n}\n\nforeach (@q) {\n    printf \"%d\\n\", 1 + &find ($_);\n}"}, {"source_code": "#!/usr/bin/perl -w\n\nmy $piles = <>;\nmy @psize = split(/ /, <>);\nmy $juicy = <>;\n\nchomp ($piles, $juicy);\n\nmy $sum = 0;\nforeach (@psize) {\n    $sum += $_;\n    $_ = $sum;\n}\n\n# print \"$piles: @psize\\n\";\n\nforeach my $q (split (/ /, <>)) {\n    chomp($q);\n    my ($start, $end) = (0, $#psize);\n    while ($start < $end) {\n\t$mid = ($start + $end) >> 1;\n\tif ($q <= $psize[$mid]) {\n#\t    print \"lt: q=$q.   st=$start  mid=$mid  end=$end\\n\";\n\t    $end   = $mid;  # not $mid - 1 like we would for a binary search.  We want std::lower_bound style behaviour\n#\t} elsif ($q == $psize[$mid]) {\n#\t    $start = $end = $mid;\n\t} else {\n#\t    print \"gt: q=$q.   st=$start  mid=$mid  end=$end\\n\";\n\t    $start = $mid + 1;\n\t}\n    }\n    #    print $start + 1, \"\\tst=$start en=$end\\n\";\n    print $start + 1, \"\\n\";\n}\n"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n#use Data::Dumper;\n\nmy @cum;\nsub bs{\n    my $val = shift;\n    my ($low,$high) = (0 ,scalar @cum);\n    while($low < $high){\n        my $mid = int(($low + $high) / 2);\n        if($cum[$mid] >= $val){$high = $mid;}\n        else{$low = $mid + 1;}\n    }\n    return $low+1;\n}\nmy $n = <>;\nmy @pile = split ' ',<>;\nmy $m = <>;\nmy @lbl = split ' ',<>;\nfor my $i(0..$n-1){\n    if($i == 0){\n        push @cum, $pile[$i];\n    }\n    else{\n        push @cum, $cum[$#cum]+$pile[$i];\n    }\n}\n\nfor my $i(0..$m-1){\n    print bs($lbl[$i]),\"\\n\";\n}\n"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}, {"source_code": "while(<>){\n\t@a=split/ /,<>;\n\t<>;\n\t$_=<>;\n\tchomp;\n\t@_=split/ /;\n\t$h{$_}++ for @_;\n\t\n\t$k=0;\n\tfor (1..10**6){\n\t\t$h{$_} and $h{$_} = $k+1 .\"\\n\";\n\t\tif ($_==$a[$k]){$k++; $a[$k]+=$a[$k-1]}\n\t\t}\n\t\n\tpush @m, $h{$_} for @_;\n\tprint @m\n\t}"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m"}, {"source_code": "<>;\nfor (split/ /,<>){\n\t$j++;\n\t$b[$i++]=$j for 1..$_\n\t}\n<>;\npush @m, $b[$_-1] for split/ /,<>;\n$,=$/;\nprint @m\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl -w\n\nmy $piles = <>;\nmy @psize = split(/ /, <>);\nmy $juicy = <>;\n\nchomp ($piles, $juicy);\n\nmy $sum = 0;\nforeach (@psize) {\n    $sum += $_;\n    $_ = $sum;\n}\n\n# print \"$piles: @psize\\n\";\n\nforeach my $q (split (/ /, <>)) {\n    chomp($q);\n    my ($start, $end) = (0, $#psize);\n    while ($start < $end) {\n    $mid = ($start + $end) >> 1;\n    if ($q < $psize[$mid]) {\n#       print \"lt: q=$q.   st=$start  mid=$mid  end=$end\\n\";\n        $end   = $mid;  # not $mid - 1 like we would for a binary search.  We want std::lower_bound style behaviour\n#   } elsif ($q == $psize[$mid]) {\n#       $start = $end = $mid;\n    } else {\n#       print \"gt: q=$q.   st=$start  mid=$mid  end=$end\\n\";\n        $start = $mid + 1;\n    }\n    }\n    #    print $start + 1, \"\\tst=$start en=$end\\n\";\n    print $start + 1, \"\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl -w\n\nmy $piles = <>;\nmy @psize = split(/ /, <>);\nmy $juicy = <>;\n\nchomp ($piles, $juicy);\n\nmy $sum = 0;\nforeach (@psize) {\n    $sum += $_;\n    $_ = $sum;\n}\n\nprint \"$piles: @psize\\n\";\n\nforeach my $q (split (/ /, <>)) {\n    chomp($q);\n    my ($start, $end) = (0, $#psize);\n    while ($start < $end) {\n\t$mid = ($start + $end) >> 1;\n\tif ($q < $psize[$mid]) {\n#\t    print \"lt: q=$q.   st=$start  mid=$mid  end=$end\\n\";\n\t    $end   = $mid;  # not $mid - 1 like we would for a binary search.  We want std::lower_bound style behaviour\n#\t} elsif ($q == $psize[$mid]) {\n#\t    $start = $end = $mid;\n\t} else {\n#\t    print \"gt: q=$q.   st=$start  mid=$mid  end=$end\\n\";\n\t    $start = $mid + 1;\n\t}\n    }\n    print $start + 1, \"\\tst=$start en=$end\\n\";\n}\n"}], "src_uid": "10f4fc5cc2fcec02ebfb7f34d83debac"}
{"source_code": "sub min {\n\t(sort {$a<=>$b} @_) [0];\n};\nundef $/; $_ = <>; ($n, $a, $b, $_) = split;\n$p = s/\\.\\.//g;\n$s = y/.//;\n$P = min($a, $b, $p);\n$S = min($a + $b - $P - $P, $s + $p - $P);\nprint $P + $P + $S;", "positive_code": [{"source_code": "use warnings;\nuse strict;\nuse integer;\n$\\ = qq/\\n/, $, = qq/ /;\nmy ( $n, $aa, $bb ) = split qq/ /, <STDIN>;\nchomp ( my $str = <STDIN> );\nmy $sum = 0;\nsub min { my $one = $_ [ 0 ] < $_ [ 1 ] ? $_ [ 0 ] : $_ [ 1 ] }\nfor my $ii ( $str =~ m/\\.+/g ) {\n    if ( length ( $ii ) % 2 == 0 ) {\n        $sum += min ( $aa, length ( $ii ) / 2 ) + min ( $bb, length ( $ii ) / 2 );\n        $aa -= min ( $aa, length ( $ii ) / 2 );\n        $bb -= min ( $bb, length ( $ii ) / 2 );\n    } else {\n        if ( min ( $aa, ( length ( $ii ) + 1 ) / 2 ) + \n             min ( $bb, ( length ( $ii ) + 1 ) / 2 ) > \n             length $ii ) {\n            if ( $aa >= $bb ) {\n                $sum += min ( $aa, ( length ( $ii ) + 1 ) / 2 ) + min ( $bb, ( length ( $ii ) ) / 2 );\n                $aa -= min ( $aa, ( length ( $ii ) + 1 ) / 2 );\n                $bb -= min ( $bb, ( length ( $ii ) ) / 2 );\n            } else {\n                $sum += min ( $aa, ( length ( $ii ) ) / 2 ) + min ( $bb, ( length ( $ii ) + 1 ) / 2 );\n                $aa -= min ( $aa, ( length ( $ii ) ) / 2 );\n                $bb -= min ( $bb, ( length ( $ii ) + 1 ) / 2 );\n            }\n        } else {\n            $sum += min ( $aa, ( length ( $ii ) + 1 ) / 2 ) + min ( $bb, ( length ( $ii ) + 1 ) / 2 );\n            $aa -= min ( $aa, ( length ( $ii ) + 1 ) / 2 );\n            $bb -= min ( $bb, ( length ( $ii ) + 1 ) / 2 );\n        }\n    }\n}\nprint $sum;\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $A, $B ) = split;\n\t\n\t$A > $B and ( $A, $B ) = ( $B, $A );\n\t\n\t$_ = <>, chomp;\n\t\n\t@_ = map length, grep $_, split /\\*/;\n\t\n\t$debug and print \"[@_]\";\n\t\n\tmy @lyg = sort { $a <=> $b } grep $_ % 2 == 0, @_;\n\tmy @nel = sort { $a <=> $b } grep $_ % 2 == 1, @_;\n\t\n\t$debug and print \"[@lyg]\";\n\t$debug and print \"[@nel]\";\n\t\n\tmy $spaces = eval join ' + ', @_;\n\tmy $AB = $A + $B;\n\tmy $all = 0;\n\tmy $cnt = 0;\n\t\n\tNEL:\n\twhile( $A < $B ){\n\t\t$debug and print \" $A < $B\";\n\t\tif( @nel ){\n\t\t\tmy $nel = shift @nel;\n\t\t\tmy $min = $nel >> 1;\n\t\t\t$A -= $min;\n\t\t\t$B -= $min + 1;\n\t\t\t$A < 0 and $A = 0;\n\t\t\t$B < 0 and $B = 0;\n\t\t\t}\n\t\telsif( @lyg ){\n\t\t\tmy $lyg = shift @lyg;\n\t\t\tmy $half = $lyg >> 1;\n\t\t\t$A -= $half;\n\t\t\t$B -= $half;\n\t\t\t$A < 0 and $A = 0;\n\t\t\t$B < 0 and $B = 0;\n\t\t\t}\n\t\telse{\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\twhile( $A == $B ){\n\t\t$debug and print \" $A = $B\";\n\t\tif( @lyg ){\n\t\t\tmy $lyg = shift @lyg;\n\t\t\tmy $half = $lyg >> 1;\n\t\t\t$A -= $half;\n\t\t\t$B -= $half;\n\t\t\t$A < 0 and $A = 0;\n\t\t\t$B < 0 and $B = 0;\n\t\t\t}\n\t\telsif( @nel ){\n\t\t\tmy $nel = shift @nel;\n\t\t\tmy $min = $nel >> 1;\n\t\t\t$A -= $min + 1;\n\t\t\t$B -= $min;\n\t\t\t$A < 0 and $A = 0;\n\t\t\t$B < 0 and $B = 0;\n\t\t\tgoto NEL;\n\t\t\t}\n\t\telse{\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\t$debug and print \"[all:$all]\";\n\tprint $all ? $spaces : $AB - $A - $B;\n\t\n\t$debug and print '-' x 10;\n\t}"}, {"source_code": "( $n, $A, $B ) = split ' ', <>;\n\n$Z = $A + $B;\n\nfor( map length, split ' ', <> =~ y/*/ /r ){\n\t$d = $_ >> 1;\n\t( $A > $B ? $A : $B ) -= $_ % 2;\n\tmap { $_ -= $d; s/-.*/0/ } $A, $B;\n\t}\n\nprint $Z - $A - $B"}], "negative_code": [], "src_uid": "6208dbdf9567b759b0026db4af4545a9"}
{"source_code": "$x = <> - 1;\n\n( join ' ', sort split ' ', join ' ', map s/\\d+ //r, <> ) =~ /\\b(\\d+)\\b(?: \\1\\b){$x}(?{ print \"$1 \" })(*F)/;", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = map s/\\d+ //r, map ~~<>, 1 .. $_;\n\t\n\tmy %h;\n\t\n\tmap { map $h{ $_ } ++, split  } @_;\n\t\n\tmy $is = $_;\n\t\n\tmy @ans = grep { $is == $h{ $_ } } keys %h;\n\t\n\tprint \"@ans\";\n\t}"}, {"source_code": "$x = <>;\n\nmap { map $h{ $_ } ++, split  } map s/\\d+ //r, <>;\n\nprint join ' ', grep $x == $h{ $_ }, keys %h;"}], "negative_code": [{"source_code": "$x = <> - 1;\n\n( join '', <> ) =~ /( \\d+)(*MARK:A)\\b(?=(.*?($ (*SKIP:A)|)\\1\\b){$x})(?{ print 0 + $1 . ' ' })(*F)/sx;\n"}], "src_uid": "16c54cf7d8b484b5e22a7d391fdc5cd3"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split //, 'LURD' . $_;\n\t\n\tmap $h{ $_ } --, keys %h;\n\t\n\t\n\t( $h{ 'L' }, $h{ 'R' } ) = ( ( sort { $a <=> $b } $h{ 'L' }, $h{ 'R' } )[ 0 ] ) x 2;\n\t( $h{ 'U' }, $h{ 'D' } ) = ( ( sort { $a <=> $b } $h{ 'U' }, $h{ 'D' } )[ 0 ] ) x 2;\n\t\n\tif( $h{ 'L' } and $h{ 'U' } ){\n\t\tprint $h{ 'L' } + $h{ 'U' } << 1;\n\t\tprint join '', map $_ x $h{ $_ }, split //, 'LURD';\n\t\t}\n\telsif( $h{ 'L' } or $h{ 'U' } ){\n\t\tprint 2;\n\t\tprint 'LR' x !! $h{ 'L' } . 'UD' x !! $h{ 'U' };\n\t\t}\n\telse{\n\t\tprint 0;\n\t\tprint '';\n\t\t}\n\t}", "positive_code": [{"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split //, 'LURD' . $_;\n\t\n\tmap $h{ $_ } --, keys %h;\n\t\n\t@h{ split //, 'LRUD' } = map { ( ( sort { $a <=> $b } @h{ split // } )[ 0 ] ) x 2 } 'LR', 'UD';\n\t\n\tmy $ans = join '', map $_ x $h{ $_ }, split //, 'LURD';\n\t\n\t( $ans ) = $ans =~ /LR|UD/g if $h{ 'L' } xor $h{ 'U' };\n\t\n\tprint for length $ans, $ans;\n\t}"}, {"source_code": "$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\tmy %h;\n\t\n\tmap $h{ $_ } ++, split //, 'LURD' . $_;\n\t\n\tmap $h{ $_ } --, keys %h;\n\t\n\t@h{ split //, 'LRUD' } = map { ( ( sort { $a <=> $b } @h{ split // } )[ 0 ] ) x 2 } 'LR', 'UD';\n\t\n\tmy $ans = do { \n\t\tif( $h{ 'L' } and $h{ 'U' } ){\n\t\t\tjoin '', map $_ x $h{ $_ }, split //, 'LURD';\n\t\t\t}\n\t\telsif( $h{ 'L' } or $h{ 'U' } ){\n\t\t\t'LR' x !! $h{ 'L' } . 'UD' x !! $h{ 'U' };\n\t\t\t}\n\t\telse{\n\t\t\t'';\n\t\t\t}\n\t\t};\n\t\n\tprint for length $ans, $ans;\n\t}"}], "negative_code": [], "src_uid": "1fba9a290d0492a3d658a7a33388db13"}
{"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n    <>=~/ /;\n#   <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n@_=split/ /,<>;\n\nfor (1..$`){\n\t$a[pop @_]++ or $i++;\n\tunshift @b, $i;\n\t}\n\nwhile (<>){\n\tprint \"$b[$_-1]\\n\";\n\t}\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}", "positive_code": [{"source_code": "($n,$m)=split(' ',<>);\n@b=reverse(split(' ',<>));\n\n$c=0; for ($i=0; $i<@b; $i++) {\n\t$a=$b[$i];\n\tif ($t[$a]!=1) {\n\t\t$t[$a]=1;\n\t\t$c++;\n\t}\n\t$w[$i]=$c;\n}\n\nfor (1..$m) {\n\t$l=<>; chomp($l);\n\tprint $w[$n-$l], \"\\n\";\n}"}], "negative_code": [], "src_uid": "1e156dfc65ef88f19ca1833f75192259"}
{"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n", "positive_code": [{"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@a = (0, split / /, <>);\n($a, $b) = (0, 0);\n($i, $j) = (1, $n);\nforeach (1 .. $n) {\n\tif ($a[$i] > $a[$j]) {\n\t\t$tmp = $a[$i++];\n\t} else {\n\t\t$tmp = $a[$j--];\n\t}\n\tif ($_ & 1) {\n\t\t$a += $tmp;\n\t} else {\n\t\t$b += $tmp;\n\t}\n}\nsay \"$a $b\";"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "my $n = <STDIN>;\nchomp ($n);\nmy $numbers = <STDIN>;\nchomp ($numbers);\nmy (@data) = split (\" \", $numbers);\n\nmy $ind = 0; my $c = 0; my $serg = 0; my $dima = 0;\n\nwhile ($c != $n) {\n    if ($ind != 1) {\n        if ($data[0] > $data[(scalar (@data))-1]) {              \n           $serg = $serg + shift (@data); \n        }else{\n           $serg = $serg + pop (@data);\n        }\n        $c++;\n        $ind = 1;        \n    } else { \n        if ($data[0] > $data[(scalar (@data))-1]) {\n           $dima = $dima + shift (@data);\n        }else{\n           $dima = $dima + pop (@data);\n        }\n        $c++;\n        $ind = 0;\n    }\n}\nprint \"$serg $dima\";"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\""}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "my $num = <STDIN>;\nmy $data = <STDIN>;\nmy @cards = split(' ', $data);\n\nmy $seroga = 0;\nmy $dima = 0;\nmy $turn = 1;\n\nwhile(@cards)\n{\n    my $grt; \n    $num--;\n    if(@cards[$num] > @cards[0])\n    {\n        $grt = pop @cards;\n    }\n    else\n    {\n        $grt = shift @cards;\n    }\n    \n    if($turn % 2)\n    {\n        $seroga += $grt;\n    }\n    else\n    {\n        $dima += $grt;\n    }\n    $turn++;\n}\n\nprint $seroga, ' ', $dima;\n\n1;"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "use List::Util \"max\";\n($t, $i, $j) = (0, 0, (<> - 1));\n@a = split \" \", <>;\n@b = (0, 0);\n\nwhile ($i <= $j) {\n    if ($a[$i] >= $a[$j]) {\n        $b[$t] += $a[$i], ++$i;\n    } else {\n        $b[$t] += $a[$j], --$j;\n    }\n    $t = 1 - $t;\n}\n\nprint join \" \", @b;"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\"\n"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$b[0]+=0;$b[1]+=0;\nprint\"@b\""}], "negative_code": [{"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\nprint+$_ for@b"}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\n$_+=0 for@b;\nprint\"@b\""}, {"source_code": "<>; @_=split/ /,<>;\n$b[$i++%2]+=$_[0]>$_[@_-1]?shift@_:pop@_ while@_;\nprint\"@b\""}], "src_uid": "a7e98ed8ee1b0a4fd03dfcd222b68c6f"}
{"source_code": "for $i ( 0 .. ( @_ = split $\\, ($_ = <>, chomp, $_) ) - 1){\n\tfor $j ( ($m = 0) .. 5e3){\n\t\t\t$i -++ ($j *= 2) < 0 && last;\n\t\t\t$_[ $i ] eq $_[ $i - $j ] or next;\n\t\t\t$m = $b if $m < ($b = $b[ $i - $j ])\n\t\t}\n\t$b[ $i ] =++ $m;\n\t$_ = $b[ $i ] if $_ < $b[ $i ]\n\t}\nprint", "positive_code": [{"source_code": "$_ = <>, chomp;\n@_ = split $\\;\nfor $i (0 .. @_ - 1){\n\tundef $m;\n\tfor $j (0 .. 500){\n\t\t\t$j *= 2;\n\t\t\t$j += 1;\n\t\t\t$i - $j < 0 and last;\n\t\t\t$_[ $i ] eq $_[ $i - $j ] or next;\n\t\t\t$m |= 1 x length $b[ $i - $j ]\n\t\t}\n\t$b[ $i ] = $m . 1;\n\t$M |= 1 x length $b[ $i ];\n\t}\nprint length $M"}, {"source_code": "$_ = <>, chomp;\n@_ = split $\\;\nfor $i (0 .. @_ - 1){\n\tundef $m;\n\tfor $j (0 .. 500){\n\t\t\t$j *= 2;\n\t\t\t$j += 1;\n\t\t\t$i - $j < 0 and last;\n\t\t\t$_[ $i ] eq $_[ $i - $j ] or next;\n\t\t\t$m |= 1 x length $b[ $i - $j ]\n\t\t}\n\t$b[ $i ] = $m . 1;\n\t$M |= 1 x length $b[ $i ];\n\t}\nprint length $M"}], "negative_code": [{"source_code": "chomp ($a = <>);\nmap $x |= $_, split 0, join $\\, map $_ = (1 + length) % 2, split $_, $a for a .. z;\nprint length $x"}, {"source_code": "$_ = <>, chomp;\n$_ = join $/, map {$j ++ % 2 ? $_ : scalar reverse} split /\\|/;\n$min = (sort {$a <=> $b} @_ = map $_ = ($a += (-1) ** ($i ++ % 2) * length) - (++ $k % 2 and length), split /\\n/ )[0];\ns/$/ q( ) x (- $min + shift @_) /emg;\nprint scalar reverse"}], "src_uid": "e95aee4975b391e750123b7ead3eb0d4"}
{"source_code": "\n\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy %h;\t\t\t\t\nmy $str;\nfor ( my $i = 0; $i < $f; $i += 1 ) {\n    $str = <STDIN>;\n    chomp ( $f );\n    if ( exists $h{ $str } ) {\n\tprint \"YES\\n\";}\n    else {\n\t$h{ $str } = 1;\n\tprint \"NO\\n\"; }}\n\n\n\n", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\n<>;\n\nmy %hash;\n\nwhile (<>) {\n\tchomp;\n\tif (exists $hash{$_}) {\n\t\tprint \"YES\\n\";\n\t}\n\telse {\n\t\tprint \"NO\\n\";\n\t}\n\t$hash{$_} = 1;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\n<>;\n\nmy %hash;\n\nwhile (<>) {\n\tchomp;\n\tif (exists $hash{$_}) {\n\t\tprint \"YES\\n\";\n\t}\n\telse {\n\t\tprint \"NO\\n\";\n\t\t$hash{$_} = 1;\n\t}\n}\n"}], "negative_code": [], "src_uid": "7f934f96cbe3990945e5ebcf5c208043"}
{"source_code": "while($n = <stdin>){\n    $ans = 0;\n    for(1..$n){\n        $line = <stdin>;\n        chomp $line;\n        ($x1, $y1, $x2, $y2) = split(' ', $line);\n        $ans += ($x2 - $x1 + 1) * ($y2 - $y1 + 1);\n    }\n    print \"$ans\\n\";\n}\n", "positive_code": [{"source_code": "($a, @b) = <>;\nchomp ($a, @b);\n$s = 0;\nfor(@b)\n{\n    ($x1, $y1, $x2, $y2) = (split(/ /, $_));\n    $s += ($x2 - $x1 + 1) * ($y2 - $y1 + 1);\n}\nprint $s;"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\nforeach (1 .. $n) {\n\t($x1, $y1, $x2, $y2) = split / /, <>;\n\t$ans += ($x2-$x1+1) * ($y2-$y1+1);\n}\nsay $ans;"}, {"source_code": "$\\ = $/;\n<>;\nwhile(<>){\n\tchomp;\n\t($a, $b, $c, $d) = split;\n\t$sum += (abs($c-$a)+1) * (abs($d-$b)+1);\n}\nprint 0+$sum"}, {"source_code": "my $n = int<>;\nmy $ans = 0;\nmy ($x1, $y1, $x2, $y2);\nfor(1..$n) {\n    ($x1, $y1, $x2, $y2) = split / /, <>;\n    $ans += ($y2 - $y1 + 1) * ($x2 - $x1 + 1);\n}\nprint $ans;\n"}], "negative_code": [], "src_uid": "ca5c44093b1ab7c01970d83b5f49d0c6"}
{"source_code": "for(1..<>)\r\n{($a,$b)=split/\\s/,<>;\r\n\r\n$t=$a-$b;\r\nprint\"01\"x($t>0?$b:$a).($t>0?\"0\"x$t:\"1\"x-$t),\" \"}", "positive_code": [{"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;print\"01\"x($a>$b?$b:$a).($a>$b?\"0\"x($a-$b):\"1\"x($b-$a)),\"\\n\"}"}, {"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;$t=$a-$b;print\"01\"x($t>0?$b:$a).($t>0?\"0\"x$t:\"1\"x-$t),\" \"}for(1..<>){($a,$b)=split/\\s/,<>;$t=$a-$b;print\"01\"x($t>0?$b:$a).($t>0?\"0\"x$t:\"1\"x-$t),\" \"}"}, {"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;$t=$a-$b;print\"01\"x($t>0?$b:$a).($t>0?\"0\"x$t:\"1\"x-$t),\" \"}"}, {"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;$t=$a-$b;print\"01\"x($t>0?$b:$a).($t>0?\"0\"x$t:\"1\"x-$t),\" \"}"}, {"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;print\"01\"x($a>$b?$b:$a).($a>$b?\"0\"x($a-$b):\"1\"x($b-$a)),\" \"}"}, {"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;$t=$a-$b;print\"01\"x($t>0?$b:$a).($t>0?\"0\"x$t:\"1\"x-$t),\" \"}"}, {"source_code": "for(1..<>){($a,$b)=split/\\s/,<>;print\"01\"x($a>$b?$b:$a).($a>$b?\"0\"x($a-$b):\"1\"x($b-$a)),\" \"}"}], "negative_code": [], "src_uid": "7767e47571c7ea82ba4fb6a0bd0fbdc5"}
{"source_code": "\n$n=<STDIN>;\n$rads=<STDIN>;\n@radius=sort {$b <=> $a} split(\" \",$rads);\n$square=0;\n$\\=\"\\n\";\n$controller=1;\n\n\nforeach $i (@radius){\n    if (($controller++)%2==0){\n        $square-=3.141592653589793*$i*$i;\n        #print $i,\"chet\";\n    }else{\n        $square+=3.141592653589793*$i*$i;\n        #print $i,\"nechet\";\n    }\n}\n\nprint $square;\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse strict;\nuse warnings;\n\nmy $n=<>;\nmy @r=split(' ',<>);\nmy $total=0;\nmy $count=0;\nmy $now;\nmy $pi=3.1415926535;\nif($n%2==1){\n\t$now=1;\n}else{\n\t$now=-1;\n}\nwhile($count<$n-1){\n\tif($r[$count]>$r[$count+1]){\n\t\tmy $temp=$r[$count];\n\t\t$r[$count]=$r[$count+1];\n\t\t$r[$count+1]=$temp;\n\t\t$count=-1;\n\t}\n\t$count++;\n}\nforeach my $count(0..$#r){\n\t$total+=$now*$pi*$r[$count]*$r[$count];\n\t$now*=-1;\n}\nprint $total;"}], "negative_code": [{"source_code": "\n$n=<STDIN>;\n$rads=<STDIN>;\n@radius=sort {$a <=> $b} split(\" \",$rads);\n$square=0;\n$\\=\"\\n\";\n$controller=1;\n\n\nforeach $i (@radius){\n    if (($controller++)%2==0){\n        $square-=3.141592653589793*$i*$i;\n        #print $i,\"chet\";\n    }else{\n        $square+=3.141592653589793*$i*$i;\n        #print $i,\"nechet\";\n    }\n}\n\nprint $square;"}, {"source_code": "sub sw($$){\n\tmy $swap=$_[0];\n\t$_[0]=$_[1];\n\t$_[1]=$swap;\n}\n\n\n$n=<STDIN>;\n$rads=<STDIN>;\n@radius=split(\" \",$rads);\n$square=0;\n$\\=\"\\n\";\n$controller=1;\n\n\n\n\nforeach $i (0 .. $n){\n\tforeach $j (0 .. ($n-1)){\n\t\tif ($radius[$j]<$radius[$j+1]){\n\t\t\tsw($radius[$j],$radius[$j+1]);\n\t\t}\n\t}\n}\n\nforeach $i (@radius){\n\tif (($controller++)%2==0){\n\t\t$square-=3.141592653589793*$i*$i;\n\t\tprint $i,\"chet\";\n\t}else{\n\t\t$square+=3.141592653589793*$i*$i;\n\t\tprint $i,\"nechet\";\n\t}\n}\n\nprint $square;"}], "src_uid": "48b9c68380d3bd64bbc69d921a098641"}
{"source_code": "<>;\n\nprint 2 ** ( () = ( sprintf \"%b\", $_ ) =~ /1/g ) . $/ for <>", "positive_code": [{"source_code": "#!/usr/bin/perl\n\n$t=<STDIN>;\nwhile ($t>0) {\n\t$x=<STDIN>;\n\t$w=1;\n\twhile ($x>0) {\n\t\tif ($x%2==1) {\n\t\t\t$w*=2;\n\t\t}\n\t\t$x/=2;\n\t}\n\tprint $w,\"\\n\";\n\t$t--;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\t\n\t$debug and print '-' x 10;\n\t\n\tmy $B = sprintf \"%b\", $_;\n\t\n\t$debug and do {\n\t\n\t\tprint \"         $_ -> $B\";\n\t\t\n\t\t$_ > 100 and next;\n\t\t\n\t\tmy $c = 0;\n\t\t\n\t\tfor my $i ( 0 .. 2 ** ( length $B ) - 1 ){\n\t\t\t$debug and print sprintf \" %b\", $i;\n\t\t\t\n\t\t\t$debug and print join ' ', ':', $_, $i, $_ ^ $i;\n\t\t\tmy $form = $_ - $i - ( $_ ^ $i );\n\t\t\t$debug and print ' ', $form;\n\t\t\t\n\t\t\t$c += ! $form;\n\t\t\t}\n\t\t\n\t\tprint \"$_ : $c\";\n\t\t\n\t\t};\n\t\n\tprint 2 ** ( () = $B =~ /1/g );\n\t}"}], "negative_code": [{"source_code": "<>;\n\nprint 2 ** ( () = ( sprintf \"%b\", $_ ) =~ /1/g ) for <>"}], "src_uid": "a896ba035e56dc707f8123b1e2f2b11c"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n   \nchomp (my $line = <STDIN>);\n\nmy $q = $line;\n\nfor (1..$q) {\n    chomp ($line = <STDIN>);\n    my ($n, $r) = split q{ }, $line;\n    chomp ($line = <STDIN>);\n    my @monsters = split q{ }, $line;\n\n    my $set = {};\n    for (@monsters) {\n        $set->{$_} = 1 if !defined $set->{$_};\n    }\n\n    @monsters = sort { $a <=> $b } keys %$set;\n\n    my $answer = 0;\n    my $i = @monsters-1;\n    while ( $i >= 0 ) {\n        if ( $monsters[$i] > $answer * $r ) {\n            $answer++;\n        }\n        $i--;\n    }\n\n    say $answer;\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $r ) = split;\n\t@_ = sort { $a <=> $b } split ' ', <>;\n\t\n\tmy $cnt = 0;\n\t\n\twhile( @_ ){\n\t\tmy $last = pop @_;\n\t\tif( @_ and $_[ @_ - 1 ] == $last ){\n\t\t\tnext;\n\t\t\t}\n\t\tif( $last - $cnt * $r > 0 ){\n\t\t\t$cnt ++;\n\t\t\t}\n\t\telse{\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tprint $cnt;\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n   \nchomp (my $line = <STDIN>);\n\nmy $q = $line;\n\nfor (1..$q) {\n    chomp ($line = <STDIN>);\n    my ($n, $r) = split q{ }, $line;\n    chomp ($line = <STDIN>);\n    my @monsters = split q{ }, $line;\n\n    my $set = {};\n    for (@monsters) {\n        $set->{$_} = 1 if !defined $set->{$_};\n    }\n\n    @monsters = sort keys %$set;\n\n    my $answer = 0;\n    while ( @monsters ) {\n        my $last = $monsters[-1];\n        while ( @monsters && $monsters[-1] == $last ) {\n            pop @monsters;\n        }\n        @monsters = grep { $_ > 0 } map { $_-1 } @monsters;\n        $answer++;\n    }\n    say $answer;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n   \nchomp (my $line = <STDIN>);\n\nmy $q = $line;\n\nfor (1..$q) {\n    chomp ($line = <STDIN>);\n    my ($n, $r) = split q{ }, $line;\n    chomp ($line = <STDIN>);\n    my @monsters = split q{ }, $line;\n\n    my $set = {};\n    for (@monsters) {\n        $set->{$_} = 1 if !defined $set->{$_};\n    }\n\n    @monsters = sort keys %$set;\n\n    my $answer = 0;\n    while ( @monsters ) {\n        my $last = $monsters[-1];\n        while ( @monsters && $monsters[-1] == $last ) {\n            pop @monsters;\n        }\n        @monsters = grep { $_ > 0 } map { $_-$r } @monsters;\n        $answer++;\n    }\n    say $answer;\n}\n"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n   \nchomp (my $line = <STDIN>);\n\nmy $q = $line;\n\nfor (1..$q) {\n    chomp ($line = <STDIN>);\n    my ($n, $r) = split q{ }, $line;\n    $r++;\n    chomp ($line = <STDIN>);\n    my @monsters = split q{ }, $line;\n\n    my $set = {};\n    for (@monsters) {\n        $set->{$_} = 1 if !defined $set->{$_};\n    }\n\n    @monsters = sort { $a <=> $b } keys %$set;\n\n    my $answer = 0;\n    my $i = 0;\n    while ( $i < @monsters ) {\n        if ( $r * $answer <= $monsters[$i] ) {\n            pop @monsters;\n            $answer++;\n        }\n        $i++;\n    }\n    say $answer;\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $r ) = split;\n\t@_ = split ' ', <>;\n\t\n\tmy $cnt = 0;\n\t\n\twhile( @_ ){\n\t\tmy $last = pop @_;\n\t\tif( $last - $cnt * $r > 0 ){\n\t\t\t$cnt ++;\n\t\t\t}\n\t\telse{\n\t\t\tlast;\n\t\t\t}\n\t\t}\n\t\n\tprint $cnt;\n\t}"}], "src_uid": "60b6c6f047051eeabfe4e3a9e045c6b0"}
{"source_code": "import strict;\nimport warnings;\n\n$_ = (<>, <>);\nmap {$me = $_; if($me >= $x){$k ++;}else{$k = 1;} if($k > $s) {$s = $k;} $x = $me; } split;\n\nprint \"$s\\n\";", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings FATAL => 'all';\nuse v5.20;\n\nmy $n = <>;\nmy @numbers = split(' ', <>);\n\nmy $result = 1;\nmy $local_result = 1;\n\nfor (my $i = 1; $i < @numbers; $i++)\n{\n    if ($numbers[$i] >= $numbers[$i-1])\n    {\n        $local_result++;\n    }\n    else\n    {\n        $result = $local_result if $local_result > $result;\n        $local_result = 1\n    }\n}\n$result = $local_result if $local_result > $result;\n\nsay $result;"}, {"source_code": "$_ = (<>, <>);\nmap { $_ >= $i ? ( $k ++, $k > $m and $m = $k ) : ( $k = 1 ), $i = $_  } split;\nprint $m"}, {"source_code": "my $n = <>;\nmy @array = split ' ', <>;\nmy $last = shift @array;\nmy $c = 1;\nmy $max_c = 1;\nwhile (my $a = shift @array) {\n    if ($a < $last) {\n      $max_c = $c if ($max_c < $c);\n      $c = 1;\n    }\n    else {\n      ++$c;   \n    }\n    $last = $a;\n}\n$max_c = $c if ($max_c < $c);\nprint $max_c;"}, {"source_code": "$_ = (<>, <>);\nmap { $_ >= $i ? ( $k ++, $k > $m and $m = $k ) : ( $k = 1 ), $i = $_  } split;\nprint $m"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\n<>;\nmy @a = split ' ', <>;\nmy $len = 1;\nmy $maxlen = 1;\nfor my $i (1..$#a) {\n    if ($a[$i - 1] <= $a[$i]) {\n        $len++;\n        $maxlen = $len if $len > $maxlen;\n    } else {\n        $len = 1;\n    }\n}\nprint \"$maxlen\\n\";\n"}, {"source_code": "<>;\nprint map {\n    $m = 0;\n    $i = 0;\n    $p = 0;\n    map {\n        $_ >= $p ? $i++ : do { $m < $i and $m = $i; $i = 1 };\n        $p = $_\n    } split;\n    $m < $i and $m = $i;\n    $m\n} $a = <>;\n"}, {"source_code": "<>;\nprint map {\n    $m = 0;\n    $i = 0;\n    $p = 0;\n    map {\n        $_ >= $p ? do { $i++, $i > $m and $m = $i } : do { $i = 1 };\n        $p = $_\n    } split;\n    $m\n} $a = <>;\n"}, {"source_code": "#!/bin/perl\n\n$n = <STDIN>;\n$s = <STDIN>;\n\nchomp $s;\n@ciong = split / +/, $s;\n\n$pop = 0;\n$maks = 0;\n$t = 0;\n\nfor($i=0;$i<$n;$i++)\n{\n\n  if(@ciong[$i] >= $pop)\n  {\n\n    $t++;\n\n    if( $t > $maks )\n    {\n\n      $maks = $t;\n\n    }\n\n  }\n  else\n  {\n\n    $t = 1;\n\n  }\n\n  $pop = @ciong[$i];\n\n}\n\nprint $maks;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @all = split \" \", <>;\n\n$n = 2_000_000_000;\nmy ($len, $mx) = (0, 0);\nfor my $i (@all){\n\tif ($i >= $n){\n\t\t$n = $i;\n\t\t++$len;\n\t}\n\telse {\n\t\t$len = 1;\n\t\t$n = $i;\n\t}\n\t$mx = $len if $len > $mx;\n}\nprint \"$mx\\n\";\n"}], "negative_code": [{"source_code": "<>;\nprint map {\n    $m = 0;\n    $i = 0;\n    $p = 0;\n    map {\n        $_ >= $p ? do { $p = $_; $i++ } : do { $m < $i and $m = $i; $i = 1 }\n    } split;\n    $m < $i and $m = $i;\n    $m\n} $a = <>;\n"}, {"source_code": "print map {\n    $m = 0;\n    $i = 0;\n    $p = 0;\n    map {\n        $_ >= $p ? do { $p = $_; $i++ } : do { $m < $i and $m = $i; $i = 1 }\n    } split;\n    $m < $i and $m = $i;\n    $m\n} $a = <>;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @all = split \" \", <>;\n\n$n = 2_000_000_000;\nmy ($len, $mx) = (0, 0);\nfor my $i (@all){\n\tif ($i >= $n){\n\t\t$n = $i;\n\t\t++$len;\n\t\t$mx = $len if $len > $mx;\n\t}\n\telse {\n\t\t$len = 1;\n\t\t$n = $i;\n\t}\n}\nprint \"$mx\\n\";\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nmy @all = split \" \", <>;\n\n$n = 2_000_000_000;\nmy ($len, $mx) = (0, 0);\nfor my $i (@all){\n\tif ($i >= $n){\n\t\t$n = $i;\n\t\t++$len;\n\t\t$mx = $len if $len > $mx;\n\t}\n\telse {\n\t\t$mx = $len if $len > $mx;\n\t\t$len = 1;\n\t\t$n = $i;\n\t}\n}\nprint \"$mx\\n\";\n"}, {"source_code": "$_ = (<>, <>);\nmap { $_ >= $i ? ( $i = $_, $k++, $k > $m and $m = $k ) : ( $k = 0, $i = 0 ) } split;\nprint $m"}, {"source_code": "$_ = (<>, <>);\nmap { $_ > $i ? ( $k++, $k > $m and $m = $k ) : ( $k = 0) } split;\nprint $m"}, {"source_code": "$_ = (<>, <>);\nmap { $_ > $i ? ( $i = $_, $k++, $k > $m and $m = $k ) : ( $k = 0, $i = 0 ) } split;\nprint $m"}], "src_uid": "1312b680d43febdc7898ffb0753a9950"}
{"source_code": "#!/bin/perl -w\nuse strict;\nuse warnings;\n\nmy ($n, $m) = map int, split /\\D/, <>;\nmy @prices = map int, split /\\D/, <>;\nmy %fruits;\nfor (1..$m) {\n    my $fruit = <>;\n    chomp $fruit;\n    if (defined $fruits{$fruit}) {\n\t$fruits{$fruit}++;\n    } else {\n\t$fruits{$fruit} = 1;\n    }\n}\n\n@prices = sort { $a <=> $b } @prices;\nmy ($cmin, $cmax, $in, $ix) = (0, 0, 0, $#prices);\nfor my $key (sort { $fruits{$b} <=> $fruits{$a} } keys %fruits) {\n    $cmin += $fruits{$key} * $prices[$in++];\n    $cmax += $fruits{$key} * $prices[$ix--];\n}\n\nprint \"$cmin $cmax\\n\";\n", "positive_code": [{"source_code": "($n, $m) = split(' ', <>);\n@pr = sort {$a <=> $b} split(' ', <>);\n\nwhile(<>){ $h{$_} ++; }\n\nfor(keys %h){ push (@c, $h{$_}); }\n\n@c = reverse(sort {$a <=> $b} @c);\n\nfor(0..$m){ $a += $c[$_] * $pr[$_]; }\nprint $a; $a = 0;\n@pr = reverse(@pr);\n\nfor(0..$m){ $a += $c[$_] * $pr[$_]; }\nprint \" $a\";"}], "negative_code": [], "src_uid": "31c43b62784a514cfdb9ebb835e94cad"}
{"source_code": "use bigint;\n$n = 0 + <>;\nif ($n->is_odd) {\n\t$x = ($n+1)/2;\n\t$y = ($n-1)/2;\n\t$a = 2*$x*$y;\n} else {\n\t$x = $n/2;\n\t$y = 1;\n\t$a = $x**2 - $y**2;\n}\n$b = $x**2 + $y**2;\nprint $a? \"$a $b\": -1", "positive_code": [{"source_code": "use bigint;\n\n\nmy $m, $n, $a, $b, $c;\nmy $i, $j;\n\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $g = $f;\n\nif ( $f <= 2 ) {\n    print \"-1\\n\";}\nelsif ( $g % 2 == 0 ) {\t\t# n is even \n    $g /= 2;\t\t\t\n    $a = $g * $g + 1;\n    $b = $g * $g - 1;\n    print \"$a $b\\n\";\n}\nelse {\t\t\t\t# n is odd\n    my $var = ($g * $g + 1) / 2;\n    my $uu = sqrt ( ($var * $var) - ($g * $g) );\n    print \"$var $uu\\n\";\n}\n\n"}], "negative_code": [{"source_code": "\n\nmy $m, $n, $a, $b, $c;\nmy $i, $j;\nmy $upper = int sqrt ( 10 ** 9 );\n\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $g = $f;\n# every even number is will be the side of a pythagorean triple\nif ( $f <= 2 ) {\n    print \"-1\\n\"; }\nelsif ( $g % 2 == 0 ) {\n    $a = $g * $g  + 1;\n    $b = $g * $g - 1;\n    print \"$a $b\\n\";\n}\nelse {\n\n\n    for ( $i = 1; $i < $upper and (not $found); $i += 1 ) {\n\tfor ( $j = $i + 1; $j < $upper and (not $found); $j += 1 ) {\n\t    $a = ($j ** 2) - ($i ** 2);\n\t    $b = 2 * $j * $i;\n\t    $c = ($j ** 2) + ($i ** 2);\n\t    if ( $a == $f or $b == $f or $c == $f ) {\n\t\tif ( $a != $f ) { print \"$a \";}\n\t\tif ( $b != $f ) { print \"$b \";}\n\t\tif ( $c != $f ) { print \"$c \";}\n\t\t$found = 1;}\n\t}\n    }\n\nif ( not $found ) { print \"-1\"; }\nprint \"\\n\";\n}\n\n"}, {"source_code": "\n\nmy $m, $n, $a, $b, $c;\nmy $i, $j;\n\nmy $f = <STDIN>;\nchomp ( $f );\n\nmy $g = $f;\n\nif ( $f <= 2 ) {\n    print \"-1\\n\";}\nelsif ( $g % 2 == 0 ) {\t\t# n is even \n    $g /= 2;\t\t\t\n    $a = $g * $g + 1;\n    $b = $g * $g - 1;\n    print \"$a $b\\n\";\n}\nelse {\t\t\t\t# n is odd\n    my $var = ($g * $g + 1) / 2;\n    my $uu = sqrt ( ($var * $var) - ($g * $g) );\n    print \"$var $uu\\n\";\n}\n\n"}], "src_uid": "df92643983d6866cfe406f2b36bec17f"}
{"source_code": "while (<>){\n    ($n, $_)=split/ /;\n    chomp;\n    @_=split/ /,<>;\n    chomp(@_);\n    @_=sort{$a<=>$b}@_;\n #   print \"@_\\n\";\n    $_>$n and print \"-1\\n\" and next;\n    $_=@_-$_;\n    unshift @_,-1;\n    $a=$_[$_+1];\n    $a==$_[$_] and print \"-1\\n\" and next;\n    print \"$a $a\\n\";\n    }", "positive_code": [{"source_code": "#!/usr/bin/perl -w\n\nuse strict;\n\nchomp($_ = <>);\nmy ($n, $k) = split;\nchomp($_ = <>);\nmy @a = split;\n@a = sort { -($a <=> $b) } @a;\nif ($k - 1 < $n) {\n    my $res = $a[$k - 1];\n    print \"$res $res\\n\";\n} else {\n    print \"-1\\n\";\n}\n"}], "negative_code": [{"source_code": "while (<>){\n    ($n, $_)=split/ /;\n    chomp;\n    @_=split/ /,<>;\n    chomp(@_);\n    @_=sort{$a<=>$b}@_;\n    print \"@_\\n\";\n    $_>$n and print \"-1\\n\" and next;\n    $_=@_-$_;\n    unshift @_,-1;\n    $a=$_[$_+1];\n    $a==$_[$_] and print \"-1\\n\" and next;\n    print \"$a $a\\n\";\n    }"}], "src_uid": "4d743a00e11510c824080ad7f1804021"}
{"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n   \nchomp (my $line = <STDIN>);\n\nmy $t = $line;\nmy @primes = (2, 3, 5, 7, 11);\n\nTESTCASE:\nfor (1..$t) {\n    chomp ($line = <STDIN>);\n    my ($x, $y) = split q{ }, $line;\n\n    my $z = $x - $y;\n\n    if ( $z == 1 ) { say \"no\"; next TESTCASE; }\n    else           { say \"yes\"; next TESTCASE; }\n}\n", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $x, $y ) = split;\n\t\n\tprint $x == $y + 1 ? \"NO\" : \"YES\";\n\t}"}], "negative_code": [], "src_uid": "0671972bc2b6452d51d048329e6e0106"}
{"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>", "positive_code": [{"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse utf8;\nuse v5.20;\n\nsub main {\n    my %args = @_;\n\n    my $lines = int(readline(STDIN)) || 0;\n\n    while ($lines--) {\n        my $world = readline(STDIN);\n        $world =~ s/(?<=^\\w).{9,}(?=\\w$)/length $&/e;\n        print $world;\n    }\n\n    return;\n}\n\nmain();\n\nexit;\n\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "chomp($num = <STDIN>);\nwhile($num-- > 0) {\n\tchomp($word = <STDIN>);\n\t$l = length($word);\n\tif($l < 11) {\n\t\tprint $word;\n\t} else {\n\t\tprint substr($word, 0, 1).($l-2).substr($word, -1, 1);\n\t}\n\tprint \"\\n\";\n}"}, {"source_code": "my $n = <>;\n\nwhile (<>) {\n    chomp;\n    \n    if (length($_) > 10) {\n        my ($f,$l) = $_ =~ /^(.).+(.)$/;\n        print $f . (length($_) - 2) . $l . \"\\n\";\n        next;\n    }\n    print $_ . \"\\n\";\n}"}, {"source_code": "use 5.010;\nuse strict;\nuse warnings;\n\nmy $n = <>;\nwhile ($n--) {\n  chomp( $_ = <> );\n  s/^(\\w)(\\w*)(\\w)$/$1 . length($2) . $3/e if length $_ > 10;\n  say;\n}\n"}, {"source_code": "$n = <>;\nfor my $i (1..$n)\n{\n\tchomp($s = <>);\n\t$len = length $s;\n\tif ($len > 10)\n\t{\n\t\t$res = substr($s, 0, 1).($len-2).substr($s, $len-1, 1);\n\t}\n\telse\n\t{\n\t\t$res = $s;\n\t}\n\tprint \"$res\\n\";\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nfor (1..$n) {\n\tmy $s = <>;\n\tchomp $s;\n\tmy $len = length $s;\n\tif ($len > 10) {\n\t\tsubstr($s,1,-1) = $len-2;\t\n\t}\n\tprint \"$s\\n\";\n}\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "$n=<>;\n\n\nfor($i=0;$i<$n;$i++){\n$str=<>;\nchomp$str;\npush(@arr,$str);\n}\nfor($i=0;$i<$n;$i++){\n$l=length$arr[$i];\nif($l<=10){\nprint \"$arr[$i]\\n\";\n}\nelse{\n$k=$l;\n$l-=2;\nprint substr($arr[$i],0,1).\"$l\".substr($arr[$i],$k-1,1).\"\\n\";\n\n}\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nchomp($n=<STDIN>);\nwhile($n--)\n{\nchomp ($str=<STDIN>);\nmy @array = split(//,$str);\n$c=$#array;\nif ($c<10)\n{\nprint \"$str\\n\";}\nelse\n{\n$m=$c-1;\nmy $e= pop(@array);\n$b= shift(@array);\nprint\"$b\";\nprint\"$m\";\nprint\"$e\\n\";\n}\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "#!/bin/perl\nuse strict;\nuse warnings;\nmy @chars = ();\nmy $line = '';\n\nchomp (my $line_n = <>);\nfor (1..$line_n) {\n    chomp($line = <>);\n    if (length($line) >= 11) {\n        @chars = $line =~ /./sg;\n        $line = \"$chars[0]\" . (length($line)-2) . \"$chars[-1]\";\n    }\n    print \"$line \\n\";\n}"}, {"source_code": "#!/bin/perl\nuse strict;\nuse warnings;\nmy @chars = ();\nmy $line = '';\nmy $l = 0;\n\nchomp (my $line_n = <>);\nfor (1..$line_n) {\n    chomp($line = <>);\n    $l = length($line);\n    if ($l >= 11) {\n        @chars = $line =~ /./sg;\n        $line = \"$chars[0]\" . ($l-2) . \"$chars[-1]\";\n    }\n    print \"$line \\n\";\n}"}, {"source_code": "    <>;\n    s/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "use strict;\nuse warnings;\nchomp (my $line_n = <>);\nmy @chars = ();\nmy $i = 0;\nmy $line = '';\nmy @out = ();\nmy $l = 0;\nfor ($i=0; $i<$line_n; $i++) {\n    chomp($line = <>);\n    $l = length($line);\n    if ($l < 11) {\n        $out[$i] = $line;\n    } else {\n        @chars = $line =~ /./sg;\n        $out[$i] = \"$chars[0]\" . ($l-2) . \"$chars[-1]\";\n    }\n}\nforeach (@out) {print \"$_ \\n\";}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for<>;"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "<STDIN>; while(<STDIN>){chomp; if((our $len = length $_) <= 10){ print \"$_\\n\"; }else{ print substr($_, 0, 1), $len-2, substr($_, -1, 1), \"\\n\" } }"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "use strict;\nuse warnings;\nuse feature \"say\";\n\nmy $n = <STDIN>;\n\nfor ($_ = 0; $_ < $n; $_++)\n{\n    my $word = <STDIN>;\n    chomp $word;\n    my $len = length $word;\n    if ($len > 10)\n    {\n        $word = substr($word, 0, 1) . ($len - 2) . substr($word, $len - 1, 1)\n    }\n    say $word;\n}\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "use v5.20;\n\nuse warnings;\nuse strict;\n\nmy $n = <>;\nchomp($n);\n\nwhile($n--)\n{\n\tmy $s =<>;\n\tchomp($s);\n\n\tif(length $s > 10)\n\t{\n\t\tmy $first = substr($s, 0, 1);\n\t\tmy $last = substr($s, -1);\n\t\tmy $length = (length $s) - 2;\n\t\tsay \"$first$length$last\";\n\t}\n\telse\n\t{\n\t\tsay \"$s\";\n\t}\n}\n\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "#!/usr/bin/perl -w\n\nfor (1..<>) {\n\t$_ = <>;\n\ts/\\B\\w{9,}\\B/length $&/e;\n\tprint $_;\n}\n\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse v5.012;\nuse warnings;\n\nchomp(my $count = <STDIN>);\n\nwhile ($count--) {\n\tchomp(my $word = <STDIN>);\n\tif (length $word > 10) {\n\t\t$word =~ /^(.)(.*)(.)$/;\n\t\t$word = $1 . (length $2) . $3;\n\t}\n\tsay $word;\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <STDIN>;\n\nwhile($n-- > 0){\n    my $s = <STDIN>;\n    chomp($s);\n    if(length($s) <= 10){\n        print \"$s\\n\";\n    }else{\n        print substr($s,0,1).(length($s)-2).substr($s,length($s)-1,1).\"\\n\";\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n$cases = <>; #number of cases\nwhile($cases--){    \n    $myname=<>; #get input name\n    $lengthofmyname=length($myname); #get its name\n    $lengthofmyname = $lengthofmyname+0; #covt to num for being safe\n    $maxlen=11; #maxlen permissible\n    if($lengthofmyname>$maxlen){ \n        $first=substr($myname,0,1); #get first letter\n        $last=substr($myname,$lengthofmyname-2,1); #get last letter\n        $lengthofmyname=$lengthofmyname-3; #decr by 3 as it returns one extra\n        print $first; \n        print $lengthofmyname;\n        print $last;\n        print \"\\n\";\n    }\n    else{\n        print \"$myname\\n\";\n    }\n}"}, {"source_code": "#!/usr/bin/env perl\n    \nuse strict;\nuse warnings;\nuse feature qw/ say /;\n    \nuse Carp;\n    \n# essential\nmy @tokens = ();\n    \nsub ceil {\n    my $n = shift;\n    my $in = int($n);\n    return $n if $in == $n;\n    return $in + 1;\n}\n    \nsub say_all {\n    my @args = @_;\n    say join ' ', @args;\n}\n    \nsub read_line {\n    chomp (my $line = <STDIN>);\n    return $line;\n}\n    \nsub read_token {\n    @tokens = split q{ }, read_line() if @tokens == 0;\n    return shift @tokens;\n}\n    \nsub min {\n    my @numbers = @_;\n    my $min = shift @numbers;\n    for ( @numbers ) {\n        $min = $min<$_ ? $min : $_;\n    }\n    return $min;\n}\n    \nsub max {\n    my @numbers = @_;\n    my $max = shift @numbers;\n    for ( @numbers ) {\n        $max = $max > $_ ? $max : $_;\n    }\n    return $max;\n}\n    \nsub sum {\n    my @numbers = @_;\n    my $sum = 0;\n    for (@numbers) {\n        $sum += $_;\n    }\n    return $sum;\n}\n    \nsub ref_ref_scalar {\n    my $ref = shift;\n    return 1 if ref($ref) eq 'SCALAR';\n}\n    \nsub toggle {\n    my $ref = shift;\n    croak \"$ref does not reference to scalar\" if !ref_ref_scalar($ref);\n    \n    $$ref = !$$ref;\n}\n    \nsub odd {\n    my $num = shift;\n    return $num % 2 == 1;\n}\n    \nsub even {\n    my $num = shift;\n    return $num % 2 == 0;\n}\n    \nsub sum_of_digits {\n    my $n = shift;\n    my @numbers = split q{}, $n;\n    \n    my $sum = 0;\n    \n    for (@numbers) {\n        $sum += $_;\n    }\n    \n    return $sum;\n}\n    \n# solution\n    \nmy $n = read_token;\n\nfor (1..$n) {\n    my $word = read_token;\n    my $len = length $word;\n    my $answer;\n    if ($len > 10) {\n        $answer = substr($word, 0, 1).($len-2).substr($word, $len-1, 1);\n    }\n    else {\n        $answer = $word;\n    }\n    say $answer;\n}\n"}, {"source_code": "<>;\nprint(map({\n    @x = split(\"\", $_);\n    $c = @x - 3;\n    @x > 11 ? \"$x[0]$c$x[-2]\\n\" : \"$_\"\n} <>))\n"}, {"source_code": "<>;\nprint(map({\n    @x = split(\"\", $_);\n    $c = @x - 3;\n    @x > 11 ? \"$x[0]$c$x[-2]\\n\" : \"$_\\n\"\n} <>))\n"}, {"source_code": "chomp($n = <STDIN>);\nwhile($n--)\n{\n    chomp($word = <STDIN>);\n    if (length($word) > 10)\n    {\n        $len = length($word) - 2;\n        $word =~ s/(^.).+?(.$)/$1$len$2/;\n        push @words, $word;\n    }\n    else\n    {\n        push @words, $word;\n    }\n}\n\nforeach $word (@words)\n{\n    print \"$word\\n\";\n}\n"}, {"source_code": "<>;for(<>){s/(?<=.).{9,}(?=.)/(length)-3/e;print}"}, {"source_code": "for$i(1..<>)\n{\n    $_=<>;\n    s/(?<=^.)(.{9,})(?=.$)/length($1)/e;\n    print;\n}"}, {"source_code": "$n = <>;\n\nfor ($i = 0; $i < $n; ++$i) {\n    $str = <>;\n    chomp $str;\n    $len = (length $str) - 2;\n    $str = substr ($str, 0, 1) . \"$len\" . chop ($str) if $len > 8; \n    print $str . \"\\n\";\n}\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "$n = <>;\n\nfor(1..$n) {\n\t$s = <>;\n\tchomp $s;\n\t$l = length $s;\n\n\tif ($l > 10) {\n\t\t@a = split \"\", $s;\n\t\t$s = $a[0].($l-2).$a[-1];\n\t}\n\n\tprint \"$s\\n\";\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "#!/usr/bin/perl;\n\n$n = <STDIN>;\n\nmy @words;\n\nfor ($i = 0; $i < $n; $i++) {\n\t$m = <STDIN>;\n\tpush(@words, $m);\n}\n\nfor ($i = 0; $i < $n; $i++) {\n\tif (length(@words[$i]) < 12) {\n\t\tprint(@words[$i]);\n\t} else {\n\t\tprint(substr(@words[$i], 0, 1),(length(@words[$i]) - 3),substr(@words[$i], -2, 1),\"\\n\");\n\t}\n}\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "#!/usr/bin/perl\nuse strict; use warnings;\n\nsub shorten\n{ my $s = $_[0]; my $n = length($s) - 3;\n  substr $s, 1, $n, $n if $n > 8; $s }\n\n<STDIN>;\nprint shorten $_ while <STDIN>\n"}, {"source_code": "my $n = <>;\nmy $s;\n\nfor (my $i = 0; $i < $n; $i++) {\n\t$s = <>;\n\t$s =~ s/([A-z])([A-z]{9,})([A-z])/$1 . (length ($2)) . $3/e;\n\tprint $s;\n}"}, {"source_code": "#!/usr/bin/perl\n\n$n = <>;\n\nwhile($n--){\n\t$word = <>;\n\t\n\t$len = length($word) - 1;\n\tif($len <11){\n\t\tprint \"$word\\n\";\n\t}\n\telse{\n\t\t$mid = $len - 2;\n\t\t@chars = split(\"\",$word);\n\t\tprint \"$chars[0]$mid$chars[$len-1]\\n\";\n\t}\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "my $n = <STDIN>;\nwhile($n--) {\n    my $s = <STDIN>;\n    if((length($s) -1) > 10) {\n        print substr($s, 0, 1).(length($s) - 3).substr($s, length($s) - 2, 1).\"\\n\";\n    }\n    else {\n        print $s;\n    }\n}"}, {"source_code": "$n = <>;\nfor(1..$n) {\n    $s = <>;\n    chomp $s;\n    @a = split \"\", $s;\n    $n = scalar @a;\n    if( $n > 10 ) {\n        $s = $a[0] . (scalar @a - 2) . $a[-1];\n    }\n    print  \"$s\\n\";\n}"}, {"source_code": "my $n = <STDIN>;\nwhile($n--) {\n    my $s = <STDIN>;\n    chomp($s);\n    if(length($s) > 10) {\n        print substr($s, 0, 1).(length($s) - 2).substr($s, length($s) - 1, 1).\"\\n\";\n    }\n    else {\n        print $s.\"\\n\";\n    }\n}"}, {"source_code": "$n = <>;\nfor(1..$n) {\n    $s = <>;\n    chomp $s;\n    @a = split \"\", $s;\n    $n = scalar @a;\n    \n    if( $n > 10 ) {\n        $s = $a[0] . ($n - 2) . $a[-1];\n    }\n    print $s . \"\\n\";\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "$n = <>;\nfor(1..$n) {\n    $s = <>;\n    chomp $s;\n    $n = length($s);\n    \n    if( $n > 10 ) {\n        $s = substr($s, 0, 1) . ($n - 2) . substr($s, -1, 1);\n    }\n    print $s . \"\\n\";\n}"}, {"source_code": "#!/usr/bin/perl\n# your code goes here\nuse v5.10;\n\nchomp ($n = <>);\nwhile ($n-- > 0) {\n\tchomp($line = <>);\n\t$len = length($line)-2;\n\t$line_ = substr($line, 0, 1) . \"$len\" . substr($line, $len+1, 1);\n\t$len<=8 and say $line or say $line_;\n}\n"}, {"source_code": "$n = <STDIN>;\nfor($i=0;$i<=$n-1;$i++)\n{\n        $word = <STDIN>;\n        @chars = split(\"\",$word);\n        $l1 = split(\"\",$word);\n        $l = $l1-1; #Newline character\n        $d = $l-2;\n        if($l>10)\n        {\n                @word[$i] = \"@chars[0]$d@chars[$l-1]\";\n        }\n        else\n        {\n                @word[$i] = substr($word,0,$l);\n        }\n\n}\n\nfor($i=0;$i<$n;$i++)\n{\n        print \"@word[$i]\\n\"\n}\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $input_lines = <>;\nmy @words;\nfor (1..$input_lines) {\n    my $line = <>;\n    chomp $line;\n    push @words, $line;\n}\n\nmy $max_len = 10;\n\nfor my $word (@words) {\n    my $word_len = length($word);\n    if ( $word_len > $max_len ) {\n        print substr($word, 0, 1) . ($word_len-2) . substr($word, $word_len-1, 1) . \"\\n\";\n    } else {\n        print \"$word\\n\";\n    }\n}\n\n"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy $i=<>;\nwhile ($i--){\nmy $a=<>;\nif(($b=length($a)-3)>8) {print substr($a,0,1),$b,substr($a,-2,1),\"\\n\";} else {print \"$a\\n\";}\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>"}, {"source_code": "use strict; \nuse warnings; \n\nsub main\n{\n    my $input = <STDIN>;\n    my @words;\n    my $word;\n    my $newWord=\"\";\n    my $wordLen;\n    for(my $i=0;$i<$input;$i++){\n        my $inputwords = <STDIN>;\n        push @words, $inputwords;\n    }\n    for(my $i=0;$i<$input;$i++){        \n        $word = shift @words;\n        $wordLen = length($word);\n        if($wordLen-1>10){\n            $wordLen=$wordLen-3;\n            my $headword = substr($word,0,1);\n            my $tailword = substr($word,length($word)-2,1);\n            $newWord = $headword.$wordLen.$tailword;\n            printf(\"$newWord\\n\");\n        }\n        else{\n            printf(\"$word\");\n        }\n    }\n}\n\nmain();"}, {"source_code": "<>;\nwhile(<>){\nchomp;\nif (10<length$_){\n \ns/^(.)(.*)(.)$/$1.(length$2).$3/e;\n \n}\nprint\"$_\\n\"\n \n}"}, {"source_code": "#!/usr/bin/perl\n$n = <>;\nfor(1..$n) {\n    $str = <>;\n    chop $str;\n    $l = length($str);\n    if($l > 10) {\n        $str =~ s/(.).+(.)/$1.($l-2).$2/e;\n    }\n    print $str, \"\\n\";\n}\n"}, {"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse v5.10;\n\n<STDIN>;\nfor (<STDIN>) {\n    chomp;\n    s/^(.)(.+)(.)$/$1.length($2).$3/e if length > 10;\n    say;\n}\n        "}, {"source_code": "<>;for(<>){s/(?<=.).{9,}(?=.)/(length)-3/e;print}\n"}, {"source_code": "<>;for(<>){$_=$1.((length)-3).$2 if/(.).{9,}(.\\s)/;print}\n"}, {"source_code": "<>;for(<>){$_=$1.(length$2).$3.\"\\n\"if/(.)(.{9,})(.)/;print}\n"}, {"source_code": "#!perl\n\nmy $num = <STDIN>;\nfor (1..$num) {\n    my $word = <STDIN>;\n    chomp $word;\n    my @word = split //, $word;\n    (@word > 10) ? print $word[0], @word - 2 , $word[-1],\"\\n\" : print $word, \"\\n\";\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "my $len = <STDIN>;\n\nfor my $val (1 .. $len) {\n\tmy $word = <STDIN>;\n\t$word =~ s/\\s//g;\n\n\tmy $word_length = length $word;\n\n\tif ($word_length > 10) {\n\t\tmy $f_let = substr $word, 0, 1;\n\t\tmy $l_let = substr $word, $word_length - 1, 1;\n\t\t\n\t\tprint $f_let.($word_length - 2).$l_let.\"\\n\";\n\t} else {\n\t\tprint $word.\"\\n\";\n\t}\n}\n"}, {"source_code": "use 5.020;\n\nreadline;\n\nwhile(<>) {\n   chomp;\n   s/(.)(.+)(.)/$1 . length($2) . $3/e if length $_ > 10;\n   say;\n}\n"}, {"source_code": "<>;for(<>){s/(?<=.).{9,}(?=.)/(length)-3/e;print}"}, {"source_code": "my $a = <>;\nforeach (0 .. $a)\n{\n    my $str = <>;\n    chomp $str;\n    if (length $str <= 10) {\n        print $str, \"\\n\";\n    } else {\n        print substr ($str, 0, 1), (length $str) - 2, substr ($str, -1, 1), \"\\n\";\n    }\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/e, print for <>\n"}, {"source_code": "$n = <STDIN>;\nfor ( $i = 0 ; $i < $n ; $i++ ) {\n\t$s = <STDIN>;\n\tchomp $s;\n\tif ( $s =~ /(\\w)(\\w{9,})(\\w)/ ) {\n\t\tprint \"$1\" . ( length($2) ) . \"$3\\n\";\n\t}\n\telse {\n\t\tprint \"$s\\n\";\n\t}\n}\n"}, {"source_code": "my $n = <>;\nmy $str;\nmy @arr;\nfor(1..$n) {\n    $str = <>;\n    chomp $str;\n    @arr = split \"\", $str;\n    $str =  $arr[0] . (scalar @arr-2) . $arr[-1] if (scalar @arr > 10);\n    print $str . \"\\n\";\n}"}, {"source_code": "\n$n = <STDIN>;\nwhile($n != 0) {\n\t$s = <STDIN>;\n\tif(length($s) - 1 > 10) {\n\t\tprint substr($s, 0, 1) . (length($s) - 3) . substr($s, length($s) - 2, 1) . \"\\n\";\n\t} else {\n\t\tprint \"$s\";\n\t}\n\t$n--;\n}\n\n# 4\n# word\n# localization\n# internationalization\n# pneumonoultramicroscopicsilicovolcanoconiosis\n\n# Выходные данные\n\n# word\n# l10n\n# i18n\n# p43s\n"}, {"source_code": "# Author Badhan Sen\n# CSE-14, JUST\n\n# 71A. Way Too Long Words\n# Accepted\n\nmy $num=<>;\n\nwhile($num--){\n\tmy $str=<>;\n\t\n\tif(length($str)-1 > 10){\n\t\tprint substr($str, 0, 1).(length($str)-3).substr($str, length($str)-2, 1);\n\t\tprint \"\\n\";\n\t}\n\telse{\n\t\tprint $str;\n\t\tprint \"\\n\";\n\t}\n}"}, {"source_code": "#!/usr/bin/env perl\n\n\nchomp(my $n = <STDIN>);\n\nfor ( 0..$n - 1 )\n{\n\tchomp(my $word = <STDIN>);\n\n\tif ( length($word) > 10 )\n\t{\n\t\t$word = substr($word, 0, 1).(length($word) - 2).substr($word, length($word) - 1);\n\n\t}\n\n\tprint(\"$word\\n\");\n\n}\n\n\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse utf8;\nuse v5.20;\n\nsub main {\n    my $lines = int(readline(STDIN)) || 0;\n\n    while ($lines--) {\n        my $word = readline(STDIN);\n        chomp $word;\n        say length $word <= 10\n            ? $word\n            : substr($word, 0, 1 ) . length(substr($word, 1, -1)) . substr($word,-1);\n    }\n\n    return;\n}\n\nmain();\n\nexit;\n\n"}], "negative_code": [{"source_code": "use strict; \nuse warnings; \n\nsub main\n{\n    my $input = <STDIN>;\n    my @words;\n    my $word;\n    my $newWord=\"\";\n    my $wordLen;\n    for(my $i=0;$i<$input;$i++){\n        my $inputwords = <STDIN>;\n        push @words, $inputwords;\n    }\n    for(my $i=0;$i<$input;$i++){        \n        $word = shift @words;\n        $wordLen = length($word);\n        if($wordLen>10){\n            $wordLen=$wordLen-3;\n            my $headword = substr($word,0,1);\n            my $tailword = substr($word,length($word)-2,1);\n            $newWord = $headword.$wordLen.$tailword;\n            printf(\"$newWord\\n\");\n        }\n        else{\n            printf(\"$word\");\n        }\n    }\n}\n\nmain();"}, {"source_code": "#! perl -lp\nnext if $. == 1;\ns/^(\\w)(\\w*)(\\w)$/$1 . length($2) . $3/e if length $_ > 10;\n"}, {"source_code": "use strict;\nuse warnings;\n\nmy $n = <>;\nfor (1..$n) {\n\tmy $s = <>;\n\tchomp $s;\n\tmy $len = length $s;\n\tif ($len > 10) {\n\t\tsubstr($s,1,-2) = $len-2;\t\n\t}\n\tprint \"$s\\n\";\n}\n"}, {"source_code": "$n=<>;\n\n\nfor($i=0;$i<$n;$i++){\n$str=<>;\nchomp$str;\npush(@arr,$str);\n}\nfor($i=0;$i<$n;$i++){\n$l=length$arr[$i];\nif($l<10){\nprint \"$arr[$i]\\n\";\n}\nelse{\n$k=$l;\n$l-=2;\nprint substr($arr[$i],0,1).\"$l\".substr($arr[$i],$k-1,1).\"\\n\";\n\n}\n}\n"}, {"source_code": "$n=<>;\n\n\nfor($i=0;$i<$n;$i++){\n$str=<>;\nchomp$str;\npush(@arr,$str);\n}\nfor($i=0;$i<$n;$i++){\n$l=length$arr[$i];\nif($l<10){\nprint \"$arr[$i]\\n\";\n}\nelse{\n$l-=2;\nprint substr($arr[$i],0,1).\"$l\".substr($arr[$i],$l-1,1).\"\\n\";\n\n}\n}\n"}, {"source_code": "#!/usr/bin/perl\n\nchomp($str=<STDIN>);\nmy @array = split(//,$str);\n$c=$#array;\nif ($c<=10)\n{\nprint \"$str\\n\";}\nelse\n{\n$m=$c-2;\nmy $e= pop(@array);\n$b= shift(@array);\nprint\"$b\";\nprint\"$m\";\nprint\"$e\";\n}"}, {"source_code": "#!/usr/bin/perl\n\nchomp($n=<STDIN>);\nwhile($n--)\n{\nchomp ($str=<STDIN>);\nmy @array = split(//,$str);\n$c=$#array;\nif ($c<=10)\n{\nprint \"$str\\n\";}\nelse\n{\n$m=$c-2;\nmy $e= pop(@array);\n$b= shift(@array);\nprint\"$b\";\nprint\"$m\";\nprint\"$e\\n\";\n}\n}"}, {"source_code": "#!/usr/bin/perl\n\nchomp($n=<STDIN>);\nwhile($n--)\n{\nchomp ($str=<STDIN>);\nmy @array = split(//,$str);\n$c=$#array;\nif ($c<=10)\n{\nprint \"$str\\n\";}\nelse\n{\n$m=$c-1;\nmy $e= pop(@array);\n$b= shift(@array);\nprint\"$b\";\nprint\"$m\";\nprint\"$e\\n\";\n}\n}"}, {"source_code": "#!/bin/perl\nuse strict;\nuse warnings;\n\nchomp (my $line_n = <>);\nmy @chars = ();\nmy $i = 0;\nmy $line = '';\nmy @out = ();\nmy $l = 0;\nfor ($i=0; $i<$line_n; $i++) {\n    chomp($line = <>);\n    $l = length($line);\n    if ($l < 10) {\n        $out[$i] = $line;\n    } else {\n        @chars = $line =~ /./sg;\n        $out[$i] = \"$chars[0]\" . ($l-2) . \"$chars[-1]\";\n    }\n}\nforeach (@out) {\n    print \"$_ \\n\";\n}"}, {"source_code": "<STDIN>; while(<STDIN>){chomp; if((our $len = length $_) <= 10){ print \"$_\\n\"; }else{ print substr($_, 0, 1), $len, substr($_, -1, 1), \"\\n\" } }"}, {"source_code": "#!/usr/bin/perl -w\n\nfor (1..<>) {\n\t$_ = <>;\n\ts/\\B\\w{8,}\\B/length $&/e;\n\tprint \"$_\\n\";\n}\n\n"}, {"source_code": "#!/usr/bin/perl\n$inputlines=<>;\nwhile($inputlines--){\n    $word=<>;\n    $len = length $word;\n    if($len > 10){\n        #then unpack them in array and print abbvr\n        $len -=2;\n        $first=substr($word,0,1);\n        $last=substr($word,$len,1);\n        $len=$len-1;\n        print $first;\n        print $len;\n        print $last;\n        print \"\\n\";\n    }\n    else{\n        print \"$word\\n\";\n    }\n}"}, {"source_code": "#!/usr/bin/perl\n$inputlines=<>;\nwhile($inputlines--){\n    $word=<>;\n    $len = length $word;\n    if($len > 10){\n        #then unpack them in array and print abbvr\n        $len -=2;\n        $first=substr($word,0,1);\n        $last=substr($word,$len,1);\n        print $first;\n        print $len;\n        print $last;\n        print \"\\n\";\n    }\n    else{\n        print \"$word\\n\";\n    }\n}"}, {"source_code": "<>;\nprint(map({\n    @x = split(\"\", $_);\n    $c = @x - 3;\n    @x > 10 ? \"$x[0]$c$x[-2]\\n\" : \"$_\\n\"\n} <>))\n"}, {"source_code": "for$i(1..<>)\n{\n    $_=<>;\n    s/(?<=^.)(.{10,})(?=.$)/length($1)/e;\n    print;\n}"}, {"source_code": "$s = <>;\nchomp $s;\n\n$n = length $s;\n\nif ($n > 10) {\n\t@a = split \"\", $s;\n\t$s = $a[0].($n-2).$a[-1];\n}\n\nprint \"$s\\n\";"}, {"source_code": "#!/usr/bin/perl;\n\n$n = <STDIN>;\n\nmy @words;\n\nfor ($i = 0; $i < $n; $i++) {\n\t$m = <STDIN>;\n\tpush(@words, $m);\n}\n\nfor ($i = 0; $i < $n; $i++) {\n\tif (length(@words[$i]) < 11) {\n\t\tprint(@words[$i]);\n\t} else {\n\t\tprint(substr(@words[$i], 0, 1),(length(@words[$i]) - 3),substr(@words[$i], -2, 1),\"\\n\");\n\t}\n}\n"}, {"source_code": "@in = <>;\n$n = $in;\nprint $in;\nprint \"\\n\";\nprint $n;\nprint \"\\n\";\nfor($i = 1; $i < $n; $i++) {\n    print $in[$i];\n}"}, {"source_code": "@in = <>;\n$n = $in;\nfor($i = 1; $i < $n; $i++) {\n    print $in[$i];\n}"}, {"source_code": "@in = <STDIN>;\n$n = $in;\nprint $in;"}, {"source_code": "$n = <>;\nfor(1..$n) {\n    $s = <>;\n #   chomp $s;\n    @a = split \"\", $s;\n    $n = scalar @a;\n    if( $n > 10 ) {\n        $s = $a[0] . ($n - 2) . $a[-1];\n    }\n    print  \"$s\\n\";\n}"}, {"source_code": "<>;\ns/\\B.{9,}\\B/length$&/, print for <>"}, {"source_code": "<>;\ns/\\B.{8,}\\B/length$&/e, print for <>"}, {"source_code": "<>;\ns/\\B.{8,}\\B/length$&/, print for <>"}, {"source_code": "<>;for(<>){s/(?<=.).{9,}(?=.)/length-3/e;print}\n"}, {"source_code": "#!perl\n\nmy $num = <STDIN>;\nfor (1..$num) {\n    my $word = <STDIN>;\n    chomp $word;\n    my @word = split //, $word;\n    (@word > 10) ? print $word[0] , length $word - 2 , $word[-1],\"\\n\" : print $word, \"\\n\";\n}"}, {"source_code": "use 5.020;\n\nmy $len = <> * 2;\n\nwhile(<>) {\n   chomp;\n   s/(.)(.+)(.)/$1 . length($2) . $3/e if length $_ > $len;\n   say;\n}\n"}, {"source_code": "use 5.020;\n\nmy $len = <>;\nchomp $len;\n\nwhile(<>) {\n   chomp;\n   s/(.)(.+)(.)/$1 . length($2) . $3/e if length $_ > $len;\n   say;\n}\n"}, {"source_code": "use 5.020;\n\nmy $len = <>;\nchomp $len;\n\nfor(<>) {\n   chomp;\n   next if length $_ <= $len;\n   s/(.)(.+)(.)/$1 . length($2) . $3/e;\n}\n"}, {"source_code": "use 5.020;\n\nmy $len = <>;\nchomp $len;\n\nwhile(<>) {\n   chomp;\n   next if length $_ <= $len;\n   s/(.)(.+)(.)/$1 . length($2) . $3/e;\n   say;\n}\n"}, {"source_code": "$n = <>;\nforeach $i (1..n)\n{\n$A=<>;\nif (length($A)>10)\n{\n$A=substr($A,0,1) . \"length($A)-2\" . substr($A,-1,1)\n}\nprint $A\n}"}, {"source_code": "$n = <>;\nforeach $i (1..n)\n{\n$A=<>;\nif (length($A)>10)\n{\n$A=substr($A,0,1)+\"length($A)-2\"+substr($A,-1,1)\n}\nprint $A\n}"}, {"source_code": "$n = <STDIN>;\nfor ( $i = 0 ; $i < $n ; $i++ ) {\n\t$s = <STDIN>;\n\tchomp $s;\n\tif ( $s =~ /(\\w)(\\w{8,})(\\w)/ ) {\n\t\tprint \"$1\" . ( length($2) ) . \"$3\\n\";\n\t}\n\telse {\n\t\tprint \"$s\\n\";\n\t}\n}\n"}, {"source_code": "$n = <STDIN>;\nfor ( $i = 0 ; $i < $n ; $i++ ) {\n\t$s = <STDIN>;\n\tif ( $s =~ /(\\w)(\\w{10,})(\\w)/ ) {\n\t\tprint \"$1\" . ( length($2) ) . \"$3\\n\";\n\t}\n\telse {\n\t\tprint \"$s\\n\";\n\t}\n}\n"}, {"source_code": "\n$n = <STDIN>;\nwhile($n != 0) {\n\t$s = <STDIN>;\n\tif(length($s) > 10) {\n\t\tprint substr($s, 0, 1) . (length($s) - 3) . substr($s, length($s) - 2, 1) . \"\\n\";\n\t} else {\n\t\tprint \"$s\";\n\t}\n\t$n--;\n}\n\n# 4\n# word\n# localization\n# internationalization\n# pneumonoultramicroscopicsilicovolcanoconiosis\n\n# Выходные данные\n\n# word\n# l10n\n# i18n\n# p43s\n"}, {"source_code": "#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\nuse utf8;\nuse v5.20;\n\nsub main {\n    my %args = @_;\n\n    my $lines = int(readline(STDIN)) || 0;\n\n    while ($lines--) {\n        my $world = readline(STDIN);\n        $world =~ s/(?<=^\\w).{6,}(?=\\w$)/length $&/e;\n        print $world;\n    }\n\n    return;\n}\n\nmain();\n\nexit;\n\n"}, {"source_code": "my $n = <STDIN>;\nwhile($n--) {\n    my $s = <STDIN>;\n    if((length($s) -1) >= 10) {\n        print substr($s, 0, 1).(length($s) - 3).substr($s, length($s) - 2, 1);\n    }\n    else {\n        print $s;\n    }\n}"}, {"source_code": "my $n = <STDIN>;\nwhile($n--) {\n    my $s = <STDIN>;\n    chomp($s);\n    if(length($s) > 10) {\n        print substr($s, 0, 1).(length($s) - 2).substr($s, length($s) - 1, 1).\"\\n\";\n    }\n    else {\n        print $s;\n    }\n}"}, {"source_code": "my $n = <STDIN>;\nwhile($n--) {\n    my $s = <STDIN>;\n    if((length($s) -1) >= 10) {\n        print substr($s, 0, 1).(length($s) - 3).substr($s, length($s) - 2, 1).\"\\n\";\n    }\n    else {\n        print $s;\n    }\n}"}, {"source_code": "use strict;\nuse warnings;\n\nmy $input_lines = <>;\nmy @words;\nprint \"\\n***\\n\";\nfor (1..$input_lines) {\n    my $line = <>;\n    chomp $line;\n    push @words, $line;\n}\n\nmy $max_len = 10;\n\nfor my $word (@words) {\n    my $word_len = length($word);\n    if ( $word_len > $max_len ) {\n        print substr($word, 0, 1) . ($word_len-2) . substr($word, $word_len-1, 1) . \"\\n\";\n    } else {\n        print \"$word\\n\";\n    }\n}\n\n"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\n\nmy $i=<>;\nwhile ($i--){\nmy $a=<>;\nif(($b=length($a)-3)>7) {print substr($a,0,1),$b,substr($a,-2,1),\"\\n\";} else {print \"$a\\n\";}\n}"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\nmy $i=<>;\nwhile ($i--){\nmy $a=<>;\nif(($b=length($a)-3)>7) {print substr($a,0,1),$b,substr($a,-2,1);} else {print $a;}\n}"}, {"source_code": "#!/usr/bin/perl -w\nuse strict;\nmy $i=<>;\nwhile ($i--){\nmy $a=<>;\nif(($b=length($a)-2)>8) {print substr($a,0,1),$b,substr($a,-1,1);} else {print $a;}\n}"}], "src_uid": "6639d6c53951f8c1a8324fb24ef68f7a"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy $max = -~0;\n\tmy $min = ~0;\n\tmy $M;\n\tmy $MM;\n\t\n\tfor my $i ( 0 .. @A - 1 ){\n\t\tmy $max = -~0;\n\t\tmy $M;\n\t\tfor my $j ( @A[ 0 .. $i - 1, $i + 1 .. @A - 1 ] ){\n\t\t\tfor my $k ( @B ){\n\t\t\t#\tprint \" $i $j $k\";\n\t\t\t\t$max < $j * $k and do { $max = $j * $k; $M = \"$j $k\" };\n\t\t\t\t}\n\t\t\t}\n\t\t$min > $max and do { $min = $max; $MM = $M };\n\t\t}\n\t\n\tuse bigint;\n\tprint 0 + eval join ' * ', split ' ', $MM;\n\tno bigint;\n\t}", "positive_code": [{"source_code": "<>;\n\n@A = split ' ', <>;\n@B = split ' ', <>;\n\t\nfor $i ( @A ){\n\tpush @M, ( sort { $b <=> $a } map $i * $_, @B )[ 0 ]\n\t}\n\nprint +( sort { $a <=> $b } @M )[ -2 ]"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy $max = -~0;\n\tmy $min = ~0;\n\tmy $M;\n\tmy @M;\n\t\n\t$debug and print \"$max|$min\";\n\t\n\tfor my $i ( @A ){\n\t\tmy $max = -~0;\n\t\tfor my $j ( @B ){\n\t\t\t$debug and print \" $i $j | \", $j * $i;\n\t\t\t$max < $j * $i and do { $max = $j * $i; $M = \"$j $i\" };\n\t\t\t}\n\t\tpush @M, [ $max, $M ];\n\t\t}\n\t\n\tuse bigint;\n\tprint 0 + eval join ' * ', split ' ', join '', map $_->[ 1 ], ( sort { $a->[ 0 ] <=> $b->[ 0 ] } @M )[ -2 ];\n\tno bigint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy $max = -~0;\n\tmy $min = ~0;\n\tmy $M;\n\tmy @M;\n\t\n\t$debug and print \"$max|$min\";\n\t\n\tfor my $i ( @A ){\n\t\tmy $max = -~0;\n\t\tfor my $j ( @B ){\n\t\t\t$debug and print \" $i $j | \", $j * $i;\n\t\t\t$max < $j * $i and do { $max = $j * $i; $M = \"$j $i\" };\n\t\t\t}\n\t\tpush @M, [ $max, $M ];\n\t\t}\n\t\n#\tuse bigint;\n\tprint 0 + eval join ' * ', split ' ', join '', map $_->[ 1 ], ( sort { $a->[ 0 ] <=> $b->[ 0 ] } @M )[ -2 ];\n#\tno bigint;\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy @M;\n\t\t\n\tfor $i ( @A ){\n\t\t$max = -~0;\n\t\tfor $j ( @B ){\n\t\t\t$max < $j * $i and $max = $j * $i;\n\t\t\t}\n\t\tpush @M, $max;\n\t\t}\n\t\n\tprint +( sort { $a <=> $b } @M )[ -2 ]\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy $max = -~0;\n\tmy $min = ~0;\n\tmy $M;\n\tmy $MM;\n\t\n\tfor my $i ( 0 .. @A - 1 ){\n\t\tmy $max = -~0;\n\t\tmy $M;\n\t\tfor my $j ( @A[ 0 .. $i - 1, $i + 1 .. @A - 1 ] ){\n\t\t\tfor my $k ( @B ){\n\t\t\t\tprint \" $i $j $k\";\n\t\t\t\t$max < $j * $k and do { $max = $j * $k; $M = \"$j $k\" };\n\t\t\t\t}\n\t\t\t}\n\t\t$min > $max and do { $min = $max; $MM = $M };\n\t\t}\n\t\n\tuse bigint;\n\tprint 0 + eval join ' * ', split ' ', $MM;\n\tno bigint;\n\t}"}], "src_uid": "c408b1d198c7c88fc635936d960c962a"}
{"source_code": "$deg=<>;\nif($deg==1){\n    print \"YES\\n2 1\\n1 2\" and exit;\n}\nif($deg%2==0){\n    print \"NO\" and exit;\n}\n$n=($deg+2)*2;\n$m=($deg+2)*$deg;\n$cnt=($deg-1)/2;\nprint \"YES\\n$n $m\\n\";\nfor($i=1;$i<=$deg+1;$i++){\n    for($j=$i+1;$j<=$deg+1;$j++){\n        if($cnt>0 && !$tag){\n            $cnt--;\n            push @stack,($i,$j);\n            $tag=2;\n            next;\n        }\n        print \"$i $j\\n\";\n        $_i=$n+1-$i;\n        $_j=$n+1-$j;\n        print \"$_i $_j\\n\";\n    }\n    $tag--;\n}\n$mid=$deg+2; $mid2=$n+1-$mid;\nprint \"$mid $mid2\\n\";\nwhile(@stack){\n    $a = pop @stack;\n    $b = pop @stack;\n    print \"$a $mid\\n$b $mid\\n\";\n    $a=$n+1-$a; $b=$n+1-$b;\n    print \"$a $mid2\\n$b $mid2\\n\";\n}", "positive_code": [{"source_code": "$deg=<>;\nprint \"YES\\n2 1\\n1 2\" and exit if($deg==1);\nprint \"NO\" and exit if($deg%2==0);\n$n=($deg+2)*2; $m=($deg+2)*$deg; $cnt=($deg-1)/2;\nprint \"YES\\n$n $m\\n\";\nfor($i=1;$i<=$deg+1;$i++){\n    for($j=$i+1;$j<=$deg+1;$j++){\n        if($cnt>0 && !$tag){\n            $cnt--; $tag=2;\n            push @stack,($i,$j) and next;\n        }\n        print \"$i $j\\n\";\n        ($_i,$_j)=wrp($i,$j);\n        print \"$_i $_j\\n\";\n    }\n    $tag--;\n}\n$mid=$deg+2; $mid2=$n+1-$mid;\nprint \"$mid $mid2\\n\";\nwhile(@stack){\n    $a = pop @stack;\n    $b = pop @stack;\n    print \"$a $mid\\n$b $mid\\n\";\n    ($a,$b)=wrp($a,$b);\n    print \"$a $mid2\\n$b $mid2\\n\";\n}\nsub wrp{return ($n+1-@_[0],$n+1-@_[1]);}"}, {"source_code": "$deg=<>;\nprint \"YES\\n2 1\\n1 2\" and exit if($deg==1);\nprint \"NO\" and exit if($deg%2==0);\n$n=($deg+2)*2; $m=($deg+2)*$deg; $cnt=($deg-1)/2;\nprint \"YES\\n$n $m\\n\";\nfor($i=1;$i<=$deg+1;$i++){\n    for($j=$i+1;$j<=$deg+1;$j++){\n        if($cnt>0 && !$tag){\n            $cnt--; $tag=2;\n            push @stack,($i,$j);\n            next;\n        }\n        print \"$i $j\\n\";\n        $_i=$n+1-$i;\n        $_j=$n+1-$j;\n        print \"$_i $_j\\n\";\n    }\n    $tag--;\n}\n$mid=$deg+2; $mid2=$n+1-$mid;\nprint \"$mid $mid2\\n\";\nwhile(@stack){\n    $a = pop @stack;\n    $b = pop @stack;\n    print \"$a $mid\\n$b $mid\\n\";\n    $a=$n+1-$a; $b=$n+1-$b;\n    print \"$a $mid2\\n$b $mid2\\n\";\n}"}], "negative_code": [{"source_code": "$deg=<>;\nif($deg==1){\n    print \"YES\\n2 1\\n1 2\" and exit;\n}\nif($deg%2==0){\n    print \"NO\" and exit;\n}\n$n=($deg+2)*2;\n$m=($deg+2)*$deg;\n$cnt=($deg-1)/2;\nprint \"YES\\n$n $m\\n\";\nfor($i=1;$i<=$deg+1;$i++){\n    for($j=$i+1;$j<=$deg+1;$j++){\n        if($cnt>0){\n            $cnt--;\n            push @stack,($i,$j);\n            next;\n        }\n        print \"$i $j\\n\";\n        $_i=$n+1-$i;\n        $_j=$n+1-$j;\n        print \"$_i $_j\\n\";\n    }\n}\n$mid=$deg+2; $mid2=$n+1-$mid;\nprint \"$mid $mid2\\n\";\nwhile(@stack){\n    $a = pop @stack;\n    $b = pop @stack;\n    print \"$a $mid\\n$b $mid\\n\";\n    $a=$n+1-$a; $b=$n+1-$b;\n    print \"$a $mid2\\n$b $mid2\\n\";\n}"}, {"source_code": "$deg=<>;\nif($deg==1){\n    print \"YES\\n2 1\\n1 2\" and exit;\n}\nif($deg%2==0){\n    print \"NO\" and exit;\n}\n$n=($deg+2)*2;\n$m=($deg+2)*$deg;\nprint \"YES\\n$n $m\\n\";\nfor($i=1;$i<=$deg+1;$i++){\n    for($j=$i+1;$j<=$deg+1;$j++){\n        next if($i==1 && $j==2);\n        print \"$i $j\\n\";\n        $_i=$n+1-$i;\n        $_j=$n+1-$j;\n        print \"$_i $_j\\n\";\n    }\n}\n$l=1; $r=2; $mid=$deg+2;\nprint \"$l $mid\\n$mid $r\\n\";\n$mid2=$n+1-$mid;\nprint \"$mid $mid2\\n\";\n$l=$n+1-$l; $r=$n+1-$r;\nprint \"$l $mid2\\n$mid2 $r\\n\";"}], "src_uid": "1e061d8c4bff217047ddc58e88be0c3f"}
{"source_code": "$tmp=<>;\n$sum1=0;\n$sum2=0;\nsub max\n{\n    my $t1=shift;\n    my $t2=shift;\n    if($t1<$t2){$t1;}\n    else\n    {$t2;}\n}\nforeach (1...$tmp)\n{\n    $ok=<>;\n    ($a,$b)=split / /,$ok;\n    $sum1+=$a;\n    $sum2+=$b;\n}\n$sum1=max($sum1,$tmp-$sum1);\n$sum2=max($sum2,$tmp-$sum2);\nprint $sum1+$sum2,\"\\n\";\n", "positive_code": [{"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Tue Nov 27 15:24:24 IST 2012\n# File Name: a.pl\n# USAGE: \n#       a.pl \n# \n# \n#------------------------------------------------\nuse List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nchomp (my $n = <STDIN>);\nmy ($a, $b, @l, @r);\n\n@r = @l = (0, 0);\n\nwhile ($n--) {\n        chomp ( ($a, $b) = split /\\s+/, <STDIN> );\n        $l[$a]++;\n        $r[$b]++;\n}\n\nprint &min (@l) + &min (@r);\n"}, {"source_code": "$tmp=<>;\n$sum1=0;\n$sum2=0;\nforeach (1...$tmp)\n{\n    $ok=<>;\n    ($a,$b)=split / /,$ok;\n    $sum1+=$a;\n    $sum2+=$b;\n}\nif(2*$sum1>$tmp){$sum1=$tmp-$sum1;}\nif(2*$sum2>$tmp){$sum2=$tmp-$sum2;}\nprint $sum1+$sum2,\"\\n\";\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$n=<>;\nwhile(<>=~/ /)\n{\n\t$` and $i++;\n\t$'+0 and $j++;\n\t}\nprint (min($i,$n-$i)+min($j,$n-$j));\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "negative_code": [{"source_code": "#! /usr/bin/perl -wl\n#------------------------------------------------\n# Author:    vj\n# Created:   Tue Nov 27 15:24:24 IST 2012\n# File Name: a.pl\n# USAGE: \n#       a.pl \n# \n# \n#------------------------------------------------\nuse List::Util qw(first max maxstr min minstr reduce shuffle sum);\n\nchomp (my $n = <STDIN>);\nmy ($a, $b, @l, @r);\n\nwhile ($n--) {\n        chomp ( ($a, $b) = split /\\s+/, <STDIN> );\n        $l[$a]++;\n        $r[$b]++;\n}\n\nprint &min (@l) + &min (@r);\n"}, {"source_code": "#!/usr/bin/perl\n\n$PI=3.14159265358979323846;\n$MOD=1000000007;\n\n#    <>=~/ /;\n#    <>=~/ (\\d+) /;\n#    <>=~/ (\\d+) (\\d+) /;\n\n$n=<>;\nwhile(<>=~/ /)\n{\n\t$` and $i++;\n\t$' and $j++;\n\t}\nprint (min($i,$n-$i)+min($j,$n-$j));\n\n#***********SUBS************\n\nsub num {$a <=> $b}\nsub num_rev {$b <=> $a}\nsub rev {$b cmp $a}\n\nsub p{print}\nsub n{print \"\\n\"}\nsub pn{p,n}\nsub pn_mas {pn for @_}\n\n# Transpose \"charbox\"\nsub transpose{\n    $i=@m=@_;\n    chomp @m;\n    while ($i--){\n        $t[$i]=~s/$/chop/e for @m\n    }\nreturn @t\n}\n\n# Transpose \"value sets\"\nsub transpose_space{\n    my @t;\n    for (@_){\n        my $j=0;\n        s/\\d+/($t[$j++].=\"$& \")?$&:$&/eg;\n        }\n    chop @t;\nreturn @t\n}\n\nsub div{\n    my ($n, $k)=@_;\nreturn ($n - $n % $k) / $k\n}\n    \nsub uniq{\n    my @m=sort @_;\n    push @u, my $i=shift @m;\n    for (@m){\n        $i eq $_ or push @u, $_;\n        $i=$_;\n        }\nreturn @u\n}\n    \nsub max{\n    my $max=shift;\n    $max<$_ and $max=$_ for @_;\nreturn $max\n}\n    \nsub min{\n    my $min=shift;\n    $min>$_ and $min=$_ for @_;\nreturn $min\n}\n\n# count (kas_ieskoma, masyvas)\nsub count{\n    my $i=0;\n    $_ eq $_[0] and $i++ for @_;\nreturn --$i\n}"}], "src_uid": "2052b0b4abdcf7d613b56842b1267f60"}
{"source_code": "<>;for(<>){print;print\"$_ \"for(1..$_-1)}", "positive_code": [{"source_code": "<>;for(<>){print;print\"$_ \"for(1..$_-1)}"}, {"source_code": "#!/usr/bin/perl\nuse Data::Dumper;\nuse integer;   ### important!\nmy $mod = 10 ** 9 + 7;\n# my $mod = 998244353;\n\nmy ($testcase) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n\nwhile( $testcase -- > 0 ){\n  \n  my ($n) = map { $_ - 0 } split(/\\s+/,<STDIN>);\n  \n  my @a = ( ($n) , ( 1 .. ($n-1) ));\n  print ( join(' ',@a) . \"\\n\" );\n  \n}\n\nexit(0);\n\nsub max {\n  my $r = undef;\n  foreach my $e (@_){  $r = $e if !defined($r) or $e > $r;  }\n  return $r;\n}\nsub min {\n  my $r = undef;\n  foreach my $e (@_){  $r = $e if !defined($r) or $e < $r;  }\n  return $r;\n}\nsub sum {\n  my $r = 0;\n  foreach my $e (@_){ $r += $e; }\n  return $r;\n}\nsub ruisum {   # my @rui = (0); &ruisum(\\@rui,\\@array);\n  my $r = shift; my $ar = shift;\n  $#{$r} = 1+$#{$ar}; $r->[0] = 0; my $rr = 0;\n  for(my $i=0;$i<=$#ar;$i++){ \n    $rr += $ar->[$i];\n    $r->[1+$i] = $rr;\n  }\n}\n"}, {"source_code": "for(1..<>){print\"$_ \"for(2..<>);print\"1 \"}"}, {"source_code": "<>;for(<>){for$i(0..$_-1){print$i||$_,\" \"}}"}], "negative_code": [{"source_code": "<>;for(<>){print;print for(1..$_-1)}"}], "src_uid": "955bc1e2769ea407ef02506bf1e4259b"}
{"source_code": "<>;\n\nwhile( <> ){\n\n$x = 'x' x $_;\n\n@_ = split ' ', <>;\n\nsubstr $x, $_ - 1, 1, 'o' for @_;\n\n$_ = $x;\n\n$i = 1;\n\ns/x(?=o)|(?<=o)x/o/g, $i ++ while /x/;\n\nprint $i . $/\n\n}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\tmy $x = 'x' x $n;\n\t\n\t@_ = split ' ', <>;\n\t\n\tsubstr $x, $_ - 1, 1, 'o' for @_;\n\t\n\t$debug and print $x;\n\t\n\tmy $i = 1;\n\t\n\twhile( $x =~ /x/ ){\n\t\t$x =~ s/x(?=o)|(?<=o)x/o/g;\n\t\t$debug and print \" $x\";\n\t\t$i ++;\n\t\t}\n\t\n\tprint $i;\n\t}"}], "negative_code": [{"source_code": "<>;\n\n$x = 'x' x <>;\n\n@_ = split ' ', <>;\n\nsubstr $x, $_ - 1, 1, 'o' for @_;\n\n$_ = $x;\n\ns/x(?=o)|(?<=o)x/o/g, $i ++ while /x/;\n\nprint 1 + $i"}, {"source_code": "<>;\n\nwhile( <> ){\n\n$x = 'x' x $_;\n\n@_ = split ' ', <>;\n\nsubstr $x, $_ - 1, 1, 'o' for @_;\n\n$_ = $x;\n\ns/x(?=o)|(?<=o)x/o/g, $i ++ while /x/;\n\nprint 1 + $i . $/\n\n}"}], "src_uid": "5de25068af66273c83cc7914910c4c84"}
{"source_code": "while(<>){\n#\tprint \"--\\n\";\n\t@_=();\n\t$f=$t=0;\n\t\n\tfor (0..7){\n\t\tpush @_,<>.\"\";\n\t\t}\n\tchomp @_;\n\t\n\t$h=0;\n\tfor (@_){\n\t\t$h or (s/K/N/ and $h++);\n#\t\tprint \"$_\\n\";\n\t\t}\n\t\n\t$k=0;\n\tfor (@_){\n\t\t$k++;\n\t\t@s=split//,$_;\n\t\t$j=0;\n\t\tfor $i(@s){\n\t\t\t$j++;\n\t\t\tif ($i eq \"K\") {\n\t\t\t\t$y=$j;\n\t\t\t\t$x=$k;\n\t\t\t\t}\n\t\t\tif ($i eq \"N\") {\n\t\t\t\t$n=$j;\n\t\t\t\t$m=$k;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t$c=$y-$n;\n\t$d=$x-$m;\n\t\n\tif ($c%4==0 and $d%4==0){$f++}\n\t\n#\tprint \"!\\n\";\n#\tprint \"!!\\n\";\t\n\t($f)?(print\"YES\\n\"):(print\"NO\\n\");\n\t\t\n\t}", "positive_code": [{"source_code": "while(<>){\n\t@_=();\n\t$f=$t=0;\n\t\n\tfor (0..7){\n\t\tpush @_,<>.\"\";\n\t\t}\n\tchomp @_;\n\t\n\t$h=0;\n\tfor (@_){\n\t\t$h or (s/K/N/ and $h++);\n\t\t}\n\t\n\t$k=0;\n\tfor (@_){\n\t\t$k++;\n\t\t@s=split//,$_;\n\t\t$j=0;\n\t\tfor $i(@s){\n\t\t\t$j++;\n\t\t\tif ($i eq \"K\") {\n\t\t\t\t$y=$j;\n\t\t\t\t$x=$k;\n\t\t\t\t}\n\t\t\tif ($i eq \"N\") {\n\t\t\t\t$n=$j;\n\t\t\t\t$m=$k;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t$c=$y-$n;\n\t$d=$x-$m;\n\t\n\tunless ($c%4 + $d%4){$f++}\n\n\tprint $f?\"YES\\n\":\"NO\\n\";\n\t}"}], "negative_code": [{"source_code": "while(<>){\n#\tprint \"--\\n\";\n\t@_=();\n\t$f=$t=0;\n\t\n\tfor (0..7){\n\t\tpush @_,<>.\"\";\n\t\t}\n\tchomp @_;\n\t\n\t$h=0;\n\tfor (@_){\n\t\t$h or (s/K/N/ and $h++);\n#\t\tprint \"$_\\n\";\n\t\t}\n\t\n\t$k=0;\n\tfor (@_){\n\t\t$k++;\n\t\t@s=split//,$_;\n\t\t$j=0;\n\t\tfor $i(@s){\n\t\t\t$j++;\n\t\t\tif ($i eq \"K\") {\n\t\t\t\t$y=$j;\n\t\t\t\t$x=$k;\n\t\t\t\t}\n\t\t\tif ($i eq \"N\") {\n\t\t\t\t$n=$j;\n\t\t\t\t$m=$k;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t$c=$y-$n;\n\t$d=$x-$m;\n\t\n\tunless ($c%2==0 and $d%2==0 and ($c+$d)%4==0){$f++}\n\t\n#\tprint \"!\\n\";\n\t\n\t$k=0;\n\tfor (@_){\n\t\t$k++;\n\t\t@s=split//,$_;\n\t\t$j=0;\n\t\tfor $i(@s){\n\t\t\t$j++;\n\t\t\t($i eq \".\") and (($j-$y)%2==0) and (($k-$x)%2==0) and (($j-$y+$k-$x)%4==0) and $t++;\n\t\t\t\n\t\t\t}\n\t\t}\n#\tprint \"!!\\n\";\t\n\t($t && !$f)?(print\"YES\\n\"):(print\"NO\\n\");\n\t\t\n\t}"}, {"source_code": "while(<>){\n#\tprint \"--\\n\";\n\t@_=();\n\t$f=$t=0;\n\t\n\tfor (0..7){\n\t\tpush @_,<>.\"\";\n\t\t}\n\tchomp @_;\n\t\n\t$h=0;\n\tfor (@_){\n\t\t$h or (s/K/N/ and $h++);\n#\t\tprint \"$_\\n\";\n\t\t}\n\t\n\t$k=0;\n\tfor (@_){\n\t\t$k++;\n\t\t@s=split//,$_;\n\t\t$j=0;\n\t\tfor $i(@s){\n\t\t\t$j++;\n\t\t\tif ($i eq \"K\") {\n\t\t\t\t$y=$j;\n\t\t\t\t$x=$k;\n\t\t\t\t}\n\t\t\tif ($i eq \"N\") {\n\t\t\t\t$n=$j;\n\t\t\t\t$m=$k;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t$c=$y-$n;\n\t$d=$x-$m;\n\t\n\tunless ($c%2==0 and $d%2==0 and ($c+$d)%4==0){$f++}\n\t\n#\tprint \"!\\n\";\n#\tprint \"!!\\n\";\t\n\t(!$f)?(print\"YES\\n\"):(print\"NO\\n\");\n\t\t\n\t}"}], "src_uid": "4f3bec9c36d0ac2fdb8041469133458c"}
{"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0;", "positive_code": [{"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "$\\ = $/;\nwhile($n = <>){\n\t\n\t@_ = ();\n\tfor $i (1 .. $n){\n\t\t$_ = <>;\n\t\t/(?<!-)[13]/ or push @_, $i;\n\t\t}\n\t\n\tprint @_ ? @_ . \"\\n@_\" : 0\n\t\n}"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "!/-/ || /( |^)[13]/ || push @_, $. -1 while <>;\nprint @_ ? @_ . \"\\n@_\" : 0\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\n@mark = (1) x ($n+1);\nforeach $i (1..$n) {\n\t$j = 1;\n\tforeach (split / /, <>) {\n\t\tif ($_ == 1) {\n\t\t\t$mark[$i] = 0;\n\t\t} elsif ($_ == 2) {\n\t\t\t$mark[$j] = 0;\n\t\t} elsif ($_ == 3) {\n\t\t\t$mark[$i] = $mark[$j] = 0;\n\t\t}\n\t\t++$j;\n\t}\n}\n$ans+=$_ foreach(@mark);\nsay $ans-1;\n$mark[$_]>0 and print \"$_ \" foreach (1..$n);"}], "negative_code": [{"source_code": "my $n = int<>;\nmy @ans;\n(scalar(() = <> =~ / 1|3/) == 0) and push @ans, $_ for(1..$n);\nprint scalar @ans;\nprint \"\\n@ans\\n\";"}], "src_uid": "3fc0ac711b113fa98f41740536dad44f"}
{"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n", "positive_code": [{"source_code": "$n=<>; $_=<>; chomp;\nif(/(^|1 )0$/ or /0.*0 0$/) {\n  print \"YES\\n\";                                                                \n  s/0 ((1 )+0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n  s/ /->/g;\n  print;\n  exit;\n}\nprint \"NO\";"}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\""}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>, $_ = <>, y/ //d;\n\nprint 0\n||\t \t/(1|^)0$/\n||\ts\t/000$/(0->0)->0/\n||\ts\t/01+00$/ $n = -3 + length $&, \"(0->\" . \"(1->\" x $n . 0 . \")\" x $n . \")->0\" /e\n?\n\t\"\" x s/(?<=\\d)(?=\\d|\\()/->/g .\n\t\"YES\\n$_\"\n:\n\t\"NO\""}, {"source_code": "<>, $_ = <>, y/ //d;\n\nprint 0\n||\t \t/(1|^)0$/\n||\ts\t/01*00$/ $n = -3 + length $&, \"(0\" . \"(1\" x $n . 0 . \")\" x $n . \")->0\" /e\n?\n\t\"\" x s/\\d\\K(?!\\)|$)/->/g .\n\t\"YES\\n$_\"\n:\n\t\"NO\""}, {"source_code": "<>, $_ = <>;\nprint qw(NO YES)[/(^|1 )0$/ || s/0 ((1 )*0) 0$/(0 ($1)) 0/\n? \"1a\" . s/ /->/g . ($a = $_):0] . \"\\n$a\""}, {"source_code": "<>,$_=<>;print qw(NO YES)[/(^|1 )0$/||s/0 ((1 )*0) 0$/(0 ($1)) 0/?\"1a\".s/ /->/g.($a = $_):0].\"\\n$a\"\n"}, {"source_code": "<>; $_=<>;\nif(/(^|1 )0$/ or /0.*0 0$/) {\n  print \"YES\\n\";\n  s/0 ((1 )+0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n  s/ /->/g;\n  print;\n  exit;\n}\nprint \"NO\";"}, {"source_code": "$n=<>; $_=<>; chomp;\nif(/1$/ or /^(1 )+0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )+0) 0$/(0 ($1)) 0/;                                                                                                                                       \n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}], "negative_code": [{"source_code": "$n=<>; $_=<>; chomp;                                                                                                                                                 \n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )(\\1)*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>; $_=<>; chomp;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {                                                                                                                              \n  print \"NO\";\n  exit;\n}\nif(/^(1 )\\1*1 0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/ or /1 0$/) {\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "$n=<>; $_=<>; chomp;\n#$s=$_;\n#$s=~s/ //g;\n#$x=1 x ($n-2);\n#$x.=\"00\";                                                                                                                                                           \n#if($s eq $x) {\n#  print \"NO\";\n#  if(/^(1 1 1 1 1 )+0 0$/) {\n#    print \"hahaha\";\n#  }\n#  exit;\n#}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )+0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@a=split ' ';\n$s=$_;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\";\nif(/^0$/ or /1 0$/) {\n  s/ /->/g;\n  print;\n} else {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  print \"yayay\\n\";\n  s/ /->/g;\n  print;\n}  "}, {"source_code": "$n=<>; $_=<>; chomp;                                                                                                                                                 \n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )\\1*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>; $_=<>; chomp;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/ or /1 0$/) {\n} elsif(/0.*00$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;                                                                       \nprint"}, {"source_code": "<>; $_=<>; chomp;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )\\1*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/ or /1 0$/) {\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint; "}, {"source_code": "<>;                                                                             \n$_=<>;\nchomp;\n@a=split ' ';\n$s=$_;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/ or /1 0$/) {\n  s/ /->/g;\n  print;\n} else {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n#print \"$_\\n\";\n  s/ /->/g;\n  print;\n}"}, {"source_code": "<>; $_=<>; chomp;                                                               \nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/ or /1 0$/) {\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>;\n$_=<>;\nchomp;\n@a=split ' ';\n$s=$_;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";                                                                  \nif(/^0$/ or /1 0$/) {\n  s/ /->/g;\n  print;\n} else {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  print \"yayay\\n\";\n  s/ /->/g;\n  print;\n}"}, {"source_code": "$n=<>; $_=<>; chomp;\n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  if(/^(1 1 1 )(\\1)*0 0$/) {\n    print \"hahaha\";                                                                                                                                                  \n  }\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )(\\1)*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "$n=<>; $_=<>; chomp;\n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  if(/^(1 1 1 1 )(\\1)*0 0$/) {\n    print \"hahaha\";                                                                                                                                                  \n  }\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )(\\1)*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "$n=<>; $_=<>; chomp;\n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  if(/^(1 )(\\1)*0 0$/) {\n    print \"hahaha\";                                                                                                                                                  \n  }\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )(\\1)*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>; $_=<>; chomp;\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )\\1*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>; $_=<>; chomp;                                                               \nif(/1$/ or /^(1 )\\1*1 0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )\\1*1 0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/ or /1 0$/) {\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>; $_=<>; chomp;\nif(/1$/ or /^(1 )\\1*0 0$/ or /^0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )\\1*1 0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){                                                                                                                                                           \n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )\\2*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "$n=<>; $_=<>; chomp;\n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  if(/^(1 1 )(\\1)*0 0$/) {\n    print \"hahaha\";                                                                                                                                                  \n  }\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )(\\1)*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "$n=<>; $_=<>; chomp;\n$s=$_;\n$s=~s/ //g;\n$x=1 x ($n-2);\n$x.=\"00\";\nif($s eq $x) {\n  print \"NO\";\n  if(/^(1 1 1 1 1 )(\\1)*0 0$/) {\n    print \"hahaha\";                                                                                                                                                  \n  }\n  exit;\n}\nif(/1$/) {\n  print \"NO\";\n  exit;\n}\nif(/^(1 )(\\1)*0 0$/) {\n  print \"NO\";\n  exit;\n}\nif(/^0 0$/) {\n  print \"NO\";\n  exit;\n}\nprint \"YES\\n\";\nif(/^0$/){\n} elsif(/1 0$/){\n} elsif(/0.*0 0$/) {\n  s/0 ((1 )(\\2)*0) 0$/(0 ($1)) 0/;\n  s/0 0 0$/(0 0) 0/;\n}\ns/ /->/g;\nprint;"}, {"source_code": "<>, $_ = <>, y/ //d;\n\nprint 0\n||\t \t/10$/\n||\ts\t/000$/(0->0)->0/\n||\ts\t/01+00$/ $n = -2 + length $&, \"0->\" . \"(1->\" x $n . 0 . \")\" x $n . \"->0\" /e\n?\n\t\"\" x s/(?<=\\d)(?=\\d|\\()/->/g .\n\t\"YES\\n$_\"\n:\n\t\"NO\""}, {"source_code": "<>, $_ = <>, y/ //d;\n\nprint 0\n||\t \t/(1|^)0$/\n||\ts\t/000$/(0->0)->0/\n||\ts\t/01+00$/ $n = -2 + length $&, \"0->\" . \"(1->\" x $n . 0 . \")\" x $n . \"->0\" /e\n?\n\t\"\" x s/(?<=\\d)(?=\\d|\\()/->/g .\n\t\"YES\\n$_\"\n:\n\t\"NO\""}, {"source_code": "<>, $_ = <>, y/ //d;\n\nprint 0\n||\t \t/(1|^)0$/\n||\ts\t/000$/(0->0)->0/\n||\ts\t/01+00$/ $n = -3 + length $&, \"0->\" . \"(1->\" x $n . 0 . \")\" x $n . \"->0\" /e\n?\n\t\"\" x s/(?<=\\d)(?=\\d|\\()/->/g .\n\t\"YES\\n$_\"\n:\n\t\"NO\""}], "src_uid": "98380bd9d6865fa9a2d100ca3484b005"}
{"source_code": "for(1..<>){<>=~/(.+) (.+)/;print$1*$1+2*$1+2>4*$2?\"YES\\n\":\"NO\\n\"}", "positive_code": [{"source_code": "for(1..<>){$_=<>,/(.+) (.+)/;print$1*$1+2*$1+2>4*$2?\"YES\\n\":\"NO\\n\"}"}, {"source_code": "for(1..<>){$_=<>,/(.+) (.+)/;print(($1+1)*($1+1)>=4*$2?\"YES\\n\":\"NO\\n\")}"}, {"source_code": "for(1..<>){$_=<>,/(.+) (.+)/;print($1*$1+2*$1+2>4*$2?\"YES\\n\":\"NO\\n\")}"}, {"source_code": "for(1..<>){$_=<>,/(.+) (.+)/;print(($1+1)*($1+1)>=4*$2?\"YES\\n\":\"NO\\n\");}"}], "negative_code": [{"source_code": "for(1..<>){$_=<>,/(.+) (.+)/;print($1+1)**2>=4*$2?\"YES\\n\":\"NO\\n\"}"}, {"source_code": "for(1..<>){<>=~/(.+)(.)/;print$1*$1+2*$1+2>4*$2?\"YES\\n\":\"NO\\n\"}"}], "src_uid": "e65b2a81689bb13b90a02a9ccf1d4125"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tchomp;\n\tprint;\n\t\n\tmy %h = map { $_ => 1 } split ' ';\n\t\t\n\tfor ( 1 .. <> ){\n\t\t@_ = split ' ', <>;\n\t\texists $h{ $_ } ? delete $h{ $_ } : ($h{ $_ } = 1) for @_;\n\t\t\n\t\tprint join ' ', keys %h;\n\t\t}\n\t\n\t$debug and print '-' x 10;\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\n\nmy $line = <>;\nchomp($line);\nmy @init_pot = split (\" \", $line);\nprint \"$init_pot[0] $init_pot[1]\\n\";\nmy $num = <>;\nchomp($num);\n\nfor (my $i=0;$i < $num;$i++) {\n        my $line = <>;\n        chomp($line);\n        my @pot = split (\" \", $line);\n        if ($init_pot [0] eq $pot[0]) {\n                $init_pot[0] = $pot[1];\n        } elsif ($init_pot [1] eq $pot[0]) {\n                $init_pot[1] = $pot[1];\n        }\n\nprint \"$init_pot[0] $init_pot[1]\\n\";\n}\n\n"}], "negative_code": [], "src_uid": "3c06e3cb2d8468e738b736a9bf88b4ca"}
{"source_code": "$_=<>;\nif(/9\\./) {\n  print \"GOTO Vasilisa.\";\n  exit;\n}\ns/(\\d)\\.(\\d).*/$1+($2<5?0:1)/e;\nprint;\n", "positive_code": [{"source_code": "$_=<>;\nif(/9\\./) {\n  print \"GOTO Vasilisa.\";\n  exit;\n}\ns/([^9])\\.(\\d).*/$1+($2<5?0:1)/e;\nprint;\n"}, {"source_code": "$ch=<>;\nchomp$ch;\n$pos=index($ch,'.');\n\nif(substr($ch,$pos-1,1) eq \"9\"){\nprint \"GOTO Vasilisa.\";\n}\nelsif(substr($ch,$pos+1,1) lt \"5\"){\nprint substr($ch,0,$pos);\n}\nelse{\n$car=substr($ch,$pos-1,1)+1;\n$res= substr($ch,0,$pos-1).$car;\nprint $res;\n\n}"}, {"source_code": "$_=<>;\nchomp;\n/(.)\\.(.)/;\n$o=$2;\n$e=$`;\n$f=$1;\nif (9 == $f) {print\"GOTO Vasilisa.\"} \nelsif ($o>4 ) {$f++; print$e,$f } \nelse{print$e,$f}"}], "negative_code": [{"source_code": "$_=<>;\n{\nif (/9$/) {print\"GOTO Vasilisa.\";last}\n\n/\\.(.)/;\n\n$e=$`;\n$o=$1;\nif ($o>4 ) {\n\n$e++\n}\n\nprint$e\n}"}], "src_uid": "3060ecad253a2b4d4fac39e91fcd6c95"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tmy( $n, $k ) = split;\n\t\n\tmy @A = split ' ', <>;\n\tmy @B = split ' ', <>;\n\t\n\tmy @C;\n\t\n\twhile( @A ){\n\t\tpush @C, [ ( pop @A ), ( pop @B ) ];\n\t\t}\n\t\n\t@C = sort { $a->[ 0 ] <=> $b->[ 0 ] } @C;\n\t\n\twhile( @C and $C[ 0 ][ 0 ] <= $k ){\n\t\tmy $c = shift @C;\n\t\t\n\t\t$k += $c->[ 1 ];\n\t\t}\n\t\n\tprint $k;\n\t}", "positive_code": [{"source_code": "for(1..<>) {\r\n        #--------------------------Get input\r\n        chomp(my $in = <>);\r\n        my ($n, $k) = split / /, $in;\r\n        chomp(my $in = <>);\r\n        my @a = split / /, $in;\r\n        chomp(my $in = <>);\r\n        my @b = split / /, $in;\r\n        #---------------------------Create Hash table\r\n        %data = ();\r\n        for(my $i = 0; $i < $n; $i++) {\r\n                if (exists $data{@a[$i]}) { #----Sum b value of dupes\r\n                        $data{@a[$i]} += @b[$i];\r\n                 } else {\r\n                        $data{@a[$i]} = @b[$i];\r\n                }\r\n        }\r\n        #--------------------------Iterate sorted hash table\r\n        foreach my $x (sort {$a <=> $b} keys %data) {\r\n                $k < $x and last;\r\n                $k += $data{$x};\r\n        }\r\n        print $k, \"\\n\";\r\n}"}], "negative_code": [], "src_uid": "168f2a740d21a3a916a9d560fbcffeb9"}
{"source_code": "<>;\n\n@_ = split ' ', <>;\n\n$_ % 2 or @_[ $_, @_ - $_ - 1 ] = @_[ @_ - $_ - 1, $_ ] for 0 .. @_ / 2 - 1;\n\nprint \"@_\"", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tfor my $i (0 .. @_ / 2 - 1){\n\t\t$i % 2 and next;\n\t\t\n\t\t( $_[ $i ], $_[ @_ - $i - 1] ) = reverse( $_[ $i ], $_[ @_ - $i - 1] );\n\t\t\n\t\t}\n\t\n\tprint \"@_\";\n\t}"}], "negative_code": [], "src_uid": "7d2f22fc06d4f0b8ff8be6c6862046e7"}
{"source_code": "<>;\n@_=split/ /,<>;\n$a[$_]++ for @_;\n$a[$_]//print for 1..@_+1", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nmy $n = <STDIN>;\nmy $s = (1 + $n) / 2 * $n;\n\nmy @a = split(/\\s+/, <>);\n\nfor ($i = 0; $i < $n - 1; $i++) {\n  $s -= @a[$i];\n}\n\n print $s;\n"}], "negative_code": [{"source_code": "<>;\n@_=split/ /,<>;\n$a[$_]++ for @_;\n$a[$_]//print for 1..@a-1"}, {"source_code": "<>;\n@_=split/ /,<>;\n$a[$_]++ for @_;\n$a[$_]//print for 1..@_"}, {"source_code": "<>;\n@_=split/ /,<>;\n$a[$_]++ for @_;\n$a[$_]//print for 1..@_-1"}, {"source_code": "<>;\n@_=split/ /,<>;\n$a[$_]++ for @_;\nshift @a;\n$_//print for @a;\n"}], "src_uid": "0e4ff955c1e653fbeb003987fa701729"}
{"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a", "positive_code": [{"source_code": "$_ = <STDIN>;\nchomp;\n\nmy $a = 0;\nmy $b = ($_ - 1)/2;\n\nfor(; $a < ($_ - 1)/2 + 1; $a++){\n    print '*' x ($b-$a), 'D' x (2 * $a + 1), '*' x ($b-$a), \"\\n\";\n}\n$a-=2;\nfor(; $a >= 0; $a--){\n    print '*' x ($b-$a), 'D' x (2 * $a + 1), '*' x ($b-$a), \"\\n\";\n}\n"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "my $n = <>;\nmy @a = ();\n$#a = $n;\nfor (1 .. int $n/2 + 1) {\n    my $b = 2 * ($_ - 1) + 1;\n    my $a = ($n - $b) / 2;\n    $a[$_ - 1] = $a[$n - $_] = (\"*\" x $a) . (\"D\" x $b) . (\"*\" x $a);\n}\nprint join \"\\n\", @a;"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "my $n = <>;\nfor (my $i = 1; $i < $n; $i += 2) {\n    print \"*\" x int(($n - $i) / 2);\n    print \"D\" x $i;\n    print \"*\" x int(($n - $i) / 2);\n    print \"\\n\";\n}\nfor (my $i = $n; $i > 0; $i -=2) {\n    print \"*\" x int(($n - $i) / 2);\n    print \"D\" x $i;\n    print \"*\" x int(($n - $i) / 2);\n    print \"\\n\";\n}\n"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "#!/usr/bin/perl\nuse v5.10;\n\nchomp($n = <>);\nfor (my $i=1,$j=($n-1)/2; $i<$n; $i+=2,--$j) {\n\t$line = '*' x $j . 'D'x $i . '*' x $j;\n\tsay $line;\n}\nfor (my $i=$n,$j=0; $i>0; $i-=2,++$j) {\n\t$line = '*' x $j . 'D'x $i . '*' x $j;\n\tsay $line;\n}"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "use integer;\nchomp($m=<>);\n$h = $m/2;\n$f = 0;\nfor(1..$m){\n    print \"*\" x $h , \"D\" x ($m - 2 * $h), \"*\" x $h, \"\\n\";\n    $h-- if !$f;\n    $h++ if $f;\n    $f++ if !$h;\n}\n"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}, {"source_code": "use integer;\n$n=<>;\n$_=(\"D\"x $n).\"\\n\";\npush @_, $_;\n$n/=2;\nfor $i(1..$n){\ns/D/*/;\ns/D\\*/**/;\ns/D$/*/;\npush @_, $_;\nunshift @_, $_;\n\n}\nprint @_;"}, {"source_code": "@_=$_=\"D\"x<>.\"\\n\";\nwhile(/D\\B/){\n\ts/\\bD|D\\b/*/g;\n\t@_=($_,@_,$_)\n\t}\nprint @_"}, {"source_code": "$a=$_=\"D\"x<>;\nwhile(/D\\B/){\n\ts/\\bD|D\\b/*/g;\n\t$a=\"$_\\n$a\\n$_\"\n\t}\nprint $a"}, {"source_code": "#!perl -p\n$a=$_=\"D\"x$_;while(/DD/){s/\\bD|D\\b/*/g;$a=\"$_\\n$a\\n$_\"}$_=$a\n"}], "negative_code": [{"source_code": "$_ = <STDIN>;\nchomp;\n\nmy $a = 0;\nmy $b = ($_ - 1)/2;\n\nfor(; $a < ($_ - 1)/2 + 1; $a++){\n    print '*' x ($b-$a), 'D' x (2 * $a + 1), '*' x ($b-$a), \"\\n\";\n}\n$a--;\nfor(; $a >= 0; $a--){\n    print '*' x ($b-$a), 'D' x (2 * $a + 1), '*' x ($b-$a), \"\\n\";\n}"}, {"source_code": "$_ = <STDIN>;\nchomp;\n\nmy $a = 0;\nmy $b = ($_ - 1)/2;\nprint $b, \"\\n\";\n\nfor(; $a < ($_ - 1)/2 + 1; $a++){\n    print '*' x ($b-$a), 'D' x (2 * $a + 1), '*' x ($b-$a), \"\\n\";\n}\n$a-=2;\nfor(; $a >= 0; $a--){\n    print '*' x ($b-$a), 'D' x (2 * $a + 1), '*' x ($b-$a), \"\\n\";\n}\n"}, {"source_code": "@_=$_=\"D\"x<>.\"\\n\";\nwhile(/D\\B/){\n\ts/\\bD|D\\b/*/g;\n\t@_=$_,@_,$_\n\t}\nprint @_"}], "src_uid": "a003d645999934c255f7b05d8494fa40"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\nmy $debug = 0;\n\nwhile(<>){\n\tmy( $n, $m, $k ) = split;\n\t\n\t@_ = ();\n\t\n\tfor ( map ~~<>, 1 .. $n ){\n\t\tmy $i = 0;\n\t\tmap { $_[ $i ++ ] .= $_ } split;\n\t\t}\n\t\n\t$debug and print for @_;\n\t@_ = grep m/1/, @_;\n\tmy $ex = 0;\n\tmy $lf = 0;\n\t\n\tfor ( @_ ){\n\t\tmy $_1 = 0;\n\t\tmy $max = 0;\n\t\tmy $max_id = -1;\n\t\tmy @A = ();\n\t\tmy $shift = 0;\n\t\t\n\t\twhile( /(.)/g ){\n\t\t\t$_1 += $1;\n\t\t\tpush @A, $1;\n\t\t\tif( @A > $k ){\n\t\t\t\t$_1 -= shift @A;\n\t\t\t\t$shift ++;\n\t\t\t\t}\n\t\t\t$debug and print \"[@A]|$_1\";\n\t\t\t$max < $_1 and $max_id = $shift;\n\t\t\t$max < $_1 and $max = $_1;\n\t\t\t}\n\t\t\n\t\t$debug and print $max;\n\t\t$debug and print $max_id;\n\t\t\n\t\ts/.{$max_id}//;\n\t\t$ex += () = $& =~ /1/g;\n\t\ts/.{1,$k}//;\n\t\t$lf += () = $& =~ /1/g;\n\t\t}\n\t\n\tprint \"$lf $ex\";\n\t$debug and print '-' x 20;\n\t}", "positive_code": [{"source_code": "use strict;\n\nsub g {\n\tmy ($s, $k) = @_;\n\tmy ($I, $V, $i, $v);\n\twhile ($s =~ /1/g) {\n\t\tmy $m = substr $s, $-[0], $k;\n\t\t$v = $m =~ y/1//;\n\t\tif ($v > $V) {\n\t\t\t$V = $v;\n\t\t\t$I = $i;\n\t\t}\n\t\t$i++;\n\t}\n\t(0 + $I, 0 + $V);\n}\n\nlocal *INPUT = 1? *STDIN: *DATA;\nmy ($n, $m, $k) = split \" \", <INPUT>;\nmy (@a, @b); s/ //g, push @a, $_ for <INPUT>;\nfor my $c (1..$m) {\n\tfor my $r (1..$n) {\n\t\t$b[$c] .= substr $a[$r-1], $c-1, 1;\n\t}\n}\n\nmy ($CHG, $VAL);\nfor $b (@b) {\n\tmy ($chg, $val) = g($b, $k);\n\t$CHG += $chg, $VAL += $val;\n}\nprint 0 + $VAL, \" \", 0 + $CHG, \"\\n\";\n\n__DATA__\n3 2 1\n1 0\n0 1\n0 0"}, {"source_code": "while(<>){\n\tmy( $n, $m, $k ) = split;\n\t\n\tfor ( map ~~<>, 1 .. $n ){\n\t\t$i = 0, map $_[ $i ++ ] .= $_, split\n\t\t}\n\t\n\t$ex = $lf = 0;\n\t\n\tfor ( @_ = grep m/1/, @_ ){\n\t\t$_1 = 0;\n\t\t$max = 0;\n\t\t$max_id = -1;\n\t\t@A = ();\n\t\t$sh = 0;\n\t\t\n\t\twhile( /(.)/g ){\n\t\t\t$_1 += $1;\n\t\t\tpush @A, $1;\n\t\t\tif( @A > $k ){\n\t\t\t\t$_1 -= shift @A;\n\t\t\t\t$sh ++;\n\t\t\t\t}\n\t\t\t$max < $_1 and do { $max_id = $sh, $max = $_1 };\n\t\t\t}\n\t\t\n\t\ts/.{$max_id}//;\n\t\t$ex += () = $& =~ /1/g;\n\t\ts/.{1,$k}//;\n\t\t$lf += () = $& =~ /1/g;\n\t\t}\n\t\n\tprint \"$lf $ex\";\n\t}"}], "negative_code": [], "src_uid": "2a3c3e98910246eaf9ec60ff1680fab6"}
{"source_code": "<>;\n\nwhile(<>){\n    \n\ts/[a-z]\\K/,/g;\n\ts/[A-Z]\\K/;/g;\n\ts/[0-9]\\K/!/g;\n\t\t\n\t/[;!]/ or s/..../A;0!/;\n\t/[,!]/ or s/..../a,0!/;\n\t/[,;]/ or s/..../a,A;/;\n\t\n\t/,/ or s/.([;!]).*\\K.\\1/a$1/;\n\t/;/ or s/.([,!]).*\\K.\\1/A$1/;\n\t/!/ or s/.([,;]).*\\K.\\1/0$1/;\n\t\n\tprint y/,;!//rd;\n\t}", "positive_code": [{"source_code": "<>;\n\nwhile(<>){\n    \n\ts/[a-z]\\K/,/g;\n\ts/[A-Z]\\K/;/g;\n\ts/[0-9]\\K/!/g;\n\t\n\t$re = '.(\\W).*\\K.\\1';\n\t\n\t0 while 0 ||\n\t\t!/,/ && s/$re/a,/ ||\n\t\t!/;/ && s/$re/A;/ ||\n\t\t!/!/ && s/$re/0!/ ||\n\t\t0;\n\t\n\tprint s/\\W//gr . $/\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\ts/^[a-z][a-z]([a-z]+)$/A1$1/;\n\ts/^[A-Z][A-Z]([A-Z]+)$/a1$1/;\n\ts/^[0-9][0-9]([0-9]+)$/Aa$1/;\n\t\n\t!/[0-9]/ and \n\t\ts/([A-Z])([a-z])([a-z])/$1${2}1/ ||\n\t\ts/([a-z])([a-z])([A-Z])/1$2$3/ || \n\t\ts/([a-z])([A-Z])([a-z])/$1${2}1/ || \n\t\ts/([a-z])([A-Z])([A-Z])/$1${2}1/ ||\n\t\ts/([A-Z])([A-Z])([a-z])/1$2$3/ || \n\t\ts/([A-Z])([a-z])([A-Z])/$1${2}1/ || 0\n\t\t;\n\t!/[a-z]/ and \n\t\ts/([A-Z])([0-9])([0-9])/$1${2}a/ ||\n\t\ts/([0-9])([0-9])([A-Z])/a$2$3/ || \n\t\ts/([0-9])([A-Z])([0-9])/$1${2}a/ || \n\t\ts/([0-9])([A-Z])([A-Z])/$1${2}a/ ||\n\t\ts/([A-Z])([A-Z])([0-9])/a$2$3/ || \n\t\ts/([A-Z])([0-9])([A-Z])/$1${2}a/ || 0\n\t\t;\n\t!/[A-Z]/ and \n\t\ts/([a-z])([0-9])([0-9])/$1${2}A/ ||\n\t\ts/([0-9])([0-9])([a-z])/A$2$3/ || \n\t\ts/([0-9])([a-z])([0-9])/$1${2}A/ || \n\t\ts/([0-9])([a-z])([a-z])/$1${2}A/ ||\n\t\ts/([a-z])([a-z])([0-9])/A$2$3/ || \n\t\ts/([a-z])([0-9])([a-z])/$1${2}A/ || 0\n\t\t;\n\t\n\tprint;\n\t}"}, {"source_code": "<>; for (<>) {\n\t@e = qw([a-z] [A-Z] [0-9]);\n\tfor $e1 (@e) {\n\tfor $e2 (@e) {\t\n\t\t$c = substr $e1, 1, 1;\n\t\t/$e1/ || s/($e2)(.*$e2)/$c$2/;\n\t}}\n\tprint;\n}"}, {"source_code": "#usr/bin/perl -w\nuse strict;\n\nmy $t=<STDIN>;chomp($t);my $l;my $u;my $d;\nfor my $i(1..$t){\n    my $s=<STDIN>;\n    $l=$s=~tr/[a-z]//;\n    $u=$s=~tr/[A-Z]//;\n    $d=$s=~tr/[0-9]//;\n    if($l==0){\n\tif($u==0){\n\t    $u++;\n\t    $l++;\n\t    $s=~s/.{2}/Ax/;\n\t}\n\telsif($d==0){\n\t    $l++;\n\t    $d++;\n\t    $s=~s/.{2}/a3/;\n\t}\n\telse{\n\t    if($u==1){\t$s=~s/[0-9]/s/;}\n\t    else{$s=~s/[A-Z]/s/;}\n\t    $l++;\n\t}\n    }\n    if($u==0){\n\tif($l==0){\n\t    $u++;\n\t    $l++;\n\t    $s=~s/.{2}/Ax/;\n\t}\n\telsif($d==0){\n\t    $u++;\n\t    $d++;\n\t    $s=~s/.{2}/A3/;\n\t}\n\telse{\n\t    if($l==1){\t$s=~s/[0-9]/A/;}\n\t    else{$s=~s/[a-z]/A/;}\n\t    $u++;\n\t}\n    }\n    if($d==0){\n\tif($u==0){\n\t    $u++;\n\t    $d++;\n\t    $s=~s/.{2}/A3/;\n\t}\n\telsif($l==0){\n\t    $l++;\n\t    $d++;\n\t    $s=~s/.{2}/a3/;\n\t}\n\telse{\n\t    if($u==1){\t$s=~s/[a-z]/6/;}\n\t    else{$s=~s/[A-Z]/6/;}\n\t    $d++;\n\t}\n    }\n    print \"$s\\n\";\n}"}], "negative_code": [{"source_code": "#usr/bin/perl -w\nuse strict;\n\nmy $t=<STDIN>;chomp($t);my $l;my $u;my $d;\nfor my $i(1..$t){\n    my $s=<STDIN>;\n    $l=$s=~tr/[a-z]//;\n    $u=$s=~tr/[A-Z]//;\n    $d=$s=~tr/[0-9]//;\n    while($d==0||$u==0||$l==0){\n\tif($l>1){\n\t    $s=~s/[a-z]/4/ if($d==0);\n\t    $s=~s/[a-z]/A/ if($u==0);\n\t    $d++ if($d==0);\n\t    $u++ if($u==0);\n\t}\n\telse{\n\t    if($d>$u){\n\t\t$s=~s/[0-9]/a/ if($l==0);\n\t\t$s=~s/[0-9]/A/ if($u==0);\n\t\t$l++ if($l==0);\n\t\t$u++ if($u==0);\n\t    }\n\t    else{\n\t\t$s=~s/[A-Z]/a/ if($l==0);\n\t\t$s=~s/[A-Z]/A/ if($d==0);\n\t\t$l++ if($l==0);\n\t\t$d++ if($d==0);\n\t    }\n\t}\n    }\n    print \"$s\\n\";\n}"}, {"source_code": "<>;\n\n$_ = <>;\n\ns/[a-z]\\K/,/g;\ns/[A-Z]\\K/;/g;\ns/[0-9]\\K/!/g;\n\t\n/[;!]/ or s/..../A;0!/;\n/[,!]/ or s/..../a,0!/;\n/[,;]/ or s/..../a,A;/;\n\n/,/ or s/.([;!]).*\\K.\\1/a$1/;\n/;/ or s/.([,!]).*\\K.\\1/A$1/;\n/!/ or s/.([,;]).*\\K.\\1/0$1/;\n\nprint y/,;!//rd"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tchomp;\n\ts/^[a-z][a-z]([a-z]+)$/A1$1/;\n\ts/^[A-Z][A-Z]([A-Z]+)$/a1$1/;\n\ts/^[0-9][0-9]([0-9]+)$/Aa$1/;\n\t!/[0-9]/ and \n\t\ts/([A-Z])([a-z])([a-z])/$1${2}1/ ||\n\t\ts/([a-z])([a-z])([A-Z])/1$2$3/ || \n\t\ts/([a-z])([A-Z])([a-z])/$1${2}1/ || \n\t\ts/([a-z])([A-Z])([A-Z])/$1${2}1/ ||\n\t\ts/([A-Z])([A-Z])([a-z])/1$2$3/ || \n\t\ts/([A-Z])([a-z])([A-Z])/$1${2}1/ || 0\n\t\t;\n\t!/[a-z]/ and \n\t\ts/([A-Z])([0-9])([0-9])/$1${2}1/ ||\n\t\ts/([0-9])([0-9])([A-Z])/1$2$3/ || \n\t\ts/([0-9])([A-Z])([0-9])/$1${2}1/ || \n\t\ts/([0-9])([A-Z])([A-Z])/$1${2}1/ ||\n\t\ts/([A-Z])([A-Z])([0-9])/1$2$3/ || \n\t\ts/([A-Z])([0-9])([A-Z])/$1${2}1/ || 0\n\t\t;\n\t!/[A-Z]/ and \n\t\ts/([a-z])([0-9])([0-9])/$1${2}1/ ||\n\t\ts/([0-9])([0-9])([a-z])/1$2$3/ || \n\t\ts/([0-9])([a-z])([0-9])/$1${2}1/ || \n\t\ts/([0-9])([a-z])([a-z])/$1${2}1/ ||\n\t\ts/([a-z])([a-z])([0-9])/1$2$3/ || \n\t\ts/([a-z])([0-9])([a-z])/$1${2}1/ || 0\n\t\t;\n\t\n\tprint;\n\t}"}, {"source_code": "<>;\n\nwhile(<>){\n    \n\ts/[a-z]\\K/,/g;\n\ts/[A-Z]\\K/;/g;\n\ts/[0-9]\\K/!/g;\n\t\n\t$re = '.(\\W).*\\K.\\1';\n\t\n\t0 while 0 ||\n\t\t!/,/ && s/$re/a,/ ||\n\t\t!/;/ && s/$re/A;/ ||\n\t\t!/!/ && s/$re/0!/ ||\n\t\t0;\n\t\n\tprint s/\\W//gr\n\t}"}], "src_uid": "81faa525ded9b209fb7d5d8fec95f38b"}
{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nchomp(my $n = <>);\nmy $ans = 0;\nmy $hashKeyCount;\nmy %h;\nchomp(my $line = <>);\nmy @socks = split(/ /,$line);\nforeach(@socks){\n        if(defined $h{$_}){\n                delete $h{$_};\n        }else{\n                $h{$_} = 1;\n                $hashKeyCount = keys %h;\n                $ans = $hashKeyCount > $ans ? $hashKeyCount : $ans;\n        }\n}\nprint \"$ans\\n\";\n", "positive_code": [{"source_code": "$/ = \"\"; $_ = <>; ($n, @x) = split;\nfor (@x) {\n\tif (exists $x{$_}) {\n\t\tdelete $x{$_};\n\t} else {\n\t\t$x{$_} = 1;\n\t\t$k = keys %x;\n\t\t$ans = $k > $ans? $k: $ans;\n\t}\n}\nprint $ans;"}], "negative_code": [{"source_code": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nchomp(my $n = <>);\nmy $ans = 0;\nmy $tableCount = 0;\nmy %h;\nchomp(my $line = <>);\nmy @socks = split(/ /,$line);\nforeach(@socks){\n\tif(defined $h{$_}){\n\t\tif($tableCount > $ans){\n\t\t\t$ans = $tableCount;\n\t\t\t$tableCount -= 1;\n\t\t}\n\t}else{\n\t\t$h{$_} = 1;\n\t\t$tableCount++;\n\t}\n}\nprint \"$ans\\n\";\n"}], "src_uid": "7f98c9258f3e127a782041c421d6317b"}
{"source_code": "$\\ = $/;\nwhile ($n = <>){\n\t$_ = <>;\n\t@_ = split;\n\tunshift @_, -1;\n\tundef %h;\n\tpush @m, 0, <>;\n\tfor (1 .. $n){\n\t#\tprint \"[[$_]]\";\n\t\t$h{$_} eq 1 and next;\n\t\t@pos = ( );\n\t\twhile ($m[$_] =~ /1/g){\n\t#\t\tprint \"[\",pos $m[$_],\"]\";\n\t\t\t$h{ pos $m[$_] } // ( push @pos, pos $m[$_] );\n\t\t\t$h{ pos $m[$_] } //= 0;\n\t\t\t}\n\t#\tprint \"@pos|\";\n\t\twhile (@pos){\n\t#\t\tprint \"<@pos>\";\n\t\t\t$p = shift @pos;\n\t\t\twhile ($m[$p] =~ /1/g){\n\t\t\t\t$h{ pos $m[$p] } // ( push @pos, pos $m[$p] );\n\t\t\t\t$h{ pos $m[$p] } //= 0;\n\t\t\t\t}\n\t\t\t\n\t\t}\n\t\t$, = $\";\n\t#\tprint keys %h, values %h;\n\t\t@h = ( );\n\t\t$h{$_} or push @h, $_ for keys %h;\n\t\t$h{$_} ||= 1 for keys %h;\n\t\t@h = sort {$a <=> $b} @h;\n\t#\tprint \"@h\";\n\t\t@n = ( );\n\t\tpush @n, $_[$_] for @h;\n\t\t@n = sort {$a <=> $b} @n;\n\t\t$_[$_] = shift @n for @h;\n\t\t}\n\t\t\n#\tprint \"((@_))\";\n\tshift @_;\n\tprint \"@_\";\n\t}", "positive_code": [{"source_code": "$n = <>;\n$_ = <>;\n@_ = (0, split);\n@m = (0, <>);\nfor (1 .. $n){\n\tnext if $h{$_};\n\t@pos = $_;\n\tdo {\n\t\t$p = shift @pos;\n\t\t$h{ pos $m[$p] } //= 0 * ( push @pos, pos $m[$p] )\n\t\twhile $m[$p] =~ /1/g\n\t} while @pos;\n\t@h = @n = ( );\n\t$h{$_} ||= 1 * ( push @h, $_ ) for keys %h;\n\t@h = sort {$a <=> $b} @h;\n\tpush @n, $_[$_] for @h;\n\t@n = sort {$a <=> $b} @n;\n\t$_[$_] = shift @n for @h;\n\t}\n\t\t\nshift @_;\nprint \"@_\""}, {"source_code": "$\\ = $/;\nwhile ($n = <>){\n\t$_ = <>;\n\t@_ = (0, split);\n\tundef %h;\n\tpush @m, 0, <>;\n\tfor (1 .. $n){\n\t\t$h{$_} eq 1 and next;\n\t\t@pos = ( );\n\t\twhile ($m[$_] =~ /1/g){\n\t\t\t$h{ pos $m[$_] } // ( push @pos, pos $m[$_] );\n\t\t\t$h{ pos $m[$_] } //= 0;\n\t\t\t}\n\t\twhile (@pos){\n\t\t\t$p = shift @pos;\n\t\t\twhile ($m[$p] =~ /1/g){\n\t\t\t\t$h{ pos $m[$p] } // ( push @pos, pos $m[$p] );\n\t\t\t\t$h{ pos $m[$p] } //= 0;\n\t\t\t\t}\n\t\t\t\n\t\t}\n\t\t@h = ( );\n\t\t$h{$_} or push @h, $_ for keys %h;\n\t\t$h{$_} ||= 1 for keys %h;\n\t\t@h = sort {$a <=> $b} @h;\n\t\t@n = ( );\n\t\tpush @n, $_[$_] for @h;\n\t\t@n = sort {$a <=> $b} @n;\n\t\t$_[$_] = shift @n for @h;\n\t\t}\n\t\t\n\tshift @_;\n\tprint \"@_\";\n\t}"}, {"source_code": "use warnings; use strict;\nmy $n = scalar <> + 0;\nmy @aa = split ' ', scalar <>; $_ += 0 foreach @aa;\n@aa == $n or die \"err\";\nmy @m = <>; \n@m == $n or die \"err\";\nforeach (@m){ chomp; $_ = [ split '', $_ ];  foreach (@$_) { $_ += 0; } @$_ == $n or die \"err\"; }\nmy @used = (0) x $n;\nmy @comp = ();\nmy @cc = ();\nsub dfs{ my $i = shift; \n    return if $used[$i];\n    $used[$i] = 1; push @cc, $i; \n    foreach (0 .. ($n-1)) {\n        dfs($_) if $m[$i][$_] == 1 || $m[$_][$i] == 1;\n        }\n    }\nsub numeric {$a <=> $b}\nforeach (0 .. ($n-1)){\n    dfs($_);\n    #print join(' ', @cc), \"\\n\";\n    push @comp, [sort numeric @cc] if @cc;\n    @cc = ();\n    }\nforeach (@comp){\n    #print join(' ', @$), \"\\n\";\n    @aa[@$_] = sort numeric @aa[@$_];\n    }\nprint join ' ', @aa;\nprint \"\\n\";\n"}], "negative_code": [{"source_code": "use warnings; use strict;\nmy $n = scalar <> + 0;\nmy @a = split ' ', scalar <>; $_ += 0 foreach @a;\n@a == $n or die \"err\";\nmy @m = <>; \n@m == $n or die \"err\";\nforeach (@m){ chomp; $_ = [ split '', $_ ];  foreach (@$_) { $_ += 0; } @$_ == $n or die \"err\"; }\nmy @used = (0) x $n;\nmy @comp = ();\nmy @cc = ();\nsub dfs{ my $i = shift; \n    return if $used[$i];\n    $used[$i] = 1; push @cc, $i; \n    foreach (0 .. ($n-1)) {\n        dfs($_) if $m[$i][$_] || $m[$_][$i];\n        }\n    }\nforeach (0 .. ($n-1)){\n    dfs($_);\n    push @comp, [sort @cc] if @cc;\n    @cc = ();\n    }\n@a[@$_] = sort @a[@$_] foreach (@comp);\nprint join ' ', @a;\nprint \"\\n\";\n"}, {"source_code": "use warnings; use strict;\nmy $n = scalar <> + 0;\nmy @a = split ' ', scalar <>; $_ += 0 foreach @a;\n@a == $n or die \"err\";\nmy @m = <>; \n@m == $n or die \"err\";\nforeach (@m){ chomp; $_ = [ split '', $_ ];  foreach (@$_) { $_ += 0; } }\nmy @used = (0) x $n;\nmy @comp = ();\nmy @cc = ();\nsub dfs{ my $i = shift; \n    return if $used[$i];\n    $used[$i] = 1; push @cc, $i; \n    foreach (0 .. ($n-1)) {\n        dfs($_) if $m[$i][$_];\n        }\n    }\nforeach (0 .. ($n-1)){\n    dfs($_);\n    push @comp, [sort @cc] if @cc;\n    @cc = ();\n    }\n@a[@$_] = sort @a[@$_] foreach (@comp);\nprint join ' ', @a;\nprint \"\\n\";\n"}, {"source_code": "use warnings; use strict;\nmy $n = scalar <> + 0;\nmy @a = split ' ', scalar <>; $_ += 0 foreach @a;\n@a == $n or die \"err\";\nmy @m = <>; \n@m == $n or die \"err\";\nforeach (@m){ chomp; $_ = [ split '', $_ ];  foreach (@$_) { $_ += 0; } @$_ == $n or die \"err\"; }\nmy @used = (0) x $n;\nmy @comp = ();\nmy @cc = ();\nsub dfs{ my $i = shift; \n    return if $used[$i];\n    $used[$i] = 1; push @cc, $i; \n    foreach (0 .. ($n-1)) {\n        dfs($_) if $m[$i][$_] == 1 || $m[$_][$i] == 1;\n        }\n    }\nforeach (0 .. ($n-1)){\n    dfs($_);\n    print join(' ', @cc), \"\\n\";\n    push @comp, [sort {$a <=> $b} @cc] if @cc;\n    @cc = ();\n    }\nforeach (@comp){\n    print join(' ', @$), \"\\n\";\n    @a[@$_] = sort @a[@$_];\n    }\nprint join ' ', @a;\nprint \"\\n\";\n"}, {"source_code": "use warnings; use strict;\nmy $n = scalar <> + 0;\nmy @aa = split ' ', scalar <>; $_ += 0 foreach @aa;\n@aa == $n or die \"err\";\nmy @m = <>; \n@m == $n or die \"err\";\nforeach (@m){ chomp; $_ = [ split '', $_ ];  foreach (@$_) { $_ += 0; } @$_ == $n or die \"err\"; }\nmy @used = (0) x $n;\nmy @comp = ();\nmy @cc = ();\nsub dfs{ my $i = shift; \n    return if $used[$i];\n    $used[$i] = 1; push @cc, $i; \n    foreach (0 .. ($n-1)) {\n        dfs($_) if $m[$i][$_] == 1 || $m[$_][$i] == 1;\n        }\n    }\nforeach (0 .. ($n-1)){\n    dfs($_);\n    #print join(' ', @cc), \"\\n\";\n    push @comp, [sort {$a <=> $b} @cc] if @cc;\n    @cc = ();\n    }\nforeach (@comp){\n    #print join(' ', @$), \"\\n\";\n    @aa[@$_] = sort @aa[@$_];\n    }\nprint join ' ', @aa;\nprint \"\\n\";\n"}, {"source_code": "use warnings; use strict;\nmy $n = scalar <> + 0;\nmy @a = split ' ', scalar <>; $_ += 0 foreach @a;\nmy @m = <>; $#m = $n-1;\nforeach (@m){ chomp; $_ = [ split '', $_ ];  foreach (@$_) { $_ += 0; } }\nmy @used = (0) x $n;\nmy @comp = ();\nmy @cc = ();\nsub dfs{ my $i = shift; \n    return if $used[$i];\n    $used[$i] = 1; push @cc, $i; \n    foreach (0 .. ($n-1)) {\n        dfs($_) if $m[$i][$_] || $m[$i][$_];\n        }\n    }\nforeach (0 .. ($n-1)){\n    dfs($_);\n    push @comp, [sort @cc] if @cc;\n    @cc = ();\n    }\n@a[@$_] = sort @a[@$_] foreach (@comp);\nprint join ' ', @a;\nprint \"\\n\";\n"}], "src_uid": "a67ea891cd6084ceeaace8894cf18e60"}
{"source_code": "<>;\n\nfor( split ' ', <> ){\n\t$m = $_ - 1 < 1e6 - $_ ? $_ - 1 : 1e6 - $_;\n\t$m > $M and $M = $m;\n\t}\n\nprint $M", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = split ' ', <>;\n\t\n\tmy @A;\n\t\n\tfor( @_ ){\n\t\tpush @A, ( sort { $a <=> $b } $_ - 1, 1e6 - $_ )[ 0 ];\n\t\t}\n\t\n\tprint +( sort { $b <=> $a } @A )[ 0 ];\n\t}"}], "negative_code": [], "src_uid": "f530e6f720dafaf8bff9324289b90b28"}
{"source_code": "=item\n797 B\n\nYou are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.\n\nYou should write a program which finds sum of the best subsequence.\nInput\n\nThe first line contains integer number n (1 ≤ n ≤ 105).\n\nThe second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.\nOutput\n\nPrint sum of resulting subseqeuence.\nExamples\nInput\n\n4\n-2 2 -3 1\n\nOutput\n\n3\n\nInput\n\n3\n2 -5 -3\n\nOutput\n\n-1\n=cut\n\nmy $n=<>;\nchomp $n;\nmy @vs=split(' ',<>);\n# print \"# $n : \",join('|',@vs),\"\\n\";\n\nmy @ps;\nmy @ns;\n\nmy $spos=0;\nfor(my $i=0;$i<$n;++$i) {\n  my $v=$vs[$i];\n  if($v>0) {\n    push @ps,$v;\n    $spos+=$v;\n  } else {\n    push @ns,$v;\n  }\n}\nif(($spos%2)==1) {\n  print \"$spos\\n\";\n  exit();\n}\n# print \"# spos=$spos : ps=@ps : ns=@ns\\n\";\n@ops=sort {$a-$b} grep {$_%2==1} @ps;\n@ons=sort {$a-$b} grep {$_%2==1} @ns;\n# print \"# ops=@ops : ons=@ons\\n\";\n\nmy $mp=scalar(@ops)>0 ? $ops[0] : 1e20;\nmy $mn=scalar(@ons)>0 ? -$ons[-1] : 1e20;\n\n$m=($mp<$mn ? $mp : $mn);\n# print \"# mp=$mp mn=$mn m=$m\\n\";\n$spos-=$m;\nprint \"$spos\\n\";\n", "positive_code": [{"source_code": "\n#!/usr/bin/perl\n\n$n = <>;\nchomp($n);\n\n$t = <>;\nchomp($t);\n@a = split(' ', $t);\n$max = -1e5;\n$min = 1e5;\n$sum = $x = $y = 0;\nfor ($i = 0; $i < $n; $i++){\n  if(@a[$i] % 2 == 0){\n    if(@a[$i] > 0){$sum += @a[$i];}\n  }\n  else {\n    if(@a[$i] > 0){$sum += @a[$i]; $min = $min > @a[$i] ? @a[$i] : $min; $x++;}\n    else {$max = $max < @a[$i] ? @a[$i] : $max; $y++;}\n  }\n}\nif($x == 0) {$sum += $max;}\nelsif($x % 2 == 0){\n  if($y == 0){$sum -= $min;}\n  else {\n  $sum += ($min > -1 * $max) ? ($max) : (-1 * $min);\n}}\nprint \"$sum\";\n"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\n$n = <>;\nchomp($n);\n\n$t = <>;\nchomp($t);\n@a = split(' ', $t);\n$max = -1e5;\n$min = 1e5;\n$sum = $x = $y = 0;\nfor ($i = 0; $i < $n; $i++){\n  if(@a[$i] % 2 == 0){\n    if(@a[$i] > 0){$sum += @a[$i];}\n  }\n  else {\n    if(@a[$i] > 0){$sum += @a[$i]; $min = $min > @a[$i] ? @a[$i] : $min; $x++;}\n    else {$max = $max < @a[$i] ? @a[$i] : $max; $y++;}\n  }\n}\nif($x == 0) {$sum += $max;}\nelsif($x % 2 == 0){\n  if($y == 0){$sum -= $min;}\n  else {\n  $sum += ($max + $min >= -1 * $min) ? ($max + $min) : (-1 * $min)};}\nprint \"$sum\";\n"}, {"source_code": "#!/usr/bin/perl\n\n$n = <>;\nchomp($n);\n\n$t = <>;\nchomp($t);\n@a = split(' ', $t);\n$max = -1e5;\n$min = 1e5;\n$sum = $x = $y = 0;\nfor ($i = 0; $i < $n; $i++){\n  if(@a[$i] % 2 == 0){\n    if(@a[$i] > 0){$sum += @a[$i];}\n  }\n  else {\n    if(@a[$i] > 0){$sum += @a[$i]; $min = $min > @a[$i] ? @a[$i] : $min; $x++;}\n    else {$max = $max < @a[$i] ? @a[$i] : $max; $y++;}\n  }\n}\nif($x == 0) {$sum += $max;}\nelsif($x % 2 == 0){$sum += ($max + $min >= 0) ? ($max + $min) : (-1 * $min)};\nprint \"$sum\";\n"}, {"source_code": "#!/usr/bin/perl\n\n$n = <>;\nchomp($n);\n\n$t = <>;\nchomp($t);\n@a = split(' ', $t);\n$max = -1e5;\n$min = 1e5;\n$sum = $x = $y = 0;\nfor ($i = 0; $i < $n; $i++){\n  if(@a[$i] % 2 == 0){\n    if(@a[$i] > 0){$sum += @a[$i];}\n  }\n  else {\n    if(@a[$i] > 0){$sum += @a[$i]; $min = $min > @a[$i] ? @a[$i] : $min; $x++;}\n    else {$max = $max < @a[$i] ? @a[$i] : $max; $y++;}\n  }\n}\nif($x == 0) {$sum += $max;}\nelsif($x % 2 == 0){$sum += ($max + $min >= -1 * $min) ? ($max + $min) : (-1 * $min)};\nprint \"$sum\";\n"}, {"source_code": "=item\n797 B\n\nYou are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.\n\nYou should write a program which finds sum of the best subsequence.\nInput\n\nThe first line contains integer number n (1 ≤ n ≤ 105).\n\nThe second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.\nOutput\n\nPrint sum of resulting subseqeuence.\nExamples\nInput\n\n4\n-2 2 -3 1\n\nOutput\n\n3\n\nInput\n\n3\n2 -5 -3\n\nOutput\n\n-1\n=cut\n\nmy $n=<>;\nchomp $n;\nmy @vs=split(' ',<>);\n# print \"# $n : \",join('|',@vs),\"\\n\";\n\nmy @ps;\nmy @ns;\n\nmy $spos=0;\nfor(my $i=0;$i<$n;++$i) {\n  my $v=$vs[$i];\n  if($v>0) {\n    push @ps,$v;\n    $spos+=$v;\n  } else {\n    push @ns,$v;\n  }\n}\nif($spos % 2 ==1) {\n  print \"$spos\\n\";\n  exit();\n}\n# print \"# spos=$spos : ps=@ps : ns=@ns\\n\";\n@ops=sort {$a-$b} grep {$_%2==1} @ps;\n@ons=sort {$a-$b} grep {$_%2==1} @ns;\n# print \"# ops=@ops : ons=@ons\\n\";\n\nmy $mp=scalar(@ops)>0 ? $ops[0] : 0;\nmy $mn=scalar(@ons)>0 ? -$ons[-1] : 0;\n\n$m=((0<$mp and $mp<$mn) ? $mp : $mn);\n# print \"# mp=$mp mn=$mn m=$m\\n\";\n$spos-=$m;\nprint \"$spos\\n\";\n"}, {"source_code": "=item\n797 B\n\nYou are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.\n\nYou should write a program which finds sum of the best subsequence.\nInput\n\nThe first line contains integer number n (1 ≤ n ≤ 105).\n\nThe second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.\nOutput\n\nPrint sum of resulting subseqeuence.\nExamples\nInput\n\n4\n-2 2 -3 1\n\nOutput\n\n3\n\nInput\n\n3\n2 -5 -3\n\nOutput\n\n-1\n=cut\n\nmy $n=<>;\nchomp $n;\nmy @vs=split(' ',<>);\nprint \"# $n : \",join('|',@vs),\"\\n\";\n\nmy @ps;\nmy @ns;\n\nmy $spos=0;\nfor(my $i=0;$i<$n;++$i) {\n  my $v=$vs[$i];\n  if($v>0) {\n    push @ps,$v;\n    $spos+=$v;\n  } else {\n    push @ns,$v;\n  }\n}\nif($spos % 2 ==1) {\n  print \"$spos\\n\";\n  exit();\n}\nprint \"# spos=$spos : ps=@ps : ns=@ns\\n\";\n@ops=sort {$a-$b} grep {$_%2==1} @ps;\n@ons=sort {$a-$b} grep {$_%2==1} @ns;\nprint \"# ops=@ops : ons=@ons\\n\";\n\nmy $mp=scalar(@ops)>0 ? $ops[0] : 0;\nmy $mn=scalar(@ons)>0 ? -$ons[-1] : 0;\n\n$m=((0<$mp and $mp<$mn) ? $mp : $mn);\nprint \"# mp=$mp mn=$mn m=$m\\n\";\n$spos-=$m;\nprint \"$spos\\n\";\n"}, {"source_code": "=item\n797 B\n\nYou are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.\n\nYou should write a program which finds sum of the best subsequence.\nInput\n\nThe first line contains integer number n (1 ≤ n ≤ 105).\n\nThe second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.\nOutput\n\nPrint sum of resulting subseqeuence.\nExamples\nInput\n\n4\n-2 2 -3 1\n\nOutput\n\n3\n\nInput\n\n3\n2 -5 -3\n\nOutput\n\n-1\n=cut\n\nmy $n=<>;\nchomp $n;\nmy @vs=split(' ',<>);\nprint \"# $n : \",join('|',@vs),\"\\n\";\n\nmy $m=-1e20;\nfor(my $i=0;$i<$n;++$i) {\n  my $s=0;\n  for(my $j=$i;$j<$n;++$j) {\n    $s+=$vs[$j];\n    if($s % 2 == 1 and $s>$m) {\n      $m=$s;\n    }\n  }\n}\nprint \"$m\\n\";"}, {"source_code": "#!/usr/bin/perl\n\n$n = <>;\nchomp($n);\n\n$t = <>;\nchomp($t);\n@a = split(' ', $t);\n$max = -1e5;\n$min = 1e5;\n$sum = $x = $y = 0;\nfor ($i = 0; $i < $n; $i++){\n  if(@a[$i] % 2 == 0){\n    if(@a[$i] > 0){$sum += @a[$i];}\n  }\n  else {\n    if(@a[$i] > 0){$sum += @a[$i]; $min = $min > @a[$i] ? @a[$i] : $min; $x++;}\n    else {$max = $max < @a[$i] ? @a[$i] : $max; $y++;}\n  }\n}\nif($x == 0) {$sum += $max;}\nelsif($x % 2 == 0){\n  if($y == 0){$sum -= $min;}\n  else {\n  $sum += ($max + $min >= -1 * $min) ? ($max) : (-1 * $min)};}\nprint \"$sum\";\n"}], "src_uid": "76dd49c5545770a1dfbb2da4140199c1"}
{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nprint 1 - <> ? NO : YES while <>", "positive_code": [{"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nprint 1 - <> ? NO : YES while <>"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\n<>;\n\nwhile(<>){\n\tprint 1 - <> ? 'NO' : 'YES';\n\t}"}, {"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nprint 1 - <> ? NO : YES while <>"}, {"source_code": "$\\ = $/;\r\n\r\n<>;\r\n\r\nprint 1 - <> ? NO : YES while <>"}], "negative_code": [], "src_uid": "76b3667cce9e23675e21caf6926f608d"}
{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nwhile(<>){\n\t@_ = ( 0 ) x ( $_ + 2 );\n\t\n\t$_[ $_ ] < 3 and $_[ $_ ] ++ for split ' ', <>;\n\t\n\t$_ = join '', @_;\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy( $cnt_min, $cnt_max ) = ( 0 ) x 2;\n\t\n\t0 while 0\n\t\t|| s/0((?:1.1)+)/ $cnt_min += ( length $1 ) \\/ 3, '0X' /ge\n\t\t|| s/[0X]\\K110/ $cnt_min += 1, 'X0' /ge\n\t\t;\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\t$cnt_max += s/1//g;\n\t\n\ts/[23]([23]+)/ $cnt_max += length $1, 3 /ge;\n\ts/(030|30|02|20)/ $cnt_max += length $1, '' /ge;\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}", "positive_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x $_;\n\t\n\tfor( split ' ', <> ){\n\t\t$_[ $_ - 1 ] ++ if $_[ $_ - 1 ] < 3;\n\t\t}\n\t\n\t$_ = join '', 0, @_, 0;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy $cnt_min = 0;\n\t\n\t$debug and print \"min:[$_]:$cnt_min\";\n\t\n\t0 while 0\n\t\t|| s/0((?:1.1)+)/ $cnt_min += ( length $1 ) \\/ 3, '0X' /ge\n\t\t|| s/0110/ $cnt_min += 1, '0X0' /ge\n\t\t|| s/X110/ $cnt_min += 1, 'XX0' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]:$cnt_min\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\tmy $cnt_max = 0;\n\t\n\ts/00\\K(0+)//g;\n\ts/11\\K(1+)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/0(1+)/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)0/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)/ $cnt_max += length $1, '' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/[23][23]\\K([23]+)/ $cnt_max += length $1, '' /ge\n\t\t|| s/[23][23]/ $cnt_max ++, 3 /ge\n\t\t|| s/030/ $cnt_max += 3, 'X' /ge\n\t\t|| s/X((?:0[23])+)/ $cnt_max += length $1, 'X' /ge\n\t\t|| s/((?:0[23])+)X/ $cnt_max += length $1, 'X' /ge\n\t\t|| s/X2X|X3X/ $cnt_max += 1, 'X' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t$cnt_max += 2 * ( () = /[23]/g );\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x ( $_ + 2 );\n\t\n\t$_[ $_ ] < 3 and $_[ $_ ] ++ for split ' ', <>;\n\t\n\t$_ = join '', @_;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy( $cnt_min, $cnt_max ) = ( 0 ) x 2;\n\t\n\t$debug and print \"min:[$_]:$cnt_min\";\n\t\n\t0 while 0\n\t\t|| s/0((?:1.1)+)/ $cnt_min += ( length $1 ) \\/ 3, '0X' /ge\n\t\t|| s/[0X]\\K110/ $cnt_min += 1, 'X0' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]:$cnt_min\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\t$cnt_max += s/1//g;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\ts/[23]([23]+)/ $cnt_max += length $1, 3 /ge;\n\ts/(030|30|02|20)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}], "negative_code": [{"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x $_;\n\t\n\tfor( split ' ', <> ){\n\t\t$_[ $_ - 1 ] ++ if $_[ $_ - 1 ] < 3;\n\t\t}\n\t\n\t$_ = join '', 0, @_, 0;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy $cnt_min = 0;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/111/ $cnt_min += 1, '' /ge\n\t\t|| s/101/ $cnt_min += 1, '' /ge\n\t\t|| s/11/ $cnt_min += 1, '' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\tmy $cnt_max = 0;\n\t\n\ts/00\\K(0+)//g;\n\ts/11\\K(1+)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/0(1+)/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)0/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)/ $cnt_max += length $1, '' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/[23][23]\\K([23]+)/ $cnt_max += length $1, '' /ge\n\t\t|| s/[23][23]/ $cnt_max ++, 3 /ge\n\t\t|| s/030/ $cnt_max += 3, 'X' /ge\n\t\t|| s/03X|X30|02X|X20/ $cnt_max += 2, 'X' /ge\n\t\t|| s/X2X|X3X/ $cnt_max += 1, 'X' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t$cnt_max += 2 * ( () = /[23]/g );\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x $_;\n\t\n\tfor( split ' ', <> ){\n\t\t$_[ $_ - 1 ] ++ if $_[ $_ - 1 ] < 3;\n\t\t}\n\t\n\t$_ = join '', 0, @_, 0;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy $cnt_min = 0;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/111/ $cnt_min += 1, '' /ge\n\t\t|| s/101/ $cnt_min += 1, '' /ge\n\t\t|| s/11/ $cnt_min += 1, '' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\tmy $cnt_max = 0;\n\t\n\ts/00\\K(0+)//g;\n\ts/11\\K(1+)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/0(1+)/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)0/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)/ $cnt_max += length $1, '' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/[23][23]\\K([23]+)/ $cnt_max += length $1, '' /ge\n\t\t|| s/[23][23]/ $cnt_max ++, 3 /ge\n\t\t|| s/030/ $cnt_max += 3, '' /ge\n\t\t|| s/030/111/g\n\t\t;\n\t\n\t$debug and print \"max:[$_]\";\n\t\n\t$cnt_max += 2 * ( () = /[^0]/g );\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x $_;\n\t\n\tfor( split ' ', <> ){\n\t\t$_[ $_ - 1 ] ++ if $_[ $_ - 1 ] < 3;\n\t\t}\n\t\n\t$_ = join '', 0, @_, 0;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy $cnt_min = 0;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/111/ $cnt_min += 1, '' /ge\n\t\t|| s/101/ $cnt_min += 1, '' /ge\n\t\t|| s/11/ $cnt_min += 1, '' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\tmy $cnt_max = 0;\n\t\n\ts/00\\K(0+)//g;\n\ts/11\\K(1+)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/0(1+)/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)0/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)/ $cnt_max += length $1, '' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/[23][23]\\K([23]+)/ $cnt_max += length $1, '' /ge\n\t\t|| s/[23][23]/ $cnt_max ++, 3 /ge\n\t\t|| s/030/ $cnt_max += 3, 'X' /ge\n\t\t|| s/03X|X30|02X|X20/ $cnt_max += 2, 'X' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t$cnt_max += 2 * ( () = /[23]/g );\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x $_;\n\t\n\tfor( split ' ', <> ){\n\t\t$_[ $_ - 1 ] ++ if $_[ $_ - 1 ] < 3;\n\t\t}\n\t\n\t$_ = join '', 0, @_, 0;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy $cnt_min = 0;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/0(1.1)+/ $cnt_min += ( length $1 ) \\/ 3, '0X' /ge\n\t\t|| s/0110/ $cnt_min += 1, '0X0' /ge\n\t\t|| s/X110/ $cnt_min += 1, 'XX0' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\tmy $cnt_max = 0;\n\t\n\ts/00\\K(0+)//g;\n\ts/11\\K(1+)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/0(1+)/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)0/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)/ $cnt_max += length $1, '' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t0 while 0\n\t\t|| s/[23][23]\\K([23]+)/ $cnt_max += length $1, '' /ge\n\t\t|| s/[23][23]/ $cnt_max ++, 3 /ge\n\t\t|| s/030/ $cnt_max += 3, 'X' /ge\n\t\t|| s/03X|X30|02X|X20/ $cnt_max += 2, 'X' /ge\n\t\t|| s/X2X|X3X/ $cnt_max += 1, 'X' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]:$cnt_max\";\n\t\n\t$cnt_max += 2 * ( () = /[23]/g );\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}, {"source_code": "#!/usr/bin/perl\n\nuse warnings;\nuse strict;\n\n$\\ = $/;\n\nmy $debug = 0;\n\nwhile(<>){\n\t$debug and print '-' x 15;\n\t@_ = ( 0 ) x $_;\n\t\n\tfor( split ' ', <> ){\n\t\t$_[ $_ - 1 ] ++ if $_[ $_ - 1 ] < 3;\n\t\t}\n\t\n\t$_ = join '', 0, @_, 0;\n\t\n\t$debug and print \"....[$_]\";\n\t\n\tmy $copy = $_;\n\t\n\ty/1-9/1/;\n\t\n\tmy $cnt_min = 0;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/11(1+)/ $cnt_min += length $1, '' /ge\n\t\t|| s/11/ $cnt_min += 1, '' /ge\n\t\t|| s/101/ $cnt_min += 1, '' /ge\n\t\t;\n\t\n\t$debug and print \"min:[$_]\";\n\t\n\t$cnt_min += () = /1/g;\n\t\n\t$_ = $copy;\n\t\n\tmy $cnt_max = 0;\n\t\n\ts/00\\K(0+)//g;\n\ts/11\\K(1+)/ $cnt_max += length $1, '' /ge;\n\t\n\t$debug and print \"max:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/0(1+)/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)0/ $cnt_max += length $1, 0 /ge\n\t\t|| s/(1+)/ $cnt_max += length $1, '' /ge\n\t\t;\n\t\n\t$debug and print \"max:[$_]\";\n\t\n\t0 while 0\n\t\t|| s/[23][23]\\K([23]+)/ $cnt_max += length $1, '' /ge\n\t\t|| s/[23][23]/ $cnt_max ++, 3 /ge\n\t\t|| s/030/ $cnt_max += 3, '' /ge\n\t\t|| s/030/111/g\n\t\t;\n\t\n\t$debug and print \"max:[$_]\";\n\t\n\t$cnt_max += 2 * ( () = /[^0]/g );\n\t\n\tprint \"$cnt_min $cnt_max\";\n\t}"}], "src_uid": "c1e51cc003cbf60a617fc11de9c73bcf"}