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
p03048
$R, $G, $B, $N = gets.split.map(&:to_i) count = 0 (0..$N).each do |r| (0..$N).each do |g| b = ($N - $R * r - $G * g).to_f / $B if 0 <= b && b.ceil == b.to_i count += 1 else break end end end puts count
$R, $G, $B, $N = gets.split.map(&:to_i) count = 0 (0..$N).each do |r| (0..$N).each do |g| b = ($N - $R * r - $G * g).to_f / $B if 0 <= b && b.ceil == b.to_i count += 1 elsif b < 0 break end end end puts count
[ "control_flow.branch.if.condition.change" ]
865,092
865,093
u379804877
ruby
p03048
r, g, b, n = gets.chomp.split.map(&:to_i) c = [r, g, b].sort.reverse cnt = 0 for i in 0..(n/c[0]) for j in 0..((n-i*c[0])/c[1]) if ((n-i*c[0])/c[1]) % c[2] == 0 cnt += 1 end end end puts cnt
r, g, b, n = gets.chomp.split.map(&:to_i) c = [r, g, b].sort.reverse cnt = 0 for i in 0..(n/c[0]) for j in 0..((n-i*c[0])/c[1]) if ((n-i*c[0])-j*c[1]) % c[2] == 0 cnt += 1 end end end puts cnt
[ "expression.operator.arithmetic.change", "control_flow.branch.if.condition.change" ]
865,519
865,520
u744908753
ruby
p03049
n = gets.to_i ab_count = 0 la_count = 0 fb_count = 0 lafb_count = 0 n.times do s = gets.chomp (0..s.size-2).each do |i| if s[i..i+1] == 'AB' ab_count += 1 end end if s[-1] == 'A' && s[0] == 'B' lafb_count += 1 else la_count += 1 if s[-1] == 'A' fb_count += 1 if s[0] == 'B' end end ...
n = gets.to_i ab_count = 0 la_count = 0 fb_count = 0 lafb_count = 0 n.times do s = gets.chomp (0..s.size-2).each do |i| if s[i..i+1] == 'AB' ab_count += 1 end end if s[-1] == 'A' && s[0] == 'B' lafb_count += 1 else la_count += 1 if s[-1] == 'A' fb_count += 1 if s[0] == 'B' end end ...
[ "control_flow.branch.if.condition.change" ]
865,801
865,802
u729246375
ruby
p03049
N = gets.to_i x = y = z = t = 0 N.times{ s = gets.chomp case when s.match(/^B.*A$/); z += 1 when s.match(/^B/); x += 1 when s.match(/A$/); y += 1 end t += s.scan("AB").size } p ([x,y].max == 0 ? z - 1 : [x,y].min + z) + t
N = gets.to_i x = y = z = t = 0 N.times{ s = gets.chomp case when s.match(/^B.*A$/); z += 1 when s.match(/^B/); x += 1 when s.match(/A$/); y += 1 end t += s.scan("AB").size } p ([x,y].max == 0 ? [z - 1, 0].max : [x,y].min + z) + t
[ "call.arguments.change", "call.add" ]
865,922
865,923
u670503797
ruby
p03049
n=gets.to_i array=[] n.times{ array.push(gets.chomp.split('')) } ans=0 righta=0 leftb=0 double=0 array.map{|str| str.map.with_index{ |char,index| if str[index+1] && str[index]=="A" && str[index+1]=="B" ans+=1 end } if str[0]=="B" leftb+=1 end if str[-...
n=gets.to_i array=[] n.times{ array.push(gets.chomp.split('')) } ans=0 righta=0 leftb=0 double=0 array.map{|str| str.map.with_index{ |char,index| if str[index+1] && str[index]=="A" && str[index+1]=="B" ans+=1 end } if str[0]=="B" leftb+=1 end if str[-...
[ "control_flow.branch.if.condition.change" ]
866,062
866,063
u506544056
ruby
p03049
n = gets.to_i s = Array.new(n) { gets.chomp } min, max = [s.count { |e| e[-1] == 'A' && e[0] != 'B' }, s.count { |e| e[-1] != 'A' && e[0] == 'B' }].minmax both = s.count { |e| e[-1] == 'A' && e[0] == 'B' } count = max == 0 ? both - 1 : min + both s.each do |e| idx = -2 count += 1 while (idx = e.index('AB', idx + ...
n = gets.to_i s = Array.new(n) { gets.chomp } min, max = [s.count { |e| e[-1] == 'A' && e[0] != 'B' }, s.count { |e| e[-1] != 'A' && e[0] == 'B' }].minmax both = s.count { |e| e[-1] == 'A' && e[0] == 'B' } count = max == 0 ? [both - 1, 0].max : min + both s.each do |e| idx = -2 count += 1 while (idx = e.index('AB...
[ "call.add" ]
866,267
866,268
u104886851
ruby
p03049
n = gets.chomp.to_i b_a = 0 b_x = 0 x_a = 0 default = 0 n.times do |i| str = gets.chomp if (str[0] == 'B' && str[-1] == 'A') b_a += 1 elsif(str[0] == 'B') b_x += 1 elsif(str[-1] == 'A') x_a += 1 end default += str.scan('AB').length end if (b_a == 0) puts [b_x,x_a].min + default else if ((b_...
n = gets.chomp.to_i b_a = 0 b_x = 0 x_a = 0 default = 0 n.times do |i| str = gets.chomp if (str[0] == 'B' && str[-1] == 'A') b_a += 1 elsif(str[0] == 'B') b_x += 1 elsif(str[-1] == 'A') x_a += 1 end default += str.scan('AB').length end if (b_a == 0) puts [b_x,x_a].min + default else if ((b_...
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
866,340
866,341
u546441021
ruby
p03049
n = gets.to_i strings = [] n.times do strings.push(gets.chomp.to_s) end ab_count = 0 first_b_count = 0 last_a_count = 0 double_count = 0 strings.each do |string| ab_count += string.scan("AB").length if string[0] == "B" first_b_count += 1 end if string[string.length - 1] == "A" last_a_count += 1 e...
n = gets.to_i strings = [] n.times do strings.push(gets.chomp.to_s) end ab_count = 0 first_b_count = 0 last_a_count = 0 double_count = 0 strings.each do |string| ab_count += string.scan("AB").length if string[0] == "B" first_b_count += 1 end if string[string.length - 1] == "A" last_a_count += 1 e...
[ "control_flow.branch.if.condition.change" ]
866,520
866,521
u653737129
ruby
p03049
N = gets.to_i a = 0 b = 0 ba = 0 ans = 0 N.times { str = gets.chop ans += str.scan(/AB/).count a += 1 if str[-1] == "A" b += 1 if str[0] == "B" ba += 1 if str[0] == "B" and str[-1] == "A" } if a == ba and b == ba a -= 1 b -= 1 end ans += a > b ? b : a puts ans
N = gets.to_i a = 0 b = 0 ba = 0 ans = 0 N.times { str = gets.chop ans += str.scan(/AB/).count a += 1 if str[-1] == "A" b += 1 if str[0] == "B" ba += 1 if str[0] == "B" and str[-1] == "A" } if ba > 0 if a == ba and b == ba a -= 1 b -= 1 end end ans += a > b ? b : a puts ans
[]
866,547
866,548
u584272055
ruby
p03049
n=gets.to_i ss=$<.map &:chomp a=b=ab=c=0 ss.map{|s| c+=s.scan('AB').size if s[0]=='B'&&s[-1]=='A' ab+=1 elsif s[0]=='B' b+=1 elsif s[-1]=='A' a+=1 end } if a==0&&b==0 p c+ab-1 elsif a==0||b==0 p c+ab else p c+[b,a].min+ab end
n=gets.to_i ss=$<.map &:chomp a=b=ab=c=0 ss.map{|s| c+=s.scan('AB').size if s[0]=='B'&&s[-1]=='A' ab+=1 elsif s[0]=='B' b+=1 elsif s[-1]=='A' a+=1 end } if a==0&&b==0 p c+[ab-1,0].max elsif a==0||b==0 p c+ab else p c+[b,a].min+ab end
[ "call.arguments.change", "call.add" ]
866,705
866,706
u019489252
ruby
p03049
N = gets.to_i Ss = [] a = 0 b = 0 ba = 0 sum = 0 N.times do s = gets.chomp sum += s.scan('AB').length if s[0] == "B" && s[s.length-1] == "A" ba += 1 elsif s[0] == "B" b += 1 elsif s[s.length-1] == "A" a += 1 end end pair = [a, b].min sum += pair if !(a == 0 && b == 0) sum += ba els...
N = gets.to_i Ss = [] a = 0 b = 0 ba = 0 sum = 0 N.times do s = gets.chomp sum += s.scan('AB').length if s[0] == "B" && s[s.length-1] == "A" ba += 1 elsif s[0] == "B" b += 1 elsif s[s.length-1] == "A" a += 1 end end pair = [a, b].min sum += pair if !(a == 0 && b == 0) sum += ba els...
[]
866,784
866,785
u786261754
ruby
p03049
def get_i gets.to_i end def get_ia(delimiter = ' ') gets.split(delimiter).map(&:to_i) end n = get_i c = 0 bb = 0 ea = 0 bo = 0 for i in 1..n t = gets.chomp.gsub("AB", "-") c += t.count("-") b = 0 if t[0] == "B" bb += 1 b += 1 end ...
def get_i gets.to_i end def get_ia(delimiter = ' ') gets.split(delimiter).map(&:to_i) end n = get_i c = 0 bb = 0 ea = 0 bo = 0 for i in 1..n t = gets.chomp.gsub("AB", "-") c += t.count("-") b = 0 if t[0] == "B" bb += 1 b += 1 end ...
[ "call.add" ]
866,991
866,992
u568319388
ruby
p03050
#input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def get_nsp() retu...
#input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def get_nsp() retu...
[ "expression.operation.binary.add" ]
867,045
867,046
u415400221
ruby
p03050
require 'pp' N = readline.to_i imax = Math.sqrt(N).to_i div = [] (1..imax).each do |i| if N % i == 0 k = i m = N/i-1 div << m if m > k end end puts div.inject(:+)
require 'pp' N = readline.to_i imax = Math.sqrt(N).to_i div = [] (1..imax).each do |i| if N % i == 0 k = i m = N/i-1 div << m if m > k end end puts div.inject(:+).to_i
[ "call.add" ]
867,392
867,393
u842192201
ruby
p03050
n = gets.chomp.to_i count = 0 1.upto((n ** 0.5).ceil) do |i| m = n / i - 1 count += m if n / m == n % m end puts count
n = gets.chomp.to_i count = 0 1.upto((n ** 0.5).ceil) do |i| m = n / i - 1 count += m if m != 0 && n / m == n % m end puts count
[ "control_flow.branch.if.condition.change" ]
867,665
867,664
u960706641
ruby
p03050
n = gets.chomp.to_i sum = 0 1.upto(Math.sqrt(n+1).ceil) do |p| if (n - p) % p == 0 m = (n - p) / p sum += m if n / m == n % m end end puts sum
n = gets.chomp.to_i sum = 0 1.upto(Math.sqrt(n+1).ceil) do |p| if (n - p) % p == 0 m = (n - p) / p sum += m if m > 0 && n / m == n % m end end puts sum
[ "control_flow.branch.if.condition.change" ]
867,835
867,836
u434509016
ruby
p03049
N = gets.chomp.to_i s = [] ab = 0 a = 0 b = 0 ba = 0 i = 0 while i < N s = gets.chomp if s[0] == "B" if s[s.size-1] == "A" ba += 1 else b += 1 end elsif s[s.size-1] == "A" a += 1 end for x in 0...s.size-1 if s[x] == "A" if s[x+1] == "B" ab += 1 end end ...
N = gets.chomp.to_i s = [] ab = 0 a = 0 b = 0 ba = 0 i = 0 while i < N s = gets.chomp if s[0] == "B" if s[s.size-1] == "A" ba += 1 else b += 1 end elsif s[s.size-1] == "A" a += 1 end for x in 0...s.size-1 if s[x] == "A" if s[x+1] == "B" ab += 1 end end ...
[ "control_flow.branch.if.condition.change" ]
868,270
868,271
u349832549
ruby
p03053
h, w = gets.to_s.split.map{|t| t.to_i } # p ".#".bytes #=> [46, 35] blacks = [] a = Array.new(h) do |i| s = gets.to_s.chomp.bytes s.each_with_index do |c, j| blacks << [i, j] if c == 35 end s end dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]] ans = -1 while blacks.any? ns = [] ans += 1 blacks.each...
# 0:17- h, w = gets.to_s.split.map{|t| t.to_i } # p ".#".bytes #=> [46, 35] blacks = [] a = Array.new(h) do |i| s = gets.to_s.chomp.bytes s.each_with_index do |c, j| blacks << [i, j] if c == 35 end s end dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]] ans = -1 while blacks.any? ns = [] ans += 1 bla...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
868,336
868,337
u693378622
ruby
p03053
h, w = gets.to_s.split.map{|t| t.to_i } # p ".#".bytes #=> [46, 35] blacks = [] a = Array.new(h) do |i| s = gets.to_s.chomp.bytes s.each_with_index do |c, j| blacks << [i, j] if c == 35 end s end dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]] ans = -1 while blacks.any? ns = [] ans += 1 blacks.each...
# 0:17- h, w = gets.to_s.split.map{|t| t.to_i } # p ".#".bytes #=> [46, 35] blacks = [] a = Array.new(h) do |i| s = gets.to_s.chomp.bytes s.each_with_index do |c, j| blacks << [i, j] if c == 35 end s end dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]] ans = -1 while blacks.any? ns = [] ans += 1 bla...
[ "assignment.add" ]
868,336
868,338
u693378622
ruby
p03053
#n = gets.chomp.to_i h,w = gets.chomp.split().map(&:to_i) sharp = 0 grid = Array.new(h){Array.new(w, -1)} q = [] h.times do |i| line = gets.chomp.split(//) w.times do |j| if line[j] == '#' grid[i][j] = 0 q.push [i,j, 0] sharp += 1 end end end #p grid cost = 0 num = 0 until sharp == h*w...
#n = gets.chomp.to_i h,w = gets.chomp.split().map(&:to_i) sharp = 0 grid = Array.new(h){Array.new(w, -1)} q = [] h.times do |i| line = gets.chomp w.times do |j| if line[j] == '#' grid[i][j] = 0 q.push [i,j, 0] sharp += 1 end end end #p grid cost = 0 num = 0 until sharp == h*w y,x = q...
[ "call.remove" ]
868,854
868,855
u524019694
ruby
p03053
io = STDIN h,w = io.gets.split.map(&:to_i) matrix = Array.new(h) do Array.new(w,0) end blacks = [] h.times do |i| io.gets.chomp.each_char.with_index do |c,j| next if c == '.' matrix[i][j] = 1 blacks << [i, j] end end def create_blacks(row, col, matrix, blacks) if row > 0 && matrix[row-1][col] == ...
io = STDIN h,w = io.gets.split.map(&:to_i) matrix = Array.new(h) do Array.new(w,0) end blacks = [] h.times do |i| io.gets.chomp.each_char.with_index do |c,j| next if c == '.' matrix[i][j] = 1 blacks << [i, j] end end def create_blacks(row, col, matrix, blacks) if row > 0 && matrix[row-1][col] == ...
[ "call.remove" ]
869,331
869,332
u556849512
ruby
p03054
H,W,N = gets.split.map(&:to_i) sr,sc = gets.split.map(&:to_i) l,r,u,d = sc,sc,sr,sr S = gets.chomp T = gets.chomp N.times do |i| c = S[i] if c == "L" l -= 1 elsif c == "R" r += 1 elsif c == "U" u -= 1 elsif c == "D" d += 1 end if l < 1 || r > W || u < 1 || d > H puts "NO" #p [l,r...
H,W,N = gets.split.map(&:to_i) sr,sc = gets.split.map(&:to_i) l,r,u,d = sc,sc,sr,sr S = gets.chomp T = gets.chomp N.times do |i| c = S[i] if c == "L" l -= 1 elsif c == "R" r += 1 elsif c == "U" u -= 1 elsif c == "D" d += 1 end if l < 1 || r > W || u < 1 || d > H puts "NO" #p [l,r...
[ "expression.operator.change" ]
870,448
870,449
u123276241
ruby
p03059
a,b,c=get.split.map(&:to_i) p (c/a)*b
a,b,t=gets.split.map(&:to_i) p (t/a)*b
[ "assignment.variable.change", "identifier.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change" ]
871,113
871,114
u315597999
ruby
p03059
a = gets.split.map(&:to_i) #入力が2つ以上の時 puts (a[2] + 0.5 ) / a[0] * a[1]
a = gets.split.map(&:to_i) #入力が2つ以上の時 puts (a[2] + 0.5 ).floor / a[0] * a[1]
[ "call.add" ]
871,534
871,535
u889261386
ruby
p03059
def biscuit_generator(a, b, t) (t / a) * b end a, b, t = gets.split.map(:to_i) puts biscuit_generator(a, b, t)
def biscuit_generator(a, b, t) (t / a) * b end a, b, t = gets.split.map(&:to_i) print biscuit_generator(a, b, t)
[ "call.arguments.change", "identifier.change" ]
871,787
871,788
u976045502
ruby
p03059
input = gets.chomp.split(" ").map(&:to_i); a = input[0] b = input[1] t = input[2] sum = (t % a) * b print sum
input = gets.chomp.split(" ").map(&:to_i); a = input[0] b = input[1] t = input[2] sum = (t / a) * b print sum.floor
[ "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "call.add" ]
871,867
871,868
u208303341
ruby
p03060
N = gets.to_i V,C = 2.times.map {gets.split.map(&:to_i)} p (0...n).map{|i|[V[i]-C[i],0].max}.inject :+
N = gets.to_i V,C = 2.times.map {gets.split.map(&:to_i)} p (0...N).map{|i|[V[i]-C[i],0].max}.inject :+
[ "call.arguments.change" ]
872,555
872,556
u562082015
ruby
p03060
a=gets.chomp.to_i b=gets.split.map(&:to_i) c=gets.split.map(&:to_i) sum=0 for i in 0..a-1 sum+=b[i]-c[0] if b[i]-c[0] > 0 end puts sum
a=gets.chomp.to_i b=gets.split.map(&:to_i) c=gets.split.map(&:to_i) sum=0 for i in 0..a-1 sum+=b[i]-c[i] if b[i]-c[i] > 0 end puts sum
[ "identifier.replace.add", "literal.replace.remove", "variable_access.subscript.index.change", "expression.operation.binary.change", "control_flow.branch.if.condition.change" ]
872,653
872,654
u585819925
ruby
p03060
N = gets.strip.to_i vs = gets.strip.split.map(&:to_i) cs = gets.strip.split.map(&:to_i) puts N.times.map{|i| vs[i] - cs[i] }.select{|i| i > 0 }.inject(&:+)
N = gets.strip.to_i vs = gets.strip.split.map(&:to_i) cs = gets.strip.split.map(&:to_i) puts ([0] + N.times.map{|i| vs[i] - cs[i] }.select{|i| i > 0 }).inject(&:+)
[ "call.arguments.change" ]
872,801
872,802
u469738426
ruby
p03060
n=gets.chomp.to_i v=gets.chomp.split.map(&:to_i) c=gets.chomp.split.map(&:to_i) s=0 n.times do |i| s+=v[i] if v[i] >= c[i] end puts s
n=gets.chomp.to_i v=gets.chomp.split.map(&:to_i) c=gets.chomp.split.map(&:to_i) s=0 n.times do |i| s+=v[i]-c[i] if v[i] >= c[i] end puts s
[ "expression.operation.binary.add" ]
872,897
872,898
u854471099
ruby
p03060
_=gets.split.map(&:to_i) a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) p a.zip(b).map{|x,y|x-y}.select{|x|x>0}.reduce(:+)
_=gets.split.map(&:to_i) a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) p a.zip(b).map{|x,y|x-y}.select{|x|x>0}.reduce(0,:+)
[ "call.arguments.add" ]
872,918
872,919
u702482655
ruby
p03060
N = gets.to_i V = gets.split(' ').map(&:to_i) C = gets.split(' ').map(&:to_i) puts V.zip(C).map { |a,b| a-b }.select { |n| n > 0 }.reduce(:+)
gets.to_i V = gets.split(' ').map(&:to_i) C = gets.split(' ').map(&:to_i) puts V.zip(C).map { |a,b| a-b }.select { |n| n > 0 }.reduce(:+) || 0
[ "assignment.remove", "expression.operation.binary.add" ]
872,951
872,952
u765478029
ruby
p03060
_ = STDIN.gets.split.map(&:to_i) v = STDIN.gets.split.map(&:to_i) c = STDIN.gets.split.map(&:to_i) vc = v.map.with_index {|v1, i| v1 - c[i] } puts vc.select {|i| i > 0 }.inject(:+)
_ = STDIN.gets.split.map(&:to_i) v = STDIN.gets.split.map(&:to_i) c = STDIN.gets.split.map(&:to_i) vc = v.map.with_index {|v1, i| v1 - c[i] } puts vc.select {|i| i > 0 }.inject(:+) || 0
[ "expression.operation.binary.add" ]
873,048
873,049
u039293076
ruby
p03061
gets.to_i A = gets.chomp.split(" ").map(&:to_i) r = Array.new(N, 0) r[N - 1] = A[-1] (N - 2).downto(1){|i| r[i] = A[i].gcd(r[i + 1]) } ans = Array.new(N, 0) ans[0] = r[1] wk = A[0] 1.upto(N - 2){|i| ans[i] = wk.gcd(r[i+1]) wk = wk.gcd(A[i]) } ans[N - 1] = wk puts ans.max
N = gets.to_i A = gets.chomp.split(" ").map(&:to_i) r = Array.new(N, 0) r[N - 1] = A[-1] (N - 2).downto(1){|i| r[i] = A[i].gcd(r[i + 1]) } ans = Array.new(N, 0) ans[0] = r[1] wk = A[0] 1.upto(N - 2){|i| ans[i] = wk.gcd(r[i+1]) wk = wk.gcd(A[i]) } ans[N - 1] = wk puts ans.max
[ "assignment.add" ]
873,831
873,832
u276517671
ruby
p03061
class SegmentTree # n is the size of array or array itself def initialize(n, unity, &func) raise ArgumentError if !n || !unity || !block_given? @size_r = 1 @n = (n.is_a?(Array) ? n.size : n) while @size_r < @n @size_r <<= 2 end @func = func @unity = unity @data = Array.new(@siz...
# source: http://drken1215.hatenablog.com/entry/2019/04/27/224100_1 # verify: https://atcoder.jp/contests/abc125/tasks/abc125_c class SegmentTree # n is the size of array or array itself def initialize(n, unity, &func) raise ArgumentError if !n || !unity || !block_given? @size_r = 1 @n = (n.is_a?(Array)...
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
874,078
874,079
u706695185
ruby
p03061
n = gets.to_i a = gets.split.map(&:to_i) x = Array.new n y = Array.new n x[0] = a[0] y[-1] = a[-1] (1..n-1).each{|i| x[i] = a[i].gcd x[i-1]} (0..n-2).reverse_each{|i|y[i] = a[i].gcd y[i+1]} ret = (1..n-2).map{|i|x[i-1].gcd y[i+1]}.max p [ret,x[n-2],y[1]].max
n = gets.to_i a = gets.split.map(&:to_i) x = Array.new n y = Array.new n x[0] = a[0] y[-1] = a[-1] (1..n-1).each{|i| x[i] = a[i].gcd x[i-1]} (0..n-2).reverse_each{|i|y[i] = a[i].gcd y[i+1]} ret = (1..n-2).map{|i|x[i-1].gcd y[i+1]}.max p [ret,x[n-2],y[1]].compact.max
[ "call.add" ]
874,122
874,123
u752146271
ruby
p03061
def gcd(a,b); a==0 ? a : gcd(b, a % b); end N = gets.strip.to_i as = gets.strip.split.map(&:to_i) from_left = [as[0]] from_right = [as[-1]] (N - 1).times do |i| from_left[i+1] = gcd(from_left[i], as[i+1]) from_right[i+1] = gcd(from_right[i], as[-2-i]) end max = [from_right[N-2], from_left[N-2]].max 1.upto(N-2) ...
def gcd(a,b); b==0 ? a : gcd(b, a % b); end N = gets.strip.to_i as = gets.strip.split.map(&:to_i) from_left = [as[0]] from_right = [as[-1]] (N - 1).times do |i| from_left[i+1] = gcd(from_left[i], as[i+1]) from_right[i+1] = gcd(from_right[i], as[-2-i]) end max = [from_right[N-2], from_left[N-2]].max 1.upto(N-2) ...
[ "identifier.change", "control_flow.branch.if.condition.change" ]
874,604
874,605
u843036991
ruby
p03061
inputs = Array.new while line = $stdin.gets inputs << line.chomp end N = inputs[0] As = inputs[1].split(" ").map(&:to_i) def getGCDAll(as, excludeIndex: -1) gcd = nil as.each.with_index do |a, index| next if index == excludeIndex if !gcd gcd = a next end gcd = gcd.gcd(a) return 1...
inputs = Array.new while line = $stdin.gets inputs << line.chomp end N = inputs[0] As = inputs[1].split(" ").map(&:to_i) def getGCDAll(as, excludeIndex: -1) gcd = nil as.each.with_index do |a, index| next if index == excludeIndex if !gcd gcd = a next end gcd = gcd.gcd(a) return 1...
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
874,609
874,610
u736893066
ruby
p03061
n = gets.to_i numbers = gets.split(" ").map(&:to_i) def gcd(n, m) n, m = m, n if m > n #p [n, m] loop { r = n % m break if r == 0 n, m = m, r } m end gcd_from_left = [] gcd_from_right = [] gcd_from_left.push(numbers.first) numbers[1..numbers.length - 1].each do |number| gcd_from_left.push(...
n = gets.to_i numbers = gets.split(" ").map(&:to_i) def gcd(n, m) n, m = m, n if m > n #p [n, m] loop { r = n % m break if r == 0 n, m = m, r } m end gcd_from_left = [] gcd_from_right = [] gcd_from_left.push(numbers.first) numbers[1..numbers.length - 1].each do |number| gcd_from_left.push(...
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.unary.add", "expression.operation.unary.remove" ]
874,917
874,918
u653737129
ruby
p03061
n = gets.to_i numbers = gets.split(" ").map(&:to_i) def gcd(n, m) n, m = m, n if m > n #p [n, m] loop { r = n % m break if r == 0 n, m = m, r } m end gcd_from_left = [] gcd_from_right = [] gcd_from_left.push(numbers.first) numbers[1..numbers.length].each do |number| gcd_from_left.push(gcd(...
n = gets.to_i numbers = gets.split(" ").map(&:to_i) def gcd(n, m) n, m = m, n if m > n #p [n, m] loop { r = n % m break if r == 0 n, m = m, r } m end gcd_from_left = [] gcd_from_right = [] gcd_from_left.push(numbers.first) numbers[1..numbers.length - 1].each do |number| gcd_from_left.push(...
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.unary.add", "expression.operation.unary.remove" ]
874,919
874,918
u653737129
ruby
p03061
n = gets.to_i a = gets.split.map(&:to_i) l = Array.new(n) r = Array.new(n) l[0] = a[0] for i in 1..n-1 l[i] = l[i-1].gcd(a[i]) end r[-1] = a[-1] (n-2).downto(0) do |i| r[i] = r[i+1].gcd(a[i]) end ans = r[1] for i in 1..n-2 m = l[i-1].gcd(r[i+1]) ans = m if m > ans end ans = l[-1] if ans < l[-2] puts ans
n = gets.to_i a = gets.split.map(&:to_i) l = Array.new(n) r = Array.new(n) l[0] = a[0] for i in 1..n-1 l[i] = l[i-1].gcd(a[i]) end r[-1] = a[-1] (n-2).downto(0) do |i| r[i] = r[i+1].gcd(a[i]) end ans = r[1] for i in 1..n-2 m = l[i-1].gcd(r[i+1]) ans = m if m > ans end ans = l[-2] if ans < l[-2] puts ans
[ "literal.number.integer.change", "assignment.value.change", "variable_access.subscript.index.change" ]
875,208
875,209
u506255180
ruby
p03062
N=gets.to_i array=gets.chomp.split(" ").map(&:to_i).sort_by{|a| a.abs } minus_count = 0 ret = 0 array.each do |a| minus_count+=1 if a < 0 ret+=a.abs end ret-=(array[0]*2) if minus_count.odd? puts ret
N=gets.to_i array=gets.chomp.split(" ").map(&:to_i).sort_by{|a| a.abs } minus_count = 0 ret = 0 array.each do |a| minus_count+=1 if a < 0 ret+=a.abs end ret-=(array[0].abs*2) if minus_count.odd? puts ret
[ "call.add" ]
875,368
875,369
u058568575
ruby
p03062
eval'A=#'+`tr ' ' ,` p -A.count{_1<0}%2*2*A.map!(&:abs).min+A.sum
eval'A=#'+`tr ' ' ,` p A.count{_1<0}%2*-2*A.map!(&:abs).min+A.sum
[ "expression.operation.unary.arithmetic.remove", "call.arguments.change", "expression.operation.unary.add" ]
875,401
875,402
u657913472
ruby
p03062
eval'A=#'+`tr ' ' ,` p -A.count{_1<0}%2*2*A.map!(&:abs).min+A.sum
eval'A=#'+`tr ' ' ,` p 0-A.count{_1<0}%2*2*A.map!(&:abs).min+A.sum
[ "call.arguments.change" ]
875,401
875,403
u657913472
ruby
p03062
require 'pp' n = gets.to_i a_n = gets.chomp!.split(" ").map(&:to_i).sort x = a_n.group_by {|x| x >= 0 } if x[false].length % 2 == 0 puts a_n.inject(0) {|sum, n| sum += n.abs } else s = a_n.inject(0) {|sum, n| sum += n.abs } min = 10 ** 10 a_n.each do |a| if a.abs < min min = a.abs ...
require 'pp' n = gets.to_i a_n = gets.chomp!.split(" ").map(&:to_i).sort x = a_n.group_by {|x| x >= 0 } if (x[false] || []).length % 2 == 0 puts a_n.inject(0) {|sum, n| sum += n.abs } else s = a_n.inject(0) {|sum, n| sum += n.abs } min = 10 ** 10 a_n.each do |a| if a.abs < min min ...
[ "control_flow.branch.if.condition.change" ]
875,712
875,713
u754375546
ruby
p03062
m = gets.chomp.to_i a = [] a = gets.split.map(&:to_i) t = 0 u = 0 v = 0 for i in 0..a.length-1 if a[i] > 0 t += 1 elsif a[i] < 0 u += 1 else v = 1 end end #p t #p u #p v n = 0 x = 10**9 for i in 0..a.length-1 n += a[i].abs if x >=a[i].abs x = a[i].abs end #p x end #p n #p x if (t + u)%2 ==...
m = gets.chomp.to_i a = [] a = gets.split.map(&:to_i) t = 0 u = 0 v = 0 for i in 0..a.length-1 if a[i] > 0 t += 1 elsif a[i] < 0 u += 1 else v = 1 end end #p t #p u #p v n = 0 x = 10**9 for i in 0..a.length-1 n += a[i].abs if x >=a[i].abs x = a[i].abs end #p x end #p n #p x if (u)%2 == 0 ...
[ "expression.operation.binary.remove" ]
876,184
876,185
u675531271
ruby
p03062
_=gets.split.map(&:to_i) a=gets.split.map(&:to_i) min=a.min_by{|x|x.abs} d=a.select{|x|x<0}.size if(d%2==0) p a.map{|x|x.abs}.reduce(:+) else p a.map{|x|x.abs}.reduce(:+) - 2*min end
_=gets.split.map(&:to_i) a=gets.split.map(&:to_i) min=a.min_by{|x|x.abs} d=a.select{|x|x<0}.size if(d%2==0) p a.map{|x|x.abs}.reduce(0,:+) else p a.map{|x|x.abs}.reduce(0,:+) - 2*min.abs end
[ "call.arguments.add", "call.add" ]
876,188
876,189
u702482655
ruby
p03062
N = gets.to_i A = gets.split.map(&:to_i) INF = 10**9 dp0 = [-INF] * (N+1) dp1 = [-INF] * (N+1) dp0[0] = 0 N.times do |i| dp0[i+1] = [dp0[i+1], dp0[i] + A[i]].max dp0[i+1] = [dp0[i+1], dp1[i] - A[i]].max if i<N-1 dp1[i+1] = [dp0[i+1], dp0[i] - A[i]].max dp1[i+1] = [dp1[i+1], dp1[i] + A[i]].max end end ...
N = gets.to_i A = gets.split.map(&:to_i) INF = 10**9 dp0 = [-INF] * (N+1) dp1 = [-INF] * (N+1) dp0[0] = 0 N.times do |i| dp0[i+1] = [dp0[i+1], dp0[i] + A[i]].max dp0[i+1] = [dp0[i+1], dp1[i] - A[i]].max if i<N-1 dp1[i+1] = [dp1[i+1], dp0[i] - A[i]].max dp1[i+1] = [dp1[i+1], dp1[i] + A[i]].max end end ...
[ "assignment.value.change", "identifier.change" ]
876,242
876,243
u006493569
ruby
p03062
n = gets.to_i a = gets.split.map(&:to_i) min = 1000000001 count = 0 a.each do |i| count += 1 if i < 0 min = i.abs if i.abs < min end abs_a = a.map(&:abs) sum = 0 abs_a.each do |i| sum += i end sum -= min if count%2 == 1 puts sum
n = gets.to_i a = gets.split.map(&:to_i) min = 1000000001 count = 0 a.each do |i| count += 1 if i < 0 min = i.abs if i.abs < min end abs_a = a.map(&:abs) sum = 0 abs_a.each do |i| sum += i end sum -= min*2 if count%2 == 1 puts sum
[]
876,285
876,286
u452808393
ruby
p03062
require 'pp' N = readline.to_i A = readline.chomp.split.map(&:to_i) sign = 0 A.each do |i| sign += 1 if i < 0 end if sign % 2 == 0 puts A.map {|a| a.abs }.inject(:+) else m = A.min_by {|a| a.abs} puts( A.map {|a| a.abs }.inject(:+) - 2*m ) end
require 'pp' N = readline.to_i A = readline.chomp.split.map(&:to_i) sign = 0 A.each do |i| sign += 1 if i < 0 end if sign % 2 == 0 puts A.map {|a| a.abs }.inject(:+) else m = A.min_by {|a| a.abs} puts( A.map {|a| a.abs }.inject(:+) - 2*m.abs ) end
[ "call.add" ]
876,439
876,440
u842192201
ruby
p03062
n = gets.to_i nums = gets.chomp.split.map(&:to_i) elLtZero = 0 elLtOne = 0 ans = 0 nums.each do |e| elLtZero += 1 if e<0 elLtOne += 1 if e<1 ans += e.abs end if (elLtOne%2===0 || elLtZero%2===0) then puts ans else idx = nums.index{|e| e<0} puts ans - 2 * nums[idx..-1].map{|e| e.abs}.min end...
n = gets.to_i nums = gets.chomp.split.map(&:to_i) elLtZero = 0 elLtOne = 0 ans = 0 nums.each do |e| elLtZero += 1 if e<0 elLtOne += 1 if e<1 ans += e.abs end if (elLtOne%2===0 || elLtZero%2===0) then puts ans else idx = nums.index{|e| e<0} puts ans - 2 * nums.map{|e| e.abs}.min end
[]
876,473
876,474
u626113839
ruby
p03062
n = gets.to_i arr = gets.split(" ").map(&:to_i) arrab = Array.new pm = 1 for i in 0..n-1 do arrab[i] = arr[i].abs end sumabs = arrab.inject(:+) if arr.include?(0) puts sumabs exit end for i in 0..n-1 do if arrab[i] != arr[i] pm = pm * -1 end end if pm == 1 puts sumabs else puts su...
n = gets.to_i arr = gets.split(" ").map(&:to_i) arrab = Array.new pm = 1 for i in 0..n-1 do arrab[i] = arr[i].abs end sumabs = arrab.inject(:+) if arr.include?(0) puts sumabs exit end for i in 0..n-1 do if arrab[i] != arr[i] pm = pm * -1 end end if pm == 1 puts sumabs else puts su...
[ "call.arguments.change" ]
876,485
876,486
u094826590
ruby
p03061
n = gets.to_i a = gets.split.map(&:to_i) a.sort! gcds = [a[0]] t = a[0] (n-1).times do |i| t = t.gcd(a[i+1]) gcds << t end ans = [] t = a[-1] (n-2).downto(1) do |i| ans << t.gcd(gcds[i-1]) t = t.gcd(a[i]) end ans << t p ans.max
n = gets.to_i a = gets.split.map(&:to_i) a.sort! gcds = [a[0]] t = a[0] (n-1).times do |i| t = t.gcd(a[i+1]) gcds << t end ans = [gcds[-2]] t = a[-1] (n-2).downto(1) do |i| ans << t.gcd(gcds[i-1]) t = t.gcd(a[i]) end ans << t p ans.max
[]
877,147
877,148
u123276241
ruby
p03061
require 'prime' N = gets.to_i A = gets.split.map(&:to_i) def gcd(a, b) if a > b return a if b == 0 gcd(b, a % b) else return b if a == 0 gcd(a, b % a) end end # A0, A1,...Ai L = Array.new(N+1) {0} # Ai,...An R = Array.new(N+1) {0} L[0] = 0 for i in (1..N) L[i] = gcd(L[i-1], A[i-1]) end # ...
require 'prime' N = gets.to_i A = gets.split.map(&:to_i) def gcd(a, b) if a > b return a if b == 0 gcd(b, a % b) else return b if a == 0 gcd(a, b % a) end end # A0, A1,...Ai L = Array.new(N+1) {0} # Ai,...An R = Array.new(N+1) {0} L[0] = 0 for i in (1..N) L[i] = gcd(L[i-1], A[i-1]) end # ...
[ "expression.operation.binary.add" ]
877,196
877,197
u237620737
ruby
p03061
n = gets.to_i as = gets.chomp.split.map(&:to_i) gcd_f = [as[0]] gcd_b = [as[-1]] max = 0 (1..n-1).each do |i| gcd_f.push(as[i].gcd(gcd_f[-1])) gcd_b.push(as[n-1-i].gcd(gcd_b[0])) end (0..n-3).each do |i| max = [max,gcd_f[i].gcd(gcd_b[n-3-i])].max end max = [max,gcd_f[n-2],gcd_b[n-2]].max puts max
n = gets.to_i as = gets.chomp.split.map(&:to_i) gcd_f = [as[0]] gcd_b = [as[-1]] max = 0 (1..n-1).each do |i| gcd_f.push(as[i].gcd(gcd_f[-1])) gcd_b.push(as[n-1-i].gcd(gcd_b[-1])) end (0..n-3).each do |i| max = [max,gcd_f[i].gcd(gcd_b[n-3-i])].max end max = [max,gcd_f[n-2],gcd_b[n-2]].max puts max
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.unary.add" ]
877,255
877,256
u191196346
ruby
p03067
A, B, C = gets.split.map(&:to_i) s, e = [A, B].sort if (s..e).cover?(C) puts 'No' else puts 'Yes' end
A, B, C = gets.split.map(&:to_i) s, e = [A, B].sort if (s..e).cover?(C) puts 'Yes' else puts 'No' end
[ "call.remove", "call.add" ]
877,835
877,836
u740836226
ruby
p03067
a,b,c = gets.split.map { |n|n.to_i } if a<c and c<b puts 'Yes' elsif b<c and c<b puts 'Yes' else puts 'No' end
a,b,c = gets.split.map { |n|n.to_i } if a<c and c<b puts 'Yes' elsif b<c and c<a puts 'Yes' else puts 'No' end
[ "identifier.change", "control_flow.branch.if.condition.change" ]
877,867
877,868
u406593336
ruby
p03067
line = gets A, B ,C = line.split.map(&:to_i) if A < C if B < C puts 'No' else puts'Yes' end else if B < C puts 'No' else puts'Yes' end end
line = gets A, B ,C = line.split.map(&:to_i) if A < C if B < C puts 'No' else puts'Yes' end else if B < C puts 'Yes' else puts'No' end end
[ "call.remove", "call.add" ]
877,958
877,959
u940766008
ruby
p03067
line = gets A, B ,C = line.split.map(&:to_i) if A < B if B < C puts 'Yes' else puts'No' end else if B < C puts 'Yes' else puts'No' end end
line = gets A, B ,C = line.split.map(&:to_i) if A < C if B < C puts 'No' else puts'Yes' end else if B < C puts 'Yes' else puts'No' end end
[ "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change" ]
877,960
877,959
u940766008
ruby
p03067
a,b,c = gets.split.map(&:to_i) if a < b n = (a..b) else n = (b..a) end p n if n.include?(c) puts "Yes" else puts "No" end
a,b,c = gets.split.map(&:to_i) if a < b n = (a..b) else n = (b..a) end if n.include?(c) puts "Yes" else puts "No" end
[ "call.remove" ]
878,011
878,012
u053656954
ruby
p03067
a, b, c = gets.strip.split.map(&:to_i) puts a, b, c if (a < c && c < b) || (a > c && c > b) puts 'Yes' else puts 'No' end
a, b, c = gets.strip.split.map(&:to_i) if (a < c && c < b) || (a > c && c > b) puts 'Yes' else puts 'No' end
[ "call.remove" ]
878,142
878,143
u984643753
ruby
p03067
a,b,c = gets.strip.split('').map(&:to_i) if (a < c && c < b) || (a > c && c > b) puts 'Yes' else puts 'No' end
a, b, c = gets.strip.split.map(&:to_i) if (a < c && c < b) || (a > c && c > b) puts 'Yes' else puts 'No' end
[ "call.arguments.change" ]
878,144
878,143
u984643753
ruby
p03067
def main a,b,c=gets.split.map(&:to_i) x=a-c y=b-c if(x>0 && y>0) then return "No" elsif(x<0 && y<0) then return "No" else return "Yes" end end
a,b,c=gets.split.map(&:to_i) x=a-c y=b-c if(x>0 && y>0) then puts "No" elsif(x<0 && y<0) then puts "No" else puts "Yes" end
[ "function.return_value.change" ]
878,197
878,198
u715414090
ruby
p03067
a, b, c = gets.chomp.split.map(&:to_i) puts (a-c)*(c-b) <= 0 ? "Yes" : "No"
a, b, c = gets.chomp.split.map(&:to_i) puts (a-c)*(c-b) > 0 ? "Yes" : "No"
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
878,353
878,354
u744908753
ruby
p03067
a, b, c = gets.chomp.split.map(&:to_i) puts (a-b)*(b-c) < 0 ? "Yes" : "No"
a, b, c = gets.chomp.split.map(&:to_i) puts (a-c)*(c-b) > 0 ? "Yes" : "No"
[ "identifier.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove", "misc.opposites", "expression.operator.compare.change" ]
878,355
878,354
u744908753
ruby
p03068
gets;puts gets.chomp.gsub(/[^#{s[gets.to_i-1]}]/, '*')
gets;s=gets.chomp;puts s.gsub(/[^#{s[gets.to_i-1]}]/, '*')
[ "assignment.variable.change" ]
878,610
878,611
u025592199
ruby
p03068
kkk = gets moji = gets bango = gets.to_i nokosu = moji[bango-1] print moji.gsub(/[^#{nokosu}]/,"*")
kkk = gets moji = gets.chomp bango = gets.to_i nokosu = moji[bango-1] print moji.gsub(/[^#{nokosu}]/,"*")
[ "call.add" ]
878,882
878,883
u312004378
ruby
p03068
input = readlines.map(&:chomp) length = input[0].to_i word = input[1] num = input[2].to_i -1 char = word[num] length.times do |i| if word[i] == char # nothing else word[i] = "*" end end print word
input = readlines.map(&:chomp) length = input[0].to_i word = input[1] num = input[2].to_i char = word[num - 1] length.times do |i| if word[i] == char # nothing else word[i] = "*" end end print word
[ "assignment.change" ]
879,006
879,007
u208303341
ruby
p03068
input = readlines.map(&:chomp) length = input[0].to_i word = input[1] num = input[2].to_i char = word[num] length.times do |i| if word[i] == char # nothing else word[i] = "*" end end print word
input = readlines.map(&:chomp) length = input[0].to_i word = input[1] num = input[2].to_i char = word[num - 1] length.times do |i| if word[i] == char # nothing else word[i] = "*" end end print word
[ "assignment.change" ]
879,008
879,007
u208303341
ruby
p03068
n = gets.to_i s = gets k = gets.to_i target = s[k-1] pattern = '[^' + target + ']' puts s.gsub(/#{pattern}/, '*')
n = gets.to_i s = gets k = gets.to_i target = s[k-1] pattern = '[^' + target + '\s]' puts s.gsub(/#{pattern}/, '*')
[ "literal.string.change", "assignment.value.change", "expression.operation.binary.change" ]
879,090
879,091
u489339677
ruby
p03068
n = gets.to_i s = gets k = gets.to_i target = s[k] pattern = '[^' + target + ']' puts s.gsub(/#{pattern}/, '*')
n = gets.to_i s = gets k = gets.to_i target = s[k-1] pattern = '[^' + target + '\s]' puts s.gsub(/#{pattern}/, '*')
[ "literal.string.change", "assignment.value.change", "expression.operation.binary.change" ]
879,092
879,091
u489339677
ruby
p03068
N = gets.to_i S = gets.chomp K = gets.to_i puts S.gsub(/[^#{S[K]}]/, "*")
N = gets.to_i S = gets.chomp K = gets.to_i - 1 puts S.gsub(/[^#{S[K]}]/, "*")
[ "assignment.change" ]
879,135
879,136
u064100484
ruby
p03068
N = gets.to_i S = gets.chomp K = gets.to_i p S t = S[K-1] ans = '' S.chars.each do |s| if s == t ans += s else ans += '*' end end puts ans
N = gets.to_i S = gets.chomp K = gets.to_i t = S[K-1] ans = '' S.chars.each do |s| if s == t ans += s else ans += '*' end end puts ans
[ "call.remove" ]
879,199
879,200
u237620737
ruby
p03068
n = gets.to_i s = gets k = gets.to_i s = s.chars ans = [] target = s[k-1] s.each do|chara| if chara == target ans << chara else ans << "*" end end puts ans.join
n = gets.to_i s = gets.chomp k = gets.to_i s = s.chars ans = [] target = s[k-1] s.each do|chara| if chara == target ans << chara else ans << "*" end end puts ans.join
[ "call.add" ]
879,213
879,214
u328174452
ruby
p03068
length = gets.to_i str = gets.to_s target_key = gets.to_i target_str = str[target_key - 1, 1] result = '' str.each_char do |ch| result += ch == target_str ? ch : '*' end puts result
length = gets.to_i str = gets.strip.to_s target_key = gets.to_i target_str = str[target_key - 1, 1] result = '' str.each_char do |ch| result += ch == target_str ? ch : '*' end puts result
[ "call.add" ]
879,406
879,407
u616199845
ruby
p03068
n = gets.to_i s = gets.chomp k = gets.to_i c = s[k] puts s.split.map{|w| w.gsub(/[^#{c}]/, '*')}.join
n = gets.to_i s = gets.chomp k = gets.to_i c = s[k-1] puts s.split.map{|w| w.gsub(/[^#{c}]/, '*')}.join
[ "assignment.change" ]
879,410
879,411
u984643753
ruby
p03069
#input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def get_nsp() retu...
#input of int(split by space) def get_i() return gets.chomp.split(" ").map(&:to_i) end #input of float(split by space) def get_f() return gets.chomp.split(" ").map(&:to_f) end #input of string(split by space) def get() return gets.chomp.split(" ") end #input of string(split per one character) def get_nsp() retu...
[ "assignment.change" ]
879,961
879,962
u415400221
ruby
p03069
n = gets.to_i s = gets.chomp.chars ans = 1e10 cnt_w = [] cnt_b = [] cnt = 0 s.each do |c| if c == "#" cnt += 1 end cnt_b << cnt end cnt = 0 s.each do |c| if c == "." cnt += 1 end cnt_w << cnt end ans = 0 if s.all?{|c| c == "#"} (0..n-1).each do |i| ans = [cnt_b[i] + cnt_w[n-1] - cnt_w[i],ans].min...
n = gets.to_i s = gets.chomp.chars ans = 1e10 cnt_w = [] cnt_b = [] cnt = 0 s.each do |c| if c == "#" cnt += 1 end cnt_b << cnt end cnt = 0 s.each do |c| if c == "." cnt += 1 end cnt_w << cnt end ans = 0 if s.all?{|c| c == "#"} (0..n-1).each do |i| ans = [cnt_b[i] + cnt_w[n-1] - cnt_w[i],ans].min...
[]
880,215
880,216
u191196346
ruby
p03069
n = gets.chomp.to_i s = gets.chomp a = [] (0...n).each do |i| a << i if s[i] == '#' end if a.empty? puts 0 else w = [] w[0] = a[0] == 0 ? 0 : s[0, a[0] - 1].count('#') (1...a.length).each do |i| w[i] = w[i - 1] + s[a[i - 1], a[i] - a[i - 1]].count('#') end b = [] b[a.length - 1] = s[a[-1], n - a...
n = gets.chomp.to_i s = gets.chomp a = [] (0...n).each do |i| a << i if s[i] == '#' end if a.empty? puts 0 else w = [] w[0] = a[0] == 0 ? 0 : s[0, a[0] - 1].count('#') (1...a.length).each do |i| w[i] = w[i - 1] + s[a[i - 1], a[i] - a[i - 1]].count('#') end b = [] b[a.length - 1] = s[a[-1], n - a...
[ "identifier.change", "expression.operation.binary.change" ]
880,385
880,386
u848841515
ruby
p03069
n = gets.chomp.to_i s = gets.chomp a = [] (0...n).each do |i| a << i if s[i] == '#' end if a.empty? puts 0 else w = [] w[0] = a[0] == 0 ? 0 : s[0, a[0] - 1].count('#') (1...a.length).each do |i| w[i] = w[i - 1] + s[a[i - 1], a[i] - a[i - 1]].count('#') end b = [] b[a.length - 1] = s[a[-1], n - a...
n = gets.chomp.to_i s = gets.chomp a = [] (0...n).each do |i| a << i if s[i] == '#' end if a.empty? puts 0 else w = [] w[0] = a[0] == 0 ? 0 : s[0, a[0] - 1].count('#') (1...a.length).each do |i| w[i] = w[i - 1] + s[a[i - 1], a[i] - a[i - 1]].count('#') end b = [] b[a.length - 1] = s[a[-1], n - a...
[ "identifier.change", "expression.operation.binary.change" ]
880,387
880,386
u848841515
ruby
p03069
def cin; gets.split.map(&:to_i) end def cout(*x); puts x.join(" ") end # exit if $0 != __FILE__ n = gets.to_i s = gets.chop.chars ws = s.reverse.inject([0]) {|m,c| m << ((c=='.') ? m.last+1 : m.last)} bs = s.inject([0]) {|m,c| m << ((c=='#') ? m.last+1 : m.last)} ws << ws.last bs << bs.last #p ws #p bs min = 10**1...
def cin; gets.split.map(&:to_i) end def cout(*x); puts x.join(" ") end # exit if $0 != __FILE__ n = gets.to_i s = gets.chop.chars ws = s.reverse.inject([0]) {|m,c| m << ((c=='.') ? m.last+1 : m.last)} bs = s.inject([0]) {|m,c| m << ((c=='#') ? m.last+1 : m.last)} ws << ws.last bs << bs.last #p ws #p bs min = 10**1...
[ "literal.number.integer.change" ]
880,429
880,430
u388603285
ruby
p03071
a,b=gets.split.map(&:to_i) mx=[a,b].max mn=[a,b].min if mx-mn > 2 then p mx + mx - 1 else p mx + mn end
a,b=gets.split.map(&:to_i) mx=[a,b].max mn=[a,b].min if mx-mn >= 2 then p mx + mx - 1 else p mx + mn end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
880,581
880,580
u803684095
ruby
p03071
x, y = readline.split.map(&:to_i) puts x == y ? (x * 2 - 1) : ([x,y].max * 2 - 1)
x, y = readline.split.map(&:to_i) puts x == y ? (x * 2) : ([x,y].max * 2 - 1)
[ "expression.operation.binary.remove" ]
881,006
881,007
u353707427
ruby
p03071
a,b = gets.split.map(&:to_i) if a == b puts a + b end if (a > b) && ((a - b) <=2) puts a + (a-1) elsif (a > b) && (a - b) < 2 puts a + b end if b > a && (b - a) <=2 puts b + (b-1) elsif (b > a) && ((b - a) < 2) puts b + a end
a,b = gets.split.map(&:to_i) if a == b puts a + b end if (a > b) && ((a - b) >=2) puts a + (a-1) elsif (a > b) && (a - b) < 2 puts a + b end if b > a && (b - a) >=2 puts b + (b-1) elsif (b > a) && ((b - a) < 2) puts b + a end
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
881,071
881,072
u012110567
ruby
p03071
a,b=gets.split.map &:to_i puts [(a*2)-1,(b*2)-1].max
a,b=gets.split.map &:to_i puts [(a*2)-1,(b*2)-1,a+b].max
[ "literal.array.change" ]
881,194
881,195
u049159332
ruby
p03071
a, b = gets.split.map(&:to_i) if a > b puts 2 * a - 1 elsif b < a puts 2 * b - 1 else puts a + b end
a, b = gets.split.map(&:to_i) if a > b puts 2 * a - 1 elsif a < b puts 2 * b - 1 else puts a + b end
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
881,196
881,197
u118211443
ruby
p03069
N = gets.to_i S = gets.chomp.chars cnt = [[0, S.count(".")]] S.each do |c| if c == "#" cnt << [cnt.last[0]+1, cnt.last[1]] else cnt << [cnt.last[0], cnt.last[1]-1] end end return cnt.map {|a,b|a+b}.min
N = gets.to_i S = gets.chomp.chars cnt = [[0, S.count(".")]] S.each do |c| if c == "#" cnt << [cnt.last[0]+1, cnt.last[1]] else cnt << [cnt.last[0], cnt.last[1]-1] end end puts cnt.map {|a,b|a+b}.min
[ "function.return_value.change" ]
881,265
881,266
u064100484
ruby
p03069
n = gets.to_i s = gets.chomp.chars w = Array.new(n,0) b = Array.new(n,0) ans=Array.new (1...n).each do |i| b[i]= if (s[i-1]=='#') b[i-1]+1 else b[i-1] end end (0...n-1).reverse_each do |i| w[i] = if (s[i+1]=='.') w[i+1]+1 else w[i+1] end end p b,w (0...n).each do |i| ans.push...
n = gets.to_i s = gets.chomp.chars w = Array.new(n,0) b = Array.new(n,0) ans=Array.new (1...n).each do |i| b[i]= if (s[i-1]=='#') b[i-1]+1 else b[i-1] end end (0...n-1).reverse_each do |i| w[i] = if (s[i+1]=='.') w[i+1]+1 else w[i+1] end end (0...n).each do |i| ans.push(b[i]+...
[ "call.remove" ]
881,296
881,297
u458187055
ruby
p03069
n = gets.to_i s = gets.chomp.chars w = Array.new(n,0) b = Array.new(n,0) ans=Array.new (1...n).each do |i| b[i]= if (s[i]=='#') b[i-1]+1 else b[i-1] end end (0...n-1).reverse_each do |i| w[i] = if (s[i]=='.') w[i+1]+1 else w[i+1] end end (0...n).each do |i| ans.push(b[i]+w[i]...
n = gets.to_i s = gets.chomp.chars w = Array.new(n,0) b = Array.new(n,0) ans=Array.new (1...n).each do |i| b[i]= if (s[i-1]=='#') b[i-1]+1 else b[i-1] end end (0...n-1).reverse_each do |i| w[i] = if (s[i+1]=='.') w[i+1]+1 else w[i+1] end end (0...n).each do |i| ans.push(b[i]+...
[ "control_flow.branch.if.condition.change" ]
881,298
881,297
u458187055
ruby
p03071
A,B = gets.split(" ").map(&:to_i) if A-1 > B puts A + A-1 elsif A-1 == B puts A + B elsif A == B puts A + B-1 else puts B + B-1 end
A,B = gets.split(" ").map(&:to_i) if A-1 > B puts A + A-1 elsif A-1 == B puts A + B elsif A == B puts A + B else puts B + B-1 end
[ "expression.operation.binary.remove" ]
881,407
881,408
u210338356
ruby
p03071
a,b=gets.split.map(&:to_i) puts [a+a-1, b+b-a, a+b].max
a,b=gets.split.map(&:to_i) puts [a+a-1, b+b-1, a+b].max
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
881,416
881,417
u056944756
ruby
p03071
a, b = gets.split(" ").map(&:to_i) val = 0 2.times do |i| if a > b val += a a -= 1 else val += b b -= b end end puts val
a, b = gets.split(" ").map(&:to_i) val = 0 2.times do |i| if a > b val += a a -= 1 else val += b b -= 1 end end puts val
[ "identifier.replace.remove", "literal.replace.add" ]
881,537
881,538
u560124635
ruby
p03071
input = gets.split.map(&:to_i) if input[0] == input[1] then puts input[0]*2 else puts input.max() * (input.max()-1) end
input = gets.split.map(&:to_i) if input[0] == input[1] then puts input[0]*2 else puts input.max() + (input.max()-1) end
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
881,539
881,540
u446713108
ruby
p03071
input = gets.split.map(&:to_i) if input[0] == input[1] then print input[0]**2 else print input.max() * (input.max()-1) end
input = gets.split.map(&:to_i) if input[0] == input[1] then puts input[0]*2 else puts input.max() + (input.max()-1) end
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "expression.operator.arithmetic.change" ]
881,541
881,540
u446713108
ruby
p03071
a, b = gets.split(' ').map(&:to_i) p list.max * 2 - (a == b ? 0 : 1)
a, b = gets.split(' ').map(&:to_i) p [a, b].max * 2 - (a == b ? 0 : 1)
[ "call.arguments.change", "expression.operation.binary.change", "literal.array.change" ]
881,555
881,556
u360187321
ruby
p03071
a, b = gets.split.map(&:to_i) p [a, b].max * 2 - (a == b ? 1 : 0)
a, b = gets.split.map(&:to_i) p [a, b].max * 2 - (a == b ? 0 : 1)
[]
881,858
881,859
u702547798
ruby
p03071
a,b=gets.split.to_a s=0 if a > b s+=a a-=1 else s+=b b-=1 end if a > b s+=a a-=1 else s+=b b-=1 end puts s
a,b=gets.split.map(&:to_i) s=0 if a > b s+=a a-=1 else s+=b b-=1 end if a > b s+=a a-=1 else s+=b b-=1 end puts s
[ "assignment.value.change", "identifier.change", "call.arguments.add" ]
881,882
881,883
u951762226
ruby
p03071
buttons = gets.chomp.split(" ").map(&:to_i) puts button[0] == button[1] ? button[0] * 2 : (button.sort[1] * 2) - 1
button = gets.chomp.split(" ").map(&:to_i) puts button[0] == button[1] ? button[0] * 2 : (button.sort[1] * 2) - 1
[ "assignment.variable.change", "identifier.change" ]
881,908
881,909
u538351278
ruby
p03071
A,B = gets.split.map(&:to_i) f = A+A-1 s = B+B-1 t = A+B if f >= s && f >= t puts f elsif s >= f && s >= t puts t else puts t end
A,B = gets.split.map(&:to_i) f = A+A-1 s = B+B-1 t = A+B if f >= s && f >= t puts f elsif s >= f && s >= t puts s else puts t end
[ "identifier.change", "call.arguments.change" ]
881,943
881,944
u363743459
ruby
p03071
A,B = gets.split.map(&:to_i) f = A+A-1 s = B+B-1 t = A+B if f > s && f > t puts f elsif s > f && s > t puts t else puts t end
A,B = gets.split.map(&:to_i) f = A+A-1 s = B+B-1 t = A+B if f >= s && f >= t puts f elsif s >= f && s >= t puts s else puts t end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "call.arguments.change" ]
881,945
881,944
u363743459
ruby