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 |
|---|---|---|---|---|---|---|---|
p02996 | N=gets.to_i
temp=N.times.map{gets.split.map(&:to_i)}.transpose.map{|t|t.map.with_index{|e,i|[e,i]}}
temp[1].sort!{|a,b|a[0]<=>b[0]}
cnt="Yes"
fc,lc =0,0
N.times do |i|
fc+=temp[0][temp[1][i][1]][0]
lc+=temp[1][i][0]
cnt="No" if lc<=fc
end
| N=gets.to_i
temp=N.times.map{gets.split.map(&:to_i)}.transpose.map{|t|t.map.with_index{|e,i|[e,i]}}
temp[1].sort!{|a,b|a[0]<=>b[0]}
cnt="Yes"
fc,lc =0,0
N.times do |i|
fc+=temp[0][temp[1][i][1]][0]
lc=temp[1][i][0]
cnt="No" if lc<fc
end
puts cnt | [
"assignment.value.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"call.add"
] | 807,287 | 807,286 | u926099741 | ruby |
p02996 | N=gets.to_i
temp=N.times.map{gets.split.map(&:to_i)}.transpose.map{|t|t.map.with_index{|e,i|[e,i]}}
temp[1].sort!{|a,b|a[0]<=>b[0]}
cnt="Yes"
fc,lc =0,0
N.times do |i|
fc+=temp[0][temp[1][i][1]][0]
lc+=temp[1][i][0]
cnt="No" if lc<fc
end
| N=gets.to_i
temp=N.times.map{gets.split.map(&:to_i)}.transpose.map{|t|t.map.with_index{|e,i|[e,i]}}
temp[1].sort!{|a,b|a[0]<=>b[0]}
cnt="Yes"
fc,lc =0,0
N.times do |i|
fc+=temp[0][temp[1][i][1]][0]
lc=temp[1][i][0]
cnt="No" if lc<fc
end
puts cnt | [
"assignment.value.change",
"call.add"
] | 807,289 | 807,286 | u926099741 | ruby |
p02999 | X, A = gets.split.map!(&:to_i)
puts (X > A) ? 10 : 0 | X, A = gets.split.map!(&:to_i)
puts (X < A) ? 0 : 10 | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 810,001 | 810,002 | u295334477 | ruby |
p03000 | require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,x = gets.chomp.split.map(&:to_i)
l = gets.chomp.split.map(&:to_i)
d = 0
ans = 0
n.times do |i|
d += l[ans]
ans += 1
unless d <= x
ans += 1
break
end
end
puts ans | require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,x = gets.chomp.split.map(&:to_i)
l = gets.chomp.split.map(&:to_i)
d = 0
ans = 1
n.times do |i|
d += l[i]
ans += 1
unless d <= x
ans -= 1
break
end
end
puts ans | [
"literal.number.integer.change",
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"expression.operator.change"
] | 811,706 | 811,707 | u524019694 | ruby |
p03000 |
N, X = gets.chomp.split.map(&:to_i)
L = gets.split(" ").map!{|i| i.to_i}
d = 0
for i in 0..N-1
d += L[i]
if d > X
puts i + 1
break
end
end
if d <= X
puts N
end |
N, X = gets.chomp.split.map(&:to_i)
L = gets.split(" ").map!{|i| i.to_i}
d = 0
for i in 0..N-1
d += L[i]
if d > X
puts i + 1
break
end
end
if d <= X
puts N + 1
end | [
"expression.operation.binary.add"
] | 812,723 | 812,724 | u501265339 | ruby |
p03001 | w,h,x,y = gets.chomp.split.map(&:to_i)
flag = 0
s = w*h/2
flag = (w/2.to_f == x && h/2.to_f == y) ? 1 : 0
puts "#{s} #{flag}" | w,h,x,y = gets.chomp.split.map(&:to_i)
flag = 0
s = w*h/2.to_f
flag = (w/2.to_f == x && h/2.to_f == y) ? 1 : 0
puts "#{s} #{flag}" | [
"call.add"
] | 814,804 | 814,805 | u191196346 | ruby |
p03001 | W, H, X, Y = gets.chomp.split(' ').map(&:to_i)
puts "#{1.0 * W * H / 2} #{W/2 == X && H/2 == Y ? 1 : 0}"
| W, H, X, Y = gets.chomp.split(' ').map(&:to_i)
puts "#{1.0 * W * H / 2} #{W/2.0 == X && H/2.0 == Y ? 1 : 0}"
| [
"literal.string.change",
"call.arguments.change"
] | 817,632 | 817,633 | u056626722 | ruby |
p03007 | N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)[0..N].sort
positives, negatives = A.partition{ |v| v > 0 }
min = A.min
max = A.max
puts (if min > 0
A.reduce(&:+) - min*2
elsif max < 0
max*2 - A.reduce(&:+)
else
positives.reduce(&:+) - negatives.reduce(&:+)
end)
(N-1).times do |i|
a, b = begin
i... | N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)[0..N].sort
positives, negatives = A.partition{ |v| v > 0 }
min = A.min
max = A.max
puts (if min > 0
A.reduce(&:+) - min*2
elsif max < 0
max*2 - A.reduce(&:+)
else
positives.reduce(0, &:+) - negatives.reduce(0, &:+)
end)
(N-1).times do |i|
a, b = begin... | [
"call.arguments.add"
] | 821,323 | 821,324 | u056626722 | ruby |
p03012 | n = gets.chop.to_i
array=[]
i=1
numbers = gets.strip.split.map(&:to_i)
(n/2+3).times do
array << (numbers[0,i].inject(:+)-numbers[i..-1].inject(:+)).abs
i+=1
end
puts array.min | n = gets.chop.to_i
array=[]
i=1
numbers = gets.strip.split.map(&:to_i)
(n-1).times do
array << (numbers[0,i].inject(:+)-numbers[i..-1].inject(:+)).abs
i+=1
end
puts array.min | [
"expression.operation.binary.remove"
] | 824,463 | 824,464 | u891506774 | ruby |
p03012 | n = gets.chop.to_i
array=[]
i=1
numbers = gets.strip.split.map(&:to_i)
(n/2+1).times do
array << (numbers[0,i].inject(:+)-numbers[i..-1].inject(:+)).abs
i+=1
end
puts array.min | n = gets.chop.to_i
array=[]
i=1
numbers = gets.strip.split.map(&:to_i)
(n-1).times do
array << (numbers[0,i].inject(:+)-numbers[i..-1].inject(:+)).abs
i+=1
end
puts array.min | [
"expression.operator.arithmetic.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 824,465 | 824,464 | u891506774 | ruby |
p03017 | n,a,b,c,d=gets.chomp.split(" ").map(&:to_i)
arr=gets.chomp
a-=1
b-=1
c-=1
d-=1
if c < d
if not arr[(b+1)..(d-1)].include?("##") and not arr[(a+1)..(c-1)].include?("##")
puts("Yes")
else
puts("No")
end
else
tmp=arr[(a+1)..(c-1)]
if not tmp.include?("##") and arr[(b+1)..(d-1)].include?("...") and not ... | n,a,b,c,d=gets.chomp.split(" ").map(&:to_i)
arr=gets.chomp
a-=1
b-=1
c-=1
d-=1
if c < d
if not arr[(b+1)..(d-1)].include?("##") and not arr[(a+1)..(c-1)].include?("##")
puts("Yes")
else
puts("No")
end
else
tmp=arr[(a+1)..(c-1)]
if not tmp.include?("##") and arr[(b-1)..(d+1)].include?("...") and not ... | [
"misc.opposites",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 831,117 | 831,118 | u111773061 | ruby |
p03029 | a,p=gets.split.map(&:to_i)
puts (a*3+2)/2 | a,p=gets.split.map(&:to_i)
puts (a*3+p)/2 | [
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 838,150 | 838,151 | u757117214 | ruby |
p03029 | a,p=gets.to_i
puts (a*3+p)/2 | a,p=gets.split.map(&:to_i)
puts (a*3+p)/2 | [
"assignment.value.change",
"identifier.change",
"call.add"
] | 838,152 | 838,151 | u757117214 | ruby |
p03029 | a,p=gets.split.map(&:to_i)
puts a*3+p/2 | a,p=gets.split.map(&:to_i)
puts (a*3+p)/2 | [
"call.arguments.change"
] | 838,153 | 838,151 | u757117214 | ruby |
p03031 | N, M = gets.split.map &:to_i
Ss = M.times.map{
k, *s = gets.split.map &:to_i
s.map(&:pred)
}
P = gets.split.map &:to_i
p (0..2**N).count{|bits|
Ss.map.with_index(0).all?{|s, i|
sum = s.map{|z| bits[z] }.inject(:+)
sum % 2 == P[i]
}
} | N, M = gets.split.map &:to_i
Ss = M.times.map{
k, *s = gets.split.map &:to_i
s.map(&:pred)
}
P = gets.split.map &:to_i
p (0...2**N).count{|bits|
Ss.map.with_index(0).all?{|s, i|
sum = s.map{|z| bits[z] }.inject(:+)
sum % 2 == P[i]
}
} | [
"call.arguments.change"
] | 842,103 | 842,104 | u711705317 | ruby |
p03035 | a,b = gets.split.map(&:to_i)
if a > 13
puts b
elsif a > 6
puts b/2
else
puts 0
end
| a,b = gets.split.map(&:to_i)
if a >= 13
puts b
elsif a >= 6
puts b/2
else
puts 0
end
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 847,422 | 847,423 | u634342027 | ruby |
p03035 | A,B=gets.chomp.split(" ").map(&:to_i);
if A<6
B = 0
elsif A <12
B = B/2
end
puts B | A,B=gets.chomp.split(" ").map(&:to_i);
if A<6
B = 0
elsif A <13
B = B/2
end
puts B | [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 848,532 | 848,533 | u602984196 | ruby |
p03037 | n,m = gets.chomp.split().map(&:to_i)
l = []
r = []
m.times do
ll, rr = gets.chomp.split().map(&:to_i)
l.push ll
r.push rr
end
puts r.min - l.max + 1
| n,m = gets.chomp.split().map(&:to_i)
l = []
r = []
m.times do
ll, rr = gets.chomp.split().map(&:to_i)
l.push ll
r.push rr
end
puts [r.min - l.max + 1, 0].max
| [
"call.arguments.change",
"call.add"
] | 850,290 | 850,291 | u524019694 | ruby |
p03037 | #!/usr/bin/ruby
# encoding: utf-8
#main
# input
N,M = gets.split.map(&:to_i)
L = Array.new(M)
R = Array.new(M)
(0..M-1).each do |i|
L[i],R[i] = gets.split.map(&:to_i)
end
ans = 0
ans max(R.min - L.max + 1 , 0)
puts ans
| #!/usr/bin/ruby
# encoding: utf-8
#main
# input
N,M = gets.split.map(&:to_i)
L = Array.new(M)
R = Array.new(M)
(0..M-1).each do |i|
L[i],R[i] = gets.split.map(&:to_i)
end
ans = 0
ans = [R.min - L.max + 1,0].max
puts ans
| [
"assignment.value.change",
"call.arguments.change",
"call.add"
] | 851,716 | 851,717 | u998741086 | ruby |
p03038 | N,M=gets.chomp.split.map(&:to_i)
A=gets.chomp.split.map(&:to_i)
bc=M.times.map { gets.split.map(&:to_i) }
bc.sort_by!{|i,j| j }.reverse!
A.sort!
af = []
a = A
if M > 0
ix = A.bsearch_index{|x| x >= bc[0][1] }
if ix != nil
af = A[ix..-1]
a = A[0...ix]
end
end
M.times do |i|
break if a.empty? || a[0]>... | N,M=gets.chomp.split.map(&:to_i)
A=gets.chomp.split.map(&:to_i)
bc=M.times.map { gets.split.map(&:to_i) }
bc.sort_by!{|i,j| j }.reverse!
A.sort!
af = []
a = A
if M > 0
ix = A.bsearch_index{|x| x >= bc[0][1] }
if ix != nil
af = A[ix..-1]
a = A[0...ix]
end
end
M.times do |i|
break if a.empty? || a[0]>... | [
"call.remove"
] | 853,623 | 853,624 | u029152350 | ruby |
p03041 | N, K = gets.split.map(&:to_i)
S = gets.chomp
S[K] = S[K].downcase
puts S
| N, K = gets.split.map(&:to_i)
S = gets.chomp
S[K-1] = S[K-1].downcase
puts S
| [
"assignment.change"
] | 855,502 | 855,503 | u846185950 | ruby |
p03041 | _,b,c=`dd`.split
c.each_char.with_index{|s,i|print i==~-b ?s.downcase : s}
puts | _,b,c=`dd`.split
c.each_char.with_index{|s,i|print i==~-b.to_i ? s.downcase : s}
puts
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 855,582 | 855,583 | u966810027 | ruby |
p03041 | _,b,c=`dd`.split
c.each_char.with_index{|s,i|print i==~-b ?s.downcase : s}
| _,b,c=`dd`.split
c.each_char.with_index{|s,i|print i==~-b.to_i ? s.downcase : s}
puts
| [
"control_flow.branch.if.condition.change",
"call.add",
"io.output.change"
] | 855,584 | 855,583 | u966810027 | ruby |
p03041 | _,b,c=`dd`.split
c.each_char.with_index{|s,i|print i==~-c ?s.downcase : s}
| _,b,c=`dd`.split
c.each_char.with_index{|s,i|print i==~-b.to_i ? s.downcase : s}
puts
| [
"control_flow.branch.if.condition.change",
"call.add",
"io.output.change"
] | 855,585 | 855,583 | u966810027 | ruby |
p03042 | S = gets.chomp
ans = ''
i = 0
for nums in S.split(/\A(.{2,2})/, 2)[1..-1] do
if nums.to_i > 12 || nums.to_i == 0
ans += "Y"
else
ans += "M"
end
i += 1
end
if ans == "YM"
p 'YYMM'
elsif ans == "MY"
p "MMYY"
elsif ans == "MM"
p 'AMBIGUOUS'
else
p 'NA'
end
| S = gets.chomp
ans = ''
i = 0
for nums in S.split(/\A(.{2,2})/, 2)[1..-1] do
if nums.to_i > 12 || nums.to_i == 0
ans += "Y"
else
ans += "M"
end
i += 1
end
if ans == "YM"
puts "YYMM"
elsif ans == "MY"
puts "MMYY"
elsif ans == "MM"
puts 'AMBIGUOUS'
else
puts 'NA'
end
| [
"literal.string.change",
"call.arguments.change",
"call.function.change",
"io.output.change"
] | 858,202 | 858,203 | u429775245 | ruby |
p03042 | S = gets
A = S[0..1]
B = S[2..3]
month = ['01','02','03','04','05','06','07','08','09','10','11','12']
if month.include?(A)
if month.include?(B)
p 'AMBIGUOUS'
else
p 'MMYY'
end
else
if month.include?(B)
p 'YYMM'
else
p 'NA'
end
end | S = gets
A = S[0..1]
B = S[2..3]
month = ['01','02','03','04','05','06','07','08','09','10','11','12']
if month.include?(A)
if month.include?(B)
print 'AMBIGUOUS'
else
print 'MMYY'
end
else
if month.include?(B)
print 'YYMM'
else
print 'NA'
end
end
| [
"call.function.change",
"io.output.change"
] | 859,624 | 859,625 | u563722393 | ruby |
p03044 | N = STDIN.gets.chomp.to_i
info = Array.new(0)
result = Array.new(N, -1)
while (line = STDIN.gets) != nil do
info.push(line.chomp.split(' ').map(&:to_i))
end
tree = Array.new(N).map{Array.new(0)}
info.each { |a|
# info[i-1][0] に u
# info[i-1][1] に v
u, v, w = a
bin = w % 2
tree[u-1].push([v-1, bin])
tre... | N = STDIN.gets.chomp.to_i
info = Array.new(0)
result = Array.new(N, -1)
while (line = STDIN.gets) != nil do
info.push(line.chomp.split(' ').map(&:to_i))
end
tree = Array.new(N).map{Array.new(0)}
info.each { |a|
# info[i-1][0] に u
# info[i-1][1] に v
u, v, w = a
bin = w % 2
tree[u-1].push([v-1, bin])
tre... | [
"assignment.change"
] | 862,987 | 862,988 | u231458241 | ruby |
p03049 | n = gets.to_i
ss = []
ans = 0
start_with_b = 0
end_with_a = 0
both = 0
n.times do
s = gets.chomp
ans += s.scan(/AB/).size
if s[0] == 'B' && s[-1] == 'A'
both += 1
elsif s[0] == 'B'
start_with_b += 1
elsif s[-1] == 'A'
end_with_a += 1
end
end
ans += both - 1
if end_with_a > 0
end_with_a -= ... | n = gets.to_i
ss = []
ans = 0
start_with_b = 0
end_with_a = 0
both = 0
n.times do
s = gets.chomp
ans += s.scan(/AB/).size
if s[0] == 'B' && s[-1] == 'A'
both += 1
elsif s[0] == 'B'
start_with_b += 1
elsif s[-1] == 'A'
end_with_a += 1
end
end
if both > 0
ans += both - 1
if end_with_a > 0
... | [] | 866,298 | 866,299 | u298628832 | ruby |
p03053 | H, W = gets.split.map(&:to_i)
INFINITY = 999999999
dark = []
max_hw = Array.new(H) { Array.new(W, INFINITY) }
H.times do |i|
gets.chomp.each_char.with_index do |c, idx|
if c == '#'
dark.unshift([i, idx, 0])
max_hw[i][idx] = 0
end
end
end
p dark
count = 0
while !dark.empty?
y, x, count = d... | H, W = gets.split.map(&:to_i)
INFINITY = 999999999
dark = []
max_hw = Array.new(H) { Array.new(W, INFINITY) }
H.times do |i|
gets.chomp.each_char.with_index do |c, idx|
if c == '#'
dark.unshift([i, idx, 0])
max_hw[i][idx] = 0
end
end
end
count = 0
while !dark.empty?
y, x, count = dark.shif... | [
"call.remove"
] | 871,237 | 871,238 | u503890246 | ruby |
p03068 | _ = gets
s = gets
i = gets.to_i
print s.gsub(/[^#{s[i-1]}]/,"*") | _ = gets
s = gets.chomp
i = gets.to_i
print s.gsub(/[^#{s[i-1]}]/,"*") | [
"call.add"
] | 878,938 | 878,939 | u702482655 | ruby |
p03071 | a, b = readlines.map(&:to_i)
ans = 0
2.times do
if a >= b
ans += a
a -= 1
else
ans += b
b -= 1
end
end
p ans | a, b = readline.split.map(&:to_i)
ans = 0
2.times do
if a >= b
ans += a
a -= 1
else
ans += b
b -= 1
end
end
p ans | [
"assignment.value.change",
"identifier.change",
"call.add"
] | 881,992 | 881,993 | u617691573 | ruby |
p03069 | _=gets;
s=gets.chomp;
memo=[s.count(".")]
(1..s.size).each{|i|
memo[i]=memo[i-1]+1 if(s[i-1]=="#");
memo[i]=memo[i-1]-1 if(s[i-1]==".");
}
p memo | _=gets;
s=gets.chomp;
memo=[s.count(".")]
(1..s.size).each{|i|
memo[i]=memo[i-1]+1 if(s[i-1]=="#");
memo[i]=memo[i-1]-1 if(s[i-1]==".");
}
p memo.min | [
"call.add"
] | 884,757 | 884,758 | u702482655 | ruby |
p03069 | _=gets;
s=gets.chomp;
memo=[s.count(".")]
(1...s.size).each{|i|
memo[i]=memo[i-1]+1 if(s[i-1]=="#");
memo[i]=memo[i-1]-1 if(s[i-1]==".");
}
p memo.min | _=gets;
s=gets.chomp;
memo=[s.count(".")]
(1..s.size).each{|i|
memo[i]=memo[i-1]+1 if(s[i-1]=="#");
memo[i]=memo[i-1]-1 if(s[i-1]==".");
}
p memo.min | [] | 884,759 | 884,758 | u702482655 | ruby |
p03074 | n,k=gets.split.map(&:to_i)
s = gets
i=0
zo=[-1]
oz=[]
if s[0] == '0'
oz << -1
else
end
loop do
i=s.index('01',i+1)
break if i.nil?
zo << i
end
i=0
loop do
i=s.index('10',i+1)
break if i.nil?
oz << i
end
oz << n-1
if s[-1] == '0'
zo << n-1
end
p (zo.size).times.map { |m| (oz[m+k] || n-1)- zo[m] }.max... | n,k=gets.split.map(&:to_i)
s = gets
i=-1
zo=[-1]
oz=[]
if s[0] == '0'
oz << -1
else
end
loop do
i=s.index('01',i+1)
break if i.nil?
zo << i
end
i=-1
loop do
i=s.index('10',i+1)
break if i.nil?
oz << i
end
oz << n-1
if s[-1] == '0'
zo << n-1
end
p (zo.size).times.map { |m| (oz[m+k] || n-1)- zo[m] }.ma... | [
"assignment.value.change",
"expression.operation.unary.add"
] | 887,287 | 887,288 | u098870186 | ruby |
p03075 | a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
arr = [a,b,c,d,e]
def five_antennas(arr, k)
for i in 0..3 do
for j in i+1..3
if (arr[j] - arr[i]) > k
return ":("
end
end
end
"Yay!"
end
puts five_antennas(arr, k)
| a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
arr = [a,b,c,d,e]
def five_antennas(arr, k)
for i in 0..3 do
for j in i+1..4
if (arr[j] - arr[i]) > k
return ":("
end
end
end
"Yay!"
end
puts five_antennas(arr, k)
| [
"literal.number.integer.change"
] | 888,867 | 888,868 | u528642874 | ruby |
p03075 | a = [ ]
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
k = gets.to_i
catch :break do
for i in 0...a.size
for j in (i+1)...a.size
unless a[i] - j[i] <= k
puts ':('
throw :break
end
end
end
puts 'Yay!'
end
|
a = [ ]
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
a.push gets.to_i
k = gets.to_i
catch :break do
for i in 0...a.size
for j in (i+1)...a.size
unless a[j] - a[i] <= k
puts ':('
throw :break
end
end
end
puts 'Yay!'
end
| [
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 890,256 | 890,257 | u878521408 | ruby |
p03077 | n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
# s a b c d e <- 各場所の人数
s = [n, 0, 0, 0, 0, 0]
x = [a, b, c, d, e]
min = x.min
if min > n
p 5
else
bottle_neck = n.div(min) + 1
p bottle_neck+4
end | n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
# s a b c d e <- 各場所の人数
s = [n, 0, 0, 0, 0, 0]
x = [a, b, c, d, e]
min = x.min
if min > n
p 5
else
#bottle_neck = n.div(min) + 1
bottle_neck = n.fdiv(min).ceil
p bottle_neck+4
end
| [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 893,697 | 893,698 | u366779547 | ruby |
p03077 | n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
# s a b c d e <- 各場所の人数
s = [n, 0, 0, 0, 0, 0]
x = [a, b, c, d, e]
min = x.min
if min > n
p 5
else
bottle_neck = n.div(min) + n%min
p bottle_neck+4
end | n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
# s a b c d e <- 各場所の人数
s = [n, 0, 0, 0, 0, 0]
x = [a, b, c, d, e]
min = x.min
if min > n
p 5
else
#bottle_neck = n.div(min) + 1
bottle_neck = n.fdiv(min).ceil
p bottle_neck+4
end
| [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 893,699 | 893,698 | u366779547 | ruby |
p03079 | a,b,c = gets.split.map(&:to_i)
puts (a == b && a == c)? :YES : :NO | a,b,c = gets.split.map(&:to_i)
puts (a == b && a == c)? 'Yes' : 'No' | [
"call.arguments.change"
] | 895,119 | 895,120 | u951762226 | ruby |
p03080 | # util functions
# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag
def pd(str)
p str if $debugFlag
end
# input
inputs = []
lc = 0
while l = $stdin.gets do
if true
inputs << l.chomp.split(" ").map(&:to_s)
else
inputs << l.chomp.split(" ").map(&:to_i)
end
lc += 1
end
ss ... | # util functions
# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag
def pd(str)
p str if $debugFlag
end
# input
inputs = []
lc = 0
while l = $stdin.gets do
if true
inputs << l.chomp.split(" ").map(&:to_s)
else
inputs << l.chomp.split(" ").map(&:to_i)
end
lc += 1
end
ss ... | [
"call.remove"
] | 896,088 | 896,089 | u714724786 | ruby |
p03080 | # util functions
# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag
def pd(str)
p str if $debugFlag
end
# input
inputs = []
lc = 0
while l = $stdin.gets do
if true
inputs << l.chomp.split(" ").map(&:to_s)
else
inputs << l.chomp.split(" ").map(&:to_i)
end
lc += 1
end
ss ... | # util functions
# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag
def pd(str)
p str if $debugFlag
end
# input
inputs = []
lc = 0
while l = $stdin.gets do
if true
inputs << l.chomp.split(" ").map(&:to_s)
else
inputs << l.chomp.split(" ").map(&:to_i)
end
lc += 1
end
ss ... | [
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.remove"
] | 896,090 | 896,089 | u714724786 | ruby |
p03078 | x, y, z, k = gets.split(' ').map(&:to_i)
as = gets.split(' ').map(&:to_i)
bs = gets.split(' ').map(&:to_i)
cs = gets.split(' ').map(&:to_i)
as.sort!.reverse!
bs.sort!.reverse!
cs.sort!.reverse!
ks = []
ans = []
x.times do |i|
y.times do |j|
ks << as[i] + bs[j]
end
end
kks = ks.sort!.reverse![0..k-1]
k.t... | x, y, z, k = gets.split(' ').map(&:to_i)
as = gets.split(' ').map(&:to_i)
bs = gets.split(' ').map(&:to_i)
cs = gets.split(' ').map(&:to_i)
as.sort!.reverse!
bs.sort!.reverse!
cs.sort!.reverse!
ks = []
ans = []
x.times do |i|
y.times do |j|
ks << as[i] + bs[j]
end
end
kks = ks.sort!.reverse![0..k-1]
kks... | [
"identifier.change",
"call.add"
] | 896,803 | 896,804 | u030314915 | ruby |
p03078 | x, y, z, k = gets.split(' ').map(&:to_i)
as = gets.split(' ').map(&:to_i)
bs = gets.split(' ').map(&:to_i)
cs = gets.split(' ').map(&:to_i)
as.sort!.reverse!
bs.sort!.reverse!
cs.sort!.reverse!
ks = []
ans = []
x.times do |i|
y.times do |j|
ks << as[h] + bs[i]
end
end
kks = ks.sort!.reverse![0..k-1]
k.t... | x, y, z, k = gets.split(' ').map(&:to_i)
as = gets.split(' ').map(&:to_i)
bs = gets.split(' ').map(&:to_i)
cs = gets.split(' ').map(&:to_i)
as.sort!.reverse!
bs.sort!.reverse!
cs.sort!.reverse!
ks = []
ans = []
x.times do |i|
y.times do |j|
ks << as[i] + bs[j]
end
end
kks = ks.sort!.reverse![0..k-1]
kks... | [
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change",
"call.add"
] | 896,805 | 896,804 | u030314915 | ruby |
p03085 | s = gets.chomp
puts "A" if s == "G"
puts "G" if s == "A"
puts "T" if s == "C"
puts "C" if s == "T" | s = gets.chomp
puts "A" if s == "T"
puts "G" if s == "C"
puts "T" if s == "A"
puts "C" if s == "G" | [
"literal.string.change",
"control_flow.branch.if.condition.change"
] | 897,398 | 897,399 | u926099741 | ruby |
p03085 | a=['A','T','C','G']
b=gets
puts b=='T' || b=='G' ? a[a.index(b)-1] : a[a.index(b)+1] | a=['A','T','C','G']
b=gets.chomp
puts b=='T' || b=='G' ? a[a.index(b)-1] : a[a.index(b)+1]
| [
"call.add"
] | 897,822 | 897,823 | u585819925 | ruby |
p03085 | a=gets.chomp
if a=='T'
puts 'A'
elsif a=='A'
puts 'T'
elsif a=='G'
puts 'C'
elsif a=='C'
puts 'C'
end
| a=gets.chomp
if a=='T'
puts 'A'
elsif a=='A'
puts 'T'
elsif a=='G'
puts 'C'
elsif a=='C'
puts 'G'
end
| [
"literal.string.change",
"call.arguments.change"
] | 898,486 | 898,487 | u308416164 | ruby |
p03086 | b = gets.chop.split("")
arr = ["A","C","G","T"]
count = []
sum = 0
for a in b
if arr.include?(a)
sum += 1
else
count.push(sum)
sum = 0
end
end
puts count.max
| b = gets.chop.split("")
arr = ["A","C","G","T"]
count = []
sum = 0
for a in b
if arr.include?(a)
sum += 1
else
count.push(sum)
sum = 0
end
end
count.push(sum)
puts count.max
| [
"call.add"
] | 901,429 | 901,430 | u634342027 | ruby |
p03087 | # A[i], A[i-1] = "C", "A"になるiの場所で累積和。探索はB[i]-B[i-1]
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp.chars
arr = 0.upto(n).to_a.map{0}
(1...n).to_a.each do |i|
if s[i-1] == "A" && s[i] == "C"
arr[i]+=1
end
end
(1...n).to_a.each do |i|
arr[i]+=arr[i-1]
end
p arr
q.times do
a, b = gets.chomp.split.map(&:to... | # A[i], A[i-1] = "C", "A"になるiの場所で累積和。探索はB[i]-B[i-1]
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp.chars
arr = 0.upto(n).to_a.map{0}
(1...n).to_a.each do |i|
if s[i-1] == "A" && s[i] == "C"
arr[i]+=1
end
end
(1...n).to_a.each do |i|
arr[i]+=arr[i-1]
end
q.times do
a, b = gets.chomp.split.map(&:to_i)
... | [
"call.remove"
] | 903,093 | 903,094 | u247554097 | ruby |
p03088 | MOD = 10**9+7
def ok?(i,j,k,l)
if i ==1 && l== 3 && (j == 2 || k == 2)
return false
end
s = "#{j}#{k}#{l}"
if s.include?("123") || s.include?("132") || s.include?("213")
return false
end
return true
end
N = gets.to_i
dp = Array.new(N+1) {Array.new(4){Array.new(4){Array.new(4,0)}}}
#dp[n][i][j]... | MOD = 10**9+7
def ok?(i,j,k,l)
if i ==1 && l== 3 && (j == 2 || k == 2)
return false
end
s = "#{j}#{k}#{l}"
if s.include?("123") || s.include?("132") || s.include?("213")
return false
end
return true
end
N = gets.to_i
dp = Array.new(N+1) {Array.new(4){Array.new(4){Array.new(4,0)}}}
#dp[n][i][j]... | [
"expression.operation.binary.add"
] | 903,979 | 903,980 | u708550576 | ruby |
p03104 | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r}... | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r}... | [
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 911,759 | 911,760 | u145123922 | ruby |
p03106 | a, b, k = gets.chomp.split.map(&:to_i)
arr = []
1.upto(100) do |i|
if a % i == 0 && b % i == 0
arr << i
end
end
p arr.reverse!
p arr[k-1]
| a, b, k = gets.chomp.split.map(&:to_i)
arr = []
1.upto(100) do |i|
if a % i == 0 && b % i == 0
arr << i
end
end
arr.reverse!
p arr[k-1]
| [
"io.output.change",
"call.remove"
] | 914,941 | 914,942 | u968699140 | ruby |
p03106 | a, b, k= gets.chomp.split(' ').map(&:to_i)
answer=[]
(1..100).each do |n|
if a%n ==0 && b%n ==0
answer << n
end
end
# answer => [1,2,4]
answer.reverse
# answer =>[4, 2, 1]
# indexは0スタートなので -1する
puts answer[k -1] | a, b, k= gets.chomp.split(' ').map(&:to_i)
answer=[]
(1..100).each do |n|
if a%n ==0 && b%n ==0
answer << n
end
end
# answer => [1,2,4]
n = answer.reverse
# answer =>[4, 2, 1]
# indexは0スタートなので -1する
puts n[k -1] | [
"identifier.change",
"call.arguments.change"
] | 915,360 | 915,361 | u841921145 | ruby |
p03106 | a, b, k= gets.chomp.split(' ').map(&:to_i)
answer=[]
(1..100).each do |n|
if a%n ==0 && b%n ==0
answer << n
end
end
puts answer[k -1] | a, b, k= gets.chomp.split(' ').map(&:to_i)
answer=[]
(1..100).each do |n|
if a%n ==0 && b%n ==0
answer << n
end
end
# answer => [1,2,4]
n = answer.reverse
# answer =>[4, 2, 1]
# indexは0スタートなので -1する
puts n[k -1] | [
"assignment.variable.change",
"call.add"
] | 915,362 | 915,361 | u841921145 | ruby |
p03107 | s = gets.chomp.sprit('')
a = s.count('0')
b = s.count('1')
puts s.length - ((a - b).abs) | s = gets.chomp.split('')
a = s.count('0')
b = s.count('1')
puts s.length - ((a - b).abs)
| [
"assignment.value.change",
"identifier.change"
] | 917,701 | 917,702 | u786261754 | ruby |
p03111 | def synthetic_kadomatsu(n, a, b, c, l)
dfs = ->(cur, a_len, b_len, c_len) {
if cur == n
return [a_len, b_len, c_len].min > 0 ? (a - a_len).abs + (b - b_len).abs + (c - c_len).abs - 30 : INF # 最初の1回分のMP10のコストは本来不要。a,b,c3回分の30引く
end
ret0 = dfs.call(cur + 1, a_len, b_len, c_len)
ret1 = dfs.call(cu... | INF = 10 ** 10
def synthetic_kadomatsu(n, a, b, c, l)
dfs = ->(cur, a_len, b_len, c_len) {
if cur == n
return [a_len, b_len, c_len].min > 0 ? (a - a_len).abs + (b - b_len).abs + (c - c_len).abs - 30 : INF # 最初の1回分のMP10のコストは本来不要。a,b,c3回分の30引く
end
ret0 = dfs.call(cur + 1, a_len, b_len, c_len)
re... | [
"assignment.add"
] | 924,055 | 924,056 | u976045502 | ruby |
p03125 | a,b=gets.split.map &:to_i;p b.send(b/a>0?:-: :+,a) | a,b=gets.split.map &:to_i;p b.send(b%a>0?:-: :+,a) | [
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 926,864 | 926,865 | u280667879 | ruby |
p03129 | N , K = gets.split.map!{|n| n.to_i}
if N >= 2 * K - 1
puts "yes"
else
puts "no"
end | N , K = gets.split.map!{|n| n.to_i}
if N >= 2 * K - 1
puts "YES"
else
puts "NO"
end
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 931,151 | 931,152 | u692254521 | ruby |
p03130 | ab = []
3.times do
ab.push gets.split.map(&:to_i)
end
h = Array.new(4) { 0 }
ab.each do |e|
h[e.first - 1] += 1
h[e.last - 1] += 1
end
puts h.sort == [1,1,2,2] ? 'Yes' : 'No'
| ab = []
3.times do
ab.push gets.split.map(&:to_i)
end
h = Array.new(4) { 0 }
ab.each do |e|
h[e.first - 1] += 1
h[e.last - 1] += 1
end
puts h.sort == [1,1,2,2] ? 'YES' : 'NO'
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 931,940 | 931,941 | u434509016 | ruby |
p03131 | k, a, b = gets.split.map(&:to_i)
if (b - 1) < (a + 1)
puts k + 1
else
puts b + (b - a) * (k - a - 1) / 2 + (k - a - 1) % 2
end
| k, a, b = gets.split.map(&:to_i)
if (b - 1) < (a + 1)
puts k + 1
else
puts b + (b - a) * ((k - a - 1) / 2) + (k - a - 1) % 2
end
| [
"call.arguments.change"
] | 932,684 | 932,685 | u889326464 | ruby |
p03135 | t, x = gets.chomp.split(" ").map(&:to_i)
puts t/x | t, x = gets.chomp.split(" ").map(&:to_f)
puts t/x | [
"assignment.value.change",
"call.arguments.change"
] | 934,763 | 934,764 | u760842625 | ruby |
p03135 | gets.chomp.split(" ").map(&:to_i)
puts t / x | t, x = gets.chomp.split(" ").map(&:to_f)
puts t/x | [
"assignment.value.change",
"call.arguments.change"
] | 934,765 | 934,764 | u760842625 | ruby |
p03137 | n, m = gets.split.map(&:to_i)
points = gets.split.map(&:to_i)
difs = []
if(m == 1)
p 0
else
points.sort.each_cons(2){|i, j| difs.push((i-j).abs)}
p difs.sort.slice(0, m-n).inject(:+)
end | n, m = gets.split.map(&:to_i)
points = gets.split.map(&:to_i)
difs = []
if m==1 or m<=n
p 0
else
points.sort.each_cons(2){|i, j| difs.push((i-j).abs)}
p difs.sort.slice(0, m-n).inject(:+)
end | [
"control_flow.branch.if.condition.change"
] | 937,527 | 937,528 | u712322283 | ruby |
p03138 | n,k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
x = 0
0.upto(100) do |i|
bin = 2 ** i
break if bin > k
bit_count = as.select{|a| a&bin>0 }.size
x += bin if bit_count <= as.size/2
end
puts as.map{|a| a^x }.inject(:+)
| n,k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
x = 0
40.downto(0) do |i|
bin = 2 ** i
next if x + bin > k
bit_count = as.select{|a| a&bin>0 }.size
x += bin if bit_count <= as.size/2
end
puts as.map{|a| a^x }.inject(:+)
| [
"literal.number.integer.change",
"identifier.change",
"call.arguments.change",
"control_flow.branch.if.condition.change"
] | 939,110 | 939,111 | u843036991 | ruby |
p03160 | N = gets.to_i
H = gets.split(" ").map(&:to_i)
dp = []
(10 ** 5).times{|i|
dp[i] = 10**4
}
dp[0] = 0
dp[1] = (H[0] - H[1]).abs
(2...N).each{|i|
dp[i] = dp[i] > dp[i-1] + (H[i-1] - H[i]).abs ? dp[i-1] + (H[i-1] - H[i]).abs : dp[i]
dp[i] = dp[i] > dp[i-2] + (H[i-2] - H[i]).abs ? dp[i-2] + (H[i-2] - H[i]).abs :... | N = gets.to_i
H = gets.split(" ").map(&:to_i)
dp = []
(10 ** 5).times{|i|
dp[i] = 10**9
}
dp[0] = 0
dp[1] = (H[0] - H[1]).abs
(2...N).each{|i|
dp[i] = dp[i] > dp[i-1] + (H[i-1] - H[i]).abs ? dp[i-1] + (H[i-1] - H[i]).abs : dp[i]
dp[i] = dp[i] > dp[i-2] + (H[i-2] - H[i]).abs ? dp[i-2] + (H[i-2] - H[i]).abs :... | [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 955,317 | 955,318 | u039504682 | ruby |
p03160 | N = gets.to_i
H = gets.split(" ").map(&:to_i)
dp = []
(10 ** 5).times{|i|
dp[i] = 10**4
}
dp[0] = 0
dp[1] = (H[0] - H[1]).abs
(1...N).each{|i|
dp[i] = dp[i] > dp[i-1] + (H[i-1] - H[i]).abs ? dp[i-1] + (H[i-1] - H[i]).abs : dp[i]
dp[i] = dp[i] > dp[i-2] + (H[i-2] - H[i]).abs ? dp[i-2] + (H[i-2] - H[i]).abs :... | N = gets.to_i
H = gets.split(" ").map(&:to_i)
dp = []
(10 ** 5).times{|i|
dp[i] = 10**9
}
dp[0] = 0
dp[1] = (H[0] - H[1]).abs
(2...N).each{|i|
dp[i] = dp[i] > dp[i-1] + (H[i-1] - H[i]).abs ? dp[i-1] + (H[i-1] - H[i]).abs : dp[i]
dp[i] = dp[i] > dp[i-2] + (H[i-2] - H[i]).abs ? dp[i-2] + (H[i-2] - H[i]).abs :... | [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 955,319 | 955,318 | u039504682 | ruby |
p03186 | (A, B, C) = gets.split.map(&:to_i)
cure = A + B
if cure >= C
puts cure - A + C
else
puts cure - A + C - 1
end | (A, B, C) = gets.split.map(&:to_i)
cure = A + B
if cure >= C
puts cure - A + C
else
puts cure - A + cure + 1
end | [] | 988,037 | 988,038 | u503890246 | ruby |
p03196 | def get_i() #空白区切の入力を数値(整数)の配列で返す
return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
return gets.chomp.split("")
end
def yn_judge(bool... | require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
return gets.chomp.split("")
end
d... | [
"call.add",
"call.arguments.change"
] | 990,943 | 990,944 | u415400221 | ruby |
p03206 | i = gets.to_i
s='Christmas'
(25-i).times { s.concat(" Eve") }
p s | i = gets.to_i
s='Christmas'
(25-i).times { s.concat(" Eve") }
puts s | [
"call.function.change",
"io.output.change"
] | 997,918 | 997,919 | u863697780 | ruby |
p03206 | n=gets.to_i
puts 'Christmas'+(' eve'*(25-n)) | n=gets.to_i
puts 'Christmas'+(' Eve'*(25-n)) | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 998,334 | 998,335 | u459746049 | ruby |
p03208 | n, k = gets.split.map(&:to_i)
arr = []
n.times do
arr << gets.to_i
end
arr = arr.sort
tmp = arr[k-1] - arr[0]
k.times do |i|
num = arr[i+k-1] - arr[i]
tmp = [tmp, num].min
end
p tmp
| n, k = gets.split.map(&:to_i)
arr = []
n.times do
arr << gets.to_i
end
arr = arr.sort
tmp = arr[k-1] - arr[0]
(n - k + 1).times do |i|
num = arr[i+k-1] - arr[i]
tmp = [tmp, num].min
end
p tmp | [] | 1,002,620 | 1,002,621 | u777001365 | ruby |
p03210 | x = gets.to_i
if [3, 5, 7].include?(x)
puts 'Yes'
else
puts 'No'
end
| x = gets.to_i
if [3, 5, 7].include?(x)
puts 'YES'
else
puts 'NO'
end
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,003,949 | 1,003,950 | u315984289 | ruby |
p03210 | puts [7, 5, 3].include?(gets.to_i) ? "Yes" : "No" | puts [7, 5, 3].include?(gets.to_i) ? "YES" : "NO" | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,427 | 1,004,428 | u653737129 | ruby |
p03210 | #!/usr/bin/env ruby
n = STDIN.readline.strip.to_i
puts n == 7 or n == 5 or n == 3 ? 'YES' : 'NO'
| #!/usr/bin/env ruby
n = STDIN.readline.strip.to_i
puts (n == 7 or n == 5 or n == 3) ? 'YES' : 'NO'
| [
"control_flow.branch.if.condition.change"
] | 1,005,022 | 1,005,023 | u681517464 | ruby |
p03211 | s = gets.chomp
tmp = s.split("")
ans = []
(0..s.size-3).each do |i|
ans << tmp[i..i+2].join.to_i
end
puts ans.min_by{|x|(x-753).abs} | s = gets.chomp
tmp = s.split("")
ans = []
(0..s.size-3).each do |i|
ans << tmp[i..i+2].join.to_i
end
puts (ans.min_by{|x|(x-753).abs} -753).abs | [
"call.arguments.change",
"call.add"
] | 1,005,559 | 1,005,560 | u895926909 | ruby |
p03212 | n = gets.chomp.to_i
num_len = 0
num = 1
while true
num_s = num.to_s(4)
ok_7 = false
ok_5 = false
ok_3 = false
ok = true
for i in 0..num_s.length-1
if num_s[i] == '3'
ok_7 = true
num_s[i] = '7'
elsif num_s[i] == '2'
ok_5 = true
num_s[i] = '5'
elsif num_s[i] == '1'
ok_3 = true
num_s[i] = '3... | n = gets.chomp.to_i
num_len = 0
num = 1
while true
num_s = num.to_s(4)
ok_7 = false
ok_5 = false
ok_3 = false
ok = true
for i in 0..num_s.length-1
if num_s[i] == '3'
ok_7 = true
num_s[i] = '7'
elsif num_s[i] == '2'
ok_5 = true
num_s[i] = '5'
elsif num_s[i] == '1'
ok_3 = true
num_s[i] = '3... | [
"call.remove"
] | 1,008,537 | 1,008,538 | u667739822 | ruby |
p03220 | n = gets.chomp.to_i
t, a = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
arr = []
h.each do |i|
shiki = (t * 1000- i * 6) / 1000
arr << shiki
end
arr_2 = []
arr.each do |item|
kizyun = (item - a).abs
arr_2 << kizyun
end
mezirusi = arr_2.min
arr_2.each_with_index do |item ,j|
... | n = gets.chomp.to_i
t, a = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
arr = []
h.each do |i|
shiki = t * 1000- i * 6
arr << shiki
end
arr_2 = []
arr.each do |item|
kizyun = (item - a * 1000).abs
arr_2 << kizyun
end
mezirusi = arr_2.min
arr_2.each_with_index do |item ,j|
... | [
"expression.operation.binary.remove"
] | 1,013,467 | 1,013,468 | u412789323 | ruby |
p03220 | n = gets.chomp.to_i
t,a = gets.strip.split.map(&:to_i)
hs = gets.strip.split.map(&:to_i)
ans = 0
most_near_abs = 100
hs.each.with_index(1) do |h,i|
th = (t - h*0.006)
abs = (a - th).abs
if abs < most_near_abs
ans = i
most_near_abs = abs
end
end
puts ans
| n = gets.chomp.to_i
t,a = gets.strip.split.map(&:to_i)
hs = gets.strip.split.map(&:to_i)
ans = 0
most_near_abs = 10000
hs.each.with_index(1) do |h,i|
th = (t - h*0.006)
abs = (a - th).abs
if abs < most_near_abs
ans = i
most_near_abs = abs
end
end
puts ans
| [
"literal.number.integer.change",
"assignment.value.change"
] | 1,015,738 | 1,015,739 | u191196346 | ruby |
p03231 | n,m = gets.chomp.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
l = n*m/(n.gcd(m))
i = 1
flag = true
while i*l*l/(n*m) < l
if !(s[i*l/m] == nil or s[i*l/m] == t[i*l/n])
flag = false
break
end
i += 1
end
if flag
puts(l)
else
puts("-1")
end
| n,m = gets.chomp.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
l = n*m/(n.gcd(m))
i = 0
flag = true
while i*l*l/(n*m) < l
if !(s[i*l/m] == nil or s[i*l/m] == t[i*l/n])
flag = false
break
end
i += 1
end
if flag
puts(l)
else
puts("-1")
end
| [
"literal.number.integer.change",
"assignment.value.change"
] | 1,022,764 | 1,022,766 | u706730549 | ruby |
p03238 | i = gets.to_i
if i == 1 then
puts "Hello, World"
else
a = gets.to_i
b = gets.to_i
puts a+b
end | n = gets.to_i
if n == 1
puts "Hello World"
else
a = gets.to_i
b = gets.to_i
puts a+b
end | [
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change"
] | 1,024,409 | 1,024,410 | u489697674 | ruby |
p03239 | def bb
n,t = gets.chomp.split(/\s/).map{|x| x.to_i}
im = -1
cm = 1000
tm = 1000
for i in 1..n
ci,ti = gets.chomp.split(/\s/).map{|x| x.to_i}
next if ti > t
if ci <= cm and ti <= tm
im = i
cm = ci
tm = ti
end
end
puts im =... | def bb
n,t = gets.chomp.split(/\s/).map{|x| x.to_i}
im = -1
cm = 1000
tm = 1000
for i in 1..n
ci,ti = gets.chomp.split(/\s/).map{|x| x.to_i}
next if ti > t
if ci <= cm# and ti <= tm
im = i
cm = ci
tm = ti
#p i
end
... | [
"expression.operation.binary.remove",
"identifier.change",
"call.arguments.change"
] | 1,025,775 | 1,025,776 | u510887956 | ruby |
p03242 | n = gets.split("")
m = []
n.each do |c|
if c == "1"
m << "9"
else
m << "1"
end
end
puts m.join.to_i | n = gets.chomp.split("")
m = []
n.each do |c|
if c == "1"
m << "9"
else
m << "1"
end
end
p m.join.to_i | [
"call.add",
"identifier.change"
] | 1,031,309 | 1,031,310 | u574326823 | ruby |
p03243 | n = gets.chomp.to_i
num = 111
9.times do
if n < num
puts num
exit
else
num+=111
end
end
| n = gets.chomp.to_i
num = 111
9.times do
if n <= num
puts num
exit
else
num+=111
end
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,032,391 | 1,032,392 | u728874732 | ruby |
p03244 | n = gets.to_i / 2
v = gets.split.map(&:to_i)
ans = 0
h1 = Hash.new(0)
n.times{|i| h1[v[2 * i]] += 1}
h1 = h1.sort{|a,b| -a[1] <=> -b[1]} + [[-1, 0]]
h2 = Hash.new(0)
n.times{|i| h2[v[2 * i + 1]] += 1}
h2 = h2.sort{|a,b| -a[1] <=> -b[1]} + [[-1, 0]]
if h1[0][0] == h2[0][0]
puts 2 * n - [h1[0][1] + h2[1][1], h1[1]... | n = gets.to_i / 2
v = gets.split.map(&:to_i)
h1 = Hash.new(0)
n.times{|i| h1[v[2 * i]] += 1}
h1 = h1.sort{|a,b| -a[1] <=> -b[1]} + [[-1, 0]]
h2 = Hash.new(0)
n.times{|i| h2[v[2 * i + 1]] += 1}
h2 = h2.sort{|a,b| -a[1] <=> -b[1]} + [[-1, 0]]
if h1[0][0] == h2[0][0]
puts 2 * n - [h1[0][1] + h2[1][1], h1[1][1] + h2... | [
"misc.opposites",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 1,033,564 | 1,033,565 | u692254521 | ruby |
p03241 | N,M=gets.chomp.split(" ").map { |e| e.to_i }
const = 0
val = Math.sqrt(M)
if M%N == 0
puts M/N
exit
end
a=[]
indx = 0
for i in 1..val+1 do
if M % i == 0
a[indx] = i
a[indx+1] = M/i
indx += 2
end
end
for i in a do
if M % i == 0 && N*i <= M
const = i
end
end
puts const
| N,M=gets.chomp.split(" ").map { |e| e.to_i }
const = 0
val = Math.sqrt(M)
if M%N == 0
puts M/N
exit
end
a=[]
indx = 0
for i in 1..val+1 do
if M % i == 0
a[indx] = i
a[indx+1] = M/i
indx += 2
end
end
for i in a do
if M % i == 0 && N*i <= M
const = i > const ? i : const
end
end
puts con... | [] | 1,035,079 | 1,035,080 | u267552846 | ruby |
p03250 | # frozen_stirng_literal: true
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
arr.sort
puts arr[2] * 10 + arr[1] + arr[0]
| # frozen_stirng_literal: true
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
arr.sort!
puts arr[2] * 10 + arr[1] + arr[0]
| [
"call.suffix.change"
] | 1,036,941 | 1,036,942 | u962609087 | ruby |
p03251 | N,M,X,Y = gets.split(" ").map(&:to_i)
x = gets.split(" ").map(&:to_i)
y = gets.split(" ").map(&:to_i)
puts (x.max <= y.min && X < y.min && y.min <= Y ) ? 'No War
' : 'War' | N,M,X,Y = gets.split(" ").map(&:to_i)
x = gets.split(" ").map(&:to_i)
y = gets.split(" ").map(&:to_i)
puts (x.max < y.min && X < y.min && y.min <= Y ) ? 'No War' : 'War' | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change"
] | 1,039,062 | 1,039,063 | u915238879 | ruby |
p03254 | n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!
ans = 0
i = 0
tmp = a[0].to_i
while tmp <= x && i < n do
if i == n-1
if tmp[ans] == x
ans += 1
end
else
x -= tmp
ans += 1
tmp = a[ans].to_i
end
i +=1
end
puts ans
| n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!
ans = 0
i = 0
tmp = a[0].to_i
while tmp <= x && i < n do
if i == n-1
if a[i] == x
ans += 1
end
else
x -= tmp
ans += 1
tmp = a[i+1].to_i
end
i +=1
end
puts ans
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"variable_access.subscript.index.change",
"assignment.value.change"
] | 1,043,232 | 1,043,233 | u707879795 | ruby |
p03260 | a , b = gets.strip.split(' ').map(&:to_i);
ans0 = a * b;
ans1 = a * b * 2;
ans2 = a * b * 3;
if ans0 % 2 == 1 || ans1 % 2 == 1 || ans2 % 2 == 1
puts "YES"
else
puts "NO"
end
| a , b = gets.strip.split(' ').map(&:to_i);
ans0 = a * b;
ans1 = a * b * 2;
ans2 = a * b * 3;
if ans0 % 2 == 1 || ans1 % 2 == 1 || ans2 % 2 == 1
puts "Yes"
else
puts "No"
end
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,045,373 | 1,045,374 | u348306621 | ruby |
p03260 | a,b= gets.chomp.split(" ").map(&:to_i )
if a×b % 2 == 1
puts ("Yes")
else
puts ("No")
end | a,b= gets.chomp.split(" ").map(&:to_i )
if a*b % 2 == 1
puts ("Yes")
else
puts ("No")
end
| [
"control_flow.branch.if.condition.change"
] | 1,045,920 | 1,045,921 | u966695319 | ruby |
p03261 | n = gets.to_i
array = []
answer = "Yes"
(1..n).each do
array.push(gets.chomp.split(""))
end
if array.length == array.uniq.length
(0..n-1).each do |number|
if array[number].last != array[number+1].first
break
end
end
else
answer = "No"
end
puts answer | n = gets.to_i
array = []
answer = "Yes"
(1..n).each do
array.push(gets.chomp.split(""))
end
if array.length == array.uniq.length
(0..n-2).each do |number|
if array[number].last != array[number+1].first
answer = "No"
break
end
end
else
answer = "No"
end
puts answer | [
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,046,319 | 1,046,320 | u333374716 | ruby |
p03261 | n = gets.to_i
array = []
answer = "Yes"
(1..n).each do
array.push(gets.chomp.split(""))
end
if array.length == array.uniq.length
(0..n-2).each do |number|
if array[number].last != array[number+1].first
break
end
end
else
answer = "No"
end
puts answer | n = gets.to_i
array = []
answer = "Yes"
(1..n).each do
array.push(gets.chomp.split(""))
end
if array.length == array.uniq.length
(0..n-2).each do |number|
if array[number].last != array[number+1].first
answer = "No"
break
end
end
else
answer = "No"
end
puts answer | [
"assignment.add"
] | 1,046,321 | 1,046,320 | u333374716 | ruby |
p03261 | n = gets.to_i
w = n.times.map{ gets.chomp.to_s }
ans = 'Yes'
(1...n).each do |i|
break if w[i][0] != w[i-1][-1]
ans = 'No'
end
if ans == 'Yes'
if w.uniq.count == n
puts ans
else
ans = 'No'
puts ans
end
else
puts ans
end | n = gets.to_i
w = n.times.map{ gets.chomp.to_s }
ans = 'Yes'
(1...n).each do |i|
if w[i][0] != w[i-1][-1]
ans = 'No'
break
end
end
if ans == 'Yes'
if w.uniq.count == n
puts ans
else
ans = 'No'
puts ans
end
else
puts ans
end | [
"control_flow.break.remove",
"control_flow.break.add"
] | 1,046,581 | 1,046,582 | u915238879 | ruby |
p03262 | _,*a=`dd`.split.map &:to_i;p a.sort.each_cons(2).map{|x,y|y-x}.reduce :lcm | _,*a=`dd`.split.map &:to_i;p a.sort.each_cons(2).map{|x,y|y-x}.reduce :gcd | [
"call.arguments.change"
] | 1,049,039 | 1,049,040 | u280667879 | ruby |
p03262 | _,*a=`dd`.split.map &:to_i;p a.sort.each_cons(2).map{|x,y|y-x}.reduce :lcd | _,*a=`dd`.split.map &:to_i;p a.sort.each_cons(2).map{|x,y|y-x}.reduce :gcd | [
"call.arguments.change"
] | 1,049,041 | 1,049,040 | u280667879 | ruby |
p03262 | _,*a=`dd`.split.map &:to_i;p a.each_cons(2).map{|x,y|y-x}.reduce :lcd | _,*a=`dd`.split.map &:to_i;p a.sort.each_cons(2).map{|x,y|y-x}.reduce :gcd | [
"call.add",
"call.arguments.change"
] | 1,049,042 | 1,049,040 | u280667879 | ruby |
p03266 | N, K = gets.chomp.split.map(&:to_i)
res = 0
num = Array.new(N,0)
1.upto(N) do |i|
num[i%K] += 1
end
K.times do |i|
a = i % K
b = (K - a) % K
c = (K - a) % K
next unless (b + c) % K == 0
res += num[a] * num[b] * num[c]
end
p res
| N, K = gets.chomp.split.map(&:to_i)
res = 0
num = Array.new([N, K].max,0)
1.upto(N) do |i|
num[i%K] += 1
end
K.times do |i|
a = i % K
b = (K - a) % K
c = (K - a) % K
next unless (b + c) % K == 0
res += num[a] * num[b] * num[c]
end
p res
| [
"call.arguments.change",
"call.add"
] | 1,052,496 | 1,052,497 | u157887852 | ruby |
p03272 | n,i = gets.chomp.split.map(&:to_i)
puts N-i+1
| n,i = gets.chomp.split.map(&:to_i)
puts n-i+1
| [
"call.arguments.change",
"expression.operation.binary.change"
] | 1,056,461 | 1,056,462 | u706730549 | ruby |
p03282 | s=gets.chomp.split("").map { |e| e.to_i }
k=gets.chomp.to_i
leng = s.length
ans = 0
leng.times do |i|
if s[i] == 1 && k>0
ans = 1
k -= 1
end
if s[i] != 1 && k < 0
puts s[i]
exit
end
end
puts 1 | s=gets.chomp.split("").map { |e| e.to_i }
k=gets.chomp.to_i
leng = s.length
ans = 0
leng.times do |i|
if s[i] == 1 && k>0
ans = 1
k -= 1
end
if s[i] != 1 && k > 0
puts s[i]
exit
end
end
puts 1
| [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,066,604 | 1,066,605 | u267552846 | ruby |
p03282 | s = gets.chop
k = gets.chop.to_i
selected = s.index(/[^1]/) == nil ? "1" : s[[k, s.index(/[^1]/)].min]
puts selected | s = gets.chop
k = gets.chop.to_i
selected = s.index(/[^1]/).nil? ? "1" : s[[k - 1, s.index(/[^1]/)].min]
puts selected | [
"assignment.change"
] | 1,066,956 | 1,066,957 | u696840169 | ruby |
p03282 | s = gets.chop
k = gets.chop.to_i
selected = s.index(/[^1]/).nil ? "1" : s[[k, s.index(/[^1]/)].min]
puts selected | s = gets.chop
k = gets.chop.to_i
selected = s.index(/[^1]/).nil? ? "1" : s[[k - 1, s.index(/[^1]/)].min]
puts selected | [
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,066,959 | 1,066,957 | u696840169 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.