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
p03592
n, m, k = gets.split.map(&:to_i) n+1.times do |r| m+1.times do |c| if r * m + c * n - 2 * r * c == k puts "Yes" exit end end end puts "No"
n, m, k = gets.split.map(&:to_i) (n + 1).times do |r| (m + 1).times do |c| if r * m + c * n - 2 * r * c == k puts "Yes" exit end end end puts "No"
[]
1,292,333
1,292,334
u706695185
ruby
p03592
n, m, k = gets.split.map &:to_i (0..n).each do |i| (0..m).each do |i| if i*j+(n-i)*(m-j) == k puts :Yes exit end end end puts :No
n, m, k = gets.split.map &:to_i (0..n).each do |i| (0..m).each do |j| if i*j+(n-i)*(m-j) == k puts :Yes exit end end end puts :No
[ "identifier.change", "io.output.change" ]
1,292,603
1,292,604
u976045235
ruby
p03592
N, M, K = gets.chop.split.map(&:to_i) flag = false for r in 0..N do for c in 0..M if r * M + N * c - 2 * r * c == K flag = true end end end puts ok ? "Yes" : "No"
N, M, K = gets.chop.split.map(&:to_i) flag = false for r in 0..N do for c in 0..M if r * M + N * c - 2 * r * c == K flag = true end end end puts flag ? "Yes" : "No"
[ "identifier.change", "control_flow.branch.if.condition.change" ]
1,292,640
1,292,641
u634209474
ruby
p03592
N,M,K = gets.split.map &:to_i; puts (0...N).any?{ |n| (0...M).any?{ |m| n*M - 2*n*m + m*N == K } } ? "Yes" : "No"
N,M,K = gets.split.map &:to_i; puts (0..N).any?{ |n| (0..M).any?{ |m| n*M - 2*n*m + m*N == K } } ? "Yes" : "No"
[ "control_flow.branch.if.condition.change" ]
1,292,682
1,292,683
u670503797
ruby
p03592
n,m,k=gets.chomp.split.map(&:to_i); for x in 1..n for y in 1..m if n*y+m*x-2*x*y==k then puts "Yes" exit end end end puts "No"
n,m,k=gets.chomp.split.map(&:to_i); for x in 0..n for y in 0..m if n*y+m*x-2*x*y==k then puts "Yes" exit end end end puts "No"
[ "literal.number.integer.change" ]
1,292,737
1,292,738
u411903982
ruby
p03592
N, M, K = gets.split.map(&:to_i) ok = false (0..N).each{|i| (0..M).each{|j| ok = true if M*i + N*j - i*j == K } } puts ok ? "Yes" : "No"
N, M, K = gets.split.map(&:to_i) ok = false (0..N).each{|i| (0..M).each{|j| # puts "#{i} #{j} #{M*i + N*j - i*j} " ok = true if M*i + N*j - 2*i*j == K } } puts ok ? "Yes" : "No"
[ "control_flow.branch.if.condition.change" ]
1,293,874
1,293,875
u693378622
ruby
p03592
n,m,k=gets.split.map &:to_i c=false (n+1).times do |i| (m+1).times do |j| g = m*i + n*j - i*j c = true if k == g end end puts c ? :Yes : :No
n,m,k=gets.split.map &:to_i c=false (n+1).times do |i| (m+1).times do |j| g = m*i + n*j - 2*i*j c = true if k == g end end puts c ? :Yes : :No
[ "assignment.change" ]
1,293,898
1,293,899
u554838392
ruby
p03592
n,m,c=gets.split.map &:to_i a=[] (n+1).times do |i| (m+1).times do |j| a<< m*i+n*j-i*j end end puts a.include?(c) ? :Yes : :No
n,m,c=gets.split.map &:to_i a=[] (n+1).times do |i| (m+1).times do |j| a<< m*i+n*j-i*j*2 end end puts a.include?(c) ? :Yes : :No
[ "expression.operation.binary.add" ]
1,293,900
1,293,901
u554838392
ruby
p03592
N,M,K=gets.split.map &:to_i;puts (0..N).any?{|k|x=K-k*M;y=N-2*k;y==0?x==0:(l=x/y;x%y==0&&l<=M)}?:Yes: :No
N,M,K=gets.split.map &:to_i;puts (0..N).any?{|k|x=K-k*M;y=N-2*k;y==0?x==0:(l=x/y;x%y==0&&0<=l&&l<=M)}?:Yes: :No
[ "control_flow.branch.if.condition.change" ]
1,293,956
1,293,957
u280667879
ruby
p03592
eval'N,M,K='+`tr ' ' ,`;-~N.times{|n|-~M.times{|m|n*M+N*m-2*n*m==K&&$.=1}};$><<[:No,:Yes][$.]
eval'N,M,K='+`tr ' ' ,`;(-~N).times{|n|(-~M).times{|m|n*M+N*m-2*n*m==K&&$.=1}};$><<[:No,:Yes][$.]
[]
1,293,974
1,293,975
u283869437
ruby
p03592
eval"puts (0..n=%d).any?{|i|(0..m=%d).any?{|j|n*i+m*j-2*i*j==%d}}?:Yes: :No"%gets.split
eval"puts (0..n=%d).any?{|i|(0..m=%d).any?{|j|n*j+m*i-2*i*j==%d}}?:Yes: :No"%gets.split
[ "literal.string.change", "call.arguments.change", "expression.operation.binary.change" ]
1,294,037
1,294,038
u711705317
ruby
p03592
N, M, K = gets.split.map &:to_i puts (0..N/2).any?{|n| (0..M/2).any?{|m| area = n * m + (N - n) * (M - m) area == K } } ? :Yes : :No
N, M, K = gets.split.map &:to_i puts (0..N).any?{|n| (0..M).any?{|m| area = n * m + (N - n) * (M - m) area == K } } ? :Yes : :No
[ "expression.operation.binary.remove" ]
1,294,039
1,294,040
u711705317
ruby
p03593
def halt(ans) puts ans exit end n, m = gets.split.map(&:to_i) hash = n.times.map { gets.chomp }.flatten.inject({}) { |sum, s| sum.merge(s.each_char.group_by(&:itself).inject({}) { |h, (k, v)| h[k] = v.count; h }) { |_,a,b| a + b } } remain = (n / 2) * (m / 2) hash.each do |c, count| i = count / 4 hash[c] -= i * 4 remain -= i end halt 'No' if remain != 0 odd = hash.find { |k,v| v.odd? } hash[odd.first] -= 1 unless odd.nil? halt 'No' if hash.any? { |k,v| v.odd? } halt 'Yes'
def halt(ans) puts ans exit end n, m = gets.split.map(&:to_i) hash = n.times.map { gets.chomp }.flatten.inject({}) { |sum, s| sum.merge(s.each_char.group_by(&:itself).inject({}) { |h, (k, v)| h[k] = v.count; h }) { |_,a,b| a + b } } remain = (n / 2) * (m / 2) hash.each do |c, count| i = count / 4 hash[c] -= i * 4 remain -= i end halt 'No' if remain > 0 odd = hash.find { |k,v| v.odd? } hash[odd.first] -= 1 unless odd.nil? halt 'No' if hash.any? { |k,v| v.odd? } halt 'Yes'
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,294,685
1,294,686
u214983738
ruby
p03597
n=gets.to_i a=gets.to_i print("#{n-a}\n")
n=gets.to_i a=gets.to_i print("#{n*n-a}\n")
[ "literal.string.change", "call.arguments.change" ]
1,294,823
1,294,824
u769530239
ruby
p03597
num = readlines all = num[0].to_i whi = num[1].to_i puts all ^ 2 - whi
num = readlines all = num[0].to_i whi = num[1].to_i puts all ** 2 - whi
[ "call.arguments.change", "expression.operation.binary.change" ]
1,295,328
1,295,329
u259280397
ruby
p03597
num = readlines all = num[0].to_i whi = num[1].to_i puts all * 2 - whi
num = readlines all = num[0].to_i whi = num[1].to_i puts all ** 2 - whi
[ "call.arguments.change", "expression.operation.binary.change" ]
1,295,330
1,295,329
u259280397
ruby
p03597
num = readlines all = num[0].to_i whi = num[1].to_i puts all ^ 2 - whi
num = readlines all = num[0].to_i whi = num[1].to_i puts all * all - whi
[]
1,295,328
1,295,331
u259280397
ruby
p03597
num = readlines all = num[0].to_i whi = num[1].to_i puts all * 2 - whi
num = readlines all = num[0].to_i whi = num[1].to_i puts all * all - whi
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "expression.operation.binary.change" ]
1,295,330
1,295,331
u259280397
ruby
p03597
a=gets.to_i b=gets.to_ipu puts a**2-b
a=gets.to_i b=gets.to_i puts a**2-b
[ "assignment.value.change", "identifier.change" ]
1,295,679
1,295,680
u831999711
ruby
p03598
n=gets.to_i k=gets.to_i b=gets.split.map(&:to_i) l=0 b.each{|x|l+=x<k/2? x:k-x} p l*2
_=gets.to_i k=gets.to_i b=gets.split.map(&:to_i) l=0 b.each{|x|l+=x<=k/2? x:k-x} p l*2
[ "assignment.variable.change", "identifier.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,295,836
1,295,837
u142949268
ruby
p03598
N = gets.chomp.to_i K = gets.chomp.to_i x = gets.chomp.split.map(&:to_i) ans = 0 N.times do |i| if (2 * (K - x[i])) < (2 * x[i]) ans += 2 * (K - x[i]) else ans *= 2 * x[i] end end puts ans
N = gets.chomp.to_i K = gets.chomp.to_i x = gets.chomp.split.map(&:to_i) ans = 0 N.times do |i| if (2 * (K - x[i]) < 2 * x[i]) ans += 2 * (K - x[i]) else ans += 2 * x[i] end end puts ans
[ "control_flow.branch.if.condition.change", "expression.operator.change" ]
1,296,016
1,296,018
u552761221
ruby
p03593
H,W = gets.split.map(&:to_i) hash = Hash.new(0) H.times{gets.chomp.chars{|c| hash[c]+=1}} ar = hash.map{|k,v| v} need4 = H/2*W/2 #かけ4する前 need2 = (H%2)*(W/2)+(W%2)*(H/2) #かけ2する前 #のこるのはセーフなので1はいいや #p need4, need2 while need4!=0 || need2!=0 do maxidx = ar.index(ar.max) if need4 > 0 then if ar[maxidx] >= 4 then ar[maxidx] -= 4 need4 -=1 else puts "No" exit end elsif need2 > 0 then if ar[maxidx] >= 2 then ar[maxidx] -= 2 need2 -=1 else puts "No" exit end end end puts "Yes" #puts ar
H,W = gets.split.map(&:to_i) hash = Hash.new(0) H.times{gets.chomp.chars{|c| hash[c]+=1}} ar = hash.map{|k,v| v} need4 = (H/2)*(W/2) #かけ4する前 need2 = (H%2)*(W/2)+(W%2)*(H/2) #かけ2する前 #のこるのはセーフなので1はいいや while need4!=0 || need2!=0 do maxidx = ar.index(ar.max) if need4 > 0 then if ar[maxidx] >= 4 then ar[maxidx] -= 4 need4 -=1 else puts "No" exit end elsif need2 > 0 then if ar[maxidx] >= 2 then ar[maxidx] -= 2 need2 -=1 else puts "No" exit end end end puts "Yes"
[]
1,296,080
1,296,081
u397763977
ruby
p03598
gets k=gets.to_i puts gets.split.map(&:to_i).map{|x| [x,k-x].min}.inject(&:+)
gets k=gets.to_i puts 2*gets.split.map(&:to_i).map{|x| [x,k-x].min}.inject(&:+)
[ "expression.operation.binary.add" ]
1,296,504
1,296,505
u056944756
ruby
p03598
N = gets.to_i K = gets.to_i X = gets.split.map(&:to_i) ans = 0 X.each do |x| if x < K/2 ans += 2*x else ans += 2*(K-x) end end print ans
N = gets.to_i K = gets.to_i X = gets.split.map(&:to_i) ans = 0 X.each do |x| if x <= K/2 ans += 2*x else ans += 2*(K-x) end end print ans
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,296,506
1,296,507
u118284895
ruby
p03598
require 'pry' n = gets.chomp.to_i k = gets.chomp.to_i array = gets.chomp.split(' ').map(&:to_i) sum = 0 array.each do | x | if x > k - x sum += (k - x) * 2 else sum += x * 2 end end print(sum)
n = gets.chomp.to_i k = gets.chomp.to_i array = gets.chomp.split(' ').map(&:to_i) sum = 0 array.each do | x | if x > k - x sum += (k - x) * 2 else sum += x * 2 end end print(sum)
[ "call.remove" ]
1,296,812
1,296,813
u780069703
ruby
p03598
n,k,*a=`dd`.split.map &:to_i;r=0;a.map{|e|r+=[k-e,e].min};p r**2
n,k,*a=`dd`.split.map &:to_i;r=0;a.map{|e|r+=[k-e,e].min};p r*2
[ "call.arguments.change" ]
1,296,864
1,296,865
u280667879
ruby
p03598
n,k,*a=`dd`.split.map &:to_i;r=0;a.map{|e|r+=[k-e,e].min};p r
n,k,*a=`dd`.split.map &:to_i;r=0;a.map{|e|r+=[k-e,e].min};p r*2
[]
1,296,866
1,296,865
u280667879
ruby
p03598
n,k,*a=gets.split.map &:to_i;r=0;a.map{|e|r+=[k-e,e].min};p r
n,k,*a=`dd`.split.map &:to_i;r=0;a.map{|e|r+=[k-e,e].min};p r*2
[ "assignment.value.change" ]
1,296,867
1,296,865
u280667879
ruby
p03599
a,b,c,d,e,f = gets.split.map(&:to_i) dp = Array.new(f+1).map{Array.new(f/2+1,false)} dp[0][0] = true dp.each_with_index do |x,i| x.each_with_index do |y,j| next unless y dp[i+100*a][j] = true if i + 100*a + j <= f dp[i+100*b][j] = true if i + 100*b + j <= f next if i == 0 dp[i][j+c] = true if 100 * (j+c) / i.to_f <= e && i + j + c <= f dp[i][j+d] = true if 100 * (j+d) / i.to_f <= e && i + j + d <= f end end max = 0 ans = "0 0" dp.each_with_index do |x,i| next unless r = x.rindex(true) if (z = 100 * r / (i + r).to_f) > max max = z ans = "#{i+r} #{r}" end end puts ans
a,b,c,d,e,f = gets.split.map(&:to_i) dp = Array.new(f+1).map{Array.new(f/2+1,false)} dp[0][0] = true dp.each_with_index do |x,i| x.each_with_index do |y,j| next unless y dp[i+100*a][j] = true if i + 100*a + j <= f dp[i+100*b][j] = true if i + 100*b + j <= f next if i == 0 dp[i][j+c] = true if 100 * (j+c) / i.to_f <= e && i + j + c <= f dp[i][j+d] = true if 100 * (j+d) / i.to_f <= e && i + j + d <= f end end max = 0 ans = "#{100*a} 0" dp.each_with_index do |x,i| next unless r = x.rindex(true) if (z = 100 * r / (i + r).to_f) > max max = z ans = "#{i+r} #{r}" end end puts ans
[ "literal.string.change", "assignment.value.change" ]
1,297,260
1,297,261
u692254521
ruby
p03599
=begin -------------- A = 100*A 水 B = 100*B 水 C,D = 1回の投入可能砂糖量 E = 100(g)あたりに溶かすことのできる砂糖量 F = ビーカー許容量(水 + 砂糖 = 総質量) sugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙) water = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙) sum = water[i]とsugar[j]の総質量 pos = water[i] に溶かせる砂糖量 con = sugar[j]*100 / (sugar[j] + water[i]) の砂糖濃度(%) ans = 答え -------------- =end A,B,C,D,E,F = gets.split.map(&:to_i); tmp = {}; tmp[:waters] = []; (0..30).each{|i| (0..30).each{|j| x = (100*A*i) + (100*B*j); tmp[:waters] << x if x <= F; } } tmp[:waters].sort!.uniq!; tmp[:sugars] = [] (0..30).each{|i| (0..30).each{|j| y = C * i + D * j; tmp[:sugars] << y if y <= F; } } tmp[:sugars].sort!.uniq!; sum_ans = 0; sugar_ans = 0; dif = -1; con = 0.0; tmp[:waters].each{|w| pos = w / 100 * E; tmp[:sugars].each{|s| sum = w + s; next if pos < s || F < sum con = (s*100) / (s + w).to_f; if dif < con sum_ans = sum; sugar_ans = s; dif = con; end } } puts "#{sum_ans} #{sugar_ans}"
=begin -------------- A = 100*A 水 B = 100*B 水 C,D = 1回の投入可能砂糖量 E = 100(g)あたりに溶かすことのできる砂糖量 F = ビーカー許容量(水 + 砂糖 = 総質量) sugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙) water = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙) sum = water[i]とsugar[j]の総質量 pos = water[i] に溶かせる砂糖量 con = sugar[j]*100 / (sugar[j] + water[i]) の砂糖濃度(%) ans = 答え -------------- =end A,B,C,D,E,F = gets.split.map(&:to_i); tmp = {}; tmp[:waters] = []; (0..30).each{|i| (0..30).each{|j| x = (100*A*i) + (100*B*j); tmp[:waters] << x if x <= F; } } tmp[:waters].sort!.uniq!; tmp[:sugars] = [] (0..100).each{|i| (0..100).each{|j| y = C * i + D * j; tmp[:sugars] << y if y <= F; } } tmp[:sugars].sort!.uniq!; sum_ans = 0; sugar_ans = 0; dif = -1; con = 0.0; tmp[:waters].each{|w| pos = w / 100 * E; tmp[:sugars].each{|s| sum = w + s; next if pos < s || F < sum con = (s*100) / (s + w).to_f; if dif < con sum_ans = sum; sugar_ans = s; dif = con; end } } puts "#{sum_ans} #{sugar_ans}"
[ "literal.number.integer.change" ]
1,297,329
1,297,330
u682209098
ruby
p03599
A,B,C,D,E,F = gets.split.map(&:to_i) G = Hash.new(false) SugerWater = Struct.new(:a,:b,:c,:d) do def weight water + suger end def water (a*A + b*B)*100 end def suger c*C + d*D end def key water*100+suger end def concentration suger*100.0 / weight end def is_dissolved water * E >= suger * 100 end def is_valid if G[key] false else G[key] = true is_dissolved && weight <= F end end def values [A,B,C,D,E,F,a,b,c,d,weight,suger,water,concentration,is_dissolved] end def candidates [ SugerWater.new(a+1,b,c,d), SugerWater.new(a,b+1,c,d), SugerWater.new(a,b,c+1,d), SugerWater.new(a,b,c,d+1), ].select(&:is_valid) end end root = SugerWater.new(0,0,0,0) Q = [root] weight = 0 suger = 0 concentration = 0 until Q.empty? node = Q.shift if concentration < node.concentration concentration = node.concentration weight = node.weight suger = node.suger end node.candidates.each{ |c| Q.push(c) } end puts [weight,suger].join(" ")
A,B,C,D,E,F = gets.split.map(&:to_i) G = Hash.new(false) SugerWater = Struct.new(:a,:b,:c,:d) do def weight water + suger end def water (a*A + b*B)*100 end def suger c*C + d*D end def key water*100+suger end def concentration suger*100.0 / weight end def is_dissolved water * E >= suger * 100 end def is_valid if G[key] false else G[key] = true is_dissolved && weight <= F end end def values [A,B,C,D,E,F,a,b,c,d,weight,suger,water,concentration,is_dissolved] end def candidates [ SugerWater.new(a+1,b,c,d), SugerWater.new(a,b+1,c,d), SugerWater.new(a,b,c+1,d), SugerWater.new(a,b,c,d+1), ].select(&:is_valid) end end root = SugerWater.new(0,0,0,0) Q = [root] weight = 0 suger = 0 concentration = -1 until Q.empty? node = Q.shift if concentration < node.concentration concentration = node.concentration weight = node.weight suger = node.suger end node.candidates.each{ |c| Q.push(c) } end puts [weight,suger].join(" ")
[ "assignment.value.change", "expression.operation.unary.add" ]
1,297,807
1,297,808
u106964380
ruby
p03599
a, b, c, d, e, f = gets.split.map(&:to_i) a *= 100 b *= 100 waters = [] 0.upto(30) do |a_count| 0.upto(30) do |b_count| amount = a * a_count + b * b_count if amount <= f waters << amount else break end end end waters.uniq! answers = [0, 0, 0.0] waters.each do |water| max_sugar = water / 100 * e 0.upto(3000) do |c_count| c_sugar = c * c_count break if water + c_sugar > f break if c_sugar > max_sugar d_sugar_max_op1 = max_sugar - c_sugar d_sugar_max_op2 = f - (water + c_sugar) d_sugar_max = [d_sugar_max_op1, d_sugar_max_op2].min d_count = d_sugar_max / d d_sugar = [d * d_count, 0].max sugar_total = c_sugar + d_sugar sugar_percentage = (sugar_total * 100.0) / (water + sugar_total) if answers[2] < sugar_percentage answers[0] = water + sugar_total answers[1] = sugar_total answers[2] = sugar_percentage end end end puts "#{answers[0]} #{answers[1]}"
a, b, c, d, e, f = gets.split.map(&:to_i) a *= 100 b *= 100 waters = [] 0.upto(30) do |a_count| 0.upto(30) do |b_count| amount = a * a_count + b * b_count if amount <= f waters << amount else break end end end waters.uniq! answers = [a, 0, 0.0] waters.each do |water| max_sugar = water / 100 * e 0.upto(3000) do |c_count| c_sugar = c * c_count break if water + c_sugar > f break if c_sugar > max_sugar d_sugar_max_op1 = max_sugar - c_sugar d_sugar_max_op2 = f - (water + c_sugar) d_sugar_max = [d_sugar_max_op1, d_sugar_max_op2].min d_count = d_sugar_max / d d_sugar = [d * d_count, 0].max sugar_total = c_sugar + d_sugar sugar_percentage = (sugar_total * 100.0) / (water + sugar_total) if answers[2] < sugar_percentage answers[0] = water + sugar_total answers[1] = sugar_total answers[2] = sugar_percentage end end end puts "#{answers[0]} #{answers[1]}"
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
1,298,025
1,298,024
u653737129
ruby
p03599
# A, B 水 100g単位 # C, D 砂糖 # E 100g の水に溶ける砂糖の量 # F ビーカーに入る砂糖水の重さ a, b, c, d, e, f = gets.split.map(&:to_i) a *= 100 b *= 100 max_concentration = 0.0 ans = [0, 0] 0.upto(f/a) do |na| 0.upto((f - a*na)/b) do |nb| 0.upto((f - a*na - b*nb)/c) do |nc| 0.upto((f - a*na - b*nb - c*nc)/d) do |nd| water = a*na + b*nb sugar = c*nc + d*nd break if water == 0 || sugar.fdiv(water) > e.fdiv(100) concentration = (100*sugar).fdiv(water+sugar) if concentration > max_concentration ans = [water + sugar, sugar] max_concentration = concentration end end end end end puts ans.join(' ')
# A, B 水 100g単位 # C, D 砂糖 # E 100g の水に溶ける砂糖の量 # F ビーカーに入る砂糖水の重さ a, b, c, d, e, f = gets.split.map(&:to_i) a *= 100 b *= 100 max_concentration = 0.0 ans = [a, 0] 0.upto(f/a) do |na| 0.upto((f - a*na)/b) do |nb| 0.upto((f - a*na - b*nb)/c) do |nc| 0.upto((f - a*na - b*nb - c*nc)/d) do |nd| water = a*na + b*nb sugar = c*nc + d*nd break if water == 0 || sugar.fdiv(water) > e.fdiv(100) concentration = (100*sugar).fdiv(water+sugar) if concentration > max_concentration ans = [water + sugar, sugar] max_concentration = concentration end end end end end puts ans.join(' ')
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove" ]
1,298,206
1,298,207
u321226359
ruby
p03599
# A, B 水 100g単位 # C, D 砂糖 # E 100g の水に溶ける砂糖の量 # F ビーカーに入る砂糖水の重さ a, b, c, d, e, f = gets.split.map(&:to_i) a *= 100 b *= 100 max_concentration = 0.0 ans = nil 0.upto(f/a) do |na| 0.upto((f - a*na)/b) do |nb| 0.upto((f - a*na - b*nb)/c) do |nc| 0.upto((f - a*na - b*nb - c*nc)/d) do |nd| water = a*na + b*nb sugar = c*nc + d*nd break if water == 0 || sugar.fdiv(water) > e.fdiv(100) concentration = (100*sugar).fdiv(water+sugar) if concentration > max_concentration ans = [water + sugar, sugar] max_concentration = concentration end end end end end puts ans.join(' ')
# A, B 水 100g単位 # C, D 砂糖 # E 100g の水に溶ける砂糖の量 # F ビーカーに入る砂糖水の重さ a, b, c, d, e, f = gets.split.map(&:to_i) a *= 100 b *= 100 max_concentration = 0.0 ans = [a, 0] 0.upto(f/a) do |na| 0.upto((f - a*na)/b) do |nb| 0.upto((f - a*na - b*nb)/c) do |nc| 0.upto((f - a*na - b*nb - c*nc)/d) do |nd| water = a*na + b*nb sugar = c*nc + d*nd break if water == 0 || sugar.fdiv(water) > e.fdiv(100) concentration = (100*sugar).fdiv(water+sugar) if concentration > max_concentration ans = [water + sugar, sugar] max_concentration = concentration end end end end end puts ans.join(' ')
[ "assignment.value.change", "literal.array.change" ]
1,298,208
1,298,207
u321226359
ruby
p03599
A,B,C,D,E,F = gets.split.map(&:to_i) W = Array.new(F + 1); W[0] = 0 S = Array.new(F + 1); S[0] = 0 (0 .. F).each do |w| W[w] = 1 if w - (100 * A) >= 0 && W[w - (100 * A)] W[w] = 1 if w - (100 * B) >= 0 && W[w - (100 * B)] end (0 .. F).each do |s| S[s] = 1 if s - C >= 0 && S[s - C] S[s] = 1 if s - D >= 0 && S[s - D] end q = 0.0 q0 = (E * 100).to_f / (100 + E) ws = [0, 0] (0 .. F).each do |w| (0 .. F).each do |s| if W[w] && S[s] && s + w <= F v = (s * 100).to_f / (s + w) if v > q && v <= q0 q = v ws[0] = s + w ws[1] = s end end end end puts ws.join(' ')
A,B,C,D,E,F = gets.split.map(&:to_i) W = Array.new(F + 1); W[0] = 0 S = Array.new(F + 1); S[0] = 0 (0 .. F).each do |w| W[w] = 1 if w - (100 * A) >= 0 && W[w - (100 * A)] W[w] = 1 if w - (100 * B) >= 0 && W[w - (100 * B)] end (0 .. F).each do |s| S[s] = 1 if s - C >= 0 && S[s - C] S[s] = 1 if s - D >= 0 && S[s - D] end q = 0.0 q0 = (E * 100).to_f / (100 + E) ws = [100 * A, 0] (0 .. F).each do |w| (0 .. F).each do |s| if W[w] && S[s] && s + w <= F v = (s * 100).to_f / (s + w) if v > q && v <= q0 q = v ws[0] = s + w ws[1] = s end end end end puts ws.join(' ')
[ "literal.number.integer.change", "assignment.value.change" ]
1,298,221
1,298,222
u627981707
ruby
p03599
a, b, c, d, e, f = gets.split.map(&:to_i) tmp = {} tmp[:waters] = [] (0..30).each do |i| (0..30 - i).each do |j| sum = 100 * a * i + 100 * b * j tmp[:waters] << sum end end tmp[:sugars] = [] (0..100).each do |i| (0..100 - i).each do |j| sum = c * i + d * j tmp[:sugars] << sum end end ret = "0 0" parcent = 0 tmp[:waters].each do |x| tmp[:sugars].each do |y| next if x + y > f tmp[:parcent] = 100 * y / (x + y).to_f next if tmp[:parcent] > 100 * e / (100 + e).to_f if parcent < tmp[:parcent] parcent = tmp[:parcent] ret = "#{x + y} #{y}" end end end puts ret
a, b, c, d, e, f = gets.split.map(&:to_i) tmp = {} tmp[:waters] = [] (0..30).each do |i| (0..30 - i).each do |j| sum = 100 * a * i + 100 * b * j tmp[:waters] << sum end end tmp[:sugars] = [] (0..100).each do |i| (0..100 - i).each do |j| sum = c * i + d * j tmp[:sugars] << sum end end ret = "" parcent = -1 tmp[:waters].each do |x| tmp[:sugars].each do |y| next if x + y > f tmp[:parcent] = 100 * y / (x + y).to_f next if tmp[:parcent] > 100 * e / (100 + e).to_f if parcent < tmp[:parcent] parcent = tmp[:parcent] ret = "#{x + y} #{y}" end end end puts ret
[ "literal.string.change", "assignment.value.change", "expression.operation.unary.add" ]
1,298,408
1,298,409
u104678771
ruby
p03599
a, b, c, d, e, f = gets.split.map(&:to_i) tmp = {} tmp[:waters] = [] (0..30).each do |i| (0..30).each do |j| sum = 100 * a * i + 100 * b * j tmp[:waters] << sum end end tmp[:sugars] = [] (0..100).each do |i| (0..100).each do |j| sum = c * i + d * j tmp[:sugars] << sum end end ret = "" parcent = 0 tmp[:waters].each do |x| tmp[:sugars].each do |y| next if x + y > f tmp[:parcent] = 100 * y / (x + y).to_f next if tmp[:parcent] > 100 * e / (100 + e).to_f if parcent < tmp[:parcent] parcent = tmp[:parcent] ret = "#{x + y} #{y}" end end end puts ret
a, b, c, d, e, f = gets.split.map(&:to_i) tmp = {} tmp[:waters] = [] (0..30).each do |i| (0..30 - i).each do |j| sum = 100 * a * i + 100 * b * j tmp[:waters] << sum end end tmp[:sugars] = [] (0..100).each do |i| (0..100 - i).each do |j| sum = c * i + d * j tmp[:sugars] << sum end end ret = "" parcent = -1 tmp[:waters].each do |x| tmp[:sugars].each do |y| next if x + y > f tmp[:parcent] = 100 * y / (x + y).to_f next if tmp[:parcent] > 100 * e / (100 + e).to_f if parcent < tmp[:parcent] parcent = tmp[:parcent] ret = "#{x + y} #{y}" end end end puts ret
[ "assignment.value.change", "expression.operation.unary.add" ]
1,298,410
1,298,409
u104678771
ruby
p03599
a, b, c, d, e, f = gets.split.map(&:to_i) tmp = {} tmp[:waters] = [] (0..30).each do |i| (0..30 - i).each do |j| sum = 100 * a * i + 100 * b * j tmp[:waters] << sum end end tmp[:sugars] = [] (0..100).each do |i| (0..100 - i).each do |j| sum = c * i + d * j tmp[:sugars] << sum end end ret = "" parcent = 0 tmp[:waters].each do |x| tmp[:sugars].each do |y| next if x + y > f tmp[:parcent] = 100 * y / (x + y).to_f next if tmp[:parcent] > 100 * e / (100 + e).to_f if parcent < tmp[:parcent] parcent = tmp[:parcent] ret = "#{x + y} #{y}" end end end puts ret
a, b, c, d, e, f = gets.split.map(&:to_i) tmp = {} tmp[:waters] = [] (0..30).each do |i| (0..30 - i).each do |j| sum = 100 * a * i + 100 * b * j tmp[:waters] << sum end end tmp[:sugars] = [] (0..100).each do |i| (0..100 - i).each do |j| sum = c * i + d * j tmp[:sugars] << sum end end ret = "" parcent = -1 tmp[:waters].each do |x| tmp[:sugars].each do |y| next if x + y > f tmp[:parcent] = 100 * y / (x + y).to_f next if tmp[:parcent] > 100 * e / (100 + e).to_f if parcent < tmp[:parcent] parcent = tmp[:parcent] ret = "#{x + y} #{y}" end end end puts ret
[ "assignment.value.change", "expression.operation.unary.add" ]
1,298,411
1,298,409
u104678771
ruby
p03599
a, b, c, d, e, f = gets.split.map(&:to_i) max_water = 0 max_sugar = 0 max_concentration = -1.0 (0..(f/(a*100))).each do |water_a| (0..(f/(b*100))).each do |water_b| next if water_a == 0 && water_b == 0 water = (water_a * a + water_b * b) * 100 sugar_limit = water / 100 * e (0..((f-water)/c)).each do |sugar_c| (0..((f-water)/d)).each do |sugar_d| sugar = sugar_c * c + sugar_d * d next if sugar > sugar_limit || sugar + water > f || sugar == 0 || water == 0 concentration = sugar.to_f / (sugar+water) if concentration > max_concentration max_concentration = concentration max_water = water max_sugar = sugar end end end end end puts "#{max_water + max_sugar} #{max_sugar}"
a, b, c, d, e, f = gets.split.map(&:to_i) max_water = a * 100 max_sugar = 0 max_concentration = 0.0 (0..(f/(a*100))).each do |water_a| (0..(f/(b*100))).each do |water_b| next if water_a == 0 && water_b == 0 water = (water_a * a + water_b * b) * 100 sugar_limit = water / 100 * e (0..((f-water)/c)).each do |sugar_c| (0..((f-water)/d)).each do |sugar_d| sugar = sugar_c * c + sugar_d * d next if sugar > sugar_limit || sugar + water > f || sugar == 0 || water == 0 concentration = sugar.to_f / (sugar+water) if concentration > max_concentration max_concentration = concentration max_water = water max_sugar = sugar end end end end end puts "#{max_water + max_sugar} #{max_sugar}"
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operation.unary.remove" ]
1,299,034
1,299,035
u482389534
ruby
p03599
a, b, c, d, e, f = gets.chomp.split(' ').map(&:to_f) max = 0 limit = e/(100+e) a *= 100 b *= 100 result = [0, 0] for i in 0..(f/a) for j in 0..(f-a*i)/b w = (a*i+b*j).to_f for k in 0..(f-w)/c for l in 0..(f-w-c*k)/d next if i+j==0 || k+l==0 s = (c*k+d*l).to_f con = s/(s+w) next if limit < con if max < con max = con result[0] = s+w result[1] = s end end end end end result.map!(&:to_i) if result[1] > 0 puts "#{result[0]} #{result[1]}" else puts "#{(100*a).to_i} #{result[1]}" end
a, b, c, d, e, f = gets.chomp.split(' ').map(&:to_f) max = 0 limit = e/(100+e) a *= 100 b *= 100 result = [0, 0] for i in 0..(f/a) for j in 0..(f-a*i)/b w = (a*i+b*j).to_f for k in 0..(f-w)/c for l in 0..(f-w-c*k)/d next if i+j==0 || k+l==0 s = (c*k+d*l).to_f con = s/(s+w) next if limit < con if max < con max = con result[0] = s+w result[1] = s end end end end end result.map!(&:to_i) if result[1] > 0 puts "#{result[0]} #{result[1]}" else puts "#{a.to_i} #{result[1]}" end
[ "literal.string.change", "call.arguments.change" ]
1,299,545
1,299,546
u354075848
ruby
p03601
A,B,C,D,E,F = gets.split.map(&:to_i) rmax = 0 ans = [] 0.upto(F/(100*A)) do |a| #puts "a=#{a}" 0.upto((F/100 - A*a)/B) do |b| #puts "b=#{b}" next if a == 0 && b == 0 mw = 100*(A*a + B*b) 0.upto((F-mw)/C) do |c| #puts "c=#{c}" 0.upto((F-mw-C*c)/D) do |d| #puts "d=#{d}" ms = C*c + D*d r = (100 * ms) / (mw + ms) #puts "r=#{r}" if r <= 100*E/(100+E) && r > rmax ans = [mw + ms, ms] rmax = r end end end end end puts ans.join(" ")
A,B,C,D,E,F = gets.split.map(&:to_i) rmax = 0 ans = [] 0.upto(F/(100*A)) do |a| 0.upto((F/100 - A*a)/B) do |b| next if a == 0 && b == 0 mw = 100*(A*a + B*b) 0.upto((F-mw)/C) do |c| 0.upto((F-mw-C*c)/D) do |d| ms = C*c + D*d r = (100.0 * ms) / (mw + ms) if r <= 100.0*E/(100+E) && r >= rmax ans = [mw + ms, ms] rmax = r end end end end end puts ans.join(" ")
[ "assignment.value.change", "expression.operation.binary.change", "io.output.change", "control_flow.branch.if.condition.change", "expression.operator.compare.change" ]
1,299,864
1,299,865
u708550576
ruby
p03599
A, B, C, D, E, F = gets.split.map(&:to_i) wt = 0.step(F, 100*A).flat_map{|a| 0.step(F - a, 100*B).map{|b| a + b}}.sort.uniq sg = 0.step(F, C).flat_map{|c| 0.step(F - c, D).map{|d| c + d}}.sort.uniq puts wt.product(sg).drop(1).select{|w, s| w + s <= F && 100*s <= w*E}.map{|w, s| [w + s, s]}.max_by{|a, s| 100*s / a}.join(' ')
A, B, C, D, E, F = gets.split.map(&:to_i) wt = 0.step(F, 100*A).flat_map{|a| 0.step(F - a, 100*B).map{|b| a + b}}.sort.uniq sg = 0.step(F, C).flat_map{|c| 0.step(F - c, D).map{|d| c + d}}.sort.uniq puts wt.product(sg).drop(1).select{|w, s| w + s <= F && 100*s <= w*E}.map{|w, s| [w + s, s]}.max_by{|a, s| 100.0*s / a}.join(' ')
[ "call.arguments.change", "expression.operation.binary.change" ]
1,301,061
1,301,062
u304198114
ruby
p03605
s = gets.chomp a,b = s.split("") if(a=='9' || b=='9') puts 'YES' else puts 'NO' end
s = gets.chomp a,b = s.split("") if(a=='9' || b=='9') puts 'Yes' else puts 'No' end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
1,301,846
1,301,847
u145950990
ruby
p03605
puts gest.include?('9') ? 'Yes':'No'
puts gets.include?('9') ? 'Yes':'No'
[ "misc.typo", "identifier.change", "control_flow.branch.if.condition.change" ]
1,301,854
1,301,855
u050914494
ruby
p03605
gets.chomp.include?(?9) ? :Yes: :No
puts gets.chomp.include?(?9) ? :Yes: :No
[ "io.output.change", "call.add" ]
1,301,935
1,301,936
u744908753
ruby
p03605
s = gets i = s.split('').map(&:to_i) c = '' c = 'No' c = [] 2.times do |o| puts o if i[o] == 9 c = 'Yes' else c = 'No' end if c == 'Yes' break end end puts c
s = gets i = s.split('').map(&:to_i) c = '' c = 'No' c = [] 2.times do |o| if i[o] == 9 c = 'Yes' else c = 'No' end if c == 'Yes' break end end puts c
[ "call.remove" ]
1,302,051
1,302,052
u126342998
ruby
p03605
ary = gets.chomp.chars.map &:to_i res = "NO" ary.each do |v| if v == 9 res = "YES" end end puts res
ary = gets.chomp.chars.map &:to_i res = "No" ary.each do |v| if v == 9 res = "Yes" end end puts res
[ "literal.string.change", "literal.string.case.change", "assignment.value.change" ]
1,302,091
1,302,092
u126541218
ruby
p03605
puts gets.count("1") > 0 ? "Yes" : "No"
puts gets.count("9") > 0 ? "Yes" : "No"
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
1,302,166
1,302,167
u670503797
ruby
p03605
n=gets().chomp() if n[0]==9 or n[1]==9 puts("Yes") else puts("No") end
n=gets().chomp() if n[0]=="9" or n[1]=="9" puts("Yes") else puts("No") end
[ "control_flow.branch.if.condition.change" ]
1,302,224
1,302,225
u060936992
ruby
p03605
n = gets.chomp.split("").map(&:to_i) n.each do |i| if i == 9 puts "Yes" exit! end end puts "No"
n = gets.chomp.split("").map(&:to_i) n.each do |i| if i == 9 puts "Yes" exit end end puts "No"
[ "call.suffix.change" ]
1,302,344
1,302,345
u872636244
ruby
p03605
p gets[?9]?'Yes':'No'
puts gets[?9]?:Yes: :No
[ "call.function.change", "io.output.change", "call.arguments.change" ]
1,302,485
1,302,486
u056944756
ruby
p03605
p gets=~/9/?"Yes":"No"
puts gets=~/9/?:Yes: :No
[ "call.function.change", "io.output.change", "call.arguments.change" ]
1,302,487
1,302,488
u210718367
ruby
p03605
p gets()=~/9/?"Yes":"No"
puts gets=~/9/?"Yes":"No"
[ "call.function.change", "io.output.change", "call.arguments.change" ]
1,302,489
1,302,490
u210718367
ruby
p03605
p gets()=~/9/?"Yes":"No"
puts gets()=~/9/?"Yes":"No"
[ "call.function.change", "io.output.change" ]
1,302,489
1,302,491
u210718367
ruby
p03605
p gets()=~/9/?"Yes":"No"
puts !(gets() =~ /9/) ? "No":"Yes"
[ "call.function.change", "io.output.change", "control_flow.branch.if.condition.change" ]
1,302,489
1,302,492
u210718367
ruby
p03606
n = gets.to_i sum = 0 n.times do l,r = gest.strip.split.map(&:to_i) sum += l-r+1 end puts sum
n = gets.to_i sum = 0 n.times do l,r = gets.strip.split.map(&:to_i) sum += r-l+1 end puts sum
[ "misc.typo", "assignment.value.change", "identifier.change", "expression.operation.binary.remove" ]
1,302,748
1,302,749
u313103408
ruby
p03606
n = gets.to_i ary = [] n.times do ary << gets.split(" ").map(&:to_i) end people = 0 ary.each do |x| people += x[1] - x[0] end puts people
n = gets.to_i ary = [] n.times do ary << gets.split(" ").map(&:to_i) end people = 0 ary.each do |x| people += x[1] - x[0] + 1 end puts people
[ "expression.operation.binary.add" ]
1,302,994
1,302,995
u928941036
ruby
p03605
input = gets.chomp! input.to_s.include?("9") ? "Yes" : "No"
input = gets.chomp! puts input.to_s.include?("9") ? "Yes" : "No"
[ "io.output.change", "call.add" ]
1,303,698
1,303,699
u329515076
ruby
p03606
res = 0 gets.to_i.times do a = gets.split.map(&:to_i) res += a[1] - a[0] end puts res
res = 0 gets.to_i.times do a = gets.split.map(&:to_i) res += a[1] - a[0] + 1 end puts res
[ "expression.operation.binary.add" ]
1,303,867
1,303,868
u664737319
ruby
p03606
res = 0 gets.to_i.times do a = gets.chop.map(&:to_i) res += a[1] - a[0] end puts res
res = 0 gets.to_i.times do a = gets.split.map(&:to_i) res += a[1] - a[0] + 1 end puts res
[ "assignment.value.change", "identifier.change" ]
1,303,869
1,303,868
u664737319
ruby
p03606
n = gets.to_i x = 0 n.times do |i| l.r = gets.chomp.split.map(&:to_i) x += (r - l + 1) end puts x
n = gets.to_i x = 0 n.times do |i| l,r = gets.chomp.split.map(&:to_i) x += (r - l + 1) end puts x
[ "misc.typo", "assignment.variable.change" ]
1,303,912
1,303,913
u001025229
ruby
p03607
_, values = readlines.map(&:chomp).map(&:to_i) counts = values.reduce(Hash.new{|h, k| h[k]=0}) do |h, v| h[v] += 1 h end p counts.select {|k, c| c % 2 == 1}.length
_, *values = readlines.map(&:chomp).map(&:to_i) counts = values.reduce(Hash.new{|h, k| h[k]=0}) do |h, v| h[v] += 1 h end p counts.select {|k, c| c % 2 == 1}.length
[]
1,304,152
1,304,153
u793069025
ruby
p03607
n=gets.to_i numbers=Hash.new() n.times { a=gets.to_i numbers[a]+=1 } puts numbers.select {|k, v| v.odd? }.length
n=gets.to_i numbers=Hash.new(0) n.times { a=gets.to_i numbers[a]+=1 } puts numbers.select {|k, v| v.odd? }.length
[ "call.arguments.change" ]
1,304,327
1,304,328
u585819925
ruby
p03607
n=gets.to_i numbers=Hash.new() n.times { a=gets.to_i numbers[a] += 1 } puts numbers.count {|k, v| v.odd? }
n=gets.to_i numbers=Hash.new(0) n.times { a=gets.to_i numbers[a]+=1 } puts numbers.select {|k, v| v.odd? }.length
[ "call.arguments.change", "identifier.change", "io.output.change", "call.add" ]
1,304,329
1,304,328
u585819925
ruby
p03607
gets list = [] while s = gets s = s.to_i list[s] = !list[s] end puts list.count{|i| i }
gets list = {} while s = gets s = s.to_i list[s] = !list[s] end puts list.count{|k,v| v }
[ "identifier.change", "call.arguments.change", "io.output.change" ]
1,304,707
1,304,708
u022797848
ruby
p03608
n, m, _ = gets.split.map(&:to_i) r = gets.split.map { |z| z.to_i - 1 } max = 1e10 d = Array.new(n) { Array.new(n, max) } m.times do a, b, c = gets.split.map(&:to_i) a -= 1 b -= 1 d[a][b] = c d[b][a] = c end n.times do |k| dk = d[k] n.times do |i| #next if i == k di = d[i] dik = di[k] (i...n).each do |j| tmp = dik + dk[j] di[j] = tmp if tmp < di[j] end end end ans = r.permutation.map do |perm| perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] } end.min p ans
n, m, _ = gets.split.map(&:to_i) r = gets.split.map { |z| z.to_i - 1 } max = 1e10 d = Array.new(n) { Array.new(n, max) } m.times do a, b, c = gets.split.map(&:to_i) a -= 1 b -= 1 d[a][b] = c d[b][a] = c end n.times do |k| dk = d[k] n.times do |i| di = d[i] dik = di[k] n.times do |j| tmp = dik + dk[j] di[j] = tmp if tmp < di[j] end end end ans = r.permutation.map do |perm| perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] } end.min p ans
[ "identifier.change" ]
1,305,217
1,305,218
u706695185
ruby
p03608
n, m, _ = gets.split.map(&:to_i) r = gets.split.map { |z| z.to_i - 1 } max = 1e10 d = Array.new(n) { Array.new(n, max) } m.times do a, b, c = gets.split.map(&:to_i) a -= 1 b -= 1 d[a][b] = c d[b][a] = c end n.times do |k| dk = d[k] n.times do |i| next if i == k di = d[i] dik = di[k] (i...n).each do |j| tmp = dik + dk[j] di[j] = tmp if tmp < di[j] end end end ans = r.permutation.map do |perm| perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] } end.min p ans
n, m, _ = gets.split.map(&:to_i) r = gets.split.map { |z| z.to_i - 1 } max = 1e10 d = Array.new(n) { Array.new(n, max) } m.times do a, b, c = gets.split.map(&:to_i) a -= 1 b -= 1 d[a][b] = c d[b][a] = c end n.times do |k| dk = d[k] n.times do |i| next if i == k di = d[i] dik = di[k] n.times do |j| tmp = dik + dk[j] di[j] = tmp if tmp < di[j] end end end ans = r.permutation.map do |perm| perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] } end.min p ans
[ "identifier.change" ]
1,305,219
1,305,220
u706695185
ruby
p03608
n, m, _ = gets.split.map(&:to_i) r = gets.split.map { |z| z.to_i - 1 } max = 1e10 d = Array.new(n) { Array.new(n, max) } m.times do a, b, c = gets.split.map(&:to_i) a -= 1 b -= 1 d[a][b] = c d[b][a] = c end n.times do |k| dk = d[k] n.times do |i| next if i == k di = d[i] dik = di[k] (i...n).each do |j| tmp = dik + dk[j] di[j] = tmp if tmp < di[j] end end end ans = r.permutation.map do |perm| perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] } end.min p ans
n, m, _ = gets.split.map(&:to_i) r = gets.split.map { |z| z.to_i - 1 } max = 1e10 d = Array.new(n) { Array.new(n, max) } m.times do a, b, c = gets.split.map(&:to_i) a -= 1 b -= 1 d[a][b] = c d[b][a] = c end n.times do |k| dk = d[k] n.times do |i| next if i == k di = d[i] dik = di[k] (0...n).each do |j| tmp = dik + dk[j] di[j] = tmp if tmp < di[j] end end end ans = r.permutation.map do |perm| perm.each_cons(2).inject(0) { |sum, (x, y)| sum + d[x][y] } end.min p ans
[ "identifier.replace.remove", "literal.replace.add" ]
1,305,219
1,305,221
u706695185
ruby
p03609
x, t = gets.chomp.spit(" ").map(&:to_i) puts [x-t,0].max
x, t = gets.chomp.split(" ").map(&:to_i) puts [x-t,0].max
[ "assignment.value.change", "identifier.change" ]
1,305,657
1,305,658
u412789323
ruby
p03609
x, t = gets.chomp.split(" ").map(&:to_i) t >= x ? answer = x - t : answer = 0 puts answer
x, t = gets.chomp.split(" ").map(&:to_i) t <= x ? answer = x - t : answer = 0 puts answer
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,305,896
1,305,897
u333374716
ruby
p03609
X, t = gets.split.map(&:to_i) puts X - t
X, t = gets.split.map(&:to_i) puts [X - t, 0].max
[ "call.arguments.change", "call.add" ]
1,306,168
1,306,169
u320576758
ruby
p03608
N, M, R = gets.split.map(&:to_i) r = gets.split.map(&:to_i) dist = Array.new(N) { Array.new(N, Float::INFINITY) } M.times do |i| a, b, c = gets.split.map(&:to_i) dist[a-1][b-1] = c dist[b-1][a-1] = c end N.times do |k| N.times do |i| N.times do |j| if dist[i][j] < dist[i][k] + dist[k][j] dist[i][j] = dist[i][k] + dist[k][j] end end end end min = Float::INFINITY r.permutation(R) do |seq| sum = 0 #seq.each_cons(2) do |x, y| # sum += dist[x-1][y-1] #end (R - 1).times do |i| sum += dist[seq[i]-1][seq[i+1]-1] end min = sum if min > sum end puts min
N, M, R = gets.split.map(&:to_i) r = gets.split.map(&:to_i) dist = Array.new(N) { Array.new(N, Float::INFINITY) } M.times do |i| a, b, c = gets.split.map(&:to_i) dist[a-1][b-1] = c dist[b-1][a-1] = c end N.times do |k| N.times do |i| N.times do |j| if dist[i][j] > dist[i][k] + dist[k][j] dist[i][j] = dist[i][k] + dist[k][j] end end end end min = Float::INFINITY r.permutation(R) do |seq| sum = 0 #seq.each_cons(2) do |x, y| # sum += dist[x-1][y-1] #end (R - 1).times do |i| sum += dist[seq[i]-1][seq[i+1]-1] end min = sum if min > sum end puts min
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,306,322
1,306,323
u033378815
ruby
p03609
require 'prime' require 'set' require 'tsort' include Math ALP = ('a'..'z').to_a INF = 0xffffffffffffffff def max(a,b); a > b ? a : b end def min(a,b); a < b ? a : b end def swap(a,b); a, b = b, a end def gif; gets.to_i end def gff; gets.to_f end def gsf; gets.chomp end def gi; gets.split.map(&:to_i) end def gf; gets.split.map(&:to_f) end def gs; gets.chomp.split.map(&:to_s) end def gc; gets.chomp.split('') end def pr(num); num.prime_division end def pr?(num); Prime.prime?(num) end def digit(num); num.to_s.length end def array(s,ini=nil); Array.new(s){ini} end def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end def rep(num); num.times{|i|yield(i)} end def repl(st,en,n=1); st.step(en,n){|i|yield(i)} end n = gif puts max(0,n[0]-n[1])
require 'prime' require 'set' require 'tsort' include Math ALP = ('a'..'z').to_a INF = 0xffffffffffffffff def max(a,b); a > b ? a : b end def min(a,b); a < b ? a : b end def swap(a,b); a, b = b, a end def gif; gets.to_i end def gff; gets.to_f end def gsf; gets.chomp end def gi; gets.split.map(&:to_i) end def gf; gets.split.map(&:to_f) end def gs; gets.chomp.split.map(&:to_s) end def gc; gets.chomp.split('') end def pr(num); num.prime_division end def pr?(num); Prime.prime?(num) end def digit(num); num.to_s.length end def array(s,ini=nil); Array.new(s){ini} end def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end def rep(num); num.times{|i|yield(i)} end def repl(st,en,n=1); st.step(en,n){|i|yield(i)} end n = gi puts max(0,n[0]-n[1])
[ "assignment.value.change", "identifier.change" ]
1,306,406
1,306,407
u988228861
ruby
p03609
(x,t)=gets.chomp.split(" ").map(&:to_s);puts([0,x-t].max.to_s)
(x,t)=gets.chomp.split(" ").map(&:to_i);puts([0,x-t].max.to_s)
[ "assignment.value.change", "call.arguments.change" ]
1,306,449
1,306,450
u198355306
ruby
p03610
n = gets.chomp.split(" ") arr = [] n.each_with_index do |item,j| if j % 2 == 0 arr << item end end puts arr.join("")
n = gets.chomp.split("") arr = [] n.each_with_index do |item,j| if j % 2 == 0 arr << item end end puts arr.join("")
[ "literal.string.change", "assignment.value.change", "call.arguments.change" ]
1,306,545
1,306,546
u412789323
ruby
p03610
s = gets.chop.split('') s.size.times do |i| if i %2 == 0 then puts s[i] end end
s = gets.chop.split('') s.size.times do |i| if i %2 == 0 then print s[i] end end print "\n"
[ "identifier.change", "io.output.change", "call.add" ]
1,306,554
1,306,555
u636683284
ruby
p03610
s = gets.chomp d = "" for i in 0..s.length d += s[i] if i%2 == 0 end puts d
s = gets.chomp d = "" for i in 0..s.length-1 d += s[i] if i%2 == 0 end puts d
[ "expression.operation.binary.add" ]
1,306,810
1,306,811
u056083754
ruby
p03610
puts gets.chomp.to_s..split(//).each_slice(2).map(&:first).join
puts gets.chomp.to_s.split(//).each_slice(2).map(&:first).join
[ "call.arguments.change" ]
1,306,834
1,306,835
u928941036
ruby
p03610
puts gets.chomp.to_s.each_slice(2).map(&:first).join
puts gets.chomp.to_s.split(//).each_slice(2).map(&:first).join
[ "call.add" ]
1,306,836
1,306,835
u928941036
ruby
p03610
ws = gets.chomp.split("") ans = [] ws.each_with_index do |i, w| ans << w if (i+1).odd? end puts ans.join
ws = gets.chomp.split("") ans = [] ws.each_with_index do |w, i| ans << w if (i+1).odd? end puts ans.join
[]
1,306,847
1,306,848
u809809975
ruby
p03610
s=gets.chars s.each_with_index do |item,i| print item if i%2!=0 end puts
s=gets.chars s.each_with_index do |item,i| print item if i%2==0 end puts
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,306,884
1,306,885
u585819925
ruby
p03610
s=gets.chomp s.length.times do |i| if i.odd? print s[i] end end
s=gets.chomp s.length.times do |i| if i.even? print s[i] end end
[ "identifier.change", "control_flow.branch.if.condition.change" ]
1,306,913
1,306,914
u744908753
ruby
p03610
array = gets.chomp.split("") p array.each_slice(2).map(&:first).join
array = gets.chomp.split("") puts array.each_slice(2).map(&:first).join
[ "call.function.change", "io.output.change" ]
1,306,979
1,306,980
u599631096
ruby
p03610
line = gets line.each_char.with_index {|ch,index|puts ch if index.even? }
line = gets line.each_char.with_index {|ch,index|print ch if index.even? }
[ "identifier.change", "io.output.change" ]
1,307,017
1,307,018
u734430573
ruby
p03610
s = gets.chars ans = [] s.each_index do |i| ans << s[i] if i.even? end p ans.join
s = gets.chars ans = [] s.each_index do |i| ans << s[i] if i.even? end puts ans.join
[ "call.function.change", "io.output.change" ]
1,307,171
1,307,172
u296101474
ruby
p03610
s = gets a = s[0];i = 2 while i < s.length a += s[i] i += 2 end p a.to_s
s = gets a = s[0];i = 2 while i < s.length a += s[i] i += 2 end puts a
[ "call.function.change", "io.output.change", "call.remove" ]
1,307,204
1,307,205
u974214237
ruby
p03610
gets.chomp.chars.each_with_index{|c,i|putc c if i%2==1} puts("")
gets.chomp.chars.each_with_index{|c,i|putc c if i%2==0} puts("")
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
1,307,237
1,307,238
u752146271
ruby
p03610
s = gets.chomp answer = "" s.length.times do |i| if i % 2 != 0 answer += s[i] end end puts answer
s = gets.chomp answer = "" s.length.times do |i| if i % 2 == 0 answer += s[i] end end puts answer
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,307,254
1,307,255
u151483411
ruby
p03610
s = gets.chomp answer = "" S.length.times do |i| if i % 2 != 0 answer += s[i] end end puts answer
s = gets.chomp answer = "" s.length.times do |i| if i % 2 == 0 answer += s[i] end end puts answer
[ "misc.typo", "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
1,307,256
1,307,255
u151483411
ruby
p03610
s = gets.chomp result = "" if s.length % 2 == 0 then n = s.length / 2 else (s.length + 1) / 2 n = (ss.length + 1) /2 end for i in 1..n do result += s[2 * i - 2] end print result
s = gets.chomp result = "" if s.length % 2 == 0 then n = s.length / 2 else (s.length + 1) / 2 n = (s.length + 1) /2 end for i in 1..n do result += s[2 * i - 2] end print result
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
1,307,357
1,307,358
u916967438
ruby
p03610
puts gets .each_char .each_slice(2) .map(&:first) join
puts gets .each_char .each_slice(2) .map(&:first) .join
[ "call.add", "call.arguments.change" ]
1,307,461
1,307,462
u882851536
ruby
p03610
str = gets.chomp! i = 0 temp = [] while i < str.length temp.push(str[i]) i += 1 end puts temp.join
str = gets.chomp! i = 0 temp = [] while i < str.length temp.push(str[i]) i += 2 end puts temp.join
[ "literal.number.integer.change" ]
1,307,469
1,307,470
u131033623
ruby
p03610
s = gets.split t = "" for i in 0 ... s.length if i % 2 == 0 t += s[i] end end puts t
s = gets.chomp t = "" for i in 0 ... s.length if i % 2 == 0 t += s[i] end end puts t
[ "assignment.value.change", "identifier.change" ]
1,307,502
1,307,503
u459746049
ruby
p03611
n = gets.to_i arr = gets.chomp.split(' ').map(&:to_i).sort i = 0 max = 0 while i < arr.size exceed_id = arr.bsearch_index {|num| num > arr[i] + 2 } || 0 if max < exceed_id - i max = exceed_id - i end i += 1 end puts max
n = gets.to_i arr = gets.chomp.split(' ').map(&:to_i).sort i = 0 max = 0 while i < arr.size exceed_id = arr.bsearch_index {|num| num > arr[i] + 2 } || arr.size if max < exceed_id - i max = exceed_id - i end i += 1 end puts max
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operation.binary.change", "call.add" ]
1,307,596
1,307,597
u059126963
ruby
p03611
n = gets.to_i arr = gets.chomp.split(' ').map(&:to_i).sort i = 0 max = 0 while i < arr.size - 2 exceed_id = arr.bsearch_index {|num| num > arr[i] + 2 } || 0 if max < exceed_id - i max = exceed_id - i end i += 1 end puts max
n = gets.to_i arr = gets.chomp.split(' ').map(&:to_i).sort i = 0 max = 0 while i < arr.size exceed_id = arr.bsearch_index {|num| num > arr[i] + 2 } || arr.size if max < exceed_id - i max = exceed_id - i end i += 1 end puts max
[ "expression.operation.binary.remove", "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "expression.operation.binary.change", "call.add" ]
1,307,598
1,307,597
u059126963
ruby
p03611
# frozen_string_literal: true _ = gets h = Hash.new(0) gets.split.map(&:to_i).each do |i| h[i - 1] += 1 h[i] += 1 h[i + 1] += 1 end puts h.max_by { |_, v| v }
# frozen_string_literal: true _ = gets h = Hash.new(0) gets.split.map(&:to_i).each do |i| h[i - 1] += 1 h[i] += 1 h[i + 1] += 1 end puts h.max_by { |_, v| v }[1]
[]
1,307,856
1,307,857
u104886851
ruby
p03611
n = gets.to_i a = gets.split.map(&:to_i) r = Hash.new(0) a.each do |x| r[x + 1] += 1 r[x - 1] += 1 r[x] += 1 end ans = 0 r.each do |k, v| ans = v > ans ? k : ans end puts ans
n = gets.to_i a = gets.split.map(&:to_i) r = Hash.new(0) a.each do |x| r[x + 1] += 1 r[x - 1] += 1 r[x] += 1 end ans = 0 r.each do |k, v| ans = v > ans ? v : ans end puts ans
[ "assignment.value.change", "identifier.change" ]
1,308,285
1,308,286
u457499130
ruby
p03611
$stdin.gets a = $stdin.gets.chomp.split(" ").map(&:to_i) d = Hash.new 0 a.each do |e| d[e] += 1 d[e-1] += 1 d[e+1] += 1 end puts d.keys.max
$stdin.gets a = $stdin.gets.chomp.split(" ").map(&:to_i) d = Hash.new 0 a.each do |e| d[e] += 1 d[e-1] += 1 d[e+1] += 1 end puts d.values.max
[ "identifier.change", "call.arguments.change" ]
1,308,314
1,308,315
u024015883
ruby
p03611
N=readline.to_i sorted_a = readline.split.map(&:to_i).sort grouped_a = sorted_a.group_by{|x|x} count_with_zero = [] (sorted_a.last+1).times do |number| numbers = grouped_a[number] || [] count_with_zero.push(numbers.size); end p count_with_zero delta_cumulative_count = count_with_zero.map.with_index do |count, i| i>0 ? count_with_zero[i-1].to_i + count_with_zero[i].to_i + count_with_zero[i+1].to_i : count_with_zero[i].to_i + count_with_zero[i+1].to_i end p delta_cumulative_count.max
N=readline.to_i sorted_a = readline.split.map(&:to_i).sort grouped_a = sorted_a.group_by{|x|x} count_with_zero = [] (sorted_a.last+1).times do |number| numbers = grouped_a[number] || [] count_with_zero.push(numbers.size); end # p count_with_zero delta_cumulative_count = count_with_zero.map.with_index do |count, i| i>0 ? count_with_zero[i-1].to_i + count_with_zero[i].to_i + count_with_zero[i+1].to_i : count_with_zero[i].to_i + count_with_zero[i+1].to_i end p delta_cumulative_count.max
[ "call.remove" ]
1,308,388
1,308,389
u021358975
ruby
p03612
n = gets.to_i a = gets.chomp.split.map(&:to_i) cont = 0 a.each_with_index do |v, i| if i + 1 == v tmp = a[i + 1] a[i + 1] = v a[i] = tmp cont += 1 end end p a p cont
n = gets.to_i a = gets.chomp.split.map(&:to_i) cont = 0 a.each_with_index do |v, i| if i + 1 == v tmp = a[i + 1] a[i + 1] = v a[i] = tmp cont += 1 end end p cont
[ "call.remove" ]
1,309,380
1,309,381
u698501698
ruby