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
p02916
N = gets.to_i as, bs, cs = 3.times.map{gets.split(' ').map{|n| n.to_i}} sum, prev = 0, 0 as.each do |a| sum += bs[a - 1] if a == prev + 1 sum += cs[a - 2] end prev = a end p sum
N = gets.to_i as, bs, cs = 3.times.map{gets.split(' ').map{|n| n.to_i}} sum, prev = 0, -1 as.each do |a| sum += bs[a - 1] if a == prev + 1 sum += cs[a - 2] end prev = a end p sum
[ "assignment.value.change", "expression.operation.unary.add" ]
712,815
712,816
u543466827
ruby
p02916
n = gets.to_i a,b,c = (0..2).map{gets.split.map(&:to_i)} s = b.inject(:+) before_num = 0 a.each do |num| if num == before_num + 1 s = s + c[num - 2] end before_num = num end p s
n = gets.to_i a,b,c = (0..2).map{gets.split.map(&:to_i)} s = b.inject(:+) before_num = -1 a.each do |num| if num == before_num + 1 s = s + c[num - 2] end before_num = num end p s
[ "assignment.value.change", "expression.operation.unary.add" ]
712,853
712,854
u562082015
ruby
p02916
N = gets.to_i A = gets.split(" ") B = gets.split(" ") C = gets.split(" ") score = -1 a_before = 0 A.each do |a| a = a.to_i score = score + B[a-1].to_i if a == a_before + 1 score = score + C[a-2].to_i end a_before = a end puts score
N = gets.to_i A = gets.split(" ") B = gets.split(" ") C = gets.split(" ") score = 0 a_before = -1 A.each do |a| a = a.to_i score = score + B[a-1].to_i if a == a_before + 1 score = score + C[a-2].to_i end a_before = a end puts score
[ "assignment.add", "assignment.remove" ]
712,855
712,856
u562082015
ruby
p02916
N = gets.to_i A = gets.split(" ") B = gets.split(" ") C = gets.split(" ") score = 0 a_before = 0 A.each do |a| a = a.to_i score = score + B[a-1].to_i if a == a_before + 1 score = score + C[a-2].to_i end a_before = a end puts score
N = gets.to_i A = gets.split(" ") B = gets.split(" ") C = gets.split(" ") score = 0 a_before = -1 A.each do |a| a = a.to_i score = score + B[a-1].to_i if a == a_before + 1 score = score + C[a-2].to_i end a_before = a end puts score
[ "assignment.value.change", "expression.operation.unary.add" ]
712,857
712,856
u562082015
ruby
p02916
n = gets.chomp.to_i a = gets.chomp.split.map(&:to_i) b = gets.chomp.split.map(&:to_i) c = gets.chomp.split.map(&:to_i) ans = 0 before = 100 n.times do |i| ans += b[a[i]-1] ans += c[a[i-1]-1] if i - before == 2 before = a[i]-1 end puts ans
n = gets.chomp.to_i a = gets.chomp.split.map(&:to_i) b = gets.chomp.split.map(&:to_i) c = gets.chomp.split.map(&:to_i) ans = 0 before = 100 n.times do |i| ans += b[a[i]-1] ans += c[a[i-1]-1] if a[i] - before == 1 before = a[i] end puts ans
[ "control_flow.branch.if.condition.change", "literal.number.integer.change", "expression.operation.binary.remove" ]
713,058
713,059
u798803126
ruby
p02916
gets a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) c=gets.split.map(&:to_i) r=0 prev=nil for a_i in a r+=b[a_i-1] + if prev && prev.succ==a_i then c[prev-1] else 0 end prev=a_i end
gets a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) c=gets.split.map(&:to_i) r=0 prev=nil for a_i in a r+=b[a_i-1] + if prev && prev.succ==a_i then c[prev-1] else 0 end prev=a_i end puts r
[ "call.add" ]
713,156
713,157
u098367142
ruby
p02916
#1行目 hoge = gets.chomp.to_i - 1 #2行目読み込み a = gets.chomp.split(" ").map!{|i| i.to_i} b= gets.chomp.split(" ").map!{|i| i.to_i} c = gets.chomp.split(" ").map!{|i| i.to_i} unchi = b[a[0]-1] for i in 1..hoge do unchi = unchi + b[a[i]-1] if a[i] == a[i-1] + 1 unchi = unchi + c[i-1] end end print unchi
#1行目 hoge = gets.chomp.to_i - 1 #2行目読み込み a = gets.chomp.split(" ").map!{|i| i.to_i} b= gets.chomp.split(" ").map!{|i| i.to_i} c = gets.chomp.split(" ").map!{|i| i.to_i} unchi = b[a[0]-1] for i in 1..hoge do unchi = unchi + b[a[i]-1] if a[i] == a[i-1] + 1 unchi = unchi + c[a[i]-2] end end print unchi
[ "literal.number.integer.change", "assignment.value.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
713,202
713,203
u401248484
ruby
p02916
n = gets.strip.to_i a = gets.strip.split.map(&:to_i) b = gets.strip.split.map(&:to_i) c = gets.strip.split.map(&:to_i) ans = 0 previous_one = 0 a.each do |i| ans += b[i-1] ans += c[i-2] if previous_one == i - 1 previous_one = i end p ans
n = gets.strip.to_i a = gets.strip.split.map(&:to_i) b = gets.strip.split.map(&:to_i) c = gets.strip.split.map(&:to_i) ans = 0 previous_one = -1 a.each do |i| ans += b[i-1] ans += c[i-2] if previous_one == i - 1 previous_one = i end p ans
[ "assignment.value.change", "expression.operation.unary.add" ]
713,552
713,553
u507611905
ruby
p02916
n=gets.to_i a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) c=gets.split.map(&:to_i) b_sum=b.reduce(:+) c_sum=a.each_cons(2).select{|x,y| x+1==y }.map{|x,_|c[x-1]}.reduce(:+) print(b_sum+c_sum)
n=gets.to_i a=gets.split.map(&:to_i) b=gets.split.map(&:to_i) c=gets.split.map(&:to_i) b_sum=b.reduce(0,:+) c_sum=a.each_cons(2).select{|x,y| x+1==y }.map{|x,_|c[x-1]}.reduce(0,:+) print(b_sum+c_sum)
[ "call.arguments.add" ]
713,573
713,574
u702482655
ruby
p02917
lines = [] while line = gets lines << line.chomp.split(' ').map(&:to_i) end N = lines[0][0] b = [] for i in 1..N-1 do b.push(lines[1][i-1]) end def min(x,y) if x > y then return y else return x end end ans = [] for i in 1..N do if i == 0 then ans.push(b[0]) elsif i == N then ans.push(b[-1]) else ans.push(min(b[i-2], b[i-1])) end end result = 0 for i in 1..N do result += ans[i-1] end print result
lines = [] while line = gets lines << line.chomp.split(' ').map(&:to_i) end N = lines[0][0] b = [] for i in 1..N-1 do b.push(lines[1][i-1]) end def min(x,y) if x > y then return y else return x end end ans = [] for i in 1..N do if i == 1 then ans.push(b[0]) elsif i == N then ans.push(b[i-2]) else ans.push(min(b[i-2], b[i-1])) end end result = 0 for i in 1..N do result += ans[i-1] end print result
[ "literal.number.integer.change", "control_flow.branch.if.condition.change", "call.arguments.change", "variable_access.subscript.index.change" ]
713,701
713,702
u569559028
ruby
p02917
n,*b=gets(p).split.map &:to_i p,s=b[-1],0 b.reverse.map{|x|s+=(x<=p ? x : p);p=x} p s
n,*b=gets(p).split.map &:to_i p,s=b[-1],0 b.reverse.map{|x|s+=(x<=p ? x : p);p=x} p s+b[0]
[ "expression.operation.binary.add" ]
713,948
713,949
u408023666
ruby
p02917
n = gets.to_i b = gets.chomp.split(" ").map(&:to_i) a = [] a.push(b.first) (1...n-2).each do |idx| b[idx] >= b[idx+1] ? a.push(b[idx+1]) : a.push(b[idx]) end a.push(b.last) puts a.inject(:+)
n = gets.to_i b = gets.chomp.split(" ").map(&:to_i) a = [] a.push(b.first) (0...n-2).each do |idx| b[idx] >= b[idx+1] ? a.push(b[idx+1]) : a.push(b[idx]) end a.push(b.last) puts a.inject(:+)
[ "literal.number.integer.change" ]
714,042
714,043
u333374716
ruby
p02917
d=[] ((_=`dd`.split.map(&:to_i)<<114514)[0]=_[1]).each_cons(2){|i|d<<i.min} p d.inject(:+)
d=[] (_=`dd`.split.map(&:to_i)<<114514)[0]=_[1] _.each_cons(2){|i|d<<i.min} p d.inject(:+)
[]
714,172
714,173
u264508862
ruby
p02917
a=gets.to_i b=gets.split.map(&:to_i) b.unshift(b[0]) b<<114514 d=[] p b b.each_cons(2){|i|d<<i.min} p d.inject(:+)
a=gets.to_i b=gets.split.map(&:to_i) b.unshift(b[0]) b<<114514 d=[] b.each_cons(2){|i|d<<i.min} p d.inject(:+)
[]
714,174
714,175
u264508862
ruby
p02917
n = gets.to_i b = gets.split.map &:to_i b = [Float::INFINITY] + b + [Float::INFINITY] (0...n).inject(0){|s, i|s+b[i, 2].min}
n = gets.to_i b = gets.split.map &:to_i b = [Float::INFINITY] + b + [Float::INFINITY] p (0...n).inject(0){|s, i|s+b[i, 2].min}
[ "io.output.change", "call.add" ]
714,229
714,230
u976045235
ruby
p02917
_n = gets.to_i b = gets.split.map(&:to_i) p b[0] + b[-1] + b.each_cons(2).map(&:min).reduce(&:+)
_n = gets.to_i b = gets.split.map(&:to_i) p b[0] + b[-1] + b.each_cons(2).map(&:min).reduce(0, &:+)
[ "call.arguments.add" ]
714,358
714,359
u793733774
ruby
p02917
n = gets.chomp.to_i b_arr = [10**5+1] + gets.chomp.split(" ").map(&:to_i) + [10**5+1] a_arr = [] b_arr.each_cons(2).with_index do |b1, b2| if b1 > b2 then a_arr << b2 else a_arr << b1 end end puts a_arr.inject(&:+)
n = gets.chomp.to_i b_arr = [10**5+1] + gets.chomp.split(" ").map(&:to_i) + [10**5+1] a_arr = [] b_arr.each_cons(2) do |b1, b2| if b1 > b2 then a_arr << b2 else a_arr << b1 end end puts a_arr.inject(&:+)
[ "call.remove" ]
714,468
714,469
u257668305
ruby
p02917
n = gets.chomp.to_i b_arr = [10**5+1] + gets.chomp.split(" ").map(&:to_i) + [10**5+1] a_arr = [] b_arr.each_cons(2).with_index do |b1, b2| if b1 > b2 then a_arr << b2 else a_arr << b1 end end puts a_arr.inject(&:+)
n = gets.chomp.to_i b_arr = [10**5+1] + gets.chomp.split(" ").map(&:to_i) + [10**5+1] a_arr = [] b_arr.each_cons(2).with_index do |(b1, b2)| if b1 > b2 then a_arr << b2 else a_arr << b1 end end puts a_arr.inject(&:+)
[]
714,468
714,470
u257668305
ruby
p02917
inputs = readlines n = inputs[0].to_i as = Array.new(n) bs = inputs[1].split(' ').map(&:to_i) (0..n-2).each do |i| if as[i] as[i] = bs[i] if as[i] > bs[i] else as[i] = bs[i] end if as[i + 1] as[i + 1] = bs[i] if as[i + 1] > bs[i] else as[i + 1] = bs[i] end end p as puts as.inject(:+)
inputs = readlines n = inputs[0].to_i as = Array.new(n) bs = inputs[1].split(' ').map(&:to_i) (0..n-2).each do |i| if as[i] as[i] = bs[i] if as[i] > bs[i] else as[i] = bs[i] end if as[i + 1] as[i + 1] = bs[i] if as[i + 1] > bs[i] else as[i + 1] = bs[i] end end puts as.inject(:+)
[ "call.remove" ]
714,605
714,606
u622715972
ruby
p02918
N, K = gets.split(" ").map(&:to_i) S = gets.split(" ").chars count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
N, K = gets.split(" ").map(&:to_i) S = gets.chomp.split("") count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
[ "call.add", "literal.string.change", "assignment.value.change", "call.arguments.change", "call.remove" ]
714,956
714,957
u729911058
ruby
p02918
N, K = gets.split(" ").map(&:to_i) S = gets.split(" ") count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
N, K = gets.split(" ").map(&:to_i) S = gets.chomp.split("") count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
[ "call.add", "literal.string.change", "assignment.value.change", "call.arguments.change" ]
714,958
714,957
u729911058
ruby
p02918
N, K = gets.split(" ").map(&:to_i) S = gets.split(" ").chars count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
N, K = gets.split(" ").map(&:to_i) S = gets.chomp.chars count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
[ "assignment.value.change", "identifier.change", "call.arguments.change" ]
714,956
714,960
u729911058
ruby
p02918
N, K = gets.split(" ").map(&:to_i) S = gets.split(" ") count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
N, K = gets.split(" ").map(&:to_i) S = gets.chomp.chars count = 0 S.each_cons(2) {|x, y| count += 1 if x != y} puts count <= 2 * K ? N - 1 : N - count + 2 * K - 1
[ "call.arguments.change" ]
714,958
714,960
u729911058
ruby
p02918
line = gets.split(' ').map(&:to_i) n = line[0] k = line[1] s = gets.split('') start = 0 for i in 0..n-2 if s[i] == s[i+1] then start += 1 end end value = 2 * k + start if value < n-1 then value = n-1 end puts value
line = gets.split(' ').map(&:to_i) n = line[0] k = line[1] s = gets.split('') start = 0 for i in 0..n-2 if s[i] == s[i+1] then start += 1 end end value = 2 * k + start if value > n-1 then value = n-1 end puts value
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
715,142
715,143
u387173453
ruby
p02918
line = gets.split(' ').map(&:to_i) n = line[0] k = line[1] s = gets.split('') start = 0 for i in 0..n-2 if s[i] == s[i+1] then start += 1 end end value = 2 * k + start if value < n-1 then value = n-1 end puts value
line = gets.split(' ').map(&:to_i) n = line[0] k = line[1] s = gets.split('') start = 0 for i in 0..n-2 if s[i] == s[i+1] then start += 1 end end value = 2 * k + start if value > n-1 then value = n-1 end p value
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "identifier.change" ]
715,142
715,144
u387173453
ruby
p02918
n,k = gets.chomp.split.collect{ |item| item.to_i} s = gets.chomp s.insert(0,"R") s += "L" ans = n badn = 0 1.upto(n) do |ni| if(s[i] == "R") badn += 1 if (s[i] != s[i+1]) else badn += 1 if (s[i] != s[i-1]) end end ans -= [1,(badn - 2*k)].max puts ans
n,k = gets.chomp.split.collect{ |item| item.to_i} s = gets.chomp s.insert(0,"R") s += "L" ans = n badn = 0 1.upto(n) do |i| if(s[i] == "R") badn += 1 if (s[i] != s[i+1]) else badn += 1 if (s[i] != s[i-1]) end end ans -= [1,(badn - 2*k)].max puts ans
[ "identifier.change" ]
715,545
715,546
u552366486
ruby
p02921
s = gets.chomp.split("")- t = gets.chomp.split("")- ans = 0 3.times do |i| ans += 1 if s[i] == t[i] end puts ans
s = gets.chomp.split("") t = gets.chomp.split("") ans = 0 3.times do |i| ans += 1 if s[i] == t[i] end puts ans
[]
716,148
716,149
u466332671
ruby
p02921
s,t=$< p (0..2).count{s[_1]==t[_1]}
s,t=*$< p (0..2).count{s[_1]==t[_1]}
[]
716,150
716,151
u657913472
ruby
p02921
st = gets.chomp.split("") st2 = gets.chomp.split("") i = 0 count = 0 3.times do if st[i] == st2[i] count += 1 i += 1 end i += 1 end puts count
st = gets.chomp.split("") st2 = gets.chomp.split("") i = 0 count = 0 3.times do if st[i] == st2[i] count += 1 i += 1 else i += 1 end end puts count
[]
716,374
716,375
u096381099
ruby
p02921
p [gets, gets].map(&:chars).transpose.count {|a| a[0] == a[1]}
p [gets, gets].map(&:chars).transpose.count{|a| a[0]==a[1]}-1
[ "expression.operation.binary.add" ]
716,495
716,496
u370564845
ruby
p02921
p [gets.chop, gets].map(&:chars).transpose.count {|a| a[0] == a[1]}
p [gets, gets].map(&:chars).transpose.count{|a| a[0]==a[1]}-1
[ "call.remove" ]
716,497
716,496
u370564845
ruby
p02921
s = gets.chomp t = gets.chomp count = 0 3.times do |i| if s[i] == s[i] count += 1 end end puts count
s = gets.chomp t = gets.chomp count = 0 3.times do |i| if s[i] == t[i] count += 1 end end puts count
[ "identifier.change", "control_flow.branch.if.condition.change" ]
716,523
716,524
u370134300
ruby
p02921
S = gets.chomp T = gets.chomp ans = 0 2.times do |i| ans += 1 if S[i] == T[i] end puts ans
S = gets.chomp T = gets.chomp ans = 0 3.times do |i| ans += 1 if S[i] == T[i] end puts ans
[ "literal.number.integer.change" ]
716,531
716,532
u846185950
ruby
p02921
puts gets.chpmp.chars.zip(gets.chomp.chars).select{|x,y|x==y}.size
puts gets.chomp.chars.zip(gets.chomp.chars).select{|x,y|x==y}.size
[ "identifier.change", "call.arguments.change" ]
716,571
716,572
u056944756
ruby
p02921
n=gets.chomp.to_s m=gets.chomp.to_s count=0 for i in 1..3 if n[i]==m[i] count=count+1 end end puts count
n=gets.chomp.to_s m=gets.chomp.to_s count=0 for i in 0..2 if n[i]==m[i] count=count+1 end end puts count
[ "literal.number.integer.change" ]
716,634
716,635
u375695365
ruby
p02921
s = gets.split("") t = gets.split("") num = 0 for i in 0..2 do if s(i) === t(i) then num = num + 1 end end print(num)
s = gets.split("") t = gets.split("") num = 0 for i in 0..2 do if s[i] === t[i] then num = num + 1 end end print(num)
[ "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
716,715
716,716
u291303244
ruby
p02921
s = gets.chomp t = gets.chomp p (0..s.length).select{|i| s[i]==t[i]}
s = gets.chomp t = gets.chomp p (0...s.length).count{|i| s[i]==t[i]}
[ "call.arguments.change", "identifier.change" ]
716,821
716,822
u976045235
ruby
p02921
forecast = gets.chomp result = gets.chomp forecast_array = forecast.split('') result_array = result.split('') correct = 0 index = 0 3.times do if forecast_array[index] == result_array[index] correct += 1 end end puts correct
forecast = gets.chomp result = gets.chomp forecast_array = forecast.split('') result_array = result.split('') correct = 0 index = 0 3.times do if forecast_array[index] == result_array[index] correct += 1 end index += 1 end puts correct
[]
716,889
716,890
u375808001
ruby
p02921
tmp = gets tmp2 = gets ans = 0 3.times do |n| ans += 1 if tmp[n] == tmp2[n] end ans
tmp = gets tmp2 = gets ans = 0 3.times do |n| ans += 1 if tmp[n] == tmp2[n] end puts ans
[ "io.output.change", "call.add" ]
716,919
716,920
u218637460
ruby
p02921
s = gets.chomp t = gets.chomp ans = 0 s.chars.each_with_index do |c, i| ans += 1 if c == t.chards[i] end puts ans
s = gets.chomp t = gets.chomp ans = 0 s.chars.each_with_index do |c, i| ans += 1 if c == t.chars[i] end puts ans
[ "identifier.change", "control_flow.branch.if.condition.change" ]
717,253
717,254
u981932242
ruby
p02921
s = gets.chomp t = gets.chomp count = 1 if s[0] == t[0] count += 1 if s[1] == t[1] count += 1 if s[2] == t[2] puts count
s = gets.chomp t = gets.chomp count = 0 count += 1 if s[0] == t[0] count += 1 if s[1] == t[1] count += 1 if s[2] == t[2] puts count
[]
717,306
717,307
u726523100
ruby
p02921
input_lines = gets.chop.split("").map(&:to_s) input_lines2 = gets.chop.split("").map(&:to_s) count = 0 for i in 0...(input_lines.size - 1) if input_lines[i] == input_lines2[i] count = count + 1 end end puts count
input_lines = gets.chop.split("").map(&:to_s) input_lines2 = gets.chop.split("").map(&:to_s) count = 0 for i in 0...input_lines.size if input_lines[i] == input_lines2[i] count = count + 1 end end puts count
[]
717,355
717,356
u302312161
ruby
p02921
S=gets.chomp.chars RRR T=gets.chomp.chars SSS ary = S.zip T puts ary.count{|attr| attr.first == attr.last}
S=gets.chomp.chars T=gets.chomp.chars ary = S.zip T puts ary.count{|attr| attr.first == attr.last}
[]
717,359
717,360
u792512290
ruby
p02921
S=gets.chomp.split T=gets.chomp.split ary = S.zip T puts ary.count{|attr| attr.first == attr.last}
S=gets.chomp.chars T=gets.chomp.chars ary = S.zip T puts ary.count{|attr| attr.first == attr.last}
[ "assignment.value.change", "identifier.change" ]
717,361
717,360
u792512290
ruby
p02921
a = gets.split(" ").map{|x| x.to_s} b = gets.split(" ").map{|x| x.to_s} count = 0 3.times do |i| if a[i] == b[i] count += 1 end end p count
a = gets.split("").map{|x| x.to_s} b = gets.split("").map{|x| x.to_s} count = 0 3.times do |i| if a[i] == b[i] count += 1 end end p count
[ "literal.string.change", "assignment.value.change", "call.arguments.change" ]
717,408
717,409
u912087911
ruby
p02922
a, b = gets.chomp.split.map(&:to_i) puts (b + a) / (a - 1) - 1
a, b = gets.chomp.split.map(&:to_i) puts (b + a - 3) / (a - 1)
[ "expression.operation.binary.remove" ]
718,284
718,285
u482840940
ruby
p02922
A, B = gets.split.map(&:to_i) if B == 1 puts 0 end count = 1 con = A loop do if B <= con break end con += A - 1 count += 1 end puts count
A, B = gets.split.map(&:to_i) if B == 1 puts 0 exit end count = 1 con = A loop do if B <= con break end con += A - 1 count += 1 end puts count
[ "control_flow.exit.add" ]
718,615
718,616
u039293076
ruby
p02922
a b =gets.split.map(&:to_i) out=1 answer = 0 while out < b do out -=1 out +=a answer +=1 end puts answer
a, b =gets.split.map(&:to_i) out=1 answer = 0 while out < b do out -=1 out +=a answer +=1 end puts answer
[]
718,696
718,697
u099319150
ruby
p02922
a, b = gets.split.map(&:to_i) puts ((b - 1) / (a - 1)).ceil
a, b = gets.split.map(&:to_i) puts ((b - 1).to_f / (a - 1)).ceil
[ "call.add" ]
718,930
718,931
u889326464
ruby
p02922
a, b = gets.split.map(&:to_i) puts (b.to_f / (a - 1)).floor
a, b = gets.split.map(&:to_i) puts ((b - 1).to_f / (a - 1)).ceil
[ "call.arguments.change", "misc.opposites", "identifier.change", "io.output.change" ]
718,932
718,931
u889326464
ruby
p02922
a,b=gets.chomp.split.map(&:to_i) mouth = 1 c = 0 while true if mouth >= b puts c exit end mouth += a c+=1 end
a,b=gets.chomp.split.map(&:to_i) mouth = 1 c = 0 while true if mouth >= b puts c exit end mouth += a-1 c+=1 end
[ "expression.operation.binary.add" ]
719,056
719,057
u585819925
ruby
p02922
a, b = gets.split(" ").map(&:to_i) ans = 1 socket = a while socket < b socket += a-1 ans += 1 end puts ans
a, b = gets.split(" ").map(&:to_i) ans = 0 socket = 1 while socket < b socket += a-1 ans += 1 end puts ans
[ "assignment.add", "assignment.remove" ]
719,288
719,289
u574117646
ruby
p02922
A,B = gets.split.map(&:to_i) cnt = 1 now = A while now < B now += A-1 cnt += 1 end puts cnt
A,B = gets.split.map(&:to_i) cnt = 0 now = 1 while now < B now += A-1 cnt += 1 end puts cnt
[ "assignment.add", "assignment.remove" ]
719,351
719,352
u760636024
ruby
p02922
a, b = gets.chomp.split.map(&:to_i) # 遅延評価でtake_whileを取り、偽になった境界は取るので+1する puts (1..Float::INFINITY).lazy.take_while{ |i| a * i - (i - 1) < b }.force.size + 1
a, b = gets.chomp.split.map(&:to_i) # 遅延評価でtake_whileを取り、偽になった境界は取るので+1する puts b > 1 ? (1..Float::INFINITY).lazy.take_while{ |i| a * i - (i - 1) < b }.force.size + 1 : 0
[]
719,355
719,356
u942539448
ruby
p02922
a, b = gets.chomp.split.map(&:to_i) ​ # 遅延評価でtake_whileを取り、偽になった境界は取るので+1する puts (1..Float::INFINITY).lazy.take_while{ |i| a * i - (i - 1) < b }.force.size + 1
a, b = gets.chomp.split.map(&:to_i) # 遅延評価でtake_whileを取り、偽になった境界は取るので+1する puts b > 1 ? (1..Float::INFINITY).lazy.take_while{ |i| a * i - (i - 1) < b }.force.size + 1 : 0
[]
719,357
719,356
u942539448
ruby
p02922
A, B = gets.chomp.split(" ").map(&:to_i) i = 0 while 1 if A * i >= B then puts i break end i += 1 end
A, B = gets.chomp.split(" ").map(&:to_i) i = 0 while 1 if A * i - (i - 1) >= B then puts i break end i += 1 end
[ "control_flow.branch.if.condition.change" ]
719,411
719,412
u198035909
ruby
p02922
a, b = gets.split.map(&:to_i) total = 1 cnt = 0 while total <= b do cnt += 1 total += a -1 end puts cnt
a, b = gets.split.map(&:to_i) total = 1 cnt = 0 while total < b do cnt += 1 total += a - 1 end puts cnt
[ "expression.operator.compare.change", "expression.operation.binary.change" ]
719,419
719,420
u414166540
ruby
p02922
A,B = gets.split.map(&:to_f) p (B-1)/(A-1).ceil
a,b = gets.split.map(&:to_f) p ((b-1)/(a-1)).ceil
[ "assignment.variable.change", "call.arguments.change", "expression.operation.binary.change" ]
719,535
719,536
u562082015
ruby
p02922
A,B = gets.split.map(&:to_f) p (B-1)/(A-1).ceil
A,B = gets.split.map &:to_f p ((B-1)/(A-1)).ceil
[ "call.arguments.change" ]
719,535
719,537
u562082015
ruby
p02922
A,B = gets.split.map(&:to_f) p (B-1)/(A-1).ceil.to_i
A,B = gets.split.map(&:to_f) p ((B-1)/(A-1)).ceil
[ "call.arguments.change", "call.remove" ]
719,538
719,539
u562082015
ruby
p02922
A,B = gets.split.map(&:to_f) p (B-1)/(A-1).ceil
A,B = gets.split.map(&:to_f) p ((B-1)/(A-1)).ceil
[ "call.arguments.change" ]
719,535
719,539
u562082015
ruby
p02922
arr = $stdin.gets.chomp.split(" ") arr.map! do |a_j| a_j.to_i end x = arr[1]/(arr[0]-1).to_f puts x.ceil
arr = $stdin.gets.chomp.split(" ") arr.map! do |a_j| a_j.to_i end x = (arr[1] - 1) / (arr[0] - 1).to_f puts x.ceil
[]
720,030
720,031
u294388467
ruby
p02922
a, b = gets.chomp.split(' ').map(&:to_i) i = 0 ans = 0 while true if i == 0 ans = 0 else ans = a + (a - 1) * (i - 1) end if ans >= b break end i += 1 end puts "#{i}"
a, b = gets.chomp.split(' ').map(&:to_i) i = 0 ans = 0 while true if i == 0 ans = 1 else ans = a + (a - 1) * (i - 1) end if ans >= b break end i += 1 end puts "#{i}"
[ "literal.number.integer.change", "assignment.value.change" ]
720,149
720,150
u683116963
ruby
p02922
a, b = gets.split(' ').map(&:to_i) count = 0 tap = 1 loop do count += 1 tap = (tap - 1) + a break if tap >= b end puts count
a, b = gets.split(' ').map(&:to_i) count = 0 tap = 1 loop do break if b == 1 count += 1 tap = (tap - 1) + a break if tap >= b end puts count
[]
720,213
720,214
u598150937
ruby
p02922
cnt = 0 a, b = gets.split.map(&:to_i) ans = 0 while cnt < b cnt += a ans += 1 end p ans
cnt = 1 a, b = gets.split.map(&:to_i) ans = 0 while cnt < b cnt -= 1 cnt += a ans += 1 end p ans
[ "literal.number.integer.change", "assignment.value.change" ]
720,266
720,267
u706695185
ruby
p02922
a, b = gets.split.map(&:to_i) count = a ans = 1 while count < b count += a-1 ans += 1 end p ans
a, b = gets.split.map(&:to_i) count = 1 ans = 0 while count < b count += a-1 ans += 1 end p ans
[ "assignment.remove", "assignment.add" ]
720,463
720,464
u617691573
ruby
p02922
=begin a = gets.split("").map{|x| x.to_s} b = gets.split("").map{|x| x.to_s} count = 0 3.times do |i| if a[i] == b[i] count += 1 end end p count =end a = gets.split(" ").map{|x| x.to_i} if a[1] == 1 p 1 exit() end a[1] -= a[0] ans = 1 while true break if (a[1] <= 0) a[1] -= a[0] - 1 ans += 1 end p ans
=begin a = gets.split("").map{|x| x.to_s} b = gets.split("").map{|x| x.to_s} count = 0 3.times do |i| if a[i] == b[i] count += 1 end end p count =end a = gets.split(" ").map{|x| x.to_i} if a[1] == 1 p 0 exit() end a[1] -= a[0] ans = 1 while true break if (a[1] <= 0) a[1] -= a[0] - 1 ans += 1 end p ans
[ "literal.number.integer.change", "call.arguments.change" ]
720,498
720,499
u912087911
ruby
p02922
a,b = gets.split.map(&:to_i) puts (b-1) / (a-1)
a,b = gets.split.map(&:to_i) puts (b-1).fdiv(a-1).ceil
[ "call.arguments.change", "expression.operation.binary.change", "call.add" ]
720,554
720,555
u471819781
ruby
p02922
A,B = gets.split.map(&:to_i) c = 1 n = A while n < B n += A - 1 c += 1 end puts c
A,B = gets.split.map(&:to_i) c = 0 n = 1 while n < B n += A - 1 c += 1 end puts c
[ "assignment.add", "assignment.remove" ]
720,608
720,609
u064100484
ruby
p02922
a, b = gets.split.map(&:to_i) def res(a, b) return 0 if b == 0 return 1 if b <= a return ((b-1)*1.0 / (a-1)).ceil end puts res(a, b)
a, b = gets.split.map(&:to_i) def res(a, b) return 0 if b == 1 return 1 if b <= a return ((b-1)*1.0 / (a-1)).ceil end puts res(a, b)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
720,631
720,632
u069429049
ruby
p02922
require 'pp' def gets; ARGF.gets; end class Solver def initialize end def main a, b = gets.split.map(&:to_i) ans = 0 if b == 1 ans = 1 else b -= 1 ans = (b + (a - 1 - 1)) / (a - 1) end puts ans end end if __FILE__ == $0 Solver.new.main end
require 'pp' def gets; ARGF.gets; end class Solver def initialize end def main a, b = gets.split.map(&:to_i) ans = 0 if b == 1 ans = 0 else b -= 1 ans = (b + (a - 1 - 1)) / (a - 1) end puts ans end end if __FILE__ == $0 Solver.new.main end
[ "literal.number.integer.change", "assignment.value.change" ]
720,825
720,826
u657749689
ruby
p02922
a, b = gets.split.map(&:to_i) cnt = 0 pow = 0 while pow < b cnt += 1 pow += a end p cnt
a, b = gets.split.map(&:to_i) cnt = 0 pow = 1 while pow < b cnt += 1 pow += a - 1 end p cnt
[ "literal.number.integer.change", "assignment.value.change" ]
721,071
721,072
u084335038
ruby
p02922
a, b = gets.split.map(&:to_i) i = 1 loop do break if 1 + (a - 1) * i >= b i += 1 end puts i
a, b = gets.split.map(&:to_i) i = 0 loop do break if 1 + (a - 1) * i >= b i += 1 end puts i
[ "literal.number.integer.change", "assignment.value.change" ]
721,164
721,165
u630043039
ruby
p02922
A, B = gets.chomp.split(" ").map(&:to_i) cnt = 0 while A * cnt < B cnt += 1 end puts cnt
A, B = gets.chomp.split(" ").map(&:to_i) cnt = 0 while A * cnt - cnt + 1 < B cnt += 1 end puts cnt
[ "expression.operation.binary.add" ]
721,317
721,318
u443924743
ruby
p02922
A, B = gets.chomp.split(" ").map(&:to_i) cnt = 1 while A * cnt < B cnt += 1 end puts cnt
A, B = gets.chomp.split(" ").map(&:to_i) cnt = 0 while A * cnt - cnt + 1 < B cnt += 1 end puts cnt
[ "literal.number.integer.change", "assignment.value.change" ]
721,319
721,318
u443924743
ruby
p02923
n = gets.to_i h = gets.split.map(&:to_i) ans = 0 cnt = 0 (n-1).times do |i| if h[i] >= h[i+1] cnt += 1 else cnt = 0 ans = cnt if cnt > ans end end ans = cnt if cnt > ans puts ans
n = gets.to_i h = gets.split.map(&:to_i) ans = 0 cnt = 0 (n-1).times do |i| if h[i] >= h[i+1] cnt += 1 else ans = cnt if cnt > ans cnt = 0 end end ans = cnt if cnt > ans puts ans
[ "assignment.remove", "assignment.add" ]
721,386
721,387
u503270460
ruby
p02923
n = gets.to_i hs = gets.chomp.split.map(&:to_i).reverse ans = [] cnt = 0 current = hs.shift hs.each do |h| if h >= current cnt += 1 else ans << cnt cnt = 0 end current = h end puts ans.max
n = gets.to_i hs = gets.chomp.split.map(&:to_i).reverse ans = [] cnt = 0 current = hs.shift hs.each do |h| if h >= current cnt += 1 else ans << cnt cnt = 0 end current = h end ans << cnt puts ans.max
[ "expression.operation.binary.add" ]
721,505
721,506
u191196346
ruby
p02923
N = gets.to_i h = [] h = gets.split.map(&:to_i) ans = 0 (N-1).times do |i| if h[i] >= h[i+1] cnt += 1 ans = [ans,cnt].max else cnt = 0 end end puts ans
N = gets.to_i h = [] h = gets.split.map(&:to_i) ans = 0 cnt = 0 (N-1).times do |i| if h[i] >= h[i+1] cnt += 1 ans = [ans,cnt].max else cnt = 0 end end puts ans
[ "assignment.add" ]
721,588
721,589
u326288614
ruby
p02923
# frozen_string_literal: true N = gets.to_i H = gets.split.map(&:to_i) count = 0 max = 0 (N - 1).times do |i| if H[i] < H[i + 1] max = count if max < count count = 0 else count += 1 end end puts count
# frozen_string_literal: true N = gets.to_i H = gets.split.map(&:to_i) count = 0 max = 0 (N - 1).times do |i| if H[i] < H[i + 1] max = count if max < count count = 0 else count += 1 end end puts max < count ? count : max
[ "control_flow.branch.if.condition.change" ]
721,874
721,875
u104886851
ruby
p02923
n = gets.to_i hs = gets.split(' ').map{|n| n.to_i} moves, moves_max = 0, 0 prev = hs.shift hs.each_with_index do |h, i| if h <= prev moves += 1 else moves_max = moves moves = 0 end prev = h end p [moves, moves_max].max
n = gets.to_i hs = gets.split(' ').map{|n| n.to_i} moves, moves_max = 0, 0 prev = hs.shift hs.each_with_index do |h, i| if h <= prev moves += 1 else moves_max = moves if moves > moves_max moves = 0 end prev = h end p [moves, moves_max].max
[]
722,247
722,248
u543466827
ruby
p02923
N = gets.to_i H = gets.split.map!(&:to_i) max = 0 cur = 0 0.upto(N-2) do |i| if H[i] >= H[i+1] cur += 1 else max = cur if max < cur cur = 0 end end puts max
N = gets.to_i H = gets.split.map!(&:to_i) max = 0 cur = 0 0.upto(N-2) do |i| if H[i] >= H[i+1] cur += 1 else max = cur if max < cur cur = 0 end end puts [max, cur].max
[ "call.arguments.change", "call.add" ]
722,306
722,307
u638516820
ruby
p02923
require 'pp' n = gets.chomp!.to_i h_n = gets.chomp!.split(" ").map(&:to_i) max = 0 now = h_n[0] now_max = 1 1.upto(n-1) do |i| if now >= h_n[i] now_max += 1 else now_max = 0 end now = h_n[i] if max < now_max max = now_max end end puts max
require 'pp' n = gets.chomp!.to_i h_n = gets.chomp!.split(" ").map(&:to_i) max = 0 now = h_n[0] now_max = 0 1.upto(n-1) do |i| if now >= h_n[i] now_max += 1 else now_max = 0 end now = h_n[i] if max < now_max max = now_max end end puts max
[ "literal.number.integer.change", "assignment.value.change" ]
722,732
722,733
u754375546
ruby
p02923
n=gets.to_i h=gets.split.map &:to_i c1=0 c2=0 (n-1).times do |i| if h[i]>=h[i+1] c1+=1 c2=c1 if i==n-2 else c2=c1 if c2<c1 c1=0 end end puts c2
n=gets.to_i h=gets.split.map &:to_i c1=0 c2=0 (n-1).times do |i| if h[i]>=h[i+1] c1+=1 c2=c1 if i==n-2&&c2<c1 else c2=c1 if c2<c1 c1=0 end end puts c2
[ "control_flow.branch.if.condition.change" ]
722,842
722,843
u390727364
ruby
p02923
# coding: utf-8 class Case03 def initialize end def show p self.instance_variables .map{ |sym| [sym, self.instance_variable_get(sym)] } .to_h end # 実行する def execute read solve output end # 読込 def read @n = gets.chomp.to_i @h = gets.chomp.split.map(&:to_i) end # 回答 def solve e = @n s = @n @result = 0 while e >= 1 do while s > 1 && @h[s-2] >= @h[s-1] do s -= 1 end @result = (e - s) if (e - s) > @result break if s <= 1 e -= 1 end end # 出力 def output puts @result end end Case03.new.execute if $0 == __FILE__
# coding: utf-8 class Case03 def initialize end def show p self.instance_variables .map{ |sym| [sym, self.instance_variable_get(sym)] } .to_h end # 実行する def execute read solve output end # 読込 def read @n = gets.chomp.to_i @h = gets.chomp.split.map(&:to_i) end # 回答 def solve e = @n s = @n @result = 0 while e >= 1 do while s > 1 && @h[s-2] >= @h[s-1] do s -= 1 end @result = (e - s) if (e - s) > @result break if s <= 1 e = s - 1 s = e end end # 出力 def output puts @result end end Case03.new.execute if $0 == __FILE__
[ "assignment.value.change" ]
723,148
723,147
u938270657
ruby
p02923
N = gets.to_i H = gets.strip.split.map(&:to_i) max = 0 s = 0 (N-1).downto(1) do |i| if H[i] <= H[i-1] s += 1 else if max <= s max = s s = 0 end end end puts max
N = gets.to_i H = gets.strip.split.map(&:to_i) max = 0 s = 0 (N-1).downto(1) do |i| if H[i] <= H[i-1] s += 1 if max < s max = s end else s = 0 end end puts max
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
723,443
723,444
u842419890
ruby
p02924
a = gets.to_i puts (a * a+1) / 2 - a
a = gets.to_i puts ((a + 1) * a) / 2 - a
[ "call.arguments.change", "expression.operation.binary.change" ]
727,210
727,211
u610761300
ruby
p02924
n = gets.chomp.to_i if n%2 == 0 sum = (n/2 -1) * n else sum = n/2 * n end puts sum
n = gets.chomp.to_i if n%2 == 0 sum = (n/2 -1) * n + n/2 else sum = n/2 * n end puts sum
[ "assignment.change" ]
727,275
727,276
u686064770
ruby
p02924
n=gets.to_i while true if n==1 puts 0 break end if n==2 puts 1 break end if n==3 puts 2 break end puts ((n+1)*(n-2)/2)+1 break end
n=gets.to_i while true if n==1 puts 0 break end if n==2 puts 1 break end if n==3 puts 3 break end puts ((n+1)*(n-2)/2)+1 break end
[ "literal.number.integer.change", "call.arguments.change" ]
728,439
728,440
u925626028
ruby
p02924
n=gets.to=i while true if n==1 puts 0 break end if n==2 puts 1 break end if n==3 puts 2 break end puts ((n+1)*(n-2)/2)+1 break end
n=gets.to_i while true if n==1 puts 0 break end if n==2 puts 1 break end if n==3 puts 3 break end puts ((n+1)*(n-2)/2)+1 break end
[ "assignment.value.change", "identifier.change", "literal.number.integer.change", "call.arguments.change" ]
728,441
728,440
u925626028
ruby
p02924
N=gets.chomp.to_i (1+(N-1))*(N-1)/2
N=gets.chomp.to_i puts (1+(N-1))*(N-1)/2
[ "io.output.change", "call.add" ]
728,537
728,538
u792512290
ruby
p02927
m, d = gets.split.map &:to_i cnt = 0 d.times do |i| s = (i/10)*(i%10) next if i/10 == 1 || i%10 == 1 cnt += 1 if s > 0 && s <= m end p cnt
m, d = gets.split.map &:to_i cnt = 0 (d+1).times do |i| s = (i/10)*(i%10) next if i/10 == 1 || i%10 == 1 cnt += 1 if s > 0 && s <= m end p cnt
[]
730,160
730,161
u744908753
ruby
p02927
m,d=gets.split.map(&:to_i) n=0 1.upto(m){|i|1.upto(d){|j| n+=1 if j%10>2 and j/10>2 and i==(j%10)*(j/10) }} p n
m,d=gets.split.map(&:to_i) n=0 1.upto(m){|i|1.upto(d){|j| n+=1 if j%10>=2 and j/10>=2 and i==(j%10)*(j/10) }} p n
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
730,512
730,513
u883824971
ruby
p02927
require 'pp' m, d = gets.split.map &:to_i cnt = 0 1.upto(m) do |mm| 1.upto(d) do |dd| next if dd.to_s.size != 2 next unless dd.to_s[0].to_i < 2 || dd.to_s[1].to_i < 2 cnt += 1 if dd.to_s[0].to_i * dd.to_s[1].to_i == mm end end p cnt
require 'pp' m, d = gets.split.map &:to_i cnt = 0 1.upto(m) do |mm| 1.upto(d) do |dd| next if dd.to_s.size != 2 next if dd.to_s[0].to_i < 2 || dd.to_s[1].to_i < 2 cnt += 1 if dd.to_s[0].to_i * dd.to_s[1].to_i == mm end end p cnt
[]
730,590
730,591
u315597999
ruby
p02928
data =[] data2 = [] cnt = 0 cnt2 = 0 n,k = gets.chomp.split(" ").map(&:to_i) data = gets.chomp.split(" ").map(&:to_i) for i in 0...n do for j in (i+1)...n do if data[j] < data[i] cnt+=1 end end end data2 = data+data l= n*2 for i in 0...n do for j in n...l do if data2[j] < data2[i] cnt2+=1 end end end p cnt p cnt2 puts (cnt*k+cnt2*k*(k-1)/2)%1000000007
data =[] data2 = [] cnt = 0 cnt2 = 0 n,k = gets.chomp.split(" ").map(&:to_i) data = gets.chomp.split(" ").map(&:to_i) for i in 0...n do for j in (i+1)...n do if data[j] < data[i] cnt+=1 end end end data2 = data+data l= n*2 for i in 0...n do for j in n...l do if data2[j] < data2[i] cnt2+=1 end end end #p cnt #p cnt2 puts (cnt*k+cnt2*k*(k-1)/2)%1000000007
[ "call.remove" ]
731,118
731,119
u091577826
ruby
p02928
n, k = gets.split.map(&:to_i) a = gets.split.map(&:to_i) t1 = 0 a.each_with_index do |i,index_i| a.each_with_index do |j,index_j| next if index_i > index_j t1 += 1 if i > j end end tn = 0 b = a.uniq.sort.reverse b.each_with_index do |i,index_i| b.each_with_index do |j,index_j| next if index_i > index_j tn += 1 if i > j end end t_sum = k*t1 + (k*(k-1)/2)*tn ans = t_sum % ((10**9) + 7) puts ans
n, k = gets.split.map(&:to_i) a = gets.split.map(&:to_i) t1 = 0 a.each_with_index do |i,index_i| a.each_with_index do |j,index_j| next if index_i > index_j t1 += 1 if i > j end end tn = 0 b = a.sort.reverse b.each_with_index do |i,index_i| b.each_with_index do |j,index_j| next if index_i > index_j tn += 1 if i > j end end t_sum = k*t1 + (k*(k-1)/2)*tn ans = t_sum % ((10**9) + 7) puts ans
[ "call.remove" ]
731,376
731,377
u559342926
ruby
p02928
eval'N,K,*A='+`dd`.split*?, a=0 A.combination(2){|x,y|a+=(K.+x<=>y)*K/2} p a.%10**9+7
eval'N,K,*A='+`dd`.split*?, a=0 A.combination(2){|x,y|x!=y&&a+=(K.+x<=>y)*K/2} p a.%10**9+7
[ "assignment.add" ]
731,479
731,480
u019489252
ruby
p02928
input = gets.split("\s") a = gets.split("\s").map(&:to_i) n = input[0].to_i k = input[1].to_i b_self = 0 b_other = 0 dp = Array.new(n, 0) n.times do |i| n.times do |j| if(a[i] > a[j]) b_other += 1 if(i < j) b_self += 1 end end end end b_other *= (k * ((k-1) / 2)) #k-1 ... 1 b_self *= k puts (b_other + b_self) % (10**9 + 7)
input = gets.split("\s") a = gets.split("\s").map(&:to_i) n = input[0].to_i k = input[1].to_i b_self = 0 b_other = 0 dp = Array.new(n, 0) n.times do |i| n.times do |j| if(a[i] > a[j]) b_other += 1 if(i < j) b_self += 1 end end end end b_other *= (k * (k-1)) / 2 #k-1 ... 1 b_self *= k puts (b_other + b_self) % (10**9 + 7)
[]
731,816
731,817
u458429268
ruby
p02928
n, k = gets.split.map(&:to_i) a = gets.split.map(&:to_i) inner = 0 for i in 1.upto(n - 1) for j in 0.upto(i - 1) if a[j] > a[i] then inner += 1 end end end a1 = a.sort lesscount = 0 outer = 0 for i in 1.upto(n - 1) if a1[i - 1] < a1[i] then lesscount = i end outer += lesscount end puts inner puts outer puts (k * inner + (k * (k - 1) / 2) * outer) % (1_000_000_000 + 7)
n, k = gets.split.map(&:to_i) a = gets.split.map(&:to_i) inner = 0 for i in 1.upto(n - 1) for j in 0.upto(i - 1) if a[j] > a[i] then inner += 1 end end end a1 = a.sort lesscount = 0 outer = 0 for i in 1.upto(n - 1) if a1[i - 1] < a1[i] then lesscount = i end outer += lesscount end puts (k * inner + (k * (k - 1) / 2) * outer) % (1_000_000_000 + 7)
[ "call.remove" ]
731,897
731,898
u420267469
ruby
p02933
a = gets.to_i s = gets puts a >= 3200 ? s : a
a = gets.to_i s = gets puts a >= 3200 ? s : 'red'
[ "call.arguments.change" ]
733,329
733,330
u765478029
ruby
p02933
a = gets.chomp.to_i s = gets.chomp if a >= 3800 puts s else puts 'red' end
a = gets.chomp.to_i s = gets.chomp if a >= 3200 puts s else puts 'red' end
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
733,339
733,340
u524019694
ruby