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
p03000
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.times { |l| now += l break if now > X bound += 1 } p bound
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.each do |l| now += l break if now > X bound += 1 end p bound
[]
813,214
813,215
u634482428
ruby
p03000
N, X= gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.times { |l| now += l break if now > X bound += 1 } p bound
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.each do |l| now += l break if now > X bound += 1 end p bound
[]
813,216
813,215
u634482428
ruby
p03000
N, X= gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.times do |l| now += l break if now > X bound += 1 end
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.each do |l| now += l break if now > X bound += 1 end p bound
[ "identifier.change", "call.add" ]
813,217
813,215
u634482428
ruby
p03000
N,X=gets.split.map(&:to_i) L=gets.split.map(&:to_i) now = 0 bound = 1 L.times do |l| now += l break if now > x bound += 1 end p bound
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.each do |l| now += l break if now > X bound += 1 end p bound
[ "identifier.change", "control_flow.branch.if.condition.change" ]
813,218
813,215
u634482428
ruby
p03000
N,X=gets.split.map(&:to_i) L=gets.split.map(&:to_i) now = 0 bound = 1 L.times do |l| now += l break if now > x bound += 1 end puts bound
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.each do |l| now += l break if now > X bound += 1 end p bound
[ "identifier.change", "control_flow.branch.if.condition.change" ]
813,219
813,215
u634482428
ruby
p03000
n,x=gets.split.map(&:to_i) L=gets.split.map(&:to_i) now = 0 bound = 1 L.times do |l| now += l break if now > x bound += 1 end puts bound
N, X = gets.split.map(&:to_i) L = gets.split.map(&:to_i) now = 0 bound = 1 L.each do |l| now += l break if now > X bound += 1 end p bound
[ "assignment.variable.change", "identifier.change", "control_flow.branch.if.condition.change" ]
813,220
813,215
u634482428
ruby
p03000
N, X = gets.split(' ').map(&:to_i) L = gets.split(' ').map(&:to_i) sum = 0 count = 0 L.each do |e| sum += e count += 1 if sum <= X end
N, X = gets.split(' ').map(&:to_i) L = gets.split(' ').map(&:to_i) sum = 0 count = 0 L.each do |e| sum += e count += 1 if sum <= X end p count + 1
[ "call.add" ]
813,223
813,224
u857555436
ruby
p03000
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i)[0..N] times = 1 L.reduce(0) do |sum, step| sum += step if sum > X puts times break end times = times + 1 sum end puts times
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i)[0..N] times = 1 L.reduce(0) do |sum, step| sum += step if sum > X break end times = times + 1 sum end puts times
[ "call.remove" ]
813,366
813,367
u056626722
ruby
p03000
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i)[0..N] times = 1 L.reduce(0) do |sum, step| sum += step if sum > X puts times break end times = times + 1 sum end
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i)[0..N] times = 1 L.reduce(0) do |sum, step| sum += step if sum > X break end times = times + 1 sum end puts times
[ "call.remove", "call.add" ]
813,368
813,367
u056626722
ruby
p03000
n, x = gets.chop.split.map(&:to_i) l = gets.chop.split.map(&:to_i) d=0 i=0 while(d<=x) d=d+l[i] i+=1 if(i==n) i+=1 if(d<=x) i+=1 break else break end end end puts i
n, x = gets.chop.split.map(&:to_i) l = gets.chop.split.map(&:to_i) d=0 i=0 while(d<=x) d=d+l[i] i+=1 if(i==n) if(d<=x) i+=1 break else break end end end puts i
[]
813,559
813,560
u281982182
ruby
p03000
def s() gets().chomp end def i() gets.to_i end def li() gets.split.map(&:to_i) end def ili() n = gets.to_i as = gets.split.map(&:to_i) [n, as] end def inli() n = gets.to_i as = [] n.times { as << gets.split.map(&:to_i) } [n, as] end class Array def sum total = 0 self.each do |item| total += item end total end end def eratosthenes(size) prime_list = [] is_prime = Array.new(size, true) is_prime[0] = false is_prime[1] = false 2.upto(size-1){|i| if is_prime[i] prime_list << i (2).upto((size.to_f/i).ceil-1){|j| is_prime[j*i] = false } end } [prime_list, is_prime] end def dijkstra(s, e, cost) size = cost.length if s==e return 0 end dp = {} dp[s] = 0 undefined_node = {} size.times{|i| if i != s undefined_node[i] = cost[s][i] end } while undefined_node.length != 0 min = undefined_node.min_by{|_, v| v} stock = {} temp = undefined_node.clone temp.each{|k, v| if min[1] == v undefined_node.delete(k) if k == e return v end dp[k] = v stock[k] = v end } stock.each{|k, v| undefined_node.each{|k2, v2| undefined_node[k2] = v + cost[k][k2] < v2 ? v + cost[k][k2] : v2 } } end end def get_bits(len) res = [] (2**len).times{|i| res << i.to_s(2).rjust(len, '0') } res end def get_GCD(m, n) tmp = [n, m].max n = [n, m].min m = tmp while n != 0 tmp = m % n m = n n = tmp end m end n, x = li() ls = li() sum = 0 count = 1 ls.each { |l| sum += l if sum >= x break end count += 1 } if n+1 <= count puts n+1 else puts count end
def s() gets().chomp end def i() gets.to_i end def li() gets.split.map(&:to_i) end def ili() n = gets.to_i as = gets.split.map(&:to_i) [n, as] end def inli() n = gets.to_i as = [] n.times { as << gets.split.map(&:to_i) } [n, as] end class Array def sum total = 0 self.each do |item| total += item end total end end def eratosthenes(size) prime_list = [] is_prime = Array.new(size, true) is_prime[0] = false is_prime[1] = false 2.upto(size-1){|i| if is_prime[i] prime_list << i (2).upto((size.to_f/i).ceil-1){|j| is_prime[j*i] = false } end } [prime_list, is_prime] end def dijkstra(s, e, cost) size = cost.length if s==e return 0 end dp = {} dp[s] = 0 undefined_node = {} size.times{|i| if i != s undefined_node[i] = cost[s][i] end } while undefined_node.length != 0 min = undefined_node.min_by{|_, v| v} stock = {} temp = undefined_node.clone temp.each{|k, v| if min[1] == v undefined_node.delete(k) if k == e return v end dp[k] = v stock[k] = v end } stock.each{|k, v| undefined_node.each{|k2, v2| undefined_node[k2] = v + cost[k][k2] < v2 ? v + cost[k][k2] : v2 } } end end def get_bits(len) res = [] (2**len).times{|i| res << i.to_s(2).rjust(len, '0') } res end def get_GCD(m, n) tmp = [n, m].max n = [n, m].min m = tmp while n != 0 tmp = m % n m = n n = tmp end m end n, x = li() ls = li() sum = 0 count = 1 ls.each { |l| sum += l if sum > x break end count += 1 } if n+1 <= count puts n+1 else puts count end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
813,673
813,674
u884847580
ruby
p03000
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i) dist = N.times.reduce(0) do |dist, i| new_dist = dist + L[i] if new_dist > X puts i.succ exit end dist + L[i] end puts dist
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i) dist = N.times.reduce(0) do |dist, i| new_dist = dist + L[i] if new_dist > X puts i.succ exit end dist + L[i] end puts N.succ
[ "call.arguments.change", "call.add" ]
813,833
813,832
u765478029
ruby
p03000
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i) puts N.times.reduce(0) do |dist, i| new_dist = dist + L[i] if new_dist > X puts i.succ exit end dist + L[i] end
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i) dist = N.times.reduce(0) do |dist, i| new_dist = dist + L[i] if new_dist > X puts i.succ exit end dist + L[i] end puts N.succ
[ "assignment.variable.change", "call.add" ]
813,834
813,832
u765478029
ruby
p03000
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i) N.times.reduce(0) do |dist, i| new_dist = dist + L[i] if new_dist > X puts i.succ exit end dist + L[i] end
N, X = gets.chomp.split(' ').map(&:to_i) L = gets.chomp.split(' ').map(&:to_i) dist = N.times.reduce(0) do |dist, i| new_dist = dist + L[i] if new_dist > X puts i.succ exit end dist + L[i] end puts N.succ
[ "call.add" ]
813,835
813,832
u765478029
ruby
p03000
n, x = gets.split.map(&:to_i) l = gets.split.map(&:to_i) d = 0 ans = 1 (2..n+1).each do |i| d = d + l[n-2] ans += 1 if d <= x end puts ans
n, x = gets.split.map(&:to_i) l = gets.split.map(&:to_i) d = 0 ans = 1 (2..n+1).each do |i| d = d + l[i-2] ans += 1 if d <= x end puts ans
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
813,836
813,837
u325709450
ruby
p03000
n, x = gets.split.map(&:to_i) l = gets.split.map(&:to_i) d = 0 ans = 1 (2..n).each do |i| d = d + l[n-2] ans += 1 if d <= x end puts ans
n, x = gets.split.map(&:to_i) l = gets.split.map(&:to_i) d = 0 ans = 1 (2..n+1).each do |i| d = d + l[i-2] ans += 1 if d <= x end puts ans
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
813,838
813,837
u325709450
ruby
p03000
#!/usr/bin/env ruby # k = gets.chomp.split(' ').map(&:to_i) # if k[0] == k[2] * 2 && k[1] == k[3] * 2 # puts "#{k[0] * k[1] /2} 1" # else # puts "#{k[0] * k[1] /2} 0" # end k = gets.chomp.split.map(&:to_i) l = gets.chomp.split.map(&:to_i) len = 0 count = 1 l.each do |v| len += v p len break if len > k[1] count += 1 end puts count
#!/usr/bin/env ruby # k = gets.chomp.split(' ').map(&:to_i) # if k[0] == k[2] * 2 && k[1] == k[3] * 2 # puts "#{k[0] * k[1] /2} 1" # else # puts "#{k[0] * k[1] /2} 0" # end k = gets.chomp.split.map(&:to_i) l = gets.chomp.split.map(&:to_i) len = 0 count = 1 l.each do |v| len += v break if len > k[1] count += 1 end puts count
[ "call.remove" ]
813,846
813,847
u987208743
ruby
p03000
#!/usr/bin/env ruby # k = gets.chomp.split(' ').map(&:to_i) # if k[0] == k[2] * 2 && k[1] == k[3] * 2 # puts "#{k[0] * k[1] /2} 1" # else # puts "#{k[0] * k[1] /2} 0" # end k = gets.chomp.split.map(&:to_i) l = k = gets.chomp.split.map(&:to_i) len = 0 count = 1 l.each do |v| len += v break if len > k[1] count += 1 end puts count
#!/usr/bin/env ruby # k = gets.chomp.split(' ').map(&:to_i) # if k[0] == k[2] * 2 && k[1] == k[3] * 2 # puts "#{k[0] * k[1] /2} 1" # else # puts "#{k[0] * k[1] /2} 0" # end k = gets.chomp.split.map(&:to_i) l = gets.chomp.split.map(&:to_i) len = 0 count = 1 l.each do |v| len += v break if len > k[1] count += 1 end puts count
[ "assignment.remove" ]
813,848
813,847
u987208743
ruby
p03000
n, x = gets.split.map(&:to_i) zahyo = [0] point = gets.split.map(&:to_i) n.times do |i| zahyo << zahyo[i] + point[i] end p zahyo.count{ |z| z < x }
n, x = gets.split.map(&:to_i) zahyo = [0] point = gets.split.map(&:to_i) n.times do |i| zahyo << zahyo[i] + point[i] end p zahyo.count{ |z| z <= x }
[ "expression.operator.compare.change", "call.arguments.change", "expression.operation.binary.change" ]
814,115
814,116
u921429241
ruby
p03000
info=gets.chomp.split(" ").map(&:to_i) l=gets.chomp.split(" ").map(&:to_i) sum=0 count=1 info[0].times do|i| sum+=l[i] if(sum>info[1]) count+=i break end end puts count
info=gets.chomp.split(" ").map(&:to_i) l=gets.chomp.split(" ").map(&:to_i) sum=0 count=1 info[0].times do|i| sum+=l[i] if(sum>info[1]) break end count+=1 end puts count
[]
814,262
814,263
u415400221
ruby
p03000
_n, x = gets.split(" ").map(&:to_i) l = gets.split(" ").map(&:to_i) c = 0 p = 0 l.each do |li| p += li c += 1 break if p > x end puts c
_n, x = gets.split(" ").map(&:to_i) l = gets.split(" ").map(&:to_i) + [0] c = 0 p = 0 l.each do |li| p += li c += 1 break if p > x end puts c
[ "assignment.change" ]
814,389
814,390
u731646494
ruby
p03000
n, x = gets.split(" ").map(&:to_i) l = gets.split(" ").map(&:to_i) c = 0 p = 0 l.each do |li| p += li c += 1 break if p > x end puts c
_n, x = gets.split(" ").map(&:to_i) l = gets.split(" ").map(&:to_i) + [0] c = 0 p = 0 l.each do |li| p += li c += 1 break if p > x end puts c
[ "assignment.variable.change", "identifier.change" ]
814,391
814,390
u731646494
ruby
p03001
w, h, x, y = gets.split.map(&:to_i) ans = (w * h / 2).to_s + " " + (x * 2 == w && y * 2 == h ? 1 : 0).to_s puts ans
w, h, x, y = gets.split.map(&:to_i) ans = (w * h / 2.0).to_s + " " + (x * 2 == w && y * 2 == h ? 1 : 0).to_s puts ans
[ "assignment.value.change", "expression.operation.binary.change" ]
814,577
814,578
u979552932
ruby
p03001
w, h, x, y = gets.split.map(&:to_i) puts (w * h / 2).to_s + " " + (x * 2 == w && y * 2 == h ? 1 : 0).to_s
w, h, x, y = gets.split.map(&:to_i) ans = (w * h / 2.0).to_s + " " + (x * 2 == w && y * 2 == h ? 1 : 0).to_s puts ans
[ "assignment.variable.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "call.add" ]
814,579
814,578
u979552932
ruby
p03001
W,H,x,y=$<.read.split.map(&:to_i) s=W*H/2.0 a= (W/2==x&&H/2==y ? 1 : 0) puts "#{s} #{a}"
W,H,x,y=$<.read.split.map(&:to_i) s=W*H/2.0 a=(W/2.0==x&&H/2.0==y ? 1 : 0) puts "#{s} #{a}"
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
814,755
814,756
u852974293
ruby
p03001
W, H, x, y = gets.chomp.split().map(&:to_i) max_s = W * H / 2.0 m = (x == W / 2) && (y == H / 2) ? 1 : 0 print(max_s , ' ', m)
W, H, x, y = gets.chomp.split().map(&:to_i) max_s = W * H / 2.0 m = (x == W / 2.0) && (y == H / 2.0) ? 1 : 0 print(max_s , ' ', m)
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
814,810
814,811
u882179152
ruby
p03001
W,H,x,y = gets.split.map(&:to_i) print ((W*H)/2).to_f if 2*x == W && 2*y == H puts " 1" else puts " 0" end
W,H,x,y = gets.split.map(&:to_f) print ((W*H)/2.0) if 2*x == W && 2*y == H puts " 1" else puts " 0" end
[ "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "call.remove" ]
815,684
815,685
u760636024
ruby
p03001
w, h, x, y = gets.strip.split.map(&:to_i) j = 0 j = 1 if x * 2 == w && y * 2 == h puts "#{w * h / 2} #{j}"
w, h, x, y = gets.strip.split.map(&:to_f) j = 0 j = 1 if x * 2 == w && y * 2 == h puts "#{w * h / 2} #{j}"
[ "assignment.value.change", "call.arguments.change" ]
815,793
815,794
u913209852
ruby
p03001
W, H, x, y = gets.split(' ').map(&:to_i) print "#{(W * H) / 2} " print W.even? && H.even? && x == (W / 2) && y == (H / 2) ? '1' : '0'
W, H, x, y = gets.split(' ').map(&:to_i) print "#{(W * H.to_f) / 2} " print W.even? && H.even? && x == (W / 2) && y == (H / 2) ? '1' : '0'
[ "literal.string.change", "call.arguments.change" ]
815,962
815,963
u543466827
ruby
p03001
W,H,x,y = gets.chomp.split(" ").map(&:to_i) ans = (x == W/2 and y == H/2) ? 1 : 0 printf("%f %d", W*H/2, ans)
W,H,x,y = gets.chomp.split(" ").map(&:to_f) ans = (x == W/2 and y == H/2) ? 1 : 0 printf("%f %d", W*H/2, ans)
[ "assignment.value.change", "call.arguments.change" ]
816,450
816,451
u111773061
ruby
p03001
( W, H, x, y ) = gets.split(' ').map(&:to_i) ret1 = W * H / 2.0 ret2 = W/2 == x && H/2 == y ? 1 : 0 puts "#{ret1} #{ret2}"
( W, H, x, y ) = gets.split(' ').map(&:to_i) ret1 = W * H / 2.00000000000 ret2 = W/2.0 == x && H/2.0 == y ? 1 : 0 puts "#{ret1} #{ret2}"
[ "literal.number.float.change", "assignment.value.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
816,537
816,538
u039504682
ruby
p03001
( W, H, x, y ) = gets.split(' ').map(&:to_i) ret1 = W * H / 2 ret2 = W/2 == x && H/2 == y ? 1 : 0 puts "#{ret1} #{ret2}"
( W, H, x, y ) = gets.split(' ').map(&:to_i) ret1 = W * H / 2.00000000000 ret2 = W/2.0 == x && H/2.0 == y ? 1 : 0 puts "#{ret1} #{ret2}"
[ "assignment.value.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
816,539
816,538
u039504682
ruby
p03001
io = STDIN w,h,x,y=io.gets.split.map(&:to_i) puts "#{(w*h)/2.0} #{w/2==x&&h/2==y ? 1 : 0}"
io = STDIN w,h,x,y=io.gets.split.map(&:to_i) puts "#{(w*h)/2.0} #{w/2.0==x && h/2.0==y ? 1 : 0}"
[ "literal.string.change", "call.arguments.change" ]
816,540
816,541
u132360211
ruby
p03001
a,b,c,d=gets.split.map(&:to_i) r = 0 r = 1 if a/2 == c && b/2 == d puts "#{(a*b)/2.0} #{r}"
a,b,c,d=gets.split.map(&:to_i) r = 0 r = 1 if a/2.0 == c && b/2.0 == d puts "#{(a*b)/2.0} #{r}"
[ "control_flow.branch.if.condition.change" ]
817,188
817,189
u098870186
ruby
p03001
a,b,c,d=gets.split.map(&:to_i) r = 0 r *= 1 if a/2 == c && b/2 == d puts "#{(a*b)/2.0} #{r}"
a,b,c,d=gets.split.map(&:to_i) r = 0 r = 1 if a/2.0 == c && b/2.0 == d puts "#{(a*b)/2.0} #{r}"
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
817,190
817,189
u098870186
ruby
p03001
W,H,x,y = gets.split.map(&:to_i) area = (W * H / 2).to_f synmmetric = 0 if x*2 == W && y*2 == H synmmetric = 1 end puts "#{area} #{synmmetric}"
W,H,x,y = gets.split.map(&:to_i) area = W * H / 2.0 synmmetric = 0 if x*2 == W && y*2 == H synmmetric = 1 end puts "#{area} #{synmmetric}"
[ "assignment.value.change", "expression.operation.binary.change", "call.remove" ]
817,229
817,230
u581928831
ruby
p03001
w, h, x, y = gets.strip.split.map(&:to_i) s = w * h / 2 is_center = x * 2 == w && y * 2 == h puts "#{s} #{is_center ? 1 : 0}"
w, h, x, y = gets.strip.split.map(&:to_i) s = w * h / 2.0 is_center = x * 2 == w && y * 2 == h puts "#{s} #{is_center ? 1 : 0}"
[ "assignment.value.change", "expression.operation.binary.change" ]
817,390
817,391
u367259152
ruby
p03001
w, h, x, y = gets.strip.split(" ").map(&:to_i) half = h / 2.0 f = if y >= half (w / 2.0) * h else (h / 2.0) * w end s = if x == (w / 2) && y == (h / 2) 1 else 0 end puts "#{f} #{s}"
w, h, x, y = gets.strip.split(" ").map(&:to_i) half = h / 2.0 f = if y >= half (w / 2.0) * h else (h / 2.0) * w end s = if x == (w / 2.0) && y == (h / 2.0) 1 else 0 end puts "#{f} #{s}"
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
817,472
817,473
u742213796
ruby
p03001
#!/usr/bin/env ruby k = gets.chomp.split(' ').map(&:to_i) if k[0] == k[3] * 2 && k[1] == k[2] * 2 puts "#{k[0] * k[1] /2} 1" else puts "#{k[0] * k[1] /2} 0" end
#!/usr/bin/env ruby k = gets.chomp.split(' ').map(&:to_i) if k[0] == k[2] * 2 && k[1] == k[3] * 2 puts "#{k[0] * k[1] /2.0} 1" else puts "#{k[0] * k[1] /2.0} 0" end # k = gets.chomp.split.map(&:to_i) # l = gets.chomp.split.map(&:to_i) # len = 0 # count = 1 # l.each do |v| # len += v # break if len > k[1] # count += 1 # end # puts count
[ "literal.number.integer.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change" ]
817,491
817,492
u987208743
ruby
p03001
w, h, x, y = gets.split.map(&:to_i) area = (w * h).fdiv(2) division = (x * 2 == w && y ** 2 == h) ? 1 : 0 ans = [area, division].join(' ') puts ans
w, h, x, y = gets.split.map(&:to_i) area = (w * h).fdiv(2) division = (x * 2 == w && y * 2 == h) ? 1 : 0 ans = [area, division].join(' ') puts ans
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
817,552
817,553
u721689253
ruby
p03001
w, h, x, y = gets.split.map(&:to_i) area = (w * h) / 2 division = (x * 2 == w && y ** 2 == h) ? 1 : 0 ans = [area, division].join(' ') puts ans
w, h, x, y = gets.split.map(&:to_i) area = (w * h).fdiv(2) division = (x * 2 == w && y * 2 == h) ? 1 : 0 ans = [area, division].join(' ') puts ans
[ "assignment.value.change", "expression.operation.binary.change", "call.add", "call.arguments.change", "control_flow.branch.if.condition.change" ]
817,554
817,553
u721689253
ruby
p03001
w, h, x, y = gets.chop.split.map(&:to_i) s_ans=w*h/2 if ((x==w/2)&&(y==h/2)) sw=1 else sw=0 end #S1=((x-y/a)+(x+h/a-y/a))*h/2 #S2=((w-x+y/a)+(w-x-h/a+y/a))*h/2 #T1=((-a*x+y)+(a*(w-x)+y))*w/2 #T2=((h+a*x-y)+(h-a*(w-x)-y))*w/2 puts s_ans.to_s+" "+sw.to_s
w, h, x, y = gets.chop.split.map(&:to_i) s_ans=w*h/2.0 if ((x==w/2.0)&&(y==h/2.0)) sw=1 else sw=0 end puts s_ans.to_s+" "+sw.to_s
[ "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
817,613
817,614
u281982182
ruby
p03001
W, H, x, y = gets.chomp.split(" ").map(&:to_i) puts "#{W * H / 2.0} #{(x == W/2 && y == H/2) ? 1 : 0}"
W, H, x, y = gets.chomp.split(" ").map(&:to_i) puts "#{W * H / 2.0} #{(x == W/2.0 && y == H/2.0) ? 1 : 0}"
[ "literal.string.change", "call.arguments.change" ]
818,066
818,067
u655122274
ruby
p03005
n,k=gets.to_i puts (k == 1 ? 0 : n-k)
n,k=gets.split.map(&:to_i) puts (k == 1 ? 0 : n-k)
[ "assignment.value.change", "identifier.change", "call.add" ]
818,899
818,900
u056944756
ruby
p03005
n,k=gets.split.map(&:to_i) puts n==1 ? 0 : n-k
n,k=gets.split.map(&:to_i) puts (k == 1 ? 0 : n-k)
[ "control_flow.branch.if.condition.change", "call.arguments.change" ]
818,901
818,900
u056944756
ruby
p03005
n,k=gets.split.map(&:to_i) puts n==0 ? 0 : n-k
n,k=gets.split.map(&:to_i) puts (k == 1 ? 0 : n-k)
[ "control_flow.branch.if.condition.change", "literal.number.integer.change", "call.arguments.change" ]
818,902
818,900
u056944756
ruby
p03005
n,k=gets.split.map(&:to_i) p k==1?0:h-k
n,k=gets.split.map(&:to_i) p k==1?0:n-k
[ "call.arguments.change" ]
818,995
818,996
u408023666
ruby
p03005
a, b = gets.map(&:to_i) if b == 1 puts 0 else puts (1 + (a - b)) - 1 end
a, b = gets.split.map(&:to_i) if b == 1 puts 0 else puts (1 + (a - b)) - 1 end
[ "call.add" ]
819,489
819,490
u702652578
ruby
p03005
a,b=gets.split.map &:to_i p b==1 ? 1 : a-b
a,b=gets.split.map &:to_i p b==1 ? 0 : a-b
[ "literal.number.integer.change", "call.arguments.change" ]
820,121
820,122
u657913472
ruby
p03006
N = gets.to_i xy = [] N.times { |i| xy << gets.split.map(&:to_i) } xyc = Hash.new(0) N.times do |i| xi, yi = xy[i] i.upto(N-1).times do |j| next if i == j xj, yj = xy[j] xyc[ [xi-xj, yi-yj] ] += 1 xyc[ [xj-xi, yj-yi] ] += 1 end end if N == 1 puts 1 else puts N - xyc.sort_by { |k, v| -v }.first[1] end
N = gets.to_i xy = [] N.times { |i| xy << gets.split.map(&:to_i) } xyc = Hash.new(0) N.times do |i| xi, yi = xy[i] i.upto(N-1) do |j| next if i == j xj, yj = xy[j] xyc[ [xi-xj, yi-yj] ] += 1 xyc[ [xj-xi, yj-yi] ] += 1 end end if N == 1 puts 1 else puts N - xyc.sort_by { |k, v| -v }.first[1] end
[ "call.remove" ]
820,328
820,329
u320576758
ruby
p03006
N = gets.to_i x, y = N.times.map{gets.split.map(&:to_i)}.transpose hash = Hash.new N.times do |i| N.each do |j| next if i == j # puts "compare #{i} and #{j}" new_x = x[i] - x[j] new_y = y[i] - y[j] hash["#{new_x},#{new_y}"] ||= 0 hash["#{new_x},#{new_y}"] += 1 end end puts N - hash.values.max
N = gets.to_i x, y = N.times.map{gets.split.map(&:to_i)}.transpose hash = Hash.new N.times do |i| N.times do |j| next if i == j new_x = x[i] - x[j] new_y = y[i] - y[j] hash["#{new_x},#{new_y}"] ||= 0 hash["#{new_x},#{new_y}"] += 1 end end puts N - (hash.values.max || 0)
[ "identifier.change", "io.output.change", "call.arguments.change" ]
820,362
820,361
u521197112
ruby
p03001
#!/usr/bin/env ruby w, h, x, y = gets.split(' ').map &:to_i if w == 2*x and h == 2*y puts "#{w*h/2} 1" else puts "#{w*h/2} 0" end
#!/usr/bin/env ruby w, h, x, y = gets.split(' ').map &:to_i if w == 2*x and h == 2*y puts "#{w*h/2.0} 1" else puts "#{w*h/2.0} 0" end
[ "literal.string.change", "call.arguments.change" ]
820,763
820,764
u041550672
ruby
p03006
N = gets.to_i if N == 1 p 1; exit end PTS = (0...N).map{ gets.split.map &:to_i }.sort diffs = {} (0...N).each{ |i| (i+1...N).each{ |j| dx = (PTS[i][0] - PTS[j][0]).abs dy = (PTS[i][1] - PTS[j][1]).abs next if dx == 0 && dy == 0 diffs[[dx,dy]] = 1 } } ans = N pmap = Hash[PTS.map{ |x,y| [[x,y],1] }] diffs.keys.each{ |a,b| done = {} r = 0 (0...N).each{ |i| x,y = PTS[i] if !pmap[[x-a,y-b]] r += 1 end } ans = [ans, r].min } p ans
N = gets.to_i if N == 1 p 1; exit end PTS = (0...N).map{ gets.split.map &:to_i }.sort diffs = {} (0...N).each{ |i| (i+1...N).each{ |j| dx = (PTS[i][0] - PTS[j][0]) dy = (PTS[i][1] - PTS[j][1]) next if dx == 0 && dy == 0 diffs[[dx,dy]] = 1 } } ans = N pmap = Hash[PTS.map{ |x,y| [[x,y],1] }] diffs.keys.each{ |a,b| done = {} r = 0 (0...N).each{ |i| x,y = PTS[i] if !pmap[[x-a,y-b]] r += 1 end } ans = [ans, r].min } p ans
[ "call.remove" ]
821,134
821,135
u670503797
ruby
p03007
n = gets.to_i ary = gets.split.map(&:to_i) positive = ary.select(&:positive?).sort negative = ary.select(&:negative?).sort if positive.empty? positive[0] = negative[-1] negative.delete_at(-1) end if negative.empty? negative[0] = positive[0] positive.delete_at(0) end result = [] positive[0..-2].each do |i| result.push("#{negative[0]} #{i}") negative[0] -= i end negative.each do |i| result.push("#{positive[-1]} #{i}") positive[-1] -= i end puts positive[-1] puts result
n = gets.to_i ary = gets.split.map(&:to_i) positive = ary.select(&:positive?).sort negative = ary.reject(&:positive?).sort if positive.empty? positive[0] = negative[-1] negative.delete_at(-1) end if negative.empty? negative[0] = positive[0] positive.delete_at(0) end result = [] positive[0..-2].each do |i| result.push("#{negative[0]} #{i}") negative[0] -= i end negative.each do |i| result.push("#{positive[-1]} #{i}") positive[-1] -= i end puts positive[-1] puts result
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
821,343
821,344
u622469330
ruby
p03007
n = gets.to_i a = gets.chomp.split.map(&:to_i).sort sign = Array.new(n,nil) if a[0] >= 0 then puts a.inject(:+) - a[0] * 2 cnt = a[0] (n - 2).times do |i| puts cnt.to_s + " " + a[i + 1].to_s cnt = cnt - a[i + 1] end puts a[n - 1].to_s + " " + cnt.to_s elsif a[n - 1] <= 0 then puts a.inject(:+) * -1 + a[n = 1] * 2 cnt = a[n - 1] (n - 1).times do |i| puts cnt.to_s + " " + a[i].to_s cnt = cnt - a[i] end else puts a.map(&:abs).inject(:+) cnt = a[0] pos = n - 2 while a[pos] >= 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end puts a[n - 1].to_s + " " + cnt.to_s if n > 2 cnt = a[n - 1] - cnt while pos > 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end end
n = gets.to_i a = gets.chomp.split.map(&:to_i).sort sign = Array.new(n,nil) if a[0] >= 0 then puts a.inject(:+) - a[0] * 2 cnt = a[0] (n - 2).times do |i| puts cnt.to_s + " " + a[i + 1].to_s cnt = cnt - a[i + 1] end puts a[n - 1].to_s + " " + cnt.to_s elsif a[n - 1] <= 0 then puts a.inject(:+) * -1 + a[n - 1] * 2 cnt = a[n - 1] (n - 1).times do |i| puts cnt.to_s + " " + a[i].to_s cnt = cnt - a[i] end else puts a.map(&:abs).inject(:+) cnt = a[0] pos = n - 2 while a[pos] >= 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end puts a[n - 1].to_s + " " + cnt.to_s cnt = a[n - 1] - cnt while pos > 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end end
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
821,371
821,372
u960706641
ruby
p03007
n = gets.to_i a = gets.chomp.split.map(&:to_i).sort sign = Array.new(n,nil) if a[0] >= 0 then puts a.inject(:+) - a[0] * 2 cnt = a[0] (n - 2).times do |i| puts cnt.to_s + " " + a[i + 1].to_s cnt = cnt - a[i + 1] end puts a[n - 1].to_s + " " + cnt.to_s elsif a[n - 1] <= 0 then puts a.inject(:+) * -1 + a[n = 1] * 2 cnt = a[n - 1] (n - 1).times do |i| puts cnt.to_s + " " + a[i].to_s cnt = cnt - a[i] end else puts a.map(&:abs).inject(:+) cnt = a[0] pos = n - 2 while a[pos] >= 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end puts a[n - 1].to_s + " " + cnt.to_s cnt = a[n - 1] - cnt while pos > 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end end
n = gets.to_i a = gets.chomp.split.map(&:to_i).sort sign = Array.new(n,nil) if a[0] >= 0 then puts a.inject(:+) - a[0] * 2 cnt = a[0] (n - 2).times do |i| puts cnt.to_s + " " + a[i + 1].to_s cnt = cnt - a[i + 1] end puts a[n - 1].to_s + " " + cnt.to_s elsif a[n - 1] <= 0 then puts a.inject(:+) * -1 + a[n - 1] * 2 cnt = a[n - 1] (n - 1).times do |i| puts cnt.to_s + " " + a[i].to_s cnt = cnt - a[i] end else puts a.map(&:abs).inject(:+) cnt = a[0] pos = n - 2 while a[pos] >= 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end puts a[n - 1].to_s + " " + cnt.to_s cnt = a[n - 1] - cnt while pos > 0 puts cnt.to_s + " " + a[pos].to_s cnt = cnt - a[pos] pos -= 1 end end
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change" ]
821,373
821,372
u960706641
ruby
p03011
p, q, r = gets.split.map &:to_i p [p+q, q+r, r+p].min
p, q, r = gets.split.map &:to_i puts [p+q, q+r, r+p].min
[ "call.function.change", "io.output.change" ]
822,719
822,720
u347948131
ruby
p03011
arr = gets.chomp.split(' ').map(&:to_i).sort puts arr[0] + aar[1]
arr = gets.chomp.split(' ').map(&:to_i).sort puts arr[0] + arr[1]
[ "misc.typo", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
822,857
822,858
u175011963
ruby
p03011
ls = gets.split(" ").map(&:to_i).sort!s p ls[0]+ls[1]
ls = gets.split(" ").map(&:to_i).sort! p ls[0]+ls[1]
[ "call.arguments.change" ]
822,994
822,995
u911815052
ruby
p03011
p, q, r = gets.split.map(&:to_i) sum = [] sum << p + q sum << q * r sum << r + p puts sum.min
p, q, r = gets.split.map(&:to_i) sum = [] sum << p + q sum << q + r sum << r + p puts sum.min
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
823,135
823,136
u326562452
ruby
p03011
P, Q, R = gets.split.map!(&:to_i) min = P + Q if min > Q + R min = Q + R else if min > R + P min = R + P end end puts min
P, Q, R = gets.split.map!(&:to_i) min = P + Q if min > Q + R min = Q + R end if min > R + P min = R + P end puts min
[]
823,405
823,406
u911320318
ruby
p03011
P, Q, R = gets.split.map!(&:to_i) min = P + Q if min > Q + R min = Q + R elsif min > R + P min = R + P end puts min
P, Q, R = gets.split.map!(&:to_i) min = P + Q if min > Q + R min = Q + R end if min > R + P min = R + P end puts min
[]
823,407
823,406
u911320318
ruby
p03011
s=gets.split("").map &:to_i s.sort! puts s[0]+s[1]
s=gets.split.map &:to_i s.sort! puts s[0]+s[1]
[ "call.arguments.change" ]
823,592
823,593
u977506075
ruby
p03011
s=gets.split("").map &:to_i s.sort! puts s[0]*s[1]
s=gets.split.map &:to_i s.sort! puts s[0]+s[1]
[ "call.arguments.change", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
823,594
823,593
u977506075
ruby
p03011
ab, bc, ca = gets.split(' ') min = ab.to_i + bc.to_i; min = bc.to_i + ca.to_i if min > bc.to_i + ca.to_i min = ca.to_i + ab.to_i if min > bc.to_i + ca.to_i p min
ab, bc, ca = gets.split(' ') min = ab.to_i + bc.to_i; min = bc.to_i + ca.to_i if min > bc.to_i + ca.to_i min = ca.to_i + ab.to_i if min > ca.to_i + ab.to_i p min
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
823,737
823,738
u686577486
ruby
p03012
N = gets.to_i W = gets.split.map(&:to_i) min = Float::INFINITY N.times do |i| break if i == N - 2 if (W[0..i].inject(:+) - W[i+1..(-1)].inject(:+)).abs <= min min = (W[0..i].inject(:+) - W[i+1..(-1)].inject(:+)).abs end end puts min
N = gets.to_i W = gets.split.map(&:to_i) min = Float::INFINITY N.times do |i| break if i == N - 1 if (W[0..i].inject(:+) - W[i+1..(-1)].inject(:+)).abs <= min min = (W[0..i].inject(:+) - W[i+1..(-1)].inject(:+)).abs end end puts min
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
824,115
824,116
u846185950
ruby
p03012
n = gets.chomp.to_i w = gets.chomp.split.map(&:to_i).sort sum = w.inject(:+) min = 100000 part_sum = 0 (0..(n-2)).each do |num| part_sum += w[num] tmp = (part_sum - (sum - part_sum)).abs min = tmp if tmp < min end puts min
n = gets.chomp.to_i w = gets.chomp.split.map(&:to_i) sum = w.inject(:+) min = sum part_sum = 0 (0..(n-1)).each do |num| part_sum += w[num] tmp = (part_sum - (sum - part_sum)).abs min = tmp if tmp < min end puts min
[ "call.remove", "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "literal.number.integer.change", "expression.operation.binary.change" ]
824,132
824,133
u876846619
ruby
p03012
N=gets.to_i as=gets.split.map(&:to_i) res=Float::INFINITY (N-1).times do |i| cnt=(as[0..i].inject(&:+)-as[i+1..N-1].inject(&:+)).abs res=cnt<res ? cnt : res end
N=gets.to_i as=gets.split.map(&:to_i) res=Float::INFINITY (N-1).times do |i| cnt=(as[0..i].inject(&:+)-as[i+1..N-1].inject(&:+)).abs res=cnt<res ? cnt : res end puts res
[ "call.add" ]
824,147
824,148
u926099741
ruby
p03012
n = gets.to_i ary = gets.split.map(&:to_i) sum = ary.inject(:+) count = 0 ary.each do |i| count += i sum = [(count * 2 - sum).abs, abs].min end puts sum
n = gets.to_i ary = gets.split.map(&:to_i) sum = ary.inject(:+) count = 0 abs = sum ary.each do |i| count += i abs = [(count * 2 - sum).abs, abs].min end puts abs
[ "assignment.variable.change", "identifier.change", "call.arguments.change" ]
824,237
824,238
u514143079
ruby
p03012
def balance n = gets.chomp.to_i w = gets.chomp.split(/\s/).map{|x| x.to_i} p n p w min = 100*100 left = w[0] right = w[1..-1] #r = right.sum # for RUby 2.4 r = right.inject(0){|sum,x| sum + x } for i in 1..n-1 do min = [min, (left-r).abs].min #p min item = right.shift left += item r -= item end p min end balance
# Balance def balance n = gets.chomp.to_i w = gets.chomp.split(/\s/).map{|x| x.to_i} # p n # p w min = 100*100 left = w[0] right = w[1..-1] #r = right.sum # for RUby 2.4 r = right.inject(0){|sum,x| sum + x } for i in 1..n-1 do min = [min, (left-r).abs].min # p min item = right.shift left += item r -= item end p min end balance
[ "call.remove" ]
824,543
824,544
u510887956
ruby
p03012
N=gets.to_i wrray=gets.split.map(&:to_i) sum = wrray.inject(:+) m=1000000007 s=0 i=0 while i < N j=0 while j < i+1 s += wrray[j] j += 1 end l= sum-s*2 if l < 0 l=-l end if m > l m=l end i+=1 end puts m
N=gets.to_i wrray=gets.split.map(&:to_i) sum = wrray.inject(:+) m=1000000007 i=0 while i < N s=0 j=0 while j < i+1 s += wrray[j] j += 1 end l= sum-s*2 if l < 0 l=-l end if m > l m=l end i+=1 end puts m
[ "assignment.remove", "assignment.add" ]
824,658
824,659
u987183622
ruby
p03012
N = gets.to_i W = gets.split.to_a.map!(&:to_i) ansers = [] N.times do |t| ansers << (W[0..t].inject(:+) - W[(t + 1)..N].inject(:+)).abs end puts ansers.min
N = gets.to_i W = gets.split.to_a.map!(&:to_i) ansers = [] N.times do |t| ansers << (W[0..t].inject(0, :+) - W[(t + 1)..N].inject(0, :+)).abs end puts ansers.min
[ "call.arguments.add" ]
824,714
824,715
u295334477
ruby
p03013
n, m = gets.chomp.split.map(&:to_i) hash = {} m.times do |i| hash[gets.chomp.to_i] = true end mod = 10 **9 + 7 ngo = Array.new(n+1,0) ngo[0] = 1 (n-1).times do |i| ngo[i] %= mod next if hash.has_key?(i) ngo[i+1] += ngo[i] if hash.has_key?(i+1) == false ngo[i+2] += ngo[i] if hash.has_key?(i+2) == false end ngo[n] += ngo[n-1] if hash.has_key?(n-2) == false puts ngo[n] % (10 ** 9 + 7)
n, m = gets.chomp.split.map(&:to_i) hash = {} m.times do |i| hash[gets.chomp.to_i] = true end mod = 10 **9 + 7 ngo = Array.new(n+1,0) ngo[0] = 1 (n-1).times do |i| ngo[i] %= mod next if hash.has_key?(i) ngo[i+1] += ngo[i] if hash.has_key?(i+1) == false ngo[i+2] += ngo[i] if hash.has_key?(i+2) == false end ngo[n] += ngo[n-1] if hash.has_key?(n-1) == false puts ngo[n] % (10 ** 9 + 7)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
825,079
825,080
u409390792
ruby
p03013
n,m = gets.chomp.split.map(&:to_i) as = m.times.map{gets.to_i} MOD = 10**9+7 dp = Array.new(n+1,-1) as.each do |a| dp[a] = 0 end p dp (n+1).times do |i| next if dp[i] == 0 if i == 0 || i == 1 dp[i] = 1 else dp[i] = (dp[i-1] + dp[i-2]) % MOD end end puts dp[n+1]
n,m = gets.chomp.split.map(&:to_i) as = m.times.map{gets.to_i} MOD = 10**9+7 dp = Array.new(n+1,-1) as.each do |a| dp[a] = 0 end (n+1).times do |i| next if dp[i] == 0 if i == 0 || i == 1 dp[i] = 1 else dp[i] = (dp[i-1] + dp[i-2]) % MOD end end puts dp[n]
[ "call.remove", "expression.operation.binary.remove" ]
825,326
825,327
u191196346
ruby
p03013
n, m = gets.split.map(&:to_i) as = Array.new(n, true) m.times do i = gets.to_i as[i] = false end ans = Array.new(n + 1, 0) mod = 10 ** 9 + 7 ans[0] = 1 ans[1] = 1 if as[1] 2.upto(n) do |i| ans[i] += ans[i - 1] if as[i - 1] ans[i] += ans[i - 2] if as[i - 2] ans[i] %= mod end puts ans[n]
n, m = gets.split.map(&:to_i) as = Array.new(n, true) m.times do i = gets.to_i as[i] = false end ans = Array.new(n + 1, 0) mod = 10 ** 9 + 7 ans[0] = 1 ans[1] = 1 if as[0] 2.upto(n) do |i| ans[i] += ans[i - 1] if as[i - 1] ans[i] += ans[i - 2] if as[i - 2] ans[i] %= mod end puts ans[n]
[ "literal.number.integer.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
825,429
825,430
u889326464
ruby
p03013
n, m = gets.chomp.split.map(&:to_i) a = Array.new(n) m.times do ary[gets.chomp.to_i] = 0 end a[0] = 1 a[1] ||= 1 (2..n).each do |i| a[i] ||= (a[i-2] + a[i-1]) % (10**9 + 7) end puts a[n]
n, m = gets.chomp.split.map(&:to_i) a = Array.new(n) m.times do a[gets.chomp.to_i] = 0 end a[0] = 1 a[1] ||= 1 (2..n).each do |i| a[i] ||= (a[i-2] + a[i-1]) % (10**9 + 7) end puts a[n]
[ "assignment.variable.change", "identifier.change" ]
826,065
826,066
u585819925
ruby
p03013
n, m = gets.chomp.split.map(&:to_i) a = Array.new(n) m.times do ary[gets.chomp.to_i] = 0 end a[0] = 1 a[1] ||= 1 (2..n).each do |i| a[i] ||= (a[i-2] + a[i-1]) % (10**9 + 7) end puts ary[n]
n, m = gets.chomp.split.map(&:to_i) a = Array.new(n) m.times do a[gets.chomp.to_i] = 0 end a[0] = 1 a[1] ||= 1 (2..n).each do |i| a[i] ||= (a[i-2] + a[i-1]) % (10**9 + 7) end puts a[n]
[ "assignment.variable.change", "identifier.change", "call.arguments.change" ]
826,067
826,066
u585819925
ruby
p03013
n,m=gets.chomp.split.map(&:to_i) a=Array.new(n) m.times do a[gets.chomp.to_i] = 0 end a[0],a[1] = 1,1 (2..n).each do |i| a[i] ||= (a[i-2] + a[i-1])% (10**9 + 7) end puts a[n]
n, m = gets.chomp.split.map(&:to_i) a = Array.new(n) m.times do a[gets.chomp.to_i] = 0 end a[0] = 1 a[1] ||= 1 (2..n).each do |i| a[i] ||= (a[i-2] + a[i-1]) % (10**9 + 7) end puts a[n]
[]
826,068
826,066
u585819925
ruby
p03013
N,M=gets.split.map(&:to_i) as=Array.new(N+1,false) M.times do as[gets.to_i]=true end dp=Array.new(N+1,0) dp[0]=1 dp[1]=as[1] ? 0 : 1 for i in 2..N dp[i]+=dp[i-2] if !as[i-2] dp[i]+=dp[i-1] if !as[i-1] dp[i]%=100000007 end puts dp[N]
N,M=gets.split.map(&:to_i) as=Array.new(N+1,false) M.times do as[gets.to_i]=true end dp=Array.new(N+1,0) dp[0]=1 dp[1]=as[1] ? 0 : 1 for i in 2..N dp[i]+=dp[i-2] if !as[i-2] dp[i]+=dp[i-1] if !as[i-1] dp[i]%=1000000007 end puts dp[N]
[ "literal.number.integer.change" ]
826,383
826,382
u926099741
ruby
p03013
N, M = gets.split.map(&:to_i) a = (1..M).map { gets.to_i - 1 } NOT_YET = -1 MOD = 1000000007 if N == 1 then puts 1 exit! end ways = Array.new(N, NOT_YET) a.each { |hole| ways[hole] = 0 } if ways[0] == NOT_YET then ways[0] = 1 end if ways[1] == NOT_YET then ways[1] = 1 + ways[0] end (2...N).each { |x| ways[x] = (ways[x - 1] + ways[x - 2]) % MOD if ways[x] == NOT_YET } puts ways.last
N, M = gets.split.map(&:to_i) a = (1..M).map { gets.to_i - 1} # 0-indexed NOT_YET = -1 MOD = 1000000007 if N == 1 then puts 1 exit end ways = Array.new(N, NOT_YET) a.each { |hole| ways[hole] = 0 } if ways[0] == NOT_YET then ways[0] = 1 end if ways[1] == NOT_YET then ways[1] = 1 + ways[0] end (2...N).each { |x| ways[x] = (ways[x - 1] + ways[x - 2]) % MOD if ways[x] == NOT_YET } puts ways.last
[ "call.suffix.change" ]
826,562
826,561
u963316883
ruby
p03013
n, m = gets.split.map(&:to_i) a = m.times.map{ gets.to_i } foo = Array.new(n + 10, 0) mod = 10 ** 9 + 7 foo[0] = 1 a.each{ |h| foo[h] = -1 } (1..n).each do |i| foo[i] = foo[i] < 0 ? 0 : (foo[i-1] + foo[i-2]) % mod end p foo puts foo[n]
n, m = gets.split.map(&:to_i) a = m.times.map{ gets.to_i } foo = Array.new(n + 10, 0) mod = 10 ** 9 + 7 foo[0] = 1 a.each{ |h| foo[h] = -1 } (1..n).each do |i| foo[i] = foo[i] < 0 ? 0 : (foo[i-1] + foo[i-2]) % mod end puts foo[n]
[ "call.remove" ]
826,612
826,613
u561391668
ruby
p03013
num = gets.chomp.split().map(&:to_i) MOD = 10**9 + 7 bs = Array.new(num[0]+1, 0) num[1].times do |n| a = gets.chomp.to_i bs[a] = -1 end num1, num2, s = 0, 1, 0 (num[0]).times do |n| s = bs[n+1] < 0 ? 0 : num1 + num2 num1 = num2 num2 = s % MOD end puts s
num = gets.chomp.split().map(&:to_i) MOD = 10**9 + 7 bs = Array.new(num[0]+1, 0) num[1].times do |n| a = gets.chomp.to_i bs[a] = -1 end num1, num2, s = 0, 1, 0 (num[0]).times do |n| s = bs[n+1] < 0 ? 0 : (num1 + num2) % MOD num1 = num2 num2 = s end puts s
[ "expression.operation.binary.remove" ]
826,617
826,618
u541032448
ruby
p03013
n, m = gets.split.map(&:to_i) out = [] steps = Array.new(n + 2, 1) m.times do steps[gets.to_i + 1] = 0 end steps[0] = 1 steps[1] = 1 for i in 2 .. n + 1 if steps[i] != 0 steps[i] = (steps[i - 1] + steps[i - 2]) % 1000000007 end end puts steps[-1]
n, m = gets.split.map(&:to_i) out = [] steps = Array.new(n + 2, 1) m.times do steps[gets.to_i + 1] = 0 end steps[0] = 0 steps[1] = 1 for i in 2 .. n + 1 if steps[i] != 0 steps[i] = (steps[i - 1] + steps[i - 2]) % 1000000007 end end puts steps[-1]
[ "literal.number.integer.change", "assignment.value.change" ]
827,240
827,241
u785521224
ruby
p03013
n, m = gets.split.map(&:to_i) broken = Array.new(n, false) m.times { a = gets.to_i broken[a - 1] = true } step = [] if !broken[0] then step[0] = 1 else step[0] = 0 end if n == 1 then puts step[0] exit end if !broken[1] then step[1] = step[0] + 1 else step[1] = step[0] end 2.upto(n - 1).each {|i| if !broken[i] then step[i] = step[i - 1] + step[i - 2] step[i] %= 1000000007 else step[i] = 0 end } puts step.last
n, m = gets.split.map(&:to_i) broken = Array.new(n, false) m.times { a = gets.to_i broken[a - 1] = true } step = [] if !broken[0] then step[0] = 1 else step[0] = 0 end if n == 1 then puts step[0] exit end if !broken[1] then step[1] = step[0] + 1 else step[1] = 0 end 2.upto(n - 1).each {|i| if !broken[i] then step[i] = step[i - 1] + step[i - 2] step[i] %= 1000000007 else step[i] = 0 end } puts step.last
[]
827,408
827,409
u420267469
ruby
p03013
n, m = gets.split.map(&:to_i) broken = Array.new(n, false) m.times { a = gets.to_i broken[a - 1] = true } step = [] if !broken[0] then step[0] = 1 else step[0] = 0 end if n == 1 then puts step[0] return end if !broken[1] then step[1] = step[0] + 1 else step[1] = step[0] end 2.upto(n - 1).each {|i| if !broken[i] then step[i] = step[i - 1] + step[i - 2] step[i] %= 1000000007 else step[i] = 0 end } puts step.last
n, m = gets.split.map(&:to_i) broken = Array.new(n, false) m.times { a = gets.to_i broken[a - 1] = true } step = [] if !broken[0] then step[0] = 1 else step[0] = 0 end if n == 1 then puts step[0] exit end if !broken[1] then step[1] = step[0] + 1 else step[1] = 0 end 2.upto(n - 1).each {|i| if !broken[i] then step[i] = step[i - 1] + step[i - 2] step[i] %= 1000000007 else step[i] = 0 end } puts step.last
[ "control_flow.return.remove", "control_flow.exit.add" ]
827,410
827,409
u420267469
ruby
p03013
MOD = 1000000007 n, m = gets.chomp.split.map(&:to_i) a = Array.new(n,1) m.times do i = gets.chomp.to_i a[i] = 0 end cnt = [1,a[1]] (2..(n+1)).each do |i| if a[i] == 0 cnt[i] = 0 else cnt[i] = (cnt[i-2] + cnt[i-1]) % MOD end end puts(cnt[n])
MOD = 1000000007 n, m = gets.chomp.split.map(&:to_i) a = Array.new(n+1,1) m.times do i = gets.chomp.to_i a[i] = 0 end cnt = [1,a[1]] (2..(n+1)).each do |i| if a[i] == 0 cnt[i] = 0 else cnt[i] = (cnt[i-2] + cnt[i-1]) % MOD end end puts(cnt[n])
[ "assignment.change" ]
827,750
827,751
u913444337
ruby
p03017
require 'pp' # 空白区切の入力値を数値の配列で返却する def gets_i_list() gets.chomp.split(" ").map(&:to_i) end N, A, B, C, D = gets_i_list S = gets.chomp if C < D a_line = S.slice(A - 1, C - A + 1) b_line = S.slice(B - 1, D - B + 1) if b_line.include?("##") puts "No" exit elsif a_line.include?("##") puts "No" exit else puts "Yes" end else ob_line = S.slice(B - 2, D - B + 2) a_line = S.slice(A - 1, C - A + 1) b_line = S.slice(B - 1, D - B + 1) if !ob_line.include?("...") puts "No" exit elsif a_line.include?("##") puts "No" exit elsif b_line.include?("##") puts "No" exit else puts "Yes" end end
require 'pp' # 空白区切の入力値を数値の配列で返却する def gets_i_list() gets.chomp.split(" ").map(&:to_i) end N, A, B, C, D = gets_i_list S = gets.chomp if C < D a_line = S.slice(A - 1, C - A + 1) b_line = S.slice(B - 1, D - B + 1) if b_line.include?("##") puts "No" exit elsif a_line.include?("##") puts "No" exit else puts "Yes" end else ob_line = S.slice(B - 2, D - B + 3) a_line = S.slice(A - 1, C - A + 1) b_line = S.slice(B - 1, D - B + 1) if !ob_line.include?("...") puts "No" exit elsif a_line.include?("##") puts "No" exit elsif b_line.include?("##") puts "No" exit else puts "Yes" end end
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
829,886
829,887
u370977023
ruby
p03017
#=$<.read.split.map(&:to_i) N,A,B,C,D=gets.split.map(&:to_i) S='-' + gets.chomp def check(s) s !~ /##/ end ret = if C<D check(S[A..B]) && check(S[C..D]) else check(S[A..C]) && S[B-1..D] =~ /\.\.\./ end puts (ret ? 'Yes' : 'No')
#=$<.read.split.map(&:to_i) N,A,B,C,D=gets.split.map(&:to_i) S='-' + gets.chomp def check(s) s !~ /##/ end ret = if C<D check(S[A..B]) && check(S[C..D]) else check(S[A..C]) && S[B-1..D+1] =~ /\.\.\./ end puts (ret ? 'Yes' : 'No')
[ "assignment.change" ]
830,205
830,206
u852974293
ruby
p03017
#=$<.read.split.map(&:to_i) N,A,B,C,D=gets.split.map(&:to_i) S='-' + gets.chomp def check(s) s !~ /##/ end ret = if C<D check(S[A..B]) && check(S[C..D]) else check(S[A..C]) && S[B-1..C] =~ /\.\.\./ end puts (ret ? 'Yes' : 'No')
#=$<.read.split.map(&:to_i) N,A,B,C,D=gets.split.map(&:to_i) S='-' + gets.chomp def check(s) s !~ /##/ end ret = if C<D check(S[A..B]) && check(S[C..D]) else check(S[A..C]) && S[B-1..D+1] =~ /\.\.\./ end puts (ret ? 'Yes' : 'No')
[ "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
830,207
830,206
u852974293
ruby
p03017
n,a,b,c,d = gets.chomp.split(' ').map(&:to_i) s = gets.chomp # 連続岩 = false 追い抜く必要性 = c > d # 追い抜ける = false 連続岩 = s[(a-1)..(([c,d].max)-1)].include?('##') if 追い抜く必要性 追い抜ける = s[(b-2)..(d-1)].include?('...') end # s.split('').each_with_index do |char, i| # x = i + 1 # if x > a && (x < c || x < d) # if char == '#' && s[i-1] == '#' # 連続岩 = true # break # end # end # # if 追い抜く必要性 && x > b && x <= d # if char == '.' && s[i-1] == '.' && s[i-2] == '.' # 追い抜ける = true # end # end # end if 連続岩 puts 'No' exit end if 追い抜く必要性 unless 追い抜ける puts 'No' exit end end puts 'Yes'
n,a,b,c,d = gets.chomp.split(' ').map(&:to_i) s = gets.chomp # 連続岩 = false 追い抜く必要性 = c > d # 追い抜ける = false 連続岩 = s[(a-1)..(([c,d].max)-1)].include?('##') if 追い抜く必要性 追い抜ける = s[(b-2)..d].include?('...') end # s.split('').each_with_index do |char, i| # x = i + 1 # if x > a && (x < c || x < d) # if char == '#' && s[i-1] == '#' # 連続岩 = true # break # end # end # # if 追い抜く必要性 && x > b && x <= d # if char == '.' && s[i-1] == '.' && s[i-2] == '.' # 追い抜ける = true # end # end # end if 連続岩 puts 'No' exit end if 追い抜く必要性 unless 追い抜ける puts 'No' exit end end puts 'Yes'
[]
830,520
830,521
u299761130
ruby
p03017
n,a,b,c,d = gets.chomp.split(' ').map(&:to_i) s = gets.chomp # 連続岩 = false 追い抜く必要性 = c > d # 追い抜ける = false 連続岩 = s[(a-1)..(([c,d].max)-1)].include?('##') if 追い抜く必要性 追い抜ける = s[(b-1)..(d-1)].include?('...') end # s.split('').each_with_index do |char, i| # x = i + 1 # if x > a && (x < c || x < d) # if char == '#' && s[i-1] == '#' # 連続岩 = true # break # end # end # # if 追い抜く必要性 && x > b && x <= d # if char == '.' && s[i-1] == '.' && s[i-2] == '.' # 追い抜ける = true # end # end # end if 連続岩 puts 'No' exit end if 追い抜く必要性 unless 追い抜ける puts 'No' exit end end puts 'Yes'
n,a,b,c,d = gets.chomp.split(' ').map(&:to_i) s = gets.chomp # 連続岩 = false 追い抜く必要性 = c > d # 追い抜ける = false 連続岩 = s[(a-1)..(([c,d].max)-1)].include?('##') if 追い抜く必要性 追い抜ける = s[(b-2)..d].include?('...') end # s.split('').each_with_index do |char, i| # x = i + 1 # if x > a && (x < c || x < d) # if char == '#' && s[i-1] == '#' # 連続岩 = true # break # end # end # # if 追い抜く必要性 && x > b && x <= d # if char == '.' && s[i-1] == '.' && s[i-2] == '.' # 追い抜ける = true # end # end # end if 連続岩 puts 'No' exit end if 追い抜く必要性 unless 追い抜ける puts 'No' exit end end puts 'Yes'
[ "literal.number.integer.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
830,522
830,521
u299761130
ruby
p03017
n,a,b,c,d = gets.chomp.split(' ').map(&:to_i) s = gets.chomp # 連続岩 = false 追い抜く必要性 = c > d # 追い抜ける = false 連続岩 = s[(a-1)..(([c,d].max)-1)].include?('##') if 追い抜く必要性 追い抜ける = s[(a-1)..(d-1)].include?('...') end # s.split('').each_with_index do |char, i| # x = i + 1 # if x > a && (x < c || x < d) # if char == '#' && s[i-1] == '#' # 連続岩 = true # break # end # end # # if 追い抜く必要性 && x > b && x <= d # if char == '.' && s[i-1] == '.' && s[i-2] == '.' # 追い抜ける = true # end # end # end if 連続岩 puts 'No' exit end if 追い抜く必要性 unless 追い抜ける puts 'No' exit end end puts 'Yes'
n,a,b,c,d = gets.chomp.split(' ').map(&:to_i) s = gets.chomp # 連続岩 = false 追い抜く必要性 = c > d # 追い抜ける = false 連続岩 = s[(a-1)..(([c,d].max)-1)].include?('##') if 追い抜く必要性 追い抜ける = s[(b-2)..d].include?('...') end # s.split('').each_with_index do |char, i| # x = i + 1 # if x > a && (x < c || x < d) # if char == '#' && s[i-1] == '#' # 連続岩 = true # break # end # end # # if 追い抜く必要性 && x > b && x <= d # if char == '.' && s[i-1] == '.' && s[i-2] == '.' # 追い抜ける = true # end # end # end if 連続岩 puts 'No' exit end if 追い抜く必要性 unless 追い抜ける puts 'No' exit end end puts 'Yes'
[ "assignment.value.change", "identifier.change", "variable_access.subscript.index.change", "expression.operation.binary.change", "literal.number.integer.change" ]
830,523
830,521
u299761130
ruby
p03017
n, a, b, c, d = gets.split.map(&:to_i) a -= 1 b -= 1 c -= 1 d -= 1 s = gets.chomp if s[a..c].include?'##' or s[b..d].include? '##' puts :No elsif c < d puts :Yes else if s[b-1..d].include? '...' puts :Yes else puts :No end end
n, a, b, c, d = gets.split.map(&:to_i) a -= 1 b -= 1 c -= 1 d -= 1 s = gets.chomp if s[a..c].include?'##' or s[b..d].include? '##' puts :No elsif c < d puts :Yes else if s[b-1..d+1].include? '...' puts :Yes else puts :No end end
[ "control_flow.branch.if.condition.change" ]
831,074
831,076
u161323909
ruby
p03017
n, a, b, c, d = gets.split.map(&:to_i) a -= 1 b -= 1 c -= 1 d -= 1 s = gets.chomp if s[a..c].include?'##' or s[b..d].include? '##' puts :No elsif c < d puts :Yes else if s[a..c].include? '...' puts :Yes else puts :No end end
n, a, b, c, d = gets.split.map(&:to_i) a -= 1 b -= 1 c -= 1 d -= 1 s = gets.chomp if s[a..c].include?'##' or s[b..d].include? '##' puts :No elsif c < d puts :Yes else if s[b-1..d+1].include? '...' puts :Yes else puts :No end end
[ "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
831,078
831,076
u161323909
ruby
p03017
n, a, b, c, d = gets.split.map(&:to_i) a -= 1 b -= 1 c -= 1 d -= 1 s = gets.chomp if s[a..c].include?'##' or s[b..d].include? '##' puts :No elsif c < d puts :Yes else if s[b..d].include? '...' puts :Yes else puts :No end end
n, a, b, c, d = gets.split.map(&:to_i) a -= 1 b -= 1 c -= 1 d -= 1 s = gets.chomp if s[a..c].include?'##' or s[b..d].include? '##' puts :No elsif c < d puts :Yes else if s[b-1..d+1].include? '...' puts :Yes else puts :No end end
[ "control_flow.branch.if.condition.change" ]
831,080
831,076
u161323909
ruby
p03017
n, a_start, b_start, a_goal, b_goal = gets.split(" ").map(&:to_i) strings = gets.chomp.to_s ans = "Yes" # a_start・a_goal間に "##" があれば "No" if strings[a_start - 1..a_goal - 1].include?("##") ans = "No" # b_start・b_goal間に "##" があれば "No" elsif strings[b_start - 1..b_goal - 1].include?("##") ans = "No" # a_goal > b_goalかつ、b_start・b_goal間に "..." がなければ "No" # (a_goal > b_goalの場合、b_start・b_goal間でaがbを抜かす必要があるため) elsif a_goal > b_goal && strings[b_start - 1..b_goal - 1].include?("...") == false ans = "No" end puts ans
n, a_start, b_start, a_goal, b_goal = gets.split(" ").map(&:to_i) strings = gets.chomp.to_s ans = "Yes" # a_start・a_goal間に "##" があれば "No" if strings[a_start - 1..a_goal - 1].include?("##") ans = "No" # b_start・b_goal間に "##" があれば "No" elsif strings[b_start - 1..b_goal - 1].include?("##") ans = "No" # a_goal > b_goalの時、b_startの1歩手前・b_goalの1歩先の間に "..." がなければ "No" # (a_goal > b_goalの場合、b_start・b_goal間でaがbを抜かす必要があるため) elsif a_goal > b_goal && strings[b_start - 2..b_goal].include?("...") == false ans = "No" end puts ans
[ "literal.number.integer.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
831,312
831,314
u653737129
ruby
p03017
N, A, B, C, D = gets.chomp.split(" ").map(&:to_i) s = gets.chomp if s[A-1..C-1].include?("##") || s[B-1..D-1].include?("##") then puts "No" else if D > C then puts "Yes" elsif s[B-2..D+1].include?("...") then puts "Yes" else puts "No" end end
N, A, B, C, D = gets.chomp.split(" ").map(&:to_i) s = gets.chomp if s[A-1..C-1].include?("##") || s[B-1..D-1].include?("##") then puts "No" else if D > C then puts "Yes" elsif s[B-2..D].include?("...") then puts "Yes" else puts "No" end end
[ "expression.operation.binary.remove" ]
831,555
831,556
u339791405
ruby
p03017
N, A, B, C, D = gets.chomp.split(" ").map(&:to_i) s = gets.chomp if s[A-1..C-1].include?("##") || s[B-1..D-1].include?("##") then puts "No" else if D > C then puts "Yes" else if s[B-2..D+1].include?("...") then puts "Yes" else puts "No" end end end
N, A, B, C, D = gets.chomp.split(" ").map(&:to_i) s = gets.chomp if s[A-1..C-1].include?("##") || s[B-1..D-1].include?("##") then puts "No" else if D > C then puts "Yes" elsif s[B-2..D].include?("...") then puts "Yes" else puts "No" end end
[ "expression.operation.binary.remove" ]
831,557
831,556
u339791405
ruby
p03017
_,a,b,c,d=gets.split.map{|m| m.to_i-1 } s=gets.chomp if s[a..[c,d].max].index(/\#{2,}/) puts "No" else if c > d if s[b..d+1].index(/\.{3,}/) puts "Yes" else puts "No" end else puts "Yes" end end
_,a,b,c,d=gets.split.map{|m| m.to_i-1 } s=gets.chomp if s[a..[c,d].max].index(/\#{2,}/) puts "No" else if c > d if s[b-1..d+1].index(/\.{3,}/) puts "Yes" else puts "No" end else puts "Yes" end end
[ "control_flow.branch.if.condition.change" ]
831,852
831,853
u098870186
ruby
p03017
_,a,b,c,d=gets.split.map{|m| m.to_i-1 } s=gets.chomp if s[0..[c,d].max].index(/\#{2,}/) puts "No" else if c > d if s[0..d+1].index(/\.{3,}/) puts "Yes" else puts "No" end else puts "Yes" end end
_,a,b,c,d=gets.split.map{|m| m.to_i-1 } s=gets.chomp if s[a..[c,d].max].index(/\#{2,}/) puts "No" else if c > d if s[b-1..d+1].index(/\.{3,}/) puts "Yes" else puts "No" end else puts "Yes" end end
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
831,854
831,853
u098870186
ruby