Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p00016
include Math theta = 90.0 puts $<.to_a.map{|i|i.split(',')}.map{|i|i.map(&:to_i)}.collect{|a| ret = [a[0] * cos(theta*PI/180.0), a[0] * sin(theta*PI/180.0)] theta -= a[1] ret }.transpose.map{|i|i.inject(:+)}.join("\n")
include Math theta = 90.0 puts $<.to_a.map{|i|i.split(',')}.map{|i|i.map(&:to_i)}.collect{|a| ret = [a[0] * cos(theta*PI/180.0), a[0] * sin(theta*PI/180.0)] theta -= a[1] ret }.transpose.map{|i|i.inject(:+).to_i}.join("\n")
[ "call.add" ]
15,394
15,395
u585414111
ruby
p00018
num = gets.split(&:to_i) num = num.sort.reverse puts num.join(" ")
num = gets.split.map(&:to_i) num = num.sort.reverse puts num.join(" ")
[ "call.add" ]
15,993
15,994
u142551424
ruby
p00018
a = gets.split(&:to_i) a = a.sort.reverse puts a.join(" ")
num = gets.split.map(&:to_i) num = num.sort.reverse puts num.join(" ")
[ "assignment.variable.change", "identifier.change", "call.add", "assignment.value.change", "call.arguments.change", "io.output.change" ]
15,996
15,994
u142551424
ruby
p00018
str = STDIN.gets nums = str.split(" ") nums.map(&:to_i) nums = nums.sort {|a, b| b <=> a } puts nums.join(" ")
str = STDIN.gets nums = str.split(" ") nums.map!(&:to_i) nums = nums.sort {|a, b| b <=> a } puts nums.join(" ")
[ "identifier.change" ]
16,017
16,018
u626163867
ruby
p00018
while gets a = $_.split(" ").map{|val| val.to_i} a.sort! for i in 0...a.size print " " if i != 0 print a[i] end puts end
while gets a = $_.split(" ").map{|val| val.to_i} a.sort!.reverse! for i in 0...a.size print " " if i != 0 print a[i] end puts end
[ "call.add" ]
16,022
16,023
u714310715
ruby
p00018
#encoding: utf-8 arr = gets.rstrip.split(/\s/).map(&:to_i) arr = arr.sort puts arr.join(" ")
#encoding: utf-8 arr = gets.rstrip.split(/\s/).map(&:to_i) arr = arr.sort.reverse puts arr.join(" ")
[ "call.add" ]
16,024
16,025
u284474275
ruby
p00019
STDIN.gets.chomp.to_i.downto(2).inject(1) { |a, e| a * e }
puts STDIN.gets.chomp.to_i.downto(2).inject(1) { |a, e| a * e }
[ "io.output.change", "call.add" ]
17,033
17,034
u919623882
ruby
p00019
n = gets.chomp result = 1 while n > 0 do result *= n n -= 1 end puts result
n = gets.to_i result = 1 while n > 0 do result *= n n -= 1 end puts result
[ "assignment.value.change", "identifier.change" ]
17,040
17,041
u936629935
ruby
p00019
while n = gets.to_i && n def fact(n) n > 0 ? n * fact(n - 1) : 1 end puts fact(n) end
while n = gets n = n.to_i def fact(n) n > 0 ? n * fact(n - 1) : 1 end puts fact(n) end
[ "expression.operation.binary.remove" ]
17,044
17,043
u642047787
ruby
p00020
p gets.upcase
puts gets.upcase
[ "call.function.change", "io.output.change" ]
18,172
18,173
u431700612
ruby
p00021
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts (a-c)*(f-h)-(b-d)*(e-g)>1e-3?:YES: :NO}
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs<1e-10?:YES: :NO}
[ "control_flow.branch.if.condition.change" ]
19,237
19,238
u890794282
ruby
p00021
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts (a-c)*(f-h)-(b-d)*(e-g)<1e-3?:YES: :NO}
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs<1e-10?:YES: :NO}
[ "control_flow.branch.if.condition.change", "call.add", "literal.number.float.change" ]
19,239
19,238
u890794282
ruby
p00021
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs>1e-3?:YES: :NO}
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs<1e-10?:YES: :NO}
[]
19,240
19,238
u890794282
ruby
p00021
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs>1e-9?:YES: :NO}
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs<1e-10?:YES: :NO}
[]
19,241
19,238
u890794282
ruby
p00021
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs>1e-11?:YES: :NO}
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs<1e-10?:YES: :NO}
[]
19,242
19,238
u890794282
ruby
p00021
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs>1e-15?:YES: :NO}
gets $<.map{|l|a,b,c,d,e,f,g,h=l.split.map &:to_f puts ((a-c)*(f-h)-(b-d)*(e-g)).abs<1e-10?:YES: :NO}
[]
19,243
19,238
u890794282
ruby
p00021
n=gets.to_i;n.times{a,b,c,d,e,f,g,h=gets.split.map &:to_f;puts ((c-a)*(h-f)-(d-b)*(g-e)).abs<1e9 ?"YES":"NO"}
n=gets.to_i;n.times{a,b,c,d,e,f,g,h=gets.split.map &:to_f;puts ((c-a)*(h-f)-(d-b)*(g-e)).abs<1e-10 ?"YES":"NO"}
[ "literal.number.float.change", "control_flow.branch.if.condition.change" ]
19,245
19,246
u823513038
ruby
p00021
n=gets.to_i;n.times{a,b,c,d,e,f,g,h=gets.split.map &:to_f;puts ((c-a)*(h-f)-(d-b)*(g-e)).abs<1e10 ?"YES":"NO"}
n=gets.to_i;n.times{a,b,c,d,e,f,g,h=gets.split.map &:to_f;puts ((c-a)*(h-f)-(d-b)*(g-e)).abs<1e-10 ?"YES":"NO"}
[ "literal.number.float.change", "control_flow.branch.if.condition.change" ]
19,247
19,246
u823513038
ruby
p00021
num = gets.chomp.to_i num.times do |n| x1, y1, x2, y2, x3, y3, x4, y4 = gets.chomp.split(" ").map(&:to_f) if y2 == y1 || y4 == y3 if y2 == y1 && y4 == y3 puts "YES" else puts "NO" end next elsif (x2 - x1)/(y2 - y1) - (x4 - x3)/(y4 - y3) < 1e-10 ...
num = gets.chomp.to_i num.times do |n| x1, y1, x2, y2, x3, y3, x4, y4 = gets.chomp.split(" ").map(&:to_f) if y2 == y1 || y4 == y3 if y2 == y1 && y4 == y3 puts "YES" else puts "NO" end next elsif ((x2 - x1)/(y2 - y1) - (x4 - x3)/(y4 - y3)).abs < 1e-10 ...
[ "control_flow.branch.if.condition.change", "call.add" ]
19,257
19,258
u720435069
ruby
p00023
(gets.to_i).times do xa,ya,ra,xb,yb,rb=gets.chomp.split(nil).map(&:to_f) r=Math::sqrt((xa-xb)**2+(ya-yb)**2) if(d+rb)<ra puts 2 elsif(d+ra)<rb puts -2 elsif d<(ra+rb) puts 1 else puts 0 end end
(gets.to_i).times do xa,ya,ra,xb,yb,rb=gets.chomp.split(nil).map(&:to_f) r=Math::sqrt((xa-xb)**2+(ya-yb)**2) if(r+rb)<ra puts 2 elsif(r+ra)<rb puts -2 elsif r<=(ra+rb) puts 1 else puts 0 end end
[ "identifier.change", "control_flow.branch.if.condition.change" ]
19,426
19,425
u287407095
ruby
p00023
class Circle def compare(list) xa, ya, ra, xb, yb, rb = list cd = center_distance(xa, ya, xb, yb) return 0 if cd > (ra - rb).abs return 2 if cd + rb < ra return -2 if cd + ra < rb 0 end def center_distance(xa, ya, xb, yb) ((ya - yb)**2 + (xa - xb)**2)**(1 / 2.0) end end n = STDIN...
class Circle def compare(list) xa, ya, ra, xb, yb, rb = list cd = center_distance(xa, ya, xb, yb) return 0 if cd > ra + rb return 2 if cd + rb < ra return -2 if cd + ra < rb 1 end def center_distance(xa, ya, xb, yb) ((ya - yb)**2 + (xa - xb)**2)**(1 / 2.0) end end n = STDIN.gets....
[ "control_flow.branch.if.condition.change", "misc.opposites", "expression.operator.arithmetic.change", "call.remove", "literal.number.integer.change" ]
19,431
19,432
u919623882
ruby
p00023
n = readline.chomp.to_i n.times do |i| (xa, ya, ra, xb, yb, rb) = file.readline.chomp.split(' ').map(&:to_f) l = Math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2) r = ra + rb if r < l p 0 elsif (ra - rb).abs <= l and l <= ra + rb p 1 else if rb > ra p 2 else p -2 end end end
n = readline.chomp.to_i n.times do |i| (xa, ya, ra, xb, yb, rb) = readline.chomp.split(' ').map(&:to_f) l = Math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2) r = ra + rb if r < l p 0 elsif (ra - rb).abs <= l and l <= ra + rb p 1 else if ra > rb p 2 else p -2 end end end
[ "call.remove", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
19,433
19,434
u580616456
ruby
p00023
#!/usr/local/bin/ruby n=gets.to_i n.times{ xa,ya,ra,xb,yb,rb=gets.split.map(&:to_f) d=Math.sqrt((ya-xa)**2+(yb-ya)**2) if d < ra-rb puts "2" elsif d < rb-ra puts"-2" elsif d > ra +rb puts"0" else puts "1" end }
#!/usr/local/bin/ruby n=gets.to_i n.times{ xa,ya,ra,xb,yb,rb=gets.split.map(&:to_f) d=Math.sqrt((xb-xa)**2+(yb-ya)**2) if d < ra-rb puts "2" elsif d < rb-ra puts"-2" elsif d > ra +rb puts"0" else puts "1" end }
[ "assignment.value.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
19,452
19,453
u679425694
ruby
p00023
def length(xa, ya, xb, yb) Math.sqrt((xa - xb)**2 + (ya - yb)**2) end n = gets.to_i while gets xa, ya, ra, xb, yb, rb = $_.split(' ').map(&:to_f) l = length(xa, ya, xb, yb) if ra > l + rb out = 2 elsif rb > l + ra out = -2 elsif ra + rb == l out = 1 else out = 0 end puts out end
def length(xa, ya, xb, yb) Math.sqrt((xa - xb)**2 + (ya - yb)**2) end n = gets.to_i while gets xa, ya, ra, xb, yb, rb = $_.split(' ').map(&:to_f) l = length(xa, ya, xb, yb) if ra > l + rb out = 2 elsif rb > l + ra out = -2 elsif ra + rb < l out = 0 else out = 1 end puts out end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
19,457
19,458
u708217907
ruby
p00023
n = gets.to_i n.times do xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f) d = Math.sqrt( (xa - xb) ** 2 - (ya - yb) ** 2 ) if ra > rb + d then puts 2 elsif rb > ra + d then puts -2 elsif d <= ra + rb puts 1 else puts 0 end end
n = gets.to_i n.times do xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f) d = Math.sqrt( (xa - xb) ** 2 + (ya - yb) ** 2 ) if ra > rb + d then puts 2 elsif rb > ra + d then puts -2 elsif d <= ra + rb then puts 1 else puts 0 end end
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
19,459
19,460
u642047787
ruby
p00023
n = gets.to_i n.times do xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f) d = Math.sqrt( (xa - xb) ** 2 - (ya - yb) ** 2 ) if ra > rb + d then puts 2 elsif rb > ra + d then puts -2 elsif d <= ra + rb then puts 1 else puts 0 end end
n = gets.to_i n.times do xa, ya, ra, xb, yb, rb = gets.split.map(&:to_f) d = Math.sqrt( (xa - xb) ** 2 + (ya - yb) ** 2 ) if ra > rb + d then puts 2 elsif rb > ra + d then puts -2 elsif d <= ra + rb then puts 1 else puts 0 end end
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
19,461
19,460
u642047787
ruby
p00023
def relation(xa, ya, ra, xb, yb, rb) d = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5 return 0 if ra + rb <= d return 2 if d + rb <= ra return -2 if d + ra <= rb return 1 end $<.gets.to_i.times do p relation(*$<.gets.split.map(&:to_i)) end
def relation(xa, ya, ra, xb, yb, rb) d = ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5 return 0 if ra + rb < d return 2 if d + rb < ra return -2 if d + ra < rb return 1 end $<.gets.to_i.times do p relation(*$<.gets.split.map(&:to_f)) end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
19,462
19,463
u238839772
ruby
p00023
class Vector attr_accessor :x, :y def initialize(x, y) @x = x @y = y end def length() Math.sqrt(@x**2 + @y**2) end def self.minus(v1, v2) return Vector.new(v1.x - v2.x, v1.y - v2.y) end end if __FILE__ == $0 n = gets.to_i n.times do xa, ya, ra, xb, yb, rb = gets.split.map{|i| ...
class Vector attr_accessor :x, :y def initialize(x, y) @x = x @y = y end def length() Math.sqrt(@x**2 + @y**2) end def self.minus(v1, v2) return Vector.new(v1.x - v2.x, v1.y - v2.y) end end if __FILE__ == $0 n = gets.to_i n.times do xa, ya, ra, xb, yb, rb = gets.split.map{|i| ...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
19,466
19,467
u533406606
ruby
p00022
while true n = gets.to_i break if n==0 a = Array.new(n){gets.to_i} max = a.max if n>1 for k in 1..n ksum = a[0..k-1].inject(:+) max = ksum if ksum>max for l in 0..n-k ksum += a[k+l]-a[l] max = ksum if ksum>max end end end puts max end
while true n = gets.to_i break if n==0 a = Array.new(n){gets.to_i} max = a.max if n>1 for k in 2..n ksum = a[0..k-1].inject(:+) max = ksum if ksum>max for l in 0..n-k-1 ksum += a[k+l]-a[l] max = ksum if ksum>max end end end puts max end
[ "literal.number.integer.change" ]
19,986
19,987
u217294278
ruby
p00022
while true n = gets.to_i break if n==0 a = Array.new(n){gets.to_i} max = a.max if n>1 for k in 2..n ksum = a[0..k-1].inject(:+) max = ksum if ksum>max for l in 0..n-k ksum += a[k+l]-a[l] max = ksum if ksum>max end end end puts max end
while true n = gets.to_i break if n==0 a = Array.new(n){gets.to_i} max = a.max if n>1 for k in 2..n ksum = a[0..k-1].inject(:+) max = ksum if ksum>max for l in 0..n-k-1 ksum += a[k+l]-a[l] max = ksum if ksum>max end end end puts max end
[ "expression.operation.binary.add" ]
19,988
19,987
u217294278
ruby
p00022
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max > sum sum = 0 if sum.negative? end puts sum end
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts max end
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "call.arguments.change", "io.output.change" ]
19,993
19,994
u708217907
ruby
p00022
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max > sum sum = 0 if sum < 0 end puts sum end
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts max end
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "call.arguments.change", "io.output.change" ]
19,995
19,994
u708217907
ruby
p00022
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max > sum sum = 0 if sum < 0 end puts sum.to_s end
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts max end
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.arguments.change", "io.output.change", "call.remove" ]
19,996
19,994
u708217907
ruby
p00022
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts sum.to_s end
loop do n = gets.to_i break if n == 0 max = -1_000_000 sum = 0 n.times do m = gets.to_i sum += m max = sum if max < sum sum = 0 if sum < 0 end puts max end
[ "call.arguments.change", "io.output.change", "call.remove" ]
19,997
19,994
u708217907
ruby
p00022
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = -Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
[ "expression.operation.unary.add" ]
20,001
20,000
u139670451
ruby
p00022
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = Float::MIN n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = -Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
[ "expression.operation.unary.add", "assignment.value.change" ]
20,002
20,000
u139670451
ruby
p00022
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = Float::INFINITY n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = -100_000 n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
[]
20,001
20,004
u139670451
ruby
p00022
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = Float::MIN n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
loop do n = gets.to_i break if n.zero? a = [] n.times do |i| a << gets.to_i end max = -100_000 n.times do |i| sum = 0 a[i..-1].each do |_a| sum += _a max = sum if sum > max end end puts max end
[]
20,002
20,004
u139670451
ruby
p00024
while line = gets v = line.chomp.to_f t = v / 9.8 y = 4.9 * t * t puts ((y + 1) / 5).ceil + 1 end
while line = gets v = line.chomp.to_f t = v / 9.8 y = 4.9 * t**2 puts ((y + 5) / 5).ceil end
[ "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "expression.operation.binary.remove" ]
20,299
20,300
u024281398
ruby
p00024
while line = gets v = line.chomp.to_f t = v / 9.8 y = 4.9 * t * t puts ((y + 5) / 5 + 2).floor end
while line = gets v = line.chomp.to_f t = v / 9.8 y = 4.9 * t**2 puts ((y + 5) / 5).ceil end
[ "expression.operation.binary.remove", "misc.opposites", "identifier.change", "call.arguments.change", "io.output.change" ]
20,301
20,300
u024281398
ruby
p00024
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t**2 n = ( y + 5 ) / 5 n = n.ceil puts n break end
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t**2 n = ( y + 5 ) / 5 n = n.ceil puts n end
[ "control_flow.break.remove" ]
20,302
20,303
u361342984
ruby
p00024
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t*2*2 n = ( y + 5 ) / 5 n = n.ceil puts n break end
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t**2 n = ( y + 5 ) / 5 n = n.ceil puts n end
[ "assignment.value.change", "expression.operation.binary.change", "expression.operation.binary.remove", "control_flow.break.remove" ]
20,304
20,303
u361342984
ruby
p00024
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t*t n = ( y + 5 ) / 5 n = n.ceil puts n break end
while line = gets v = line.to_f t = v / 9.8 y = 4.9 * t**2 n = ( y + 5 ) / 5 n = n.ceil puts n end
[ "control_flow.break.remove" ]
20,305
20,303
u361342984
ruby
p00024
while gets do v = '25.4'.to_f t = v/9.8 y = 4.9*t*t puts ((y+5.0)/5.0).ceil end
while gets do v = $_.to_f t = v/9.8 y = 4.9*t*t puts ((y+5.0)/5.0).ceil end
[]
20,312
20,313
u708217907
ruby
p00024
#!/usr/local/bin/ruby while gets x=gets.to_i t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
#!/usr/local/bin/ruby while line=gets v=line.to_f t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
[ "assignment.variable.change", "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change" ]
20,316
20,317
u679425694
ruby
p00024
#!/usr/local/bin/ruby while line=gets x=line.to_i t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
#!/usr/local/bin/ruby while line=gets v=line.to_f t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
[ "assignment.variable.change", "identifier.change", "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change" ]
20,318
20,317
u679425694
ruby
p00024
#!/usr/local/bin/ruby while line=gets v=line.to_i t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
#!/usr/local/bin/ruby while line=gets v=line.to_f t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
[ "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change" ]
20,319
20,317
u679425694
ruby
p00024
#!/usr/local/bin/ruby while line=gets v=line.to_i t=v/9.8 y=4.9*t**2 n=(y+5)/5+1 puts n.ceil end
#!/usr/local/bin/ruby while line=gets v=line.to_f t=v/9.8 y=4.9*t**2 n=(y+5)/5 puts n.ceil end
[ "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change", "expression.operation.binary.remove" ]
20,320
20,317
u679425694
ruby
p00025
while gets a=$<.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times do |i| if a[i]==b[i] then c+=1 else 4.times do |j| if a[i]==b[j] then d+=1;break; end end end end print c," ",d,"\n" end
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times do |i| if a[i]==b[i] then c+=1 else 4.times do |j| if a[i]==b[j] then d+=1;break; end end end end print c," ",d,"\n" end
[ "assignment.value.change" ]
20,674
20,673
u198011997
ruby
p00025
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } p "#{c} #{d}" end
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } puts "#{c} #{d}" end
[ "call.function.change", "io.output.change" ]
20,675
20,676
u198011997
ruby
p00025
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c,d=0,0; 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } p "#{c} #{d}" end
while gets a=$_.split.map(&:to_i) b=gets.split.map(&:to_i) c=d=0 4.times{|i| c+=1 if a[i]==b[i] d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i] } puts "#{c} #{d}" end
[ "call.function.change", "io.output.change" ]
20,675
20,677
u198011997
ruby
p00025
abs = [] begin while line = $stdin.gets.chomp break if line == "" a = line.split(" ") b = $stdin.gets.chomp.split(" ") abs.push({:a => a, :b => b}) end rescue end abs.each{|ab| hit = 0 blow = 0 ab[:a].each_with_index{|an, i| hit += 1 if ab[:b][i] == an blow += 1 if ab[:b].count(an) ...
abs = [] begin while line = $stdin.gets.chomp break if line == "" a = line.split(" ") b = $stdin.gets.chomp.split(" ") abs.push({:a => a, :b => b}) end rescue end abs.each{|ab| hit = 0 blow = 0 ab[:a].each_with_index{|an, i| hit += 1 if ab[:b][i] == an blow += 1 if ab[:b].count(an) ...
[]
20,678
20,679
u789070388
ruby
p00025
#!/usr/bin/ruby until (a = gets).nil? a = a.split; b = gets.split hit = a.map.with_index{|e,i| e == b[i-1]}.count(true) blow = (a & b).size - hit puts "#{hit} #{blow}" end
#!/usr/bin/ruby until (a = gets).nil? a = a.split; b = gets.split hit = a.map.with_index{|e,i| e == b[i]}.count(true) blow = (a & b).size - hit puts "#{hit} #{blow}" end
[ "expression.operation.binary.remove" ]
20,680
20,681
u549203837
ruby
p00025
input = gets(nil) a = [] b = [] input.split("\n").each_with_index do |line, i| if i % 2 == 0 a = line.split(" ").map(&:to_i) next end b = line.split(" ").map(&:to_i) s1 = 0 s2 = 0 0.upto(3) do |i| s1 += 1 if a[i] == b[i] s2 += 1 if a.include?(b[i]) end puts "#{s1} #{s2}" end
input = gets(nil) a = [] b = [] input.split("\n").each_with_index do |line, i| if i % 2 == 0 a = line.split(" ").map(&:to_i) next end b = line.split(" ").map(&:to_i) s1 = 0 s2 = 0 0.upto(3) do |i| s1 += 1 if a[i] == b[i] s2 += 1 if a.include?(b[i]) end puts "#{s1} #{s2-s1}" end
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
20,684
20,685
u503026981
ruby
p00027
class WhatDayIsToday def initialize init_ndays init_week init_calendar end def init_ndays @ndays = Array.new(12, 31) @ndays[1] = 29 @ndays[3] = @ndays[5] = @ndays[8] = @ndays[10] = 31 end def init_week @week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "...
class WhatDayIsToday def initialize init_ndays init_week init_calendar end def init_ndays @ndays = Array.new(12, 31) @ndays[1] = 29 @ndays[3] = @ndays[5] = @ndays[8] = @ndays[10] = 30 end def init_week @week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "...
[ "literal.number.integer.change", "assignment.value.change" ]
20,862
20,863
u750346935
ruby
p00027
#!/usr/bin/ruby Time.new(2004, *$_.split.map(&:to_i)).strftime("%A") while gets != "0 0\n"
#!/usr/bin/ruby puts Time.new(2004, *$_.split.map(&:to_i)).strftime("%A") while gets != "0 0\n"
[ "io.output.change", "call.add" ]
20,866
20,867
u549203837
ruby
p00027
# AOJ 0027 What day is today? days_in_a_month = [31, 29, 30, 30, 31, 30, 31, 31, 30, 31, 30, 31] offset = [] days_in_a_month.each.with_index do |d, m| offset[m] = m.zero? ? 0 : days_in_a_month[0..(m - 1)].reduce(0, :+) end the_day = %w[Thursday Friday Saturday Sunday Monday Tuesday Wednesday] loop do month, day ...
# AOJ 0027 What day is today? days_in_a_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] offset = [] days_in_a_month.each.with_index do |d, m| offset[m] = m.zero? ? 0 : days_in_a_month[0..(m - 1)].reduce(0, :+) end the_day = %w[Thursday Friday Saturday Sunday Monday Tuesday Wednesday] loop do month, day ...
[ "literal.number.integer.change", "assignment.value.change" ]
20,870
20,871
u593170857
ruby
p00026
# Paper class Paper def initialize(x, y) @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) } end def dye(x, y, size) case size when 1 dense(x, y) dense(x, y - 1) dense(x + 1, y) dense(x, y + 1) dense(x - 1, y) when 2 dense(x, y) dense(x, y - 1) ...
# Paper class Paper def initialize(x, y) @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) } end def dye(x, y, size) case size when 1 dense(x, y) dense(x, y - 1) dense(x + 1, y) dense(x, y + 1) dense(x - 1, y) when 2 dense(x, y) dense(x, y - 1) ...
[ "identifier.change", "call.arguments.change", "io.output.change" ]
21,272
21,273
u024281398
ruby
p00026
# Paper class Paper def initialize(x, y) @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) } end def dye(x, y, size) case size when 1 dense(x, y) dense(x, y - 1) dense(x + 1, y) dense(x, y + 1) dense(x - 1, y) when 2 dense(x, y) dense(x, y - 1) ...
# Paper class Paper def initialize(x, y) @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) } end def dye(x, y, size) case size when 1 dense(x, y) dense(x, y - 1) dense(x + 1, y) dense(x, y + 1) dense(x - 1, y) when 2 dense(x, y) dense(x, y - 1) ...
[]
21,274
21,273
u024281398
ruby
p00026
#!/usr/bin/ruby @paper = Array.new(10) @paper.map!{|c| c = Array.new(10, 0) } @patt = [[[-1,0],[0,-1],[0,0],[0,1],[1,0]], \ [[-1,-1],[-1,1],[1,1],[1,-1]], \ [[0,-2],[-2,0],[2,0],[0,2]]] def drop(x, y, num) @patt[num].each do |xa, ya| next unless [x+xa, y+ya].any?{|x| (0...10) === x} @paper[...
#!/usr/bin/ruby @paper = Array.new(10) @paper.map!{|c| c = Array.new(10, 0) } @patt = [[[-1,0],[0,-1],[0,0],[0,1],[1,0]], \ [[-1,-1],[-1,1],[1,1],[1,-1]], \ [[0,-2],[-2,0],[2,0],[0,2]]] def drop(x, y, num) @patt[num].each do |xa, ya| next unless [x+xa, y+ya].all?{|x| (0...10) === x} @paper[...
[ "identifier.change" ]
21,275
21,276
u549203837
ruby
p00028
data = Array.new() i = 0 while data[i] = gets do i += 1 end j = 0 number = Array.new() while out = data[j] out = out.chomp number[j] = out.to_i j += 1 end ten = Array.new(100,0) number = number.sort score = number.uniq i=0 j=0 k=0 for i in score do for j in number do if i == j ten[k] = ten[k] + 1 e...
data = Array.new() i = 0 while data[i] = gets do i += 1 end j = 0 number = Array.new() while out = data[j] out = out.chomp number[j] = out.to_i j += 1 end ten = Array.new(100,0) number = number.sort score = number.uniq i=0 j=0 k=0 for i in score do for j in number do if i == j ten[k] = ten[k] + 1 e...
[ "expression.operation.binary.remove" ]
21,544
21,545
u222957942
ruby
p00028
arr = Array.new(100){0} while gets do arr[i-1]+=1 end max = arr.max arr.each_with_index {|v, n| puts(n+1) if v == max}
arr = Array.new(100){0} while gets do arr[$_.to_i-1]+=1 end max = arr.max arr.each_with_index {|v, n| puts(n+1) if v == max}
[ "variable_access.subscript.index.change", "expression.operation.binary.change", "call.add" ]
21,551
21,552
u708217907
ruby
p00028
h={};$<.map{|s|h[n==s.to_i]||=0;h[n]+=1};puts h.select{|x,y|y==h.values.max}.keys.sort
h={};$<.map{|s|h[n=s.to_i]||=0;h[n]+=1};puts h.select{|x,y|y==h.values.max}.keys.sort
[ "expression.operation.compare.replace.remove", "assignment.replace.add", "misc.typo" ]
21,557
21,558
u310778860
ruby
p00028
a=Array.new(10,0) $<.map{|n|a[n.to_i]+=1} a.map.with_index{|n,i|n==a.max&&p(i)}
a=Array.new(101,0) $<.map{|n|a[n.to_i]+=1} a.map.with_index{|n,i|n==a.max&&p(i)}
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change" ]
21,566
21,567
u879497299
ruby
p00028
count = (0..9).map{ 0 } while (line = gets) n = line.chop.to_i count[n] += 1 end max = count.max puts (0..9).select{|k| count[k] == max}
count = (0..100).map{ 0 } while (line = gets) n = line.chop.to_i count[n] += 1 end max = count.max puts (0..100).select{|k| count[k] == max}
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change", "io.output.change" ]
21,569
21,570
u137027976
ruby
p00029
strings = gets.split(" ") hash = Hash.new(0) longest_size = strings.max_by{ |(elm1)| elm1.length} strings.each {|e| hash[e] += 1} freq_num = hash.max_by{|_,len_i| len_i }[1] puts "#{freq_num} #{longest_size}"
strings = gets.split(" ") hash = Hash.new(0) longest_size = strings.max_by{ |(elm1)| elm1.length} strings.each {|e| hash[e] += 1} freq_num = hash.max_by{|_,len_i| len_i }[0] puts "#{freq_num} #{longest_size}"
[ "literal.number.integer.change", "assignment.value.change", "variable_access.subscript.index.change" ]
21,976
21,977
u395283634
ruby
p00029
words = gets.split.group_by{|i| i} puts "#{words.max_by{|k,v| v}.first} #{words.keys.max_by{|i| i.size}}"
words = gets.split.group_by{|i| i} puts "#{words.max_by{|k,v| v.size}.first} #{words.keys.max_by{|i| i.size}}"
[ "literal.string.change", "call.arguments.change" ]
21,986
21,987
u662700808
ruby
p00029
count = Hash.new(0) longest = '' $<.each_line do |line| line.split.each do |word| count[word] += 1 longest = word if longest.size < word.size end end puts count.max_by(&:last).first puts longest
count = Hash.new(0) longest = '' $<.each_line do |line| line.split.each do |word| count[word] += 1 longest = word if longest.size < word.size end end puts count.max_by(&:last).first + ' ' << longest
[ "expression.operation.binary.add" ]
21,990
21,991
u238839772
ruby
p00030
#!/usr/bin/ruby loop do n, s = gets.split.map(&:to_i) break if n == 0 && s == 0 [*0..9].combination(n).count{|x| x.inject(:+) == s } end
#!/usr/bin/ruby loop do n, s = gets.split.map(&:to_i) break if n == 0 && s == 0 puts [*0..9].combination(n).count{|x| x.inject(:+) == s } end
[ "io.output.change", "call.add" ]
22,318
22,319
u549203837
ruby
p00031
weight = gets.chomp.to_i ans = Array.new 9.step(0, -1) do |i| if weight >= 2**i ans.push(2**i) weight = weight - 2**i end end puts ans.sort.join(" ")
while weight = gets weight = weight.chomp.to_i ans = Array.new 9.step(0, -1) do |i| if weight >= 2**i ans.push(2**i) weight = weight - 2**i end end puts ans.sort.join(" ") end
[ "assignment.add" ]
22,414
22,415
u261074410
ruby
p00031
while gets w = $_.to_i a = [] 9.times{|i| unless (c = (1<<i & w)) == 0 then a << c end } puts a.join(" ") end
while gets w = $_.to_i a = [] 10.times{|i| unless (c = (1<<i & w)) == 0 then a << c end } puts a.join(" ") end
[ "literal.number.integer.change" ]
22,416
22,417
u461552210
ruby
p00031
#!/usr/local/bin/ruby a=gets.to_i w=a.to_s(2) rec=Array.new y=w.split("").map(&:to_i).reverse l=y.size (l-1).downto(0){|i| if y[i]==1 rec.unshift(2**i) end } puts rec.join(" ")
#!/usr/local/bin/ruby while line=gets a=line.to_i w=a.to_s(2) rec=Array.new y=w.split("").map(&:to_i).reverse l=y.size (l-1).downto(0){|i| if y[i]==1 rec.unshift(2**i) end } puts rec.join(" ") end
[ "assignment.add" ]
22,420
22,421
u679425694
ruby
p00031
n = gets.to_i a = 1 while a <= n if (a & n) == a print a print" " if a << 1 <= n end a <<= 1 end puts
while gets n = $_.to_i a = 1 while a <= n if (a & n) == a print a print" " if a << 1 <= n end a <<= 1 end puts end
[ "assignment.value.change", "call.add" ]
22,422
22,423
u642047787
ruby
p00032
cho_n = 0 hishi_n = 0 while str = gets do a, b, c = str.chomp.split(" ").map(&:to_i) if a == b hishi_num += 1 end if a * a + b * b == c * c cho_n += 1 end end puts cho_n puts hishi_n
cho_n = 0 hishi_n = 0 while str = gets do a, b, c = str.chomp.split(",").map(&:to_i) if a == b hishi_n += 1 end if a * a + b * b == c * c cho_n += 1 end end puts cho_n puts hishi_n
[ "literal.string.change", "assignment.value.change", "call.arguments.change", "identifier.change" ]
22,855
22,856
u720435069
ruby
p00032
cho_n = 0 hishi_n = 0 while str = gets do a, b, c = str.chomp.split(" ").map(&:to_i) if a == b hishi_n += 1 end if a * a + b * b == c * c cho_n += 1 end end puts cho_n puts hishi_n
cho_n = 0 hishi_n = 0 while str = gets do a, b, c = str.chomp.split(",").map(&:to_i) if a == b hishi_n += 1 end if a * a + b * b == c * c cho_n += 1 end end puts cho_n puts hishi_n
[ "literal.string.change", "assignment.value.change", "call.arguments.change" ]
22,857
22,856
u720435069
ruby
p00032
hishi = 0 tyou = 0 while input = gets do a,b,c = input.chop.split(",").map{|n| n.to_i} if a == b then hishi += 1 elsif a**2 + b**2 == c**2 then tyou += 1 end end puts hishi,tyou
hishi = 0 tyou = 0 while input = gets do a,b,c = input.chop.split(",").map{|n| n.to_i} if a == b then hishi += 1 elsif a**2 + b**2 == c**2 then tyou += 1 end end puts tyou,hishi
[ "call.arguments.add", "call.arguments.change" ]
22,858
22,859
u480817624
ruby
p00032
#!/usr/local/bin/ruby rec,dia=0,0 while line=gets arr=line.split(",").map(&:to_i) a=arr[0].to_i b=arr[1].to_i c=arr[2].to_i if a==b elsif a**2+b**2==c**2 dia+=1 end end puts "#{rec}" puts "#{dia}"
#!/usr/local/bin/ruby rec,dia=0,0 while line=gets arr=line.split(",").map(&:to_i) a=arr[0].to_i b=arr[1].to_i c=arr[2].to_i if a==b dia+=1 elsif a**2+b**2==c**2 rec+=1 end end puts "#{rec}" puts "#{dia}"
[ "identifier.change" ]
22,860
22,861
u679425694
ruby
p00033
n=gets.to_i n.times do ab,ac=[],[] balls=split(/\s/).map(&:to_i) balls.each do |inb| if ab.size==0||ab.last<inb ab << inb else (ac.size>0&&ac.last>inb) ? break : ac << inb end end puts ((ab.size+ac.size)==10) ? 'YES' : 'NO' end
n=gets.to_i n.times do ab,ac=[],[] balls=gets.split(/\s/).map(&:to_i) balls.each do |inb| if ab.size==0||ab.last<inb ab << inb else (ac.size>0&&ac.last>inb) ? break : ac << inb end end puts ((ab.size+ac.size)==10) ? 'YES' : 'NO' end
[ "call.add" ]
23,312
23,313
u708217907
ruby
p00033
n = readline.chomp.to_i n.times{ v = readline.chomp.split.map{|c| c.to_i} stack1 = [0] stack2 = [0] v.each{|c| if stack1[-1] > stack2[-1] if stack1[-1] < c stack1.push(c) elsif stack2[-1] < c stack2.push(c) else puts "NO" break end else if ...
n = readline.chomp.to_i n.times{ v = readline.chomp.split.map{|c| c.to_i} # (1..10).to_a.permutation{|v| # p v stack1 = [0] stack2 = [0] v.each{|c| # if stack1[-1] < c # stack1.push(c) # elsif stack2[-1] < c # stack2.push(c) # else # puts "NO" # break # end if sta...
[ "call.remove" ]
23,314
23,315
u664697594
ruby
p00034
while line=gets line=line.chomp.split(",").map{|s| s.to_i} length=(0..9).map{|i| line[0..i].inject{|sum,j| sum+j}} v1=line[10] v2=line[11] p=length[9]*v1/(v1+v2).to_f p p 10.times{|i| if p<=length[i] then puts i+1 break end } end
while line=gets line=line.chomp.split(",").map{|s| s.to_i} length=(0..9).map{|i| line[0..i].inject{|sum,j| sum+j}} v1=line[10] v2=line[11] p=length[9]*v1/(v1+v2).to_f 10.times{|i| if p<=length[i] then puts i+1 break end } end
[ "call.remove" ]
23,373
23,374
u421423781
ruby
p00034
while (list=gets)!=nil sum=0 list=list.split(",").map{|i|i.to_i} v1,v2=list[10,11] for i in 0..9 sum+=list[i] end r=v1*sum.quo(v1+v2) for i in 0..9 r-=list[i] if r<0 puts i+1 break end end end
while (list=gets)!=nil sum=0 list=list.split(",").map{|i|i.to_i} v1,v2=list[10,2] for i in 0..9 sum+=list[i] end r=v1*sum.quo(v1+v2) for i in 0..9 r-=list[i] if r<=0.0 puts i+1 break end end end
[ "literal.number.integer.change", "assignment.value.change", "variable_access.subscript.index.change" ]
23,377
23,378
u595651980
ruby
p00034
loop { t = gets if t == nil break end t = t.split(",") dist = [] dist[0] = 0 10.times do |i| dist[i+1] = dist[i] + t[i].to_f end v1 = t[10].to_f v2 = t[11].to_f v = v1 + v2 d = v1.to_f * dist[10].to_f / v.to_f 10.times do |i| if dist[i].to_f >= d puts i break end end }
loop { t = gets if t == nil break end t = t.split(",") dist = [] dist[0] = 0.0 10.times do |i| dist[i+1] = dist[i] + t[i].to_f end v1 = t[10].to_f v2 = t[11].to_f v = v1 + v2 d = v1.to_f * dist[10].to_f / v.to_f 11.times do |i| if dist[i].to_f >= d puts i break end end }
[ "assignment.value.change", "literal.number.integer.change", "io.output.change" ]
23,381
23,382
u703161091
ruby
p00034
loop { t = gets if t == nil break end t = t.split(",") dist = [] dist[0] = 0.0 10.times do |i| dist[i+1] = dist[i] + t[i].to_f end v1 = t[10].to_f v2 = t[11].to_f v = v1 + v2 d = v1.to_f * dist[10].to_f / v.to_f 10.times do |i| if dist[i].to_f >= d puts i break end end }
loop { t = gets if t == nil break end t = t.split(",") dist = [] dist[0] = 0.0 10.times do |i| dist[i+1] = dist[i] + t[i].to_f end v1 = t[10].to_f v2 = t[11].to_f v = v1 + v2 d = v1.to_f * dist[10].to_f / v.to_f 11.times do |i| if dist[i].to_f >= d puts i break end end }
[ "literal.number.integer.change", "io.output.change" ]
23,383
23,382
u703161091
ruby
p00038
while gets do a = Array.new(13,0) $_.split(",").map(&:to_i).each do |i| a[i-1]+=1 end if a.member?(4) then puts "for card" elsif a.member?(2) then if a.member?(3) then puts "full house" elsif a.index(2) == a.rindex(2) then puts "one pair" else puts "two pair" end el...
while gets do a = Array.new(13,0) $_.split(",").map(&:to_i).each do |i| a[i-1]+=1 end if a.member?(4) then puts "four card" elsif a.member?(2) then if a.member?(3) then puts "full house" elsif a.index(2) == a.rindex(2) then puts "one pair" else puts "two pair" end e...
[ "literal.string.change", "call.arguments.change" ]
23,547
23,548
u642047787
ruby
p00038
while query = gets hand = query.chomp.split(",").map(&:to_i) cnt_max = hand.max_by{|x| hand.count(x)} same = hand.count(cnt_max) case same when 4 puts "four card" when 3 cnt_min = hand.min_by{|x| hand.count(x)} p cnt_min if hand.count(cnt_min) == 2 puts "full house" else puts "th...
while query = gets hand = query.chomp.split(",").map(&:to_i) cnt_max = hand.max_by{|x| hand.count(x)} same = hand.count(cnt_max) case same when 4 puts "four card" when 3 cnt_min = hand.min_by{|x| hand.count(x)} if hand.count(cnt_min) == 2 puts "full house" else puts "three card" ...
[ "call.remove" ]
23,549
23,550
u261074410
ruby
p00038
def q*a;a.delete a[0];a.empty?end $<.map{|x| a,b,c,d,e=x.chop.split(",").map(&:to_i).sort; puts case when q(a,b,c,d)||q(b,c,d,e);"four card" when a==b&&q(c,d,e)||q(a,b,c)&&d==e;"full house" when (s=[a,b,c,d,e])==(a..e).to_a||s==[10,11,12,13,1];"straight" when q(a,b,c)||q(b,c,d)||q(c,d,e);"three card" when...
def q*a;a.delete a[0];a.empty?end $<.map{|x| a,b,c,d,e=x.chop.split(",").map(&:to_i).sort; puts case when q(a,b,c,d)||q(b,c,d,e);"four card" when a==b&&q(c,d,e)||q(a,b,c)&&d==e;"full house" when (s=[a,b,c,d,e])==(a..e).to_a||s==[1,10,11,12,13];"straight" when q(a,b,c)||q(b,c,d)||q(c,d,e);"three card" when...
[ "literal.array.change" ]
23,556
23,557
u310778860
ruby
p00036
while gets l = $_.chomp t = 8 t = 7 if l != "" t.times do l << gets.chomp end puts "A" if l.include?("1100000011") puts "B" if l.include?("1000000100000010000001000000") puts "C" if l.include?("1111") puts "D" if l.include?("1000000110000001") puts "E" if l.include?("11000000011") puts "F" if ...
while gets l = $_.chomp t = 8 t = 7 if l != "" t.times do l << gets.chomp end puts "A" if l.include?("1100000011") puts "B" if l.include?("1000000010000000100000001") puts "C" if l.include?("1111") puts "D" if l.include?("1000000110000001") puts "E" if l.include?("11000000011") puts "F" if l.i...
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
23,869
23,870
u461552210
ruby
p00037
d=2 map=*$< o=?R x,y=1,0 (u,v=1,1 (d+=1 u=x+[0,0,-1,0][d%4] v=y+[0,1,0,-1][d%4] )until u>=0&&v>=0&&v<9&&map[v][u]==?1 e=d%4 x+=[1,0,-1,0][e] y+=[0,2,0,-2][e] o+="RDLU"[e] d+=2 )while [x,y]!=[0,0] puts o
d=2 map=*$< o=?R x,y=1,0 (u,v=9,9 (d+=1 u=x+[0,0,-1,0][d%4] v=y+[0,1,0,-1][d%4] )until u>=0&&v>=0&&v<9&&map[v][u]==?1 e=d%4 x+=[1,0,-1,0][e] y+=[0,2,0,-2][e] o+="RDLU"[e] d+=2 )while [x,y]!=[0,0] puts o
[ "literal.number.integer.change", "assignment.value.change" ]
24,159
24,160
u890794282
ruby
p00037
d=2 map=*$< o=?R x,y=1,0 (u,v=1,1 (d+=1 u=x+[0,0,-1,0][d%4] v=y+[0,1,0,-1][d%4] )until u>=0&&v>=0&&v<9&&map[v][u]==?1 e=d%4 x+=[1,0,-1,0][e] y+=[0,2,0,-2][e] o+="RDLU"[e] d+=2 )while [x,y]!=[0,0] print o
d=2 map=*$< o=?R x,y=1,0 (u,v=9,9 (d+=1 u=x+[0,0,-1,0][d%4] v=y+[0,1,0,-1][d%4] )until u>=0&&v>=0&&v<9&&map[v][u]==?1 e=d%4 x+=[1,0,-1,0][e] y+=[0,2,0,-2][e] o+="RDLU"[e] d+=2 )while [x,y]!=[0,0] puts o
[ "literal.number.integer.change", "assignment.value.change", "identifier.change" ]
24,161
24,160
u890794282
ruby
p00044
n = 50021 a = Array.new(n){|i| i+1} a[0] = 0 (2..n**(0.50)).each do |i| (2..(n/i)).each{|j| a[i*j-1] = 0} if a[i-1]>0 end a.delete(0) while gets q = $_.to_i i = 1 while a[i] < q do i+=1 end puts "#{a[i-1]}, #{a[i]==q ? a[i+1]:a[i]}" end
n = 50021 a = Array.new(n){|i| i+1} a[0] = 0 (2..n**(0.50)).each do |i| (2..(n/i)).each{|j| a[i*j-1] = 0} if a[i-1]>0 end a.delete(0) while gets q = $_.to_i i = 1 while a[i] < q do i+=1 end puts "#{a[i-1]} #{a[i]==q ? a[i+1]:a[i]}" end
[ "literal.string.change", "call.arguments.change" ]
24,481
24,482
u461552210
ruby
p00045
def main sum = 0 sumnum = 0 count = 0 while arg = gets arg = arg.split(",").map(&:to_i) sum += arg[0] * arg[1] sumnum += arg[0] count += 1 end puts sum, (sumnum.to_f / count).round end main
def main sum = 0 sumnum = 0 count = 0 while arg = gets arg = arg.split(",").map(&:to_i) sum += arg[0] * arg[1] sumnum += arg[1] count += 1 end puts sum, (sumnum.to_f / count).round end main
[ "literal.number.integer.change", "variable_access.subscript.index.change" ]
24,969
24,970
u514597327
ruby
p00046
ary = [] while tmp = gets tmp = tmp.to_i ary << tmp end puts ary.max - ary.min
ary = [] while tmp = gets tmp = tmp.to_f ary << tmp end puts (ary.max - ary.min)
[ "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change", "call.arguments.change" ]
25,323
25,324
u395283634
ruby
p00046
ary = [] while tmp = gets tmp = tmp.to_i ary << tmp end puts (ary.max - ary.min).to_f
ary = [] while tmp = gets tmp = tmp.to_f ary << tmp end puts (ary.max - ary.min)
[ "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change", "call.remove" ]
25,325
25,324
u395283634
ruby
p00042
i = 1 until (furoshiki = $<.gets.to_i).zero? table = {0 => 0} Array.new($<.gets.to_i) {$<.gets.split(",").map(&:to_i)}.each do |v, w| h = Hash.new(0) table.each {|key, value| h[key + w] = table[key] + v if key + w <= furoshiki} table.merge!(h) {|k, v1, v2| [v1, v2].max} end p table m = table.value...
i = 1 until (furoshiki = $<.gets.to_i).zero? table = {0 => 0} Array.new($<.gets.to_i) {$<.gets.split(",").map(&:to_i)}.each do |v, w| h = Hash.new(0) table.each {|key, value| h[key + w] = table[key] + v if key + w <= furoshiki} table.merge!(h) {|k, v1, v2| [v1, v2].max} end m = table.values.max ma...
[ "call.remove" ]
25,867
25,868
u864617427
ruby
p00042
loop do w = gets.to_i @num ||= 1 break if w==0 n = gets.to_i dp = Array.new(n+1){ Array.new(w+1){ {v: 0, w: 0}}} n.times.map{ gets.split(",").map(&:to_i) }.each_with_index do |(vi,wi), i| w.times do |j| t = dp[i][[j+1-wi,0].max] dp[i+1][j+1] = if j+1>=wi && t[:v]+vi >= dp[i][j+1][:v] ...
loop do w = gets.to_i @num ||= 1 break if w==0 n = gets.to_i dp = Array.new(n+1){ Array.new(w+1){ {v: 0, w: 0}}} n.times.map{ gets.split(",").map(&:to_i) }.each_with_index do |(vi,wi), i| w.times do |j| t = dp[i][[j+1-wi,0].max] dp[i+1][j+1] = if j+1>=wi && t[:v]+vi >= dp[i][j+1][:v] ...
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
25,873
25,874
u662700808
ruby
p00042
@case_num = 1 while true do w = gets.to_i break if w == 0 n = gets.to_i table = n.times.map{ gets.split(',').map(&:to_i) } mw, mv = w, 0 dp = Array.new(n+1){Array.new} dp[0][0] = 0 table.each.with_index(1) do |p, i| (0..w).reject{ |wi| dp[i-1][wi].nil? }.each do |wi| va = dp[i][wi] = [dp[i][w...
@case_num = 1 while true do w = gets.to_i break if w == 0 n = gets.to_i table = n.times.map{ gets.split(',').map(&:to_i) } mw, mv = w, 0 dp = Array.new(n+1){Array.new} dp[0][0] = 0 table.each.with_index(1) do |p, i| (0..w).reject{ |wi| dp[i-1][wi].nil? }.each do |wi| va = dp[i][wi] = [dp[i][w...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
25,875
25,876
u708217907
ruby
p00042
@case_num = 1 while true do w = gets.to_i break if w == 0 n = gets.to_i table = n.times.map{ gets.split(',').map(&:to_i) } mw, mv = w, 0 dp = Array.new(n+1){Array.new} dp[0][0] = 0 table.each.with_index(1) do |p, i| (0..w).reject{ |wi| dp[i-1][wi].nil? }.each do |wi| va = dp[i][wi] = [dp[i][w...
@case_num = 1 while true do w = gets.to_i break if w == 0 n = gets.to_i table = n.times.map{ gets.split(',').map(&:to_i) } mw, mv = w, 0 dp = Array.new(n+1){Array.new} dp[0][0] = 0 table.each.with_index(1) do |p, i| (0..w).reject{ |wi| dp[i-1][wi].nil? }.each do |wi| va = dp[i][wi] = [dp[i][w...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
25,877
25,876
u708217907
ruby
p00042
@num = 1 loop do w = gets.to_i break if w == 0 n = gets.to_i arr = n.times.map { gets.split(',').map(&:to_i) } dp = Array.new(n+1) { Array.new(w+1) } dp[0][0] = 0 mw, mv = w, 0 arr.each_with_index do |ia, i| (0..w).to_a.reject{ |wi| dp[i][wi].nil? }.each do |wi| t = dp[i+1][wi] = [dp[i][wi],...
@num = 1 loop do w = gets.to_i break if w == 0 n = gets.to_i arr = n.times.map { gets.split(',').map(&:to_i) } dp = Array.new(n+1) { Array.new(w+1) } dp[0][0] = 0 mw, mv = w, 0 arr.each_with_index do |ia, i| (0..w).to_a.reject{ |wi| dp[i][wi].nil? }.each do |wi| t = dp[i+1][wi] = [dp[i][wi],...
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
25,878
25,879
u708217907
ruby
p00047
hash = {"A" => 1, "B" => 0, "C" => 0} choice = [] while tmp = gets tmp = tmp.split(",").map(&:chomp) p cng1 = hash[tmp[1]] p cng2 = hash[tmp[0]] p hash[tmp[0]] = cng1 p hash[tmp[1]] = cng2 p hash end puts hash.select{|_,v| v == hash.values.max}.keys
hash = {"A" => 1, "B" => 0, "C" => 0} choice = [] while tmp = gets tmp = tmp.split(",").map(&:chomp) cng1 = hash[tmp[1]] cng2 = hash[tmp[0]] hash[tmp[0]] = cng1 hash[tmp[1]] = cng2 hash end puts hash.select{|_,v| v == hash.values.max}.keys
[ "io.output.change", "call.remove" ]
25,967
25,966
u395283634
ruby
p00047
#encoding:utf-8 No.0047 2014.10.6 cups = {"A"=>"ball","B"=>nil,"C"=>nil} change = [] while gets change.push gets.chomp.split(/,/) end change.length.times do |i| cups[change[i][0]],cups[change[i][1]] = cups[change[i][1]],cups[change[i][0]] end cups.each{|key,value| puts key if value == "ball" }
#encoding:utf-8 No.0047 2014.10.6 cups = {"A"=>"ball","B"=>nil,"C"=>nil} change = [] while gets change.push $_.chomp.split(/,/) end change.length.times do |i| cups[change[i][0]],cups[change[i][1]] = cups[change[i][1]],cups[change[i][0]] end cups.each{|key,value| puts key if value == "ball" }
[ "call.arguments.change", "call.add" ]
25,969
25,970
u949338836
ruby
Free AI Image Generator No sign-up. Instant results. Open Now