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
p03760
o=gest.chomp.chars e=gest.chomp.chars ans = "" (o.size + e.size).times do |i| if i.odd? ans << e.shift else ans << o.shift end end puts ans
o=gets.chomp.chars e=gets.chomp.chars ans = "" (o.size + e.size).times do |i| if i.odd? ans << e.shift else ans << o.shift end end puts ans
[ "misc.typo", "assignment.value.change", "identifier.change" ]
1,407,215
1,407,216
u706695185
ruby
p03760
O = gets.chomp E = gets.chomp s = "" O.size.times do s += O.slice!(0) + E.slice!(0) end puts s+E
O = gets.chomp E = gets.chomp s = "" E.size.times do s += O.slice!(0) + E.slice!(0) end puts s+O
[ "call.arguments.change", "expression.operation.binary.change" ]
1,407,331
1,407,332
u502306384
ruby
p03760
o=gets.chomp e=gets.chomp ans="" e.size.times do |i| ans+=o[i]+e[i] end ans+=e[-1] if o.size-e.size==1 puts ans
o=gets.chomp e=gets.chomp ans="" e.size.times do |i| ans+=o[i]+e[i] end ans+=o[-1] if o.size-e.size==1 puts ans
[ "identifier.change" ]
1,407,357
1,407,358
u602591412
ruby
p03760
o = gets.chomp e = gets.chomp s = [] for i in 0..o.length-1 s << o[i] s << e[i] end puts (o.length+e.length).even? ? s.join("") : s.push(o[o.length-1]).join("")
o = gets.chomp e = gets.chomp s = [] for i in 0..e.length-1 s << o[i] s << e[i] end puts (o.length+e.length).even? ? s.join("") : s.push(o[o.length-1]).join("")
[ "identifier.change", "expression.operation.binary.change" ]
1,407,470
1,407,471
u990788654
ruby
p03760
o = gets.chomp e = gets.chomp s = [] for i in 0..o.length-1 s << o[i] s << e[i] end puts (o.length+e.length).even? ? s.join("") : s.push(e[e.length-1]).join("")
o = gets.chomp e = gets.chomp s = [] for i in 0..e.length-1 s << o[i] s << e[i] end puts (o.length+e.length).even? ? s.join("") : s.push(o[o.length-1]).join("")
[ "identifier.change", "expression.operation.binary.change", "call.arguments.change", "variable_access.subscript.index.change" ]
1,407,472
1,407,471
u990788654
ruby
p03760
o = gets.chomp.split('') e = gets.chomp.split('') l = o.length if o.length == e.length (0...l).each do |i| print o[i] + e[i] end puts else (0...l-1).each do |i| if i == l-1 print o[i] else print o[i] + e[i] end end puts end
o = gets.chomp.split('') e = gets.chomp.split('') l = o.length if o.length == e.length (0...l).each do |i| print o[i] + e[i] end puts else (0..l-1).each do |i| if i == l-1 print o[i] else print o[i] + e[i] end end puts end
[]
1,407,796
1,407,797
u482389534
ruby
p03760
o = gets.chomp e = gets.chomp o.zip(e) { |a| print a.join }; puts
o = gets.chomp.chars e = gets.chomp.chars o.zip(e) { |a| print a.join }; puts
[ "call.add" ]
1,408,857
1,408,858
u018539875
ruby
p03767
n = gets.to_i s = gets.split.map(&:to_i).sort.reverse ret = 0 for i in 0..n ret += s[i * 2 + 1] end puts ret
n = gets.to_i s = gets.split.map(&:to_i).sort.reverse ret = 0 for i in 0..n-1 ret += s[i * 2 + 1] end puts ret
[ "expression.operation.binary.add" ]
1,410,037
1,410,038
u056083754
ruby
p03767
n = gets.to_i s = gets.split.map(&:to_i).sort.reverse ret = 0 for i in 0..n ret += a[i * 2 + 1] end puts ret
n = gets.to_i s = gets.split.map(&:to_i).sort.reverse ret = 0 for i in 0..n-1 ret += s[i * 2 + 1] end puts ret
[ "identifier.change" ]
1,410,040
1,410,038
u056083754
ruby
p03767
n=gets.to_i as=gets.split.map &:to_i as.sort! as.reverse! cnt=0 for i in 1..n cnt+=as[2*i+1] end p cnt
n=gets.to_i as=gets.split.map &:to_i as.sort! as.reverse! cnt=0 for i in 1..n cnt+=as[2*i-1] end p cnt
[ "misc.opposites", "expression.operator.arithmetic.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
1,410,351
1,410,352
u926099741
ruby
p03767
N = gets.to_i A = gets.split.map(&:to_i) sorted = A.sort.reverse sum = 0 0.upto(N-1) do |n| sum += sorted[N + n] end puts sum
N = gets.to_i A = gets.split.map(&:to_i) sorted = A.sort.reverse sum = 0 0.upto(N-1) do |n| sum += sorted[n*2 + 1] end puts sum
[ "expression.operation.binary.remove" ]
1,410,838
1,410,839
u237620737
ruby
p03767
result = 0 n = gets.to_i-1 input = gets.chomp.split(" ").map { |n| n.to_i } input.sort!.reverse! for i in 0..n result += input[1+i] end puts result
result = 0 n = gets.to_i-1 input = gets.chomp.split(" ").map { |n| n.to_i } input.sort!.reverse! for i in 0..n result += input[1+i*2] end puts result
[ "expression.operation.binary.add" ]
1,411,156
1,411,157
u136468939
ruby
p03773
a, b = gets.chomp.split(" ").map(&:to_i) kaisi = a + b if kaisi > 24 ans = kaisi - 24 else ans = kaisi end puts ans
a, b = gets.chomp.split(" ").map(&:to_i) kaisi = a + b if kaisi >= 24 ans = kaisi - 24 else ans = kaisi end puts ans
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,411,599
1,411,600
u412789323
ruby
p03773
n,m=gets.split.map(&:to_i) a=n+m puts a>24? a-24:a
n,m=gets.split.map(&:to_i) a=n+m puts a>=24? a-24:a
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,411,893
1,411,894
u590472228
ruby
p03773
A, B = gets.map(&:to_i) puts (A + B) % 24
A, B = gets.split.map(&:to_i) puts (A + B) % 24
[ "call.add" ]
1,411,962
1,411,963
u112504572
ruby
p03773
a,b = gets.chomp.split.map(&:to_i) if a + b >= 23 puts (a + b) - 24 else puts a + b end
a,b = gets.chomp.split.map(&:to_i) if a + b > 23 puts (a + b) - 24 else puts a + b end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,411,964
1,411,965
u689027433
ruby
p03773
a, b = gets.chomp.split.map(&:to_i) puts (a + B) % 24
a, b = gets.chomp.split.map(&:to_i) puts (a + b) % 24
[ "call.arguments.change", "expression.operation.binary.change" ]
1,411,968
1,411,969
u792512290
ruby
p03773
# イルカはプログラミングコンテスト好きで、 # 今日はAtCoderのコンテストに参加します。 # 現在時刻は、24 時間表記 (0:00〜23:59) で # A 時ちょうどであり、コンテストがちょうど B 時間後に始まります。 # コンテストの開始時刻は、24 時間表記で何時ちょうどでしょうか? ab = gets.chomp.split a = ab[0].to_i b = ab[1].to_i if a + b >= 24 puts a + b - 21 else puts a + b end
# イルカはプログラミングコンテスト好きで、 # 今日はAtCoderのコンテストに参加します。 # 現在時刻は、24 時間表記 (0:00〜23:59) で # A 時ちょうどであり、コンテストがちょうど B 時間後に始まります。 # コンテストの開始時刻は、24 時間表記で何時ちょうどでしょうか? ab = gets.chomp.split a = ab[0].to_i b = ab[1].to_i if a + b >= 24 puts a + b - 24 else puts a + b end
[ "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change" ]
1,412,076
1,412,077
u139850627
ruby
p03773
a,b = gets.split.map(&:to_i) if a+b > 24 puts a+b - 24 else puts a+b end
a,b = gets.split.map(&:to_i) if a+b >= 24 puts a+b - 24 else puts a+b end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,412,612
1,412,613
u012110567
ruby
p03773
A,B = gets.split.map(&:to_i) p A+B > 24 ? A+B-24 : A+B
A,B = gets.split.map(&:to_i) p A+B >= 24 ? A+B-24 : A+B
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,412,826
1,412,827
u244087909
ruby
p03773
a, b = gets.split.map(&:to_i) puts a+b>24 ? a+b : a+b-24
a, b = gets.split.map(&:to_i) puts a+b<24 ? a+b : a+b-24
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,412,828
1,412,829
u968699140
ruby
p03773
a.b=gets.split.map(&:to_i); a+b>=24 ? a+b-24 : a+b
a,b=gets.split.map(&:to_i); puts a+b>=24 ? a+b-24 : a+b
[ "misc.typo", "assignment.variable.change", "io.output.change", "call.add" ]
1,413,171
1,413,172
u831999711
ruby
p03773
a,b=gets.split.map(&:to_i); p (a+b)%24
a,b=gets.split.map &:to_i p (a+b)%24
[ "call.arguments.change" ]
1,413,254
1,413,255
u785521224
ruby
p03773
a, b = gets.chomp.split(" ").map(&:to_i) puts a+b=>24 ? a+b-24 : a+b
a, b = gets.chomp.split(" ").map(&:to_i) puts a+b>=24 ? a+b-24 : a+b
[ "call.arguments.change" ]
1,413,292
1,413,293
u868089307
ruby
p03773
a, b = gets.chomp.split(" ").map(&:to_i) puts a+b>24 ? a+b-24 : a+b
a, b = gets.chomp.split(" ").map(&:to_i) puts a+b>=24 ? a+b-24 : a+b
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,413,294
1,413,293
u868089307
ruby
p03773
a,b = gets.split.map(&:to_i) puts (a + b % 24)
a,b = gets.split.map(&:to_i) puts ((a+b) % 24)
[ "call.arguments.change" ]
1,413,499
1,413,500
u627981707
ruby
p03773
a, b = gets.chomp.split(" ").map(&:to_i) result = a+b > 24? (a+b)%24 : a+b puts result
a, b = gets.chomp.split(" ").map(&:to_i) result = a+b >= 24? (a+b)%24 : a+b puts result
[ "expression.operator.compare.change", "assignment.value.change", "control_flow.branch.if.condition.change" ]
1,413,712
1,413,713
u136468939
ruby
p03774
class Problem attr_accessor *(?a..?z).to_a.map(&:to_sym) def initialize @n,@m = gets.to_s.split.map{ |v| v.to_i } @a,@b = Array.new(n){ gets.to_s.split.map{ |v| v.to_i } }.transpose @c,@d = Array.new(n){ gets.to_s.split.map{ |v| v.to_i } }.transpose end def len(a,b,c,d) (a-c).abs + (b-d).abs end def solve ans = [] n.times do |i| lens = n.times.map{|j|len(a[i],b[i],c[j],d[j])} mini = lens.min k = lens.find_index(mini) ans << k + 1 end ans end def show(ans) ans.each do |a| puts a end end end Problem.new.instance_eval do show(solve) end
class Problem attr_accessor *(?a..?z).to_a.map(&:to_sym) def initialize @n,@m = gets.to_s.split.map{ |v| v.to_i } @a,@b = Array.new(n){ gets.to_s.split.map{ |v| v.to_i } }.transpose @c,@d = Array.new(m){ gets.to_s.split.map{ |v| v.to_i } }.transpose end def len(a,b,c,d) (a-c).abs + (b-d).abs end def solve ans = [] n.times do |i| lens = m.times.map{|j|len(a[i],b[i],c[j],d[j])} mini = lens.min k = lens.find_index(mini) ans << k + 1 end ans end def show(ans) ans.each do |a| puts a end end end Problem.new.instance_eval do show(solve) end
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
1,413,833
1,413,834
u106964380
ruby
p03774
require 'pp' require 'pry' # 空白区切の入力値を数値の配列で返却する def gets_i_list() gets.chomp.split(" ").map(&:to_i) end N, M = gets_i_list students = [] N.times do students.push(gets_i_list) end checkpoints = [] M.times do checkpoints.push(gets_i_list) end students.each do |s| sx, sy = s min_point = nil min_distance = nil checkpoints.each_with_index do |c, i| cx, cy = c distance = (sx - cx).abs + (sy - cy).abs if min_point.nil? min_point = i + 1 min_distance = distance elsif !min_point.nil? && min_distance > distance min_point = i + 1 min_distance = distance end end puts min_point end
require 'pp' # 空白区切の入力値を数値の配列で返却する def gets_i_list() gets.chomp.split(" ").map(&:to_i) end N, M = gets_i_list students = [] N.times do students.push(gets_i_list) end checkpoints = [] M.times do checkpoints.push(gets_i_list) end students.each do |s| sx, sy = s min_point = nil min_distance = nil checkpoints.each_with_index do |c, i| cx, cy = c distance = (sx - cx).abs + (sy - cy).abs if min_point.nil? min_point = i + 1 min_distance = distance elsif !min_point.nil? && min_distance > distance min_point = i + 1 min_distance = distance end end puts min_point end
[ "call.remove" ]
1,414,149
1,414,150
u370977023
ruby
p03774
def d(a,b);(a[0]-b[0]).abs+(a[1]-b[1]).abs;end;M=$<.map{|l|l.split.map(&:to_i)};n,m=M.shift;S=M.take(n);puts S.map{|s|(1..m).min_by{|i|d(M[i-1],s)}}
def d(a,b);(a[0]-b[0]).abs+(a[1]-b[1]).abs;end M=$<.map{|l|l.split.map(&:to_i)} n,m=M.shift S=M.shift(n) puts S.map{|s|(1..m).min_by{|i|d(M[i-1],s)}}
[ "assignment.value.change", "identifier.change" ]
1,415,028
1,415,029
u627981707
ruby
p03774
n,m=gets.split.map(&:to_i) a=[] n.times{a<<gets.split.map(&:to_i)} b=[] m.times{b<<gets.split.map(&:to_i)} b.each do |x,y| puts a.each_with_index.min_by{|(z,w),i| [[z-x,w-y].map(&:abs).inject(&:+),i]}[1]+1 end
n,m=gets.split.map(&:to_i) a=[] n.times{a<<gets.split.map(&:to_i)} b=[] m.times{b<<gets.split.map(&:to_i)} a.each do |x,y| puts b.each_with_index.min_by{|(z,w),i| [[z-x,w-y].map(&:abs).inject(&:+),i]}[1]+1 end
[]
1,415,105
1,415,106
u056944756
ruby
p03774
n,m=gets.split.map(&:to_i) a=[] n.times{a<<gets.split.map(&:to_i)} b=[] m.times{b<<gets.split.map(&:to_i)} b.each do |x,y| puts a.each_with_index.min_by{|(z,w),i| [z-x,w-y].map(&:abs).inject(&:+)}[1]+1 end
n,m=gets.split.map(&:to_i) a=[] n.times{a<<gets.split.map(&:to_i)} b=[] m.times{b<<gets.split.map(&:to_i)} a.each do |x,y| puts b.each_with_index.min_by{|(z,w),i| [[z-x,w-y].map(&:abs).inject(&:+),i]}[1]+1 end
[]
1,415,107
1,415,106
u056944756
ruby
p03774
n,m = gets.chomp.split(' ').map{|n| n.to_i} a = [] b = [] c = [] d = [] C = (10 ** 8) + 1 n.times do |i| a[i], b[i] = gets.chomp.split(' ').map{|n| n.to_i} end m.times do |i| c[i], d[i] = gets.chomp.split(' ').map{|n| n.to_i} end distance = Array.new(n) n.times do |i| cheack = C m.times do |ci| ds_tmp = (a[i] - c[ci]).abs + (b[i] - d[ci]).abs if ds_tmp < cheack distance[i] = ci + 1 cheack = ds_tmp end end end distance.each do |i| puts i end
n,m = gets.chomp.split(' ').map{|n| n.to_i} a = [] b = [] c = [] d = [] C = 10 ** 9 n.times do |i| a[i], b[i] = gets.chomp.split(' ').map{|n| n.to_i} end m.times do |i| c[i], d[i] = gets.chomp.split(' ').map{|n| n.to_i} end distance = Array.new(n) n.times do |i| cheack = C m.times do |ci| ds_tmp = (a[i] - c[ci]).abs + (b[i] - d[ci]).abs if ds_tmp < cheack distance[i] = ci + 1 cheack = ds_tmp end end end distance.each do |i| puts i end
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
1,415,119
1,415,120
u698501698
ruby
p03774
n,m = gets.chomp.split(' ').map{|n| n.to_i} a = [] b = [] c = [] d = [] C = 10 ** 8 n.times do |i| a[i], b[i] = gets.chomp.split(' ').map{|n| n.to_i} end m.times do |i| c[i], d[i] = gets.chomp.split(' ').map{|n| n.to_i} end distance = Array.new(n) n.times do |i| check = C m.times do |ci| ds_tmp = (a[i] - c[ci]).abs + (b[i] - d[ci]).abs if ds_tmp < check distance[i] = ci + 1 check = ds_tmp end end end distance.each do |i| puts i end
n,m = gets.chomp.split(' ').map{|n| n.to_i} a = [] b = [] c = [] d = [] C = 10 ** 9 n.times do |i| a[i], b[i] = gets.chomp.split(' ').map{|n| n.to_i} end m.times do |i| c[i], d[i] = gets.chomp.split(' ').map{|n| n.to_i} end distance = Array.new(n) n.times do |i| cheack = C m.times do |ci| ds_tmp = (a[i] - c[ci]).abs + (b[i] - d[ci]).abs if ds_tmp < cheack distance[i] = ci + 1 cheack = ds_tmp end end end distance.each do |i| puts i end
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change", "assignment.variable.change", "identifier.change", "control_flow.branch.if.condition.change" ]
1,415,121
1,415,120
u698501698
ruby
p03773
input = gets.chomp inp = input.split("\s") a = inp[0].to_i b = inp[1].to_i time = a + b if time > 24 time = time - 24 end print(time, "\n")
input = gets.chomp inp = input.split("\s") a = inp[0].to_i b = inp[1].to_i time = a + b if time >= 24 time = time - 24 end print(time, "\n")
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,415,339
1,415,340
u079482478
ruby
p03774
N, M = gets.split.map(&:to_i) S = [] N.times do S << gets.split.map(&:to_i) end C = [] M.times do C << gets.split.map(&:to_i) end p C S.each do |xs, ys| ds = C.map {|xc, yc| (xs - xc).abs + (ys - yc).abs} puts ds.index(ds.min) + 1 end
N, M = gets.split.map(&:to_i) S = [] N.times do S << gets.split.map(&:to_i) end C = [] M.times do C << gets.split.map(&:to_i) end S.each do |xs, ys| ds = C.map {|xc, yc| (xs - xc).abs + (ys - yc).abs} puts ds.index(ds.min) + 1 end
[ "call.remove" ]
1,415,517
1,415,518
u004588855
ruby
p03774
nm = gets.chomp.split.map {|s| s.to_i } s = Array.new(nm[0]) do |i| gets.chomp.split.map {|s| s.to_i } end d = Array.new(nm[1]) do |i| gets.chomp.split.map {|s| s.to_i } end s.each do |e| m = 100000000000 res = 0 d.each_with_index do |x, idx| res = idx if ((e[0]-x[0]).abs + (e[1]-x[1]).abs) < ((e[0]-d[res][0]).abs + (e[1]-d[res][1]).abs) end puts res end
nm = gets.chomp.split.map {|s| s.to_i } s = Array.new(nm[0]) do |i| gets.chomp.split.map {|s| s.to_i } end d = Array.new(nm[1]) do |i| gets.chomp.split.map {|s| s.to_i } end s.each do |e| m = 100000000000 res = 0 d.each_with_index do |x, idx| res = idx if ((e[0]-x[0]).abs + (e[1]-x[1]).abs) < ((e[0]-d[res][0]).abs + (e[1]-d[res][1]).abs) end puts res + 1 end
[ "expression.operation.binary.add" ]
1,415,566
1,415,567
u664737319
ruby
p03774
n, m = gets.split.map(&:to_i) students = n.times.map{gets.split.map(&:to_i)} checks = n.times.map{|i| gets.split.map(&:to_i) << i+1} students.each{|p| puts checks.min_by{|q| p.zip(q).map{|d| d.reduce(:-).abs}.reduce(:+)}[2] }
n, m = gets.split.map(&:to_i) students = n.times.map{gets.split.map(&:to_i)} checks = m.times.map{|i| gets.split.map(&:to_i) << i+1} students.each{|p| puts checks.min_by{|q| p.zip(q).map{|d| d.reduce(:-).abs}.reduce(:+)}[2] }
[ "assignment.value.change", "identifier.change" ]
1,415,471
1,415,472
u467508794
ruby
p03775
n = gets.to_i sqrt = Math.sqrt(n).to_i i = 1 min = sqrt while i < sqrt if n % i == 0 if (n / i).to_s.length < min min = (n / i).to_s.length end end i += 1 end puts min
n = gets.to_i sqrt = Math.sqrt(n).to_i + 1 i = 1 min = sqrt while i < sqrt if n % i == 0 if (n / i).to_s.length <= min min = (n / i).to_s.length end end i += 1 end puts min
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,415,891
1,415,892
u059126963
ruby
p03775
#!/usr/bin/env ruby n = gets.chomp.to_i i = 1 ans = Float::INFINITY while i * i < n d, m = n.divmod(i) if m == 0 ans = [ans, [i.to_s.length, d.to_s.length].max].min end i += 1 end puts ans
#!/usr/bin/env ruby n = gets.chomp.to_i i = 1 ans = Float::INFINITY while i * i <= n d, m = n.divmod(i) if m == 0 ans = [ans, [i.to_s.length, d.to_s.length].max].min end i += 1 end puts ans
[ "expression.operator.compare.change", "expression.operation.binary.change" ]
1,416,174
1,416,175
u722851971
ruby
p03775
n = gets.to_ ar = [] 1.upto(sqrt(n)) do |x| next n % x != 0 y = n / x ar << [x.to_s.length, y.to_s.length].max end puts ar.min
n = gets.to_i ar = [] 1.upto(Math.sqrt(n)) do |x| next if n % x != 0 y = n / x ar << [x.to_s.length, y.to_s.length].max end puts ar.min
[ "assignment.value.change", "identifier.change", "call.add" ]
1,416,215
1,416,216
u392423112
ruby
p03775
n = gets.to_i tmp = n.to_s.size puts tmp 1.upto(n ** 0.5) do |a| b = n.to_f / a.to_f if b.to_s[-1] == "0" d = a.to_i.to_s.size > b.to_i.to_s.size ? a.to_i.to_s.size : b.to_i.to_s.size tmp = d if tmp > d end end puts tmp
n = gets.to_i tmp = n.to_s.size 1.upto(n ** 0.5) do |a| b = n.to_f / a.to_f if b.to_s[-1] == "0" d = a.to_i.to_s.size > b.to_i.to_s.size ? a.to_i.to_s.size : b.to_i.to_s.size tmp = d if tmp > d end end puts tmp
[ "call.remove" ]
1,416,958
1,416,959
u390727364
ruby
p03775
n = gets.to_i m = Math.sqrt(n).to_i max = n.to_s.size max = 0 (1..m).each do |i| if n % i == 0 max = [max,[i.to_s.size, (n / i).to_s.size].max].min end end puts max
n = gets.to_i m = Math.sqrt(n).to_i max = n.to_s.size (1..m).each do |i| if n % i == 0 max = [max,[i.to_s.size, (n / i).to_s.size].max].min end end puts max
[ "assignment.remove" ]
1,417,043
1,417,045
u819939299
ruby
p03775
n = gets.to_i m = Math.sqrt(n).to_i max = n.to_s.size max = 0 (1..m).each do |i| if n%i == 0 max = [max,[i.to_s.size, (n / i).to_s.size].max].min end end puts max
n = gets.to_i m = Math.sqrt(n).to_i max = n.to_s.size (1..m).each do |i| if n % i == 0 max = [max,[i.to_s.size, (n / i).to_s.size].max].min end end puts max
[ "assignment.remove" ]
1,417,047
1,417,045
u819939299
ruby
p03775
n = gets.to_i m = Math.sqrt(n).to_i arr = [] (1..m).each do |a| b = n / a arr << [a,b] if n == a*b p arr end long = n.to_s.chars.length arr.each do |x| long_x = x.max.to_s.chars.length long = long_x if long > long_x end puts long
n = gets.to_i m = Math.sqrt(n).to_i arr = [] (1..m).each do |a| b = n / a arr << [a,b] if n == a*b end long = n.to_s.chars.length arr.each do |x| long_x = x.max.to_s.chars.length long = long_x if long > long_x end puts long
[ "call.remove" ]
1,417,262
1,417,263
u296101474
ruby
p03775
N = gets.to_i n = Math.sqrt(N).ceil; while n >= 1 do if (N % n == 0) print n.to_s.size, "\n" break end n -= 1 end
N = gets.to_i n = Math.sqrt(N).floor; while n >= 1 do if (N % n == 0) print (N/n).to_s.size, "\n" break end n -= 1 end
[ "misc.opposites", "assignment.value.change", "identifier.change", "call.arguments.change" ]
1,417,772
1,417,773
u576106056
ruby
p03775
N=gets.to_i yaku = [] (1..[(N/2),100000].min).each{|i| yaku<<i if N%i==0 } min = 11 #てきとう yaku.each{|t| a = t.to_s.size b = (N/t).to_s.size a = b if b > a min = a if a < min } puts min
N=gets.to_i yaku = [] (1..[[(N/2),100000].min, 1].max).each{|i| yaku<<i if N%i==0 } min = 11 #てきとう yaku.each{|t| a = t.to_s.size b = (N/t).to_s.size a = b if b > a min = a if a < min } puts min
[ "call.add" ]
1,418,144
1,418,145
u397763977
ruby
p03777
s = gets.chomp ans = s.split("") h="H" d="D" if ans[0] == h if ans[1] == h puts h else puts d end else if ans[1] == h puts d else puts h end end
s = gets.chomp ans = s.split(" ") h="H" d="D" if ans[0] == h if ans[1] == h puts h else puts d end else if ans[1] == h puts d else puts h end end
[ "literal.string.change", "assignment.value.change", "call.arguments.change" ]
1,418,953
1,418,954
u145950990
ruby
p03777
A, B = gets.split a = A=='H' b = B=='H' p(a^b ? 'D' : 'H')
A, B = gets.split a = A=='H' b = B=='H' puts(a^b ? 'D' : 'H')
[ "call.function.change", "io.output.change" ]
1,419,421
1,419,422
u437302815
ruby
p03777
a,b = gets.chomp.split(' ').map{|n| n} b_role = {'H' => 'D', 'D' => 'H'} if a == 'H' p b else p b_role[b] end
a,b = gets.chomp.split(' ').map{|n| n} b_role = {'H' => 'D', 'D' => 'H'} if a == 'H' puts b else puts b_role[b] end
[ "call.function.change", "io.output.change" ]
1,419,423
1,419,424
u698501698
ruby
p03777
s = gets if s[0] == 'H' puts s[1] else if s[1] == 'H' puts 'D' else puts 'H' end end
s = gets.split if s[0] == 'H' puts s[1] else if s[1] == 'H' puts 'D' else puts 'H' end end
[ "call.add" ]
1,419,632
1,419,633
u601070043
ruby
p03778
W,a,b=gets.split.map &:to_i if b>(a+W) puts b-(a+W) elsif a>(b+W) puts a-(b+W) else 0 end
W,a,b=gets.split.map &:to_i if b>(a+W) puts b-(a+W) elsif a>(b+W) puts a-(b+W) else puts 0 end
[ "io.output.change", "call.add" ]
1,419,899
1,419,900
u630043039
ruby
p03777
a,b=gets.split p a==b ??H:?D
a,b=gets.split puts a==b ??H:?D
[ "call.function.change", "io.output.change" ]
1,419,953
1,419,954
u554838392
ruby
p03778
w,a,b = gets.chomp.split(' ').map{|n| n.to_i} a_end = w + a if a_end < b p b - a_end elsif a_end > b && b > a p 0 else p a - ( w + b) end
w,a,b = gets.chomp.split(' ').map{|n| n.to_i} a_end = w + a if a_end < b p b - a_end elsif a_end >= b && b + w >= a p 0 else p a - ( w + b) end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,420,239
1,420,238
u698501698
ruby
p03779
i = gets.to_i # ans=0 # while ans*(ans+1)/2 < i do # ans += 1 # end # puts ans tri = 1 dan = 1 while true do dan += 1 tri += dan if tri >= i break end end puts ans
i = gets.to_i # ans=0 # while ans*(ans+1)/2 < i do # ans += 1 # end # puts ans tri = 0 dan = 0 while true do dan += 1 tri += dan if tri >= i break end end puts dan
[ "literal.number.integer.change", "assignment.value.change", "identifier.change", "call.arguments.change" ]
1,421,218
1,421,217
u162612857
ruby
p03781
X = gets.to_i sum = 0 bs = [*1..(X**0.5).ceil].map{ |t| sum += t } p bs.bsearch_index{ |s| X <= s } + 1
X = gets.to_i sum = 0 bs = [*1..2*(X**0.5).ceil].map{ |t| sum += t } p bs.bsearch_index{ |s| X <= s } + 1
[ "assignment.change" ]
1,421,721
1,421,722
u693378622
ruby
p03776
N, A, B = gets.split.map(&:to_i) V = gets.split.map(&:to_i).sort.reverse freq = V.inject(Hash.new(0)) {|h, x| h[x] += 1; h} nums = V.take(A) puts "%.6f\n" % (nums.inject(:+) / nums.size.to_f) def nCr(n, r) ((r + 1)..n).inject(1, :*) / (1..(n - r)).inject(1, :*) end if nums.first == nums.last X = freq[nums.first] puts (A..X).map{|r| nCr(X, r)}.inject(:+) else c = nums.last m = freq[c] r = nums.reverse.inject(0) {|tot, x| tot += 1 if x == c; tot} puts nCr(m, r) end
N, A, B = gets.split.map(&:to_i) V = gets.split.map(&:to_i).sort.reverse freq = V.inject(Hash.new(0)) {|h, x| h[x] += 1; h} nums = V.take(A) puts "%.6f\n" % (nums.inject(:+) / nums.size.to_f) def nCr(n, r) ((r + 1)..n).inject(1, :*) / (1..(n - r)).inject(1, :*) end if nums.first == nums.last X = freq[nums.first] puts (A..[X, B].min).map{|r| nCr(X, r)}.inject(:+) else c = nums.last m = freq[c] r = nums.reverse.inject(0) {|tot, x| tot += 1 if x == c; tot} puts nCr(m, r) end
[ "call.arguments.change", "call.add" ]
1,421,957
1,421,958
u004588855
ruby
p03785
class Bus attr_accessor :start_time, :num, :max_num, :th_time def initialize max_num, th_time @max_num = max_num @th_time = th_time init_state end def init_state @num = 0 @start_time = nil end def get_on(time) if @num == 0 @start_time = time + @th_time end @num += 1 end def leave?(time) (!@start_time.nil? && @start_time < time) || @num==@max_num end def leave init_state end def empty? @num==0 end end N,c,k = gets.split.map(&:to_i) T = [] N.times{T<<gets.to_i} T.sort! ans = 0 bus=Bus.new(k,c) T.each do |t| if bus.leave?(t) bus.leave ans+=1 end bus.get_on t end ans+=1 unless bus.empty? puts ans
class Bus attr_accessor :start_time, :num, :max_num, :th_time def initialize max_num, th_time @max_num = max_num @th_time = th_time init_state end def init_state @num = 0 @start_time = nil end def get_on(time) if @num == 0 @start_time = time + @th_time end @num += 1 end def leave?(time) (!@start_time.nil? && @start_time < time) || @num==@max_num end def leave init_state end def empty? @num==0 end end N,c,k = gets.split.map(&:to_i) T = [] N.times{T<<gets.to_i} T.sort! ans = 0 bus=Bus.new(c,k) T.each do |t| if bus.leave?(t) bus.leave ans+=1 end bus.get_on t end ans+=1 unless bus.empty? puts ans
[]
1,422,452
1,422,453
u244257825
ruby
p03785
n, c, k = gets.split.map(&:to_i) ts = n.times.map { gets.to_i }.sort!.reverse! ans = 1 base = ts.first passengers = 1 1.upto(n - 1) do |i| if ts[i] + k <= base || passengers == c ans += 1 base = ts[i] passengers = 0 end passengers += 1 end puts ans
n, c, k = gets.split.map(&:to_i) ts = n.times.map { gets.to_i }.sort!.reverse! ans = 1 base = ts.first passengers = 1 1.upto(n - 1) do |i| if ts[i] + k < base || passengers == c ans += 1 base = ts[i] passengers = 1 else passengers += 1 end end puts ans
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,422,587
1,422,588
u889326464
ruby
p03785
n, c, k = gets.split.map(&:to_i) ts = [] n.times do ts << gets.to_i end ts.sort! # puts ts.inspect ans = 0 cur = 0 while cur < n cur_t = ts[cur] a = ts.bsearch_index { |t| t > cur_t + c } || 10 ** 20 # puts a cur = [cur+c, a].min # puts "#{a} #{cur}" ans += 1 end puts ans
n, c, k = gets.split.map(&:to_i) ts = [] n.times do ts << gets.to_i end ts.sort! ans = 0 cur = 0 while cur < n current_time = ts[cur] a = ts.bsearch_index { |t| t > current_time + k } || 10 ** 20 cur = [cur+c, a].min ans += 1 end puts ans
[ "assignment.variable.change", "identifier.change", "assignment.value.change", "expression.operation.binary.change" ]
1,422,849
1,422,850
u729246375
ruby
p03785
n, c, k = gets.split.map(&:to_i) ts = [] n.times do ts << gets.to_i end ts.sort! # puts ts.inspect ans = 0 cur = 0 while cur < n cur_t = ts[cur] a = ts.bsearch_index { |t| t > cur_t + c } || 10 ** 20 # puts a cur = [cur+c, a].min # puts "#{a} #{cur}" ans += 1 end puts ans
n, c, k = gets.split.map(&:to_i) ts = [] n.times do ts << gets.to_i end ts.sort! # puts ts.inspect ans = 0 cur = 0 while cur < n cur_t = ts[cur] a = ts.bsearch_index { |t| t > cur_t + k } || 10 ** 20 # puts a cur = [cur+c, a].min # puts "#{a} #{cur}" ans += 1 end puts ans
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
1,422,849
1,422,851
u729246375
ruby
p03785
n,c,k=gets.split.map(&:to_i) t=[] n.times.each do t<<gets.to_i end #条件として最初に人が来てからk分たつもしくは乗客がc人になると発車 t.sort! count=0 limit=t[0]+k onbus=1 for i in 1..t.length-1 v=t[i] onbus+=1 if onbus>c || t[i]>=limit count+=1 onbus=1 limit=t[i]+k end end if onbus>0 p count+1 else p count end
n,c,k=gets.split.map(&:to_i) t=[] n.times.each do t<<gets.to_i end #条件として最初に人が来てからk分たつもしくは乗客がc人になると発車 t.sort! count=0 limit=t[0]+k onbus=1 for i in 1..t.length-1 v=t[i] onbus+=1 if onbus>c || t[i]>limit count+=1 onbus=1 limit=t[i]+k end end if onbus>0 p count+1 else p count end
[ "expression.operator.compare.change" ]
1,422,984
1,422,985
u590472228
ruby
p03785
N, C, K = gets.split.map(&:to_i) T = N.times.map{gets.to_i}.sort ans = 0 until T.empty? t = T.shift while !T.empty? && T.first <= t + K && cnt < C T.shift cnt += 1 end ans += 1 end p ans
N, C, K = gets.split.map(&:to_i) T = N.times.map{gets.to_i}.sort ans = 0 until T.empty? t = T.shift cnt = 1 while !T.empty? && T.first <= t + K && cnt < C T.shift cnt += 1 end ans += 1 end p ans
[ "assignment.add" ]
1,423,256
1,423,257
u984479733
ruby
p03785
N, C, K = gets.split.map(&:to_i) T = N.times.map{gets.to_i}.sort ans = 0 until T.empty? t = T.shift while !T.empty? && T.first <= t + k && cnt < C T.shift cnt += 1 end ans += 1 end p ans
N, C, K = gets.split.map(&:to_i) T = N.times.map{gets.to_i}.sort ans = 0 until T.empty? t = T.shift cnt = 1 while !T.empty? && T.first <= t + K && cnt < C T.shift cnt += 1 end ans += 1 end p ans
[ "expression.operation.binary.change" ]
1,423,258
1,423,257
u984479733
ruby
p03785
n,c,k = gets.split.map(&:to_i) t = [] n.times do t << gets.to_i end time = t.sort i = time[0] counter = 1 per = 1 (1..n-1).each do |j| if i+k >= time[j] && c >= per per += 1 elsif counter += 1 per = 1 i = time[j] end end p counter
n,c,k = gets.split.map(&:to_i) t = [] n.times do t << gets.to_i end time = t.sort i = time[0] counter = 1 per = 1 (1..n-1).each do |j| if i+k >= time[j] && c > per per += 1 elsif counter += 1 per = 1 i = time[j] end end p counter
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,423,286
1,423,287
u296101474
ruby
p03785
n,c,k = gets.split.map(&:to_i) t = [] n.times do t << gets.to_i end time = t.sort i = t[0] counter = 1 per = 1 (1..n).each do |j| if i+k >= time[j] && c > sum per += 1 elsif counter += 1 per = 1 i = time[j] end end p counter
n,c,k = gets.split.map(&:to_i) t = [] n.times do t << gets.to_i end time = t.sort i = time[0] counter = 1 per = 1 (1..n-1).each do |j| if i+k >= time[j] && c > per per += 1 elsif counter += 1 per = 1 i = time[j] end end p counter
[ "assignment.value.change", "identifier.change", "control_flow.branch.if.condition.change" ]
1,423,288
1,423,287
u296101474
ruby
p03785
N, C, K = gets.split.map(&:to_i) ts = N.times.map{gets.to_i}.sort ans = 1 capa = 1 time = ts[0] (1...N).each do |i| if capa == C || ts[i] - time >= K ans += 1 capa = 1 time = ts[i] else capa += 1 end end puts ans
N, C, K = gets.split.map(&:to_i) ts = N.times.map{gets.to_i}.sort ans = 1 capa = 1 time = ts[0] (1...N).each do |i| if capa == C || ts[i] - time > K ans += 1 capa = 1 time = ts[i] else capa += 1 end end puts ans
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,424,280
1,424,281
u314396879
ruby
p03785
if __FILE__==$0 rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)} r_i=lambda{|str|str.strip.to_i} dl=" " #空港に到着バスに搭乗 n,c,k=rl_i[gets,dl] #num,ac,ti t=Array.new(n){0} n.times do |x| t[x]=r_i[gets] end #p [c,k] t.sort! bn=1 bc=c bk=k br=t.shift #p [br,br,bn,bc,bk] t.each do |x| bc-=1 bk-=x-br br=x if bc<0 || bk<0 bn+=1 bc=c-1 bk=k end #p [x,br,bn,bc,bk] end #p [t[-1],br,bn,bc,bk] p bn end
if __FILE__==$0 rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)} r_i=lambda{|str|str.strip.to_i} dl=" " #空港に到着バスに搭乗 n,c,k=rl_i[gets,dl] #num,ac,ti t=Array.new(n){0} n.times do |x| t[x]=r_i[gets] end #p [c,k] t.sort! bn=1 bc=c-1 bk=k br=t.shift #p [br,br,bn,bc,bk] t.each do |x| bc-=1 bk-=x-br br=x if bc<0 || bk<0 bn+=1 bc=c-1 bk=k end #p [x,br,bn,bc,bk] end #p [t[-1],br,bn,bc,bk] p bn end
[ "assignment.change" ]
1,424,534
1,424,535
u036059298
ruby
p03785
if __FILE__==$0 rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)} r_i=lambda{|str|str.strip.to_i} dl=" " #空港に到着バスに搭乗 n,c,k=rl_i[gets,dl] #num,ac,ti t=Array.new(n){0} n.times do |x| t[x]=r_i[gets] end #p [c,k] t.sort! bn=1 bc=c bk=k br=t.shift #p [br,br,bn,bc,bk] t.each do |x| bc-=1 bk-=x-br br=x if bc<0 || bk <0 bn+=1 bc=c bk=k end #p [x,br,bn,bc,bk] end #p [t[-1],br,bn,bc,bk] p bn end
if __FILE__==$0 rl_i=lambda{|str,dl|str.strip.split(dl).map(&:to_i)} r_i=lambda{|str|str.strip.to_i} dl=" " #空港に到着バスに搭乗 n,c,k=rl_i[gets,dl] #num,ac,ti t=Array.new(n){0} n.times do |x| t[x]=r_i[gets] end #p [c,k] t.sort! bn=1 bc=c-1 bk=k br=t.shift #p [br,br,bn,bc,bk] t.each do |x| bc-=1 bk-=x-br br=x if bc<0 || bk<0 bn+=1 bc=c-1 bk=k end #p [x,br,bn,bc,bk] end #p [t[-1],br,bn,bc,bk] p bn end
[ "assignment.change" ]
1,424,536
1,424,535
u036059298
ruby
p03791
a=b=1;_,q=`dd`.split;q.map{|x|a,b=a*b%(10**9+7),1+[b,-~x.to_i/2].min};p a
a=b=1;_,*q=`dd`.split;q.map{|x|a,b=a*b%(10**9+7),1+[b,-~x.to_i/2].min};p a
[]
1,425,269
1,425,270
u280667879
ruby
p03791
a=b=1;_,q=`dd`.split;d.map{|x|a,b=a*b%(10**9+7),1+[b,-~x.to_i/2].min};p a
a=b=1;_,*q=`dd`.split;q.map{|x|a,b=a*b%(10**9+7),1+[b,-~x.to_i/2].min};p a
[ "identifier.change" ]
1,425,271
1,425,270
u280667879
ruby
p03795
N = gets.chomp.to_i puts N * 800 - 200 * N / 15
N = gets.chomp.to_i puts N * 800 - 200 * (N / 15)
[ "call.arguments.change" ]
1,425,666
1,425,667
u088211391
ruby
p03795
n = gets.to_i puts 800 * n - (n % 15) * 200
n = gets.to_i puts 800 * n - (n / 15) * 200
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
1,425,808
1,425,809
u333374716
ruby
p03795
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE'] require 'prime' def inpf() a=gets.chomp.split(" ").map(&:to_f)end def inps() a=gets.chomp.split(" ")end def copy(a) Marshal.load(Marshal.dump(a)) end def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end def na(n,d=0) Array.new(n,d)end def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end def inp() a=gets.chomp.split(" ").map(&:to_i)end def r_up(a, b) (a+b-1)/b end def sum(a) a.inject(:+) end def big(a,b) return (a>b)? a:b end def small(a,b) return (a<b)? a:b end n = inp[0] p n+800 - n/15*200
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE'] require 'prime' def inpf() a=gets.chomp.split(" ").map(&:to_f)end def inps() a=gets.chomp.split(" ")end def copy(a) Marshal.load(Marshal.dump(a)) end def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end def na(n,d=0) Array.new(n,d)end def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end def inp() a=gets.chomp.split(" ").map(&:to_i)end def r_up(a, b) (a+b-1)/b end def sum(a) a.inject(:+) end def big(a,b) return (a>b)? a:b end def small(a,b) return (a<b)? a:b end n = inp[0] p n*800 - n/15*200
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
1,425,833
1,425,834
u145123922
ruby
p03795
a=gets.chomp.to_i puts a*800-(a*200)
a=gets.chomp.to_i puts a*800-(a/15*200)
[ "expression.operation.binary.add" ]
1,425,958
1,425,959
u585819925
ruby
p03795
a=gets.chomp.to_i puts a*800-a*200
a=gets.chomp.to_i puts a*800-(a/15*200)
[ "call.arguments.change" ]
1,425,960
1,425,959
u585819925
ruby
p03795
n=gets.to_i puts n*800-200/15
n=gets.to_i puts n*800-n/15*200
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
1,426,020
1,426,021
u706695185
ruby
p03795
N = gets.to_i; p N*200 - (N/15)*200
N = gets.to_i; p N*800 - (N/15)*200
[ "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change" ]
1,426,189
1,426,190
u670503797
ruby
p03795
N = gets.to_i puts 800*N - 200*(N%15)
N = gets.to_i puts 800*N - 200*(N/15)
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
1,426,555
1,426,556
u693378622
ruby
p03797
N,M = gets.chomp.split.map(&:to_i) if N >= M / 2 puts M / 2 else puts (M / 4) + (2 * N / 4) end
N,M = gets.chomp.split.map(&:to_i) if N >= M / 2 puts M / 2 else puts (M + (2 * N)) / 4 end
[ "call.arguments.change" ]
1,428,748
1,428,749
u088211391
ruby
p03797
N,M = gets.chomp.split.map(&:to_i) if N >= M / 2 puts M / 2 else puts (M + N) / 3 end
N,M = gets.chomp.split.map(&:to_i) if N >= M / 2 puts M / 2 else puts (M + (2 * N)) / 4 end
[ "call.arguments.change", "literal.number.integer.change", "expression.operation.binary.change" ]
1,428,750
1,428,749
u088211391
ruby
p03797
n,m=gets.split.map(&:to_i) if n<=m/2 puts n+(m-2*n)/4 else pts m/2 end
n,m=gets.split.map(&:to_i) if n<=m/2 puts n+(m-2*n)/4 else puts m/2 end
[ "identifier.change" ]
1,428,784
1,428,785
u602591412
ruby
p03797
n,m = gets.chomp.split.map(&:to_i) if 2*n >= m puts n else puts n + ((m - 2*n)/4) end
n,m = gets.chomp.split.map(&:to_i) if 2*n >= m puts m/2 else puts n + ((m - 2*n)/4) end
[ "call.arguments.change" ]
1,428,786
1,428,787
u191196346
ruby
p03797
n, m = gets.chomp.split.map(&:to_i) if n >= 2 * m p m / 2 else ans = 0 ans += n m -= 2 * n ans += m / 4 p ans end
n, m = gets.chomp.split.map(&:to_i) if n * 2 >= m p m / 2 else ans = 0 ans += n m -= 2 * n ans += m / 4 p ans end
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
1,428,889
1,428,890
u195257137
ruby
p03797
require 'set'; require 'prime'; require 'pp' INF=Float::INFINITY; MOD=10**9+7 s, c = gets.chomp.split.map(&:to_i) if 2*s >= c # c全部使う puts s else puts s + (c - 2*s) / 4 end
require 'set'; require 'prime'; require 'pp' INF=Float::INFINITY; MOD=10**9+7 s, c = gets.chomp.split.map(&:to_i) if 2*s >= c # c全部使う puts c/2 else puts s + (c - 2*s) / 4 end
[ "call.arguments.change" ]
1,429,210
1,429,211
u524019694
ruby
p03797
require 'set'; require 'prime'; require 'pp' INF=Float::INFINITY; MOD=10**9+7 s, c = gets.chomp.split.map(&:to_i) if 2*s >= c # c全部使う puts s else puts s + (c - 2*s) / 3 end
require 'set'; require 'prime'; require 'pp' INF=Float::INFINITY; MOD=10**9+7 s, c = gets.chomp.split.map(&:to_i) if 2*s >= c # c全部使う puts c/2 else puts s + (c - 2*s) / 4 end
[ "call.arguments.change", "literal.number.integer.change", "expression.operation.binary.change" ]
1,429,212
1,429,211
u524019694
ruby
p03797
# m-2n >=0 -> 残ったmを4つずつでひとつのセットが作れる # m-2n < 0 -> m/2個ぶんだけ作れる n, m = gets.chomp.split.map(&:to_i) if m-2*n>=0 x = m-2*n puts n+x/4 else puts n+m/2 end
# m-2n >=0 -> 残ったmを4つずつでひとつのセットが作れる # m-2n < 0 -> m/2個ぶんだけ作れる n, m = gets.chomp.split.map(&:to_i) if m-2*n>=0 x = m-2*n puts n+x/4 else puts m/2 end
[ "expression.operation.binary.remove" ]
1,429,409
1,429,410
u445624660
ruby
p03797
N, M = gets.split(' ').map(&:to_i) if N * 2 >= M puts M else puts N + (M - 2 * N) / 4 end
N, M = gets.split(' ').map(&:to_i) if N * 2 >= M puts M / 2 else puts N + (M - 2 * N) / 4 end
[ "expression.operation.binary.add" ]
1,429,631
1,429,632
u548834738
ruby
p03797
N, M = gets.split.map(&:to_i) if M <= 2 * N puts N / 2 else puts N + (M - 2 * N) / 4 end
N, M = gets.split.map(&:to_i) if M <= 2 * N puts M / 2 else puts N + (M - 2 * N) / 4 end
[ "call.arguments.change", "expression.operation.binary.change" ]
1,429,714
1,429,715
u627981707
ruby
p03798
n = gets.chomp.to_i s = gets.chomp.split('') def next_animal(last2_animal, last_animal, last_o_or_x) if last2_animal == 'S' if last_animal == 'S' if last_o_or_x == 'o' return 'S' else return 'W' end else if last_o_or_x == 'o' return 'W' else return 'S' end end else if last_animal == 'S' if last_o_or_x == 'o' return 'W' else return 'S' end else if last_o_or_x == 'o' return 'S' else return 'W' end end end end def check(ans, s, n) if next_animal(ans[n-2], ans[n-1], s[n-1]) == ans[0] && next_animal(ans[n-1], ans[0], s[0] == ans[1]) puts ans.join('') exit end end ['SS', 'SW', 'WS', 'WW'].each do |uu| ans = [] fi, se = uu.split('') ans.push(fi) ans.push(se) 2.upto(n-1) do |i| ans.push(next_animal(ans[i-2], ans[i-1], s[i-1])) end check(ans, s, n) end p -1
n = gets.chomp.to_i s = gets.chomp.split('') def next_animal(last2_animal, last_animal, last_o_or_x) if last2_animal == 'S' if last_animal == 'S' if last_o_or_x == 'o' return 'S' else return 'W' end else if last_o_or_x == 'o' return 'W' else return 'S' end end else if last_animal == 'S' if last_o_or_x == 'o' return 'W' else return 'S' end else if last_o_or_x == 'o' return 'S' else return 'W' end end end end def check(ans, s, n) if next_animal(ans[n-2], ans[n-1], s[n-1]) == ans[0] && next_animal(ans[n-1], ans[0], s[0]) == ans[1] puts ans.join('') exit end end ['SS', 'SW', 'WS', 'WW'].each do |uu| ans = [] fi, se = uu.split('') ans.push(fi) ans.push(se) 2.upto(n-1) do |i| ans.push(next_animal(ans[i-2], ans[i-1], s[i-1])) end check(ans, s, n) end p -1
[ "control_flow.branch.if.condition.change" ]
1,430,017
1,430,018
u195257137
ruby
p03798
n = gets.chomp.to_i s = gets.chomp.split('') def next_animal(last2_animal, last_animal, last_o_or_x) if last2_animal == 'S' if last_animal == 'S' if last_o_or_x == 'o' return 'S' else return 'W' end else if last_o_or_x == 'o' return 'W' else return 'S' end end else if last_animal == 'S' if last_o_or_x == 'o' return 'W' else return 'S' end else if last_o_or_x == 'o' return 'S' else return 'W' end end end end def check(ans, s, n) if next_animal(ans[n-2], ans[n-1], s[n-1]) == ans[0] && next_animal(ans[n-1], ans[0], s[0] == ans[1]) puts ans.join('') exit end end ['SS', 'SW', 'SS', 'WW'].each do |uu| ans = [] fi, se = uu.split('') ans.push(fi) ans.push(se) 2.upto(n-1) do |i| ans.push(next_animal(ans[i-2], ans[i-1], s[i-1])) end check(ans, s, n) end p -1
n = gets.chomp.to_i s = gets.chomp.split('') def next_animal(last2_animal, last_animal, last_o_or_x) if last2_animal == 'S' if last_animal == 'S' if last_o_or_x == 'o' return 'S' else return 'W' end else if last_o_or_x == 'o' return 'W' else return 'S' end end else if last_animal == 'S' if last_o_or_x == 'o' return 'W' else return 'S' end else if last_o_or_x == 'o' return 'S' else return 'W' end end end end def check(ans, s, n) if next_animal(ans[n-2], ans[n-1], s[n-1]) == ans[0] && next_animal(ans[n-1], ans[0], s[0]) == ans[1] puts ans.join('') exit end end ['SS', 'SW', 'WS', 'WW'].each do |uu| ans = [] fi, se = uu.split('') ans.push(fi) ans.push(se) 2.upto(n-1) do |i| ans.push(next_animal(ans[i-2], ans[i-1], s[i-1])) end check(ans, s, n) end p -1
[ "control_flow.branch.if.condition.change", "literal.string.change" ]
1,430,019
1,430,018
u195257137
ruby
p03797
s,c = gets.chomp.split(' ').map{|n| n.to_i} if c <= s * 2 p c - s * 2 else p s + (c - s * 2) / 4 end
s,c = gets.chomp.split(' ').map{|n| n.to_i} if c < s * 2 p c / 2 else p s + (c - s * 2) / 4 end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
1,430,105
1,430,106
u698501698
ruby
p03797
s,c=gets.split s=s.to_i c=c.to_i if 2*s>=c puts s else k=c-2*s puts s+k/4 end
s,c=gets.split s=s.to_i c=c.to_i if 2*s>=c puts c/2 else k=c-2*s puts s+k/4 end
[ "call.arguments.change" ]
1,430,289
1,430,290
u506544056
ruby
p03798
n = gets.to_i s = gets pattern = [{"SS"=>'S', "SW"=>'W', "WS"=>'W', "WW"=>'S'}, {"SS"=>'W', "SW"=>'S', "WS"=>'S', "WW"=>'W'}] pt = (s[0] == 'o') ? 0 : 1 keys = ["SS", "SW", "WS", "WW"] p keys ok = false 4.times do |i| ans = keys[i].dup 1.upto(n - 1) do |j| if s[j] == 'o' ans << pattern[0][ans[-2]+ans[-1]] else ans << pattern[1][ans[-2]+ans[-1]] end end if pattern[pt][keys[i]] == ans[n - 1] && ans[n] == ans[0] ok = true puts ans[0..(n - 1)] break end end puts (-1) unless ok
n = gets.to_i s = gets pattern = [{"SS"=>'S', "SW"=>'W', "WS"=>'W', "WW"=>'S'}, {"SS"=>'W', "SW"=>'S', "WS"=>'S', "WW"=>'W'}] pt = (s[0] == 'o') ? 0 : 1 keys = ["SS", "SW", "WS", "WW"] ok = false 4.times do |i| ans = keys[i].dup 1.upto(n - 1) do |j| if s[j] == 'o' ans << pattern[0][ans[-2]+ans[-1]] else ans << pattern[1][ans[-2]+ans[-1]] end end if pattern[pt][keys[i]] == ans[n - 1] && ans[n] == ans[0] ok = true puts ans[0..(n - 1)] break end end puts (-1) unless ok
[ "call.remove" ]
1,430,344
1,430,345
u601070043
ruby
p03798
n,s=`dd`.split;n=n.to_i;%w(SS SW WS WW).find{|_|a=_.bytes;2.upto(n+1){|i|a[i]=a[i-2]^((a[i-1]==?W)^(s[~-i%n]==?o)?0:4)};a[0,2]==a[n,2]&&$><<a[0..-3].map(&:chr)*''}||(p -1)
n,s=`dd`.split;n=n.to_i;%w(SS SW WS WW).find{|_|a=_.bytes;2.upto(n+1){|i|a[i]=a[i-2]^((a[i-1]==87)^(s[~-i%n]==?o)?0:4)};a[0,2]==a[n,2]&&$><<a[0..-3].map(&:chr)*''}||(p -1)
[ "assignment.value.change", "control_flow.branch.if.condition.change" ]
1,430,368
1,430,369
u280667879
ruby
p03798
n,s=`dd`.split;n=n.to_i;%w(SS SW WS WW).find{|_|a=_.chars;2.upto(n+1){|i|a[i]=(a[i-1]==?W)^(a[i-2]==?W)^(s[~-i%n]==?o)??S:?W};a[0,2]==a[n,2]&&$><<a[0..-3]}||(p -1)
n,s=`dd`.split;n=n.to_i;%w(SS SW WS WW).find{|_|a=_.chars;2.upto(n+1){|i|a[i]=(a[i-1]==?W)^(a[i-2]==?W)^(s[~-i%n]==?o)??S:?W};a[0,2]==a[n,2]&&$><<a[0..-3]*''}||(p -1)
[ "expression.operation.binary.add" ]
1,430,370
1,430,371
u280667879
ruby
p03798
#!/usr/bin/ruby n=gets.to_i s=gets.chomp [83,87].repeated_permutation(2).find{|_| a=_.dup 2.upto(n+1){|i| a[i]=a[i-2]^((a[i-1]==87)^(s[i-1]==?x) ? 4 : 0) } $><<a[0..-3].map(&:chr)*''if a[0]==a[n]&&a[1]==a[n+1] }||(p -1)
#!/usr/bin/ruby n=gets.to_i s=gets.chomp [83,87].repeated_permutation(2).find{|_| a=_.dup 2.upto(n+1){|i| a[i]=a[i-2]^((a[i-1]==87)^(s[~-i%n]==?x) ? 4 : 0) } $><<a[0..-3].map(&:chr)*''if a[0]==a[n]&&a[1]==a[n+1] }||(p -1)
[ "assignment.value.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change", "identifier.replace.add", "literal.replace.remove" ]
1,430,372
1,430,373
u280667879
ruby
p03799
n,m = gets.chomp.split(' ').map(&:to_i) ans = 0 if 2 * n <= m ans += n m -= 2 * n ans += m/4 else ans = m/3 end puts ans
n,m = gets.chomp.split(' ').map(&:to_i) ans = 0 if 2 * n <= m ans += n m -= 2 * n ans += m/4 else ans = m/2 end puts ans
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
1,430,428
1,430,429
u059126963
ruby
p03799
n,m = gets.chomp.split(' ').map(&:to_i) ans = 0 if 2 * n <= m ans += n m -= 2 * n ans += m/4 else ans = m/4 end puts ans
n,m = gets.chomp.split(' ').map(&:to_i) ans = 0 if 2 * n <= m ans += n m -= 2 * n ans += m/4 else ans = m/2 end puts ans
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
1,430,430
1,430,429
u059126963
ruby
p03797
n, m = gets.chomp.split(" ") n = n.to_i # s m = m.to_i # c # Scc num_c = n * 2 + m if (num_c / 4) * 2 > m puts m else puts num_c / 4 end
n, m = gets.chomp.split(" ") n = n.to_i # s m = m.to_i # c # Scc num_c = n * 2 + m #p num_c ans = num_c / 4 if ans * 2 > m puts m / 2 else puts num_c / 4 end
[ "control_flow.branch.if.condition.change" ]
1,431,165
1,431,164
u031564375
ruby