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 9
values |
|---|---|---|---|---|---|---|---|
p02789 | n, m = gets.to_i
if n==m
puts "Yes"
else
puts "No"
end | n, m = gets.split.map(&:to_i)
if n == m
puts "Yes"
else
puts "No"
end | [
"assignment.value.change",
"identifier.change",
"call.add"
] | 594,948 | 594,949 | u105001881 | ruby |
p02789 | def get_nums
gets.split.map(&:to_i)
end
def init_matrix(row_num, row_length, default = nil)
Array.new(row_num).map { Array.new(row_length, default) }
end
n, m = get_nums
if n == m
puts "AC"
else
puts "No"
end | def get_nums
gets.split.map(&:to_i)
end
def init_matrix(row_num, row_length, default = nil)
Array.new(row_num).map { Array.new(row_length, default) }
end
n, m = get_nums
if n == m
puts "Yes"
else
puts "No"
end | [
"literal.string.change",
"call.arguments.change"
] | 595,065 | 595,066 | u624505752 | ruby |
p02790 | a,b = gets.chomp.split(' ').map(&:to_i)
answer << (a.to_s)*b
answer << (b.to_s)*a
puts answer.sort.first | a,b = gets.chomp.split(' ').map(&:to_i)
answer = []
answer << (a.to_s)*b
answer << (b.to_s)*a
puts answer.sort.first
| [
"assignment.add"
] | 595,292 | 595,293 | u844000954 | ruby |
p02790 | a,b = gets.split(' ').map(&:to_i)
aa = []
ba = []
a.times do |ai|
ba << b
end
b.times do |bi|
aa << a
end
if a < b
puts aa.join
elsif a > b
puts ab.join
else
puts aa.join
end
| a,b = gets.split(' ').map(&:to_i)
aa = []
ba = []
a.times do |ai|
ba << b
end
b.times do |bi|
aa << a
end
if a < b
puts aa.join
elsif a > b
puts ba.join
else
puts aa.join
end | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 595,644 | 595,645 | u802039083 | ruby |
p02790 | a,b = gets.split(' ').map(&:to_i)
aa = []
ba = []
a.times do |ai|
ba << b
end
b.times do |bi|
aa << a
end
if a > b
puts aa.join
elsif a < b
puts ab.join
else
puts aa.join
end
| a,b = gets.split(' ').map(&:to_i)
aa = []
ba = []
a.times do |ai|
ba << b
end
b.times do |bi|
aa << a
end
if a < b
puts aa.join
elsif a > b
puts ba.join
else
puts aa.join
end | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 595,646 | 595,645 | u802039083 | ruby |
p02790 | a,b = gets.chomp.split.map(&:to_i)
x = a.to_s * b
y = b.to_s * a
puts [x,y].max | a,b = gets.chomp.split.map(&:to_i)
x = a.to_s * b
y = b.to_s * a
puts [x,y].min
| [
"misc.opposites",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 595,726 | 595,727 | u557668939 | ruby |
p02790 | # 入力(数字として使うやつ)
a,b = gets.chomp.split.map(&:to_i)
# 文字を作る
c = a.to_s * b
d = b.to_s * a
# 普通の時のこたえ
s = [c,d]
n = s.sort
#もじが同じだった時の処理
if a == b
puts c
else
n.min
end | # 入力(数字として使うやつ)
a,b = gets.chomp.split.map(&:to_i)
# 文字を作る
c = a.to_s * b
d = b.to_s * a
# 普通の時のこたえ
s = [c,d]
n = s.sort
#もじが同じだった時の処理
if a != b
puts n.min
else
puts c
end | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"call.arguments.change",
"call.add"
] | 595,770 | 595,771 | u689027433 | ruby |
p02790 | min, max = gets.split.map(&:to_i).sort
min.to_s * max | min, max = gets.split.map(&:to_i).sort
puts min.to_s * max | [
"io.output.change",
"call.add"
] | 595,941 | 595,942 | u298187292 | ruby |
p02790 | input = gets.chomp.split(" ")
if input[0] < input[1]
puts input[0].to_s * input[1]
elsif input[0] > input[1]
puts input[1].to_s * input[0].to_i
else
puts input[0].to_s * input[1].to_i
end
| input = gets.chomp.split(" ")
if input[0] < input[1]
puts input[0].to_s * input[1].to_i
elsif input[0] > input[1]
puts input[1].to_s * input[0].to_i
else
puts input[0].to_s * input[1].to_i
end
| [
"call.add"
] | 595,949 | 595,950 | u670430370 | ruby |
p02790 | a,b = gets.chomp.split(" ").map(&:to_i)
answer = ""
if a != b then
if a < b then
for i in 1..a do
answer += b.to_s
end
else
for i in 1..b do
answer += a.to_s
end
end
else
for i in 1..a do
answer += a.to_s
end
end
print answer | a,b = gets.chomp.split(" ").map(&:to_i)
answer = ""
if a != b then
if a < b then
for i in 1..b do
answer += a.to_s
end
else
for i in 1..a do
answer += b.to_s
end
end
else
for i in 1..a do
answer += a.to_s
end
end
print answer | [] | 596,274 | 596,275 | u096860578 | ruby |
p02790 | a , b = gets.split(' ').map!(&:to_i)
if a >= b
puts b.to_s * a
else
a.to_s * b
end
| a , b = gets.split(' ').map!(&:to_i)
if a >= b
puts b.to_s * a
else
puts a.to_s * b
end
| [
"io.output.change",
"call.add"
] | 596,426 | 596,427 | u315984289 | ruby |
p02791 | N = gets.to_i
P = gets.chomp.split(" ").map(&:to_i)
count = 0
min = P[1]
P.each_with_index do |x, i|
if i == 0
count += 1
elsif min >= x
min = x
count += 1
end
end
puts "#{count}"
| N = gets.to_i
P = gets.chomp.split(" ").map(&:to_i)
count = 0
min = P[0]
P.each_with_index do |x, i|
if i == 0
count += 1
elsif min >= x
min = x
count += 1
end
end
puts "#{count}"
| [
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 597,398 | 597,399 | u729911058 | ruby |
p02791 | gets
a = gets.split.map(&:to_i)
x = 0
min = 0
a.each do |n|
if n <= min
x += 1
min = n
end
end
puts x | gets
a = gets.split.map(&:to_i)
x = 0
min = a[0]
a.each do |n|
if n <= min
x += 1
min = n
end
end
puts x | [] | 597,425 | 597,426 | u557668939 | ruby |
p02791 | N = STDIN.gets.chomp.to_i
P = STDIN.gets.split(' ').map{|s| s.to_i}
ans = 0
min = []
N.times do |i|
if i == 0
min[i] = P[0]
else
min[i] = [P[i-1], P[i]].min
end
if P[i] <= min[i]
ans += 1
end
end
puts ans
| N = STDIN.gets.chomp.to_i
P = STDIN.gets.split(' ').map{|s| s.to_i}
ans = 0
min = []
N.times do |i|
if i == 0
min[i] = P[0]
else
min[i] = [min[i-1], P[i]].min
end
if P[i] <= min[i]
ans += 1
end
end
puts ans
| [
"assignment.value.change"
] | 597,429 | 597,430 | u902774407 | ruby |
p02791 | gets.to_i
b = gets.split.map(&:to_i)
c = 2000000
ans = 0
for num in 0..a-1 do
if b[num] < c
c = b[num]
ans += 1
end
end
p ans | a = gets.to_i
b = gets.split.map(&:to_i)
c = 20000000
ans = 0
for num in 0..a-1 do
if b[num] < c
c = b[num]
ans += 1
end
end
p ans | [
"literal.number.integer.change",
"assignment.value.change"
] | 597,796 | 597,797 | u945412921 | ruby |
p02791 | lines = readlines.map{|line| line.split(' ').map(&:to_i)}
a=0
b=lines[0][0]-1
for i in 0..lines[0][0]-1
f=0
b = b < lines[1][i] ? b : lines[1][i]
if b>=lines[1][i] then
a=a+1
end
end
puts a | lines = readlines.map{|line| line.split(' ').map(&:to_i)}
a=0
b=lines[0][0]
for i in 0..lines[0][0]-1
f=0
b = b <= lines[1][i] ? b : lines[1][i]
if b>=lines[1][i] then
a=a+1
end
end
puts a | [
"expression.operation.binary.remove",
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 597,850 | 597,851 | u413184068 | ruby |
p02791 | n = gets.chomp.to_i
inputs = gets.split.map(&:to_i)
reject = 0
temp = 200000
(0...n).each do |i|
_temp_1 = inputs[i]
if temp <= _temp_1
reject += 1
end
temp = _temp_1
end
puts n - reject | n = gets.chomp.to_i
inputs = gets.split.map(&:to_i)
reject = 0
temp = 200000
(0...n).each do |i|
_temp_1 = inputs[i]
if temp < _temp_1
reject += 1
else
temp = _temp_1
end
end
puts n - reject | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 597,986 | 597,987 | u542197477 | ruby |
p02791 | n = gets.chomp.to_i
inputs = gets.split.map(&:to_i)
reject = 0
temp = 200000
(0...n).each do |i|
_temp_1 = inputs[i]
if temp < _temp_1
reject += 1
end
temp = _temp_1
end
puts n - reject | n = gets.chomp.to_i
inputs = gets.split.map(&:to_i)
reject = 0
temp = 200000
(0...n).each do |i|
_temp_1 = inputs[i]
if temp < _temp_1
reject += 1
else
temp = _temp_1
end
end
puts n - reject | [] | 597,988 | 597,987 | u542197477 | ruby |
p02791 | n = gets.chomp.to_i
inputs = gets.split.map(&:to_i)
reject = 0
temp = 1000000
(0...n).each do |i|
_temp_1 = inputs[i]
if temp < _temp_1
reject += 1
end
temp = _temp_1
end
puts n - reject | n = gets.chomp.to_i
inputs = gets.split.map(&:to_i)
reject = 0
temp = 200000
(0...n).each do |i|
_temp_1 = inputs[i]
if temp < _temp_1
reject += 1
else
temp = _temp_1
end
end
puts n - reject | [
"literal.number.integer.change",
"assignment.value.change"
] | 597,989 | 597,987 | u542197477 | ruby |
p02791 | N=gets.to_i
a=gets.split.map(&:to_i)
res=0
cnt=Float::infinity
N.times do |i|
if cnt>a[i]
res+=1
cnt=a[i]
end
end
puts res
| N=gets.to_i
a=gets.split.map(&:to_i)
res=0
cnt=Float::INFINITY
N.times do |i|
if cnt>a[i]
res+=1
cnt=a[i]
end
end
puts res
| [
"assignment.value.change"
] | 598,349 | 598,350 | u926099741 | ruby |
p02791 | N = gets.to_i
nums = gets.split.map(&:to_i)
min = Float::INFINITY
ans = 0
nums.each_with_index do |ai, i|
if ai < m
m = ai
ans += 1
end
end
p ans | N = gets.to_i
nums = gets.split.map(&:to_i)
min = Float::INFINITY
ans = 0
nums.each_with_index do |ai|
if ai < min
min = ai
ans += 1
end
end
p ans | [] | 598,378 | 598,379 | u645787471 | ruby |
p02791 | N = gets.to_i
nums = gets.split.map(&:to_i)
min = Float::INFINITY
ans = 0
nums.each_with_index do |i|
if i < m
m = i
ans += 1
end
end
p ans | N = gets.to_i
nums = gets.split.map(&:to_i)
min = Float::INFINITY
ans = 0
nums.each_with_index do |ai|
if ai < min
min = ai
ans += 1
end
end
p ans | [
"identifier.change",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 598,380 | 598,379 | u645787471 | ruby |
p02791 | N = gets.to_i
nums = gets.split.map(&:to_i)
min = Float::INFINITY
ans = 0
nums.each_with_index do |i|
if i < m
m = ai
ans += 1
end
end
p ans | N = gets.to_i
nums = gets.split.map(&:to_i)
min = Float::INFINITY
ans = 0
nums.each_with_index do |ai|
if ai < min
min = ai
ans += 1
end
end
p ans | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 598,381 | 598,379 | u645787471 | ruby |
p02792 | #とても回りくどいやり方をしていたので他の人のを見て直す
n = gets.to_i
data = Array.new(10){Array.new(10, 0)}
n.times do |i|
a = i.to_s
af = a[0].to_i
al = a[-1].to_i
data[af][al] += 1
end
sum = 0
1.upto(9) do |i|
1.upto(9) do |j|
sum += data[i][j] * data[j][i]
end
end
p sum | #とても回りくどいやり方をしていたので他の人のを見て直す
n = gets.to_i
data = Array.new(10){Array.new(10, 0)}
(n+1).times do |i|
a = i.to_s
af = a[0].to_i
al = a[-1].to_i
data[af][al] += 1
end
sum = 0
1.upto(9) do |i|
1.upto(9) do |j|
sum += data[i][j] * data[j][i]
end
end
p sum | [] | 598,908 | 598,909 | u799910874 | ruby |
p02792 | require 'pp'
def get_nums
gets.split.map(&:to_i)
end
def init_matrix(row_num, row_length, default = nil)
Array.new(row_num).map { Array.new(row_length, default) }
end
top_and_bottoms = Array.new(10).map {Array.new(10, 0)}
inp = gets.chomp
n = inp.to_i
digits = inp.size
res = 0
1.upto(n) do |i|
i_s = i.to_s
top_digit = i_s[0].to_i
end_digit = i_s[-1].to_i
top_and_bottoms[top_digit][end_digit] += 1
# top_and_bottoms[end_digit][top_digit] += 1
end
res = 0
0.upto(9) do |i|
i_eq_j = false
0.upto(9) do |j|
next if i_eq_j && i == j
# puts "Ok" if i == j && i == 1
i_eq_j = true if i == j
# p [i, j, top_and_bottoms[i], top_and_bottoms[i][j], top_ and_bottoms[j][i]]
# p [i, j] if top_and_bottoms[i][j] * top_and_bottoms[j][i] != 0
res += top_and_bottoms[i][j] * top_and_bottoms[j][i]
end
end
pp top_and_bottoms
puts res | require 'pp'
def get_nums
gets.split.map(&:to_i)
end
def init_matrix(row_num, row_length, default = nil)
Array.new(row_num).map { Array.new(row_length, default) }
end
top_and_bottoms = Array.new(10).map {Array.new(10, 0)}
inp = gets.chomp
n = inp.to_i
digits = inp.size
res = 0
1.upto(n) do |i|
i_s = i.to_s
top_digit = i_s[0].to_i
end_digit = i_s[-1].to_i
top_and_bottoms[top_digit][end_digit] += 1
# top_and_bottoms[end_digit][top_digit] += 1
end
res = 0
0.upto(9) do |i|
i_eq_j = false
0.upto(9) do |j|
next if i_eq_j && i == j
# puts "Ok" if i == j && i == 1
i_eq_j = true if i == j
# p [i, j, top_and_bottoms[i], top_and_bottoms[i][j], top_ and_bottoms[j][i]]
# p [i, j] if top_and_bottoms[i][j] * top_and_bottoms[j][i] != 0
res += top_and_bottoms[i][j] * top_and_bottoms[j][i]
end
end
# pp top_and_bottoms
puts res | [
"call.remove"
] | 598,937 | 598,938 | u624505752 | ruby |
p02792 | # after listening explanation
n = gets.to_i
c = Array.new
n.times{ c << Array.new(10, 0) }
def h(k)
((k+1).to_s)[0].to_i
end
def t(k)
(k+1)%10
end
n.times{|k|
c[h(k)][t(k)] += 1
}
ans = 0
n.times{|k|
ans += c[t(k)][h(k)]
}
p ans
| # after listening explanation
n = gets.to_i
c = Array.new
10.times{ c << Array.new(10, 0) }
def h(k)
((k+1).to_s)[0].to_i
end
def t(k)
(k+1)%10
end
n.times{|k|
c[h(k)][t(k)] += 1
}
ans = 0
n.times{|k|
ans += c[t(k)][h(k)]
}
p ans
| [
"identifier.replace.remove",
"literal.replace.add"
] | 598,947 | 598,948 | u679291177 | ruby |
p02793 | n = gets.to_i
a = gets.split.map(&:to_i)
l = a.inject{|r,v| r.lcm(v)}
sum = 0
a.each do |v|
sum += x / v
end
puts sum % (10 ** 9 + 7) | n = gets.to_i
a = gets.split.map(&:to_i)
l = a.inject{|r,v| r.lcm(v)}
sum = 0
a.each do |v|
sum += l / v
end
puts sum % (10 ** 9 + 7) | [
"identifier.change",
"expression.operation.binary.change"
] | 599,431 | 599,432 | u692254521 | ruby |
p02793 | #!/usr/bin/ruby
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
lcm = 1
A.each{|n|
lcm = n.lcm(lcm)
}
puts lcm
total = 0
A.each{|n|
b = lcm/n
total += b
}
puts total % (10**9 + 7)
| #!/usr/bin/ruby
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
lcm = 1
A.each{|n|
lcm = n.lcm(lcm)
}
#puts lcm
total = 0
A.each{|n|
b = lcm/n
total += b
}
puts total % (10**9 + 7)
| [
"call.remove"
] | 599,541 | 599,542 | u014854522 | ruby |
p02793 | N=gets.to_i
A=gets.split(' ').map(&:to_i)
L=A.inject(:lcm)
ans=A.map{|e|lcm/e}.inject(:+)
ans%=10**9+7
puts ans | N=gets.to_i
A=gets.split(' ').map(&:to_i)
L=A.inject(:lcm)
ans=A.map{|e|L/e}.inject(:+)
ans%=10**9+7
puts ans | [
"assignment.value.change",
"expression.operation.binary.change"
] | 599,666 | 599,667 | u041282550 | ruby |
p02793 | N=gets.to_i
A=gets.split.map(&:to_i)
L=A.inject(:lcm)
ans=A.map{|e|lcm/e}.inject(:+)
ans%=10**9+7
puts ans | N=gets.to_i
A=gets.split(' ').map(&:to_i)
L=A.inject(:lcm)
ans=A.map{|e|L/e}.inject(:+)
ans%=10**9+7
puts ans | [
"call.arguments.add",
"assignment.value.change",
"expression.operation.binary.change"
] | 599,668 | 599,667 | u041282550 | ruby |
p02795 | h, w, n = readlines.map(&:to_i)
puts (n / [h, w].max).ceil | h, w, n = readlines.map(&:to_i)
puts (n / [h, w].max.to_f).ceil | [
"call.add"
] | 600,230 | 600,231 | u297507288 | ruby |
p02793 | 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
require "prime"
N,*A = `dd`.split.map &:to_i
Mod = 10**9 + 7
qs = {}
PD = A.map{ |a|
pd = a.prime_division
pd.each{ |q,d| qs[q] = [qs[q] || 0, d].max }
pd
}
LCM = qs.map{ |q,d| powmod(q,d,Mod) }.reduce{ |a,b| a * b % Mod }
p PD.reduce(0){ |a,pd|
divisor = pd.map{ |q,d| powmod(q,d,Mod) }.reduce{ |a,b| a * b % Mod }
(a + (LCM * invmod(divisor,Mod))) % Mod
} | 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
require "prime"
N,*A = `dd`.split.map &:to_i
Mod = 10**9 + 7
qs = {}
PD = A.map{ |a|
pd = a.prime_division
pd.each{ |q,d| qs[q] = [qs[q] || 0, d].max }
pd
}
LCM = qs.map{ |q,d| powmod(q,d,Mod) }.reduce(1){ |a,b| a * b % Mod }
p PD.reduce(0){ |a,pd|
divisor = pd.map{ |q,d| powmod(q,d,Mod) }.reduce(1){ |a,b| a * b % Mod }
(a + (LCM * invmod(divisor,Mod))) % Mod
} | [
"call.arguments.add"
] | 600,446 | 600,447 | u670503797 | ruby |
p02793 | MOD = 10 ** 9 + 7
n = gets.to_i
nums = gets.split.map(&:to_i)
lcm = nums.inject(&:lcm)
puts nums.inject { |res, num| res + lcm / num } % MOD
| MOD = 10 ** 9 + 7
n = gets.to_i
nums = gets.split.map(&:to_i)
lcm = nums.inject(&:lcm)
puts nums.inject(0) { |res, num| res + lcm / num } % MOD
| [
"call.arguments.add"
] | 600,464 | 600,465 | u653737129 | ruby |
p02795 | h = gets.chomp.to_i
w = gets.chomp.to_i
n = gets.chomp.to_i
hw = h < w ? w : h
puts (n / hw).ceil
| h = gets.chomp.to_i
w = gets.chomp.to_i
n = gets.chomp.to_i
hw = h < w ? w : h
puts (1.0 * n / hw).ceil
| [
"expression.operation.binary.add"
] | 600,611 | 600,612 | u208362438 | ruby |
p02796 | n = gets.to_i
robot = []
n.times {robot << gets.split.map(&:to_i)}
robot.sort_by!{|x, l| x}
pre = robot[0][0] - robot[0][1]
ans = 0
robot.each do |x, l|
if pre <= x - l
ans += 1
pre = x + l
end
end
puts ans | n = gets.to_i
robot = []
n.times {robot << gets.split.map(&:to_i)}
robot.sort_by!{|x, l| x + l}
pre = robot[0][0] - robot[0][1]
ans = 0
robot.each do |x, l|
if pre <= x - l
ans += 1
pre = x + l
end
end
puts ans | [
"expression.operation.binary.add"
] | 601,212 | 601,213 | u692254521 | ruby |
p02796 | n,m=gets.split(" ").map(&:to_i)
pairs = []
while line=gets
break if line.chomp.empty?
pairs<<line.split(" ").map(&:to_i)
end
robots = []
input.each do |pos, len|
robots << [pos - len, pos + len]
end
ok = []
right = nil
robots.sort {|a,b| a[1] <=> b[1] }.each do |start, fin|
right = start unless right
if right <= start
ok << [start, fin]
right = fin
end
end
p ok.length | n,m=gets.split(" ").map(&:to_i)
input = []
while line=gets
break if line.chomp.empty?
input<<line.split(" ").map(&:to_i)
end
robots = []
input.each do |pos, len|
robots << [pos - len, pos + len]
end
ok = []
right = nil
robots.sort {|a,b| a[1] <=> b[1] }.each do |start, fin|
right = start unless right
if right <= start
ok << [start, fin]
right = fin
end
end
p ok.length | [
"assignment.variable.change",
"identifier.change"
] | 601,231 | 601,232 | u977982581 | ruby |
p02796 | BINF = -(10**12)
N = gets.to_i
robots = []
N.times do
s, t = gets.split.map(&:to_i)
robots << [s + t, s - t]
end
robots.sort_by!
# p robots
t = BINF
count = 0
# binding.pry
robots.each do |robo|
if t > robo[1]
count += 1
next
end
t = robo[0]
end
puts N - count | # require 'pry'
BINF = -(10**12)
N = gets.to_i
robots = []
N.times do
s, t = gets.split.map(&:to_i)
robots << [s + t, s - t]
end
robots.sort_by!{|x|x}
# p robots
t = BINF
count = 0
# binding.pry
robots.each do |robo|
if t > robo[1]
count += 1
next
end
t = robo[0]
end
puts N - count
| [] | 601,296 | 601,297 | u875730451 | ruby |
p02796 | gets
t=-10e9
p $<.map{|s|
x,l=s.split.map &:to_i
[x-l,x+l]
}.sort_by!{|l,r|l}.inject(0){|c,(l,r)|
next c if t>l
t=r
c+=1
} | gets
t=-10e9
p $<.map{|s|
x,l=s.split.map &:to_i
[x-l,x+l]
}.sort_by!{|l,r|r}.inject(0){|c,(l,r)|
next c if t>l
t=r
c+=1
} | [
"identifier.change",
"call.arguments.change"
] | 601,796 | 601,797 | u933935509 | ruby |
p02796 | n = gets.chomp.to_i
robs = Array.new
for i in 0..n-1 do
x, l = gets.chomp.split(" ").map(&:to_i)
robs[i] = [x - l + 1, x + l - 1]
end
robs = robs.sort_by {|a| a[1]}
# p robs
ans = 0
e = -1000000001
for i in 0..n-1 do
if e < robs[i][0]
e = robs[i][1]
ans += 1
end
end
puts ans | # WA
n = gets.chomp.to_i
robs = Array.new
for i in 0..n-1 do
x, l = gets.chomp.split(" ").map(&:to_i)
robs[i] = [x - l, x + l]
end
robs = robs.sort_by {|a| a[1]}
# p robs
ans = 0
e = -1000000001
for i in 0..n-1 do
if e <= robs[i][0]
e = robs[i][1]
ans += 1
end
end
puts ans | [
"expression.operation.binary.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 601,961 | 601,962 | u502813058 | ruby |
p02796 | n = gets.to_i
x, l = n.times.map{gets.split.map(&:to_i)}.transpose
count = 1
arm = n.times.map{|i| [x[i]-l[i]+1, x[i]+l[i]-1]}.sort
(n-1).times do |i|
if arm[i][1] < arm[i+1][0]
count+= 1
elsif arm[i][1] < arm[i+1][1]
arm[i+1][1] = arm[i][1]
end
end
puts count | n = gets.to_i
x, l = n.times.map{gets.split.map(&:to_i)}.transpose
count = 1
arm = n.times.map{|i| [x[i]-l[i], x[i]+l[i]]}.sort
(n-1).times do |i|
if arm[i][1] <= arm[i+1][0]
count+= 1
elsif arm[i][1] < arm[i+1][1]
arm[i+1][1] = arm[i][1]
end
end
puts count | [
"expression.operation.binary.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 602,002 | 602,003 | u960706641 | ruby |
p02793 | n = gets.to_i
a = gets.split.map(&:to_i)
mod = 10**9 + 7
l = 1
a.each do |ai|
l = l.lcm(ai)
end
ans = 0
a.each do |ai|
ans += l / ai % mod
#ans %= mod
end
p ans
| n = gets.to_i
a = gets.split.map(&:to_i)
mod = 10**9 + 7
l = 1
a.each do |ai|
l = l.lcm(ai)
end
ans = 0
a.each do |ai|
ans += l / ai
end
p ans % mod
| [
"expression.operation.binary.remove"
] | 603,149 | 603,150 | u706695185 | ruby |
p02793 | _ = gets
a_n = gets.split.map(&:to_i)
l = a_n.inject {|lcm, a| lcm.lcm(a) }
ans = a_n.inject(0) {|ans, l| ans = (ans + (l / a)) }
puts ans % 1_000_000_007 | _ = gets
a_n = gets.split.map(&:to_i)
l = a_n.inject {|lcm, a| lcm.lcm(a) }
ans = a_n.inject(0) {|ans, a| ans = (ans + (l / a)) }
puts ans % 1_000_000_007 | [
"assignment.value.change",
"identifier.change"
] | 603,176 | 603,177 | u754375546 | ruby |
p02793 | def gcd(a, b)
a,b = b, a % b while b > 0
a
end
# 最小公倍数
def lcm(a,b)
a * b / gcd(a,b)
end
n = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
MOD = 10**9+7
ans = 0
tmp = 0
n.times do |i|
if i == 0
tmp = A[i]
else
tmp = lcm(tmp, A[i])
end
end
tmp = tmp % MOD
n.times do |i|
ans += tmp/A[i]
end
p ans % MOD
| def gcd(a, b)
a,b = b, a % b while b > 0
a
end
# 最小公倍数
def lcm(a,b)
a * b / gcd(a,b)
end
n = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
MOD = 10**9+7
ans = 0
tmp = 0
n.times do |i|
if i == 0
tmp = A[i]
else
tmp = lcm(tmp, A[i])
end
end
n.times do |i|
ans += tmp/A[i]
end
p ans % MOD
| [
"assignment.remove"
] | 603,201 | 603,202 | u157887852 | ruby |
p02796 | require 'pp'
n = gets.to_i
xl = []
n.times do
xl << gets.split.map(&:to_i) # x, l
end
xl.sort_by!{|z|z[0] - z[1]}
line = xl[0][0] + xl[0][1]
# p xl
cnt = 0
i = 1
while i < n
break if xl[i].nil?
if line > (xl[i][0] - xl[i][1])
cnt += 1
i += 1
next
end
line = xl[i][0] + xl[i][1]
i += 1
end
p n - cnt
# 3 1 5
| require 'pp'
n = gets.to_i
xl = []
n.times do
xl << gets.split.map(&:to_i) # x, l
end
xl.sort_by!{|z|z[0] + z[1]}
line = xl[0][0] + xl[0][1]
# p xl
cnt = 0
i = 1
while i < n
break if xl[i].nil?
if line > (xl[i][0] - xl[i][1])
cnt += 1
i += 1
next
end
line = xl[i][0] + xl[i][1]
i += 1
end
p n - cnt
# 3 1 5
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 603,281 | 603,282 | u315597999 | ruby |
p02796 | require 'pp'
n = gets.to_i
xl = []
n.times do
xl << gets.split.map(&:to_i) # x, l
end
xl.sort_by!{|z|z[0]}
line = xl[0][0] + xl[0][1]
# p xl
cnt = 0
i = 1
while i < n
break if xl[i].nil?
if line > (xl[i][0] - xl[i][1])
cnt += 1
i += 1
next
end
line = xl[i][0] + xl[i][1]
i += 1
end
p n - cnt
# 3 1 5
| require 'pp'
n = gets.to_i
xl = []
n.times do
xl << gets.split.map(&:to_i) # x, l
end
xl.sort_by!{|z|z[0] + z[1]}
line = xl[0][0] + xl[0][1]
# p xl
cnt = 0
i = 1
while i < n
break if xl[i].nil?
if line > (xl[i][0] - xl[i][1])
cnt += 1
i += 1
next
end
line = xl[i][0] + xl[i][1]
i += 1
end
p n - cnt
# 3 1 5
| [
"expression.operation.binary.add"
] | 603,283 | 603,282 | u315597999 | ruby |
p02801 | c = gets.chomp
alf = []
("a".."z").each do |i|
alf << i
end
alf.each do |k, i|
if k == c
puts alf[i+1]
break
end
end | c = gets.chomp
alf = []
("a".."z").each do |i|
alf << i
end
alf.each_with_index do |k, i|
if k == c
puts alf[i+1]
break
end
end | [
"identifier.change"
] | 603,872 | 603,873 | u684458716 | ruby |
p02801 | p ($<.ord+1).chr | puts (gets.ord+1).chr | [
"call.function.change",
"io.output.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 604,014 | 604,015 | u604693716 | ruby |
p02801 | c = gets.chomp
# array でa~zの配列をつくる
array = ("a".."z").to_a
# find で条件に一致した要素を取り出す
# オブジェクト.find{ |要素| ブロック処理}
num = array.find_num(c)
puts array[num + 1]
| c = gets.chomp
# array でa~zの配列をつくる
array = ("a".."z").to_a
# find で条件に一致した要素を取り出す
# オブジェクト.find{ |要素| ブロック処理}
index = array.find_index(c)
puts array[index + 1]
| [
"assignment.variable.change",
"identifier.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 604,021 | 604,022 | u552761221 | ruby |
p02801 | alpbets = ("a".."z").to_a.join
puts alpbets[alpbets.index(gets)+1] | alpbets = ("a".."z").to_a.join
puts alpbets[alpbets.index(gets.chomp)+1] | [
"call.add"
] | 604,285 | 604,286 | u802371628 | ruby |
p02801 | c = gets.chomp
alph = ("a".."z").to_a
n = alph.index(c)
p alph[n + 1] | c = gets.chomp
alph = ("a".."z").to_a
n = alph.index(c)
puts alph[n+1] | [
"call.function.change",
"io.output.change"
] | 604,319 | 604,320 | u395458577 | ruby |
p02801 | c = gets
alph = ("a".."z").to_a
n = alph.index(c)
p alph[n +1] | c = gets.chomp
alph = ("a".."z").to_a
n = alph.index(c)
puts alph[n+1] | [
"call.add",
"call.function.change",
"io.output.change"
] | 604,321 | 604,320 | u395458577 | ruby |
p02801 | #アルファベット順を作る
text = ("a".."z").to_a
# 奇跡的にうまれた
puts text[text.index(gets.choms)+1] | #アルファベット順を作る
text = ("a".."z").to_a
# 奇跡的にうまれた
puts text[text.index(gets.chomp)+1] | [
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 604,353 | 604,354 | u689027433 | ruby |
p02801 | #アルファベット順を作る
text = ('a'..'z').to_a
# 奇跡的にうまれた
puts text[text.index(gets.choms)+1] | #アルファベット順を作る
text = ("a".."z").to_a
# 奇跡的にうまれた
puts text[text.index(gets.chomp)+1] | [
"literal.string.change",
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 604,355 | 604,354 | u689027433 | ruby |
p02801 | #アルファベット順を作る
text = ('a'..'z').to_a
# 奇跡的にうまれた
puts text[text.index(gets)+1] | #アルファベット順を作る
text = ("a".."z").to_a
# 奇跡的にうまれた
puts text[text.index(gets.chomp)+1] | [
"literal.string.change",
"assignment.value.change",
"call.add"
] | 604,356 | 604,354 | u689027433 | ruby |
p02801 | text = ('a'..'z').to_a
puts text[text.index(gets)+1] | #アルファベット順を作る
text = ("a".."z").to_a
# 奇跡的にうまれた
puts text[text.index(gets.chomp)+1] | [
"literal.string.change",
"assignment.value.change",
"call.add"
] | 604,357 | 604,354 | u689027433 | ruby |
p02801 | #アルファベット順を作る
text = ('a'..'z').to_a
# 奇跡的にうまれた
puts text[text.index(gets)+1] | #アルファベット順を作る
text = ("a".."z").to_a
# 奇跡的にうまれた
puts text[text.index(gets.chomp)+1] | [
"literal.string.change",
"assignment.value.change",
"call.add"
] | 604,359 | 604,354 | u689027433 | ruby |
p02801 | c = gets
text = ("a".."z").to_a
moji = text.index(c)
puts text[moji+1] | c = gets.chomp
text = ("a".."z").to_a
moji = text.index(c)
puts text[moji+1] | [
"call.add"
] | 604,360 | 604,361 | u689027433 | ruby |
p02801 | c = gets
text = ('a'..'z').to_a
moji = text.index(c)
puts text[moji+1] | c = gets.chomp
text = ("a".."z").to_a
moji = text.index(c)
puts text[moji+1] | [
"call.add",
"literal.string.change",
"assignment.value.change"
] | 604,362 | 604,361 | u689027433 | ruby |
p02801 | # 順番を変える
c = gets
#アルファベット順を作る
text = ('a'..'z').to_a
# 入力した文字を何番目の配列か見つける
moji = text.index(c)
puts text[moji+1] | c = gets.chomp
text = ("a".."z").to_a
moji = text.index(c)
puts text[moji+1] | [
"call.add",
"literal.string.change",
"assignment.value.change"
] | 604,363 | 604,361 | u689027433 | ruby |
p02801 | p gets.strip.next | puts gets.strip.next | [
"call.function.change",
"io.output.change"
] | 604,385 | 604,386 | u173515518 | ruby |
p02801 | C = gets
p (C.ord + 1).chr
| C = gets
puts (C.ord + 1).chr
| [
"call.function.change",
"io.output.change"
] | 604,389 | 604,390 | u487252913 | ruby |
p02801 | puts gets.chomp.sacc | puts gets.chomp.succ | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 604,435 | 604,436 | u980438307 | ruby |
p02801 | C=gets
puts C+1 | C=gets
puts C.succ | [] | 604,453 | 604,454 | u041282550 | ruby |
p02801 | C=gets
puts C+1 | C=gets
puts (C.ord+1).chr | [
"call.arguments.change",
"call.add"
] | 604,453 | 604,455 | u041282550 | ruby |
p02801 | c = gets.chomp
p c.next.chr | c = gets.chomp
puts c.next.chr | [
"call.function.change",
"io.output.change"
] | 604,487 | 604,488 | u713505166 | ruby |
p02801 | c = gets
p c.next | c = gets.chomp
puts c.next.chr | [
"assignment.value.change",
"call.add",
"io.output.change"
] | 604,489 | 604,488 | u713505166 | ruby |
p02801 |
s = gets.chmp
puts (s.bytes.first + 1).chr |
s = gets.chomp
puts (s.bytes.first + 1).chr
| [
"assignment.value.change",
"identifier.change"
] | 604,490 | 604,491 | u302838475 | ruby |
p02801 |
s = gets.chomp
puts (s.bytes + 1).chr |
s = gets.chomp
puts (s.bytes.first + 1).chr
| [
"call.add"
] | 604,492 | 604,491 | u302838475 | ruby |
p02801 | C = gets
alp = 'abcdefghijklmnopqrstuvwxyz'
puts alp[alp.index(C)+1] | C = gets.strip
alp = 'abcdefghijklmnopqrstuvwxyz'
puts alp[alp.index(C)+1] | [
"call.add"
] | 604,501 | 604,502 | u808757777 | ruby |
p02801 | S = gets.chomp
p S.succ | S = gets.chomp
puts S.succ | [
"call.function.change",
"io.output.change"
] | 604,666 | 604,667 | u010077599 | ruby |
p02801 | S = gets
array = 'a'.upto('z').to_a
flag = 0
(0..25).each do |i|
if array[i] == S
flag = 1
elsif flag == 1 and i != 25
puts array[i]
break
elsif i == 25
puts array[i]
end
end | S = gets.chomp.to_s
array = 'a'.upto('z').to_a
flag = 0
(0..25).each do |i|
if array[i] == S
flag = 1
elsif flag == 1 and i != 25
puts array[i]
break
elsif i == 25
puts array[i]
end
end | [
"call.add"
] | 604,698 | 604,699 | u119088863 | ruby |
p02801 | C = gets.chomp
al = ("a".."z").to_a
p al[al.index(C)+1]
| C = gets.chomp
al = ("a".."z").to_a
puts al[al.index(C)+1] | [
"call.function.change",
"io.output.change"
] | 604,723 | 604,724 | u012110567 | ruby |
p02801 | (gets.chars.first.ord+1).chr | puts (gets.chars.first.ord+1).chr | [
"io.output.change",
"call.add"
] | 604,737 | 604,738 | u545334763 | ruby |
p02801 | p gets.next | puts gets.next | [
"call.function.change",
"io.output.change"
] | 604,754 | 604,755 | u024469792 | ruby |
p02801 | str = 'abcdefghijklmnopqrstuvwxyz'
c = gets
puts str[str.index(c)+1] | str = 'abcdefghijklmnopqrstuvwxyz'
c = gets.chop
puts str[str.index(c)+1] | [
"call.add"
] | 604,800 | 604,801 | u604352408 | ruby |
p02801 | c=gets.to_s
a=('a'..'z').to_a
puts a[a.index(c)+1] | c=gets.chomp.to_s
a=("a".."z").to_a
puts a[a.index(c)+1] | [
"call.add",
"literal.string.change",
"assignment.value.change"
] | 604,946 | 604,945 | u630043039 | ruby |
p02802 | n,m=gets.split.map(&:to_i)
hash={}
m.times do |i|
p,s=gets.split
if hash[p]==nil
hash[p]=[s]
else
hash[p]<<s
end
end
ac=0
penalty=0
hash.each_value do |s|
wa=0
s.each do |i|
if i=="AC"
ac+=1
penalty=wa
break
else
wa+=1
end
end
end
puts "#{ac} #{penalty}"
| n,m=gets.split.map(&:to_i)
hash={}
m.times do |i|
p,s=gets.split
if hash[p]==nil
hash[p]=[s]
else
hash[p]<<s
end
end
ac=0
penalty=0
hash.each_value do |s|
wa=0
s.each do |i|
if i=="AC"
ac+=1
penalty+=wa
break
else
wa+=1
end
end
end
puts "#{ac} #{penalty}"
| [
"assignment.value.change"
] | 605,326 | 605,327 | u556046719 | ruby |
p02802 | State = Struct.new(:id, :his)
N, M = gets.split.map(&:to_i)
p = []
s = []
submit = []
status = Hash.new
pena = 0
corr = 0
tmp = []
M.times do |i|
p[i], s[i] = gets.split
p[i] = p[i].to_i
puts "#{status}"
# はじめての提出の場合
if status[p[i]].nil?
status[p[i]] = s[i]
# 1回目のミス
if status[p[i]] == 'WA'
tmp[p[i]] = 1
# 1回目でAC
elsif status[p[i]] == 'AC'
corr += 1
end
# 2回目以降の提出で,かつまだ解けてない問題について
elsif status[p[i]] == 'WA'
# 2回目以降のミス
if s[i] == 'WA'
tmp[p[i]] += 1
# 2回目以降の提出でAC
elsif s[i] == 'AC'
status[p[i]] = 'AC'
pena += tmp[p[i]]
corr += 1
end
end
end
puts "#{corr} #{pena}" | State = Struct.new(:id, :his)
N, M = gets.split.map(&:to_i)
p = []
s = []
submit = []
status = Hash.new
pena = 0
corr = 0
tmp = []
M.times do |i|
p[i], s[i] = gets.split
p[i] = p[i].to_i
# はじめての提出の場合
if status[p[i]].nil?
status[p[i]] = s[i]
# 1回目のミス
if status[p[i]] == 'WA'
tmp[p[i]] = 1
# 1回目でAC
elsif status[p[i]] == 'AC'
corr += 1
end
# 2回目以降の提出で,かつまだ解けてない問題について
elsif status[p[i]] == 'WA'
# 2回目以降のミス
if s[i] == 'WA'
tmp[p[i]] += 1
# 2回目以降の提出でAC
elsif s[i] == 'AC'
status[p[i]] = 'AC'
pena += tmp[p[i]]
corr += 1
end
end
end
puts "#{corr} #{pena}" | [
"call.remove"
] | 605,500 | 605,501 | u326288614 | ruby |
p02802 | n,m=gets.split.map(&:to_i)
sp=[]
m.times{x=gets.chomp.split;sp<<[x[0].to_i,x[1]]}
i=0
sp.sort_by!{|a|[a[0],i+=1]}
i=p=q=r=0
c=false
sp.each{|a|
if a[0]==i
if c
elsif a[1]=="WA"
r+=1
elsif a[1]=="AC"
p+=r
r=0
q+=1
c=true
end
else
i=a[0]
c=false
if a[1]=="WA"
r+=1
elsif a[1]=="AC"
p+=r
r=0
q+=1
c=true
end
end
}
puts "#{q} #{p}"
| n,m=gets.split.map(&:to_i)
sp=[]
m.times{x=gets.chomp.split;sp<<[x[0].to_i,x[1]]}
i=0
sp.sort_by!{|a|[a[0],i+=1]}
i=p=q=r=0
c=false
sp.each{|a|
if a[0]==i
if c
elsif a[1]=="WA"
r+=1
elsif a[1]=="AC"
p+=r
r=0
q+=1
c=true
end
else
i=a[0]
r=0
c=false
if a[1]=="WA"
r+=1
elsif a[1]=="AC"
p+=r
r=0
q+=1
c=true
end
end
}
puts "#{q} #{p}"
| [
"assignment.add"
] | 605,634 | 605,635 | u883824971 | ruby |
p02802 | N, M = gets.chop.split.map(&:to_i)
lines = []
while line = gets
lines << line.chomp.split(' ')
end
hash = {}
#{1: [ture, 0]}
lines.each do |p|
hash[p[0]] ||= [false, 0]
if hash[p[0]][0]
next
else
if p[1] == 'WA'
hash[p[0]][1] += 1
else
hash[p[0]][0] = true
end
end
end
ac = 0
wa = 0
hash.each do |i|
if i[1][0]
ac += 1
end
wa += i[1][1]
end
print ac, ' ', wa
| N, M = gets.chop.split.map(&:to_i)
lines = []
while line = gets
lines << line.chomp.split(' ')
end
hash = {}
#{1: [ture, 0]}
lines.each do |p|
hash[p[0]] ||= [false, 0]
if hash[p[0]][0]
next
else
if p[1] == 'WA'
hash[p[0]][1] += 1
else
hash[p[0]][0] = true
end
end
end
ac = 0
wa = 0
hash.each do |i|
if i[1][0]
ac += 1
wa += i[1][1]
end
end
print ac, ' ', wa
| [] | 605,644 | 605,645 | u450617345 | ruby |
p02802 | inputs = Array.new
while line = $stdin.gets
inputs << line.chomp
end
N, M = inputs[0].split(" ").map(&:to_i)
pS = inputs[1..-1]
# [n, cnt_wa, is_ac]
hash = Hash.new
pS.each do |ps|
i, s = ps.split
i = i.to_i
if s == "WA"
if hash[i].nil?
hash[i] = {
cnt_wa: 1,
is_ac: false,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa] + 1,
is_ac: false,
}
end
end
elsif s == "AC"
if hash[i].nil?
hash[i] = {
cnt_wa: 0,
is_ac: true,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa],
is_ac: true,
}
end
end
end
end
wa = 0
ac = 0
hash.each do |i, value|
cnt_wa = value[:cnt_wa]
is_ac = value[:is_ac]
if is_ac
wa += cnt_wa
ac += 1
end
end
puts "#{ac}, #{wa}"
| inputs = Array.new
while line = $stdin.gets
inputs << line.chomp
end
N, M = inputs[0].split(" ").map(&:to_i)
pS = inputs[1..-1]
# [n, cnt_wa, is_ac]
hash = Hash.new
pS.each do |ps|
i, s = ps.split
i = i.to_i
if s == "WA"
if hash[i].nil?
hash[i] = {
cnt_wa: 1,
is_ac: false,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa] + 1,
is_ac: false,
}
end
end
elsif s == "AC"
if hash[i].nil?
hash[i] = {
cnt_wa: 0,
is_ac: true,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa],
is_ac: true,
}
end
end
end
end
wa = 0
ac = 0
hash.each do |i, value|
cnt_wa = value[:cnt_wa]
is_ac = value[:is_ac]
if is_ac
wa += cnt_wa
ac += 1
end
end
puts "#{ac} #{wa}"
| [
"literal.string.change",
"call.arguments.change"
] | 605,662 | 605,663 | u736893066 | ruby |
p02802 | inputs = Array.new
while line = $stdin.gets
inputs << line.chomp
end
N, M = inputs[0].split(" ").map(&:to_i)
pS = inputs[1..-1]
# [n, cnt_wa, is_ac]
hash = Hash.new
pS.each do |ps|
i, s = ps.split
i = i.to_i
if s == "WA"
if hash[i].nil?
hash[i] = {
cnt_wa: 1,
is_ac: false,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa] + 1,
is_ac: false,
}
end
end
else s == "AC"
if hash[i].nil?
hash[i] = {
cnt_wa: 0,
is_ac: true,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa],
is_ac: true,
}
end
end
end
end
wa = 0
ac = 0
hash.each do |i, value|
cnt_wa = value[:cnt_wa]
is_ac = value[:is_ac]
if is_ac
wa += cnt_wa
ac += 1
end
end
puts "#{ac}, #{wa}"
| inputs = Array.new
while line = $stdin.gets
inputs << line.chomp
end
N, M = inputs[0].split(" ").map(&:to_i)
pS = inputs[1..-1]
# [n, cnt_wa, is_ac]
hash = Hash.new
pS.each do |ps|
i, s = ps.split
i = i.to_i
if s == "WA"
if hash[i].nil?
hash[i] = {
cnt_wa: 1,
is_ac: false,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa] + 1,
is_ac: false,
}
end
end
elsif s == "AC"
if hash[i].nil?
hash[i] = {
cnt_wa: 0,
is_ac: true,
}
else
unless hash[i][:is_ac]
hash[i] = {
cnt_wa: hash[i][:cnt_wa],
is_ac: true,
}
end
end
end
end
wa = 0
ac = 0
hash.each do |i, value|
cnt_wa = value[:cnt_wa]
is_ac = value[:is_ac]
if is_ac
wa += cnt_wa
ac += 1
end
end
puts "#{ac} #{wa}"
| [
"literal.string.change",
"call.arguments.change"
] | 605,664 | 605,663 | u736893066 | ruby |
p02802 | _, m = gets.split.map(&:to_i)
solved = {}
wa = {}
was = 0
m.times do
p, s = gets.split
p = p.to_i
next if solved[p]
case s
when 'AC'
solved[p] = true
was += wa[p]
when 'WA'
wa[p] = (wa[p]||0)+1
end
end
puts [(solved.select{|_,v|v}.size), was]*' '
| _, m = gets.split.map(&:to_i)
solved = {}
wa = {}
was = 0
m.times do
p, s = gets.split
p = p.to_i
next if solved[p]
case s
when 'AC'
solved[p] = true
was += wa[p]||0
when 'WA'
wa[p] = (wa[p]||0)+1
end
end
puts [(solved.select{|_,v|v}.size), was]*' '
| [
"expression.operation.binary.add"
] | 605,928 | 605,929 | u056944756 | ruby |
p02802 | n, m = gets.chomp.split.map(&:to_i)
submits = []
m.times do |set|
submits << gets.chomp.split
end
res = {}
submits.each do |set|
num = set[0]
type = set[1]
res[num] = {} if res[num].nil?
if type == 'AC'
res[num]['ac'] = true if res[num]['ac'].nil?
elsif type == 'WA'
res[num]['wa'] = res[num]['wa'].to_i + 1 if res[num]['ac'].nil?
end
end
ac = 0
wa = 0
res.each do |k, v|
ac += 1 if v['ac']
wa += v['wa'] if v['ac']
end
puts "#{ac} #{wa}" | n, m = gets.chomp.split.map(&:to_i)
submits = []
m.times do |set|
submits << gets.chomp.split
end
res = {}
submits.each do |set|
num = set[0]
type = set[1]
res[num] = {} if res[num].nil?
if type == 'AC'
res[num]['ac'] = true if res[num]['ac'].nil?
elsif type == 'WA'
res[num]['wa'] = res[num]['wa'].to_i + 1 if res[num]['ac'].nil?
end
end
ac = 0
wa = 0
res.each do |k, v|
ac += 1 if v['ac']
wa += v['wa'].to_i if v['ac']
end
puts "#{ac} #{wa}" | [
"call.add"
] | 606,078 | 606,079 | u447059782 | ruby |
p02802 | n, m = gets.chomp.split(' ').map{|i| i.to_i }
last_submits = []
ac = 0
pns = []
m.times{|i|
pp, s = gets.chomp.split(' ')
pp = pp.to_i
if last_submits[pp].nil?
if s[0] == 'A'
last_submits[pp] = true
ac += 1
pn += pns[pp] unless pns[pp].nil?
else
pns[pp] = 0 if pns[pp].nil?
pns[pp] += 1
end
end
}
puts "#{ac} #{pn}"
| n, m = gets.chomp.split(' ').map{|i| i.to_i }
last_submits = []
ac = 0
pn = 0
pns = []
m.times{|i|
pp, s = gets.chomp.split(' ')
pp = pp.to_i
if last_submits[pp].nil?
if s[0] == 'A'
last_submits[pp] = true
ac += 1
pn += pns[pp] unless pns[pp].nil?
else
pns[pp] = 0 if pns[pp].nil?
pns[pp] += 1
end
end
}
puts "#{ac} #{pn}"
| [
"assignment.add"
] | 606,785 | 606,786 | u208362438 | ruby |
p02802 | n, m = gets.split.map(&:to_i)
submissions = Hash.new { |h, k| h[k] = [] }
ac = 0
wa = 0
m.times do
pi, s = gets.split
submissions[pi.to_i] << s.chomp
end
submissions.each do |_pi, s_ary|
# ある問題piに対してAC数が0ならスキップ
next unless s_ary.count('AC')
# 初めてACしたのが何回目の提出か
first_ac_idx = s_ary.index('AC')
ac += 1
wa += first_ac_idx
end
puts "#{ac} #{wa}"
| n, m = gets.split.map(&:to_i)
submissions = Hash.new { |h, k| h[k] = [] }
ac = 0
wa = 0
m.times do
pi, s = gets.split
submissions[pi.to_i] << s.chomp
end
submissions.each do |_pi, s_ary|
# ある問題piに対してAC数が0ならスキップ
next if s_ary.count('AC').zero?
# 初めてACしたのが何回目の提出か
first_ac_idx = s_ary.index('AC')
ac += 1
wa += first_ac_idx
end
puts "#{ac} #{wa}"
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 606,834 | 606,835 | u776649162 | ruby |
p02803 | $H, $W = gets.chomp.split.map(&:to_i)
$maze = []
$ans = 0
$H.times do
$maze << gets.chomp.split("")
end
def update_ans(dist)
dist.each do |row|
row.each do |e|
next unless e
$ans = $ans > e ? $ans : e
end
end
end
def bfs(sx, sy)
queue = [[sx, sy]]
reach = Array.new($H).map{Array.new($W, nil)}
reach[sy][sx] = 0
until queue.empty?
x, y = queue.shift
dist = reach[y][x]
[
[x-1, y],
[x+1, y],
[x, y-1],
[x, y+1]
].each do |x, y|
next if x < 0 || $W <= x || y < 0 || $H <= y
next if reach[y][x]
if $maze[y][x] == "#" then
reach[y][x] = -1
next
end
queue << [x, y]
reach[y][x] = dist+1
end
end
update_ans(reach)
end
$W.times do |i|
$H.times do |j|
next if $maze[y][x] == "#"
bfs(i, j)
end
end
puts $ans | $H, $W = gets.chomp.split.map(&:to_i)
$maze = []
$ans = 0
$H.times do
$maze << gets.chomp.split("")
end
def update_ans(dist)
dist.each do |row|
row.each do |e|
next unless e
$ans = $ans > e ? $ans : e
end
end
end
def bfs(sx, sy)
queue = [[sx, sy]]
reach = Array.new($H).map{Array.new($W, nil)}
reach[sy][sx] = 0
until queue.empty?
x, y = queue.shift
dist = reach[y][x]
[
[x-1, y],
[x+1, y],
[x, y-1],
[x, y+1]
].each do |x, y|
next if x < 0 || $W <= x || y < 0 || $H <= y
next if reach[y][x]
if $maze[y][x] == "#" then
reach[y][x] = -1
next
end
queue << [x, y]
reach[y][x] = dist+1
end
end
update_ans(reach)
end
$W.times do |i|
$H.times do |j|
next if $maze[j][i] == "#"
bfs(i, j)
end
end
puts $ans | [
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 607,348 | 607,349 | u466332671 | ruby |
p02803 | H,W = gets.split.map(&:to_i)
S = readlines.map(&:chomp)
ans = 0
H.times do |y|
W.times do |x|
next if S[y][x] == '#'
s = Array.new(H) { [] }
s[y][x] = 0
q = [[y,x]]
while !q.empty?
y,x = q.pop
n = s[y][x]
ans = n if ans < n
[y-1,x, y+1,x, y,x-1, y,x+1].each_slice(2) do |y,x|
next if x < 0 || y < 0 || x >= W || y >= H
next if s[y][x] != nil
next if S[y][x] == '#'
s[y][x] = n + 1
q << [y,x]
end
end
end
end
puts ans
| H,W = gets.split.map(&:to_i)
S = readlines.map(&:chomp)
ans = 0
H.times do |y|
W.times do |x|
next if S[y][x] == '#'
s = Array.new(H) { [] }
s[y][x] = 0
q = [[y,x]]
while !q.empty?
y,x = q.shift
n = s[y][x]
ans = n if ans < n
[y-1,x, y+1,x, y,x-1, y,x+1].each_slice(2) do |y,x|
next if x < 0 || y < 0 || x >= W || y >= H
next if s[y][x] != nil
next if S[y][x] == '#'
s[y][x] = n + 1
q << [y,x]
end
end
end
end
puts ans
| [
"assignment.value.change",
"identifier.change"
] | 607,664 | 607,665 | u064100484 | ruby |
p02804 | class ModCombination
attr_reader :fac, :inv, :finv, :mod
MOD = 10 ** 9 + 7
def initialize(n, mod: MOD)
@mod = mod
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]
(2..n).each do |i|
@fac[i] = fac[i - 1] * i % mod
@inv[i] = mod - inv[mod % i] * (mod / i) % mod
@finv[i] = finv[i - 1] * inv[i] % mod
end
end
def combination(n, k)
return 0 if n < k
return 0 if n < 0 || k < 0
fac[n] * (finv[k] * finv[n - k] % mod) % mod
end
def repeated_combination(n, k)
combination(n + k - 1, k)
end
end
MOD = 10 ** 9 + 7
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
if K == 1
puts 0
exit
end
ans = 0
mc = ModCombination.new(N + 1)
N.times do |i|
a = A[i]
if i <= N - K + 1
ans += -a * mc.combination(N - i - 1, K - 1)
end
if i >= N - K - 1
ans += a * mc.combination(i, K - 1)
end
ans %= MOD
end
puts ans
| class ModCombination
attr_reader :fac, :inv, :finv, :mod
MOD = 10 ** 9 + 7
def initialize(n, mod: MOD)
@mod = mod
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]
(2..n).each do |i|
@fac[i] = fac[i - 1] * i % mod
@inv[i] = mod - inv[mod % i] * (mod / i) % mod
@finv[i] = finv[i - 1] * inv[i] % mod
end
end
def combination(n, k)
return 0 if n < k
return 0 if n < 0 || k < 0
fac[n] * (finv[k] * finv[n - k] % mod) % mod
end
def repeated_combination(n, k)
combination(n + k - 1, k)
end
end
MOD = 10 ** 9 + 7
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
if K == 1
puts 0
exit
end
ans = 0
mc = ModCombination.new(N + 1)
N.times do |i|
a = A[i]
if i <= N - K + 1
ans += -a * mc.combination(N - i - 1, K - 1)
end
if i >= K - 1
ans += a * mc.combination(i, K - 1)
end
ans %= MOD
end
puts ans
| [
"expression.operation.binary.remove"
] | 608,625 | 608,626 | u740836226 | ruby |
p02806 | n = gets.to_i
ans = 0
arr = []
n.times do
input = gets.chomp.split(" ")
arr.push(input)
end
x = gets
arr.reverse.each do |v|
break if v[0] == x[0..x.length]
ans += v[1].to_i
end
print ans | n = gets.to_i
ans = 0
arr = []
n.times do
input = gets.chomp.split(" ")
arr.push(input)
end
x = gets
arr.reverse.each do |v|
break if v[0] == x[0..x.length-2]
ans += v[1].to_i
end
puts ans | [
"control_flow.branch.if.condition.change",
"identifier.change"
] | 609,397 | 609,398 | u097182283 | ruby |
p02806 | n = gets.to_i
ans = 0
arr = []
n.times do
input = gets.chomp.split(" ")
arr.push(input)
end
x = gets
arr.reverse.each do |v|
break if v[0] == x[0..x.length]
ans += v[1].to_i
end
puts ans | n = gets.to_i
ans = 0
arr = []
n.times do
input = gets.chomp.split(" ")
arr.push(input)
end
x = gets
arr.reverse.each do |v|
break if v[0] == x[0..x.length-2]
ans += v[1].to_i
end
puts ans | [
"control_flow.branch.if.condition.change"
] | 609,399 | 609,398 | u097182283 | ruby |
p02806 | n=gets.to_i
st=(0...n).map{(s,t) = gets.split;[s,t.to_i]}
x=gets
i=st.index{|(s,t)| s==x}
r = st[i+1...st.size].map{|s,t|t}.reduce(0,:+)
print r | n=gets.to_i
st=(0...n).map{(s,t) = gets.split;[s,t.to_i]}
x=gets.chomp
i=st.index{|(s,t)| s==x}
r = st[i+1...st.size].map{|s,t|t}.reduce(0,:+)
print r
| [
"call.add"
] | 609,494 | 609,495 | u702482655 | ruby |
p02806 | n=gets.to_i
st=(0...n).map{(s,t) = gets.split;[s,t.to_i]}
x=gets
i=st.index{|(s,t)| s==x}
r = st[i+1...st.size].map{|s,t|t}.reduce(0,:+)
print r
| n=gets.to_i
st=(0...n).map{(s,t) = gets.split;[s,t.to_i]}
x=gets.chomp
i=st.index{|(s,t)| s==x}
r = st[i+1...st.size].map{|s,t|t}.reduce(0,:+)
print r
| [
"call.add"
] | 609,496 | 609,495 | u702482655 | ruby |
p02803 | h, w = gets.chop.split.map(&to_i)
s = []
h.times do
ws = gets.chop.split
s << ws
end
max = 0
h.times do |i_h|
w.times do |i_w|
next if s[i_h][i_w] == '#'
cost = Array.new(h) { Array.new(w, nil) }
cost[i_h][i_w] = 0
adds = [[i_h, i_w]]
loop do
break if adds.empty?
new_adds = []
adds.each do |a|
p = cost[a[0]][a[1]]
if a[0] > 0 && s[a[0]-1][a[1]] == '.' && cost[a[0]-1][a[1]].nil?
cost[a[0]-1][a[1]] = p + 1
new_adds << [a[0]-1, a[1]]
end
if a[0] < h-1 && s[a[0]+1][a[1]] == '.' && cost[a[0]+1][a[1]].nil?
cost[a[0]+1][a[1]] = p + 1
new_adds << [a[0]+1, a[1]]
end
if a[1] > 0 && s[a[0]][a[1]-1] == '.' && cost[a[0]][a[1]-1].nil?
cost[a[0]][a[1]-1] = p + 1
new_adds << [a[0], a[1]-1]
end
if a[1] < w-1 && s[a[0]][a[1]+1] == '.' && cost[a[0]][a[1]+1].nil?
cost[a[0]][a[1]+1] = p + 1
new_adds << [a[0], a[1]+1]
end
end
adds = new_adds
end
max =[max, cost.flattern.compact.max].max
end
end
puts max | h, w = gets.chop.split.map(&:to_i)
s = []
h.times do
ws = gets.chop.chars
s << ws
end
max = 0
h.times do |i_h|
w.times do |i_w|
next if s[i_h][i_w] == '#'
cost = Array.new(h) { Array.new(w, nil) }
cost[i_h][i_w] = 0
adds = [[i_h, i_w]]
loop do
break if adds.empty?
new_adds = []
adds.each do |a|
p = cost[a[0]][a[1]]
if a[0] > 0 && s[a[0]-1][a[1]] == '.' && cost[a[0]-1][a[1]].nil?
cost[a[0]-1][a[1]] = p + 1
new_adds << [a[0]-1, a[1]]
end
if a[0] < h-1 && s[a[0]+1][a[1]] == '.' && cost[a[0]+1][a[1]].nil?
cost[a[0]+1][a[1]] = p + 1
new_adds << [a[0]+1, a[1]]
end
if a[1] > 0 && s[a[0]][a[1]-1] == '.' && cost[a[0]][a[1]-1].nil?
cost[a[0]][a[1]-1] = p + 1
new_adds << [a[0], a[1]-1]
end
if a[1] < w-1 && s[a[0]][a[1]+1] == '.' && cost[a[0]][a[1]+1].nil?
cost[a[0]][a[1]+1] = p + 1
new_adds << [a[0], a[1]+1]
end
end
adds = new_adds
end
max = [max, cost.flatten.compact.max].max
end
end
puts max | [
"assignment.value.change",
"call.arguments.change",
"identifier.change"
] | 609,552 | 609,553 | u604352408 | ruby |
p02805 | N = gets.to_i
PS = (0...N).map{ gets.split.map &:to_i }
EPS = 1e-16
#p EPS
def contains_all(cx,cy,r2,points)
r = points.all?{ |x,y| r2 - (cx-x)**2 - (cy-y)**2 >= -EPS }
# $stderr.puts "(#{cx},#{cy}) x #{r2} -> #{r}"
r
end
r = 1000000000000000
(0...N).each{ |i|
xa,ya = PS[i]
(i+1...N).each{ |j|
xb,yb = PS[j]
# check for doublet
r2 = ((xa-xb) ** 2 + (ya-yb) ** 2) / 4.0
centx = (xa+xb)/2.0
centy = (ya+yb)/2.0
if r2 < r && contains_all(centx, centy, r2, PS)
#p [i, j, centx, centy, r2]
r = [r, r2].min
end
c2 = (xa-xb)**2 + (ya-yb)**2
c1 = Math.sqrt(c2)
(j+1...N).each{ |k|
# check for triplet
xc,yc = PS[k]
a2 = (xb-xc)**2 + (yb-yc)**2
b2 = (xa-xc)**2 + (ya-yc)**2
a1 = Math.sqrt(a2)
b1 = Math.sqrt(b2)
ae = a2*(b2+c2-a2); be = b2*(a2+c2-b2); ce = c2*(a2+b2-c2)
d = ae + be + ce
next if d == 0
centx = (ae*xa + be*xb + ce*xc) / d.to_f
centy = (ae*ya + be*yb + ce*yc) / d.to_f
r2 = (a1*b1*c1) ** 2 / (a1+b1+c1)*(-a1+b1+c1)*(a1-b1+c1)*(a1+b1-c1)
#$stderr.puts Math.sqrt(r2)
if r2 < r && contains_all(centx, centy, r2, PS)
#p [i, j, k, centx, centy, r2]
r = r2
end
}
}
}
p Math.sqrt(r) | N = gets.to_i
PS = (0...N).map{ gets.split.map &:to_i }
EPS = 1e-8
#p EPS
def contains_all(cx,cy,r2,points)
r = points.all?{ |x,y| r2 - (cx-x)**2 - (cy-y)**2 >= -EPS }
#$stderr.puts "(#{cx},#{cy}) x #{r2} -> #{r}"
r
end
r = 1000000000000000
(0...N).each{ |i|
xa,ya = PS[i]
(i+1...N).each{ |j|
xb,yb = PS[j]
# check for doublet
r2 = ((xa-xb) ** 2 + (ya-yb) ** 2) / 4.0
centx = (xa+xb)/2.0
centy = (ya+yb)/2.0
#$stderr.puts(Math.sqrt(r2))
if r2 < r && contains_all(centx, centy, r2, PS)
#p [PS[i], PS[j], centx, centy, r2]
r = [r, r2].min
end
c2 = (xa-xb)**2 + (ya-yb)**2
c1 = Math.sqrt(c2)
(j+1...N).each{ |k|
# check for triplet
xc,yc = PS[k]
a2 = (xb-xc)**2 + (yb-yc)**2
b2 = (xa-xc)**2 + (ya-yc)**2
a1 = Math.sqrt(a2)
b1 = Math.sqrt(b2)
ae = a2*(b2+c2-a2); be = b2*(a2+c2-b2); ce = c2*(a2+b2-c2)
d = ae + be + ce
next if d == 0
centx = (ae*xa + be*xb + ce*xc) / d.to_f
centy = (ae*ya + be*yb + ce*yc) / d.to_f
r2 = (a1*b1*c1) ** 2 / ((a1+b1+c1)*(-a1+b1+c1)*(a1-b1+c1)*(a1+b1-c1))
#$stderr.puts Math.sqrt(r2)
if r2 < r && contains_all(centx, centy, r2, PS)
#p [PS[i], PS[j], PS[k], centx, centy, a1, b1, c1, r2]
r = r2
end
}
}
}
p Math.sqrt(r) | [
"literal.number.float.change",
"assignment.value.change"
] | 609,920 | 609,921 | u670503797 | ruby |
p02811 | k,x=gets.split.map &:to_i
p k*500<x ? :No : :Yes | k,x=gets.split.map &:to_i
puts k*500<x ? :No : :Yes | [
"call.function.change",
"io.output.change"
] | 610,248 | 610,249 | u657913472 | ruby |
p02811 | k, x = gets.split.map(&:to_i)
if k*500 > x
print 'Yes'
else
print 'No'
end | k, x = gets.split.map(&:to_i)
if k*500 >= x
print 'Yes'
else
print 'No'
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 610,346 | 610,347 | u872827179 | ruby |
p02811 | def input_n
gets.to_i # 単一整数
end
def input_s
gets.chomp # 文字列。chompを付けないと改行文字がついてくる
end
def input_a
gets.split.map(&:to_i) # スペースで区切られた複数の整数
end
def input_o(num)
num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある
end
def output_f(num)
puts sprintf("%.12f", num)
end
k, x = input_n
if k * 500 >= x
puts "Yes"
else
puts "No"
end | def input_n
gets.to_i # 単一整数
end
def input_s
gets.chomp # 文字列。chompを付けないと改行文字がついてくる
end
def input_a
gets.split.map(&:to_i) # スペースで区切られた複数の整数
end
def input_o(num)
num.times.map { gets.to_i } # 縦に並んだ複数の整数。たまにある
end
def output_f(num)
puts sprintf("%.12f", num)
end
k, x = input_a
if k * 500 >= x
puts "Yes"
else
puts "No"
end | [
"assignment.value.change",
"identifier.change"
] | 610,395 | 610,396 | u876846619 | ruby |
p02811 | k,x = gets.chomp.split(' ').map(&:to_i)
if (500 * x) >= x
print 'Yes'
else
print 'No'
end | k,x = gets.chomp.split(' ').map(&:to_i)
if (500 * k) >= x
print 'Yes'
else
print 'No'
end
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 610,414 | 610,415 | u305811972 | ruby |
p02811 | k,x = gets.chomp.split(' ').map(&:to_i)
if (500 * x) > x
print 'Yes'
else
print 'No'
end | k,x = gets.chomp.split(' ').map(&:to_i)
if (500 * k) >= x
print 'Yes'
else
print 'No'
end
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"expression.operator.compare.change"
] | 610,416 | 610,415 | u305811972 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.