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
p02848
num = gets.chomp.to_i letters = gets.chomp.split('') $a_to_z = [*"A".."Z"] $answer = [] letters.each do |letter| if $a_to_z.index(letter) + $num < $a_to_z.count $answer << $a_to_z[$a_to_z.index(letter) + $num] else $answer << $a_to_z[($a_to_z.index(letter) + $num) - $a_to_z.count] end end puts $answer.join("")
$num = gets.chomp.to_i letters = gets.chomp.split('') $a_to_z = [*"A".."Z"] $answer = [] letters.each do |letter| if $a_to_z.index(letter) + $num < $a_to_z.count $answer << $a_to_z[$a_to_z.index(letter) + $num] else $answer << $a_to_z[($a_to_z.index(letter) + $num) - $a_to_z.count] end end puts $answer.join("")
[]
655,915
655,916
u448351322
ruby
p02848
num = gets.chomp.to_i letters = gets.chomp.split('') a_to_z = [*"A".."Z"] answer = [] letters.each do |letter| if $a_to_z.index(letter) + $num < $a_to_z.count $answer << $a_to_z[$a_to_z.index(letter) + $num] else $answer << $a_to_z[($a_to_z.index(letter) + $num) - $a_to_z.count] end end puts $answer.join("")
$num = gets.chomp.to_i letters = gets.chomp.split('') $a_to_z = [*"A".."Z"] $answer = [] letters.each do |letter| if $a_to_z.index(letter) + $num < $a_to_z.count $answer << $a_to_z[$a_to_z.index(letter) + $num] else $answer << $a_to_z[($a_to_z.index(letter) + $num) - $a_to_z.count] end end puts $answer.join("")
[]
655,917
655,916
u448351322
ruby
p02848
N = gets.chop.to_i S = gets.chars alp = Array('A'..'Z') code = [] S.each do |s| num = (alp.index(s) + 1) + N if num >> 26 code << alp[num - 27] else code << alp[num] end end puts code.join
N = gets.chop.to_i S = gets.chop.chars alp = Array('A'..'Z') code = [] S.each do |s| num = (alp.index(s) + 1) + N if num >> 26 code << alp[num - 27] else code << alp[num] end end puts code.join
[ "call.add" ]
655,941
655,942
u525844030
ruby
p02848
N = gets.to_i S = gets.chars alp = Array('A'..'Z') code = [] S.each do |s| num = (alp.index(s) + 1) + N if num >> 26 code << alp[num - 27] else code << alp[num] end end puts code.join
N = gets.chop.to_i S = gets.chop.chars alp = Array('A'..'Z') code = [] S.each do |s| num = (alp.index(s) + 1) + N if num >> 26 code << alp[num - 27] else code << alp[num] end end puts code.join
[ "call.add" ]
655,943
655,942
u525844030
ruby
p02853
x,y = gets.split(" ").map(&:to_i) sum = 0 ans = true if x == 1 && y == 1 puts 1000000 ans = false else if x == 1 sum += 300000 elsif x == 2 sum += 200000 elsif x == 3 sum += 100000 end if x == 1 sum += 300000 elsif y == 2 sum += 200000 elsif y == 3 sum += 100000 end end if ans puts sum end
x,y = gets.split(" ").map(&:to_i) sum = 0 ans = true if x == 1 && y == 1 puts 1000000 ans = false else if x == 1 sum += 300000 elsif x == 2 sum += 200000 elsif x == 3 sum += 100000 end if y == 1 sum += 300000 elsif y == 2 sum += 200000 elsif y == 3 sum += 100000 end end if ans puts sum end
[ "identifier.change", "control_flow.branch.if.condition.change" ]
657,983
657,984
u417892119
ruby
p02853
x,y = gets.chomp.split.map(&:to_i) p = 0 f = 300000 s = 200000 t = 100000 if x == 1 p += f elsif x == 2 p += s elsif x =- 3 p += t else p end if y == 1 p += f elsif y == 2 p += s elsif y == 3 p += t else p end if p == 600000 puts p + 400000 else puts p end
x,y = gets.chomp.split.map(&:to_i) p = 0 f = 300000 s = 200000 t = 100000 if x == 1 p += f elsif x == 2 p += s elsif x == 3 p += t end if y == 1 p += f elsif y == 2 p += s elsif y == 3 p += t end if p == 600000 puts p + 400000 else puts p end
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo", "expression.operation.unary.arithmetic.remove", "control_flow.branch.if.condition.change", "io.output.change", "call.remove" ]
658,053
658,054
u840923028
ruby
p02854
# DISCO 2020 # 方針:全体の長さn、累積和を取りつつnとの差分も取る # 正と負の最小の絶対値の小さいほうが答え n = gets.to_i a = gets.split.map &:to_i cs = Array.new(n+1,0) n.times do |i| cs[i+1] = cs[i] + a[i] end sum = cs[n] diff = Array.new(n-1,0) (n-1).times do |i| diff[i] = sum - cs[i+1] * 2 end p diff exit b = diff.select{|v|v >= 0}.min c = diff.select{|v|v < 0}.map{|v|v.abs}.min ans = [b,c].compact.min puts ans
# DISCO 2020 # 方針:全体の長さn、累積和を取りつつnとの差分も取る # 正と負の最小の絶対値の小さいほうが答え n = gets.to_i a = gets.split.map &:to_i cs = Array.new(n+1,0) n.times do |i| cs[i+1] = cs[i] + a[i] end sum = cs[n] diff = Array.new(n-1,0) (n-1).times do |i| diff[i] = sum - cs[i+1] * 2 end b = diff.select{|v|v >= 0}.min c = diff.select{|v|v < 0}.map{|v|v.abs}.min ans = [b,c].compact.min puts ans
[ "call.remove" ]
658,431
658,432
u106964380
ruby
p02854
# DISCO 2020 # 方針:全体の長さn、累積和を取りつつnとの差分も取る # 正と負の最小の絶対値の小さいほうが答え n = gets.to_i a = gets.split.map &:to_i cs = Array.new(n+1,0) n.times do |i| cs[i+1] = cs[i] + a[i] end sum = cs[n] diff = Array.new(n-1,0) (n-1).times do |i| diff[i] = sum - cs[i+1] * 2 end p diff exit b = diff.select{|v|v >= 0}.min c = diff.select{|v|v < 0}.map{|v|v.abs}.max ans = [b,c].compact.min puts ans
# DISCO 2020 # 方針:全体の長さn、累積和を取りつつnとの差分も取る # 正と負の最小の絶対値の小さいほうが答え n = gets.to_i a = gets.split.map &:to_i cs = Array.new(n+1,0) n.times do |i| cs[i+1] = cs[i] + a[i] end sum = cs[n] diff = Array.new(n-1,0) (n-1).times do |i| diff[i] = sum - cs[i+1] * 2 end b = diff.select{|v|v >= 0}.min c = diff.select{|v|v < 0}.map{|v|v.abs}.min ans = [b,c].compact.min puts ans
[ "call.remove", "misc.opposites", "assignment.value.change", "identifier.change" ]
658,433
658,432
u106964380
ruby
p02854
a = gets.split.map &:to_i ss = a.inject :+ s = 0 ans = Float::INFINITY a.each do |b| s += b ans = [ans, (ss-s*2).abs].min end p ans
gets a = gets.split.map &:to_i ss = a.inject :+ s = 0 ans = Float::INFINITY a.each do |b| s += b ans = [ans, (ss-s*2).abs].min end p ans
[]
658,507
658,508
u976045235
ruby
p02854
N = gets.to_i A = gets.split().map(&:to_i) sum = A.inject(&:+) min = 100000000000 left = 0 (0..N-2).each do |i| left += A[i] if left >= sum / 2 right = sum - left min = [min, left-right].min left -= A[i] right = sum - left min = [min, right-left].min break end next end puts min
N = gets.to_i A = gets.split().map(&:to_i) sum = A.inject(&:+) min = 100000000000 left = 0 (0..N-1).each do |i| left += A[i] if left >= sum / 2 right = sum - left min = [min, left-right].min left -= A[i] right = sum - left min = [min, right-left].min break end next end puts min
[ "literal.number.integer.change", "expression.operation.binary.change" ]
658,746
658,747
u620219777
ruby
p02859
puts gets.to_i **2
a = gets.to_i puts a **2
[ "assignment.variable.change", "call.add" ]
660,741
660,742
u774573868
ruby
p02859
r = gets.to_i puts r^2
r = gets.to_i puts (r * r)
[ "call.arguments.change" ]
660,756
660,757
u678452755
ruby
p02859
input = gets p input.chomp!.to_i
input = gets num = input.chomp!.to_i p num * num
[ "assignment.variable.change", "call.add" ]
661,246
661,247
u342135573
ruby
p02859
r = gets p r^2
r = gets.to_i p r * r
[ "call.add" ]
661,265
661,266
u469292607
ruby
p02859
input = gets.to_i input * input
input = gets.to_i puts (input * input)
[ "call.add", "call.arguments.change" ]
661,439
661,440
u574162665
ruby
p02859
r = $stdin.gets.chomp puts r * r
r = $stdin.gets.chomp.to_i puts r * r
[ "call.add" ]
661,501
661,502
u294388467
ruby
p02859
s = gets.chomp.to_i * 2 puts s
s = gets.chomp.to_i ** 2 puts s
[ "assignment.value.change", "expression.operation.binary.change" ]
661,770
661,771
u124060141
ruby
p02860
n = gets.to_i s = gets.chomp if s.slice(0, n/2) == s.slice(n/2, s.length) p "Yes" else p "No" end
n = gets.to_i s = gets.chomp if s.slice(0, n/2) == s.slice(n/2, s.length) puts "Yes" else puts "No" end
[ "call.function.change", "io.output.change" ]
662,309
662,310
u389410817
ruby
p02860
n = gets.to_i s = gets.chomp if s[0..n/2] == s[n/2..n] puts "Yes" else puts "No" end
n = gets.to_i s = gets.chomp if s[0...n/2] == s[n/2..n] puts "Yes" else puts "No" end
[ "control_flow.branch.if.condition.change" ]
662,490
662,491
u370134300
ruby
p02860
n = gets.chomp.to_i s = gets.chomp if n.odd? puts 'No' elsif s[0...(n.length / 2)] == s[(n.length / 2)...n] puts 'Yes' else puts 'No' end
n = gets.chomp.to_i s = gets.chomp if n.odd? puts 'No' elsif s[0...(n / 2)] == s[(n / 2)...n] puts 'Yes' else puts 'No' end
[ "call.remove" ]
662,523
662,524
u895926909
ruby
p02860
n = gets.to_i s = gets.to_s if n%2==1 puts "No" end before_half = s[0, n/2] after_half = s[n/2, n/2] if before_half == after_half puts "Yes" else puts "No" end
n = gets.to_i s = gets.to_s if n%2==1 puts "No" else before_half = s[0, n/2] after_half = s[n/2, n/2] if before_half == after_half puts "Yes" else puts "No" end end
[]
662,549
662,550
u076474814
ruby
p02860
n = gets.to_i s = gets.to_s if n%2==1 puts "No" end before_half = s[0, n/2] after_half = s[n/2+1, n/2] if before_half == after_half puts "Yes" else puts "No" end
n = gets.to_i s = gets.to_s if n%2==1 puts "No" else before_half = s[0, n/2] after_half = s[n/2, n/2] if before_half == after_half puts "Yes" else puts "No" end end
[ "expression.operation.binary.remove" ]
662,551
662,550
u076474814
ruby
p02860
N = gets.to_i S = gets.chomp T = S.size / 2 puts S[0...T] * 2 == S ? "Yes" : "NO"
N = gets.to_i S = gets.chomp T = S.size / 2 puts S[0...T] * 2 == S ? "Yes" : "No"
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
662,945
662,946
u774573868
ruby
p02860
n = (gets.to_i / 2) p n s = gets.chomp (s[0...n] + s[0...n]) == s ? puts("Yes") : puts("No")
n = (gets.to_i / 2) s = gets.chomp (s[0...n] + s[0...n]) == s ? puts("Yes") : puts("No")
[ "call.remove" ]
662,954
662,955
u109378157
ruby
p02860
n = gets.to_i s = gets.chomp puts (n.even? && s[0..n/2] == s[n/2+1..n-1]) ? "Yes" : "No"
n = gets.to_i s = gets.chomp puts (n.even? && s[0..n/2-1] == s[n/2..n-1]) ? "Yes" : "No"
[ "control_flow.branch.if.condition.change", "expression.operation.binary.remove" ]
663,166
663,167
u585819925
ruby
p02860
n = gets.to_i s = gets.chomp puts (n.even? && s[0..n/2] == s[n/2..n-1]) ? "Yes" : "No"
n = gets.to_i s = gets.chomp puts (n.even? && s[0..n/2-1] == s[n/2..n-1]) ? "Yes" : "No"
[ "control_flow.branch.if.condition.change" ]
663,168
663,167
u585819925
ruby
p02860
n = gets.to_i s = gets.chomp ans = 'No' ans = 'Yes' if s[0..(n - 1) / 2] == s[(n - 1) / 2 + 1..n - 1] p ans
n = gets.to_i s = gets.chomp ans = 'No' ans = 'Yes' if s[0..(n - 1) / 2] == s[(n - 1) / 2 + 1..n - 1] puts ans
[ "call.function.change", "io.output.change" ]
663,356
663,357
u335381753
ruby
p02860
n = gets.to_i s = gets.chomp p s.slice!(0,n/2) == s ? "Yes" : "No"
n = gets.to_i s = gets.chomp puts s.slice!(0,n/2) == s ? "Yes" : "No"
[ "call.function.change", "io.output.change" ]
663,412
663,413
u469030089
ruby
p02860
n = gets.to_i if n%2 == 1 puts :No exit end s = gets.chomp.chars t = s.each_slice(n/2).map(&:join) p (t[0] == t[1]) ? :Yes : :No
n = gets.to_i if n%2 == 1 puts :No exit end s = gets.chomp.chars t = s.each_slice(n/2).map(&:join) puts (t[0] == t[1]) ? :Yes : :No
[ "call.function.change", "io.output.change" ]
663,419
663,420
u679291177
ruby
p02860
num = gets.to_i str = gets.chomp if num%2 != 0 p "No" else if str[0...str.length/2] == str[str.length/2...str.length] p "Yes" else p "No" end end
num = gets.to_i str = gets.chomp if num%2 != 0 puts "No" else if str[0...str.length/2] == str[str.length/2...str.length] puts "Yes" else puts "No" end end
[ "call.function.change", "io.output.change" ]
663,563
663,569
u156931988
ruby
p02860
n = gets.to_i s = gets.chomp s1 = s[0,n/2] s2 = s[n/2,s.length-1] if n%2 != 0 puts 'No' else if s1 == s2 puts 'Yes' else puts 'No', s1,s2 end end
n = gets.to_i s = gets.chomp s1 = s[0,n/2] s2 = s[n/2,s.length-1] if n%2 != 0 puts 'No' else if s1 == s2 puts 'Yes' else puts 'No' end end
[ "call.arguments.change" ]
663,682
663,683
u932417742
ruby
p02860
n=gets.to_i s=gets.chomp.to_s if n%2==0 ss=s.slice(0..n/2-1) b = ss+ss==s ? true:false end p b ? "Yes":"No"
n=gets.to_i s=gets.chomp.to_s if n%2==0 ss=s.slice(0..n/2-1) b = ss+ss==s ? true:false end print b ? 'Yes':'No'
[ "call.function.change", "io.output.change", "literal.string.change", "call.arguments.change" ]
663,969
663,970
u966322470
ruby
p02860
n = gets.chomp.to_i s = gets.chomp s1 = s.slice(0, n / 2) s2 = s.slice(n / 2, n / 2) if s1 == s2 puts "Yes" else puts "No" end
n = gets.chomp.to_i s = gets.chomp s1 = s.slice(0, n / 2) s2 = s.slice(n / 2, n - (n / 2)) if s1 == s2 puts "Yes" else puts "No" end
[ "call.arguments.change" ]
663,987
663,988
u683116963
ruby
p02860
N = gets.to_i S = gets.chomp if N % 2 == 0 H = N / 2 S1, S2 = S.scan(/.{1,#{H}}/) if S1 == S2 puts "Yes" else puts "No" end else end
N = gets.to_i S = gets.chomp if N % 2 == 0 H = N / 2 S1, S2 = S.scan(/.{1,#{H}}/) if S1 == S2 puts "Yes" else puts "No" end else puts "No" end
[ "call.add" ]
664,208
664,209
u193470608
ruby
p02860
N = gets str = gets.chomp len = str.length if len % 2 != 0 puts("NO") exit 0 end half = len/2 first = str[0..half-1] second = str[half..-1] if first == second puts("YES") else puts("NO") end
N = gets str = gets.chomp len = str.length if len % 2 != 0 puts("No") exit 0 end half = len/2 first = str[0..half-1] second = str[half..-1] if first == second puts("Yes") else puts("No") end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
664,892
664,893
u403537991
ruby
p02860
n = gets.to_i s = gets.chomp if n % 2 == 1 puts 'No' else a = s.slice(0, s.size/2) b = s.slice(s.size/2, s.size) if a.nil? || b.nil? puts 'No' else puts s == (a + b) ? 'Yes' : 'No' end end
n = gets.to_i s = gets.chomp if n % 2 == 1 puts 'No' else a = s.slice(0, s.size/2) b = s.slice(s.size/2, s.size) if a.nil? || b.nil? puts 'No' else puts a == b ? 'Yes' : 'No' end end
[ "expression.operation.binary.remove", "control_flow.branch.if.condition.change" ]
664,908
664,909
u498700239
ruby
p02860
n = gets.to_i str = gets harf_n = n/2 result = str[0, harf_n] == str[harf_n, n] ? "Yes" : "No" print("#{result}")
n = gets.to_i str = gets.chomp harf_n = n/2 result = str[0, harf_n] == str[harf_n, n] ? "Yes" : "No" print("#{result}")
[ "call.add" ]
664,925
664,926
u491851024
ruby
p02860
n = gets.to_i str = gets harf_n = n/2 result = a[0, harf_n] == a[harf_n, n] ? "Yes" : "No" print("#{result}")
n = gets.to_i str = gets.chomp harf_n = n/2 result = str[0, harf_n] == str[harf_n, n] ? "Yes" : "No" print("#{result}")
[ "call.add", "assignment.value.change", "identifier.change", "control_flow.branch.if.condition.change" ]
664,927
664,926
u491851024
ruby
p02861
n = gets.to_i xys = n.times.map { gets.split.map(&:to_i) } routes = [*0..n - 1].permutation ans = 0 ans = routes.each do |r| (n - 1).times do |i| a = r[i] b = r[i + 1] ans += Math.sqrt((xys[a][0] - xys[b][0])**2 + (xys[a][1] - xys[b][1])**2) end end puts ans / routes.count
n = gets.to_i xys = n.times.map { gets.split.map(&:to_i) } routes = [*0..n - 1].permutation ans = 0 routes.each do |r| (n - 1).times do |i| a = r[i] b = r[i + 1] ans += Math.sqrt((xys[a][0] - xys[b][0])**2 + (xys[a][1] - xys[b][1])**2) end end puts ans / routes.count
[ "assignment.remove" ]
665,067
665,068
u889326464
ruby
p02861
n=gets.to_i xy=n.times.map{gets.split.map(&:to_i)} def dis(p1, p2) Math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) end r = c = 0 [*0...n].permutation(n).each do |x| x.each_cons(2).each do |p1,p2| r += dis(p1, p2) end c += 1 end puts r / c
n=gets.to_i xy=n.times.map{gets.split.map(&:to_i)} def dis(p1, p2) Math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) end r = c = 0 [*0...n].permutation(n).each do |x| x.each_cons(2).each do |p1,p2| r += dis(xy[p1], xy[p2]) end c += 1 end puts r / c
[ "call.arguments.change" ]
665,201
665,202
u056944756
ruby
p02861
N = gets.to_i cities = [] N.times do |c| cities.push(gets.chomp.split(" ").map(&:to_i)) end path_len = [] perm = cities.permutation(N).to_a for item in perm lens = [] item.each_cons(2) do |a, b| lens.push(((a[0]-a[1])**2 + (b[0]-b[1])**2)**(1/2.0)) end path_len.push(lens.inject(:+)) end print("#{path_len.inject(:+) / path_len.length}")
N = gets.to_i cities = [] N.times do |c| cities.push(gets.chomp.split(" ").map(&:to_i)) end path_len = [] perm = cities.permutation(N).to_a for item in perm lens = [] item.each_cons(2) do |a, b| lens.push(((a[0]-b[0])**2 + (a[1]-b[1])**2)**(1/2.0)) end path_len.push(lens.inject(:+)) end print("#{path_len.inject(:+) / path_len.length}")
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "literal.number.integer.change", "variable_access.subscript.index.change" ]
665,613
665,614
u491851024
ruby
p02862
X, Y = gets.cnomp.split(" ").map(&:to_i) ONE = '1'.freeze MOD = (10**9) + 7 def inv(x) res = 1 beki = x (MOD - 2).to_s(2).reverse.chars do |digest| res = (beki * res) % MOD if digest == ONE beki = (beki * beki) % MOD end res end def fact(s, e) (s..e).reduce(1) { |r, i| (r * i) % MOD } end def nCk(n, k) (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD end if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0 && 2 * Y >= X && 2 * X >= Y a = (2 * Y - X) / 3 b = (2 * X - Y) / 3 puts nCk(a + b, a) else puts 0 end
X, Y = gets.chomp.split(" ").map(&:to_i) ONE = '1'.freeze MOD = (10**9) + 7 def inv(x) res = 1 beki = x (MOD - 2).to_s(2).reverse.chars do |digest| res = (beki * res) % MOD if digest == ONE beki = (beki * beki) % MOD end res end def fact(s, e) (s..e).reduce(1) { |r, i| (r * i) % MOD } end def nCk(n, k) (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD end if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0 && 2 * Y >= X && 2 * X >= Y a = (2 * Y - X) / 3 b = (2 * X - Y) / 3 puts nCk(a + b, a) else puts 0 end
[ "assignment.value.change", "identifier.change" ]
665,947
665,948
u729911058
ruby
p02862
def rec(n, p, m) return 1 if p == 0 if p % 2 == 0 tmp = rec(n, p / 2, m) return tmp * tmp % m end n * rec(n, p - 1, m) % m end x, y = gets.chomp.split(' ').map(&:to_i) xy = x + y mod = (1e+9 + 7).to_i if xy % 3 != 0 puts 0 else n = xy / 3 if !(x >= n && x <= 2 * n && y >= n && y <= 2 * n) puts 0 else r = x - n arr = Array.new(n) arr[0] = 1 (1...n).each do |i| arr[i] = arr[i - 1] * (i + 1) % mod end arr.unshift(0) a = arr[n] b = arr[n - r] c = arr[r] bc = (b * c) % mod puts (a * rec(bc, mod - 2, mod)) % mod end end
def rec(n, p, m) return 1 if p == 0 if p % 2 == 0 tmp = rec(n, p / 2, m) return tmp * tmp % m end n * rec(n, p - 1, m) % m end x, y = gets.chomp.split(' ').map(&:to_i) xy = x + y mod = (1e+9 + 7).to_i if xy % 3 != 0 puts 0 else n = xy / 3 if !(x >= n && x <= 2 * n && y >= n && y <= 2 * n) puts 0 else r = x - n arr = Array.new(n) arr[0] = 1 (1...n).each do |i| arr[i] = arr[i - 1] * (i + 1) % mod end arr.unshift(1) a = arr[n] b = arr[n - r] c = arr[r] bc = (b * c) % mod puts (a * rec(bc, mod - 2, mod)) % mod end end
[ "literal.number.integer.change", "call.arguments.change" ]
666,122
666,123
u857510905
ruby
p02862
X,Y = gets.split.map &:to_i A3 = 2*X - Y B3 = 2*Y - X unless A3 >= 0 && B3 >= 0 && A3 % 3 == 0 && B3 % 3 == 0 p 0; exit end A = A3 / 3; B = A3 / 3; Mod = 10**9+7 def powmod(b,r,mod) a = 1 while r > 0 if r%2 == 1 a = a * b % mod end b = b * b % mod r /= 2 end a end def invmod(f, mod) powmod(f, mod-2, mod) end def factorial(n, mod) fs = [1] (1..n).each{ |k| fs << (fs[-1] * k) % mod } fs end $fs = factorial(A+B,Mod) def comb(n,r) return 0 if r < 0 return 0 if n < r $fs[n] * invmod($fs[r],Mod) % Mod * invmod($fs[n-r],Mod) % Mod end p comb(A+B, A)
X,Y = gets.split.map &:to_i A3 = 2*X - Y B3 = 2*Y - X unless A3 >= 0 && B3 >= 0 && A3 % 3 == 0 && B3 % 3 == 0 p 0; exit end A = A3 / 3; B = B3 / 3; Mod = 10**9+7 def powmod(b,r,mod) a = 1 while r > 0 if r%2 == 1 a = a * b % mod end b = b * b % mod r /= 2 end a end def invmod(f, mod) powmod(f, mod-2, mod) end def factorial(n, mod) fs = [1] (1..n).each{ |k| fs << (fs[-1] * k) % mod } fs end $fs = factorial(A+B,Mod) def comb(n,r) return 0 if r < 0 return 0 if n < r $fs[n] * invmod($fs[r],Mod) % Mod * invmod($fs[n-r],Mod) % Mod end p comb(A+B, A)
[ "assignment.value.change", "expression.operation.binary.change" ]
666,779
666,780
u670503797
ruby
p02862
# frozen_string_literal: true x, y = gets.split.map(&:to_i) if (2 * x - y) % 3 != 0 || (-x + 2 * y) % 3 != 0 puts 0 exit end n = (2 * x - y) / 3 m = (-x + 2 * y) / 3 MOD = 10**9 + 7 N = n * 3 def ncrmod(n, r) return 0 if r < 0 || r > n r = [r, n - r].min $g1[n] * $g2[r] * $g2[n - r] % MOD end $g1 = [1, 1] $g2 = [1, 1] $inverse = [0, 1] 2.upto(N + 1) do |i| $g1.push(($g1[-1] * i) % MOD) $inverse.push((-$inverse[MOD % i] * (MOD / i)) % MOD) $g2.push(($g2[-1] * $inverse[-1]) % MOD) end puts ncrmod(n + m, m)
# frozen_string_literal: true x, y = gets.split.map(&:to_i) if (2 * x - y) % 3 != 0 || (-x + 2 * y) % 3 != 0 puts 0 exit end n = (2 * x - y) / 3 m = (-x + 2 * y) / 3 MOD = 10**9 + 7 N = (n + m) * 3 def ncrmod(n, r) return 0 if r < 0 || r > n r = [r, n - r].min $g1[n] * $g2[r] * $g2[n - r] % MOD end $g1 = [1, 1] $g2 = [1, 1] $inverse = [0, 1] 2.upto(N + 1) do |i| $g1.push(($g1[-1] * i) % MOD) $inverse.push((-$inverse[MOD % i] * (MOD / i)) % MOD) $g2.push(($g2[-1] * $inverse[-1]) % MOD) end puts ncrmod(n + m, m)
[]
667,047
667,048
u434509016
ruby
p02863
n, t = gets.split.map(&:to_i) ab = n.times.map {gets.split.map(&:to_i)}.sort_by{|e| e[0]} dp = Array.new(t) dp[0][0] = max = 0 dp[0][ab[0][0]] = max = ab[0][1] if ab[0][0] < t ans = ab[0][1] ab.shift ab.each do |a, b| ans = max + b if ans < max + b (t - a - 1).downto(0) do |i| next if dp[i].nil? x = dp[i] + b dp[i+a] = x if dp[i+a].nil? || dp[i+a] < x max = x if max < x end end puts ans
n, t = gets.split.map(&:to_i) ab = n.times.map {gets.split.map(&:to_i)}.sort_by{|e| e[0]} dp = Array.new(t) dp[0] = max = 0 dp[ab[0][0]] = max = ab[0][1] if ab[0][0] < t ans = ab[0][1] ab.shift ab.each do |a, b| ans = max + b if ans < max + b (t-a-1).downto(0) do |i| next if dp[i].nil? x = dp[i] + b dp[i+a] = x if dp[i+a].nil? || dp[i+a] < x max = x if max < x end end puts ans
[]
667,657
667,658
u692254521
ruby
p02863
num, time = gets.chomp.split.map(&:to_i) time -= 1 things = [] num.times { things << gets.split.map(&:to_i) } # 許容時間ごとの価値の最大値を格納(順次更新) dp = Array.new(time + 1, 0) ans = [] # num個目までの料理を、ナップサックに入れるべきか順番に確認する num.times do |n| # n個目の時間をtmp_time、価値をtmp_valueとする tmp_time, tmp_value = things[n] # n個目の料理を最後に食べると仮定し、答えの選択肢に追加する ans << dp[time] + tmp_value # 許容時間がtimeからtmp_timeまでの場合を、順番に確認する # (許容時間がtmp_time未満の場合、ナップサックに入れることはできないため確認の必要なし) # なお、uptoを用いて逆向きに確認すると、ループ中に既に更新した数値を参照してしまうため、正常に動作しない time.downto(tmp_time) do |t_accepted| # 「許容時間がtmp_time分少ない時の価値 + tmp_value」が「現在格納されている値」よりも大きければ格納する sum_value = dp[t_accepted - tmp_time] + tmp_value dp[t_accepted] = sum_value if dp[t_accepted] < sum_value end end puts ans.max
num, time = gets.chomp.split.map(&:to_i) time -= 1 things = [] num.times { things << gets.split.map(&:to_i) } things.sort! # 許容時間ごとの価値の最大値を格納(順次更新) dp = Array.new(time + 1, 0) ans = [] # num個目までの料理を、ナップサックに入れるべきか順番に確認する num.times do |n| # n個目の時間をtmp_time、価値をtmp_valueとする tmp_time, tmp_value = things[n] # n個目の料理を最後に食べると仮定し、答えの選択肢に追加する ans << dp[time] + tmp_value # 許容時間がtimeからtmp_timeまでの場合を、順番に確認する # (許容時間がtmp_time未満の場合、ナップサックに入れることはできないため確認の必要なし) # なお、uptoを用いて逆向きに確認すると、ループ中に既に更新した数値を参照してしまうため、正常に動作しない time.downto(tmp_time) do |t_accepted| # 「許容時間がtmp_time分少ない時の価値 + tmp_value」が「現在格納されている値」よりも大きければ格納する sum_value = dp[t_accepted - tmp_time] + tmp_value dp[t_accepted] = sum_value if dp[t_accepted] < sum_value end end puts ans.max
[ "call.add" ]
667,708
667,709
u653737129
ruby
p02865
n = gets.to_i puts n / 2
n = gets.to_i puts (n - 1) / 2
[ "call.arguments.change" ]
667,777
667,778
u482840940
ruby
p02865
N = gets.to_i if N.odd? puts (N-1)/2 else puts N/2 end
N = gets.to_i if N.odd? puts (N-1)/2 else puts (N-2)/2 end
[ "call.arguments.change" ]
668,299
668,300
u106964380
ruby
p02866
N,*D = `dd`.split.map &:to_i if D[0] != 1 p 0 exit end D.sort! Mod = 998244353 ans = 1 cs = {} D.each{ |d| if d == 0 if cs[d] ans = 0 break end else ans = ans * (cs[d-1] || 0) % Mod end cs[d] = (cs[d] || 0) + 1 } p ans
N,*D = `dd`.split.map &:to_i if D[0] != 0 p 0 exit end D.sort! Mod = 998244353 ans = 1 cs = {} D.each{ |d| if d == 0 if cs[d] ans = 0 break end else ans = ans * (cs[d-1] || 0) % Mod end cs[d] = (cs[d] || 0) + 1 } p ans
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
668,829
668,830
u670503797
ruby
p02866
gets d=gets.split.map(&:to_i).sort testd = d[1..-1].uniq if d[0] == 0 && testd == [*1..testd.size] p d.group_by(&:itself).sort.map{|k,v|v.size}.each_cons(2).map{|a,b|a**b%998244353}.inject(1){|s,r|s*r%998244353} else p 0 end
gets d=gets.split.map(&:to_i) testd = d[1..-1].sort.uniq if d[0] == 0 && testd == [*1..testd.size] p d.group_by(&:itself).sort.map{|k,v|v.size}.each_cons(2).map{|a,b|a**b%998244353}.inject(1){|s,r|s*r%998244353} else p 0 end
[ "call.remove", "call.add" ]
668,984
668,985
u353917577
ruby
p02866
MOD = 998244353 N = gets.to_i D = gets.split.map(&:to_i) list = Hash.new(0) D.each do |d| list[d] += 1 end if D[0] != 0 || list[0] >= 1 puts 0 exit end ans = 1 1.upto(D.max) do |d| n = list[d] if n == 0 ans = 0 break else ans = (ans * (list[d-1] ** n)) % MOD end end puts ans
MOD = 998244353 N = gets.to_i D = gets.split.map(&:to_i) list = Hash.new(0) D.each do |d| list[d] += 1 end if D[0] != 0 || list[0] >= 2 puts 0 exit end ans = 1 1.upto(D.max) do |d| n = list[d] if n == 0 ans = 0 break else ans = (ans * (list[d-1] ** n)) % MOD end end puts ans
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
669,547
669,548
u740836226
ruby
p02873
line=gets.chomp l=line.length-1 a=[] b=[] c=0 m=0 n=0 for i in 0..l if line[i-1]=="<" then m=m+1 else m=0 end a.push(m) end for j in 0..l if line[l-j]==">" then n=n+1 else n=0 end b.push(n) end b.reverse! for k in 0..a.length-1 c=c+[a[k],b[k]].max end puts c
line=gets.chomp l=line.length-1 a=[0] b=[0] c=0 m=0 n=0 for i in 0..l if line[i]=="<" then m=m+1 else m=0 end a.push(m) end for j in 0..l if line[l-j]==">" then n=n+1 else n=0 end b.push(n) end b.reverse! for k in 0..a.length-1 c=c+[a[k],b[k]].max end puts c
[ "expression.operation.binary.remove" ]
671,096
671,097
u413184068
ruby
p02873
s = gets.chomp.to_s.split(//) n = s.size ary = Array.new(n + 1, 0) i = 0 while i < n if s[i] == "<" ary[i+1] = ary[i] + 1 end i += 1 end i = n - 1 while i > 0 if s[i] == ">" ary[i] = [ary[i+1] + 1, ary[i]].max end i -= 1 end puts ary.inject(:+)
s = gets.chomp.to_s.split(//) n = s.size ary = Array.new(n + 1, 0) i = 0 while i < n if s[i] == "<" ary[i+1] = ary[i] + 1 end i += 1 end i = n - 1 while i >= 0 if s[i] == ">" ary[i] = [ary[i+1] + 1, ary[i]].max end i -= 1 end puts ary.inject(:+)
[ "expression.operator.compare.change", "expression.operation.binary.change" ]
671,418
671,419
u928941036
ruby
p02873
def max(a, b) a > b ? a : b end L = '>' # > R = '<' # < arr = gets.chomp.split('') targets = [] last_dir = R count = -1 arr.each do |dir| if last_dir == dir count += 1 next end targets << count + 1 if dir == L targets << nil end last_dir = dir count = 0 end if last_dir = L targets << count + 1 else targets << count + 2 end counter = 0 targets.each_with_index do |num, index| if num.nil? add = max(targets[index - 1], targets[index + 1]) else add = (num * (num - 1)) / 2 end counter += add end puts counter
def max(a, b) a > b ? a : b end L = '>' # > R = '<' # < arr = gets.chomp.split('') targets = [] last_dir = R count = -1 arr.each do |dir| if last_dir == dir count += 1 next end targets << count + 1 if dir == L targets << nil end last_dir = dir count = 0 end if last_dir == L targets << count + 1 else targets << count + 2 end counter = 0 targets.each_with_index do |num, index| if num.nil? add = max(targets[index - 1], targets[index + 1]) else add = (num * (num - 1)) / 2 end counter += add end puts counter
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
671,715
671,716
u482583772
ruby
p02873
S = [] gets.chomp.chars.slice_when{|a,b| a != b}.each do |v| S << [v[0], v.size] end def acc(n) n*(n+1)/2 end count = 0 if S[0][0] == ">" s = s.shift count += acc(s[1]) end S.each_slice(2) do |a,b| if b.nil? count += acc(a[1]) break end if a[1] < b[1] count += acc(a[1]-1) count += acc(b[1]) else count += acc(a[1]) count += acc(b[1]-1) end end puts count
S = [] gets.chomp.chars.slice_when{|a,b| a != b}.each do |v| S << [v[0], v.size] end def acc(n) n*(n+1)/2 end count = 0 if S[0][0] == ">" s = S.shift count += acc(s[1]) end S.each_slice(2) do |a,b| if b.nil? count += acc(a[1]) break end if a[1] < b[1] count += acc(a[1]-1) count += acc(b[1]) else count += acc(a[1]) count += acc(b[1]-1) end end puts count
[ "assignment.value.change" ]
671,874
671,875
u106964380
ruby
p02879
a,b = gets.split.map(&:to_i) puts a < 10 && b < 10 ? 'Yes':'-1'
a,b = gets.split.map(&:to_i) puts a < 10 && b < 10 ? a*b :'-1'
[]
673,054
673,055
u781354194
ruby
p02879
# Wrote in Mar 5, 2020 21:44 by reetok require 'time' require 'prime' require 'bigdecimal' def inp(type=:to_i,spst=" ") return eval("gets.chomp.split(#{spst}).map(&:#{type})") end def inpf() return self.inp(:to_f," ") end def inps() return self.inp(:to_s," ") end def r_up(a, b) (a/b).ceil end def r_down(a, b) (a/b).floor end def sum(a) a.inject(:+) end def big(a,b) return (a>b)? a:b end def small(a,b) return (a<b)? a:b end def minp(n,datatype=".to_i") t = [] n.times do t.push(eval("gets.chomp#{datatype}")) end return t end def yes() puts "Yes" end def no() puts "No" end def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end class Integer def divisor_list devisors = [1] 2.upto(self/2) do |i| devisors << i if self%i == 0 end devisors << self return devisors.uniq.sort end end class Array def upper(a) #aより上 self.sort.select{|n|n>=a} end def downer(a) #aより下 self.sort.select{|n|n<=a} end end #--------------- a,b = inp if a>9||b>9 puts -1 end puts a*b
# Wrote in Mar 5, 2020 21:44 by reetok require 'time' require 'prime' require 'bigdecimal' def inp(type=:to_i,spst=" ") return eval("gets.chomp.split(#{spst}).map(&:#{type})") end def inpf() return self.inp(:to_f," ") end def inps() return self.inp(:to_s," ") end def r_up(a, b) (a/b).ceil end def r_down(a, b) (a/b).floor end def sum(a) a.inject(:+) end def big(a,b) return (a>b)? a:b end def small(a,b) return (a<b)? a:b end def minp(n,datatype=".to_i") t = [] n.times do t.push(eval("gets.chomp#{datatype}")) end return t end def yes() puts "Yes" end def no() puts "No" end def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end class Integer def divisor_list devisors = [1] 2.upto(self/2) do |i| devisors << i if self%i == 0 end devisors << self return devisors.uniq.sort end end class Array def upper(a) #aより上 self.sort.select{|n|n>=a} end def downer(a) #aより下 self.sort.select{|n|n<=a} end end #--------------- a,b = inp if a>9||b>9 puts "-1" exit end puts a*b
[ "call.arguments.change", "control_flow.exit.add" ]
673,292
673,293
u891258088
ruby
p02879
a,b = gets.split.map(&:to_i) if a < 10 && b << 10 puts a * b else puts -1 end
a,b = gets.split.map(&:to_i) if a < 10 && b < 10 puts a * b else puts -1 end
[ "misc.typo", "control_flow.branch.if.condition.change" ]
673,301
673,302
u945412921
ruby
p02879
a,b = gets.chomp.split.map(&:to_i) (a <= 9) && (b <= 9) ? a * b : '-1'
a,b = gets.chomp.split.map(&:to_i) puts ((a <= 9) && (b <= 9) ? a * b : '-1' )
[ "call.add", "call.arguments.change" ]
673,318
673,319
u895926909
ruby
p02879
a,b=gets.split.map(&:to_i) puts (a<10 && b<10) ? -1 : a*b
a,b=gets.split.map(&:to_i) puts (a<10 && b<10) ? a*b : -1
[]
673,326
673,327
u926099741
ruby
p02879
a, b=gets.split.map &to_i p (a<10&&b<10?a*b:-1)
a, b=gets.split.map &:to_i p (a<10&&b<10?a*b:-1)
[ "assignment.value.change", "call.arguments.change" ]
673,402
673,403
u976045235
ruby
p02879
b=gets.chomp.split(" ").map(&:to_i); if b[0]>=1 and b[0]<=9 and b[1]>=1 and b[1]<=9 print("#{b[0]*b[1]}") else purint("-1") end
b=gets.chomp.split(" ").map(&:to_i); if b[0]>=1 and b[0]<=9 and b[1]>=1 and b[1]<=9 print("#{b[0]*b[1]}") else print("-1") end
[ "identifier.change" ]
673,616
673,617
u862174999
ruby
p02879
a, b = gets.strip.split.map(&:to_i) if a<9 && b<9 then print(a*b) else print(-1) end
a, b = gets.strip.split.map(&:to_i) if a<10 && b<10 then print(a*b) else print(-1) end
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
673,667
673,668
u291303244
ruby
p02879
a,b = gets.chomp.split(' ').map(&:to_i) if a < 10 && b < 10 puts a + b else puts -1 end
#AC a,b = gets.chomp.split(' ').map(&:to_i) if a < 10 && b < 10 puts a * b else puts -1 end
[ "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change" ]
673,720
673,721
u059126963
ruby
p02879
a = gets.split.map(&:to_i) puts 9 > a[0] || 9 > a[1] ? -1 : a[0] * a[1]
a = gets.split.map(&:to_i) puts 9 < a[0] || 9 < a[1] ? -1 : a[0] * a[1]
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
673,798
673,799
u039504682
ruby
p02879
input = gets.chomp.split num1 = input.first.to_i num2 = input.last.to_i if (1..9).include?(num1) && (1..9).include?(num1) res = num1 * num2 puts res.to_s else puts '-1' end
input = gets.chomp.split num1 = input.first.to_i num2 = input.last.to_i if (1..9).include?(num1) && (1..9).include?(num2) res = num1 * num2 puts res.to_s else puts '-1' end
[ "identifier.change", "control_flow.branch.if.condition.change" ]
673,956
673,957
u447059782
ruby
p02879
a, b = gets.split.map(&:to_i) if a > 9 or b > 0 puts "-1" else puts a * b end
a, b = gets.split.map(&:to_i) if a > 9 or b > 9 puts -1 else puts a * b end
[ "literal.number.integer.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
674,274
674,275
u056083754
ruby
p02879
a, b = gets.split.map(&:to_i) if a > 9 or b > 0 puts -1 else puts a * b end
a, b = gets.split.map(&:to_i) if a > 9 or b > 9 puts -1 else puts a * b end
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
674,276
674,275
u056083754
ruby
p02879
a, b = gets.split.map(&:to_i) if a > 9 || b > 9 puts "-1" end puts a * b
a, b = gets.split.map(&:to_i) if a > 9 || b > 9 puts "-1" exit end puts a * b
[ "control_flow.exit.add" ]
674,416
674,417
u876846619
ruby
p02879
a, b = gets.split.map(&:to_i) if a < 10 && b < 10 puts -1 else puts a*b end
a, b = gets.split.map(&:to_i) unless a < 10 && b < 10 puts -1 else puts a*b end
[]
674,531
674,532
u056944756
ruby
p02879
a, b = gets.split.map(&:to_i) if a > 10 || b > 10 puts '-1' else puts a * b end
a, b = gets.split.map(&:to_i) if a > 9 || b > 9 puts '-1' else puts a * b end
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
674,566
674,567
u821757826
ruby
p02880
n = gets.to_i s = 0 (1..9).each do |x| if n%x==0 if 1<=n%x && 9>=n%x s += 1 end end end if s != 0 puts "Yes" else puts "No" end
n = gets.to_i s = 0 (1..9).each do |x| if n%x==0 if (1<=n/x) && (9>=n/x) s += 1 end end end if s != 0 puts "Yes" else puts "No" end
[ "control_flow.branch.if.condition.change", "expression.operator.arithmetic.change" ]
674,714
674,715
u313103408
ruby
p02880
n99 = (1..9).to_a.repeated_permutation(2).map{|a,b| a*b} puts n99.include?(gets.to_i) ? "YES" : "NO"
n99 = (1..9).to_a.repeated_permutation(2).map{|a,b| a*b} puts n99.include?(gets.to_i) ? "Yes" : "No"
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
675,362
675,363
u502306384
ruby
p02879
a,b = gets.split(" ").map(&:to_i) puts ((a > 0 && a < 9)&&(b > 0 && b < 9) ? a*b : -1)
a,b = gets.split(" ").map(&:to_i) puts ((a > 0 && a < 10)&&(b > 0 && b < 10) ? a*b : -1)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
675,481
675,482
u538351278
ruby
p02879
a,b = gets.split(" ").map(&to_i) puts ((a > 0 && a < 9)&&(b > 0 && b < 9) ? a*b : -1)
a,b = gets.split(" ").map(&:to_i) puts ((a > 0 && a < 10)&&(b > 0 && b < 10) ? a*b : -1)
[ "assignment.value.change", "call.arguments.change", "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
675,483
675,482
u538351278
ruby
p02880
#!/usr/bin/env ruby require 'pry' n = gets.chomp.to_i ary = [] 1.upto(9) do |n1| 1.upto(9) do |n2| ary << n1*n2 end end puts (ary.include?(n)) ? 'Yes' : 'No'
#!/usr/bin/env ruby # require 'pry' n = gets.chomp.to_i ary = [] 1.upto(9) do |n1| 1.upto(9) do |n2| ary << n1*n2 end end puts (ary.include?(n)) ? 'Yes' : 'No'
[ "call.remove" ]
675,720
675,721
u347201362
ruby
p02880
n = gets.to_i ans = 'No' 1.upto(9) do |i| div, mod = n.divmod(i) ans = 'Yes' if [1..9].include?(div) && mod.zero? end puts ans
n = gets.to_i ans = 'No' 1.upto(9) do |i| div, mod = n.divmod(i) ans = 'Yes' if (1..9).include?(div) && mod.zero? end puts ans
[ "control_flow.branch.if.condition.change" ]
675,832
675,833
u889326464
ruby
p02880
n=gets.to_i for i in 1..9 for j in 1..9 if i*j==n puts "yes" exit end end end puts "no"
n=gets.to_i for i in 1..9 for j in 1..9 if i*j==n puts "Yes" exit end end end puts "No"
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
675,860
675,861
u602591412
ruby
p02880
number = gets.to_i answer = "No" (1..9).each do |n| if number % n == 0 && number / n = 1 && number / n <= 9 answer = "Yes" break end end puts answer
number = gets.to_i answer = "No" (1..9).each do |n| if number % n == 0 && number / n >= 1 && number / n <= 9 answer = "Yes" break end end puts answer
[ "control_flow.branch.if.condition.change" ]
675,919
675,920
u333374716
ruby
p02880
a=gets.to_i 9.times do |i| c=a/(i+1) if c>=1 and c<=9 and a%(i+1)==0 print("Yes") break else #print("No") end end print("No")
a=gets.to_i 9.times do |i| c=a/(i+1) if c>=1 and c<=9 and a%(i+1)==0 print("Yes") exit else #print("No") end end print("No")
[ "control_flow.break.remove", "control_flow.exit.add" ]
675,962
675,963
u506228157
ruby
p02880
puts 0x20101814325195b35d7fe[`dd`.to_i]?:Yes: :No
puts 0x20101814325195b35d7fe[gets.to_i]>0?:Yes: :No
[ "variable_access.subscript.index.change", "control_flow.branch.if.condition.change" ]
676,057
676,058
u832039789
ruby
p02880
p([1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81].index(gets.to_i)?:Yes: :No)
puts [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81].index(gets.to_i)?:Yes: :No
[ "call.function.change", "io.output.change", "call.arguments.change" ]
676,094
676,095
u976045235
ruby
p02880
p([1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81].index[gets.to_i]?:Yes: :No)
puts [1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,32,35,36,40,42,45,48,49,54,56,63,64,72,81].index(gets.to_i)?:Yes: :No
[ "call.function.change", "io.output.change", "call.arguments.change", "control_flow.branch.if.condition.change" ]
676,096
676,095
u976045235
ruby
p02880
line = gets.to_i flg = false (1..9).each do |n| (1..9).each do |m| flg = true if n * m == line end end puts flg ? 'YES' : 'NO'
line = gets.to_i flg = false (1..9).each do |n| (1..9).each do |m| flg = true if n * m == line end end puts flg ? 'Yes' : 'No'
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
676,238
676,239
u495110940
ruby
p02880
N = gets.to_i def solve(n) (1..10).each do |a| (1..10).each do |b| return "Yes" if a*b == n end end return "No" end puts solve(N)
N = gets.to_i def solve(n) (1..9).each do |a| (1..9).each do |b| return "Yes" if a*b == n end end return "No" end puts solve(N)
[ "literal.number.integer.change" ]
676,906
676,907
u487252913
ruby
p02880
input = gets N = input.split(" ")[0].to_i i = 1 arry = [] 9.times do j = 1 9.times do ans = i*j arry.push(ans) j += 1 end i += 1 end if arry.include?(N) puts "Yes" else p "No" end
input = gets N = input.split(" ")[0].to_i i = 1 arry = [] 9.times do j = 1 9.times do ans = i*j arry.push(ans) j += 1 end i += 1 end if arry.include?(N) puts "Yes" else puts "No" end
[ "call.function.change", "io.output.change" ]
677,770
677,771
u532764966
ruby
p02880
input = gets N = input.split(" ")[0].to_i i = 1 arry = [] 9.times do j = 1 9.times do ans = i*j arry.push(ans) j += 1 end i += 1 end if arry.include?(N) p "Yes" else p "No" end
input = gets N = input.split(" ")[0].to_i i = 1 arry = [] 9.times do j = 1 9.times do ans = i*j arry.push(ans) j += 1 end i += 1 end if arry.include?(N) puts "Yes" else puts "No" end
[ "call.function.change", "io.output.change" ]
677,772
677,771
u532764966
ruby
p02880
input = gets N = input.split(" ")[0].to_i i = 1 arry = [] 9.times do j = 1 9.times do ans = i*j arry.push(ans) j += 1 end i += 1 end if arry.include?(N) p 'Yes' else p 'No' end
input = gets N = input.split(" ")[0].to_i i = 1 arry = [] 9.times do j = 1 9.times do ans = i*j arry.push(ans) j += 1 end i += 1 end if arry.include?(N) puts "Yes" else puts "No" end
[ "literal.string.change", "call.arguments.change" ]
677,773
677,771
u532764966
ruby
p02880
c = [] for a in 1...9 do for b in 1...9 do if a >= 1 && a <= 9 && b >= 1 && b <= 9 c << a * b end end end puts c.include?(gets.to_i) ? 'Yes' : 'No'
c = [] for a in 1..9 do for b in 1..9 do if a >= 1 && a <= 9 && b >= 1 && b <= 9 c << a * b end end end puts c.include?(gets.to_i) ? 'Yes' : 'No'
[]
677,859
677,860
u498700239
ruby
p02880
n = gets.to_i calc = [] 9.times do |i| 9.times do |j| calc.append((i+1)*(j+1)) end end puts(n.include?(n) ? "Yes" : "No")
n = gets.to_i calc = [] 9.times do |i| 9.times do |j| calc.push((i+1)*(j+1)) end end puts(calc.include?(n) ? "Yes" : "No")
[ "identifier.change", "control_flow.branch.if.condition.change" ]
678,323
678,322
u403537991
ruby
p02881
N=gets.to_i ret = N root = Math.sqrt(N).to_i i = 1 while i < root r,q = N.divmod(i) if q == 0 t = i+r-2 ret = t if t < ret end i += 1 end puts ret
N=gets.to_i ret = N+1 root = Math.sqrt(N).to_i i = 1 while i <= root r,q = N.divmod(i) if q == 0 t = i+r-2 ret = t if t < ret end i += 1 end puts ret
[ "expression.operator.compare.change", "expression.operation.binary.change" ]
678,891
678,892
u852974293
ruby
p02881
N = gets.to_i if N == 1 then puts '0' exit end result = [] num = N i = 2 while i <= Math.sqrt(num) do if num % i == 0 result << i end i += 1 end min = N*2 result.each do |a| b = N/a dist = a+b-2 min = dist if min > dist end puts min
N = gets.to_i if N == 1 then puts '0' exit end result = [] num = N i = 1 while i <= Math.sqrt(num) do if num % i == 0 result << i end i += 1 end min = N*2 result.each do |a| b = N/a dist = a+b-2 min = dist if min > dist end puts min
[ "literal.number.integer.change", "assignment.value.change" ]
679,080
679,081
u244257825
ruby
p02881
N = gets.to_i if N == 1 then puts '0' exit end result = [] num = N i = 2 while i <= Math.sqrt(num) do if num % i == 0 puts i result << i end i += 1 end min = N*2 result.each do |a| b = N/a dist = a+b-2 min = dist if min > dist end puts min
N = gets.to_i if N == 1 then puts '0' exit end result = [] num = N i = 1 while i <= Math.sqrt(num) do if num % i == 0 result << i end i += 1 end min = N*2 result.each do |a| b = N/a dist = a+b-2 min = dist if min > dist end puts min
[ "literal.number.integer.change", "assignment.value.change", "call.remove" ]
679,082
679,081
u244257825
ruby
p02881
def divisors(num) num.prime_division.inject([1]) do |arr, (p, e)| (0..e).map { |e1| p**e1 }.product(arr).map { |a, b| a * b } end.sort end n = gets.to_i d = divisors(n) # puts(d: d) ans = (n - 1) ((d.length + 1) / 2).times do |i| xdiff = (d[i] - 1) ydiff = (d[-1 * (i + 1)] - 1) # puts(xdiff: xdiff, ydiff: ydiff) ans = xdiff + ydiff if xdiff + ydiff <= ans end puts ans
require 'prime' def divisors(num) num.prime_division.inject([1]) do |arr, (p, e)| (0..e).map { |e1| p**e1 }.product(arr).map { |a, b| a * b } end.sort end n = gets.to_i d = divisors(n) ans = (n - 1) ((d.length + 1) / 2).times do |i| xdiff = (d[i] - 1) ydiff = (d[-1 * (i + 1)] - 1) ans = xdiff + ydiff if xdiff + ydiff <= ans end puts ans
[ "call.add" ]
680,023
680,024
u889326464
ruby
p02881
require 'prime' def divisors(num) num.prime_division.inject([1]) do |arr, (p, e)| (0..e).map { |e1| p**e1 }.product(arr).map { |a, b| a * b } end.sort end n = gets.to_i d = divisors(n) ans = (n - 1) (d.length / 2).times do |i| xdiff = (d[i] - 1) ydiff = (d[-1 * (i + 1)] - 1) ans = xdiff + ydiff if xdiff + ydiff <= ans end puts ans
require 'prime' def divisors(num) num.prime_division.inject([1]) do |arr, (p, e)| (0..e).map { |e1| p**e1 }.product(arr).map { |a, b| a * b } end.sort end n = gets.to_i d = divisors(n) ans = (n - 1) ((d.length + 1) / 2).times do |i| xdiff = (d[i] - 1) ydiff = (d[-1 * (i + 1)] - 1) ans = xdiff + ydiff if xdiff + ydiff <= ans end puts ans
[]
680,025
680,024
u889326464
ruby
p02881
a = gets.to_i max = (Math.sqrt(50)).to_i res = 0 max.downto(1) do |n| if a%n==0 res = a/n + n - 2 break end end puts res
a = gets.to_i max = (Math.sqrt(a)).to_i res = 0 max.downto(1) do |n| if a%n==0 res = a/n + n - 2 break end end puts res
[ "assignment.value.change", "identifier.replace.add", "literal.replace.remove", "call.arguments.change" ]
680,255
680,256
u296296948
ruby
p02881
n=gets.to_i cnt=n-2 ((n**(1/2.0)).to_i).times do |i| i+=1 cnt = [cnt,i+n/i -2].min if n%i==0 end puts cnt
n=gets.to_i cnt=n-1 ((n**(1/2.0)).to_i).times do |i| i+=1 cnt = [cnt,i+n/i -2].min if n%i==0 end puts cnt
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
680,321
680,322
u926099741
ruby
p02881
input = gets.chomp.to_i t = Math.sqrt(input).to_i r = (1..t).map do |n| if input % n == 0 n + (input / n) -2 else 2147483647 end end puts r.min
input = gets.chomp.to_i t = Math.sqrt(input).to_i r = (1..t).map do |n| if input % n == 0 n + (input / n) -2 else 10**12 + 1 end end puts r.min
[ "literal.number.integer.change", "assignment.value.change" ]
680,556
680,557
u447059782
ruby
p02881
require 'prime' n = gets.strip.to_i ans = [1,1] divs=Prime.prime_division(n) nums = divs.map{|pr,c| [pr]*c } .flatten if nums.length==1 p n-1 exit end result = n Math.sqrt(n).to_i.times do |i| next unless (n%(i+2)).zero? tmp = (i+1 + n/(i+1))-2 #p [n, n/(i+1)*n==n, tmp] result = [result, tmp].min end p result
require 'prime' n = gets.strip.to_i ans = [1,1] divs=Prime.prime_division(n) nums = divs.map{|pr,c| [pr]*c } .flatten if nums.length==1 p n-1 exit end result = n Math.sqrt(n).to_i.times do |i| next unless (n%(i+1)).zero? tmp = (i+1 + n/(i+1))-2 #p [n, n/(i+1)*n==n, tmp] result = [result, tmp].min end p result
[ "literal.string.change", "call.arguments.change" ]
680,945
680,946
u021358975
ruby