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
p02682
a, b, c, k = gets.split.map(&:to_i) ans = -10000000 if k <= a ans = a elsif (k - a) <= b ans = a else ans = a + (k-a-b) end puts ans
a, b, c, k = gets.split.map(&:to_i) ans = -10000000 if k <= a ans = k elsif (k - a) <= b ans = a else ans = a - (k - a - b) end puts ans
[ "assignment.value.change", "identifier.change", "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
407,577
407,578
u866325115
ruby
p02682
A,B,C,K = `dd`.split.map &:to_i p K <= A ? K : K <= A + B ? A : A - [C - (K - A - B), 0].min
A,B,C,K = `dd`.split.map &:to_i p K <= A ? K : K <= A + B ? A : A - [C, K - A - B].min
[ "call.arguments.change", "expression.operation.binary.change" ]
407,628
407,629
u670503797
ruby
p02682
#n=gets.chomp.split(" ").map(&:to_i); a,b,c,k=gets.chomp.split(" ").map(&:to_i); sum = 0 sum += [a,k].min k-=[a,k].min k-=[b,k].min sum -= [b,k].min puts sum
#n=gets.chomp.split(" ").map(&:to_i); a,b,c,k=gets.chomp.split(" ").map(&:to_i); sum = 0 sum += [a,k].min k-=[a,k].min k-=[b,k].min sum -= [c,k].min puts sum
[ "identifier.change" ]
407,910
407,911
u650620788
ruby
p02682
a, b, c, k = gets.chomp.split(" ").to_i if a >= k puts k elsif a < k && a + b > k puts a else puts a - ( k - a - b ) end
a, b, c, k = gets.chomp.split(" ").map(&:to_i) if a >= k puts k elsif a < k && a + b > k puts a else puts a - ( k - a - b ) end
[ "assignment.value.change", "identifier.change", "call.arguments.add" ]
408,275
408,276
u412789323
ruby
p02682
a, b, c, k = gets.chomp.split("").to_i if a >= k puts k elsif a < k && a + b > k puts a else puts a - ( k - a - b ) end
a, b, c, k = gets.chomp.split(" ").map(&:to_i) if a >= k puts k elsif a < k && a + b > k puts a else puts a - ( k - a - b ) end
[ "literal.string.change", "assignment.value.change", "call.arguments.change", "identifier.change", "call.arguments.add" ]
408,277
408,276
u412789323
ruby
p02682
a, b, c, k = gets.split.map(&:to_i) total = 0 if a <= k total += a k -= a else total += k puts total exit end if k == 0 || k <= b puts total exit else k -= b end if b == 0 puts total exit end total -= k puts total
a, b, c, k = gets.split.map(&:to_i) total = 0 if a <= k total += a k -= a else total += k puts total exit end if k == 0 || k <= b puts total exit else k -= b end if k == 0 puts total exit end total -= k puts total
[ "identifier.change", "control_flow.branch.if.condition.change" ]
408,396
408,397
u658910570
ruby
p02682
a, b, c, k = gets.split.map(&:to_i) sum = 0 count = k if count-(a+b)>0 sum=a sum= sum+(count-(a+b))*(-1) else if count-a>0 sum=a elsif count-a==0 sum=a else sum=a end end puts sum
a, b, c, k = gets.split.map(&:to_i) sum = 0 count = k if count-(a+b)>0 sum=a sum= sum+(count-(a+b))*(-1) else if count-a>0 sum=a elsif count-a==0 sum=a else sum=k end end puts sum
[ "assignment.value.change", "identifier.change" ]
408,462
408,463
u514143079
ruby
p02682
a,b,c,k=`dd`.split.map &:to_i if k<=a p k elsif a<k && k<=a+b p a else a-(k-(a+b)) end
a,b,c,k=`dd`.split.map &:to_i if k<=a p k elsif a<k && k<=a+b p a else p a-(k-(a+b)) end
[ "io.output.change", "call.add" ]
408,576
408,577
u128694188
ruby
p02682
a,b,c,k=`dd`.split.map &:to_i if k<=a p k elsif a<k<=a+b p a else a-(k-(a+b)) end
a,b,c,k=`dd`.split.map &:to_i if k<=a p k elsif a<k && k<=a+b p a else p a-(k-(a+b)) end
[ "control_flow.branch.if.condition.change", "io.output.change", "call.add" ]
408,578
408,577
u128694188
ruby
p02682
a, b, c, k = gets.split.map(&:to_i) puts (k <= a + b) ? a : 2 * a + b - k
a, b, c, k = gets.split.map(&:to_i) puts (k <= a + b) ? [a, k].min : 2 * a + b - k
[ "call.arguments.change", "call.add" ]
408,663
408,664
u605918955
ruby
p02682
A,B,C,K=gets.split.map(&:to_i) sum=0 if K-A>=0 sum+=A if K-A-B>=0 sum-=(K-A-B) end end puts sum
A,B,C,K=gets.split.map(&:to_i) sum=0 if K-A>=0 sum+=A if K-A-B>=0 sum-=(K-A-B) end else sum+=K end puts sum
[]
408,855
408,856
u168915361
ruby
p02682
a,b,c,k = gets.split.map(&:to_i) sum = 0 def main(a, b, c, k, sum) pulsA = a > k ? k : a k = k-a sum = sum + a if k <= 0 print sum return end k = k-b if k <= 0 print sum return end pulsC = c > k ? k :c sum = sum - pulsC print sum end main(a,b,c,k,sum)
a,b,c,k = gets.split.map(&:to_i) sum = 0 def main(a, b, c, k, sum) pulsA = a > k ? k : a k = k-pulsA sum = sum + pulsA if k <= 0 print sum return end k = k-b if k <= 0 print sum return end pulsC = c > k ? k : c sum = sum - pulsC print sum end main(a,b,c,k,sum)
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
409,118
409,119
u470192783
ruby
p02682
a = gets.split.map(&:to_i) S = 0 n = 0 if a[3] > a[0] S += a[0] n = a[3] - a[0] if n <= a[1] puts S else puts S - (n - a[1]) end else puts a[0] end
a = gets.split.map(&:to_i) S = 0 n = 0 if a[3] > a[0] S += a[0] n = a[3] - a[0] if n <= a[1] puts S else puts S - (n - a[1]) end else puts a[3] end
[ "literal.number.integer.change", "variable_access.subscript.index.change", "call.arguments.change" ]
409,204
409,205
u020467031
ruby
p02682
def input_n gets.to_i # 単一整数 end def input_s gets.chomp # 文字列。chompを付けないと改行文字がついてくる end def input_a gets.split.map(&:to_i) # スペースで区切られた複数の整数 end def input_o(num) num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある end def output_f(num) puts sprintf("%.12f", num) end a, b, c, k = input_a if a >= k puts a exit end if a < k if a + b >= k puts a else tmp = k - (a + b) puts a - tmp end end
def input_n gets.to_i # 単一整数 end def input_s gets.chomp # 文字列。chompを付けないと改行文字がついてくる end def input_a gets.split.map(&:to_i) # スペースで区切られた複数の整数 end def input_o(num) num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある end def output_f(num) puts sprintf("%.12f", num) end a, b, c, k = input_a if a >= k puts k exit end if a < k if a + b >= k puts a else tmp = k - (a + b) puts a - tmp end end
[ "identifier.change", "call.arguments.change" ]
409,232
409,233
u876846619
ruby
p02682
A,B,C,K = $stdin.read.chomp.split(" ").map(&:to_i) k = K if A >= k puts A exit end k -= A if B >= k puts A exit end k -= B puts A - [0, k].max
A,B,C,K = $stdin.read.chomp.split(" ").map(&:to_i) k = K if A >= k puts k exit end k -= A if B >= k puts A exit end k -= B puts A - [0, k].max
[ "call.arguments.change" ]
409,349
409,350
u381839731
ruby
p02682
a,b,c,k = gets.chomp.split(" ").map(&:to_i) if k < a puts a - k elsif k < a + b puts a else puts a + (k - a - b) * (-1) end
a,b,c,k = gets.chomp.split(" ").map(&:to_i) if k < a puts k elsif k < a + b puts a else puts a + (k - a - b) * (-1) end
[ "expression.operation.binary.remove" ]
409,401
409,402
u257668305
ruby
p02682
a, b, c, k = gets.split.map(&:to_i) ans = k if k > a k -= a + b ans -= k if k > 0 end puts ans
a, b, c, k = gets.split.map(&:to_i) ans = k if k > a ans = a k -= a + b ans -= k if k > 0 end puts ans
[ "assignment.add" ]
409,480
409,481
u374765295
ruby
p02682
a, b, c, k = gets.split.map(&:to_i) ans = a if k > a k -= a + b ans -= k if k > 0 end puts ans
a, b, c, k = gets.split.map(&:to_i) ans = k if k > a ans = a k -= a + b ans -= k if k > 0 end puts ans
[ "assignment.value.change", "identifier.change" ]
409,482
409,481
u374765295
ruby
p02682
num = gets.split.map(&:to_i) a = num[0] b = num[1] c = num[2] k = num[3] if a >= k puts a elsif a + b >= k puts a else puts a - (k - a - b) end
num = gets.split.map(&:to_i) a = num[0] b = num[1] c = num[2] k = num[3] if a >= k puts k elsif a + b >= k puts a else puts a - (k - a - b) end
[ "identifier.change", "call.arguments.change" ]
409,623
409,624
u906724785
ruby
p02682
# abc167 B a, b, c, k = gets.split.map(&:to_i) if a >= k p a else if a + b >= k p a else p a - (k - a - b) end end
# abc167 B a, b, c, k = gets.split.map(&:to_i) if a >= k p k else if a + b >= k p a else p a - ( k - (a+b) ) end end
[ "identifier.change", "call.arguments.change", "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
409,797
409,798
u315597999
ruby
p02682
# abc167 B a, b, c, k = gets.split.map(&:to_i) if a > k p a else if a + b > k p a else p a - (k - a - b) end end
# abc167 B a, b, c, k = gets.split.map(&:to_i) if a >= k p k else if a + b >= k p a else p a - ( k - (a+b) ) end end
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change", "call.arguments.change", "misc.opposites", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
409,799
409,798
u315597999
ruby
p02682
a, b, c, k = gets.split.map(&:to_i) sum = 0 sum += [a, k].min k -= a k -= b sum -= [c, k].min puts sum
a, b, c, k = gets.split.map(&:to_i) sum = 0 sum += [a, k].min k -= a k -= b sum -= [c, k].min if k >= 0 puts sum
[]
410,081
410,082
u889326464
ruby
p02682
a,b,c,k = gets.chomp.split(' ').map(&:to_i) if (k > (a+b)) puts a - (k-a-b) else puts a end
a,b,c,k = gets.chomp.split(' ').map(&:to_i) if (k > (a+b)) puts a - (k-a-b) else puts [a,k].min end
[ "call.arguments.change", "call.add" ]
410,271
410,272
u546441021
ruby
p02682
A, B, C, K = gets.split.map{|i|i.to_i} puts([A, K].min - [C, K - A - B].min)
A, B, C, K = gets.split.map{|i|i.to_i} puts([A, K].min - [0, K - A - B].max)
[ "call.arguments.change", "expression.operation.binary.change", "io.output.change", "misc.opposites", "identifier.change" ]
410,289
410,290
u488526012
ruby
p02682
# frozen_string_literal: true a, b, c, k = gets.split.map(&:to_i) if a + b >= k puts a else puts a - (k - a - b) end
# frozen_string_literal: true a, b, c, k = gets.split.map(&:to_i) if a + b >= k puts [k, a].min else puts a - (k - a - b) end
[ "literal.array.change", "call.add" ]
410,461
410,462
u434509016
ruby
p02683
N, M, X = gets.chomp.split(" ").map(&:to_i) DATA = [] N.times.map { gets.chomp }.each do |row| values = row.split(" ").map(&:to_i) DATA << {c: values.shift, a: values} end def hoge(arr) price = 0 lern = [] arr.each do |i| price += DATA[i][:c] M.times do |j| lern[j] = 0 unless lern[j] lern[j] += DATA[i][:a][j] end end { price: price, learned: lern.map{|l| X - l}.all?{|v| v <= 0} } end results = [] N.times do |j| (0..N-1).to_a.combination(j+1).to_a.each do |_arr| results << hoge(_arr) end end lern_arr = results.select{|h| h[:learned]} puts if lern_arr.count == 0 ? -1 : lern_arr.map{|h| h[:price]}.sort.first
N, M, X = gets.chomp.split(" ").map(&:to_i) DATA = [] N.times.map { gets.chomp }.each do |row| values = row.split(" ").map(&:to_i) DATA << {c: values.shift, a: values} end def hoge(arr) price = 0 lern = [] arr.each do |i| price += DATA[i][:c] M.times do |j| lern[j] = 0 unless lern[j] lern[j] += DATA[i][:a][j] end end { price: price, learned: lern.map{|l| X - l}.all?{|v| v <= 0} } end results = [] N.times do |j| (0..N-1).to_a.combination(j+1).to_a.each do |_arr| results << hoge(_arr) end end lern_arr = results.select{|h| h[:learned]} puts lern_arr.count == 0 ? -1 : lern_arr.map{|h| h[:price]}.sort.first
[]
411,180
411,181
u113279239
ruby
p02683
N, M, X = gets.split.map(&:to_i) BOOKS = N.times.map { cost, *parameters = gets.split.map(&:to_i) [cost, parameters] } def f(mask) total_cost = 0 skills = Array.new(M, 0) N.times do |i| next if mask[i] == 0 cost, parameters = BOOKS[i] total_cost += cost parameters.each_with_index do |x, idx| skills[idx] += x end end if skills.all? { |x| x >= X } total_cost else Float::INFINITY end end min_cost = Float::INFINITY (2 ** N - 1).times do |mask| cost = f(mask) if min_cost > cost min_cost = cost end end if min_cost == Float::INFINITY puts -1 else puts min_cost end
N, M, X = gets.split.map(&:to_i) BOOKS = N.times.map { cost, *parameters = gets.split.map(&:to_i) [cost, parameters] } def f(mask) total_cost = 0 skills = Array.new(M, 0) N.times do |i| next if mask[i] == 0 cost, parameters = BOOKS[i] total_cost += cost parameters.each_with_index do |x, idx| skills[idx] += x end end if skills.all? { |x| x >= X } total_cost else Float::INFINITY end end min_cost = Float::INFINITY (2 ** N).times do |mask| cost = f(mask) if min_cost > cost min_cost = cost end end if min_cost == Float::INFINITY puts -1 else puts min_cost end
[ "expression.operation.binary.remove" ]
411,504
411,505
u740836226
ruby
p02683
N,M,X = gets.chomp.split.map(&:to_i) C = N.times.map{gets.chomp.split.map(&:to_i)} D = C.transpose count = 0 (1..M).each do |i| if D[i].sum < X count += 1 end end if count != 0 puts "-1" exit end bits = [0, 1].repeated_permutation(N).to_a ans = (10 ** 5) * 12 bits.each do |bit| rikaido = [0] * (M + 1) (0..N-1).each do |j| if bit[j] == 1 (0..M).each do |k| rikaido[k] += C[j][k] if rikaido.all? { |n| n >= X } ans = rikaido[0] if ans >= rikaido[0] end end end end end puts ans
N,M,X = gets.chomp.split.map(&:to_i) C = N.times.map{gets.chomp.split.map(&:to_i)} D = C.transpose count = 0 (1..M).each do |i| if D[i].sum < X count += 1 end end if count != 0 puts "-1" exit end bits = [0, 1].repeated_permutation(N).to_a ans = (10 ** 5) * 12 bits.each do |bit| rikaido = [0] * (M + 1) (0..N-1).each do |j| if bit[j] == 1 (0..M).each do |k| rikaido[k] += C[j][k] if rikaido[1..M].all? { |n| n >= X } ans = rikaido[0] if ans >= rikaido[0] end end end end end puts ans
[ "control_flow.branch.if.condition.change" ]
411,554
411,555
u088211391
ruby
p02683
require 'matrix' n, m, x = gets.split.map(&:to_i) c = Array.new(n, 0) a = Array.new(n){Array.new(m, 0)} a = Matrix.zero(n, m) n.times do |i| b = gets.split.map(&:to_i) c[i] = b[0] 1.upto(m) do |j| a[i, j - 1] = b[j] end end m.times do |j| if a.column(j).to_a.sum < x puts "-1" exit end end #p c #p a min = Float::INFINITY 1.upto(2 ** n - 1) do |bit| sum = 0 ans = 0 m.times do |j| n.times do |i| if bit[i] == 1 sum += a[i, j] end # puts "bit=#{bit} #{bit[i]} a=#{a[i, j]} c=#{c[i]}" end break if sum < x end if sum >= x n.times do |i| if bit[i] == 1 ans += c[i] end end min = ans if min > ans end end puts min
require 'matrix' n, m, x = gets.split.map(&:to_i) c = Array.new(n, 0) a = Array.new(n){Array.new(m, 0)} a = Matrix.zero(n, m) n.times do |i| b = gets.split.map(&:to_i) c[i] = b[0] 1.upto(m) do |j| a[i, j - 1] = b[j] end end m.times do |j| if a.column(j).to_a.sum < x puts "-1" exit end end min = Float::INFINITY 1.upto(2 ** n - 1) do |bit| ans = 0 sum = 0 m.times do |j| sum = 0 n.times do |i| if bit[i] == 1 sum += a[i, j] end end break if sum < x end if sum >= x n.times do |i| if bit[i] == 1 ans += c[i] end end min = ans if min > ans end end puts min
[ "assignment.variable.change", "identifier.change" ]
411,650
411,651
u979552932
ruby
p02683
(N,M,X),*A=$<.map{_1.split.map &:to_i} p ((0..2**N).map{|i|c,*t=A.transpose.map{|x|N.times.sum{x[_1]*i[_1]}} t.min<X&&c}-[!1]).min||-1
(N,M,X),*A=$<.map{_1.split.map &:to_i} p ((0..2**N).map{|i|c,*t=A.transpose.map{|x|N.times.sum{x[_1]*i[_1]}} t.min<X||c}-[!p]).min||-1
[ "misc.opposites", "call.arguments.change", "expression.operation.binary.change", "identifier.replace.add", "literal.replace.remove" ]
411,871
411,872
u019489252
ruby
p02683
(N,M,X),*A=$<.map{_1.split.map &:to_i} p ((0..2**N).map{|i|c,*t=A.transpose.map{|x|N.times.sum{x[_1]*i[_1]}} t.min<X&&c}-[!p]).min||-1
(N,M,X),*A=$<.map{_1.split.map &:to_i} p ((0..2**N).map{|i|c,*t=A.transpose.map{|x|N.times.sum{x[_1]*i[_1]}} t.min<X||c}-[!p]).min||-1
[ "misc.opposites", "call.arguments.change", "expression.operation.binary.change" ]
411,873
411,872
u019489252
ruby
p02683
$input = $stdin.read.split("\n") N,M,X = $input.shift.split(" ").map(&:to_i) $input = $input.map{|line| line.split(" ").map(&:to_i)} def ok?(ai) return false if ai.count == 0 ai.map{|a| a[1..]}.transpose.all?{|line| line.sum >= X} end all = (0...N).to_a ans = Float::INFINITY (0...N).each do |r| mss = (all.combination(r).to_a) mss.each do |ms| ai = ms.map{|m| $input[m] } cost = ai.map{|a| a.first }.sum if ok?(ai) ans = [ans,cost].min end end end if ans.infinite? puts "-1" else puts ans end
$input = $stdin.read.split("\n") N,M,X = $input.shift.split(" ").map(&:to_i) $input = $input.map{|line| line.split(" ").map(&:to_i)} def ok?(ai) return false if ai.count == 0 ai.map{|a| a[1..]}.transpose.all?{|line| line.sum >= X} end all = (0...N).to_a ans = Float::INFINITY (1..N).each do |r| mss = (all.combination(r).to_a) mss.each do |ms| ai = ms.map{|m| $input[m] } cost = ai.map{|a| a.first }.sum if ok?(ai) ans = [ans,cost].min end end end if ans.infinite? puts "-1" else puts ans end
[ "literal.number.integer.change" ]
411,918
411,919
u381839731
ruby
p02683
$input = $stdin.read.split("\n") N,M,X = $input.shift.split(" ").map(&:to_i) $input = $input.map{|line| line.split(" ").map(&:to_i)} def ok?(ai) return false if ai.count == 0 ai.map{|a| a[1..]}.transpose.all?{|line| line.sum >= X} end all = (0...N).to_a ans = Float::INFINITY (1...N).each do |r| mss = (all.combination(r).to_a) mss.each do |ms| ai = ms.map{|m| $input[m] } cost = ai.map{|a| a.first }.sum if ok?(ai) ans = [ans,cost].min end end end if ans.infinite? puts "-1" else puts ans end
$input = $stdin.read.split("\n") N,M,X = $input.shift.split(" ").map(&:to_i) $input = $input.map{|line| line.split(" ").map(&:to_i)} def ok?(ai) return false if ai.count == 0 ai.map{|a| a[1..]}.transpose.all?{|line| line.sum >= X} end all = (0...N).to_a ans = Float::INFINITY (1..N).each do |r| mss = (all.combination(r).to_a) mss.each do |ms| ai = ms.map{|m| $input[m] } cost = ai.map{|a| a.first }.sum if ok?(ai) ans = [ans,cost].min end end end if ans.infinite? puts "-1" else puts ans end
[]
411,920
411,919
u381839731
ruby
p02683
(N,M,X),*A=$<.map{_1.split.map &:to_i} p (1..N).map{|n|A.combination(n).map{|e|e.transpose.drop(1).all?{X<=_1.sum}&&e.sum{_1[0]}}}.flatten.compact.min||-1
(N,M,X),*A=$<.map{_1.split.map &:to_i} p (1..N).map{|n|A.combination(n).map{|e|e.transpose.drop(1).all?{X<=_1.sum}&&e.sum{_1[0]}}}.flatten.select{_1}.min||-1
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
412,058
412,059
u657913472
ruby
p02683
(N,M,X),*A=$<.map{|e|e.split.map &:to_i} p (1...N).map{|n|A.combination(n).select{|e|e.transpose.drop(1).all?{|e|X<=e.inject(:+)}}.map{|e|e.inject(0){|s,x|s+x[0]}}}.flatten.min||-1
(N,M,X),*A=$<.map{|e|e.split.map &:to_i} p (1..N).map{|n|A.combination(n).select{|e|e.transpose.drop(1).all?{|e|X<=e.inject(:+)}}.map{|e|e.inject(0){|s,x|s+x[0]}}}.flatten.min||-1
[ "call.arguments.change" ]
412,060
412,061
u657913472
ruby
p02683
(N,M,X),*A=$<.map{|e|e.split.map &:to_i} p (1...N).map{|n|A.combination(n).select{|e|e.transpose.drop(1).all?{|e|X<=e.inject(:+)}}.map{|e|e.inject(0){|s,x|s+x[0]}}}.flatten.max||-1
(N,M,X),*A=$<.map{|e|e.split.map &:to_i} p (1..N).map{|n|A.combination(n).select{|e|e.transpose.drop(1).all?{|e|X<=e.inject(:+)}}.map{|e|e.inject(0){|s,x|s+x[0]}}}.flatten.min||-1
[ "call.arguments.change", "misc.opposites", "identifier.change", "expression.operation.binary.change" ]
412,062
412,061
u657913472
ruby
p02683
# frozen_string_literal: true n, m, x = gets.split.map(&:to_i) arr = [] alg = Array.new(m, 0) sum = 0 n.times do a = gets.split.map(&:to_i) (1..m).each do |i| alg[i - 1] += a[i] end sum += a[0] arr << a end unless alg.select { |i| i < x }.empty? puts -1 exit end (1..m).each do |i| arr.combination(i).each do |a| count = 0 al = Array.new(m, 0) a.each do |c, *v| count += c m.times do |i| al[i] += v[i] end end if al.select { |i| i < x }.empty? sum = count if sum > count end end end puts sum
# frozen_string_literal: true n, m, x = gets.split.map(&:to_i) arr = [] alg = Array.new(m, 0) sum = 0 n.times do a = gets.split.map(&:to_i) (1..m).each do |i| alg[i - 1] += a[i] end sum += a[0] arr << a end unless alg.select { |i| i < x }.empty? puts -1 exit end (1..n).each do |i| arr.combination(i).each do |a| count = 0 al = Array.new(m, 0) a.each do |c, *v| count += c m.times do |i| al[i] += v[i] end end if al.select { |i| i < x }.empty? sum = count if sum > count end end end puts sum
[ "identifier.change" ]
412,069
412,070
u437368899
ruby
p02683
n=gets.split.map(&:to_i) lines = [] while line=gets lines << line.chomp.split(' ').map(&:to_i) end result=[1000000000] for i in 1..lines.length combi=lines.combination(i).to_a for j in 0..combi.length-1 yen=0 v=Array.new(n[1],0) combi[j].each do |k| yen+=k[0] for l in 1..k.length-1 v[l-1]+=k[l] end end if v.all? {|m| m>=n[2]}==true result.push(yen) end end end if result.min==10000000000 puts -1 else puts result.min end
n=gets.split.map(&:to_i) lines = [] while line=gets lines << line.chomp.split(' ').map(&:to_i) end result=[10000000000] for i in 1..lines.length combi=lines.combination(i).to_a for j in 0..combi.length-1 yen=0 v=Array.new(n[1],0) combi[j].each do |k| yen+=k[0] for l in 1..k.length-1 v[l-1]+=k[l] end end if v.all? {|m| m>=n[2]}==true result.push(yen) end end end if result.min==10000000000 puts -1 else puts result.min end
[ "literal.number.integer.change", "assignment.value.change" ]
412,183
412,184
u590472228
ruby
p02683
N, M, X = gets.chomp.split(' ').map(&:to_i) C = Array.new N.times do |i| C[i] = gets.chomp.split(' ').map(&:to_i) end min = Float::INFINITY N.times do |i| combinations = (0..N-1).to_a.combination(i+1).to_a combinations.each do |combination| sum = Array.new(M, 0) M.times do |k| (i+1).times do |j| sum[k] += C[combination[j]][k] end end if sum.slice(1..-1).all?{ |value| value >= X } min = [min, sum[0]].min end end end p (min.infinite? ? -1 : min)
N, M, X = gets.chomp.split(' ').map(&:to_i) C = Array.new N.times do |i| C[i] = gets.chomp.split(' ').map(&:to_i) end min = Float::INFINITY N.times do |i| combinations = (0..N-1).to_a.combination(i+1).to_a combinations.each do |combination| sum = Array.new(M+1, 0) (M+1).times do |k| (i+1).times do |j| sum[k] += C[combination[j]][k] end end if sum.slice(1..-1).all?{ |value| value >= X } min = [min, sum[0]].min end end end p (min.infinite? ? -1 : min)
[ "assignment.change" ]
412,343
412,344
u576332644
ruby
p02683
N, M, X = gets.chomp.split(" ").map(&:to_i) B = Array.new(N).map{ gets.chomp.split(" ").map(&:to_i) } ans = [] (1...(1<<N)).each{|n| wk = Array.new(M+1, 0) (0..N).each{|k| if n[k] == 1 then (0...M).each{|m| wk[m] += B[k][m]} end } ans << wk[0] if wk[1..M].all?{|w| w >= X} } puts ans.empty? ? -1 : ans.min
N, M, X = gets.chomp.split(" ").map(&:to_i) B = Array.new(N).map{ gets.chomp.split(" ").map(&:to_i) } ans = [] (1...(1<<N)).each{|n| wk = Array.new(M+1, 0) (0..N).each{|k| if n[k] == 1 then (0..M).each{|m| wk[m] += B[k][m]} end } ans << wk[0] if wk[1..M].all?{|w| w >= X} } puts ans.empty? ? -1 : ans.min
[]
412,479
412,480
u276517671
ruby
p02683
N, M, X = gets.chomp.split(" ").map(&:to_i) B = Array.new(N).map{ gets.chomp.split(" ").map(&:to_i) } ans = [] (1...(1<<N)).each{|n| wk = Array.new(M, 0) (0..N).each{|k| if n[k] == 1 then (0...M).each{|m| wk[m] += B[k][m]} end } ans << wk[0] if wk[1...M].all?{|w| w >= X} } puts ans.empty? ? -1 : ans.min
N, M, X = gets.chomp.split(" ").map(&:to_i) B = Array.new(N).map{ gets.chomp.split(" ").map(&:to_i) } ans = [] (1...(1<<N)).each{|n| wk = Array.new(M+1, 0) (0..N).each{|k| if n[k] == 1 then (0..M).each{|m| wk[m] += B[k][m]} end } ans << wk[0] if wk[1..M].all?{|w| w >= X} } puts ans.empty? ? -1 : ans.min
[ "control_flow.branch.if.condition.change" ]
412,481
412,480
u276517671
ruby
p02684
require 'set' class Hash def push(key, value) self[key] = [] if self[key] == nil self[key].push(value) end end class Array def lower_bound(value) left = -1; right = self.length; while left + 1 < right mid = left + (right - left) / 2; if self[mid] >= value right = mid else left = mid end end right end def unique res = [self.first] each_cons(2) do |a, b| if a != b res.push(b) end end res end end def get_ints gets.split.map(&:to_i) end def get_ints_minus_one get_ints.map { |x| x - 1 } end def get_int gets.chomp.to_i end N, K = get_ints A = get_ints_minus_one hash = Hash.new stock = 0 cur = 0 num = 0 loop do break if num >= K if hash[cur].nil? hash[cur] = num else one_loop = num - hash[cur] zan = K - num stock = zan % one_loop binding.pry break end cur = A[cur] num += 1 end stock.times do |i| cur = A[cur] end puts cur+1
require 'set' class Hash def push(key, value) self[key] = [] if self[key] == nil self[key].push(value) end end class Array def lower_bound(value) left = -1; right = self.length; while left + 1 < right mid = left + (right - left) / 2; if self[mid] >= value right = mid else left = mid end end right end def unique res = [self.first] each_cons(2) do |a, b| if a != b res.push(b) end end res end end def get_ints gets.split.map(&:to_i) end def get_ints_minus_one get_ints.map { |x| x - 1 } end def get_int gets.chomp.to_i end N, K = get_ints A = get_ints_minus_one hash = Hash.new stock = 0 cur = 0 num = 0 loop do break if num >= K if hash[cur].nil? hash[cur] = num else one_loop = num - hash[cur] zan = K - num stock = zan % one_loop break end cur = A[cur] num += 1 end stock.times do |i| cur = A[cur] end puts cur+1
[ "call.remove" ]
412,967
412,968
u305883349
ruby
p02684
require 'set' class Hash def push(key, value) self[key] = [] if self[key] == nil self[key].push(value) end end class Array def lower_bound(value) left = -1; right = self.length; while left + 1 < right mid = left + (right - left) / 2; if self[mid] >= value right = mid else left = mid end end right end def unique res = [self.first] each_cons(2) do |a, b| if a != b res.push(b) end end res end end def get_ints gets.split.map(&:to_i) end def get_ints_minus_one get_ints.map { |x| x - 1 } end def get_int gets.chomp.to_i end N, K = get_ints A = get_ints_minus_one hash = Hash.new stock = 0 cur = 0 num = 0 loop do if hash[cur].nil? hash[cur] = num else one_loop = num - hash[cur] zan = K - num stock = zan % one_loop break end cur = A[cur] num += 1 end stock.times do |i| cur = A[cur] end puts cur+1
require 'set' class Hash def push(key, value) self[key] = [] if self[key] == nil self[key].push(value) end end class Array def lower_bound(value) left = -1; right = self.length; while left + 1 < right mid = left + (right - left) / 2; if self[mid] >= value right = mid else left = mid end end right end def unique res = [self.first] each_cons(2) do |a, b| if a != b res.push(b) end end res end end def get_ints gets.split.map(&:to_i) end def get_ints_minus_one get_ints.map { |x| x - 1 } end def get_int gets.chomp.to_i end N, K = get_ints A = get_ints_minus_one hash = Hash.new stock = 0 cur = 0 num = 0 loop do break if num >= K if hash[cur].nil? hash[cur] = num else one_loop = num - hash[cur] zan = K - num stock = zan % one_loop break end cur = A[cur] num += 1 end stock.times do |i| cur = A[cur] end puts cur+1
[]
412,969
412,968
u305883349
ruby
p02684
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i +=1 if i == k puts s exit end t[cur] >= 0 ? break : (t[cur] = i) end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i +=1 if i == k puts cur exit end t[cur] >= 0 ? break : (t[cur] = i) end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
[ "identifier.change", "call.arguments.change", "io.output.change" ]
413,922
413,923
u693378622
ruby
p02684
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i +=1 if i == k puts s exit end t[cur] > 0 ? break : t[cur] = i end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i +=1 if i == k puts cur exit end t[cur] >= 0 ? break : (t[cur] = i) end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
[ "identifier.change", "call.arguments.change", "io.output.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
413,924
413,923
u693378622
ruby
p02684
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i +=1 if i == k puts s exit end t[cur] >= 0 ? break : (t[cur] = i) end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i += 1 if i == k puts cur exit end t[cur] >= 0 ? break : t[cur] = i end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
[ "identifier.change", "call.arguments.change", "io.output.change" ]
413,922
413,925
u693378622
ruby
p02684
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i +=1 if i == k puts s exit end t[cur] > 0 ? break : t[cur] = i end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } cur = 1 t[1] = i = 0 loop do cur = a[cur] i += 1 if i == k puts cur exit end t[cur] >= 0 ? break : t[cur] = i end dist = t[cur] puts t.index((k - dist) % (i - dist) + dist) # cycle = i - dist # idx = (k - dist) % (i - dist) + dist
[ "identifier.change", "call.arguments.change", "io.output.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
413,924
413,925
u693378622
ruby
p02684
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } used = Array.new(n+1){ false } t[1] = i = 0 s = 1 used[1] = true loop do s = a[s] i +=1 used[s] ? break : used[s] = true t[s] = i end dist = t[s] cycle = i - dist if dist >= k puts s else idx = (k - dist) % cycle + dist puts t.index(idx) end
n, k = gets.to_s.split.map{|e|e.to_i} a = [0] + gets.to_s.split.map{|e|e.to_i} t = Array.new(n+1){ -1 } used = Array.new(n+1){ false } t[1] = i = 0 s = 1 used[1] = true loop do s = a[s] i +=1 # if i == k # puts s # exit # end used[s] ? break : used[s] = true t[s] = i end dist = t[s] cycle = i - dist if dist >= k puts t.index(k) else idx = (k - dist) % cycle + dist puts t.index(idx) end
[ "call.arguments.change", "call.add" ]
413,926
413,927
u693378622
ruby
p02684
(N, K), As = readlines.map{_1.split.map(&:to_i)} cs = Array.new(N + 1, 0) i, x, y = 1, [], [] until cs[i] == 2 (cs[i].zero? ? x : y) << i cs[i] += 1 i = As[i - 1] end puts K < x.size ? x[K - 1] : y[(K - x.size)%(y.size)]
(N, K), As = readlines.map{_1.split.map(&:to_i)} cs = Array.new(N + 1, 0) i, x, y = 1, [], [] until cs[i] == 2 (cs[i].zero? ? x : y) << i cs[i] += 1 i = As[i - 1] end puts K < x.size ? x[K] : y[(K - x.size)%(y.size)]
[ "expression.operation.binary.remove" ]
414,754
414,755
u304198114
ruby
p02684
(N, K), As = readlines.map{_1.split.map(&:to_i)} cs = Array.new(N + 1, 0) i, x, y = 1, [], [] until cs[i] == 2 (cs[i].zero? ? x : y) << i cs[i] += 1 i = As[i - 1] end puts K <= x.size ? x[K - 1] : y[(K - x.size)%(y.size)]
(N, K), As = readlines.map{_1.split.map(&:to_i)} cs = Array.new(N + 1, 0) i, x, y = 1, [], [] until cs[i] == 2 (cs[i].zero? ? x : y) << i cs[i] += 1 i = As[i - 1] end puts K < x.size ? x[K] : y[(K - x.size)%(y.size)]
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
414,756
414,755
u304198114
ruby
p02684
(N, K), As = readlines.map{_1.split.map(&:to_i)} cs = Array.new(N + 1, 0) i, xs, ys = 1, [1], [] cs[1] = 1 while cs[i] <= 2 i = As[i - 1] case cs[i] when 0; xs << i when 1; ys << i end cs[i] += 1 end puts K <= xs.size ? xs[K - 1] : ys[(K - xs.size)%ys.size]
(N, K), As = readlines.map{_1.split.map(&:to_i)} cs = Array.new(N + 1, 0) i, xs, ys = 1, [1], [] cs[1] = 1 while cs[i] <= 2 i = As[i - 1] case cs[i] when 0; xs << i when 1; ys << i end cs[i] += 1 end puts K < xs.size ? xs[K] : ys[(K - xs.size)%ys.size]
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
414,759
414,758
u304198114
ruby
p02684
n, k = gets.chomp.split.map(&:to_i) a = gets.chomp.split.map(&:to_i) cur = 0 cnt = Array.new(n, -1) while cnt[a[cur] - 1] == -1 cnt[a[cur] - 1] = cnt[cur] + 1 cur = a[cur] - 1 k -= 1 end k %= (cnt[cur] - cnt[a[cur] - 1] + 1) while k > 0 cnt[a[cur] - 1] = cnt[cur] + 1 cur = a[cur] - 1 k -= 1 end puts cur + 1
n, k = gets.chomp.split.map(&:to_i) a = gets.chomp.split.map(&:to_i) cur = 0 cnt = Array.new(n, -1) while cnt[a[cur] - 1] == -1 && k > 0 cnt[a[cur] - 1] = cnt[cur] + 1 cur = a[cur] - 1 k -= 1 end k %= (cnt[cur] - cnt[a[cur] - 1] + 1) while k > 0 cnt[a[cur] - 1] = cnt[cur] + 1 cur = a[cur] - 1 k -= 1 end puts cur + 1
[ "expression.operation.binary.add" ]
414,933
414,934
u482840940
ruby
p02684
n, k = gets.chomp.split(" ").map(&:to_i) a = gets.chomp.split(" ").map(&:to_i) memo = {} i = a[0] - 1 memo[a[0]] = 1 count = 2 while !memo.has_key?(a[i]) do memo[a[i]] = count i = a[i]-1 count += 1 end before_cycle_count = memo[a[i]] - 1 ans = memo.to_a if before_cycle_count >= k then puts ans[k-1][0] else tmp = (k-before_cycle_count) % (ans.size-before_cycle_count) + before_cycle_count puts ans[tmp-1][0] end
n, k = gets.chomp.split(" ").map(&:to_i) a = gets.chomp.split(" ").map(&:to_i) memo = {} i = a[0] - 1 memo[a[0]] = 1 count = 2 while !memo.has_key?(a[i]) do memo[a[i]] = count i = a[i]-1 count += 1 end before_cycle_count = memo[a[i]] ans = memo.to_a if before_cycle_count >= k then puts ans[k-1][0] else tmp = (k-before_cycle_count) % (ans.size-before_cycle_count+1) + before_cycle_count puts ans[tmp-1][0] end
[ "expression.operation.binary.remove" ]
415,294
415,295
u466332671
ruby
p02684
def input_n gets.to_i # 単一整数 end def input_s gets.chomp # 文字列。chompを付けないと改行文字がついてくる end def input_a gets.split.map(&:to_i) # スペースで区切られた複数の整数 end def input_o(num) num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある end def output_f(num) puts sprintf("%.12f", num) end n, k = input_a a = input_a b = Array.new(n, -1) index = 0 cnt = 0 while cnt < k if b[index] != -1 nokori = k - cnt amari = nokori % (cnt - b[index]) amari.times do |i| index = a[index] - 1 end puts index + 1 exit end b[index] = cnt index = a[index] - 1 cnt += 1 end puts a[index]
def input_n gets.to_i # 単一整数 end def input_s gets.chomp # 文字列。chompを付けないと改行文字がついてくる end def input_a gets.split.map(&:to_i) # スペースで区切られた複数の整数 end def input_o(num) num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある end def output_f(num) puts sprintf("%.12f", num) end n, k = input_a a = input_a b = Array.new(n, -1) index = 0 cnt = 0 while cnt < k if b[index] != -1 nokori = k - cnt amari = nokori % (cnt - b[index]) amari.times do |i| index = a[index] - 1 end puts index + 1 exit end b[index] = cnt index = a[index] - 1 cnt += 1 end puts index + 1
[ "call.arguments.change" ]
415,737
415,738
u876846619
ruby
p02684
n, k = gets.split.map!(&:to_i) a = gets.split.map!(&:to_i).unshift(0) x = 1 a1 = 1 a2 = a[a1] while a1 != a2 x += 1 a1 = a[a1] a2 = a[a[a2]] end y = 0 a1 = 1 a2 = a2 while a1 != a2 y += 1 a1 = a[a1] a2 = a[a[a2]] end k = (k - y) % x + y puts k.times.inject(1) { |ai, *| a[ai] }
n, k = gets.split.map!(&:to_i) a = gets.split.map!(&:to_i).unshift(0) x = 1 a1 = 1 a2 = a[a1] while a1 != a2 x += 1 a1 = a[a1] a2 = a[a[a2]] end y = 0 a1 = 1 a2 = a2 while a1 != a2 y += 1 a1 = a[a1] a2 = a[a[a2]] end k = (k - y) % x + y if k >= y puts k.times.inject(1) { |ai, *| a[ai] }
[]
415,833
415,834
u960319975
ruby
p02684
n,k = gets.split.map &:to_i as = gets.split.map &:to_i check = Array.new(n+1, false) trail = [] pos = 0 (n + 1).times{ if check[pos] then loop_start = trail.find_index(pos) loop_end = trail.size loop_size = loop_end - loop_start if k <= loop_start then puts trail[k - 1] + 1 else step = (k - loop_start) % loop_size puts trail[loop_start + step] + 1 end exit else check[pos] = true trail << pos pos = as[pos] - 1 end }
n,k = gets.split.map &:to_i as = gets.split.map &:to_i check = Array.new(n+1, false) trail = [] pos = 0 (n + 1).times{ if check[pos] then loop_start = trail.find_index(pos) loop_end = trail.size loop_size = loop_end - loop_start if k <= loop_start then puts trail[k] + 1 else step = (k - loop_start) % loop_size puts trail[loop_start + step] + 1 end exit else check[pos] = true trail << pos pos = as[pos] - 1 end }
[ "expression.operation.binary.remove" ]
416,024
416,025
u874414087
ruby
p02684
n,k = gets.split.map &:to_i as = gets.split.map &:to_i check = Array.new(n+1, false) trail = [] pos = 0 n.times{ if check[pos] then loop_start = trail.find_index(pos) loop_end = trail.size loop_size = loop_end - loop_start if k <= loop_start then puts trail[k - 1] + 1 else step = (k - loop_start) % loop_size puts trail[loop_start + step] + 1 end exit else check[pos] = true trail << pos pos = as[pos] - 1 end }
n,k = gets.split.map &:to_i as = gets.split.map &:to_i check = Array.new(n+1, false) trail = [] pos = 0 (n + 1).times{ if check[pos] then loop_start = trail.find_index(pos) loop_end = trail.size loop_size = loop_end - loop_start if k <= loop_start then puts trail[k] + 1 else step = (k - loop_start) % loop_size puts trail[loop_start + step] + 1 end exit else check[pos] = true trail << pos pos = as[pos] - 1 end }
[ "expression.operation.binary.remove" ]
416,026
416,025
u874414087
ruby
p02684
# frozen_string_literal: true n, k = gets.split.map(&:to_i) a = gets.split.map(&:to_i) h = Hash.new a.each_with_index do |e, i| h[i + 1] = e end c = [1] i = 1 hh = Hash.new { false } ind = 0 hh[1] = true loop do i = h[i] if hh[i] ind = c.index(i) break end c.push i hh[i] = true end if k <= c.size - 1 puts c[k] else puts c[ind - 1 + (k + 1 - ind) % (c.size - ind)] end
# frozen_string_literal: true n, k = gets.split.map(&:to_i) a = gets.split.map(&:to_i) h = Hash.new a.each_with_index do |e, i| h[i + 1] = e end c = [1] i = 1 hh = Hash.new { false } ind = 0 hh[1] = true loop do i = h[i] if hh[i] ind = c.index(i) break end c.push i hh[i] = true end if k <= c.size - 1 puts c[k] else puts c[ind..-1][(k - ind) % (c.size - ind)] end
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
416,074
416,075
u434509016
ruby
p02684
N, K = gets.chomp.split.map(&:to_i) A = gets.chomp.split.map {|i| i.to_i - 1 } idx = 0 m = { 0 => 0 } ans = nil (1..K).each do |i| idx = A[idx] if m[idx] # すでに通った c = i - m[idx] r = K - i ans = A[m[idx]..(i-1)][r % c] break end m[idx] = i end if ans puts ans + 1 else puts idx + 1 end
N, K = gets.chomp.split.map(&:to_i) A = gets.chomp.split.map {|i| i.to_i - 1 } idx = 0 m = { 0 => 0 } ans = nil (1..K).each do |i| idx = A[idx] if m[idx] c = i - m[idx] r = K - i ans = m.keys[m[idx]..-1][r % c] break end m[idx] = i end if ans puts ans + 1 else puts idx + 1 end
[ "assignment.value.change", "call.add" ]
416,489
416,490
u110341137
ruby
p02685
N,M,K = gets.split.map(&:to_i) Mod = 998244353 D,U = [1],[1] [K,N-K].min.times{|i| i+=1 D << D[-1]*(N-i)%Mod U << U[-1]*i%Mod } U.map!{|_| _.pow(Mod-2,Mod) } Com = lambda{|r| r = [N-1-r,r].min D[r] * U[r] % Mod } p (0..K).inject(0){|a,k| (a + Com[k] * M * (M-1).pow(N-1-k,Mod)) % Mod }
N,M,K = gets.split.map(&:to_i) Mod = 998244353 D,U = [1],[1] [K,N/2].min.times{|i| i+=1 D << D[-1] *(N-i) % Mod U << U[-1] * i % Mod } U.map!{|_| _.pow(Mod-2,Mod) } Com = lambda{|r| r = [N-1-r,r].min D[r] * U[r] % Mod } p (0..K).inject(0){|a,k| (a + Com[k] * M * (M-1).pow(N-1-k,Mod)) % Mod }
[]
417,026
417,027
u977697682
ruby
p02686
N = gets.to_i start_depth = 0 end_depth = 0 center_blocks= [] N.times{ s = gets.chomp d = 0 min_d = 0 max_d = 0 s.each_char{|c| if c == "(" d += 1 if d > max_d max_d = d end else d -= 1 if d < min_d min_d = d end end } depth = [-min_d, d - min_d] next if depth[0] == 0 && depth[1] == 0 if depth[0] == 0 start_depth += depth[1] elsif depth[1] == 0 end_depth += depth[0] else center_blocks << depth end } loop{ prev_size = center_blocks.size center_blocks.delete_if{|block| r = false if start_depth >= block[0] r = true start_depth += block[1] - block[0] elsif end_depth >= block[0] r = true end_depth += block[0] - block[1] end r } break if prev_size == center_blocks.size } if center_blocks.empty? && start_depth == end_depth puts "Yes" else puts "No" end
N = gets.to_i start_depth = 0 end_depth = 0 center_blocks= [] N.times{ s = gets.chomp d = 0 min_d = 0 max_d = 0 s.each_char{|c| if c == "(" d += 1 if d > max_d max_d = d end else d -= 1 if d < min_d min_d = d end end } depth = [-min_d, d - min_d] next if depth[0] == 0 && depth[1] == 0 if depth[0] == 0 start_depth += depth[1] elsif depth[1] == 0 end_depth += depth[0] else center_blocks << depth end } loop{ prev_size = center_blocks.size center_blocks.delete_if{|block| r = false if start_depth >= block[0] r = true start_depth += block[1] - block[0] elsif end_depth >= block[1] r = true end_depth += block[0] - block[1] end r } break if prev_size == center_blocks.size } if center_blocks.empty? && start_depth == end_depth puts "Yes" else puts "No" end
[ "literal.number.integer.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
417,460
417,461
u488526012
ruby
p02687
S = gets.to_s if S == "ABC" puts "ARC" else puts "ABC" end
S = gets.strip.to_s #問答無用で改行コードを落とせ if S == "ABC" puts "ARC" else puts "ABC" end
[ "call.add" ]
417,616
417,617
u313103408
ruby
p02687
S = gets.to_s if S == "ABC" then puts "ARC" else puts "ABC" end
S = gets.strip.to_s #問答無用で改行コードを落とせ if S == "ABC" puts "ARC" else puts "ABC" end
[ "call.add" ]
417,618
417,617
u313103408
ruby
p02687
S = gets.to_s if S == "ABC" then puts "ARC" else puts "ABC" end
S = gets.strip.to_s if (S == "ABC") then puts "ARC" else puts "ABC" end
[ "call.add", "control_flow.branch.if.condition.change" ]
417,618
417,620
u313103408
ruby
p02687
s=gets.chomp if s=="ABC" p "ARC" else p "ABC" end
s=gets.chomp if s=="ABC" puts "ARC" else puts "ABC" end
[ "call.function.change", "io.output.change" ]
417,634
417,635
u977506075
ruby
p02687
s = gets.chomp print "ABC"==s ? "ARC" : s
s = gets.chomp print "ABC"==s ? "ARC" : "ABC"
[ "call.arguments.change" ]
417,926
417,927
u019252409
ruby
p02687
if s == "ABC" puts "ARC" else puts"ABC" end
s = gets.chomp if s == "ABC" puts "ARC" else puts"ABC" end
[ "assignment.add" ]
418,536
418,537
u121289149
ruby
p02687
puts gets == "ABC" ? "ARC" : "ABC"
puts gets.chomp == "ABC" ? "ARC" : "ABC"
[ "control_flow.branch.if.condition.change", "call.add" ]
418,619
418,620
u541950811
ruby
p02687
if readline == "ARC" puts "ABC" else puts "ARC" end
if readline.chomp == "ARC" puts "ABC" else puts "ARC" end
[ "control_flow.branch.if.condition.change", "call.add" ]
418,621
418,622
u541950811
ruby
p02687
if gets().to_s == "ARC" puts "ABC" else puts "ARC" end
if readline.chomp == "ARC" puts "ABC" else puts "ARC" end
[ "identifier.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
418,623
418,622
u541950811
ruby
p02687
if gets() == "ARC" puts "ABC" else puts "ARC" end
if readline.chomp == "ARC" puts "ABC" else puts "ARC" end
[]
418,624
418,622
u541950811
ruby
p02687
if gets().to_s == "ARC" puts "ABC" else puts "ARC" end
if gets().chomp == "ARC" puts "ABC" else puts "ARC" end
[ "identifier.change", "control_flow.branch.if.condition.change" ]
418,623
418,625
u541950811
ruby
p02687
if gets() == "ARC" puts "ABC" else puts "ARC" end
if gets().chomp == "ARC" puts "ABC" else puts "ARC" end
[ "control_flow.branch.if.condition.change", "call.add" ]
418,624
418,625
u541950811
ruby
p02687
if gets()=="ABC" print "ARC\n" else print "ABC\n" end
if gets()=="ABC\n" print "ARC\n" else print "ABC\n" end
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
418,908
418,909
u579508806
ruby
p02687
s = gets if s == 'ARC' puts 'ABC' else puts 'ARC' end
s = gets.chomp if s == 'ARC' puts 'ABC' else puts 'ARC' end
[ "call.add" ]
418,937
418,938
u510200974
ruby
p02687
s = gets == 'ABC' ? 'ARC' : 'ABC' puts s
a = gets.chomp == 'ABC' ? 'ARC' : 'ABC' puts a
[ "assignment.variable.change", "identifier.change", "control_flow.branch.if.condition.change", "call.add", "call.arguments.change" ]
418,966
418,967
u514667801
ruby
p02687
s = gets.strip if s == 'ABC' p 'ARC' elsif p 'ABC' end
s = gets.chomp if s == 'ABC' puts 'ARC' elsif puts 'ABC' end
[ "assignment.value.change", "identifier.change", "call.function.change", "io.output.change" ]
418,989
418,990
u589974359
ruby
p02687
str = gets.to_s if str == "ABC" puts "ARC" else puts "ABC" end
str = gets.to_s.chomp if str == "ABC" puts "ARC" else puts "ABC" end
[ "call.add" ]
419,056
419,055
u021866120
ruby
p02687
n=gets.to_s puts n="ABC"? "ARC":"ABC"
n=gets.chomp.to_s puts n=="ABC" ? "ARC":"ABC"
[ "call.add", "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
419,095
419,096
u590472228
ruby
p02687
n = gets.chomp.split("") if n[1] == R puts "ABC" else puts "ARC" end
n = gets.chomp.split("") if n[1] == "R" puts "ABC" else puts "ARC" end
[ "control_flow.branch.if.condition.change" ]
419,139
419,140
u412789323
ruby
p02687
if gets == "ABC" then puts "ARC" else puts "ABC" end
if gets.chomp == "ABC" then puts "ARC" else puts "ABC" end
[ "control_flow.branch.if.condition.change", "call.add" ]
419,269
419,270
u713980442
ruby
p02687
S = gets.to_s if S == "ABC" puts "ARC" else if S == "ARC" puts "ABC" end end
S = gets.chomp.to_s if S == "ABC" puts "ARC" else if S == "ARC" puts "ABC" end end
[ "call.add" ]
419,313
419,314
u088211391
ruby
p02687
s = gets puts (s=='ARC') ? 'ABC' : 'ARC'
s = gets.chomp puts (s=='ARC') ? 'ABC' : 'ARC'
[ "call.add" ]
419,340
419,341
u374892957
ruby
p02687
contest = gets if contest.eql?("ABC") puts "ARC" else puts "ABC" end
contest = gets.chomp! if contest.eql?("ABC") puts "ARC" else puts "ABC" end
[ "call.add" ]
419,378
419,379
u201441274
ruby
p02687
S = gets if S == "ABC" puts "ARC" else puts "ABC" end
S = gets if S.include?("ABC") puts "ARC" else puts "ABC" end
[ "control_flow.branch.if.condition.change", "call.add" ]
419,493
419,494
u373586461
ruby
p02687
S = gets if S == "ABC" puts "ARC" else puts "ABC" end
S = gets.chomp if S == "ABC" puts "ARC" else puts "ABC" end
[ "call.add" ]
419,581
419,582
u123648284
ruby
p02687
S = gets.chomp puts "ARC" if S == ABC puts "ABC" if S == ARC
S = gets.chomp puts "ARC" if S == "ABC" puts "ABC" if S == "ARC"
[ "control_flow.branch.if.condition.change" ]
419,831
419,832
u226855113
ruby
p02687
n = $stdin.gets.chomp if n[2] == "B" puts "ARC" else puts "ABC" end
n = $stdin.gets.chomp if n[1] == "B" puts "ARC" else puts "ABC" end
[ "literal.number.integer.change", "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
419,850
419,851
u688809543
ruby
p02687
s=gets.chomp if s="ABC" puts "ARC" else puts "ABC" end
s=gets.chomp if s=="ABC" puts "ARC" else puts "ABC" end
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
419,885
419,886
u744908753
ruby
p02687
def solve s = gets if s == 'ABC' print 'ARC' else print 'ABC' end end solve
def solve s = gets.chomp if s == 'ABC' print 'ARC' else print 'ABC' end end solve
[ "call.add" ]
419,916
419,917
u595657182
ruby
p02687
a = gets p a == "ABC" ? "ARC" : "ABC"
a = gets.chomp puts a == "ABC" ? "ARC" : "ABC"
[ "assignment.value.change", "call.add", "io.output.change" ]
419,999
420,000
u329977093
ruby
p02688
N,K=gets.chomp.split.map(&:to_i) p array=(1..N).to_a K.times{ a=gets.to_i gets.split.map(&:to_i).each do |n| p n array=array.select{|k| k!=n} p array if array.size==0 break end end } puts array.size
N,K=gets.chomp.split.map(&:to_i) array=(1..N).to_a K.times{ a=gets.to_i gets.split.map(&:to_i).each do |n| array=array.select{|k| k!=n} if array.size==0 break end end } puts array.size
[ "io.output.change", "call.remove" ]
420,110
420,111
u085647568
ruby
p02688
N,K=gets.chomp.split.map(&:to_i) array=(1..N).to_a K.times{ a=gets.to_i gets.split.chomp.map(&:to_i).each do |n| array=array.select{|k| k=!n} if array.size==0 break end end } puts array.size
N,K=gets.chomp.split.map(&:to_i) array=(1..N).to_a K.times{ a=gets.to_i gets.split.map(&:to_i).each do |n| array=array.select{|k| k!=n} if array.size==0 break end end } puts array.size
[ "call.remove", "assignment.variable.change", "identifier.change", "expression.operation.unary.logical.remove" ]
420,112
420,111
u085647568
ruby
p02688
n,k=gets.chomp.split(' ').map(&:to_i) ans = [*(1..n)] k.times do gets candy = gets.chomp.split(' ').map(&:to_i) candy.each do |c| if ans.include?(c) ans.delete(c) end end end puts ans
n,k=gets.chomp.split(' ').map(&:to_i) ans = [*(1..n)] k.times do gets candy = gets.chomp.split(' ').map(&:to_i) candy.each do |c| if ans.include?(c) ans.delete(c) end end end puts ans.size
[ "call.add" ]
420,353
420,354
u710018917
ruby
p02688
N,K = gets.split.map &:to_i p ((1..K).to_a - K.times.map{ gets; gets.split.map &:to_i }.flatten.uniq.sort).count
N,K = gets.split.map &:to_i p ((1..N).to_a - K.times.map{ gets; gets.split.map &:to_i }.flatten.uniq.sort).count
[ "call.arguments.change", "expression.operation.binary.change" ]
420,400
420,401
u009976559
ruby
p02688
N, K = gets.split.map(&:to_i) cnt = [0]*n K.times do d = gets.to_i a = gets.split.map(&:to_i) a.each do |v| cnt[v-1] += 1 end end p cnt.select{|v| v==0}.size
N, K = gets.split.map(&:to_i) cnt = [0]*N K.times do d = gets.to_i a = gets.split.map(&:to_i) a.each do |v| cnt[v-1] += 1 end end p cnt.select{|v| v==0}.size
[ "assignment.value.change", "expression.operation.binary.change" ]
420,498
420,499
u423966555
ruby
p02688
n, k = gets.split.map(&:to_i) ary = [] (k*2).times do ary << gets.split.map(&:to_i) end ans = Array.new(3, 0) ary.each_with_index do |k, i| if i.odd? k.each do |l| ans[l-1]+=1 end end end count = 0 ans.each do |m| count+=1 if m==0 end puts count
n, k = gets.split.map(&:to_i) ary = [] (k*2).times do ary << gets.split.map(&:to_i) end ans = Array.new(n, 0) ary.each_with_index do |k, i| if i.odd? k.each do |l| ans[l-1]+=1 end end end count = 0 ans.each do |m| count+=1 if m==0 end puts count
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "call.arguments.change" ]
420,601
420,602
u514143079
ruby
p02688
N, K = gets.split.map(&:to_i) n = {} K.times do gets gets.split.map {|i| n[i] = true} end puts n.keys.size
N, K = gets.split.map(&:to_i) n = {} K.times do gets gets.split.map {|i| n[i] = true} end puts N - n.keys.size
[ "expression.operation.binary.add" ]
420,794
420,795
u984479733
ruby
p02688
number,type = gets.chomp!.split(" ").map(&:to_i) array = [] type*2.times do |i| if i%2 == 0 num = gets end if i%2 == 1 array << gets.chomp!.split(" ").map(&:to_i) end end p number - array.flatten.uniq.length
number,type = gets.chomp!.split(" ").map(&:to_i) array = [] roop = type*2 roop.times do |i| if i%2 == 0 num = gets end if i%2 == 1 array << gets.chomp!.split(" ").map(&:to_i) end end p number - array.flatten.uniq.length
[ "call.add" ]
420,859
420,860
u201441274
ruby
p02688
ARRAY = gets.split.map(&:to_i) N = ARRAY[0] K = ARRAY[1] $a = Array.new(N, 1) K.times do gets tmp = gets.split.map(&:to_i) tmp.each do |e| $a[e - 1] = 0 end end p $a puts $a.select{|v| v == 1}.count
ARRAY = gets.split.map(&:to_i) N = ARRAY[0] K = ARRAY[1] $a = Array.new(N, 1) K.times do gets tmp = gets.split.map(&:to_i) tmp.each do |e| $a[e - 1] = 0 end end puts $a.select{|v| v == 1}.count
[ "call.remove" ]
421,193
421,194
u990758634
ruby