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
p00047
def ball(c1, c2, b) case b when c1 return c2 when c2 return c1 else return b end end b = "A" while line = gets cup1, cup2 = line.chomp.split(",") p b = ball(cup1, cup2, b) end puts b
def ball(c1, c2, b) case b when c1 return c2 when c2 return c1 else return b end end b = "A" while line = gets cup1, cup2 = line.chomp.split(",") b = ball(cup1, cup2, b) end puts b
[ "io.output.change", "call.remove" ]
25,971
25,972
u814658648
ruby
p00049
#!/usr/bin/ruby # -*- coding: utf-8 -*- a = 0; b = 0; o = 0; ab =...
#!/usr/bin/ruby # -*- coding: utf-8 -*- a = 0; b = 0; o = 0; ab =...
[ "call.remove", "call.add" ]
26,059
26,060
u233891002
ruby
p00049
r = {"A" => 0, "B" => 0, "AB" => 0, "O" => 0} while a = gets.chomp r[a.split(",")[1]] += 1 end r.each_value{ |i| puts i }
r = {"A" => 0, "B" => 0, "AB" => 0, "O" => 0} begin while a = gets.chomp r[a.split(",")[1]] += 1 end rescue end r.each_value{ |i| puts i }
[]
26,061
26,062
u708862509
ruby
p00049
r = {"A" => 0, "B" => 0, "AB" => 0, "O" => 0} while a = gets.chomp r[a.split(",")[1]] += 1 end r.each_value{ |i| puts i }
r = {"A" => 0, "B" => 0, "AB" => 0, "O" => 0} while a = gets r[a.chomp.split(",")[1]] += 1 end r.each_value{ |i| puts i }
[ "call.remove", "call.add" ]
26,061
26,063
u708862509
ruby
p00048
classes = %w(light_fly fly bantam feather light light_welter welter light_middle mddle light_heavy heavy) upper_bound = [48,51,54,57,60,64,69,75,81,91, Float::INFINITY] puts $<.map {|s| classes[upper_bound.index{|ub| s.to_f <= ub}].sub(?_, ' ') }
classes = %w(light_fly fly bantam feather light light_welter welter light_middle middle light_heavy heavy) upper_bound = [48,51,54,57,60,64,69,75,81,91, Float::INFINITY] puts $<.map {|s| classes[upper_bound.index{|ub| s.to_f <= ub}].sub(?_, ' ') }
[ "literal.string.change", "assignment.value.change" ]
26,115
26,116
u797180951
ruby
p00048
def result(w) r = "" if w <= 48.0 then r = "light fly" elsif w <= 51.0 then r = "fly" elsif w <= 54.0 then r = "bandam" elsif w <= 57.0 then r = "feather" elsif w <= 60.0 then r = "light" elsif w <= 64.0 then r = "light welter" elsif w <= 69.0 then r = "welter" elsif w <= 75.0 then r = "light middle" ...
def result(w) r = "" if w <= 48.0 then r = "light fly" elsif w <= 51.0 then r = "fly" elsif w <= 54.0 then r = "bantam" elsif w <= 57.0 then r = "feather" elsif w <= 60.0 then r = "light" elsif w <= 64.0 then r = "light welter" elsif w <= 69.0 then r = "welter" elsif w <= 75.0 then r = "light middle" ...
[ "literal.string.change", "assignment.value.change", "call.add" ]
26,117
26,118
u480817624
ruby
p00048
def result(w) r = "" if w <= 48.0 then r = "light fly" elsif w <= 51.0 then r = "fly" elsif w <= 54.0 then r = "bandam" elsif w <= 57.0 then r = "feather" elsif w <= 60.0 then r = "light" elsif w <= 64.0 then r = "light welter" elsif w <= 69.0 then r = "welter" elsif w <= 75.0 then r = "light middle" ...
def result(w) r = "" if w <= 48.0 then r = "light fly" elsif w <= 51.0 then r = "fly" elsif w <= 54.0 then r = "bantam" elsif w <= 57.0 then r = "feather" elsif w <= 60.0 then r = "light" elsif w <= 64.0 then r = "light welter" elsif w <= 69.0 then r = "welter" elsif w <= 75.0 then r = "light middle" ...
[ "literal.string.change", "assignment.value.change" ]
26,119
26,118
u480817624
ruby
p00048
C = { 48 => 'light fly', 51 => 'fly', 54 => 'bandam', 57 => 'feather', 60 => 'light', 64 => 'light welter', 69 => 'welter', 75 => 'light middle', 81 => 'middle', 91 => 'light heavy', 9999 => 'heavy' } while s = gets w = s.to_f n = nil C.sort.each { |k, v| if w <= k n = v ...
C = { 48 => 'light fly', 51 => 'fly', 54 => 'bantam', 57 => 'feather', 60 => 'light', 64 => 'light welter', 69 => 'welter', 75 => 'light middle', 81 => 'middle', 91 => 'light heavy', 9999 => 'heavy' } while s = gets w = s.to_f n = nil C.sort.each { |k, v| if w <= k n = v ...
[ "literal.string.change", "assignment.value.change" ]
26,120
26,121
u854447110
ruby
p00050
ap, pa, a, p = 'apple', 'pech', 'a' * 10000, 'p' * 10000 puts gets.sub(ap, a).sub(pa, p).sub(a, pa).sub(p, ap)
ap, pa, a, p = 'apple', 'peach', 'a' * 10000, 'p' * 10000 puts gets.gsub(ap, a).gsub(pa, p).gsub(a, pa).gsub(p, ap)
[ "literal.string.change", "assignment.value.change", "identifier.change", "call.arguments.change", "io.output.change" ]
26,712
26,713
u621997536
ruby
p00050
text = gets.chomp offset = 0 loop do a = text.index("apple", offset) b = text.index("peach", offset) if a && b if a < b offset = a + 1 text[a,5] = "peach" else offset = b + 1 text[a,5] = "apple" end elsif a text[a,5] = "peach" offset = a + 1 elsif b text[b,5] ...
text = gets.chomp offset = 0 loop do a = text.index("apple", offset) b = text.index("peach", offset) if a && b if a < b offset = a + 1 text[a,5] = "peach" else offset = b + 1 text[b,5] = "apple" end elsif a text[a,5] = "peach" offset = a + 1 elsif b text[b,5] ...
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
26,719
26,720
u960312159
ruby
p00051
for i in 1..gets.to_i s=gets.split(//).map(&:to_i) min=s.sort! max=s.reverse puts max.join.to_i-min.join.to_i end
for i in 1..gets.to_i s=gets.chomp.split(//).map(&:to_i) min=s.sort! max=s.reverse puts max.join.to_i-min.join.to_i end
[ "call.add" ]
26,836
26,837
u287407095
ruby
p00055
while gets sum = $_.to_f 9.times do |i| i % 2 == 0 ? a *= 2 : a /= 3 sum += a end puts sum end
while gets a, sum = $_.to_f sum = a 9.times do |i| i % 2 == 0 ? a *= 2 : a /= 3 sum += a end puts sum end
[ "assignment.add" ]
27,065
27,066
u814658648
ruby
p00055
while gets sum = $_.to_f 9.times do |i| i % 2 == 0 ? a *= 2 : a /= 3 sum += a end puts sum end
while gets sum = a = $_.to_f 9.times do |i| i % 2 == 0 ? a *= 2 : a /= 3 sum += a end puts sum end
[ "assignment.add" ]
27,065
27,067
u814658648
ruby
p00060
cards = Array.new(11,1) a,b,c = gets.split.map &:to_i cards[a] = 0 cards[b] = 0 cards[c] = 0 r = 20 - a - b count = 0 r = 10 if r > 10 r.times { |i| count += cards[i + 1] } puts ["NO", "YES"][count/4]
while t = gets cards = Array.new(11,1) a,b,c = t.split.map &:to_i cards[a] = 0 cards[b] = 0 cards[c] = 0 r = 20 - a - b count = 0 r = 10 if r > 10 r.times { |i| count += cards[i + 1] } puts ["NO", "YES"][count/4] end
[ "assignment.value.change", "identifier.change" ]
27,408
27,409
u708862509
ruby
p00058
#!ruby -n l=$_.split.map(&:to_f) puts ((l[3]-l[1])*(l[7]-l[5])+(l[2]-l[0])*(l[6]-l[4])<1e-8)? 'YES': 'NO'
#!ruby -n l=$_.split.map(&:to_f) puts ((l[3]-l[1])*(l[7]-l[5])+(l[2]-l[0])*(l[6]-l[4])).abs<1e-12? 'YES': 'NO'
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
27,613
27,614
u316203371
ruby
p00058
#!ruby -n l=$_.split.map(&:to_f) puts ((l[3]-l[1])*(l[7]-l[5])+(l[2]-l[0])*(l[6]-l[4])<1e-10)? 'YES': 'NO'
#!ruby -n l=$_.split.map(&:to_f) puts ((l[3]-l[1])*(l[7]-l[5])+(l[2]-l[0])*(l[6]-l[4])).abs<1e-12? 'YES': 'NO'
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
27,615
27,614
u316203371
ruby
p00058
while str = STDIN.gets if str == -1 then break end a = str.split(' '); eps = 1e-11; for i in 0...8 do a[i] = a[i].to_i end if ((a[0]-a[2])*(a[4]-a[6])+(a[1]-a[3])*(a[5]-a[7])).abs <= eps then puts "YES\n" else puts "NO\n" end end
while str = STDIN.gets if str == -1 then break end a = str.split(' '); eps = 1e-12; for i in 0...8 do a[i] = a[i].to_f end if ((a[0]-a[2])*(a[4]-a[6])+(a[1]-a[3])*(a[5]-a[7])).abs <= eps then puts "YES\n" else puts "NO\n" end end
[ "literal.number.float.change", "assignment.value.change", "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change" ]
27,619
27,620
u904101743
ruby
p00058
while str = STDIN.gets if str == -1 then break end a = str.split(' '); eps = 1e-12; for i in 0...8 do a[i] = a[i].to_i end if ((a[0]-a[2])*(a[4]-a[6])+(a[1]-a[3])*(a[5]-a[7])).abs <= eps then puts "YES\n" else puts "NO\n" end end
while str = STDIN.gets if str == -1 then break end a = str.split(' '); eps = 1e-12; for i in 0...8 do a[i] = a[i].to_f end if ((a[0]-a[2])*(a[4]-a[6])+(a[1]-a[3])*(a[5]-a[7])).abs <= eps then puts "YES\n" else puts "NO\n" end end
[ "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change" ]
27,621
27,620
u904101743
ruby
p00053
max=110000 array=[*2..max] 2.upto(Math.sqrt(max)) do |num1| array.reject! do |num2| (num2%num1==0)&&(num2>num1) end end p array.size while gets break if $_.to_i==0 x=0 for i in 0...$_.to_i x+=array[i] end puts x end
max=110000 array=[*2..max] 2.upto(Math.sqrt(max)) do |num1| array.reject! do |num2| (num2%num1==0)&&(num2>num1) end end while gets break if $_.to_i==0 x=0 for i in 0...$_.to_i x+=array[i] end puts x end
[ "call.remove" ]
27,917
27,916
u287407095
ruby
p00053
max = 105000 sn = max.to_f**0.5.ceil is_prime = [false, false] + [true]*(max-1) (2..sn).each do |i| next unless is_prime[i] (i*i).step(max, i) do |j| is_prime[j] = false end end prime_list = (2..max).to_a.select{ |i| is_prime[i] } puts prime_list.size while n = gets.to_i do break if n == 0 puts prime_lis...
max = 105000 sn = max.to_f**0.5.ceil is_prime = [false, false] + [true]*(max-1) (2..sn).each do |i| next unless is_prime[i] (i*i).step(max, i) do |j| is_prime[j] = false end end prime_list = (2..max).to_a.select{ |i| is_prime[i] } while n = gets.to_i do break if n == 0 puts prime_list[0..(n-1)].inject(:+...
[ "call.remove" ]
27,921
27,922
u708217907
ruby
p00063
s = 0 while a = gets.chop f = 1 a.size.times{|i| f = 0 if a[i] != a[~i] } s += f end p s
s = 0 while a = gets a.chop! f = 1 a.size.times{|i| f = 0 if a[i] != a[~i] } s += f end p s
[ "call.add", "identifier.change" ]
28,041
28,042
u708862509
ruby
p00056
primes = Array.new(1_000_000, true) primes[0, 2] = [false, false] 2.upto(999_999){|x| if primes[x] m = 2 while x * m <= 999_999 primes[x * m] = false m += 1 end end } while true n = gets.to_i break if n == 0 sum = 0 3.upto(n/2){|x| sum += 1 if pri...
primes = Array.new(50000, true) primes[0, 2] = [false, false] 2.upto(50000 - 1){|x| if primes[x] m = 2 while x * m <= 999_999 primes[x * m] = false m += 1 end end } while true n = gets.to_i break if n == 0 sum = 0 2.upto(n/2){|x| sum += 1 if prime...
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change" ]
28,455
28,456
u247371045
ruby
p00056
primes = Array.new(50000, true) primes[0, 2] = [false, false] 2.upto(50000 - 1){|x| if primes[x] m = 2 while x * m <= 999_999 primes[x * m] = false m += 1 end end } while true n = gets.to_i break if n == 0 sum = 0 3.upto(n/2){|x| sum += 1 if prime...
primes = Array.new(50000, true) primes[0, 2] = [false, false] 2.upto(50000 - 1){|x| if primes[x] m = 2 while x * m <= 999_999 primes[x * m] = false m += 1 end end } while true n = gets.to_i break if n == 0 sum = 0 2.upto(n/2){|x| sum += 1 if prime...
[ "literal.number.integer.change" ]
28,457
28,456
u247371045
ruby
p00056
def primes(max) nums = Array.new(max + 1, 1) nums[0] = nums[1] = 0 (2..Math.sqrt(max)).each do |sieve| if nums[sieve] == 1 (2 * sieve).step(max, sieve).each do |num| nums[num] = 0 end end end nums end max = 50 primes = primes(max) nums = (2..max).select { |num| primes[num] == ...
def primes(max) nums = Array.new(max + 1, 1) nums[0] = nums[1] = 0 (2..Math.sqrt(max)).each do |sieve| if nums[sieve] == 1 (2 * sieve).step(max, sieve).each do |num| nums[num] = 0 end end end nums end max = 50_000 primes = primes(max) nums = (2..max).select { |num| primes[num]...
[ "literal.number.integer.change", "assignment.value.change" ]
28,458
28,459
u024281398
ruby
p00056
sn = 50000.0**0.5 + 1 is_prime = [false, false] + [true]*49999 (2..sn).each do |i| next unless is_prime[i] (i*i).step(50000, i).each do |j| is_prime[j] = false end end plist = (2..50000).to_a.select{ |i| is_prime[i] } while gets s = $_.to_i tmp = plist.dup l = tmp.shift h = tmp.pop c = 0 until t...
sn = 50000.0**0.5 + 1 is_prime = [false, false] + [true]*49999 (2..sn).each do |i| next unless is_prime[i] (i*i).step(50000, i).each do |j| is_prime[j] = false end end plist = (2..50000).to_a.select{ |i| is_prime[i] } while gets s = $_.to_i break if s == 0 tmp = plist.dup l = tmp.shift h = tmp.pop ...
[]
28,466
28,467
u708217907
ruby
p00064
a=[] while gets a<<$_.chomp.split(/[a-z]+/).map(&:to_i) end p a.flatten.inject(:+)
a=[] while gets a<<$_.chomp.split(/[^0-9]+/).map(&:to_i) end p a.flatten.inject(:+)
[ "literal.string.change", "call.arguments.change", "expression.operation.binary.change" ]
28,575
28,576
u461552210
ruby
p00065
a,b=gets(p).split("\n\n"); c=[0]*2000;d=[0]*2000; ans=[]; a.split.map{|s|b=s.to_i;c[b]+=1} b.split.map{|s|b=s.to_i;ans<<b if c[b]>0;d[b]+=1} ans=ans.sort.uniq; ans.map{|a|puts "#{a} #{c[a]+d[a]}"}
a,b=gets(p).split("\n\n"); c=[0]*2000;d=[0]*2000; ans=[]; a.split.map{|s|l=s.to_i;c[l]+=1} b.split.map{|s|b=s.to_i;ans<<b if c[b]>0;d[b]+=1} ans=ans.sort.uniq; ans.map{|a|puts "#{a} #{c[a]+d[a]}"}
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
28,646
28,647
u868447400
ruby
p00065
pm = {} while (s = gets) != "\n" (n, c) = s.chomp.split(/,/).map(&:to_i) pm[n] = [] if !pm.key?(n) pm[n].push(c) end tm = {} while (s = gets) != "\n" (n, c) = s.chomp.split(/,/).map(&:to_i) tm[n] = [] if !tm.key?(n) tm[n].push(c) end pm.keys.sort.each do |k| if tm.key?(k) puts "#{k} #{pm[k].size +...
pm = {} while (s = gets) != "\n" (n, c) = s.chomp.split(/,/).map(&:to_i) pm[n] = [] if !pm.key?(n) pm[n].push(c) end tm = {} while s = gets (n, c) = s.chomp.split(/,/).map(&:to_i) tm[n] = [] if !tm.key?(n) tm[n].push(c) end pm.keys.sort.each do |k| if tm.key?(k) puts "#{k} #{pm[k].size + tm[k].siz...
[ "expression.operation.binary.remove" ]
28,650
28,651
u854447110
ruby
p00071
#!/usr/bin/env ruby def bomb(x, y) return if @field[x][y] != 1 @field[x][y] = 0 -3.upto(3) do |i| next if i.zero? bomb(x + i, y) if (x + i) > 0 && (x + i) < 8 bomb(x, y + i) if (y + i) > 0 && (y + i) < 8 end end n = gets.chomp!.to_i # skip empty line gets n.times do |i| @field = [] 8.times ...
#!/usr/bin/env ruby def bomb(x, y) return if @field[x][y] != 1 @field[x][y] = 0 -3.upto(3) do |i| next if i.zero? bomb(x + i, y) if (x + i) >= 0 && (x + i) < 8 bomb(x, y + i) if (y + i) >= 0 && (y + i) < 8 end end n = gets.chomp!.to_i # skip empty line gets n.times do |i| @field = [] 8.time...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
28,818
28,819
u717782380
ruby
p00071
#!/usr/bin/env ruby def bomb(x, y) return if @field[x][y] != 1 @field[x][y] = 0 -3.upto(3) do |i| next if i.zero? bomb(x + i, y) if (x + i) >= 0 && (x + i) < 8 bomb(x, y + i) if (y + i) >= 0 && (y + i) < 8 end end n = gets.chomp!.to_i # skip empty line gets n.times do |i| @field = [] 8.time...
#!/usr/bin/env ruby def bomb(x, y) return if @field[x][y] != 1 @field[x][y] = 0 -3.upto(3) do |i| next if i.zero? bomb(x + i, y) if (x + i) >= 0 && (x + i) < 8 bomb(x, y + i) if (y + i) >= 0 && (y + i) < 8 end end n = gets.chomp!.to_i # skip empty line gets n.times do |i| @field = [] 8.time...
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
28,820
28,819
u717782380
ruby
p00074
loop do record_time=2*3600#????????§???????§???° time=gets.chomp.split(nil).map(&:to_i) break if time.all?{|x|x==-1} t=time[2] t+=time[1]*60 t+=time[0]*3600 #?¨?????????? rest_of_time=record_time-t h=rest_of_time/3600#hour m=(rest_of_time%3600)/60#minute s=rest_of_t...
loop do record_time=2*3600#????????§???????§???° time=gets.chomp.split(nil).map(&:to_i) break if time.all?{|x|x==-1} t=time[2] t+=time[1]*60 t+=time[0]*3600 #?¨?????????? rest_of_time=record_time-t h=rest_of_time/3600#hour m=(rest_of_time%3600)/60#minute s=rest_of_time%60#sec...
[ "literal.string.change", "call.arguments.change", "io.output.change", "assignment.value.change", "expression.operation.binary.change" ]
29,267
29,268
u287407095
ruby
p00077
puts gets.chomp.gsub(/@(\d)(.)/) {|m| m[2] * m[1].to_i}
while line = gets puts line.chomp.gsub(/@(\d)(.)/) {|m| m[2] * m[1].to_i} end
[ "call.add" ]
29,618
29,619
u670581076
ruby
p00079
def aop() i = 0 b = [] a =[] c = [] while c = gets b = c.split(',').map(&:to_f) puts b a[i] = b i += 1 end t = 0 for i in 1..a.length-2 x = ((a[0][0]-a[i][0])**2 + (a[0][1]-a[i][1])**2)**(1/2.0) y = ((a[0][0]-a[i+1][0])**2 + (a[0][1]-a[i+1][1])**2)**(1/2.0) z = ((a[i+1][0]-a[...
def aop() i = 0 b = [] a =[] c = [] while c = gets b = c.split(',').map(&:to_f) a[i] = b i += 1 end t = 0 for i in 1..a.length-2 x = ((a[0][0]-a[i][0])**2 + (a[0][1]-a[i][1])**2)**(1/2.0) y = ((a[0][0]-a[i+1][0])**2 + (a[0][1]-a[i+1][1])**2)**(1/2.0) z = ((a[i+1][0]-a[i][0])**2 +...
[ "call.remove" ]
30,030
30,031
u670287874
ruby
p00079
point = Array.new def solve(point) source = point[0] point.delete_at(0) # point.sort{|p1,p2| p1[1] <=> p2[1]} sum = 0 while point.size > 1 do p1 = point[0] p2 = point[1] a = getDistance(source, p1) b = getDistance(source,p2) c = getDistance(p1, p2) z = (a + b + c) / 2 ...
point = Array.new def solve(point) source = point[0] point.delete_at(0) # point.sort{|p1,p2| p1[1] <=> p2[1]} sum = 0 while point.size > 1 do p1 = point[0] p2 = point[1] a = getDistance(source, p1) b = getDistance(source,p2) c = getDistance(p1, p2) z = (a + b + c) / 2 ...
[ "call.arguments.change", "expression.operation.binary.change" ]
30,032
30,033
u985809245
ruby
p00069
def amida(n,m,s,l) a=Array.new(n) {|i| i+1} l.each do |i| i.each_with_index do |j,id| a[id],a[id+1]=a[id+1],a[id] if j==1 end end return a[s-1]==m ? true : false end loop do break if gets.chomp=="0" n,m,s,d,l=$_.to_i,gets.to_i,gets.to_i,gets.to_i,[] d.times do l<<gets.chomp.split("").ma...
def amida(n,m,s,l) a=Array.new(n) {|i| i+1} l.each do |i| i.each_with_index do |j,id| a[id],a[id+1]=a[id+1],a[id] if j==1 end end return a[s-1]==m ? true : false end loop do break if gets.chomp=="0" n,m,s,d,l=$_.to_i,gets.to_i,gets.to_i,gets.to_i,[] d.times do l<<gets.chomp.split("").ma...
[]
30,146
30,147
u461552210
ruby
p00069
def amida(n,m,s,l) a=Array.new(n) {|i| i+1} l.each do |i| # puts "#{i.join}" i.each_with_index do |j,id| a[id],a[id+1]=a[id+1],a[id] if j==1 end end # p a # puts "m:#{m}, s:#{s}" return a[s-1]==m ? true : false end loop do break if gets.chomp=="0" n,m,s,d,l=$_.to_i,gets.to_i,gets.to_i...
def amida(n,m,s,l) a=Array.new(n) {|i| i+1} l.each do |i| i.each_with_index do |j,id| a[id],a[id+1]=a[id+1],a[id] if j==1 end end return a[s-1]==m ? true : false end loop do break if gets.chomp=="0" n,m,s,d,l=$_.to_i,gets.to_i,gets.to_i,gets.to_i,[] d.times do l<<gets.chomp.split("").ma...
[]
30,148
30,147
u461552210
ruby
p00069
def goal?(amida,m,s) s == 1 + (amida.inject(m-1) do |s,i| if s>1 && i[s-1]=="1" s-1 elsif i[s]=="1" s+1 else s end end) end loop do n = gets.to_i break if n==0 m,s,d = 3.times.map{ gets.to_i } amida = d.times.map{ gets.chomp } if goal?(amida,m,s) puts 0 next en...
def goal?(amida,m,s) s == 1 + (amida.inject(m-1) do |s,i| if s>=1 && i[s-1]=="1" s-1 elsif i[s]=="1" s+1 else s end end) end loop do n = gets.to_i break if n==0 m,s,d = 3.times.map{ gets.to_i } amida = d.times.map{ gets.chomp } if goal?(amida,m,s) puts 0 next e...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
30,152
30,153
u662700808
ruby
p00084
arr, ans = gets.split.map{ |i| i.delete(",.") }, [] arr.each do |str| p str.length ans << str if (3..6).include?(str.length) end puts ans.join(" ")
arr, ans = gets.split.map{ |i| i.delete(",.") }, [] arr.each do |str| ans << str if (3..6).include?(str.length) end puts ans.join(" ")
[ "call.remove" ]
30,382
30,383
u814658648
ruby
p00080
while true q=gets.to_f break if(q==-1) x=q/2 p x while (x**3-q).abs>=0.00001 x=x-((x**3-q)/(3*x*x)) end printf("%.6f\n", x) end
while true q=gets.to_f break if(q==-1) x=q/2 while (x**3-q).abs>0.00001*q x=x-((x**3-q)/(3*x*x)) end printf("%.6f\n", x) end
[ "call.remove", "expression.operator.compare.change", "expression.operation.binary.change" ]
30,786
30,784
u287407095
ruby
p00080
readlines.map(&:to_f).each{|q| break if q == -1 x = q / 2.0 loop do break if (x * x * x - q).abs < 0.0001 * q x -= (x * x * x - q)/(3.0*x * x) end puts "%.6f" % x }
readlines.map(&:to_f).each{|q| break if q == -1 x = q / 2.0 loop do break if (x * x * x - q).abs < 0.00001 * q x -= (x * x * x - q)/(3.0*x * x) end puts "%.8f" % x }
[ "literal.number.float.change", "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
30,789
30,790
u960312159
ruby
p00080
readlines.map(&:to_f).each{|q| break if q == -1 x = q / 2.0 loop do break if (x * x * x - q).abs < 0.0001 * q x -= (x * x * x - q)/(3.0*x * x) end puts "%.8f" % x }
readlines.map(&:to_f).each{|q| break if q == -1 x = q / 2.0 loop do break if (x * x * x - q).abs < 0.00001 * q x -= (x * x * x - q)/(3.0*x * x) end puts "%.8f" % x }
[ "literal.number.float.change", "control_flow.branch.if.condition.change" ]
30,791
30,790
u960312159
ruby
p00082
c = [4,1,4,1,2,1,2,1] readlines.each do |l| p = l.split.map(&:to_i) ans = 7.times.map{ c=c.rotate }.sort do |a,b| t = (a.zip(p).map{|i,j| [i-j,0].max}.inject(:+) <=> b.zip(p).map{|i,j| [i-j,0].max}.inject(:+)) t==0 ? a.join.to_i <=> b.join.to_i : t end.first puts ans.join(" ") end
c = [4,1,4,1,2,1,2,1] readlines.each do |l| p = l.split.map(&:to_i) ans = 8.times.map{ c=c.rotate }.sort do |a,b| t = (a.zip(p).map{|i,j| [i-j,0].max}.inject(:+) <=> b.zip(p).map{|i,j| [i-j,0].max}.inject(:+)) t==0 ? a.join.to_i <=> b.join.to_i : t end.first puts ans.join(" ") end
[ "literal.number.integer.change", "assignment.value.change" ]
30,879
30,880
u662700808
ruby
p00085
readlines.each do |l| n,m = l.split.map(&:to_i) break if n==0 && m==0 i = n p = (0..(n-1)).to_a while p.size>1 p.delete_at(i=((i+m) % p.size)) i = (i-1) % p.size end puts p.first end
readlines.each do |l| n,m = l.split.map(&:to_i) break if n==0 && m==0 i = -1 p = (0..(n-1)).to_a while p.size>1 p.delete_at(i=((i+m) % p.size)) i = (i-1) % p.size end puts p.first+1 end
[ "assignment.value.change", "expression.operation.unary.add" ]
31,089
31,090
u662700808
ruby
p00088
def main(input = STDIN) plane = {" " => "101", "'" => "000000", "," => "000011", "-" => "10010001", "." => "010001", "?" => "000001", "A" => "100101", "B" => "10011010", "C" => "0101", "D" => "0001", "E" => "110", "F" => "01001", "G" => "10011011", "H" => "010000", "I" => "0111", "J" => "10011000", "K" => "0110", "L"...
def main(input = STDIN) plane = {" " => "101", "'" => "000000", "," => "000011", "-" => "10010001", "." => "010001", "?" => "000001", "A" => "100101", "B" => "10011010", "C" => "0101", "D" => "0001", "E" => "110", "F" => "01001", "G" => "10011011", "H" => "010000", "I" => "0111", "J" => "10011000", "K" => "0110", "L"...
[]
31,353
31,354
u514597327
ruby
p00088
code_a = Hash[ *%w( ' 000000 , 000011 - 10010001 . 010001 ? 000001 A 100101 B 10011010 C 0101 D 0001 E 110 F 01001 G 10011011 H 010000 I 0111 J 10011000 K 0110 L 00100 M 10011001 N 10011110 O 00101 P 111 Q 10011111 R 1000 S 00110 T 00111 U 10011100 V 10011101 W 000010 X 10010010 Y 10010011 Z 10010000 )] code_a[' '] = '...
code_a = Hash[ *%w( ' 000000 , 000011 - 10010001 . 010001 ? 000001 A 100101 B 10011010 C 0101 D 0001 E 110 F 01001 G 10011011 H 010000 I 0111 J 10011000 K 0110 L 00100 M 10011001 N 10011110 O 00101 P 111 Q 10011111 R 1000 S 00110 T 00111 U 10011100 V 10011101 W 000010 X 10010010 Y 10010011 Z 10010000 )] code_a[' '] = '...
[ "expression.operation.binary.remove" ]
31,355
31,356
u797180951
ruby
p00088
words = [" ", "\'", ",", "-", ".", "?"] words += %{ABCDEFGHIJKLMNOPQRSTUVWXYZ}.split("") code = %w{101 000000 000011 10010001 010001 000001 100101 10011010 0101 0001 110 01001 10011011 010000 0111 10011000 0110 00100 10011001 10011110 00101 111 10011111 1000 00110 00111 10011100 10011101 000010 100100...
words = [" ", "\'", ",", "-", ".", "?"] words += %{ABCDEFGHIJKLMNOPQRSTUVWXYZ}.split("") code = %w{101 000000 000011 10010001 010001 000001 100101 10011010 0101 0001 110 01001 10011011 010000 0111 10011000 0110 00100 10011001 10011110 00101 111 10011111 1000 00110 00111 10011100 10011101 000010 100100...
[ "call.add" ]
31,357
31,358
u811434779
ruby
p00088
mp = {} mp[" "] = "101" mp["'"] = "000000" mp[","] = "000011" mp["-"] = "10010001" mp["."] = "010001" mp["?"] = "000001" mp["A"] = "100101" mp["B"] = "10011010" mp["C"] = "0101" mp["D"] = "0001" mp["E"]="110" mp["F"]="01001" mp["G"]="10011011" mp["H"]="010000" mp["I"]="0111" mp["J"]="10011000" mp["K"]="0110" mp["L"]="0...
mp = {} mp[" "] = "101" mp["'"] = "000000" mp[","] = "000011" mp["-"] = "10010001" mp["."] = "010001" mp["?"] = "000001" mp["A"] = "100101" mp["B"] = "10011010" mp["C"] = "0101" mp["D"] = "0001" mp["E"]="110" mp["F"]="01001" mp["G"]="10011011" mp["H"]="010000" mp["I"]="0111" mp["J"]="10011000" mp["K"]="0110" mp["L"]="0...
[ "literal.string.change", "assignment.variable.change", "variable_access.subscript.index.change" ]
31,359
31,360
u289594538
ruby
p00088
class String @@encode = {} @@decode = {} def encode res = split('').map{ |c| @@encode[c] }.join res + '0' * (5 - res.size % 5) end def decode scan(/.{5}/).map{ |s| @@decode[s] }.join end @@encode[" "] = "101" @@encode["'"] = "000000" @@encode[","] = "000011" @@encode["-"] = "10010001...
class String @@encode = {} @@decode = {} def encode res = split('').map{ |c| @@encode[c] }.join res + '0' * ((5 - res.size % 5) % 5) end def decode scan(/.{5}/).map{ |s| @@decode[s] }.join end @@encode[" "] = "101" @@encode["'"] = "000000" @@encode[","] = "000011" @@encode["-"] = "10...
[]
31,363
31,364
u439230786
ruby
p00088
class String @@encode = {} @@decode = {} def encode res = split('').map{ |c| @@encode[c] }.join res + '0' * (5 - res.size % 5) % 5 end def decode scan(/.{5}/).map{ |s| @@decode[s] }.join end @@encode[" "] = "101" @@encode["'"] = "000000" @@encode[","] = "000011" @@encode["-"] = "1001...
class String @@encode = {} @@decode = {} def encode res = split('').map{ |c| @@encode[c] }.join res + '0' * ((5 - res.size % 5) % 5) end def decode scan(/.{5}/).map{ |s| @@decode[s] }.join end @@encode[" "] = "101" @@encode["'"] = "000000" @@encode[","] = "000011" @@encode["-"] = "10...
[]
31,365
31,364
u439230786
ruby
p00087
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A\d+\z/ stack << t.to_i when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack <<...
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A-?\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack ...
[ "call.function.change", "type_conversion.to_float.change", "type_conversion.to_number.change" ]
31,696
31,697
u810567623
ruby
p00087
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack <<...
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A-?\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack ...
[]
31,698
31,697
u810567623
ruby
p00087
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack <<...
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A-?\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack ...
[ "call.arguments.change" ]
31,699
31,697
u810567623
ruby
p00087
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack <<...
while _ = $stdin.gets stack = [] terms = _.chomp.split(/ /) terms.each do |t| case t when /^\A-?\d+\z/ stack << t.to_f when '+' stack << stack.pop(2).inject(:+) when '-' stack << stack.pop(2).inject(:-) when '/' stack << stack.pop(2).inject(:/) when '*' stack ...
[ "call.remove" ]
31,700
31,697
u810567623
ruby
p00087
$<.each do |line| stack = line.chomp.split #逆ポーランド記法 n = stack.inject([]) do |s, x| x =~ /[0-9]/ ? s << x : s << eval(s.pop(2).join(x)) end puts sprintf("%.6f", n.first + 0) end
$<.each do |line| stack = line.chomp.split #逆ポーランド記法 n = stack.inject([]) do |s, x| x =~ /[0-9]/ ? s << x.to_f : s << eval(s.pop(2).join(x)) end puts sprintf("%.6f", n.first + 0) end
[ "call.add" ]
31,701
31,702
u858664023
ruby
p00093
require 'date' f=nil;while(a,b=gets.split.map(&:to_i))!=[0,0]do if f then puts end;f=1 z=a.step(b).select{|i|Date.new(i).leap?} if z.size==0 then puts'NA'else z.each{|e|p e}end end
require 'date' f=nil;while(a,b=gets.split.map(&:to_i))!=[0,0]do if f then puts end;f=1 z=a.step(b).select{|i|Date.leap?(i)} if z.size==0 then puts'NA'else z.each{|e|p e}end end
[ "assignment.value.change", "identifier.change", "call.remove" ]
31,810
31,811
u300645821
ruby
p00093
f=nil;while(a,b=gets.split.map(&:to_i))!=[0,0]do if f then puts end;f=1 z=a.step(b).select{|i|Date.leap?(i)} if z.size==0 then puts'NA'else z.each{|e|p e}end end
require 'date' f=nil;while(a,b=gets.split.map(&:to_i))!=[0,0]do if f then puts end;f=1 z=a.step(b).select{|i|Date.leap?(i)} if z.size==0 then puts'NA'else z.each{|e|p e}end end
[ "call.add" ]
31,812
31,811
u300645821
ruby
p00095
gets;p [*$<].max_by{|s|a,b=s.split.map &:to_i;b*100+100-a}
gets;puts [*$<].max_by{|s|a,b=s.split.map &:to_i;b*100+100-a}
[ "call.function.change", "io.output.change" ]
32,017
32,018
u868447400
ruby
p00095
a=0;v=0; gets.to_i.times do line=gets x,y=line.split.map(&:to_i) if y>v then a=x;v=y elsif y=v then if x<a then a=x end end end print a," ",v,"\n"
a=0;v=-1; gets.to_i.times do line=gets x,y=line.split.map(&:to_i) if y>v then a=x;v=y elsif y==v then if x<a then a=x end end end print a," ",v,"\n"
[ "assignment.value.change", "expression.operation.unary.add", "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
32,025
32,026
u925831343
ruby
p00095
a=0;v=-1; gets.to_i.times do line=gets x,y=line.split.map(&:to_i) if y>v then a=x;v=y elsif y=v then if x<a then a=x end end end print a," ",v,"\n"
a=0;v=-1; gets.to_i.times do line=gets x,y=line.split.map(&:to_i) if y>v then a=x;v=y elsif y==v then if x<a then a=x end end end print a," ",v,"\n"
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
32,027
32,026
u925831343
ruby
p00095
def main(input = STDIN) maxv = 0 maxa = 1 / 0.0 input.gets.to_i.times do a, v = input.gets.split(" ").map(&:to_i) maxv, maxa = v, a if maxv < v or (maxv == v and maxa <= a) end puts "#{maxa} #{maxv}" end main
def main(input = STDIN) maxv = 0 maxa = 1 / 0.0 input.gets.to_i.times do a, v = input.gets.split(" ").map(&:to_i) maxv, maxa = v, a if maxv < v or (maxv == v and maxa > a) end puts "#{maxa} #{maxv}" end main
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
32,028
32,029
u514597327
ruby
p00095
l = [] gets.to_i.times { l << gets.split.map(&:to_i) } puts l.sort_by{ |v| [-v[1], v[0]] }.join(" ")
l = [] gets.to_i.times { l << gets.split.map(&:to_i) } puts l.sort_by{ |v| [-v[1], v[0]] }[0].join(" ")
[]
32,030
32,031
u811434779
ruby
p00097
L = 100 @memo = Array.new(9) {Array.new(101) {[]}} def solve(num, start, sum) return 0 if sum <= 0 or start > L return (sum <= L) ? 1 : 0 if num == 1 a = @memo[num - 1][start][sum] return a if a co = 0 lim = [L, sum].min (start..lim).each do |i| co += solve(num - 1, i + 1, sum - i) end @memo[num ...
L = 100 @memo = Array.new(9) {Array.new(101) {[]}} def solve(num, start, sum) return 0 if sum < 0 or start > L return (start <= sum and sum <= L) ? 1 : 0 if num == 1 a = @memo[num - 1][start][sum] return a if a co = 0 lim = [L, sum].min (start..lim).each do |i| co += solve(num - 1, i + 1, sum - i) ...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
32,392
32,393
u864617427
ruby
p00097
L = 100 @memo = Array.new(9) {Array.new(101) {[]}} def solve(num, start, sum) return 0 if sum <= 0 or start > L return (sum <= L) ? 1 : 0 if num == 1 a = @memo[num - 1][start][sum] return a if a co = 0 lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min (start..lim).each do |i| co += solve(num - 1,...
L = 100 @memo = Array.new(9) {Array.new(101) {[]}} def solve(num, start, sum) return 0 if sum < 0 or start > L return (start <= sum and sum <= L) ? 1 : 0 if num == 1 a = @memo[num - 1][start][sum] return a if a co = 0 lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min (start..lim).each do |i| co +...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
32,395
32,396
u864617427
ruby
p00097
L = 100 @memo = Array.new(9) {Array.new(101) {[]}} def solve(num, start, sum) return 0 if sum <= 0 or start > L return (start <= sum and sum <= L) ? 1 : 0 if num == 1 a = @memo[num - 1][start][sum] return a if a co = 0 lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min (start..lim).each do |i| co ...
L = 100 @memo = Array.new(9) {Array.new(101) {[]}} def solve(num, start, sum) return 0 if sum < 0 or start > L return (start <= sum and sum <= L) ? 1 : 0 if num == 1 a = @memo[num - 1][start][sum] return a if a co = 0 lim = [L, (2 * sum - num ** 2 + num) / (2 * num)].min (start..lim).each do |i| co +...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
32,397
32,396
u864617427
ruby
p00099
hash = Hash.new(0) min_a, max_v = Float::INFINITY, 0 n, q = gets.chomp.split.map(&:to_i) q.times do a, v = gets.chomp.split.map(&:to_i) hash[a] += v if v > 0 if hash[a] > max_v max_v = hash[a] min_a = a elsif hash[a] == max_v max_a = [a, min_a].min end else if a == min_a ...
hash = Hash.new(0) min_a, max_v = Float::INFINITY, -Float::INFINITY n, q = gets.chomp.split.map(&:to_i) q.times do a, v = gets.chomp.split.map(&:to_i) hash[a] += v if v > 0 if hash[a] > max_v max_v = hash[a] min_a = a elsif hash[a] == max_v min_a = [a, min_a].min end else if ...
[ "assignment.value.change", "assignment.variable.change", "identifier.change" ]
32,877
32,878
u024281398
ruby
p00100
while true hash = Hash.new n = gets.to_i #???????????° break if n == 0 for r in 0...n do line = gets.chomp! line = line.split no = line[0].to_i #???????????? unitPrice = line[1].to_i #????£??????? quantity = line[2].to_i #?£??????°??? total = unitPrice * quantity #?°??¨? if hash.key?(no) tota...
while true hash = Hash.new n = gets.to_i #???????????° break if n == 0 for r in 0...n do line = gets.chomp! line = line.split no = line[0].to_i #???????????? unitPrice = line[1].to_i #????£??????? quantity = line[2].to_i #?£??????°??? total = unitPrice * quantity #?°??¨? if hash.key?(no) tota...
[ "call.function.change", "io.output.change" ]
33,551
33,552
u290971603
ruby
p00100
loop do n = gets.to_i break if n.zero? totals = Hash.new(0) n.times do e, p, q = gets.split.map(&:to_i) totals[e] += p * q end employees = totals.select { |_, total| total >= 1_000_000 }.keys.sort if employees.empty? puts 'NA' else puts employees.sort.join("\n") end end
loop do n = gets.to_i break if n.zero? totals = Hash.new(0) n.times do e, p, q = gets.split.map(&:to_i) totals[e] += p * q end employees = totals.select { |_, total| total >= 1_000_000 }.keys if employees.empty? puts 'NA' else puts employees.join("\n") end end
[ "call.remove" ]
33,560
33,561
u139670451
ruby
p00100
while n = gets.chomp.to_i break if n.zero? sales = Hash.new{0} n.times do e, p, q = gets.chomp.split.map(&:to_i) sales[e] += p * q end achieved = sales.select{|k, v| v >= 1_000_000} achieved.each{|k, v| puts k} puts 'NA' unless achieved.empty? end
while n = gets.chomp.to_i break if n.zero? sales = Hash.new{0} n.times do e, p, q = gets.chomp.split.map(&:to_i) sales[e] += p * q end achieved = sales.select{|k, v| v >= 1_000_000} achieved.each{|k, v| puts k} puts 'NA' if achieved.empty? end
[]
33,562
33,563
u670581076
ruby
p00100
loop do n = gets.to_i break if n.zero? dataset = Hash.new dataset.default = 0 n.times do id, selling_price, quantity = gets.chomp.split.map(&:to_i) dataset[id] += selling_price * quantity end satisfying_id = dataset.select{|id, sales| v >= 1000000 }.keys.join(?\n) puts (satisfying_id.empty? ? "NA" : ...
loop do n = gets.to_i break if n.zero? dataset = Hash.new dataset.default = 0 n.times do id, selling_price, quantity = gets.chomp.split.map(&:to_i) dataset[id] += selling_price * quantity end satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys.join(?\n) puts (satisfying_id.empty? ? "NA...
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change", "call.remove" ]
33,568
33,569
u881491942
ruby
p00100
loop do n = gets.to_i break if n.zero? dataset = Hash.new dataset.default = 0 n.times do id, selling_price, quantity = gets.chomp.split.map(&:to_i) dataset[id] += selling_price * quantity end satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys.join(?\n) puts (satisfying_id.empty? ? "NA...
loop do n = gets.to_i break if n.zero? dataset = Hash.new dataset.default = 0 n.times do id, selling_price, quantity = gets.chomp.split.map(&:to_i) dataset[id] += selling_price * quantity end satisfying_id = dataset.select{|id, sales| sales >= 1000000 }.keys.join(?\n) puts (satisfying_id.empty? ? "NA...
[ "call.remove" ]
33,570
33,569
u881491942
ruby
p00103
gets.to_i.times{r=o=s=0 (c=gets[1];c<?O?(r+=1):c<?U?(s+=r+1;r=0):o+=1)while o<3 p s+r-3}
gets.to_i.times{r=o=s=0 (c=gets[1];c<?O?(r+=1):c<?U?(s+=r+1;r=0):o+=1)while o<3 p r<3?s:s+r-3}
[ "call.arguments.change" ]
33,664
33,665
u198069342
ruby
p00103
class BaseBall def initialize @first=false @second=false @third=false @out=0 end def hit if @third then point=1 else point=0 end @third = false @third = true if @second @second = true if @first @first = true return point end def homerun point=...
class BaseBall def initialize @first=false @second=false @third=false @out=0 end def hit if @third then point=1 else point=0 end @third = false @third = true if @second @second = true if @first @first = true return point end def homerun point=...
[ "misc.opposites", "control_flow.branch.if.condition.change" ]
33,668
33,669
u032662562
ruby
p00103
left=gets.to_i out,runner,score=0,0,0 while left>0 judge=gets.chomp case judge when "HIT" then runner+=1 if runner>3 then runner-=1 score+=1 end when "OUT" then out+=1 if out>=3 then puts score runner,score=0,0 left-=1 end when "HOMERUN" then score+=(r...
left=gets.to_i out,runner,score=0,0,0 while left>0 judge=gets.chomp case judge when "HIT" then runner+=1 if runner>3 then runner-=1 score+=1 end when "OUT" then out+=1 if out>=3 then puts score runner,score,out=0,0,0 left-=1 end when "HOMERUN" then sco...
[]
33,670
33,671
u461552210
ruby
p00101
n = gets puts $_.gsub("Hoshiro", "Hoshina") while gets
n = gets puts $_.gsub("Hoshino", "Hoshina") while gets
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
33,901
33,902
u797180951
ruby
p00101
n = gets.to_i n.times do line = gets.chomp! puts line.gsub('Hosino', 'Hoshina') end
n = gets.to_i n.times do line = gets.chomp! puts line.gsub('Hoshino', 'Hoshina') end
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
33,905
33,906
u888227825
ruby
p00101
#繰り返し回数 count = gets.to_i count.times do #入力された値の"Hoshino"を"Hoshina"に置き換えて表示 p gets.gsub("Hoshino","Hoshina") end
#繰り返し回数 count = gets.to_i count.times do #入力された値の"Hoshino"を"Hoshina"に置き換えて表示 puts gets.gsub("Hoshino","Hoshina") end
[ "call.function.change", "io.output.change" ]
33,917
33,916
u770686467
ruby
p00101
gets.to_i.times { p gets.chomp.gsub("Hoshino", "Hoshina") }
gets.to_i.times { puts gets.chomp.gsub("Hoshino", "Hoshina") }
[ "call.function.change", "io.output.change" ]
33,928
33,929
u881491942
ruby
p00102
num=[] while gets x=[] y=[] z=0 s=$_.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end end ...
loop do num=[] x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end en...
[ "assignment.value.change" ]
34,203
34,204
u287407095
ruby
p00102
num=[] while true x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end end...
loop do num=[] x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end en...
[]
34,205
34,204
u287407095
ruby
p00102
num=[] loop do x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end end ...
loop do num=[] x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end en...
[]
34,206
34,204
u287407095
ruby
p00102
num=[] loop do x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end end ...
loop do num=[] x=[] y=[] z=0 s=gets.to_i break if (s==0) s.times do |i| x[i]=0 num<<gets.chomp.split(nil).map(&:to_i) x[i]=num[i].inject(:+) z+=x[i] end s.times do |i| y[i]=0 s.times do |j| y[i]+=num[j][i] end en...
[]
34,208
34,204
u287407095
ruby
p00104
loop do w, h = gets.chomp.split.map(&:to_i) break if [w, h].all?(&:zero?) tile_map = Array.new h.times do |i| tile_map[i] = gets.chomp.split('') end x = y = 0 tile_already_arrived = Array.new h.times { tile_already_arrived << Array.new(w, false) } is_loop = false while true tile = tile_map[y][x] if t...
loop do h, w = gets.chomp.split.map(&:to_i) break if [w, h].all?(&:zero?) tile_map = Array.new h.times do |i| tile_map[i] = gets.chomp.split('') end x = y = 0 tile_already_arrived = Array.new h.times { tile_already_arrived << Array.new(w, false) } is_loop = false while true tile = tile_map[y][x] if t...
[]
34,251
34,252
u881491942
ruby
p00104
loop do h, w = gets.chomp.split.map(&:to_i) break if [h, w].all?(&:zero?) tile_map = tile_already_arrived = Array.new h.times do tile_map << gets.chomp.split('') tile_already_arrived << Array.new(w, false) end x = y = 0 while true tile_present = tile_map[y][x] if tile_already_arrived[y][x] == true ...
loop do h, w = gets.chomp.split.map(&:to_i) break if [h, w].all?(&:zero?) tile_map = Array.new tile_already_arrived = Array.new h.times do tile_map << gets.chomp.split('') tile_already_arrived << Array.new(w, false) end x = y = 0 while true tile_present = tile_map[y][x] if tile_already_arrived[y][x...
[ "call.add" ]
34,253
34,254
u881491942
ruby
p00104
loop do h, w = gets.chomp.split.map(&:to_i) break if [h, w].all?(&:zero?) tile_map = tile_already_arrived = Array.new h.times do tile_map << gets.chomp.split('') tile_already_arrived << Array.new(w, false) end x = y = 0 while true tile_present = tile_map[y][x] if tile_already_arrived[y][x] == true ...
loop do h, w = gets.chomp.split.map(&:to_i) break if [h, w].all?(&:zero?) tile_map = Array.new tile_already_arrived = Array.new h.times do tile_map << gets.chomp.split('') tile_already_arrived << Array.new(w, false) end x = y = 0 while true tile_present = tile_map[y][x] if tile_alre...
[ "call.add" ]
34,253
34,255
u881491942
ruby
p00105
index=Hash.new{|word,page| word[page] = []} while line =gets do word,page= line.split(" ") page =page.to_i index[word]<<page end p index index.each{|word,page|page.sort!} index2=index.sort index2.each{|key,value| puts key puts value.join(" ") }
index=Hash.new{|word,page| word[page] = []} while line =gets do word,page= line.split(" ") page =page.to_i index[word]<<page end index.each{|word,page|page.sort!} index2=index.sort index2.each{|key,value| puts key puts value.join(" ") }
[ "call.remove" ]
34,380
34,381
u534464795
ruby
p00105
cat rb.rb hash = Hash.new([]) while true do line = gets break if line == nil line.chomp word, page = line.split(' ') hash[word] += [page.to_i] end arr = hash.sort arr.each do |w| puts w[0] w[1].sort! puts w[1].join(' ') end
hash = Hash.new([]) while true do line = gets break if line == nil line.chomp word, page = line.split(' ') hash[word] += [page.to_i] end arr = hash.sort arr.each do |w| puts w[0] w[1].sort! puts w[1].join(' ') end
[ "call.remove" ]
34,382
34,383
u879497299
ruby
p00121
require 'pry' def to_xy(str, target) str.chars.each_with_index do |s, i| if target == s.to_i x = i%4 y = i < 4 ? 0 : 1 return x, y, i end end end def move_zero(str, mx, my) zx, zy, zi = to_xy(str, 0) (1..7).each do |i| sx, sy, si = to_xy(str, i) if (zx + mx) == sx and (zy + m...
def to_xy(str, target) str.chars.each_with_index do |s, i| if target == s.to_i x = i%4 y = i < 4 ? 0 : 1 return x, y, i end end end def move_zero(str, mx, my) zx, zy, zi = to_xy(str, 0) (1..7).each do |i| sx, sy, si = to_xy(str, i) if (zx + mx) == sx and (zy + my) == sy ...
[ "call.remove" ]
37,128
37,129
u708217907
ruby
p00127
def maje_table i = 0 j = 0 table = Array.new(6) table.map!{Array.new(5)} "a".upto("z") do |c| table[i][j] = c j += 1 i += 1 if j == 5 j = 0 if j == 5 end table[5][1] = '.' table[5][2] = '?' table[5][3] = '!' table[5][4] = ' ' table end $table = make_table readlines.each do |in...
def make_table i = 0 j = 0 table = Array.new(6) table.map!{Array.new(5)} "a".upto("z") do |c| table[i][j] = c j += 1 i += 1 if j == 5 j = 0 if j == 5 end table[5][1] = '.' table[5][2] = '?' table[5][3] = '!' table[5][4] = ' ' table end $table = make_table readlines.each do |in...
[ "identifier.change" ]
37,583
37,584
u881491942
ruby
p00135
n = gets.to_i t = []*n 0.upto(n-1) {|i| t[i] = gets.chomp.split(/:/).map(&:to_i)} 0.upto(n-1) do |i| a,b = t[i] long = b * 6 short = a * 30 + b.to_f / 2 r = (long - short).abs r = 180 - r if r > 180 case r when 0...30 puts "alert" when 30...90 puts "warning" when 90..180 puts "safe" end...
n = gets.to_i t = []*n 0.upto(n-1) {|i| t[i] = gets.chomp.split(/:/).map(&:to_i)} 0.upto(n-1) do |i| a,b = t[i] long = b * 6 short = a * 30 + b.to_f / 2 r = (long - short).abs r = 360 - r if r > 180 case r when 0...30 puts "alert" when 30...90 puts "warning" when 90..180 puts "safe" end...
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
38,074
38,075
u329400409
ruby
p00135
n = gets.chomp.to_i n.times do h, m = gets.chomp.split(':').map(&:to_f) diff = (h * 30 + m * 0.5 - m * 6).abs diff = 360 - diff if diff > 180 puts diff if diff < 30 puts :alert elsif diff < 90 puts :warning else puts :safe end end
n = gets.chomp.to_i n.times do h, m = gets.chomp.split(':').map(&:to_f) diff = (h * 30 + m * 0.5 - m * 6).abs diff = 360 - diff if diff > 180 if diff < 30 puts :alert elsif diff < 90 puts :warning else puts :safe end end
[ "call.remove" ]
38,076
38,077
u024281398
ruby
p00141
puts ("1\n"..gets).map{n=gets.to_i n<2?"#\n":n<3?"# \n"*2:(a=[?#*n+?\n]+(2..n).map{?#+" "*(n-2)+"#\n"} c=i=j=n-1 d=[[1,0],[0,-1],[-1,0],[0,1]] (c=0;(x,y),_=d.rotate!;(c+=1;a[i+=x][j+=y]=?#)while a[i+x*2][j+y*2]<?#)while c>1 a*"")}*?\n
puts ("1\n"..gets).map{n=gets.to_i n<2?"#\n":n<3?"##\n# \n":(a=[?#*n+?\n]+(2..n).map{?#+" "*(n-2)+"#\n"} c=i=j=n-1 d=[[1,0],[0,-1],[-1,0],[0,1]] (c=0;(x,y),_=d.rotate!;(c+=1;a[i+=x][j+=y]=?#)while a[i+x*2][j+y*2]<?#)while c>1 a*"")}*?\n
[ "literal.string.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "expression.operation.binary.remove" ]
38,230
38,231
u198069342
ruby
p00148
while gets tmp = ($_.to_i) % 39 puts "3c%02d" % (tmp == 0 ? 39 : tmp) end
while gets tmp = ($_.to_i) % 39 puts "3C%02d" % (tmp == 0 ? 39 : tmp) end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change", "expression.operation.binary.change" ]
38,593
38,594
u814658648
ruby
p00150
require 'prime' m = 10000 cache = Prime.each(m).each_cons(2).select {|a,b| b-a == 2 }.reverse while (n = gets.to_i)!=0 p1,q1 = cache.bsearch {|_,q| n > q } puts "#{p1} #{q1}" end
require 'prime' m = 10000 cache = Prime.each(m).each_cons(2).select {|a,b| b-a == 2 }.reverse while (n = gets.to_i)!=0 p1,q1 = cache.bsearch {|_,q| n >= q } puts "#{p1} #{q1}" end
[ "expression.operator.compare.change", "assignment.value.change", "expression.operation.binary.change" ]
38,939
38,940
u645368411
ruby
p00150
require 'prime' twin_prime = Prime.each(10000).each_cons(2).select{ |p, q| q - p == 2} loop do n = gets.to_i break if n.zero? ans = twin_prime.select{ |twin| twin.last < n }.last puts ans.join(' ') end
require 'prime' twin_prime = Prime.each(10000).each_cons(2).select{ |p, q| q - p == 2} loop do n = gets.to_i break if n.zero? ans = twin_prime.select{ |twin| twin.last <= n }.last puts ans.join(' ') end
[ "expression.operator.compare.change", "assignment.value.change", "expression.operation.binary.change" ]
38,941
38,942
u881491942
ruby
p00160
criteria = [ [60, 2, 600], [80, 5, 800], [100, 10, 1000], [120, 15, 1200], [140, 20, 1400], [160, 25, 1600] ] while line = gets n = line.chomp.to_i break if n == 0 fee = 0 n.times do x, y, h, w = gets.chomp.split.map(&:to_i) criteria.each do |a| if [x, y, h].max <= a[0] && w <= a[1]...
criteria = [ [60, 2, 600], [80, 5, 800], [100, 10, 1000], [120, 15, 1200], [140, 20, 1400], [160, 25, 1600] ] while line = gets n = line.chomp.to_i break if n == 0 fee = 0 n.times do x, y, h, w = gets.chomp.split.map(&:to_i) criteria.each do |a| if x + y + h <= a[0] && w <= a[1] ...
[ "control_flow.branch.if.condition.change", "call.remove" ]
39,201
39,202
u024281398
ruby
p00168
def rec(n, current) if @dp[current] != -1 return @dp[current] end if current == n 1 elsif current > n 0 else @dp[current] = rec(n, current + 1) + rec(n, current + 2) + rec(n, current + 3) end end def solve(n) @dp = Array.new(34, -1) sum = rec(n, 0) result = ( (sum / 10) + 365 ) / 365...
def rec(n, current) if @dp[current] != -1 return @dp[current] end if current == n 1 elsif current > n 0 else @dp[current] = rec(n, current + 1) + rec(n, current + 2) + rec(n, current + 3) end end def solve(n) @dp = Array.new(34, -1) sum = rec(n, 0) result = ( (sum / 10) + 365 ) / 365...
[ "call.remove", "call.add" ]
39,682
39,683
u164672217
ruby
p00168
$kannondou = [0, 1, 2, 4] $size = $kannondou.size def count(n) while $size < n $kannondou[$size] = $kannondou[$size-1] + $kannondou[$size-2] + $kannondou[$size-3] $size += 1 end $kannondou[n] end while n = gets.to_i break if n.zero? puts count(n) / 3650 + 1 end
$kannondou = [0, 1, 2, 4] $size = $kannondou.size def count(n) while $size <= n $kannondou[$size] = $kannondou[$size-1] + $kannondou[$size-2] + $kannondou[$size-3] $size += 1 end $kannondou[n] end while n = gets.to_i break if n.zero? puts count(n) / 3650 + 1 end
[ "expression.operator.compare.change", "expression.operation.binary.change" ]
39,685
39,686
u881491942
ruby
p00168
Moves = [1,2,3] MaxStep = 30 def solve dp = Array.new(MaxStep + 1, 0) dp[0] = 1 for step in 1...MaxStep Moves.each do |m| break if step - m < 0 dp[step] += dp[step - m] end end dp end result = solve while (n = $stdin.gets.to_i) != 0 printf "%d\n", (result[n].to_f / 3650.to_f).ceil end
Moves = [1,2,3] MaxStep = 30 def solve dp = Array.new(MaxStep + 1, 0) dp[0] = 1 for step in 1..MaxStep Moves.each do |m| break if step - m < 0 dp[step] += dp[step - m] end end dp end result = solve while (n = $stdin.gets.to_i) != 0 printf "%d\n", (result[n].to_f / 3650.to_f).ceil end
[]
39,687
39,688
u985809245
ruby
p00196
loop{ n=gets.to_i; exit if n==0; [*1..n].map{s,*a=gets.split;t=0;a.map{|b|b=b.to_i;t+=b==0 ? 2*n : b==1 ? -1 : 0};[-t,s]}.sort.map{|a|puts a[1]} }
loop{ n=gets.to_i; exit if n==0; [*1..n].map{|i|s,*a=gets.split;t=0;a.map{|b|b=b.to_i;t+=b==0 ? 2*n : b==1 ? -1 : 0};[-t,i,s]}.sort.map{|a|puts a[2]} }
[ "literal.array.change", "literal.number.integer.change", "variable_access.subscript.index.change", "call.arguments.change", "io.output.change" ]
40,917
40,918
u868447400
ruby
p00191
def solve trans,m,n prev = Array.new(n,1.0) (m-1).times do cur = Array.new(n,0) n.times do |i| n.times do |j| cur[i] = [cur[i], prev[j]*trans[j][i]].max end end cur,prev = prev,cur end prev.max end loop do n,m = gets.chomp.split.map{|i|i.to_i} break if n==0 trans = [] ...
def solve trans,m,n prev = Array.new(n,1.0) (m-1).times do cur = Array.new(n,0) n.times do |i| n.times do |j| cur[i] = [cur[i], prev[j]*trans[j][i]].max end end cur,prev = prev,cur end prev.max end loop do n,m = gets.chomp.split.map{|i|i.to_i} break if n==0 trans = [] ...
[ "literal.string.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
41,733
41,734
u553881259
ruby