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 |
|---|---|---|---|---|---|---|---|
p02947 | N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.conbination(2).size
end
puts count
| N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.combination(2).size
end
puts count
| [
"identifier.change"
] | 746,559 | 746,558 | u729911058 | ruby |
p02947 | N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.split.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.conbination(2).size
end
puts count
| N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.combination(2).size
end
puts count
| [
"assignment.value.change",
"identifier.change"
] | 746,560 | 746,558 | u729911058 | ruby |
p02947 | N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.convination(2).size
end
puts count
| N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.combination(2).size
end
puts count
| [
"misc.typo",
"identifier.change"
] | 746,561 | 746,558 | u729911058 | ruby |
p02947 | N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.split.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.convination(2).size
end
puts count
| N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.combination(2).size
end
puts count
| [
"assignment.value.change",
"identifier.change",
"misc.typo"
] | 746,562 | 746,558 | u729911058 | ruby |
p02947 | n = gets.to_i
ss = n.times.map { gets.chomp.chars.sort.join }
ans = 0
hash = Hash.new(-1)
ss.each do |s|
hash[s] += 1
ans += hash[s]
end
puts an | n = gets.to_i
ss = n.times.map { gets.chomp.chars.sort.join }
ans = 0
hash = Hash.new(-1)
ss.each do |s|
hash[s] += 1
ans += hash[s]
end
puts ans
| [
"misc.typo",
"identifier.change",
"call.arguments.change"
] | 747,001 | 747,002 | u889326464 | ruby |
p02947 | n = gets.to_i
ss = []
n.times do
s = gets.chomp.chars.sort.join
ss << s
end
ss.sort!
ans = 0
h = Hash.new(0)
ss.size.times do |i|
h[ss[i]] += 1
end
h.each do |k,v|
if v > 1
ans += (1..v).to_a.combination(2).size
else
ans += v
end
end
# puts ss.size - ss.uniq.size
puts ans
| n = gets.to_i
ss = []
n.times do
s = gets.chomp.chars.sort.join
ss << s
end
ss.sort!
ans = 0
h = Hash.new(0)
ss.size.times do |i|
h[ss[i]] += 1
end
h.each do |k,v|
if v > 0
ans += (1..v).to_a.combination(2).size
else
ans += v
end
end
# puts ss.size - ss.uniq.size
puts ans
| [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 747,609 | 747,610 | u298628832 | ruby |
p02947 | n = gets.to_i
s = []
n.times do
s.push(gets.split("").sort.join)
end
s.sort!
p(s)
sum = 0
buff = s[0]
combo = 1
1.upto(n-1) do |i|
if buff == s[i] then
sum += combo
combo += 1
else
buff = s[i]
combo = 1
end
end
print(sum) | n = gets.to_i
s = []
n.times do
s.push(gets.split("").sort.join)
end
s.sort!
sum = 0
buff = s[0]
combo = 1
1.upto(n-1) do |i|
if buff == s[i] then
sum += combo
combo += 1
else
buff = s[i]
combo = 1
end
end
print(sum) | [
"call.remove"
] | 748,039 | 748,040 | u849186626 | ruby |
p02947 | n = gets.to_i
s = []
n.times do
s.push(gets.split("").sort.join)
end
s.sort!
p(s)
sum = 0
buff = s[0]
combo = 1
1.upto(n-1) do |i|
if buff == s[i] then
sum += combo
combo += 1
else
buff = s[i]
combo = 1
end
end
p(sum) | n = gets.to_i
s = []
n.times do
s.push(gets.split("").sort.join)
end
s.sort!
sum = 0
buff = s[0]
combo = 1
1.upto(n-1) do |i|
if buff == s[i] then
sum += combo
combo += 1
else
buff = s[i]
combo = 1
end
end
print(sum) | [
"call.remove",
"call.function.change",
"io.output.change"
] | 748,041 | 748,040 | u849186626 | ruby |
p02947 | N = gets.to_i
S = N.times.map { gets.chomp }
counter = Hash.new(0)
S.each do |s|
counter[s.sum] += 1
end
ans = 0
counter.each_value do |v|
next if v <= 1
ans += v * (v - 1) / 2
end
puts ans
| N = gets.to_i
S = N.times.map { gets.chomp }
counter = Hash.new(0)
S.each do |s|
counter[s.chars.sort] += 1
end
ans = 0
counter.each_value do |v|
next if v <= 1
ans += v * (v - 1) / 2
end
puts ans
| [
"identifier.change",
"variable_access.subscript.index.change",
"call.add"
] | 748,441 | 748,442 | u740836226 | ruby |
p02947 | N = gets.chomp.to_i
words = {}
N.times do
word = gets.chomp.chars.sort.join
words[word] = words.key?(word) ? words[word] + 1 : 1
end
p words
puts words.values.reduce(0) { |sum, count| count == 2 ? sum + 1 : count == 1 ? sum : sum + count*(count-1)/2 }
| N = gets.chomp.to_i
words = {}
N.times do
word = gets.chomp.chars.sort.join
words[word] = words.key?(word) ? words[word] + 1 : 1
end
puts words.values.reduce(0) { |sum, count| count == 2 ? sum + 1 : count == 1 ? sum : sum + count*(count-1)/2 }
| [
"call.remove"
] | 748,501 | 748,502 | u056626722 | ruby |
p02947 | n=gets.to_i
words=[]
n.times do
word = gets.chomp.split("").sort.join("")
if words.exist?(word)
words[word] +=1
else
words[word] = 1
end
end
counter=0
words.each_pair do |key,value|
if value > 1
counter += value * (value-1) / 2
end
end
puts counter | n=gets.to_i
words={}
n.times do
word = gets.chomp.split("").sort.join("")
if words.include?(word)
words[word] +=1
else
words[word] = 1
end
end
counter=0
words.each_pair do |key,value|
if value > 1
counter += value * (value -1) / 2
end
end
puts counter | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 748,666 | 748,667 | u883824971 | ruby |
p02947 | n=gets.to_i
words=[]
n.times do
word = gets.chomp.split("").sort.join("")
if words.exist?(word)
words[word] +=1
else
words[word] = 1
end
end
counter=0
words.each_pair do |key,value|
if value > 1
counter += value * (value -1) / 2
end
end
puts counter | n=gets.to_i
words={}
n.times do
word = gets.chomp.split("").sort.join("")
if words.include?(word)
words[word] +=1
else
words[word] = 1
end
end
counter=0
words.each_pair do |key,value|
if value > 1
counter += value * (value -1) / 2
end
end
puts counter | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 748,668 | 748,667 | u883824971 | ruby |
p02947 | n = gets.chomp.to_i
kq = {}
(1..n).each do |i|
sorted = gets.chomp.split("").sort.join("")
if kq[sorted] != nil
kq[sorted] = kq[sorted] + 1
else
kq[sorted] = 1
end
end
puts kq
sum = 0
kq.map {|key, value| sum+= value*(value-1)/2}
puts sum | n = gets.chomp.to_i
kq = {}
(1..n).each do |i|
sorted = gets.chomp.split("").sort.join("")
if kq[sorted] != nil
kq[sorted] = kq[sorted] + 1
else
kq[sorted] = 1
end
end
sum = 0
kq.map {|key, value| sum+= value*(value-1)/2}
puts sum | [
"call.remove"
] | 749,069 | 749,070 | u151224155 | ruby |
p02947 | n = gets.to_i
hash = Hash.new(0)
ans = 0
n.times do
str = gets.chomp.chars.join
h[str] += 1
end
hash.each do |k, v|
ans += (v-1..v).inject(:*) / 2 if v > 1
end
p ans | n = gets.to_i
hash = Hash.new(0)
ans = 0
n.times do
str = gets.chomp.chars.sort.join
hash[str] += 1
end
hash.each do |k, v|
ans += (v-1..v).inject(:*) / 2 if v > 1
end
p ans
| [
"call.add",
"identifier.change"
] | 749,200 | 749,201 | u617691573 | ruby |
p02947 | def comb_init(max, mod)
fac = Array.new(max)
finv = Array.new(max)
inv = Array.new(max)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
(2...max).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
{ fac: fac, finv: finv, mod: mod }
end
def comb(n, k, context)
return 0 if n < k
return 0 if n < 0 || k < 0
fac = context[:fac]
finv = context[:finv]
mod = context[:mod]
fac[n] * (finv[k] * finv[n - k] % mod) % mod
end
N = gets.to_i
table = Hash.new { 0 }
s_list = N.times.map { gets.chomp.chars }
s_list.each do |s|
table[s.sort] += 1
end
ans = 0
context = comb_init(N + 10, 10 ** 9 + 7)
table.each do |k, v|
next if v == 0
ans += comb(v, 2, context)
end
puts ans
| def comb_init(max, mod)
fac = Array.new(max)
finv = Array.new(max)
inv = Array.new(max)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
(2...max).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
{ fac: fac, finv: finv, mod: mod }
end
def comb(n, k, context)
return 0 if n < k
return 0 if n < 0 || k < 0
fac = context[:fac]
finv = context[:finv]
mod = context[:mod]
fac[n] * (finv[k] * finv[n - k] % mod) % mod
end
N = gets.to_i
table = Hash.new { 0 }
s_list = N.times.map { gets.chomp.chars }
s_list.each do |s|
table[s.sort] += 1
end
ans = 0
context = comb_init(N + 10, 67280421310721 )
table.each do |k, v|
next if v == 0
ans += comb(v, 2, context)
end
puts ans
| [
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 749,319 | 749,320 | u012133968 | ruby |
p02948 | class PriorityQueue
def initialize(array = [])
@data = []
array.each{|a| add(a)}
end
def add(element)
@data.push(element)
bottom_up
p @data
end
# @return Integer
def peek
@data[0]
end
# @return Integer
def poll
if size == 0
return 0
elsif size == 1
return @data.pop
else
max = @data[0]
@data[0] = @data.pop
top_down
return max
end
end
# @return Integer
def size
@data.size
end
private
def swap(i, j)
@data[i], @data[j] = @data[j], @data[i]
end
def bottom_up
idx = size - 1
while(has_parent?(idx))
parent_idx = parent_idx(idx)
if @data[parent_idx] < @data[idx]
swap(parent_idx, idx)
idx = parent_idx
else
return
end
end
end
def top_down
idx = 0
while (has_child?(idx))
a = left_child_idx(idx)
b = right_child_idx(idx)
if @data[b].nil?
c = a
else
c = @data[a] >= @data[b] ? a : b
end
if @data[idx] < @data[c]
swap(idx, c)
idx = c
else
return
end
end
end
# @param Integer
# @return Integer
def parent_idx(idx)
(idx - (idx.even? ? 2 : 1)) / 2
end
# @param Integer
# @return Integer
def left_child_idx(idx)
(idx * 2) + 1
end
# @param Integer
# @return Integer
def right_child_idx(idx)
(idx * 2) + 2
end
# @param Integer
# @return Boolent
def has_child?(idx)
((idx * 2) + 1) < @data.size
end
def has_parent?(idx)
idx > 0
end
end
n, m = gets.chomp.split(' ').map(&:to_i)
jobs = (1..n).map { gets.chomp.split(' ').map(&:to_i) }.group_by { |ab| ab.first }
sum = 0
pq = PriorityQueue.new
1.upto(m) do |d|
jobs[d].map(&:last).each { |money| pq.add(money) } if jobs[d]
sum += pq.poll
end
puts sum
| class PriorityQueue
def initialize(array = [])
@data = []
array.each{|a| add(a)}
end
def add(element)
@data.push(element)
bottom_up
end
# @return Integer
def peek
@data[0]
end
# @return Integer
def poll
if size == 0
return 0
elsif size == 1
return @data.pop
else
max = @data[0]
@data[0] = @data.pop
top_down
return max
end
end
# @return Integer
def size
@data.size
end
private
def swap(i, j)
@data[i], @data[j] = @data[j], @data[i]
end
def bottom_up
idx = size - 1
while(has_parent?(idx))
parent_idx = parent_idx(idx)
if @data[parent_idx] < @data[idx]
swap(parent_idx, idx)
idx = parent_idx
else
return
end
end
end
def top_down
idx = 0
while (has_child?(idx))
a = left_child_idx(idx)
b = right_child_idx(idx)
if @data[b].nil?
c = a
else
c = @data[a] >= @data[b] ? a : b
end
if @data[idx] < @data[c]
swap(idx, c)
idx = c
else
return
end
end
end
# @param Integer
# @return Integer
def parent_idx(idx)
(idx - (idx.even? ? 2 : 1)) / 2
end
# @param Integer
# @return Integer
def left_child_idx(idx)
(idx * 2) + 1
end
# @param Integer
# @return Integer
def right_child_idx(idx)
(idx * 2) + 2
end
# @param Integer
# @return Boolent
def has_child?(idx)
((idx * 2) + 1) < @data.size
end
def has_parent?(idx)
idx > 0
end
end
n, m = gets.chomp.split(' ').map(&:to_i)
jobs = (1..n).map { gets.chomp.split(' ').map(&:to_i) }.group_by { |ab| ab.first }
sum = 0
pq = PriorityQueue.new
1.upto(m) do |d|
jobs[d].map(&:last).each { |money| pq.add(money) } if jobs[d]
sum += pq.poll
end
puts sum
| [
"call.remove"
] | 750,360 | 750,361 | u842633542 | ruby |
p02948 | n,m = gets.split.map(&:to_i)
h = Hash.new
n.times do
a, b = gets.split.map(&:to_i)
unless h[a]
h[a] = Array.new
end
h[a].push(b)
end
ans = 0
jobs = Array.new(0)
for day in 1..m
if h[day]
h[day].each do |b|
idx = jobs.bsearch_index { |x| x >= b }
if jobs.size > 0 && idx
p idx
jobs.insert(idx, b)
else
jobs.push(b)
end
end
end
val = jobs.pop
ans += val if val
end
puts ans
| n,m = gets.split.map(&:to_i)
h = Hash.new
n.times do
a, b = gets.split.map(&:to_i)
unless h[a]
h[a] = Array.new
end
h[a].push(b)
end
ans = 0
jobs = Array.new(0)
for day in 1..m
if h[day]
h[day].each do |b|
idx = jobs.bsearch_index { |x| x >= b }
if jobs.size > 0 && idx
jobs.insert(idx, b)
else
jobs.push(b)
end
end
end
val = jobs.pop
ans += val if val
end
puts ans
| [
"call.remove"
] | 750,474 | 750,475 | u843127718 | ruby |
p02948 | class PriorityQueue
def initialize(&compare)
@items = []
if block_given?
@compare_proc = compare
else
@compare_proc = Proc.new { |a, b| a > b }
end
end
def push(x)
n = @items.size
@items << x
while n != 0
p = (n - 1) / 2
if @compare_proc.call(@items[n], @items[p])
@items[p], @items[n] = @items[n], @items[p]
end
n = p
end
pp @items
end
def pop
result = @items[0]
@items[0] = @items[-1]
@items.delete_at(-1)
n = 0
loop do
left = 2 * n + 1
break if left >= @items.size
right = left + 1
if (right < @items.size) && @compare_proc.call(@items[right], @items[left])
c = right
else
c = left
end
break unless @compare_proc.call(@items[c], @items[n])
@items[n], @items[c] = @items[c], @items[n]
n = c
end
pp @items
result
end
def empty?
@items.empty?
end
def size
@items.size
end
end
n, m = gets.split.map(&:to_i)
rewards = (m + 1).times.map{Array.new}
n.times do
a, b = gets.split.map(&:to_i)
rewards[a] << b if a <= m
end
ans = 0
reward = PriorityQueue.new
1.upto(m) do |i|
rewards[i].each do |b|
reward.push(b)
end
unless reward.empty?
ans += reward.pop
end
end
puts ans
| class PriorityQueue
def initialize(&compare)
@items = []
if block_given?
@compare_proc = compare
else
@compare_proc = Proc.new { |a, b| a > b }
end
end
def push(x)
n = @items.size
@items << x
while n != 0
p = (n - 1) / 2
if @compare_proc.call(@items[n], @items[p])
@items[p], @items[n] = @items[n], @items[p]
end
n = p
end
end
def pop
result = @items[0]
@items[0] = @items[-1]
@items.delete_at(-1)
n = 0
loop do
left = 2 * n + 1
break if left >= @items.size
right = left + 1
if (right < @items.size) && @compare_proc.call(@items[right], @items[left])
c = right
else
c = left
end
break unless @compare_proc.call(@items[c], @items[n])
@items[n], @items[c] = @items[c], @items[n]
n = c
end
result
end
def empty?
@items.empty?
end
def size
@items.size
end
end
n, m = gets.split.map(&:to_i)
rewards = (m + 1).times.map{Array.new}
n.times do
a, b = gets.split.map(&:to_i)
rewards[a] << b if a <= m
end
ans = 0
reward = PriorityQueue.new
1.upto(m) do |i|
rewards[i].each do |b|
reward.push(b)
end
unless reward.empty?
ans += reward.pop
end
end
puts ans
| [
"call.remove"
] | 750,488 | 750,489 | u457499130 | ruby |
p02951 | a, b , c = gets.chomp.split(" ").map(&:to_i)
puts c - (a - b)
| a, b , c = gets.chomp.split(" ").map(&:to_i)
puts [c - (a - b),0].max | [
"call.arguments.change",
"call.add"
] | 751,384 | 751,385 | u412789323 | ruby |
p02951 | a,b,c = gets.split.map(&:to_i)
puts c-(a-b)
| a,b,c = gets.split.map(&:to_i)
puts [c-(a-b),0].max
| [
"call.arguments.change",
"call.add"
] | 752,122 | 752,123 | u124214522 | ruby |
p02951 | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
def sum(a) a.inject(:+) end
a,b,c = inp
p c-a+b | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
def sum(a) a.inject(:+) end
a,b,c = inp
p [c-a+b,0].max | [
"call.arguments.change",
"call.add"
] | 752,210 | 752,211 | u145123922 | ruby |
p02951 | a,b,c = gets.split.map(&:to_i)
puts a - b >= c ? 0 : c - a - b | a,b,c = gets.split.map(&:to_i)
puts a - b >= c ? 0 : c - (a - b) | [
"call.arguments.change"
] | 752,354 | 752,355 | u502774641 | ruby |
p02951 | line = gets.split(" ").map(&:to_i)
a = line[0]
b = line[1]
c = line[2]
if a - b <= 0
puts 0
else
puts c - (a - b)
end | line = gets.split(" ").map(&:to_i)
a = line[0]
b = line[1]
c = line[2]
if a - b >= c
puts 0
else
puts c - (a - b)
end | [] | 752,434 | 752,435 | u748406041 | ruby |
p02951 | A,B,C=gets.split.map(&:to_i);p C-A+B | A,B,C=gets.split.map(&:to_i);p [C-A+B,0].max | [
"call.arguments.change",
"call.add"
] | 752,458 | 752,459 | u655122274 | ruby |
p02951 | class Main
def execute
@a, @b, @c = gets.split.map(&:to_i)
@d = @a - @b
ans = @c - @d
puts 0 if ans < 0
end
end
Main.new.execute | class Main
def execute
@a, @b, @c = gets.split.map(&:to_i)
@d = @a - @b
ans = @c - @d
ans = 0 if ans < 0
puts ans
end
end
Main.new.execute | [
"assignment.variable.change",
"call.add"
] | 752,538 | 752,539 | u145952711 | ruby |
p02951 | a, b, c = gets.chomp.split(' ').map{|v| v.to_i}
res = b + c - a
if res >= 0
puts res
else
0
end | a, b, c = gets.chomp.split(' ').map{|v| v.to_i}
res = b + c - a
if res >= 0
puts res
else
puts 0
end
| [
"io.output.change",
"call.add"
] | 752,580 | 752,581 | u277797473 | ruby |
p02951 | a,b,c = gets.chomp.split().map(&:to_i)
puts [c-(a-b), 0].min | a,b,c = gets.chomp.split().map(&:to_i)
puts [c-(a-b), 0].max | [
"misc.opposites",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 752,621 | 752,622 | u792512290 | ruby |
p02951 | A, B, C = gets.chomp.split(' ').map(&to_i)
if C - (A-B) < 0
puts 0
else
puts C - (A-B)
end | A, B, C = gets.chomp.split(' ').map(&:to_i)
if C-(A-B)<0
puts 0
else
puts C-(A-B)
end | [
"assignment.value.change",
"call.arguments.change"
] | 752,635 | 752,636 | u303448696 | ruby |
p02951 | A, B, C = gets.chomp.split(' ').map(&to_i)
if C > (A-B)
puts 0
else
puts C - (A-B)
end | A, B, C = gets.chomp.split(' ').map(&:to_i)
if C-(A-B)<0
puts 0
else
puts C-(A-B)
end | [
"assignment.value.change",
"call.arguments.change",
"control_flow.branch.if.condition.change"
] | 752,637 | 752,636 | u303448696 | ruby |
p02951 | input = gets
a, b, c = input.split.map(&:to_i)
puts c - (a - b)
| input = gets
a, b, c = input.split.map(&:to_i)
puts [c - (a - b), 0].max
| [
"call.arguments.change",
"call.add"
] | 752,667 | 752,668 | u183175308 | ruby |
p02951 | a,b,c = gets.split.map(&:to_i)
puts c - a + b | a,b,c = gets.split.map(&:to_i)
puts [c - a + b,0].max | [
"call.arguments.change",
"call.add"
] | 752,740 | 752,741 | u622469330 | ruby |
p02951 | A, B, C=gets.chomp.split(" ").map(&:to_i);
if c - (A - B) > 0
puts C - (A - B)
else
puts 0
end | A, B, C=gets.chomp.split(" ").map(&:to_i);
if C - (A - B) > 0
puts C - (A - B)
else
puts 0
end
| [
"misc.typo",
"control_flow.branch.if.condition.change"
] | 752,755 | 752,756 | u533566373 | ruby |
p02951 | a,b,c = gets.chomp.split(' ').map(&:to_i);p if c-(a-b) > 0 ? c-(a-b):0 | a,b,c = gets.chomp.split(' ').map(&:to_i);p c-(a-b) > 0 ? c-(a-b):0 | [] | 752,833 | 752,834 | u274530567 | ruby |
p02951 | A, B, C = gets.split.map &:to_i
p C-(A-B)
| A, B, C = gets.split.map &:to_i
p [C-(A-B),0].max
| [
"call.arguments.change",
"call.add"
] | 752,971 | 752,972 | u977697682 | ruby |
p02951 | # frozen_string_literal: true
a, b, c = gets.split.map(&:to_i)
puts c - (a - b)
| # frozen_string_literal: true
a, b, c = gets.split.map(&:to_i)
puts [c - (a - b), 0].max
| [
"call.arguments.change",
"call.add"
] | 753,215 | 753,216 | u434509016 | ruby |
p02952 | c=0
(1..gets.to_i).each{|i|c+=1 if i%2!=0}
p c
| c=0
(1..gets.to_i).each{|i|c+=1 if i.to_s.size%2!=0}
p c
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 753,347 | 753,348 | u966810027 | ruby |
p02952 | n = gets.to_i
i = 1
sum = 0
while i <= n do
m = i.to_s.size
if m&2==1
sum += 1
end
i += 1
end
puts sum | n = gets.to_i
i = 1
sum = 0
while i <= n do
if (i.to_s.size)%2==1
sum += 1
end
i += 1
end
puts sum | [
"control_flow.branch.if.condition.change"
] | 753,413 | 753,414 | u313103408 | ruby |
p02949 | require 'set'
N, M, P = gets.split.map(&:to_i)
abc_list = M.times.map do
a, b, c = gets.split.map(&:to_i)
[a - 1, b - 1, -(c - P)]
end
graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
graph[a].push([b, c])
end
reverse_graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
reverse_graph[b].push([a, c])
end
INF = 1 << 60
def reachable(graph, s)
visit = Set.new
visit.add(s)
queue = [s]
while !queue.empty?
u = queue.shift
graph[u].each.with_index do |(v, _)|
next if visit.include?(v)
visit.add(v)
queue.push(v)
end
end
visit
end
def bellman_ford(edge_list, s, max_count)
d = Array.new(M, INF)
d[s] = 0
c = 0
loop do
is_update = false
edge_list.each do |(u, v, c)|
if d[u] != INF && d[u] + c < d[v]
d[v] = d[u] + c
is_update = true
end
end
return d if !is_update
c += 1
return nil if c == max_count
end
end
reachable_from_0 = reachable(graph, 0)
reachable_to_n = reachable(reverse_graph, N - 1)
v_set = Set.new
N.times do |v|
v_set.add(v) if reachable_from_0.include?(v) && reachable_to_n.include?(v)
end
edge_list = abc_list.select do |(a, b, _)|
v_set.include?(a) && v_set.include?(b)
end
ans = bellman_ford(edge_list, 0, v_set.size)
puts(ans == nil ? '-1' : [-(ans[N - 1]), 0].max)
| require 'set'
N, M, P = gets.split.map(&:to_i)
abc_list = M.times.map do
a, b, c = gets.split.map(&:to_i)
[a - 1, b - 1, -(c - P)]
end
graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
graph[a].push([b, c])
end
reverse_graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
reverse_graph[b].push([a, c])
end
INF = 1 << 60
def reachable(graph, s)
visit = Set.new
visit.add(s)
queue = [s]
while !queue.empty?
u = queue.shift
graph[u].each do |(v, _)|
next if visit.include?(v)
visit.add(v)
queue.push(v)
end
end
visit
end
def bellman_ford(edge_list, s, max_count)
d = Array.new(N, INF)
d[s] = 0
c = 0
loop do
is_update = false
edge_list.each do |(u, v, c)|
if d[u] != INF && d[u] + c < d[v]
d[v] = d[u] + c
is_update = true
end
end
return d if !is_update
c += 1
return nil if c == max_count
end
end
reachable_from_0 = reachable(graph, 0)
reachable_to_n = reachable(reverse_graph, N - 1)
v_set = Set.new
N.times do |v|
v_set.add(v) if reachable_from_0.include?(v) && reachable_to_n.include?(v)
end
edge_list = abc_list.select do |(a, b, _)|
v_set.include?(a) && v_set.include?(b)
end
ans = bellman_ford(edge_list, 0, v_set.size)
puts(ans == nil ? '-1' : [-(ans[N - 1]), 0].max)
| [
"call.remove",
"assignment.value.change",
"call.arguments.change"
] | 753,847 | 753,848 | u012133968 | ruby |
p02949 | require 'set'
N, M, P = gets.split.map(&:to_i)
abc_list = M.times.map do
a, b, c = gets.split.map(&:to_i)
[a - 1, b - 1, -(c - P)]
end
graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
graph[a].push([b, c])
end
reverse_graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
reverse_graph[b].push([a, c])
end
INF = 1 << 60
def reachable(graph, s)
visit = Set.new
visit.add(s)
queue = [s]
while !queue.empty?
u = queue.shift
graph[u].each.with_index do |(v, _)|
next if visit.include?(v)
visit.add(v)
queue.push(v)
end
end
visit
end
def bellman_ford(edge_list, s, max_count)
d = Array.new(M, INF)
d[s] = 0
c = 0
loop do
is_update = false
edge_list.each do |(u, v, c)|
if d[u] != INF && d[u] + c < d[v]
d[v] = d[u] + c
is_update = true
end
end
return d if !is_update
c += 1
return nil if c == max_count
end
end
reachable_from_0 = reachable(graph, 0)
reachable_to_n = reachable(reverse_graph, N - 1)
v_set = Set.new
N.times do |v|
v_set.add(v) if reachable_from_0.include?(v) && reachable_to_n.include?(v)
end
edge_list = abc_list.select do |(a, b, _)|
v_set.include?(a) && v_set.include?(b)
end
ans = bellman_ford(edge_list, 0, v_set.size)
puts(ans == nil ? '-1' : [-(ans[N - 1]), 0].max)
| require 'set'
N, M, P = gets.split.map(&:to_i)
abc_list = M.times.map do
a, b, c = gets.split.map(&:to_i)
[a - 1, b - 1, -(c - P)]
end
graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
graph[a].push([b, c])
end
reverse_graph = Array.new(N) { [] }
abc_list.each do |(a, b, c)|
reverse_graph[b].push([a, c])
end
INF = 1 << 60
def reachable(graph, s)
visit = Set.new
visit.add(s)
queue = [s]
while !queue.empty?
u = queue.shift
graph[u].each.with_index do |(v, _)|
next if visit.include?(v)
visit.add(v)
queue.push(v)
end
end
visit
end
def bellman_ford(edge_list, s, max_count)
d = Array.new(N, INF)
d[s] = 0
c = 0
loop do
is_update = false
edge_list.each do |(u, v, c)|
if d[u] != INF && d[u] + c < d[v]
d[v] = d[u] + c
is_update = true
end
end
return d if !is_update
c += 1
return nil if c == max_count
end
end
reachable_from_0 = reachable(graph, 0)
reachable_to_n = reachable(reverse_graph, N - 1)
v_set = Set.new
N.times do |v|
v_set.add(v) if reachable_from_0.include?(v) && reachable_to_n.include?(v)
end
edge_list = abc_list.select do |(a, b, _)|
v_set.include?(a) && v_set.include?(b)
end
ans = bellman_ford(edge_list, 0, v_set.size)
puts(ans == nil ? '-1' : [-(ans[N - 1]), 0].max)
| [
"assignment.value.change",
"call.arguments.change"
] | 753,847 | 753,850 | u012133968 | ruby |
p02952 | n = gets.strip.to_i
c = 0
c += 9 if n <= 9
c += 9 if n > 9
c += (n - 99) if n > 99 && n <= 999
c += 900 if n > 999
c += (n - 9999) if n > 9999 && n <= 99999
c += 90000 if n > 99999
puts c | n = gets.strip.to_i
c = 0
c += n if n > 0 && n <= 9
c += 9 if n > 9
c += (n - 99) if n > 99 && n <= 999
c += 900 if n > 999
c += (n - 9999) if n > 9999 && n <= 99999
c += 90000 if n > 99999
puts c | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change"
] | 754,127 | 754,128 | u259578064 | ruby |
p02952 | n = gets.to_i
ans = 0
(1..n).each do |num|
ans.succ if (num.to_s.size) % 2 == 1
end
puts ans | n = gets.to_i
ans = 0
(1..n).each do |num|
ans += 1 if (num.to_s.size) % 2 == 1
end
puts ans | [] | 754,155 | 754,156 | u721508245 | ruby |
p02952 | N = gets.chomp.to_i
if N <= 10
puts N
elsif N < 100
puts 9
elsif N < 1000
puts N-90
elsif N < 10000
puts 909
elsif N <= 100000
puts N-99999+909
end
| N = gets.chomp.to_i
if N < 10
puts N
elsif N < 100
puts 9
elsif N < 1000
puts N-90
elsif N < 10000
puts 909
elsif N < 100000
puts N-9090
else
puts 90909
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 754,303 | 754,301 | u760636024 | ruby |
p02952 | N = gets.to_i
if N/10 < 0
puts N
elsif N/10 < 10
puts 9
elsif N/100 < 10
puts 9 + N- 99
elsif N/1000 < 10
puts 9 + 900
elsif N/10000 < 10
puts 909 + N - 9999
else
puts 90909
end | N = gets.to_i
if N < 10
puts N
elsif N/10 < 10
puts 9
elsif N/100 < 10
puts 9 + N- 99
elsif N/1000 < 10
puts 9 + 900
elsif N/10000 < 10
puts 909 + N - 9999
else
puts 90909
end | [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 754,363 | 754,364 | u411203878 | ruby |
p02952 | N = gets.to_i
if N/10 < 0
puts N
elsif N/10 < 10
puts 9
elsif N/100 < 10
puts 9 + N- 99
elsif N/1000 < 10
puts 9 + 900
elsif N/10000 < 10
puts 910 + N - 9999
else
puts 90909
end | N = gets.to_i
if N < 10
puts N
elsif N/10 < 10
puts 9
elsif N/100 < 10
puts 9 + N- 99
elsif N/1000 < 10
puts 9 + 900
elsif N/10000 < 10
puts 909 + N - 9999
else
puts 90909
end | [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove",
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 754,365 | 754,364 | u411203878 | ruby |
p02952 | N = gets.to_i
if N/10 < 0
puts N
elsif N/10 < 10
puts 9
elsif N/100 < 10
puts 9 + N- 99
elsif N/1000 < 10
puts 9 + 901
elsif N/10000 < 10
puts 910 + N - 9999
else
puts 90909
end | N = gets.to_i
if N < 10
puts N
elsif N/10 < 10
puts 9
elsif N/100 < 10
puts 9 + N- 99
elsif N/1000 < 10
puts 9 + 900
elsif N/10000 < 10
puts 909 + N - 9999
else
puts 90909
end | [
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove",
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 754,366 | 754,364 | u411203878 | ruby |
p02952 | n=gets
i=1
c=0
while i<=n
if i.to_s.chars.length%2==1
c+=1
end
i+=1
end
puts c | n=gets.to_i
i=1
c=0
while i<=n
if i.to_s.chars.length%2==1
c+=1
end
i+=1
end
puts c | [
"call.add"
] | 754,609 | 754,610 | u560481052 | ruby |
p02952 | ('1'..gets.chop).count{|i|i.size.odd?} | p ('1'..gets.chop).count{|i|i.size.odd?} | [
"io.output.change",
"call.add"
] | 754,722 | 754,723 | u752146271 | ruby |
p02952 | target=gets
number=target.to_i
keta = target.to_s.length.to_i
total=0
1.step(keta-1,2) do |num|
total=total+(9*10**(num-1))
end
if keta%2 == 1
total=total+(number-(10**(keta-1)))+1
end
puts total | target=gets.chomp
number=target.to_i
keta = target.to_s.length.to_i
total=0
1.step(keta-1,2) do |num|
total=total+(9*10**(num-1))
end
if keta%2 == 1
total=total+(number-(10**(keta-1)))+1
end
puts total
| [
"call.add"
] | 754,814 | 754,815 | u562148988 | ruby |
p02952 | target=gets
number=target.to_i
keta = target.to_s.length.to_i
total=0
1.step(keta-1,2) do |num|
total=total+(9*10**(num-1))
end
if keta%2 == 1
total=total+(number-(10**(keta-1)))+1
end
puts total
| target=gets.chomp
number=target.to_i
keta = target.to_s.length.to_i
total=0
1.step(keta-1,2) do |num|
total=total+(9*10**(num-1))
end
if keta%2 == 1
total=total+(number-(10**(keta-1)))+1
end
puts total
| [
"call.add"
] | 754,817 | 754,815 | u562148988 | ruby |
p02952 | n = gets.to_i
count = 0
[1..n].each do |int|
count += 1 if int.to_s.size.odd?
end
puts count | n = gets.to_i
count = 0
[*1..n].each do |int|
count += 1 if int.to_s.size.odd?
end
puts count | [] | 754,826 | 754,827 | u920525832 | ruby |
p02952 | n = gets.chomp.to_i
if n < 10
puts n
elsif n < 100
puts 9
elsif n < 1000
puts (n - 99) + 9
elsif n < 10000
puts 909
elsif n < 1000000
puts (n - 9999) + 909
else
puts 90909
end
| n = gets.chomp.to_i
if n < 10
puts n
elsif n < 100
puts 9
elsif n < 1000
puts (n - 99) + 9
elsif n < 10000
puts 909
elsif n < 100000
puts (n - 9999) + 909
else
puts 90909
end
| [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 754,852 | 754,853 | u744908753 | ruby |
p02952 | n = gets.chomp
digit_count = n.size
res = 0
(1..digit_count).each do |i|
i.even? && next
if i == 1
if digit_count > 1
res += 9
else
res += digit_count
end
next
end
if i == digit_count
x = '1'
(1..i-1).each { x += '0' }
res += n.to_i - x.to_i + 1
next
end
res += 10**(i - 1) * 9
end
puts res | n = gets.chomp
digit_count = n.size
res = 0
(1..digit_count).each do |i|
i.even? && next
if i == 1
if digit_count > 1
res += 9
else
res += n.to_i
end
next
end
if i == digit_count
x = '1'
(1..i-1).each { x += '0' }
res += n.to_i - x.to_i + 1
next
end
res += 10**(i - 1) * 9
end
puts res | [
"call.add"
] | 754,886 | 754,887 | u675497468 | ruby |
p02952 | n = gets.to_i
ret = 0
n.times do |i|
if((1 <= i) && (i <= 9))
ret += 1;
elsif((100 <= i) && (i <= 999))
ret += 1;
elsif((10000 <= i) && (i <= 99999))
ret += 1;
end
end
puts ret | n = gets.to_i
ret = 0
(n+1).times do |i|
if((1 <= i) && (i <= 9))
ret += 1;
elsif((100 <= i) && (i <= 999))
ret += 1;
elsif((10000 <= i) && (i <= 99999))
ret += 1;
end
end
puts ret
| [] | 755,115 | 755,116 | u559342926 | ruby |
p02952 | n = gets.to_i
ret = 0
n.each do |i|
if((0 <= i) && (i <= 9))
ret += 1;
elsif((100 <= i) && (i <= 999))
ret += 1;
elsif((10000 <= i) && (i <= 99999))
ret += 1;
end
end
puts ret | n = gets.to_i
ret = 0
(n+1).times do |i|
if((1 <= i) && (i <= 9))
ret += 1;
elsif((100 <= i) && (i <= 999))
ret += 1;
elsif((10000 <= i) && (i <= 99999))
ret += 1;
end
end
puts ret
| [
"identifier.change",
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 755,117 | 755,116 | u559342926 | ruby |
p02952 | n = gets
ans = 0
n.size.times do |i|
next if i.odd?
lower = ("1" + ("0" * i)).to_i
upper = [("9" * (i + 1)).to_i, n.to_i].min
ans += upper - lower + 1
end
puts ans
| n = gets
ans = 0
n.size.times do |i|
next if i.odd?
lower = ("1" + ("0" * i)).to_i
upper = [("9" * (i + 1)).to_i, n.to_i].min
next if upper < lower
ans += upper - lower + 1
end
puts ans
| [] | 755,173 | 755,174 | u457499130 | ruby |
p02952 | N = gets.to_i
unevenNumbers = []
for i in 1..N do
if i%2 !=0
unevenNumbers << i
end
end
puts unevenNumbers.length
| N = gets.to_i
unevenNumbers = []
for i in 1..N do
if i.to_s.length%2 !=0
unevenNumbers << i
end
end
puts unevenNumbers.length
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 755,233 | 755,234 | u932417742 | ruby |
p02952 | n = gets.chomp.to_i
answer =
case n.to_s.size
when 1
n
when 2
9
when 3
9 + n - 99
when 4
899 + 9
when 5
899 + 9 + n - 9999
when 6
89999 + 899 + 9
end
puts answer
| n = gets.chomp.to_i
answer =
case n.to_s.size
when 1
n
when 2
9
when 3
9 + n - 99
when 4
900 + 9
when 5
900 + 9 + n - 9999
when 6
90000 + 900 + 9
end
puts answer
| [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 755,366 | 755,367 | u623402808 | ruby |
p02952 | n = gets.chomp!
s = n.size
n = n.to_i
if s == 1 or s == 2
puts n
elsif s == 3
puts 9 + (n - 99)
elsif s == 4
puts 909
elsif s == 5
puts 9 + 900 + (n - 9999)
elsif s == 6
puts 90909
end
| n = gets.chomp!
s = n.size
n = n.to_i
if s == 1
puts n
elsif s == 2
puts 9
elsif s == 3
puts 9 + (n - 99)
elsif s == 4
puts 909
elsif s == 5
puts 9 + 900 + (n - 9999)
elsif s == 6
puts 90909
end
| [
"control_flow.branch.if.condition.change",
"call.arguments.change",
"identifier.replace.remove",
"literal.replace.add"
] | 755,535 | 755,536 | u178515699 | ruby |
p02952 | n = gets.to_i
(1..n).count{|i|i.to_s.size % 2 == 1} | n = gets.to_i
puts (1..n).count{|i|i.to_s.size % 2 == 1} | [
"io.output.change",
"call.add"
] | 755,854 | 755,855 | u158131514 | ruby |
p02953 | gets
h = gets.split.map &:toi
d = [-1]
h.each{|i| d = (i-1..i).select{|j| d.any?{|k| k<=j}}}
puts d[0] ? :Yes : :No | gets
h = gets.split.map &:to_i
d = [-1]
h.each{|i| d = (i-1..i).select{|j| d.any?{|k| k<=j}}}
puts d[0] ? :Yes : :No | [
"assignment.value.change",
"call.arguments.change"
] | 756,764 | 756,765 | u976045235 | ruby |
p02953 | N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
if h <= top
max = h
else
if h-1 == top
next
else
result = "No"
break
end
end
end
puts result | N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
if h <= top
top = h
else
if h-1 == top
next
else
result = "No"
break
end
end
end
puts result | [
"assignment.variable.change",
"identifier.change"
] | 756,843 | 756,844 | u390727364 | ruby |
p02953 | N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
if h <= top
max = h
else
if h-1 == max
next
else
result = "No"
break
end
end
end
puts result | N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
if h <= top
top = h
else
if h-1 == top
next
else
result = "No"
break
end
end
end
puts result | [
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 756,845 | 756,844 | u390727364 | ruby |
p02953 | N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
if h <= top
max = h
else
if h-1 == max
next
else
check = "No"
break
end
end
end
puts result | N = gets.to_i
H = gets.split.map(&:to_i)
result = "Yes"
top = H[-1]
H.reverse.each do |h|
if h <= top
top = h
else
if h-1 == top
next
else
result = "No"
break
end
end
end
puts result | [
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 756,846 | 756,844 | u390727364 | ruby |
p02953 | lines = STDIN.readlines
n = lines[0].chomp.to_i
h = lines[1].split(" ").map(&:to_i).reverse
(n-1).times do |i|
p h
if h[i + 1] - h[i] > 1
puts "No"
exit
end
if h[i+1] - h[i] == 1
h[i + 1] -= 1
next
end
end
puts "Yes"
| lines = STDIN.readlines
n = lines[0].chomp.to_i
h = lines[1].split(" ").map(&:to_i).reverse
(n-1).times do |i|
if h[i + 1] - h[i] > 1
puts "No"
exit
end
if h[i+1] - h[i] == 1
h[i + 1] -= 1
next
end
end
puts "Yes"
| [
"call.remove"
] | 757,158 | 757,159 | u690357343 | ruby |
p02953 | n = gets.to_i
h = gets.split.map(&:to_i)
(n-1).downto(0) do |i|
if i == 0
puts "Yes"
p h
return
end
if h[i-1] - h[i] > 1
puts "No"
return
elsif h[i-1] - h[i] == 1
h[i-1] -= 1
end
end
| n = gets.to_i
h = gets.split.map &:to_i
(n-1).downto(0) do |i|
if i == 0
puts "Yes"
exit
end
if h[i-1] - h[i] > 1
puts "No"
exit
elsif h[i-1] - h[i] == 1
h[i-1] -= 1
end
end
| [
"call.arguments.change",
"io.output.change",
"control_flow.return.remove",
"control_flow.exit.add"
] | 757,164 | 757,163 | u212567766 | ruby |
p02953 | n = gets.to_i
h = gets.split.map &:to_i
(n-1).downto(0) do |i|
if i == 0
puts "Yes"
p h
return
end
if h[i-1] - h[i] > 1
puts "No"
return
elsif h[i-1] - h[i] == 1
h[i-1] -= 1
end
end
| n = gets.to_i
h = gets.split.map &:to_i
(n-1).downto(0) do |i|
if i == 0
puts "Yes"
exit
end
if h[i-1] - h[i] > 1
puts "No"
exit
elsif h[i-1] - h[i] == 1
h[i-1] -= 1
end
end
| [
"io.output.change",
"call.arguments.change",
"control_flow.return.remove",
"control_flow.exit.add"
] | 757,165 | 757,163 | u212567766 | ruby |
p02953 | n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
if n == 1
puts "Yes"
exit
end
for i in 0..(n-1) do
if i == 1
h[i] -= 1
else
if h[i-1] <= h[i]-1
h[i] -= 1
end
end
end
hcop = h.sort
for i in 0..(n-1) do
if h[i] != hcop[i]
puts "No"
exit
end
end
puts "Yes"
| n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
if n == 1
puts "Yes"
exit
end
for i in 0..(n-1) do
if i == 0
h[i] -= 1
else
if h[i-1] <= h[i]-1
h[i] -= 1
end
end
end
hcop = h.sort
for i in 0..(n-1) do
if h[i] != hcop[i]
puts "No"
exit
end
end
puts "Yes"
| [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 757,204 | 757,205 | u512524057 | ruby |
p02953 | n = gets.to_i
hs = gets.strip.split.map(&:to_i)
# 右から見ていって、自分より右側にあるものの最小値を覚えておく
# 自分を1下げた時、自分より右側に自分より小さいものがあればダメ
arr = []
min = 10 ** 10
hs.each_with_index.reverse_each do |v, i|
min = v if min > v
arr << min
end
arr.reverse!
puts hs.each_with_index.map {|v, i| v - 1 <= arr[i]}.all? ? "YES" : "NO" | n = gets.to_i
hs = gets.strip.split.map(&:to_i)
# 右から見ていって、自分より右側にあるものの最小値を覚えておく
# 自分を1下げた時、自分より右側に自分より小さいものがあればダメ
arr = []
min = 10 ** 10
hs.each_with_index.reverse_each do |v, i|
min = v if min > v
arr << min
end
arr.reverse!
puts hs.each_with_index.map {|v, i| v - 1 <= arr[i]}.all? ? "Yes" : "No" | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 757,283 | 757,284 | u367259152 | ruby |
p02953 | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
p (ans ? "Yes" : "No") | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
puts (ans ? 'Yes' : 'No') | [
"call.function.change",
"io.output.change",
"literal.string.change",
"call.arguments.change"
] | 757,438 | 757,439 | u617691573 | ruby |
p02953 | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
p (ans ? 'Yes' : 'No') | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
puts (ans ? 'Yes' : 'No') | [
"call.function.change",
"io.output.change"
] | 757,440 | 757,439 | u617691573 | ruby |
p02953 | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
p (ans ? "Yes" : "No") | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
puts (ans ? "Yes" : "No") | [
"call.function.change",
"io.output.change"
] | 757,438 | 757,441 | u617691573 | ruby |
p02953 | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
p (ans ? 'Yes' : 'No') | n = gets.to_i
h = gets.split.map(&:to_i)
ans = true
h[0] -= 1
(1...n).each do |i|
if h[i] > h[i-1]
h[i] -= 1
elsif h[i] < h[i-1]
ans = false
break
end
end
puts (ans ? "Yes" : "No") | [
"call.function.change",
"io.output.change",
"literal.string.change",
"call.arguments.change"
] | 757,440 | 757,441 | u617691573 | ruby |
p02953 | N = gets.chomp.to_i
H = gets.chomp.split(" ").map(&:to_i)
if N == 1
puts "Yes"
exit
end
unless H[0] <= H[1] - 1
puts "No"
exit
end
prev_h = H[0] - 1
1.upto(N-1) do |i|
if H[i] < prev_h
puts "No"
exit
end
prev_h = [prev_h, H[i] - 1].max
end
puts "Yes"
| N = gets.chomp.to_i
H = gets.chomp.split(" ").map(&:to_i)
if N == 1
puts "Yes"
exit
end
if H[0] > H[1] + 1
puts "No"
exit
end
prev_h = H[0] - 1
1.upto(N-1) do |i|
if H[i] < prev_h
puts "No"
exit
end
prev_h = [prev_h, H[i] - 1].max
end
puts "Yes"
| [
"expression.operator.compare.change",
"expression.operation.binary.change",
"misc.opposites",
"expression.operator.arithmetic.change"
] | 757,811 | 757,812 | u443924743 | ruby |
p02953 | N = gets.chomp.to_i
H = gets.chomp.split(" ").map(&:to_i)
if N == 1
puts "Yes"
exit
end
unless H[0] <= H[1] - 1
puts "No"
exit
end
prev_h = H[0]
1.upto(N-1) do |i|
if H[i] < prev_h
puts "No"
exit
end
prev_h = [prev_h, H[i] - 1].max
end
puts "Yes"
| N = gets.chomp.to_i
H = gets.chomp.split(" ").map(&:to_i)
if N == 1
puts "Yes"
exit
end
if H[0] > H[1] + 1
puts "No"
exit
end
prev_h = H[0] - 1
1.upto(N-1) do |i|
if H[i] < prev_h
puts "No"
exit
end
prev_h = [prev_h, H[i] - 1].max
end
puts "Yes"
| [
"expression.operator.compare.change",
"expression.operation.binary.change",
"misc.opposites",
"expression.operator.arithmetic.change"
] | 757,813 | 757,812 | u443924743 | ruby |
p02954 | S = gets.chomp
rl = [-1]
until rl[-1] == nil do
rl << S.index('RL', rl[-1] + 1)
end
rl.shift
rl.pop
lr = [0]
until lr[-1] == nil do
lr << S.index('LR', lr[-1] + 1)
end
lr.shift
lr.pop
rl.map!{|e| e + 1}
lr.map!{|e| e + 1}
lr.unshift(0)
lr.push(S.size)
p rl
p lr
ans = Array.new(S.size, 0)
rl.each_with_index{|rl, idx|
r = rl - lr[idx]
l = lr[idx + 1] - rl
ans[rl - 1] += (r / 2 + l / 2)
ans[rl] += (r / 2 + l / 2)
ans[rl - 1] += 1 if r.odd?
ans[rl] += 1 if l.odd?
}
puts ans.join(' ')
| S = gets.chomp
rl = [-1]
until rl[-1] == nil do
rl << S.index('RL', rl[-1] + 1)
end
rl.shift
rl.pop
lr = [0]
until lr[-1] == nil do
lr << S.index('LR', lr[-1] + 1)
end
lr.shift
lr.pop
rl.map!{|e| e + 1}
lr.map!{|e| e + 1}
lr.unshift(0)
lr.push(S.size)
ans = Array.new(S.size, 0)
rl.each_with_index{|rl, idx|
r = rl - lr[idx]
l = lr[idx + 1] - rl
ans[rl - 1] += (r / 2 + l / 2)
ans[rl] += (r / 2 + l / 2)
ans[rl - 1] += 1 if r.odd?
ans[rl] += 1 if l.odd?
}
puts ans.join(' ')
| [
"call.remove"
] | 758,468 | 758,469 | u276517671 | ruby |
p02954 | S = gets.chomp
n = S.length
ans = Array.new(S.length, 0)
cnt = 0
n.times do |i|
if S[i] == 'R'
cnt += 1
else
ans[i] += cnt/2
ans[i-1] += (cnt+1)/2
cnt = 0
end
end
cnt = 0
(n-1).downto(0) do |i|
if S[i] == 'L'
cnt += 1
else
ans[i] += cnt/2
ans[i+1] += (cnt+1)/2
cnt = 0
end
end
puts ans.join()
| S = gets.chomp
n = S.length
ans = Array.new(S.length, 0)
cnt = 0
n.times do |i|
if S[i] == 'R'
cnt += 1
else
ans[i] += cnt/2
ans[i-1] += (cnt+1)/2
cnt = 0
end
end
cnt = 0
(n-1).downto(0) do |i|
if S[i] == 'L'
cnt += 1
else
ans[i] += cnt/2
ans[i+1] += (cnt+1)/2
cnt = 0
end
end
puts ans.join(' ')
| [] | 758,568 | 758,569 | u620219777 | ruby |
p02954 | chars = gets.chars
ans = Array.new(chars.length) { 0 }
cnt = 0
chars.each_with_index do |c, i|
if c == 'R'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
cnt = 0
chars.reverse.each_with_index do |c, i|
if c == 'L'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
puts ans.join(' ') | chars = gets.chomp.chars
ans = Array.new(chars.length) { 0 }
cnt = 0
chars.each_with_index do |c, i|
if c == 'R'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
cnt = 0
chars.reverse.each_with_index do |c, i|
if c == 'L'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
puts ans.join(' ') | [
"call.add"
] | 758,626 | 758,627 | u981932242 | ruby |
p02954 | chars = gets.chars
ans = Array.new(chars.length) { 0 }
cnt = 0
chars.each_with_index do |c, i|
if c == 'R'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
cnt = 0
chars.reverse.each_with_index do |c, i|
if c == 'L'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
puts ans.join(' ').strip | chars = gets.chomp.chars
ans = Array.new(chars.length) { 0 }
cnt = 0
chars.each_with_index do |c, i|
if c == 'R'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
cnt = 0
chars.reverse.each_with_index do |c, i|
if c == 'L'
cnt += 1
else
ans[i] += cnt / 2
ans[i - 1] += (cnt + 1) / 2
cnt = 0
end
end
ans.reverse!
puts ans.join(' ') | [
"call.add",
"call.remove"
] | 758,628 | 758,627 | u981932242 | ruby |
p02954 | s=gets.chomp
ary=s.scan(/R+L+/)
res=[]
ary.each do |str|
rnum=str[/R+/].size
lnum=str.size-rnum
n=rnum/2 + lnum/2
if rnum.size.odd?
rres=n+1
# 0000n+1n+10000
else
rres=n
end
if lnum.size.odd?
lres=n+1
# 0000n+1n+10000
else
lres=n
end
(2..rnum).each{|i| res<<0}
res << rres
res << lres
(2..lnum).each{|i| res<<0}
end
puts res.join(' ') | s=gets.chomp
ary=s.scan(/R+L+/)
res=[]
ary.each do |str|
rnum=str[/R+/].size
lnum=str.size-rnum
n=rnum/2 + lnum/2
if rnum.odd?
rres=n+1
# 0000n+1n+10000
else
rres=n
end
if lnum.odd?
lres=n+1
# 0000n+1n+10000
else
lres=n
end
(2..rnum).each{|i| res<<0}
res << rres
res << lres
(2..lnum).each{|i| res<<0}
end
puts res.join(' ') | [
"call.remove"
] | 758,657 | 758,658 | u883824971 | ruby |
p02954 | #abc136 D
s = gets
n,l,r = s.length, 0, 0
ans = Array.new(n,0)
n.times do |i|
if s[i]=='R'
if (l+r).even?
l+=1
else
r+=1
end
else
ans[i-1] += l
ans[i] += r
l,r=0,0
end
end
(n-1).downto(0) do |i|
if s[i]=='L'
if (l+r).odd?
l+=1
else
r+=1
end
else
ans[i] += l
ans[i+1] += r
l,r=0,0
end
end
ans.each do |x|
print x,' '
end
| #abc136 D
s = gets.chomp
n,l,r = s.length, 0, 0
ans = Array.new(n,0)
n.times do |i|
if s[i]=='R'
if (l+r).even?
l+=1
else
r+=1
end
else
ans[i-1] += l
ans[i] += r
l,r=0,0
end
end
(n-1).downto(0) do |i|
if s[i]=='L'
if (l+r).odd?
l+=1
else
r+=1
end
else
ans[i] += l
ans[i+1] += r
l,r=0,0
end
end
ans.each do |x|
print x,' '
end | [
"call.add"
] | 758,722 | 758,723 | u053360288 | ruby |
p02954 | s = gets.chomp
ans = []
i = 0
while i < s.size
tmp = i
while s[i] == "R"
i += 1
end
r = i - tmp
while s[i] == "L"
i += 1
end
l = i - r - tmp
if (l + r).odd?
if r > l
if (r - 1).odd? # 反転
(r - 1).times do
ans << 0
end
ans << (l + r) / 2
ans << (l + r) / 2 + 1
(l - 1).times do
ans << 0
end
else
(r - 1).times do
ans << 0
end
ans << (l + r) / 2 + 1
ans << (l + r) / 2
(l - 1).times do
ans << 0
end
end
else
if (l - 1).odd? # 反転
(r - 1).times do
ans << 0
end
ans << (l + r) / 2 + 1
ans << (l + r) / 2
(l - 1).times do
ans << 0
end
else
(r - 1).times do
ans << 0
end
ans << (l + r) / 2
ans << (l + r) / 2 + 1
(l - 1).times do
ans << 0
end
end
end
else
a = (l + r) / 2
(a - 1).times do
ans << 0
end
ans << a
ans << a
(a - 1).times do
ans << 0
end
end
end
puts ans * ' ' | s = gets.chomp
ans = []
i = 0
while i < s.size
tmp = i
while s[i] == "R"
i += 1
end
r = i - tmp
while s[i] == "L"
i += 1
end
l = i - r - tmp
if (l + r).odd?
if r > l
if (r - 1).odd? # 反転
(r - 1).times do
ans << 0
end
ans << (l + r) / 2
ans << (l + r) / 2 + 1
(l - 1).times do
ans << 0
end
else
(r - 1).times do
ans << 0
end
ans << (l + r) / 2 + 1
ans << (l + r) / 2
(l - 1).times do
ans << 0
end
end
else
if (l - 1).odd? # 反転
(r - 1).times do
ans << 0
end
ans << (l + r) / 2 + 1
ans << (l + r) / 2
(l - 1).times do
ans << 0
end
else
(r - 1).times do
ans << 0
end
ans << (l + r) / 2
ans << (l + r) / 2 + 1
(l - 1).times do
ans << 0
end
end
end
else
a = (l + r) / 2
(r - 1).times do
ans << 0
end
ans << a
ans << a
(l - 1).times do
ans << 0
end
end
end
puts ans * ' ' | [
"identifier.change",
"expression.operation.binary.change"
] | 758,785 | 758,786 | u706695185 | ruby |
p02948 | #!/usr/bin/ruby
n, m = gets.split.map { |s| s.to_i }
ab = []
(0...n).each { |i|
ab[i] = gets.split.map { |s| s.to_i }
}
days = (1..m).to_a
payments = 0
ab.sort { |ab1, ab2|
a1, b1 = ab1
a2, b2 = ab2
if b1 != b2
b2 <=> b1
else
a1 <=> a2
end
}.each { |a, b|
i = days.bsearch_index { |d| d >= a }
next if i == nil
days.delete_at(i)
payments += b
break if days.length == 0
}
puts payments.reduce(:+)
| #!/usr/bin/ruby
n, m = gets.split.map { |s| s.to_i }
ab = []
(0...n).each { |i|
ab[i] = gets.split.map { |s| s.to_i }
}
days = (1..m).to_a
payments = 0
ab.sort { |ab1, ab2|
a1, b1 = ab1
a2, b2 = ab2
if b1 != b2
b2 <=> b1
else
a1 <=> a2
end
}.each { |a, b|
i = days.bsearch_index { |d| d >= a }
next if i == nil
days.delete_at(i)
payments += b
break if days.length == 0
}
puts payments
| [
"call.remove"
] | 759,006 | 759,007 | u404924624 | ruby |
p02948 | # A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
# MOD=1000000007
# 優先度付きキュー
class PriorityQueue
# 優先度付きキューのノードクラス
class Node
attr_reader :id
attr_accessor :priority, :value
@@next_id=0 # 自動でidを付与するために使用
def initialize(priority,value=nil, id: nil)
if id.nil? # idの自動付与
@id=@@next_id
@@next_id+=1
else # idの手動付与
@id=id
end
@priority=priority
@value=value
end
def self.reset # idを0からにリセット
@@next_id=0
end
end
def initialize
@nodes = [nil]
@id2index = {}
end
# Nodeクラスのノードを保存する
def <<(new_node)
@nodes << new_node
@id2index[new_node.id]=@nodes.size-1
bubble_up(@nodes.size-1)
end
alias :push :<<
# 最大優先度のノードを取り出す
def >>
return nil if empty?
hi=@nodes[1]
ti=@nodes[@nodes.size-1]
hiid=hi.id
tiid=ti.id
temp=@id2index[hiid]
@id2index[hiid]=@id2index[tiid]
@id2index[tiid]=temp
@nodes[1]=ti
@nodes[@nodes.size-1]=hi
max=@nodes.pop
bubble_down(1)
return max
end
alias :pop :>>
def empty?
return @nodes.size==1
end
# Nodeクラスの指定されたidの要素の優先度を変更する
# 指定されたidが存在しないときはfalseを返す
def change_priority(id,new_priority)
index=@id2index[id]
return false if index.nil?
@nodes[index].priority=new_priority
bubble_up(index)
bubble_down(index)
return true
end
# 指定されたidが存在しないときは例外を投げる
def change_priority!(id,new_priority)
if !change_priority(id,new_priority)
raise StandardError
end
return true
end
# ヒープ内で適切な位置になるように要素を上に移動させる
def bubble_up(index)
while true
parent_index=index/2
return if index<=1
ni=@nodes[index]
pi=@nodes[parent_index]
return if pi.priority>=ni.priority
niid=ni.id
piid=pi.id
temp=@id2index[niid]
@id2index[niid]=@id2index[piid]
@id2index[piid]=temp
@nodes[index]=pi
@nodes[parent_index]=ni
index=parent_index
end
end
# ヒープ内で適切な位置になるように要素を下に移動させる
def bubble_down(index)
while true
child_index=index*2
return if child_index>@nodes.size-1
child_index+=1 if child_index<@nodes.size-1 && @nodes[child_index+1]>@nodes[child_index]
ni=@nodes[index]
ci=@nodes[child_index]
return if ni.priority>ci.priority
niid=ni.id
ciid=ci.id
temp=@id2index[niid]
@id2index[niid]=@id2index[ciid]
@id2index[ciid]=temp
@nodes[index]=ci
@nodes[child_index]=ni
index=child_index
end
end
end
N,M=gets.split.map(&:to_i)
task_part=Array.new(10**5+1){Array.new}
N.times do
a,b=gets.split.map(&:to_i)
task_part[a-1] << b
end
PQ=PriorityQueue.new
ans=0
M.times do |t|
task_part[t].each do |b|
PQ << PriorityQueue::Node.new(b)
end
ans+=PQ.pop.priority if !PQ.empty?
end
puts ans
| # A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
# MOD=1000000007
# 優先度付きキュー
class PriorityQueue
# 優先度付きキューのノードクラス
class Node
attr_reader :id
attr_accessor :priority, :value
@@next_id=0 # 自動でidを付与するために使用
def initialize(priority,value=nil, id: nil)
if id.nil? # idの自動付与
@id=@@next_id
@@next_id+=1
else # idの手動付与
@id=id
end
@priority=priority
@value=value
end
def self.reset # idを0からにリセット
@@next_id=0
end
end
def initialize
@nodes = [nil]
@id2index = {}
end
# Nodeクラスのノードを保存する
def <<(new_node)
@nodes << new_node
@id2index[new_node.id]=@nodes.size-1
bubble_up(@nodes.size-1)
end
alias :push :<<
# 最大優先度のノードを取り出す
def >>
return nil if empty?
hi=@nodes[1]
ti=@nodes[@nodes.size-1]
hiid=hi.id
tiid=ti.id
temp=@id2index[hiid]
@id2index[hiid]=@id2index[tiid]
@id2index[tiid]=temp
@nodes[1]=ti
@nodes[@nodes.size-1]=hi
max=@nodes.pop
bubble_down(1)
return max
end
alias :pop :>>
def empty?
return @nodes.size==1
end
# Nodeクラスの指定されたidの要素の優先度を変更する
# 指定されたidが存在しないときはfalseを返す
def change_priority(id,new_priority)
index=@id2index[id]
return false if index.nil?
@nodes[index].priority=new_priority
bubble_up(index)
bubble_down(index)
return true
end
# 指定されたidが存在しないときは例外を投げる
def change_priority!(id,new_priority)
if !change_priority(id,new_priority)
raise StandardError
end
return true
end
# ヒープ内で適切な位置になるように要素を上に移動させる
def bubble_up(index)
while true
parent_index=index/2
return if index<=1
ni=@nodes[index]
pi=@nodes[parent_index]
return if pi.priority>=ni.priority
niid=ni.id
piid=pi.id
temp=@id2index[niid]
@id2index[niid]=@id2index[piid]
@id2index[piid]=temp
@nodes[index]=pi
@nodes[parent_index]=ni
index=parent_index
end
end
# ヒープ内で適切な位置になるように要素を下に移動させる
def bubble_down(index)
while true
child_index=index*2
return if child_index>@nodes.size-1
child_index+=1 if child_index<@nodes.size-1 && @nodes[child_index+1].priority>@nodes[child_index].priority
ni=@nodes[index]
ci=@nodes[child_index]
return if ni.priority>ci.priority
niid=ni.id
ciid=ci.id
temp=@id2index[niid]
@id2index[niid]=@id2index[ciid]
@id2index[ciid]=temp
@nodes[index]=ci
@nodes[child_index]=ni
index=child_index
end
end
end
N,M=gets.split.map(&:to_i)
task_part=Array.new(10**5+1){Array.new}
N.times do
a,b=gets.split.map(&:to_i)
task_part[a-1] << b
end
PQ=PriorityQueue.new
ans=0
M.times do |t|
task_part[t].each do |b|
PQ << PriorityQueue::Node.new(b)
end
ans+=PQ.pop.priority if !PQ.empty?
end
puts ans
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 759,018 | 759,019 | u364298541 | ruby |
p02954 | tr = gets.chomp
array = [0] * str.length
i = 0
while index = str.index(/L(R|$)/, i)
sindex = str.index('RL', i)
r = sindex - i + 1
l = index - sindex
array[sindex] = r / 2 + l / 2
array[sindex] += 1 if r.odd?
array[sindex + 1] = r / 2 + l / 2
array[sindex + 1] += 1 if l.odd?
i = index + 1
end
puts array.join(' ') | str = gets.chomp
array = [0] * str.length
i = 0
while index = str.index(/L(R|$)/, i)
sindex = str.index('RL', i)
r = sindex - i + 1
l = index - sindex
array[sindex] = r / 2 + l / 2
array[sindex] += 1 if r.odd?
array[sindex + 1] = r / 2 + l / 2
array[sindex + 1] += 1 if l.odd?
i = index + 1
end
puts array.join(' ') | [
"assignment.variable.change",
"identifier.change"
] | 759,106 | 759,107 | u102720298 | ruby |
p02957 | a, b = gets.chomp.split.map(&:to_i)
puts ((a + b) % 2 == 0)? (a - b).abs / 2 : "IMPOSSIBLE" | a, b = gets.chomp.split.map(&:to_i)
puts ((a + b) % 2 == 0)? (a + b) / 2 : "IMPOSSIBLE" | [
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"call.remove"
] | 760,012 | 760,013 | u482840940 | ruby |
p02957 | a, b = gets.chomp.split.map(&:to_i)
if (a + b)%2 == 0 # 余り 0 の割り算
puts (a + b) / 2
else
puts "impossible"
end
# 計算式わからなかった。。。
| a, b = gets.chomp.split.map(&:to_i)
if (a + b)%2 == 0 # 余り 0 の割り算
puts (a + b) / 2
else
puts "IMPOSSIBLE"
end
# 計算式わからなかった。。。
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 760,100 | 760,101 | u552761221 | ruby |
p02957 | a, b = gets.chomp.split.map(&:to_i)
if (a + b)%2 == 0 # 余り 0 の割り算
puts a + b / 2
else
puts "impossible"
end
# 計算式わからなかった。。。
| a, b = gets.chomp.split.map(&:to_i)
if (a + b)%2 == 0 # 余り 0 の割り算
puts (a + b) / 2
else
puts "IMPOSSIBLE"
end
# 計算式わからなかった。。。
| [
"call.arguments.change",
"literal.string.change",
"literal.string.case.change"
] | 760,102 | 760,101 | u552761221 | ruby |
p02957 | n = gets.split.map(&:to_i).inject(:+)
p n.even? ? n/2 : "IMPOSSIBLE" | n = gets.split.map(&:to_i).inject(:+)
puts n.even? ? n/2 : "IMPOSSIBLE" | [
"call.function.change",
"io.output.change"
] | 760,777 | 760,778 | u502306384 | ruby |
p02957 | arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
x = (arr[1]+arr[0])/2
if x%2 == 0
puts x
else
puts "IMPOSSIBLE"
end | arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
x = (arr[1]+arr[0])
if x % 2 == 0
puts x / 2
else
puts "IMPOSSIBLE"
end
| [
"expression.operation.binary.remove"
] | 760,885 | 760,886 | u294388467 | ruby |
p02957 | arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
x = (arr[1]+arr[0])/2
if x%2 == 0
puts x
else
puts "IMPOSSIBLE"
end | arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
x = (arr[1]+arr[0])
if x%2 == 0
puts x/2
else
puts "IMPOSSIBLE"
end | [
"expression.operation.binary.remove"
] | 760,885 | 760,887 | u294388467 | ruby |
p02957 | a,b = gets.chomp.split("").map(&:to_i)
if (a+b).even?
puts (a+b)/2
else
puts "IMPOSSIBLE"
end
| a,b = gets.chomp.split().map(&:to_i)
if (a+b).even?
puts (a+b)/2
else
puts "IMPOSSIBLE"
end
| [] | 760,944 | 760,945 | u012110567 | ruby |
p02957 | a,b = gets.chomp.split("").map(&:to_i)
if (a+b).even?
puts a+b/2
else
puts "IMPOSSIBLE"
end
| a,b = gets.chomp.split().map(&:to_i)
if (a+b).even?
puts (a+b)/2
else
puts "IMPOSSIBLE"
end
| [
"call.arguments.change"
] | 760,946 | 760,945 | u012110567 | ruby |
p02957 | A, B = gets.split.map(&:to_i)
a = [A, B].min
b = [A, B].max
if (b - a) % 2 == 1
puts "IMPOSSIBLE"
else
puts a + b / 2
end | A, B = gets.split.map(&:to_i)
a = [A, B].min
b = [A, B].max
if (b - a) % 2 == 1
puts "IMPOSSIBLE"
else
puts (a + b) / 2
end | [
"call.arguments.change"
] | 761,184 | 761,185 | u843127718 | ruby |
p02957 | a,b = gets.split.map(&:to_i)
p (a+b).even? ? (a+b)/2 : 'IMPOSSIBLE' | a,b = gets.split.map(&:to_i)
puts (a+b).even? ? (a+b)/2 : 'IMPOSSIBLE' | [
"call.function.change",
"io.output.change"
] | 761,222 | 761,223 | u562082015 | ruby |
p02957 | a,b = gets.split.map(&:to_i)
p (a+b).even? ? (a+b)/2 : "IMPOSSIBLE" | a,b = gets.split.map(&:to_i)
puts (a+b).even? ? (a+b)/2 : 'IMPOSSIBLE' | [
"call.function.change",
"io.output.change",
"literal.string.change",
"call.arguments.change"
] | 761,224 | 761,223 | u562082015 | ruby |
p02957 | a,b = gets.chomp.split.map(&to_i)
if (a+b).even?
puts (a+b)/2
else
puts 'IMPOSSIBLE'
end | a,b = gets.chomp.split.map(&:to_i)
if (a+b).even?
puts (a+b)/2
else
puts 'IMPOSSIBLE'
end | [
"assignment.value.change",
"call.arguments.change"
] | 761,725 | 761,726 | u303448696 | ruby |
p02957 | a,b = gets.split.map &:to_i
p (a+b)%2 == 0 ? (a+b)/2 : "IMPOSSIBLE" | a,b = gets.split.map &:to_i
puts (a+b)%2 == 0 ? (a+b)/2 : "IMPOSSIBLE" | [
"call.function.change",
"io.output.change"
] | 761,827 | 761,828 | u212567766 | ruby |
p02957 |
x = gets.chomp.split("")
a = x[0].to_i
b = x[2].to_i
if (a+b)%2 == 0
puts((a+b)/2)
else
puts('IMPOSSIBLE')
end
| x = gets.chomp.split(" ")
a = x[0].to_i
b = x[1].to_i
if (a+b)%2 == 0
puts((a+b)/2)
else
puts('IMPOSSIBLE')
end | [
"literal.string.change",
"assignment.value.change",
"call.arguments.change",
"literal.number.integer.change",
"variable_access.subscript.index.change"
] | 761,874 | 761,875 | u803116463 | ruby |
p02957 | n = gets.strip.split.map(&:to_i)
if (n[0] + n[1])%2 == 0
puts (n[0] + n[1])/2
else
puts "IMPOSIBLE"
end | n = gets.strip.split.map(&:to_i)
if (n[0] + n[1])%2 == 0
puts (n[0] + n[1])/2
else
puts "IMPOSSIBLE"
end | [
"literal.string.change",
"call.arguments.change"
] | 761,882 | 761,883 | u054055736 | ruby |
p02957 | n = gets.strip.split.map(&:to_i)
if (n[0] + n[1])%2 == 0
puts (n[0] + n[1])/2
else
puts "IMPOSIVEL"
end | n = gets.strip.split.map(&:to_i)
if (n[0] + n[1])%2 == 0
puts (n[0] + n[1])/2
else
puts "IMPOSSIBLE"
end | [
"literal.string.change",
"call.arguments.change"
] | 761,884 | 761,883 | u054055736 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.