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 |
|---|---|---|---|---|---|---|---|
p03386
|
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,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
return bool ? y : n
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
if size2==-1
return Array.new(size1){init}
else
return Array.new(size2){Array.new(size1){init}}
end
end
A,B,K=get_i
if B-A<=2*K
A.upto(B) do|i|
puts i
end
else
A.upto(A+K-1) do|i|
puts i
end
(B-K+1).upto(B) do|i|
puts i
end
end
|
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,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
return bool ? y : n
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
if size2==-1
return Array.new(size1){init}
else
return Array.new(size2){Array.new(size1){init}}
end
end
A,B,K=get_i
if B-A<2*K
A.upto(B) do|i|
puts i
end
else
A.upto(A+K-1) do|i|
puts i
end
(B-K+1).upto(B) do|i|
puts i
end
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,149,182
| 1,149,183
|
u415400221
|
ruby
|
p03386
|
a,b,k = gets.split.map(&:to_i)
if b-a <= k*2
puts (a..b).to_a
else
puts (a..a+k-1).to_a|(b-k+1..b).to_a
end
|
a,b,k = gets.split.map(&:to_i)
if b-a < k*2
puts (a..b).to_a
else
puts (a..a+k-1).to_a|(b-k+1..b).to_a
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,149,344
| 1,149,345
|
u012110567
|
ruby
|
p03386
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans = []
if b < k
ans = [*a..b]
else
a.upto(a+k-1) do |i|
ans << i
end
b.downto(b-k+1) do |i|
ans << i
end
end
puts ans.sort.uniq
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans = []
if b-a < k
ans = [*a..b]
else
a.upto(a+k-1) do |i|
ans << i
end
b.downto(b-k+1) do |i|
ans << i
end
end
puts ans.sort.uniq
|
[
"control_flow.branch.if.condition.change"
] | 1,149,410
| 1,149,411
|
u466332671
|
ruby
|
p03386
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans = []
if a > k || b < k
ans = [*a..b]
else
a.upto(a+k-1) do |i|
ans << i
end
b.downto(b-k+1) do |i|
ans << i
end
end
puts ans.sort.uniq
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans = []
if b-a < k
ans = [*a..b]
else
a.upto(a+k-1) do |i|
ans << i
end
b.downto(b-k+1) do |i|
ans << i
end
end
puts ans.sort.uniq
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 1,149,412
| 1,149,411
|
u466332671
|
ruby
|
p03329
|
N = gets.to_i
m = N
N.times do |num|
cnt = 0
n = num
while n > 0
cnt += n % 6
n /= 6
end
n = N - num
while n > 0
cnt += n % 9
n /= 9
end
m = [m, cnt].min
end
puts m
|
N = gets.to_i
m = N
(N+1).times do |num|
cnt = 0
n = num
while n > 0
cnt += n % 6
n /= 6
end
n = N - num
while n > 0
cnt += n % 9
n /= 9
end
m = [m, cnt].min
end
puts m
|
[] | 1,149,578
| 1,149,579
|
u308793296
|
ruby
|
p03386
|
a, b, k = gets.split.map(&:to_i)
puts (b-a) - (2*k) > 0 ? (a..(a+k-1)).to_a + ((b-k+1)..b).to_a : (a..b).to_a
|
a, b, k = gets.split.map(&:to_i)
puts (b-a).succ - (2*k) > 0 ? (a..(a+k-1)).to_a + ((b-k+1)..b).to_a : (a..b).to_a
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 1,149,757
| 1,149,758
|
u561391668
|
ruby
|
p03386
|
a,b,k=gets.split.map &:to_i
if b-a<=2*k then
puts (b-a+1).times.map{|n|n.to_i+a}.join("\n")
else
puts k.times.map{|n|n.to_i+a}.join("\n")
puts k.times.map{|n|b-n.to_i}.reverse.join("\n")
end
|
a,b,k=gets.split.map &:to_i
if b-a+1 <= 2 * k then
puts (b-a+1).times.map{|n|n.to_i+a}.join("\n")
else
puts k.times.map{|n|n.to_i+a}.join("\n")
puts k.times.map{|n|b-n.to_i}.reverse.join("\n")
end
|
[
"control_flow.branch.if.condition.change"
] | 1,149,766
| 1,149,767
|
u025592199
|
ruby
|
p03386
|
a, b, k = gets.split.map(&:to_i)
ans = []
(a..[a + k, b].min).each { |i| ans << i }
([a, b - k].max..b).each { |i| ans << i }
ans.uniq.sort.each do |i|
puts i
end
|
a, b, k = gets.split.map(&:to_i)
ans = []
(a..[a + k - 1, b].min).each { |i| ans << i }
([a, b - k + 1].max..b).each { |i| ans << i }
ans.uniq.sort.each do |i|
puts i
end
|
[
"expression.operation.binary.add"
] | 1,149,817
| 1,149,818
|
u457499130
|
ruby
|
p03386
|
a=gets.split.map(&:to_i)
if a[0]+a[2]>a[1]-a[2]
puts [*a[0]..a[1]]
else
puts [*a[0]..a[0]+a[2]-1]
puts [*a[1]-a[2]..a[1]]
end
|
a=gets.split.map(&:to_i)
if a[0]+a[2]>a[1]-a[2]
puts [*a[0]..a[1]]
else
puts [*a[0]..a[0]+a[2]-1]
puts [*a[1]-a[2]+1..a[1]]
end
|
[
"expression.operation.binary.add"
] | 1,149,819
| 1,149,820
|
u585819925
|
ruby
|
p03386
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans=[]
for i in 0...k do
if a+i<=b then
ans.push(a+i)
end
end
for i in 0...k do
if ans.find { |n| n==b-i } == nil && b-i>=a then
ans.push(b-i)
end
end
ans.sort
for i in 0...ans.length do
p ans[i]
end
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
ans=[]
for i in 0...k do
if a+i<=b then
ans.push(a+i)
end
end
for i in 0...k do
if ans.find { |n| n==b-i } == nil && b-i>=a then
ans.push(b-i)
end
end
ans.sort!
for i in 0...ans.length do
p ans[i]
end
|
[
"call.suffix.change"
] | 1,150,444
| 1,150,445
|
u136817957
|
ruby
|
p03386
|
a,b,k=gets.split.map(&:to_i)
t=b-a+1
if t <= 2*k
p (a..b).to_a
else
p (a..a+k-1).to_a
p (b-k+1..b).to_a
end
|
a,b,k=gets.split.map(&:to_i)
t=b-a+1
if t <= 2*k
puts (a..b).to_a
else
puts (a..a+k-1).to_a
puts (b-k+1..b).to_a
end
|
[
"call.function.change",
"io.output.change"
] | 1,150,453
| 1,150,454
|
u056944756
|
ruby
|
p03386
|
a,b,k=gets.split(" ").map(&:to_i)
ary = Array.new()
for i in 0..k
if a+i<=b
puts a+i
ary.push(a+i)
end
end
for i in 0...k
puts b-(k-i)+1 if !ary.include?(b-(k-i)+1) && b-(k-i)+1 >= a
end
|
a,b,k=gets.split(" ").map(&:to_i)
ary = Array.new()
for i in 0...k
if a+i<=b
puts a+i
ary.push(a+i)
end
end
for i in 0...k
puts b-(k-i)+1 if !ary.include?(b-(k-i)+1) && b-(k-i)+1 >= a
end
|
[] | 1,150,610
| 1,150,611
|
u887087974
|
ruby
|
p03386
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
if a + k < b - k then
k.times do |i|
puts a + i
end
k.times do |i|
puts b - k + 1 + i
end
else
a.upto(b) do |i|
puts i
end
end
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
if a + k < b - k + 1 then
k.times do |i|
puts a + i
end
k.times do |i|
puts b - k + 1 + i
end
else
a.upto(b) do |i|
puts i
end
end
|
[
"control_flow.branch.if.condition.change"
] | 1,150,643
| 1,150,644
|
u910756197
|
ruby
|
p03387
|
array = gets.chomp.split(" ").map(&:to_i).sort!
cnt = array.last - array[1]
if (array[1] - array.first).even?
cnt += (array[1] - array.first) / 2
else
cnt += (array[1] - array.first) / 2 + 1
end
puts cnt
|
array = gets.chomp.split(" ").map(&:to_i).sort!
cnt = array.last - array[1]
if (array[1] - array.first).even?
cnt += (array[1] - array.first) / 2
else
cnt += (array[1] - array.first) / 2 + 2
end
puts cnt
|
[
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,150,916
| 1,150,917
|
u333374716
|
ruby
|
p03387
|
a = gets.split.map(&:to_i)
a.sort!
p a
cnt = 0
if (a[2] - a[1]) % 2 == 0
cnt += (a[2] - a[1]) / 2
else
cnt += (a[2]- a[1]) / 2 + 1
a[0] += 1
end
if(a[2] - a[0]) %2 == 0
cnt += (a[2] - a[0]) / 2
else
cnt += (a[2] - a[0]) / 2
cnt += 2
end
puts cnt
|
a = gets.split.map(&:to_i)
a.sort!
cnt = 0
if (a[2] - a[1]) % 2 == 0
cnt += (a[2] - a[1]) / 2
else
cnt += (a[2]- a[1]) / 2 + 1
a[0] += 1
end
if(a[2] - a[0]) %2 == 0
cnt += (a[2] - a[0]) / 2
else
cnt += (a[2] - a[0]) / 2
cnt += 2
end
puts cnt
|
[
"call.remove"
] | 1,151,074
| 1,151,075
|
u895795263
|
ruby
|
p03387
|
data = gets.split.map(&:to_i)
sum = data.inject(:+)
puts sum % 2 == data.max * 3 % 2 ? (data.max * 3 - sum) / 2 : ((data.max + 1 * 3 - sum)) / 2
|
data = gets.split.map(&:to_i)
sum = data.inject(:+)
puts sum % 2 == data.max * 3 % 2 ? (data.max * 3 - sum) / 2 : ((data.max + 1) * 3 - sum) / 2
|
[
"call.arguments.change"
] | 1,151,089
| 1,151,090
|
u503890246
|
ruby
|
p03387
|
A = gets.split.map(&:to_i).sort
o = A.map{|v| v%2}.inject(&:+)
ans = 0
if o == 1 || o == 2 then
ans++
3.times{|i| A[i] += 1 if A[i]%2 == (o == 1 ? 0 : 1) }
end
ans += A.map{|v| (A[2] - v) / 2}.inject(&:+)
puts ans
|
A = gets.split.map(&:to_i).sort
o = A.map{|v| v%2}.inject(&:+)
ans = 0
if o == 1 || o == 2 then
ans += 1
3.times{|i| A[i] += 1 if A[i]%2 == (o == 1 ? 0 : 1) }
end
ans += A.map{|v| (A[2] - v) / 2}.inject(&:+)
puts ans
|
[] | 1,151,177
| 1,151,178
|
u811309788
|
ruby
|
p03386
|
a, b, k = gets.split.map(&:to_i)
puts k.times.map { |i| [a + i, b - i] }.flatten.uniq.select{|e| a <= e && e <= b }.sort.join('\n')
|
a, b, k = gets.split.map(&:to_i)
puts k.times.map { |i| [a + i, b - i] }.flatten.uniq.select{|e| a <= e && e <= b }.sort.join("\n")
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 1,151,459
| 1,151,461
|
u814026219
|
ruby
|
p03386
|
a, b, k = gets.split.map(&:to_i)
ans_arr = []
(a..a+k).each do |i|
ans_arr << i
if i >= b
break
end
end
(-b..-b+k).each do |i|
ans_arr << -i
if -i <= a
break
end
end
ans_arr.uniq!
ans_arr.sort!
ans_arr.each do |n|
puts n
end
|
a, b, k = gets.split.map(&:to_i)
ans_arr = []
(a..a+k-1).each do |i|
ans_arr << i
if i >= b
break
end
end
(-b..-b+k-1).each do |i|
ans_arr << -i
if -i <= a
break
end
end
ans_arr.uniq!
ans_arr.sort!
ans_arr.each do |n|
puts n
end
|
[
"expression.operation.binary.add"
] | 1,151,560
| 1,151,561
|
u269725575
|
ruby
|
p03386
|
a,b,k = gets.split.map(&:to_i)
ans = []
[k,b-a].min.times{|i|
ans += [a+i,b-i]
}
ans.sort.uniq.each{|t|p t}
|
a,b,k = gets.split.map(&:to_i)
ans = []
[k,b-a+1].min.times{|i|
ans += [a+i,b-i]
}
ans.sort.uniq.each{|t|p t}
|
[
"expression.operation.binary.add"
] | 1,151,571
| 1,151,572
|
u397763977
|
ruby
|
p03386
|
a, b, k = gets.split.map(&:to_i)
arr = []
(a..b).each.with_index(0) do |e,i|
# puts "#{i} #{e}"
arr << a+i
arr << b-i
break if i == k-1
end
puts arr.sort.uniq!
|
a, b, k = gets.split.map(&:to_i)
arr = []
(a..b).each.with_index(0) do |e,i|
# puts "#{i} #{a+i} #{b+i}"
arr << a+i
arr << b-i
break if i == k-1
end
puts arr.sort!.uniq
|
[
"call.suffix.change",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 1,151,724
| 1,151,725
|
u633378318
|
ruby
|
p03386
|
a, b, k = gets.split.map(&:to_i)
len = b - a + 1
if k * 2 >= len
nums.each { |n| puts n }
else
nums = (a..a+k-1).to_a + (b-k+1..b).to_a
nums.each { |n| puts n }
end
|
a, b, k = gets.split.map(&:to_i)
len = b - a + 1
if k * 2 >= len
(a..b).each { |n| puts n }
else
nums = (a..a+k-1).to_a + (b-k+1..b).to_a
nums.each { |n| puts n }
end
|
[] | 1,151,726
| 1,151,727
|
u605315756
|
ruby
|
p03386
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b).abs
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.uniq!.sort!
for hoge in result do
puts hoge
end
end
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b).abs
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.uniq!
result.sort!
for hoge in result do
puts hoge
end
end
|
[
"call.add"
] | 1,151,783
| 1,151,784
|
u658389776
|
ruby
|
p03386
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b).abs
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.sort!
for hoge in result do
puts hoge
end
end
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b).abs
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.uniq!
result.sort!
for hoge in result do
puts hoge
end
end
|
[
"call.add"
] | 1,151,785
| 1,151,784
|
u658389776
|
ruby
|
p03386
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b)/2
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.sort!
for hoge in result do
puts hoge
end
end
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b).abs
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.uniq!
result.sort!
for hoge in result do
puts hoge
end
end
|
[
"call.add"
] | 1,151,786
| 1,151,784
|
u658389776
|
ruby
|
p03386
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a + b)/2
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.uniq!.sort!
for hoge in result do
puts hoge
end
end
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if c >= (a - b).abs
for i in a..b do
puts i
end
else
result = []
n = c - 1
for i in 0..n do
result.push a + i
result.push b - i
end
result.uniq!
result.sort!
for hoge in result do
puts hoge
end
end
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change",
"call.add"
] | 1,151,787
| 1,151,784
|
u658389776
|
ruby
|
p03386
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
if b - a <= k +1 then
for i in a..b do
puts i
end
else
for i in a..(a+k-1) do
puts i
end
for i in (b-k+1)..b do
puts i
end
end
|
a, b, k = gets.chomp.split(" ").map(&:to_i)
if b - a <= 2 * k - 2 then
for i in a..b do
puts i
end
else
for i in a..(a+k-1) do
puts i
end
for i in (b-k+1)..b do
puts i
end
end
|
[
"control_flow.branch.if.condition.change"
] | 1,151,803
| 1,151,804
|
u868089307
|
ruby
|
p03386
|
a,b,k = gets.chomp.split(" ").map(&:to_i)
forward = [*a..[a+k,b].min]
backward = [*[b-k+1,a].max..b]
puts (forward+backward).uniq
|
a,b,k = gets.chomp.split(" ").map(&:to_i)
forward = [*a...[a+k,b].min]
backward = [*[b-k+1,a].max..b]
puts (forward+backward).uniq
|
[] | 1,151,820
| 1,151,821
|
u872636244
|
ruby
|
p03393
|
def main(argv)
s = gets.chomp
n = s.size
if s == 'zyxwvutsrqponmlkjihgfedcba' then
puts (-1).to_s
return
end
if n < 26 then
f = [false] * 26
s.split('').each{ |c| f[c.ord - 'a'.ord] = true }
ch = ('a'.ord + f.find_index(false)).chr
puts (s + ch)
return
end
t = []
(n - 1).times do |i|
j = (n - 1) - i
t.push(s[j])
if s[j - 1] < s[j] then
t.sort.select!{ |c| c > s[j - 1] }
s = s[0...(j - 1)] + t[0]
break
end
end
puts s
end
if self.to_s == 'main' then
main(ARGV)
end
|
def main(argv)
s = gets.chomp
n = s.size
if s == 'zyxwvutsrqponmlkjihgfedcba' then
puts (-1).to_s
return
end
if n < 26 then
f = [false] * 26
s.split('').each{ |c| f[c.ord - 'a'.ord] = true }
ch = ('a'.ord + f.find_index(false)).chr
puts (s + ch)
return
end
t = []
(n - 1).times do |i|
j = (n - 1) - i
t.push(s[j])
if s[j - 1] < s[j] then
t = t.sort.select{ |c| c > s[j - 1] }
s = s[0...(j - 1)] + t[0]
break
end
end
puts s
end
if self.to_s == 'main' then
main(ARGV)
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,153,122
| 1,153,123
|
u198355306
|
ruby
|
p03393
|
S = gets.chomp
ans = nil
if S == "zyxwvutsrqponmlkjihgfedcba"
ans = -1
elsif S.length == 26
reversed_suffix = []
for i in 1..S.length
if !reversed_suffix.empty? && S[-i] < reversed_suffix[0]
ans = S[0..-i-1] + reversed_suffix.find {|char| S[-i] < char}
break
else
reversed_suffix << S[-i]
end
end
else
all = "abcdefghijklmnopqrstuvwxyz"
S.each_char do |char|
all.delete!(char)
end
ans = S + all[0]
end
puts ans
|
S = gets.chomp
ans = nil
if S == "zyxwvutsrqponmlkjihgfedcba"
ans = -1
elsif S.length == 26
reversed_suffix = []
for i in 1..S.length
if !reversed_suffix.empty? && S[-i] < reversed_suffix[-1]
ans = S[0..-i-1] + reversed_suffix.find {|char| S[-i] < char}
break
else
reversed_suffix << S[-i]
end
end
else
all = "abcdefghijklmnopqrstuvwxyz"
S.each_char do |char|
all.delete!(char)
end
ans = S + all[0]
end
puts ans
|
[
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"expression.operation.unary.add"
] | 1,153,247
| 1,153,248
|
u655122274
|
ruby
|
p03393
|
s = gets.chomp
if s.size < 26
puts s + ("a".."z").to_a.find{|v| !s.include?(v)}; exit
end
x = s[-1]
y = x
(s.size-1).times.reverse_each{|v|
if y < s[v]
y = s[v]; next
end
puts s[0..v] + s[v..-1].chars.select{|c| s[v] < c}.sort[0]; exit
}
puts -1
|
s = gets.chomp
if s.size < 26
puts s + ("a".."z").to_a.find{|v| !s.include?(v)}; exit
end
x = s[-1]
y = x
(s.size-1).times.reverse_each{|v|
if y < s[v]
y = s[v]; next
end
puts s[0...v] + s[v..-1].chars.select{|c| s[v] < c}.sort[0]; exit
}
puts -1
|
[
"call.arguments.change"
] | 1,153,546
| 1,153,547
|
u811309788
|
ruby
|
p03391
|
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
if(IS_DEBUG)
puts str
end
end
def dpp str
if(IS_DEBUG)
pp str
end
end
N,d=gets.chomp.split(' ').map{|n| n.to_i}
min = 10000000000
flg = false
sum = 0
1.upto(N){|d|
a,b=gets.chomp.split(' ').map{|n| n.to_i}
if(a > b && b < min)
min = b
flg = true
end
sum += a
}
if(flg)
puts sum-min
else
puts sum
end
|
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
if(IS_DEBUG)
puts str
end
end
def dpp str
if(IS_DEBUG)
pp str
end
end
N,d=gets.chomp.split(' ').map{|n| n.to_i}
min = 10000000000
flg = false
sum = 0
1.upto(N){|d|
a,b=gets.chomp.split(' ').map{|n| n.to_i}
if(a > b && b < min)
min = b
flg = true
end
sum += a
}
if(flg)
puts sum-min
else
puts 0
end
|
[
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change"
] | 1,153,850
| 1,153,851
|
u415591191
|
ruby
|
p03393
|
def swap!(list, a, b)
list[a], list[b] = list[b], list[a]
end
word = gets
alphabets = "abcdefghijklmnopqrstuvwxyz".split("")
words = word.split("")
ans = 0
found1 = 0
if (word == "zyxwvutsrqponmlkjihgfedcba\n") then
ans = -1
elsif (words.length < 26) then
alphabets.each{|c|
if(!words.include?(c))then
words.delete("\n")
words.push(c)
words.push("\n")
ans = words.join("")
break
end
}
else
biggers = Array.new
#(words.length-1).downto(0) { |i|
# done = false
# (words.length-1).downto(0) { | j |
# puts "i=" + i.to_s + " j=" + j.to_s
## if(words[i] < words[j]) then
# biggers.push(j)
# found1 = i
# done = true
# end
# }
#
# if(done) then
# break
# end
(25).downto(0) { |i|
if(words[i-1] < words[i]) then
found1 = i
break
end
}
for i in found1..25 do
if(words[found1-1] < words[i]) then
biggers.push(words[i])
end
end
rep = biggers.min
repindex = words.find_index{|i| i == rep}
puts repindex.to_s
swap!(words, found1-1, repindex)
findx = words.find_index{|i| i == rep}
zenhan = words.slice(0..found1-1)
kouhan = words.slice(found1..findx)
kouhan.sort!
tmp = Array.new
tmp.concat(zenhan)
tmp.concat(kouhan)
ans = tmp.join("")
end
puts ans
|
def swap!(list, a, b)
list[a], list[b] = list[b], list[a]
end
word = gets
alphabets = "abcdefghijklmnopqrstuvwxyz".split("")
words = word.split("")
ans = 0
found1 = 0
if (word == "zyxwvutsrqponmlkjihgfedcba\n") then
ans = -1
elsif (words.length < 26) then
alphabets.each{|c|
if(!words.include?(c))then
words.delete("\n")
words.push(c)
words.push("\n")
ans = words.join("")
break
end
}
else
biggers = Array.new
#(words.length-1).downto(0) { |i|
# done = false
# (words.length-1).downto(0) { | j |
# puts "i=" + i.to_s + " j=" + j.to_s
## if(words[i] < words[j]) then
# biggers.push(j)
# found1 = i
# done = true
# end
# }
#
# if(done) then
# break
# end
(25).downto(0) { |i|
if(words[i-1] < words[i]) then
found1 = i
break
end
}
for i in found1..25 do
if(words[found1-1] < words[i]) then
biggers.push(words[i])
end
end
rep = biggers.min
repindex = words.find_index{|i| i == rep}
#puts repindex.to_s
swap!(words, found1-1, repindex)
findx = words.find_index{|i| i == rep}
zenhan = words.slice(0..found1-1)
kouhan = words.slice(found1..findx)
kouhan.sort!
tmp = Array.new
tmp.concat(zenhan)
tmp.concat(kouhan)
ans = tmp.join("")
end
puts ans
|
[
"call.remove"
] | 1,154,097
| 1,154,098
|
u658559310
|
ruby
|
p03399
|
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
if a >= b && c >= d
puts b + d
elsif a <= b && c >= d
puts s + d
elsif a >= b && c <= d
puts b + c
elsif a <= b && c <= d
puts a + c
end
|
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
if a >= b && c >= d
puts b + d
elsif a <= b && c >= d
puts a + d
elsif a >= b && c <= d
puts b + c
elsif a <= b && c <= d
puts a + c
end
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,154,752
| 1,154,753
|
u866325115
|
ruby
|
p03399
|
A,B,C,D = gets.split.map(&:to_i)
p [A,B].min + [C,D].min
|
A,B,C,D = `dd`.split.map(&:to_i)
p [A,B].min + [C,D].min
|
[
"assignment.value.change"
] | 1,154,950
| 1,154,951
|
u670503797
|
ruby
|
p03400
|
n = gets.to_i
sum = 0
d,x = gets.split.map(&:to_i)
for num in 1..n do
a = gets.to_i
sum += d/a +1
end
p sum + x
|
n = gets.to_i
sum = 0
d,x = gets.split.map(&:to_i)
for num in 1..n do
a = gets.to_i
sum += (d-1)/a +1
end
p sum + x
|
[] | 1,155,264
| 1,155,265
|
u945412921
|
ruby
|
p03400
|
gets;d,x=gets.split.map &:to_i;$<.map{|c|x+=1+(d-1)/c.to_i};p c
|
gets;d,x=gets.split.map &:to_i;$<.map{|c|x+=1+(d-1)/c.to_i};p x
|
[
"identifier.change",
"call.arguments.change"
] | 1,155,527
| 1,155,528
|
u657913472
|
ruby
|
p03400
|
N,D,X,*A=`dd`.split.map &:to_i;r=0;A.map{|e|r+=~-D/e+1};p r
|
N,D,r,*A=`dd`.split.map &:to_i;A.map{|e|r+=~-D/e+1};p r
|
[
"assignment.variable.change"
] | 1,155,724
| 1,155,725
|
u280667879
|
ruby
|
p03401
|
n=gets.to_i
a=[0]+gets.split.map(&:to_i)+[0]
d=0
(n+1).times do|i|
d+=(a[i+1]-a[i]).abs
end
p d
n.times do|i|
p d-(a[i+1]-a[i]).abs-(a[i+2]-a[i+1]).abs+(a[i+2]-a[i]).abs
end
|
n=gets.to_i
a=[0]+gets.split.map(&:to_i)+[0]
d=0
(n+1).times do|i|
d+=(a[i+1]-a[i]).abs
end
n.times do|i|
p d-(a[i+1]-a[i]).abs-(a[i+2]-a[i+1]).abs+(a[i+2]-a[i]).abs
end
|
[
"call.remove"
] | 1,156,033
| 1,156,034
|
u785521224
|
ruby
|
p03401
|
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
asum = a[0].abs + a[n-1].abs
(n-1).times do |i|
asum += (a[i + 1] - a[i]).abs
end
p asum
puts
n.times do |i|
if i == 0 then
puts asum - (a[1] - a[0]).abs - a[0].abs + a[1].abs
elsif i == n -1
puts asum - (a[n-1] - a[n-2]).abs - a[n - 1].abs + a[n - 2].abs
else
puts asum - (a[i + 1]- a[i]).abs - (a[i] - a[i - 1]).abs + (a[i + 1] - a[i - 1]).abs
end
end
|
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
asum = a[0].abs + a[n-1].abs
(n-1).times do |i|
asum += (a[i + 1] - a[i]).abs
end
n.times do |i|
if i == 0 then
puts asum - (a[1] - a[0]).abs - a[0].abs + a[1].abs
elsif i == n -1
puts asum - (a[n-1] - a[n-2]).abs - a[n - 1].abs + a[n - 2].abs
else
puts asum - (a[i + 1]- a[i]).abs - (a[i] - a[i - 1]).abs + (a[i + 1] - a[i - 1]).abs
end
end
|
[
"call.remove",
"io.output.change"
] | 1,156,132
| 1,156,133
|
u910756197
|
ruby
|
p03403
|
N = gets.chomp.to_i
spots = gets.chomp.split(" ").map(&:to_i)
spots.unshift(0).push(0)
distance = 0
spots.inject { |from, current| distance += (spot - current).abs; current }
(1..N).each do |i|
from = spots[i-1]
current = spots[i]
to = spots[i+1]
puts distance - (((to - current).abs + (current - from).abs) - (to - from).abs)
end
|
N = gets.chomp.to_i
spots = gets.chomp.split(" ").map(&:to_i)
spots.unshift(0).push(0)
distance = 0
spots.inject { |from, current| distance += (current - from).abs; current }
(1..N).each do |i|
from = spots[i-1]
current = spots[i]
to = spots[i+1]
puts distance - (((to - current).abs + (current - from).abs) - (to - from).abs)
end
|
[
"expression.operation.binary.remove"
] | 1,156,683
| 1,156,684
|
u421511053
|
ruby
|
p03407
|
a, b, c = gets.split.map &:to_i
puts c - a - b > 0 ? :Yes: :No
|
a, b, c = gets.split.map &:to_i
puts c - a - b > 0 ? :No: :Yes
|
[] | 1,157,715
| 1,157,716
|
u489339677
|
ruby
|
p03407
|
a, b, c = gets.split.map(&:to_i)
(a+b <= c) ? (puts "Yes"):(puts "No")
|
a, b, c = gets.split.map(&:to_i)
(a+b >= c) ? (puts "Yes"):(puts "No")
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,158,006
| 1,158,007
|
u326891688
|
ruby
|
p03407
|
a,b,c = gets.chomp.split(" ").map(&:to_i)
if a + b*2 >= c
print("Yes")
else
print("No")
end
|
a,b,c = gets.chomp.split(" ").map(&:to_i)
if a + b >= c
print("Yes")
else
print("No")
end
|
[
"expression.operation.binary.remove"
] | 1,158,220
| 1,158,221
|
u691896522
|
ruby
|
p03407
|
a,b,c = gets.chomp.split(" ").map(&:to_i)
if a + b*2 <= c
print("Yes")
else
print("No")
end
|
a,b,c = gets.chomp.split(" ").map(&:to_i)
if a + b >= c
print("Yes")
else
print("No")
end
|
[
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 1,158,222
| 1,158,221
|
u691896522
|
ruby
|
p03407
|
a, b, c = gets.split.map(&:to_s)
puts a + b >= c ? "Yes" : "No"
|
a, b, c = gets.split.map(&:to_i)
puts a + b >= c ? "Yes" : "No"
|
[
"assignment.value.change",
"call.arguments.change"
] | 1,158,479
| 1,158,480
|
u653737129
|
ruby
|
p03407
|
A, B, C = gets.split.map(&:to_i)
if A * 2 + B * 2 >= C
puts 'Yes'
else
puts 'No'
end
|
A, B, C = gets.split.map(&:to_i)
if A + B >= C
puts 'Yes'
else
puts 'No'
end
|
[
"expression.operation.binary.remove"
] | 1,158,550
| 1,158,551
|
u503890246
|
ruby
|
p03407
|
a,b,c = gets.chomp.split(" ").map(&:to_i)
if a + b >= c then
puts 'YES'
else
puts 'NO'
end
|
a,b,c = gets.chomp.split(" ").map(&:to_i)
if a + b >= c then
puts 'Yes'
else
puts 'No'
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,158,556
| 1,158,557
|
u257668305
|
ruby
|
p03407
|
A, B, C = gets.split.map(&:to_i)
puts (A+B > C) ? 'Yes' : 'No'
|
A, B, C = gets.split.map(&:to_i)
puts (A+B >= C) ? 'Yes' : 'No'
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,158,570
| 1,158,571
|
u320576758
|
ruby
|
p03407
|
a, b, c = gets.split.map(&:to_i)
p a + b >= c ? 'Yes' : 'No'
|
a, b, c = gets.split.map(&:to_i)
puts a + b >= c ? 'Yes' : 'No'
|
[
"call.function.change",
"io.output.change"
] | 1,158,585
| 1,158,586
|
u262994359
|
ruby
|
p03407
|
A,B,C = gets.split.map(&:to_i)
if A+B <= C
puts("Yes")
else puts("No")
end
|
A,B,C = gets.split.map(&:to_i)
if A+B >= C
puts("Yes")
else puts("No")
end
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,158,719
| 1,158,720
|
u241469130
|
ruby
|
p03407
|
a, b, c = gets.chomp.split &:to_i
if a + b >= c
puts 'Yes'
else
puts 'No'
end
|
a, b, c = gets.chomp.split.map &:to_i
if a + b >= c
puts 'Yes'
else
puts 'No'
end
|
[
"call.add"
] | 1,159,063
| 1,159,064
|
u090225501
|
ruby
|
p03407
|
a,b,c = gets.split.map &:to_i
a+b >= c ? "Yes": "No"
|
a,b,c = gets.split.map &:to_i
puts (a+b) >= c ? "Yes": "No"
|
[
"call.add",
"control_flow.branch.if.condition.change"
] | 1,159,120
| 1,159,121
|
u831999711
|
ruby
|
p03407
|
#!/usr/bin/env ruby
a, b, c = gets.split.map {|n| n.to_i }
if c <= a + b * 2
puts 'Yes'
else
puts 'No'
end
|
#!/usr/bin/env ruby
a, b, c = gets.split.map {|n| n.to_i }
if c <= (a + b)
puts 'Yes'
else
puts 'No'
end
|
[
"control_flow.branch.if.condition.change"
] | 1,159,132
| 1,159,133
|
u614596051
|
ruby
|
p03407
|
a,b,c=gets.split.map(&:to_i)
puts a+b<=c ? "Yes" : "No"
|
a,b,c=gets.split.map(&:to_i)
puts a+b>=c ? "Yes" : "No"
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,159,218
| 1,159,219
|
u726630158
|
ruby
|
p03407
|
a,b,c=gets.split.map(&:to_i)
puts (((a+b)-c).negative?) ? 'NO' : 'YES'
|
a,b,c=gets.split.map(&:to_i)
puts (((a+b)-c).negative?) ? 'No' : 'Yes'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,159,659
| 1,159,662
|
u656701701
|
ruby
|
p03407
|
a,b,c=gets.split(" ").map(&:to_i)
puts a+b*2<c ? "No":"Yes"
|
a,b,c=gets.split(" ").map(&:to_i)
puts a+b<c ? "No":"Yes"
|
[
"expression.operation.binary.remove"
] | 1,159,887
| 1,159,888
|
u562793957
|
ruby
|
p03407
|
a, b, o = STDIN.read.split(' ').map{|e|Integer(e)}
a + b >= o ? 'Yes' : 'No'
|
a, b, o = STDIN.read.split(' ').map{|e|Integer(e)}
puts a + b >= o ? 'Yes' : 'No'
|
[
"io.output.change",
"call.add"
] | 1,159,924
| 1,159,925
|
u188969045
|
ruby
|
p03407
|
a, b, o = STDIN.read.split(' ').map{|e|Integer(e)}
puts a + b <= o ? 'Yes' : 'No'
|
a, b, o = STDIN.read.split(' ').map{|e|Integer(e)}
puts a + b >= o ? 'Yes' : 'No'
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,159,926
| 1,159,925
|
u188969045
|
ruby
|
p03407
|
A ,B,C = gets.chomp.split(/ /).map(&:to_i);
if A+B > C
print "Yes"
else
print "No"
end
|
A ,B,C = gets.chomp.split(/ /).map(&:to_i);
if A+B >= C
print "Yes"
else
print "No"
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,159,805
| 1,159,807
|
u459590249
|
ruby
|
p03408
|
N = gets.to_i
s = N.times.map { gets.chomp }
M = gets.to_i
t = M.times.map { gets.chomp }
m = s.inject({}) {|acc, str|
acc[str] ||= 0
acc[str] += 1
acc
}
m = t.inject(m) {|acc, str|
acc[str] ||= 0
acc[str] -= 1
acc
}
puts m.values.max
|
N = gets.to_i
s = N.times.map { gets.chomp }
M = gets.to_i
t = M.times.map { gets.chomp }
m = s.inject({}) {|acc, str|
acc[str] ||= 0
acc[str] += 1
acc
}
m = t.inject(m) {|acc, str|
acc[str] ||= 0
acc[str] -= 1
acc
}
puts [m.values.max, 0].max
|
[
"call.arguments.change",
"call.add"
] | 1,159,980
| 1,159,981
|
u039293076
|
ruby
|
p03408
|
N = gets.to_i
words = Hash.new(0)
N.times do
word = gets.chomp
words[word] += 1
end
M = gets.to_i
M.times do
word = gets.chomp
words[word] -= 1
end
puts words.values.max
|
N = gets.to_i
words = Hash.new(0)
N.times do
word = gets.chomp
words[word] += 1
end
M = gets.to_i
M.times do
word = gets.chomp
words[word] -= 1
end
puts [words.values.max, 0].max
|
[
"call.arguments.change",
"call.add"
] | 1,160,943
| 1,160,944
|
u548834738
|
ruby
|
p03408
|
s = Hash.new(0)
t = Hash.new(0)
gets.to_i.times do
s[gets.chomp] += 1
end
gets.to_i.times do
t[gets.chomp] += 1
end
ans = 0
s.each do |k,v|
ans += [v-t[k],0].max
end
puts ans
|
s = Hash.new(0)
t = Hash.new(0)
gets.to_i.times do
s[gets.chomp] += 1
end
gets.to_i.times do
t[gets.chomp] += 1
end
ans = 0
s.each do |k,v|
ans = [ans,v-t[k]].max
end
puts ans
|
[
"assignment.value.change",
"literal.array.change"
] | 1,161,280
| 1,161,281
|
u506255180
|
ruby
|
p03408
|
s=gets.to_i.times.map{gets.chomp}
t=gets.to_i.times.map{gets.chomp}
puts [s.uniq.map{|x| s.count(x) - t.count(y)}.max, 0].max
|
s=gets.to_i.times.map{gets.chomp}
t=gets.to_i.times.map{gets.chomp}
puts [s.uniq.map{|x| s.count(x) - t.count(x)}.max, 0].max
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,161,315
| 1,161,316
|
u056944756
|
ruby
|
p03408
|
N = gets.chomp.to_i
a = []
for i in 1..N do
str = gets.chomp
a.push str
end
b = []
M = gets.chomp.to_i
for i in 1..N do
str = gets.chomp
b.push str
end
best = 0
for str in a do
price = a.count(str) - b.count(str)
best = price if price > best
end
puts best
|
N = gets.chomp.to_i
a = []
for i in 1..N do
str = gets.chomp
a.push str
end
b = []
M = gets.chomp.to_i
for i in 1..M do
str = gets.chomp
b.push str
end
best = 0
for str in a do
price = a.count(str) - b.count(str)
best = price if price > best
end
puts best
|
[] | 1,161,365
| 1,161,366
|
u658389776
|
ruby
|
p03408
|
hash = Hash.new
n1 = gets.to_i
[*0..(n1-1)].each{|i|
str = gets.chomp.to_s
if hash[str] == nil then
hash[str] = 1
else
hash[str] += 1
end
}
n2 = gets.to_i
[*0..(n2-1)].each{|i|
str = gets.chomp.to_s
if hash[str] == nil then
hash[str] = -1
else
hash[str] -= 1
end
}
score = 0
hash.each{|key, val|
if val > 0 then
score += val
end
}
puts score
|
hash = Hash.new
n1 = gets.to_i
[*0..(n1-1)].each{|i|
str = gets.chomp.to_s
if hash[str] == nil then
hash[str] = 1
else
hash[str] += 1
end
}
n2 = gets.to_i
[*0..(n2-1)].each{|i|
str = gets.chomp.to_s
if hash[str] == nil then
hash[str] = -1
else
hash[str] -= 1
end
}
score = 0
hash.each{|key, val|
if val > score then
score = val
end
}
puts score
|
[
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 1,161,395
| 1,161,396
|
u998662234
|
ruby
|
p03408
|
s=gets.to_i.times.map{gets.chomp}
t=gets.to_i.times.map{gets.chomp}
puts s.map{|w|s.count(w)-t.count(w)}.max
|
s=gets.to_i.times.map{gets.chomp}
t=gets.to_i.times.map{gets.chomp}
puts s.map{|w|s.count(w)-t.count(w)}.push(0).max
|
[
"call.add"
] | 1,161,433
| 1,161,434
|
u726630158
|
ruby
|
p03408
|
N = gets.to_i
blue_card_str = []
N.times do
blue_card_str << gets.chomp
end
M = gets.to_i
red_card_str = []
M.times do
red_card_str << gets.chomp
end
max = 0
blue_card_str.each do |str|
blue_num = blue_card_str.count(str)
red_num = red_card_str.count(str)
max = blue_num - red_num > max ? blue_num - red_num : 0
end
puts max
|
N = gets.to_i
blue_card_str = []
N.times do
blue_card_str << gets.chomp
end
M = gets.to_i
red_card_str = []
M.times do
red_card_str << gets.chomp
end
max = 0
blue_card_str.each do |str|
blue_num = blue_card_str.count(str)
red_num = red_card_str.count(str)
max = blue_num - red_num > max ? blue_num - red_num : max
end
puts max
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 1,161,512
| 1,161,513
|
u497542289
|
ruby
|
p03407
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if (a + b) > c
puts "Yes"
else
puts "No"
end
|
a,b,c = gets.chomp.split(' ').map{|n| n.to_i}
if (a + b) >= c
puts "Yes"
else
puts "No"
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,161,741
| 1,161,742
|
u658389776
|
ruby
|
p03407
|
a,b,c=gets.split.map &:to_i;puts a+b==c ? :Yes : :No
|
a,b,c=gets.split.map &:to_i;puts a+b>=c ? :Yes : :No
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,161,842
| 1,161,843
|
u598016178
|
ruby
|
p03407
|
y = gets.chomp.split(" ").map(&:to_i)
p y[0] + y[1] >= y[2] ? "Yes" : "No"
|
y = gets.chomp.split(" ").map(&:to_i)
puts y[0] + y[1] >= y[2] ? "Yes" : "No"
|
[
"call.function.change",
"io.output.change"
] | 1,161,846
| 1,161,847
|
u076590868
|
ruby
|
p03407
|
a,b, c = gets.chomp.split(" ").map(&:to_i);
st = (c < a + b ? 'Yes' : 'No')
print(st)
|
# スペース区切りの整数の入力
a, b,c=gets.chomp.split(" ").map(&:to_i);
# 文字列の入力
st = (c <= a+b ? 'Yes' : 'No' )
print(st)
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 1,161,877
| 1,161,878
|
u025879810
|
ruby
|
p03409
|
n = gets.to_i
reds = []
blues = []
n.times { reds << gets.split.map(&:to_i) }
n.times { blues << gets.split.map(&:to_i) }
reds.sort! { |a, b| b[0] <=> a[0] }
blues.sort! { |a, b| a[1] <=> b[1] }
blues.each do |blue_x, blue_y|
if index = reds.find_index { |red_x, red_y| red_x < blue_x && red_y << blue_y }
reds.delete_at(index)
end
end
puts n - reds.size
|
n = gets.to_i
reds = []
blues = []
n.times { reds << gets.split.map(&:to_i) }
n.times { blues << gets.split.map(&:to_i) }
reds.sort! { |a, b| b[0] <=> a[0] }
# blue の y が小さい順に見る
blues.sort! { |a, b| a[1] <=> b[1] }
blues.each do |blue_x, blue_y|
# red の x が大きい順に見て、条件に合致したら削除
# この時、y の値は条件に合致すれば何でも良い
# (blue の y は小さい順に見ているため)
if index = reds.find_index { |red_x, red_y| red_x < blue_x && red_y < blue_y }
reds.delete_at(index)
end
end
puts n - reds.size
|
[
"misc.typo",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 1,162,021
| 1,162,022
|
u653737129
|
ruby
|
p03409
|
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}.sort_by{|i,j|i}.reverase
c = n.times.map{gets.split.map(&:to_i)}.sort_by{|i,j|j}
ans = 0
n.times do |i|
min = 1000
n.times do |j|
if a[i][0] < c[j][0] && a[i][1] < c[j][1]
ans += 1
c[j] = [-1,-1]
break
end
end
end
puts ans
|
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}.sort_by{|i,j|i}.reverse
c = n.times.map{gets.split.map(&:to_i)}.sort_by{|i,j|j}
ans = 0
n.times do |i|
min = 1000
n.times do |j|
if a[i][0] < c[j][0] && a[i][1] < c[j][1]
ans += 1
c[j] = [-1,-1]
break
end
end
end
puts ans
|
[
"assignment.value.change",
"identifier.change"
] | 1,162,242
| 1,162,243
|
u506255180
|
ruby
|
p03408
|
map = {}
N = gets.chomp.to_i
for n in 0...N
key = gets.chomp
if map.include?(key)
map[key] += 1
else
map[key] = 1
end
end
M = gets.chomp.to_i
for m in 0...M
key = gets.chomp
if map.include?(key)
map[key] -= 1
else
map[key] = -1
end
end
puts map.max{ |x, y| x[1] <=> y[1] }[1]
|
map = {"" => 0}
N = gets.chomp.to_i
for n in 0...N
key = gets.chomp
if map.include?(key)
map[key] += 1
else
map[key] = 1
end
end
M = gets.chomp.to_i
for m in 0...M
key = gets.chomp
if map.include?(key)
map[key] -= 1
else
map[key] = -1
end
end
puts map.max{ |x, y| x[1] <=> y[1] }[1]
|
[] | 1,162,302
| 1,162,303
|
u037981383
|
ruby
|
p03408
|
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b); a > b ? a : b end
def min(a,b); a < b ? a : b end
def swap(a,b); a, b = b, a end
def gif; gets.to_i end
def gff; gets.to_f end
def gsf; gets.chomp end
def gi; gets.split.map(&:to_i) end
def gf; gets.split.map(&:to_f) end
def gs; gets.chomp.split.map(&:to_s) end
def gc; gets.chomp.split('') end
def pr(num); num.prime_division end
def pr?(num); Prime.prime?(num) end
def digit(num); num.to_s.length end
def array(s,ini=nil); Array.new(s){ini} end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end
def rep(num); num.times{|i|yield(i)} end
def repl(st,en,n=1); st.step(en,n){|i|yield(i)} end
n = gif
s = []
rep n do
s << gsf
end
m = gif
t = []
rep m do
t << gsf
end
list = (s + t).uniq
mx = -INF
list.each do |l|
mx = max mx,s.count(l)-t.count(l)
end
puts mx
|
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b); a > b ? a : b end
def min(a,b); a < b ? a : b end
def swap(a,b); a, b = b, a end
def gif; gets.to_i end
def gff; gets.to_f end
def gsf; gets.chomp end
def gi; gets.split.map(&:to_i) end
def gf; gets.split.map(&:to_f) end
def gs; gets.chomp.split.map(&:to_s) end
def gc; gets.chomp.split('') end
def pr(num); num.prime_division end
def pr?(num); Prime.prime?(num) end
def digit(num); num.to_s.length end
def array(s,ini=nil); Array.new(s){ini} end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end
def rep(num); num.times{|i|yield(i)} end
def repl(st,en,n=1); st.step(en,n){|i|yield(i)} end
n = gif
s = []
rep n do
s << gsf
end
m = gif
t = []
rep m do
t << gsf
end
list = (s + t).uniq
mx = 0
list.each do |l|
mx = max mx,s.count(l)-t.count(l)
end
puts mx
|
[
"assignment.value.change",
"expression.operation.unary.remove"
] | 1,162,337
| 1,162,338
|
u988228861
|
ruby
|
p03408
|
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b); a > b ? a : b end
def min(a,b); a < b ? a : b end
def swap(a,b); a, b = b, a end
def gif; gets.to_i end
def gff; gets.to_f end
def gsf; gets.chomp end
def gi; gets.split.map(&:to_i) end
def gf; gets.split.map(&:to_f) end
def gs; gets.chomp.split.map(&:to_s) end
def gc; gets.chomp.split('') end
def pr(num); num.prime_division end
def pr?(num); Prime.prime?(num) end
def digit(num); num.to_s.length end
def array(s,ini=nil); Array.new(s){ini} end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end
def rep(num); num.times{|i|yield(i)} end
def repl(st,en,n=1); st.step(en,n){|i|yield(i)} end
n = gif
s = []
rep n do
s << gsf
end
m = gif
t = []
rep m do
t << gsf
end
list = s.uniq
mx = -INF
list.each do |l|
mx = max mx,s.count(l)-t.count(l)
end
puts mx
|
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b); a > b ? a : b end
def min(a,b); a < b ? a : b end
def swap(a,b); a, b = b, a end
def gif; gets.to_i end
def gff; gets.to_f end
def gsf; gets.chomp end
def gi; gets.split.map(&:to_i) end
def gf; gets.split.map(&:to_f) end
def gs; gets.chomp.split.map(&:to_s) end
def gc; gets.chomp.split('') end
def pr(num); num.prime_division end
def pr?(num); Prime.prime?(num) end
def digit(num); num.to_s.length end
def array(s,ini=nil); Array.new(s){ini} end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}} end
def rep(num); num.times{|i|yield(i)} end
def repl(st,en,n=1); st.step(en,n){|i|yield(i)} end
n = gif
s = []
rep n do
s << gsf
end
m = gif
t = []
rep m do
t << gsf
end
list = (s + t).uniq
mx = 0
list.each do |l|
mx = max mx,s.count(l)-t.count(l)
end
puts mx
|
[
"assignment.value.change",
"expression.operation.unary.remove"
] | 1,162,339
| 1,162,338
|
u988228861
|
ruby
|
p03408
|
def card_list()
cards=[]
STDIN.gets.to_i.times do |i|
cards.push STDIN.gets.chomp
end
cards
end
blue_cards=card_list
red_cards=card_list
result=blue_cards.uniq.map{|i| blue_cards.count{|j| j == i} - red_cards.count{|j| j ==i}}.max
if result > 0
puts result
else
0
end
|
def card_list()
cards=[]
STDIN.gets.to_i.times do |i|
cards.push STDIN.gets.chomp
end
cards
end
blue_cards=card_list
red_cards=card_list
result=blue_cards.uniq.map{|i| blue_cards.count{|j| j == i} - red_cards.count{|j| j ==i}}.max
if result > 0
puts result
else
puts 0
end
|
[
"io.output.change",
"call.add"
] | 1,162,418
| 1,162,419
|
u702652578
|
ruby
|
p03409
|
#!/usr/bin/ruby
N=gets.to_i
r=0
(2*N).times.map{|i|gets.split.map(&:to_i)+[i/N]}.sort.each{|x,y,c|
if c==1
A<<y
else
k=-1
ki=-1
A.each_with_index{|z,i|
if k<z && z<y
k=z
ki=i
end
}
if ki>=0
A.delete_at(ki)
r+=1
end
end
}
p r
|
#!/usr/bin/ruby
N=gets.to_i
r=0
A=[]
(2*N).times.map{|i|gets.split.map(&:to_i)+[i/N]}.sort.each{|x,y,c|
if c==0
A<<y
else
k=-1
ki=-1
A.each_with_index{|z,i|
if k<z && z<y
k=z
ki=i
end
}
if ki>=0
A.delete_at(ki)
r+=1
end
end
}
p r
|
[
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,162,452
| 1,162,453
|
u280667879
|
ruby
|
p03411
|
gets;A=$<.map{|s|s.split.map &:to_i};p A.pop(eval$_).sort.count{|x,y|A.delete A.sort_by{|x,y|[y,x]}.find{|z,t|x>z&&y>t}}
|
gets;A=$<.map{|s|s.split.map &:to_i};p A.pop(eval$_).sort.count{|x,y|A.delete A.sort_by{|x,y|-y}.find{|z,t|x>z&&y>t}}
|
[
"call.arguments.change"
] | 1,163,275
| 1,163,276
|
u657913472
|
ruby
|
p03415
|
ans = ''
3.times do
ans += gets[1]
end
puts ans
|
ans = ''
3.times do |i|
ans += gets[i]
end
puts ans
|
[
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change"
] | 1,163,627
| 1,163,628
|
u320576758
|
ruby
|
p03415
|
puts (_=`dd`)[0]+_[5]+_[-1]
|
puts (_=`dd`)[0]+_[5]+_[-2]
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,163,684
| 1,163,686
|
u264508862
|
ruby
|
p03415
|
p gets[0] + gets[1] + gets[2]
|
puts gets[0] + gets[1] + gets[2]
|
[
"call.function.change",
"io.output.change"
] | 1,163,871
| 1,163,872
|
u118284895
|
ruby
|
p03415
|
proc{|a,b,c| puts a[0]+b[1]+c[2]}.call($stdin.gets.split("¥n"))
|
proc{|a,b,c| puts a[0]+b[1]+c[2]}.call($stdin.read.split("\n"))
|
[
"identifier.change",
"call.arguments.change",
"literal.string.change",
"io.output.change",
"io.output.newline.add"
] | 1,163,886
| 1,163,887
|
u534173972
|
ruby
|
p03415
|
strs = ""
3.times do |i|
strs < gets.to_s[i]
end
print(strs)
|
strs = ""
3.times do |i|
strs += gets[i]
end
print(strs)
|
[
"expression.operation.binary.change",
"call.remove"
] | 1,163,888
| 1,163,889
|
u922487073
|
ruby
|
p03416
|
a,b = gets.chomp.split(' ').map(&:to_i)
ans = 0
while a < b
s = a.to_s.chars
if s[0] == s[4] && s[1] == s[3]
ans += 1
end
a += 1
end
puts ans
|
a,b = gets.chomp.split(' ').map(&:to_i)
ans = 0
while a <= b
s = a.to_s.chars
if s[0] == s[4] && s[1] == s[3]
ans += 1
end
a += 1
end
puts ans
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 1,164,516
| 1,164,517
|
u059126963
|
ruby
|
p03416
|
a, b = gets.split.map(&:to_i)
ans = a.upto(b).count do |n|
xa = n / 1_000 % 10
xb = n % 10
ya = n / 10 % 10
yb = n / 10_000 % 10
xa == xb && ya == yb
end
puts ans
|
a, b = gets.split.map(&:to_i)
ans = a.upto(b).count do |n|
xa = n / 10_000 % 10
xb = n % 10
ya = n / 10 % 10
yb = n / 1_000 % 10
xa == xb && ya == yb
end
puts ans
|
[
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,164,744
| 1,164,745
|
u889326464
|
ruby
|
p03416
|
a,b = gets.split.map(&:to_i)
ctr = 0
(a..b).to_a.each do |n|
if n.to_s[0] == n.to_s[-1]
if n.to_s[1] == n.to_s[-2]
ctr += 1
end
else
exit
end
end
puts ctr
|
a,b = gets.split.map(&:to_i)
ctr = 0
(a..b).to_a.each do |n|
if n.to_s[0] == n.to_s[-1]
if n.to_s[1] == n.to_s[-2]
ctr += 1
end
else
next
end
end
puts ctr
|
[] | 1,164,970
| 1,164,971
|
u012110567
|
ruby
|
p03416
|
a,b = gets.split.map(&:to_i)
cnt = 0
(a..b).each do |num|
renum = num.to_s.split("").reverse.join.map(&:to_i)
cnt += 1 if num == renum
end
puts cnt
|
a,b = gets.split.map(&:to_i)
cnt = 0
(a..b).each do |num|
renum = num.to_s.split("").reverse.join.to_i
cnt += 1 if num == renum
end
puts cnt
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 1,164,978
| 1,164,979
|
u809809975
|
ruby
|
p03416
|
a,b = gets.chomp.split(" ").map(&:to_i)
cnt = 0
(a+1...b).each do |number|
if number.to_s.split("").join.to_i == number.to_s.split("").reverse.join.to_i
cnt += 1
end
end
puts cnt
|
a,b = gets.chomp.split(" ").map(&:to_i)
cnt = 0
(a..b).each do |number|
if number.to_s.split("").join.to_i == number.to_s.split("").reverse.join.to_i
cnt += 1
end
end
puts cnt
|
[] | 1,165,073
| 1,165,074
|
u333374716
|
ruby
|
p03416
|
a, b = gets.chomp.split(" ").map(&:to_i)
ans = 0
def ispalind(string)
n = string.length
for i in 0..(n - 1)/2
if string[i] != string[n - 1 - i]
return false
end
end
return true
end
for i in a...b
if ispalind(i.to_s)
ans += 1
end
end
print(ans)
|
a, b = gets.chomp.split(" ").map(&:to_i)
ans = 0
def ispalind(string)
n = string.length
for i in 0..(n - 1)/2
if string[i] != string[n - 1 - i]
return false
end
end
return true
end
for i in a..b
if ispalind(i.to_s)
ans += 1
end
end
print(ans)
|
[] | 1,165,126
| 1,165,127
|
u691896522
|
ruby
|
p03416
|
a,b = gets.strip.split.map(&:to_i)
cnt = 0
a.upto(b) do |i|
s = i%10
t = i/10000%10
u = i/10000 % 10
v = i/10%10
cnt += 1 if s==t && u==v
end
puts cnt
|
a,b = gets.strip.split.map(&:to_i)
cnt = 0
a.upto(b) do |i|
s = i%10
t = i/10000%10
u = i/1000 % 10
v = i/10%10
cnt += 1 if s==t && u==v
end
puts cnt
|
[
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,165,830
| 1,165,831
|
u124214522
|
ruby
|
p03416
|
def ascan; gets.split.map(&:to_i); end
a,b = accan
cnt = 0
a.upto(b) do |x|
cnt += 1 if x.to_s.reverse == x.to_s
end
p cnt
|
def ascan; gets.split.map(&:to_i); end
a,b = ascan
cnt = 0
a.upto(b) do |x|
cnt += 1 if x.to_s.reverse == x.to_s
end
p cnt
|
[
"assignment.value.change",
"identifier.change"
] | 1,165,897
| 1,165,898
|
u079330987
|
ruby
|
p03416
|
ss = gets.split(' ')
count = 0
nums = [ss[0].to_i,ss[1].to_i]
(nums[1].to_i - nums[0].to_i).times do |i|
(count += 1) if ((i+nums[0]).to_s == (i+nums[0]).to_s.reverse)
end
print count
|
ss = gets.split(' ')
count = 0
nums = [ss[0].to_i,ss[1].to_i]
(nums[1].to_i - nums[0].to_i+1).times do |i|
(count += 1) if ((i+nums[0]).to_s == (i+nums[0]).to_s.reverse)
end
print count
|
[
"expression.operation.binary.add"
] | 1,165,941
| 1,165,942
|
u922487073
|
ruby
|
p03416
|
a = gets.split(" ").map(&:to_i)
b = (a[0]...a[1]).each_with_object([]) {|n,r|
if n.to_s == n.to_s.reverse
r.push(1)
end
}
puts b.length
|
a = gets.split(" ").map(&:to_i)
b = (a[0]..a[1]).each_with_object([]) {|n,r|
if n.to_s == n.to_s.reverse
r.push(1)
end
}
puts b.length
|
[] | 1,166,053
| 1,166,054
|
u951980350
|
ruby
|
p03417
|
n, m = gets.chomp.split.map(&:to_i)
if n == 1 && m == 1
p 1
elsif n == 1 || m == 1
if n == 1
p m - 2
else
p n - 1
end
else
p (n-2) * (m-2)
end
|
n, m = gets.chomp.split.map(&:to_i)
if n == 1 && m == 1
p 1
elsif n == 1 || m == 1
if n == 1
p m - 2
else
p n - 2
end
else
p (n-2) * (m-2)
end
|
[
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,166,763
| 1,166,764
|
u195257137
|
ruby
|
p03416
|
a=gets.chop;b=gets.chop
c=0;for s in a..b;;c+=s.reverse==s ?1:0;end
puts c
|
a,b=gets.split
c=0;for s in a..b;;c+=s.reverse==s ?1:0;end
puts c
|
[
"assignment.variable.change",
"assignment.value.change",
"identifier.change"
] | 1,167,609
| 1,167,610
|
u459746049
|
ruby
|
p03417
|
tmp = gets.split(' ')
n = tmp[0].to_i
m= tmp[1].to_i
if (n<2) and (m>2) then
print m-2
elsif (m<2) and (n>2) then
print n-2
elsif (n<=2) or (m<=2) then
print 0
else
print (n-2)*(m-2)
end
|
tmp = gets.split(' ')
n = tmp[0].to_i
m= tmp[1].to_i
if (n<2) and (m>2) then
print m-2
elsif (m<2) and (n>2) then
print n-2
elsif (n==2) or (m==2) then
print 0
else
print (n-2)*(m-2)
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,168,108
| 1,168,109
|
u922487073
|
ruby
|
p03417
|
tmp = gets.split(' ')
n = tmp[0].to_i
m= tmp[1].to_i
if (n<2) and (m>2) then
print m-2
elsif (m<2) and (n>2) then
print n-2
elsif (n<=2) or (m<=2) then
print 0
else
print (n-1)*(m-1)
end
|
tmp = gets.split(' ')
n = tmp[0].to_i
m= tmp[1].to_i
if (n<2) and (m>2) then
print m-2
elsif (m<2) and (n>2) then
print n-2
elsif (n==2) or (m==2) then
print 0
else
print (n-2)*(m-2)
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,168,110
| 1,168,109
|
u922487073
|
ruby
|
p03417
|
a,b=gets.split.map &:to_i
if a==0 || b==0
p 0
elsif a==1 && b==1
p 0
elsif a==1
p b-2
elsif b==1
p a-2
else
p (a-2)*(b-2)
end
|
a,b=gets.split.map &:to_i
if a==0 || b==0
p 0
elsif a==1 && b==1
p 1
elsif a==1
p b-2
elsif b==1
p a-2
else
p (a-2)*(b-2)
end
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 1,168,315
| 1,168,316
|
u610697662
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.