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 |
|---|---|---|---|---|---|---|---|
p03162
|
n = gets.to_i
dp = Array.new(n) { Array.new(3, 0) }
n.times do |i|
a, b, c = gets.chomp.split.map(&:to_i)
if i == 0
dp[0] = [a, b, c]
else
dp[i][0] = [dp[i - 1][1], dp[i - 1][2]].max + a
dp[i][1] = [dp[i - 1][2], dp[i - 1][1]].max + b
dp[i][2] = [dp[i - 1][0], dp[i - 1][0]].max + c
end
end
puts dp[-1].max
|
n = gets.to_i
dp = Array.new(n) { Array.new(3, 0) }
n.times do |i|
a, b, c = gets.chomp.split.map(&:to_i)
if i == 0
dp[0] = [a, b, c]
else
dp[i][0] = [dp[i - 1][1], dp[i - 1][2]].max + a
dp[i][1] = [dp[i - 1][2], dp[i - 1][0]].max + b
dp[i][2] = [dp[i - 1][0], dp[i - 1][1]].max + c
end
end
puts dp[-1].max
|
[
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 963,355
| 963,356
|
u482840940
|
ruby
|
p03162
|
N = gets.to_i
a = []
b = []
c = []
N.times do
gets.split(' ').each_with_index do |e, i|
a << e.to_i if i == 1
b << e.to_i if i == 2
c << e.to_i if i == 3
end
end
d = [[a[0], b[0], c[0]]]
(1...N).each do |i|
d << [[d[i-1][1], d[i-1][2]].max + a[i], [d[i-1][0], d[i-1][2]].max + b[i], [d[i-1][0], d[i-1][1]].max + c[i]]
end
puts d[-1].max
|
N = gets.to_i
a = []
b = []
c = []
N.times do
gets.split(' ').each_with_index do |e, i|
a << e.to_i if i == 0
b << e.to_i if i == 1
c << e.to_i if i == 2
end
end
d = [[a[0], b[0], c[0]]]
(1...N).each do |i|
d << [[d[i-1][1], d[i-1][2]].max + a[i], [d[i-1][0], d[i-1][2]].max + b[i], [d[i-1][0], d[i-1][1]].max + c[i]]
end
puts d[-1].max
|
[
"identifier.change",
"expression.operation.binary.change"
] | 965,272
| 965,273
|
u941522668
|
ruby
|
p03163
|
n,w = gets.chomp.split.map(&:to_i)
wv_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}
dp = Array.new(w+1, 0)
n.times do |i|
part_w, part_v = wv_arr[i]
w.downto(0) do |sum_w|
a = dp[sum_w - part_w] + part_v
b = dp[sum_w]
if sum_w - part_w >= 0 && a > b
dp[sum_w] = a
else
dp[sum_w] = b
end
puts dp.inspect
end
end
puts dp[w]
|
n,w = gets.chomp.split.map(&:to_i)
wv_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}
dp = Array.new(w+1, 0)
n.times do |i|
part_w, part_v = wv_arr[i]
w.downto(0) do |sum_w|
a = dp[sum_w - part_w] + part_v
b = dp[sum_w]
if sum_w - part_w >= 0 && a > b
dp[sum_w] = a
else
dp[sum_w] = b
end
end
end
puts dp[w]
|
[
"call.remove"
] | 965,489
| 965,490
|
u257668305
|
ruby
|
p03163
|
n, W_LIMIT = gets.to_s.split.map{|t| t.to_i }
wv = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }.sort_by{|w, _| w }
inf = 10 ** 12
dp = Array.new(W_LIMIT+1){ -inf }
dp[0] = 0
w_sum = 0
wv.each do |(w_i, v_i)|
w_sum = W_LIMIT < w_sum + w_i ? W_LIMIT : w_sum + w_i
w_sum.downto(w_i) do |w|
dp[w] = dp[w-w_i] + v_i if dp[w] < dp[w-w_i] + v_i
end
end
p dp
p dp.max
|
n, W_LIMIT = gets.to_s.split.map{|t| t.to_i }
wv = Array.new(n){ gets.to_s.split.map{|t| t.to_i } }.sort_by{|w, _| w }
inf = 10 ** 12
dp = Array.new(W_LIMIT+1){ -inf }
dp[0] = 0
w_sum = 0
wv.each do |(w_i, v_i)|
w_sum = W_LIMIT < w_sum + w_i ? W_LIMIT : w_sum + w_i
w_sum.downto(w_i) do |w|
dp[w] = dp[w-w_i] + v_i if dp[w] < dp[w-w_i] + v_i
end
end
p dp.max
|
[
"call.remove"
] | 965,594
| 965,595
|
u693378622
|
ruby
|
p03163
|
require 'pp'
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
N, W = gets_i_list
wv_list = []
N.times do
wv_list.push gets_i_list
end
wv_list.sort!{|x,y| x[0]<=>y[0]}
pp wv_list
dp = Array.new(W + 1, 0)
wv_list.each do |w, v|
W.downto(w) do |i|
dp[i] = dp[i - w] + v if dp[i] < dp[i - w] + v
end
end
puts dp.max
|
# https://atcoder.jp/contests/dp/submissions/12482219
require 'pp'
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
N, W = gets_i_list
wv_list = []
N.times do
wv_list.push gets_i_list
end
wv_list.sort!{|x,y| x[0]<=>y[0]}
dp = Array.new(W + 1, 0)
wv_list.each do |w, v|
W.downto(w) do |i|
dp[i] = dp[i - w] + v if dp[i] < dp[i - w] + v
end
end
puts dp.max
|
[
"call.remove"
] | 966,023
| 966,024
|
u370977023
|
ruby
|
p03163
|
require 'pp'
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
N, W = gets_i_list
wv_list = []
N.times do
wv_list.push gets_i_list
end
wv_list.sort!{|x,y| x[0]<=>y[0]}
pp wv_list
dp = Array.new(W + 1, 0)
wv_list.each do |w, v|
W.downto(w) do |i|
dp[i] = dp[i - w] + v if dp[i] < dp[i - w] + v
end
end
puts dp.max
|
require 'pp'
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
N, W = gets_i_list
wv_list = []
N.times do
wv_list.push gets_i_list
end
wv_list.sort!{|x,y| x[0]<=>y[0]}
dp = Array.new(W + 1, 0)
wv_list.each do |w, v|
W.downto(w) do |i|
dp[i] = dp[i - w] + v if dp[i] < dp[i - w] + v
end
end
puts dp.max
|
[
"call.remove"
] | 966,023
| 966,025
|
u370977023
|
ruby
|
p03163
|
n, W = gets.chomp.split.map(&:to_i)
dp = Array.new(W+1,0)
n.times do |i|
w, v = gets.chomp.split.map(&:to_i)
W.downto(0).each do |weight|
if w <= weight
dp[weight] = dp[weight-w] + v if dp[weight] < dp[weight-w] + v
end
end
end
# dp.each{|line| p line}
p dp
puts dp[W]
|
n, W = gets.chomp.split.map(&:to_i)
dp = Array.new(W+1,0)
n.times do |i|
w, v = gets.chomp.split.map(&:to_i)
W.downto(0).each do |weight|
if w <= weight
dp[weight] = dp[weight-w] + v if dp[weight] < dp[weight-w] + v
end
end
end
# dp.each{|line| p line}
# p dp
puts dp[W]
|
[
"call.remove"
] | 965,849
| 965,850
|
u524019694
|
ruby
|
p03163
|
n, W = gets.chomp.split.map(&:to_i)
dp = Array.new(W+1,0)
n.times do |i|
w, v = gets.chomp.split.map(&:to_i)
W.downto(0).each do |weight|
if w <= weight
dp[weight] = dp[weight-w] + v if dp[weight] < dp[weight-w] + v
end
end
end
# dp.each{|line| p line}
p dp
puts dp[W]
|
n, W = gets.chomp.split.map(&:to_i)
dp = Array.new(W+1,0)
n.times do |i|
w, v = gets.chomp.split.map(&:to_i)
W.downto(0).each do |weight|
if w <= weight
dp[weight] = dp[weight-w] + v if dp[weight] < dp[weight-w] + v
end
end
end
# dp.each{|line| p line}
# p dp
puts dp[W]
|
[
"call.remove"
] | 965,849
| 965,851
|
u524019694
|
ruby
|
p03163
|
N, W = gets.split.map(&:to_i)
dp_old = [0] * (W + 1)
1.upto(N) do |i|
w, v = gets.split.map(&:to_i)
dp = dp_old.clone
w.upto(W) do |w_max|
res = dp_old[w_max - w] + v
dp[w_max] = res if res < dp_old[w_max]
end
dp_old = dp
end
puts dp_old.last
|
N, W = gets.split.map(&:to_i)
dp_old = [0] * (W + 1)
1.upto(N) do |i|
w, v = gets.split.map(&:to_i)
dp = dp_old.clone
w.upto(W) do |w_max|
res = dp_old[w_max - w] + v
dp[w_max] = res if dp_old[w_max] < res
end
dp_old = dp
end
puts dp_old.last
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 968,342
| 968,343
|
u379804877
|
ruby
|
p03164
|
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def ang(n) Array.new(n){gsmi} end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def arrays(n,num) #要素数、配列数
ret = Array.new(num){Array.new(n)}
n.times do |i|
ins = gsmi
num.times{|j| ret[j][i] = ins[j] }
end
ret
end
inf = Float::INFINITY
$stdin = File.open('input.txt') if File.exist?('input.txt')
n,w_max = gsmi #100, 10**9
ws,vs = arrays(n,2) #w, 10**5
ws.unshift 0
vs.unshift 0
v_max = 100001
dp = []
(N+1).times do |n|
dp << [inf] * (v_max + 1)
end
dp[0][0] = 0
(1..n).each do |i|
v_max.times do |j|
if(j-vs[i]>=0)
#puts vs[i] if i==1 && j==1
dp[i][j] = min(dp[i-1][j], dp[i-1][j-vs[i]]+ws[i])
else
dp[i][j] = dp[i-1][j]
end
#dp[i][j] = dp[i-1][j] if dp[i][j] > dp[i-1][j]
end
end
(v_max-1).downto(0) do |j|
if dp[-1][j]<=w_max
puts j
exit
end
end
|
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def ang(n) Array.new(n){gsmi} end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def arrays(n,num) #要素数、配列数
ret = Array.new(num){Array.new(n)}
n.times do |i|
ins = gsmi
num.times{|j| ret[j][i] = ins[j] }
end
ret
end
inf = Float::INFINITY
$stdin = File.open('input.txt') if File.exist?('input.txt')
n,w_max = gsmi #100, 10**9
ws,vs = arrays(n,2) #w, 10**5
ws.unshift 0
vs.unshift 0
v_max = 100001
dp = []
(n+1).times do
dp << [inf] * (v_max + 1)
end
dp[0][0] = 0
(1..n).each do |i|
v_max.times do |j|
if(j-vs[i]>=0)
#puts vs[i] if i==1 && j==1
dp[i][j] = min(dp[i-1][j], dp[i-1][j-vs[i]]+ws[i])
else
dp[i][j] = dp[i-1][j]
end
#dp[i][j] = dp[i-1][j] if dp[i][j] > dp[i-1][j]
end
end
(v_max-1).downto(0) do |j|
if dp[-1][j]<=w_max
puts j
exit
end
end
|
[
"expression.operation.binary.change"
] | 969,359
| 969,360
|
u600153083
|
ruby
|
p03170
|
eval"N,K,*A="+`dd`.split*?,;
d=[1];
K.times{d<<A.find{|a|!d[-a]}}
puts d[-1]?:Second: :First
|
eval"N,K,*A="+`dd`.split*?,;
d=[1];
K.times{d<<!A.find{|a|d[-a]}}
puts d[-1]?:Second: :First
|
[
"expression.operation.unary.add",
"expression.operation.unary.logical.remove",
"call.arguments.change"
] | 978,433
| 978,434
|
u657913472
|
ruby
|
p03170
|
eval"N,K,*A="+`dd`.split*?,;
d=[p];
K.times{d<<A.find{|a|!d[-a]}}
puts d[-1]?:First: :Second
|
eval"N,K,*A="+`dd`.split*?,;
d=[1];
K.times{d<<!A.find{|a|d[-a]}}
puts d[-1]?:Second: :First
|
[
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"expression.operation.unary.add",
"expression.operation.unary.logical.remove",
"call.arguments.change"
] | 978,435
| 978,434
|
u657913472
|
ruby
|
p03186
|
cokkie=gets.chomp.split(" ").map(&:to_i)
if(cokkie[0]+cokkie[1]<cokkie[2]+1)
print(cokkie[0]+cokkie[1]*2+1)
else
print(cokkie[2]+cokkie[1])
end
|
cokkie=gets.chomp.split(" ").map(&:to_i)
if(cokkie[0]+cokkie[1]<cokkie[2])
print(cokkie[0]+cokkie[1]*2+1)
else
print(cokkie[2]+cokkie[1])
end
|
[
"expression.operation.binary.remove"
] | 987,596
| 987,597
|
u415400221
|
ruby
|
p03186
|
a, b, c = gets.chomp.split(" ").map(&:to_i)
n = a + b + c
count = 0
if a + b >= c
puts c + b
else
puts (a + b) + 3
end
|
a, b, c = gets.chomp.split(" ").map(&:to_i)
n = a + b + c
count = 0
if a + b >= c
puts c + b
else
puts b + (a + b + 1)
end
|
[
"expression.operation.binary.remove"
] | 987,829
| 987,830
|
u512524057
|
ruby
|
p03186
|
co = gets.split.map { |i| i.to_i }
if co[0]+co[1] >= co[2]+1
puts co[1]+co[2]
else
puts co[0] + 2*co[1] + 1
end
|
co = gets.split.map { |i| i.to_i }
if co[0]+co[1]+1 >= co[2]
puts co[1]+co[2]
else
puts co[0] + 2*co[1] + 1
end
|
[
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 987,914
| 987,915
|
u475329018
|
ruby
|
p03186
|
a,b,c = gets.split.map(&:to_i)
if a+b+1 < c
puts b + c-((a+b+c)-(a+b)*2+1)
else
puts b+c
end
|
a,b,c = gets.split.map(&:to_i)
if a+b+1 < c
puts b + c-((a+b+c)-((a+b)*2+1))
else
puts b+c
end
|
[
"call.arguments.change"
] | 987,961
| 987,962
|
u987183622
|
ruby
|
p03186
|
a,b,c=gets.split.map(&:to_i)
if (a + b + 1) >= c
puts(b+c)
else
puts(a + b + 1) + b
end
|
a,b,c=gets.split.map(&:to_i)
if (a + b + 1) >= c
puts(b+c)
else
puts((a + b + 1) + b)
end
|
[
"call.arguments.change"
] | 988,033
| 988,034
|
u427914934
|
ruby
|
p03186
|
a, b, c = gets.split.map(&:to_i)
if c < a + b - 1 then puts b + c
else puts b + (a + b + 1)
end
|
a, b, c = gets.split.map(&:to_i)
if c < a + b + 1 then puts b + c
else puts b + (a + b + 1)
end
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 988,230
| 988,231
|
u331906013
|
ruby
|
p03186
|
a, b, c = gets.split.map(&:to_i)
if c < a + b - 1 then puts b + c
else puts b + (a + b + 1)
end
|
a, b, c = gets.split.map(&:to_i)
if c < a + b + 1 then puts b + c
else puts b + (a + b + 1)
end
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change"
] | 988,230
| 988,234
|
u331906013
|
ruby
|
p03186
|
# A B C : C C -> end, max (B + C)
A, B, C = gets.split.map(&:to_i)
p A + B >= C ? B + C : A + B + 3
|
# A B C : C C -> end, max (B + C)
A, B, C = gets.split.map(&:to_i)
# delicious cookies - diff + 1
p A + B >= C ? B + C : A + 2 * B + 1
|
[
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 988,641
| 988,642
|
u333012034
|
ruby
|
p03192
|
str = gets
str.count('2')
|
puts gets.count('2')
|
[] | 989,205
| 989,207
|
u941522668
|
ruby
|
p03192
|
return gets.count('2')
|
puts gets.count('2')
|
[
"function.return_value.change"
] | 989,209
| 989,207
|
u941522668
|
ruby
|
p03192
|
gets.count('2')
|
puts gets.count('2')
|
[
"io.output.change",
"call.add"
] | 989,211
| 989,207
|
u941522668
|
ruby
|
p03192
|
number = input
res = number.to_s.scan(/2/).count
puts res
|
number = gets.chomp
res = number.to_s.scan(/2/).count
puts res
|
[
"assignment.value.change",
"call.add"
] | 989,279
| 989,280
|
u223072934
|
ruby
|
p03192
|
number = ARGV[0]
res = number.to_s.scan(/2/).count
puts res
|
number = gets.chomp
res = number.to_s.scan(/2/).count
puts res
|
[] | 989,281
| 989,280
|
u223072934
|
ruby
|
p03192
|
letter = gets.chomp!
array = letter.chars
m=0
p array
for i in (0..3)
if array[i]=="2"
m+=1
end
end
puts m
|
letter = gets.chomp!
array = letter.chars
m=0
for i in (0..3)
if array[i]=="2"
m+=1
end
end
puts m
|
[
"call.remove"
] | 989,292
| 989,293
|
u257354345
|
ruby
|
p03194
|
require 'prime'
N, P = gets.split.map &:to_i
primes = Prime.prime_division(P)
ans = 1
for pr, n in primes do
if n >= N then
ans *= pr*(n/N)
end
end
p ans
|
require 'prime'
N, P = gets.split.map &:to_i
primes = Prime.prime_division(P)
ans = 1
for pr, n in primes do
if n >= N then
ans *= pr**(n/N)
end
end
p ans
|
[
"call.arguments.change"
] | 990,130
| 990,131
|
u716826907
|
ruby
|
p03194
|
require 'prime'
n, x = gets.split.map(&:to_i)
a = Prime.prime_division(x)
ans = 1
a.each do |p, c|
if n <= c
ans *= p * (c / n)
end
end
puts ans
|
require 'prime'
n, x = gets.split.map(&:to_i)
a = Prime.prime_division(x)
ans = 1
a.each do |p, c|
if n <= c
ans *= p ** (c / n)
end
end
puts ans
|
[
"expression.operation.binary.change"
] | 990,143
| 990,144
|
u331906013
|
ruby
|
p03194
|
N,P=gets.split.map &:to_i
require 'prime'
c=1
Prime.prime_division(P).each{|x|
if x[1]>=N then c*=x[0]*(x[1]/N) end
}
p c
|
N,P=gets.split.map &:to_i
require 'prime'
c=1
Prime.prime_division(P).each{|x|
if x[1]>=N then c*=x[0]**(x[1]/N) end
}
p c
|
[
"expression.operation.binary.change"
] | 990,376
| 990,377
|
u656771711
|
ruby
|
p03194
|
n,p=gets.chomp.split(" ").map(&:to_i)
number = 2
if(n==1 || p<4)
puts p
else
divisionNumber = 0
loop do
temp_number_n = number ** n
divisionNumber = number if(p % temp_number_n == 0 )
if((p % temp_number_n == 0 ||(p % temp_number_n != 0 && p > temp_number_n )))
number += 1
else
break
end
end
puts divisionNumber
end
|
n,p=gets.chomp.split(" ").map(&:to_i)
number = 2
if(n==1)
puts p
else
divisionNumber = 1
loop do
temp_number_n = number ** n
divisionNumber = number if(p % temp_number_n == 0 )
if((p % temp_number_n == 0 ||(p % temp_number_n != 0 && p > temp_number_n )))
number += 1
else
break
end
end
puts divisionNumber
end
|
[
"expression.operation.binary.remove",
"literal.number.integer.change",
"assignment.value.change"
] | 990,498
| 990,499
|
u802371628
|
ruby
|
p03196
|
n, m = gets.split.map(&:to_i)
x = 1
m.prime_division.sort { |a, b| a[1] <=> b[1] }.reverse.each do |d|
y = d[1] / n
x *= (d[0]**y)
end
puts x
|
require 'prime'
n, m = gets.split.map(&:to_i)
x = 1
m.prime_division.sort { |a, b| a[1] <=> b[1] }.reverse.each do |d|
y = d[1] / n
x *= (d[0]**y)
end
puts x
|
[
"call.add"
] | 990,693
| 990,694
|
u244257825
|
ruby
|
p03196
|
require 'pp'
require 'prime'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
N, P = gets_i_list
factors = Prime.prime_division(P)
max = 1
factors.each do |num, count|
max *= num ** count / N
end
puts max
|
require 'pp'
require 'prime'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
N, P = gets_i_list
factors = Prime.prime_division(P)
max = 1
factors.each do |num, count|
max *= num ** (count / N)
end
puts max
|
[] | 990,781
| 990,782
|
u370977023
|
ruby
|
p03196
|
# frozen_string_literal: true
def factor(n)
return [1] if n == 1
`factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n`.split.map(&:to_i)
end
def uniq_factor(n)
`factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n|uniq`.split.map(&:to_i)
end
n, p = gets.split(' ').map(&:to_i)
factors = factor(p)
factors_map = Hash.new(0)
factors.each do |i|
factors_map[i] += 1
end
ans = 1
factors_map.each do |key, val|
ans *= val / n * key if val >= n
end
puts ans
|
# frozen_string_literal: true
def factor(n)
return [1] if n == 1
`factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n`.split.map(&:to_i)
end
def uniq_factor(n)
`factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n|uniq`.split.map(&:to_i)
end
n, p = gets.split(' ').map(&:to_i)
factors = factor(p)
factors_map = Hash.new(0)
factors.each do |i|
factors_map[i] += 1
end
ans = 1
factors_map.each do |key, val|
ans *= key**(val / n) if val >= n
end
puts ans
|
[
"call.add",
"expression.operation.binary.change"
] | 991,183
| 991,184
|
u083910207
|
ruby
|
p03196
|
def ascan; gets.split.map(&:to_i); end
require 'prime'
N, P = ascan
ans = 1
Prime::prime_division(P).each do |q, m|
if m >= N
ans *= q*(m/N)
end
end
p ans
|
def ascan; gets.split.map(&:to_i); end
require 'prime'
N, P = ascan
ans = 1
Prime::prime_division(P).each do |q, m|
if m >= N
ans *= q**(m/N)
end
end
p ans
|
[
"call.arguments.change"
] | 991,590
| 991,591
|
u079330987
|
ruby
|
p03196
|
require "prime"
n,q = gets.split.map(&:to_i)
a = q.prime_division
ans = 1
a.each{|(k,v)|
if v>=n
ans*=k
end
}
p ans
|
require "prime"
n,q = gets.split.map(&:to_i)
a = q.prime_division
ans = 1
a.each{|(k,v)|
while v>=n
ans*=k
v-=n
end
}
p ans
|
[
"control_flow.branch.while.replace.add",
"control_flow.loop.if.replace.remove"
] | 991,699
| 991,700
|
u397763977
|
ruby
|
p03196
|
require "Prime"
n,q = gets.split.map(&:to_i)
a = q.prime_division
ans = 1
a.each{|(k,v)|
if v>=n
ans*=k
end
}
p ans
|
require "prime"
n,q = gets.split.map(&:to_i)
a = q.prime_division
ans = 1
a.each{|(k,v)|
while v>=n
ans*=k
v-=n
end
}
p ans
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"control_flow.branch.while.replace.add",
"control_flow.loop.if.replace.remove"
] | 991,701
| 991,700
|
u397763977
|
ruby
|
p03194
|
require 'prime'
n,q = gets.split.map &:to_i
a = q.prime_division
result = 1
a.each do |i,j|
result *= i * (j / n) if j >= n
end
puts result
|
require 'prime'
n,q = gets.split.map &:to_i
a = q.prime_division
result = 1
a.each do |i,j|
result *= i ** (j / n) if j >= n
end
puts result
|
[
"expression.operation.binary.change"
] | 991,769
| 991,770
|
u158131514
|
ruby
|
p03194
|
#!/usr/bin/env ruby
(n, p) = gets.chomp.split(/ /).map(&:to_i)
array = []
if (n == 1)
puts p
exit
end
if (p == 1)
puts 1
exit
end
i = 2
ans = 1
while (i * i <= n)
if (p % i == 0)
if ((p % (i ** n)) == 0)
ans *= i
p /= i ** n
else
p /= i
end
else
i += 1
end
end
puts ans
|
#!/usr/bin/env ruby
(n, p) = gets.chomp.split(/ /).map(&:to_i)
array = []
if (n == 1)
puts p
exit
end
if (p == 1)
puts 1
exit
end
i = 2
ans = 1
while (i * i <= p)
if (p % i == 0)
if ((p % (i ** n)) == 0)
ans *= i
p /= i ** n
else
p /= i
end
else
i += 1
end
end
puts ans
|
[
"identifier.change",
"expression.operation.binary.change"
] | 991,799
| 991,800
|
u029843816
|
ruby
|
p03194
|
require 'prime'
n, p = gets.chomp.split(" ").map(&:to_i)
gcd = p.prime_division.select{|array| array[1] >= n}.flatten.first
while a = (p / gcd ** n).prime_division.select{|array| array[1] >= n}.flatten.first do
gcd = gcd * a
end
puts gcd
|
require 'prime'
n, p = gets.chomp.split(" ").map(&:to_i)
gcd = p.prime_division.select{|array| array[1] >= n}.flatten.first
while gcd && a = (p / gcd ** n).prime_division.select{|array| array[1] >= n}.flatten.first do
gcd = gcd * a
end
puts gcd || 1
|
[
"expression.operation.binary.add"
] | 991,825
| 991,826
|
u298628832
|
ruby
|
p03198
|
N,*A=`dd`.split.map &:to_i
x,y=[A,A.reverse].map{|_|
t=[]
r=[c=0]
_.each_with_index{|a,i|
b=a
q=1
while !t.empty?&&t[-1][0]<b
x,d,n=t.pop
(c+=n*2;x*=4;d*=4)while x<b
b=d
q+=n
end
t<<t.empty? ? [a,0,q] : [a,b,q]
r<<c
}
r
}
p (0..N).map{|i|x[i]+i+y[-1-i]}.min
|
N,*A=`dd`.split.map &:to_i
x,y=[A,A.reverse].map{|_|
t=[]
r=[c=0]
_.each_with_index{|a,i|
b=a
q=1
while !t.empty?&&t[-1][0]<b
x,d,n=t.pop
(c+=n*2;x*=4;d*=4)while x<b
b=d
q+=n
end
t<<(t.empty? ? [a,0,q] : [a,b,q])
r<<c
}
r
}
p (0..N).map{|i|x[i]+i+y[-1-i]}.min
|
[] | 992,218
| 992,219
|
u280667879
|
ruby
|
p03196
|
require 'prime'
N,P=gets.chomp.split.map(&:to_i)
ans=1
Prime.prime_division(P).each do |a,b|
next if b < N
ans *= a * (b/N)
end
puts ans
|
require 'prime'
N,P=gets.chomp.split.map(&:to_i)
ans=1
Prime.prime_division(P).each do |a,b|
next if b < N
ans *= (a ** (b/N))
end
puts ans
|
[
"expression.operation.binary.change"
] | 993,082
| 993,083
|
u868089307
|
ruby
|
p03196
|
require 'prime'
n,p = gets.split.map(&:to_i)
puts p.prime_division.map{|x,y| x ** (y/n)}.inject(&:*)
|
require 'prime'
n,p = gets.split.map(&:to_i)
puts p.prime_division.map{|x,y| x ** (y/n)}.inject(1,&:*)
|
[
"call.arguments.add"
] | 993,095
| 993,096
|
u056944756
|
ruby
|
p03196
|
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end
exit if $0 != __FILE__
require 'prime'
n, p = cin
pds = Prime.prime_division(p)
x = 1
pds.each do |pd|
x *= pd[0] * (pd[1] / n) if pd[1] >= n
end
puts x
|
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end
exit if $0 != __FILE__
require 'prime'
n, p = cin
pds = Prime.prime_division(p)
x = 1
pds.each do |pd|
x *= pd[0] ** (pd[1] / n) if pd[1] >= n
end
puts x
|
[
"expression.operation.binary.change"
] | 993,139
| 993,140
|
u388603285
|
ruby
|
p03200
|
s=gets
cnt,ans=0,0
(0...s.length).each do |i|
next if s[i]=='B'
ans+=i-cnt
cnt+=1
end
puts ans
|
s=gets
cnt,ans=0,0
(0..s.length-1).each do |i|
if s[i]=='W'
ans+=i-cnt
cnt+=1
end
end
puts ans
|
[
"literal.string.change",
"control_flow.branch.if.condition.change"
] | 993,893
| 993,894
|
u394033362
|
ruby
|
p03201
|
n=gets.to_i
a=gets.split.map &:to_i
a.sort!
c=0
31.downto(1){|s|
i=0
j=a.size-1
while i<j
if !a[i]
i+=1
elsif !a[j]
j-=1
else
k=a[i]+a[j]-2**s
if k<0
i+=1
elsif k>0
j-=1
else
c+=1
a[i]=a[j]=0
i+=1
j-=1
end
end
end
}
p c
|
n=gets.to_i
a=gets.split.map &:to_i
a.sort!
c=0
31.downto(1){|s|
i=0
j=a.size-1
while i<j
if !a[i]
i+=1
elsif !a[j]
j-=1
else
k=a[i]+a[j]-2**s
if k<0
i+=1
elsif k>0
j-=1
else
c+=1
a[i]=a[j]=nil
i+=1
j-=1
end
end
end
}
p c
|
[
"assignment.value.change"
] | 995,334
| 995,335
|
u019489252
|
ruby
|
p03201
|
N = gets.to_i
A = gets.split.map(&:to_i).sort
odds = A.select(&:odd?)
evens = A.select(&:even?)
def f(n)
b = 2
while b < n
b *= 2
end
b - n
end
def c(list)
cnt = 0
counter = Hash.new(0)
list.each do |l|
counter[l] += 1
end
until list.empty?
n = list.pop
next if counter[n] <= 0
counter[n] -= 1
t = f(n)
r = list.bsearch { |x| x >= t }
if r && r == t && counter[r] > 0
counter[r] -= 1
cnt += 1
end
end
cnt
end
puts c(odds) + c(evens)
|
N = gets.to_i
A = gets.split.map(&:to_i).sort
odds = A.select(&:odd?)
evens = A.select(&:even?)
def f(n)
b = 2
while b <= n
b *= 2
end
b - n
end
def c(list)
cnt = 0
counter = Hash.new(0)
list.each do |l|
counter[l] += 1
end
until list.empty?
n = list.pop
next if counter[n] <= 0
counter[n] -= 1
t = f(n)
r = list.bsearch { |x| x >= t }
if r && r == t && counter[r] > 0
counter[r] -= 1
cnt += 1
end
end
cnt
end
puts c(odds) + c(evens)
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 995,659
| 995,660
|
u740836226
|
ruby
|
p03206
|
print "Christmas"
for i in 25-gets.to_i do
print " Eve"
end
puts ""
|
print "Christmas"
for i in 1..25-gets.to_i do
print " Eve"
end
puts ""
|
[] | 996,588
| 996,589
|
u141968173
|
ruby
|
p03206
|
d = gets.chomp.to_i
s = 'Christmas'
(25-d).times do |i|
s += 'Eve'
end
puts s
|
d = gets.chomp.to_i
s = 'Christmas'
(25-d).times do |i|
s += ' Eve'
end
puts s
|
[
"literal.string.change"
] | 997,173
| 997,174
|
u303448696
|
ruby
|
p03206
|
D = gets.chomp.to_i
case D
when 25
puts "Chrismas"
when 24
puts "Chrismas Eve"
when 23
puts "Chrismas Eve Eve"
when 22
puts "Chrismas Eve Eve Eve"
end
|
D = gets.chomp.to_i
case D
when 25
puts "Christmas"
when 24
puts "Christmas Eve"
when 23
puts "Christmas Eve Eve"
when 22
puts "Christmas Eve Eve Eve"
end
|
[
"literal.string.change",
"call.arguments.change"
] | 997,200
| 997,201
|
u968699140
|
ruby
|
p03206
|
d = gets.to_i
puts "Cristmas#{' Eve'*(25-d)}"
|
d = gets.to_i
puts "Christmas#{' Eve'*(25-d)}"
|
[
"literal.string.change",
"call.arguments.change"
] | 997,349
| 997,350
|
u977667253
|
ruby
|
p03206
|
d = gets.to_i
case d
when 25
puts "Christmas"
when 24
puts "Christmas Eve"
when 23
puts "Christmas Eve Eve"
when 22
puts "Christmas Eve Eve"
end
|
#AC
d = gets.to_i
case d
when 25
puts "Christmas"
when 24
puts "Christmas Eve"
when 23
puts "Christmas Eve Eve"
when 22
puts "Christmas Eve Eve Eve"
end
|
[
"literal.string.change",
"call.arguments.change"
] | 997,553
| 997,554
|
u059126963
|
ruby
|
p03206
|
D = gets.to_i
p 'Christmas' + ' Eve'*(25-D)
|
D = gets.to_i
puts 'Christmas' + ' Eve'*(25-D)
|
[
"call.function.change",
"io.output.change"
] | 997,784
| 997,785
|
u439687774
|
ruby
|
p03206
|
d = gets.to_i
if d == 25
puts "Christmas"
elsif d == 24
puts "Christmas Eve"
elsif d == 23
puts "Christmas Eve Eve"
elself d == 22
puts "Christmas Eve Eve Eve"
end
|
d = gets.to_i
if d == 25
puts "Christmas"
elsif d == 24
puts "Christmas Eve"
elsif d == 23
puts "Christmas Eve Eve"
elsif d == 22
puts "Christmas Eve Eve Eve"
end
|
[] | 997,881
| 997,882
|
u760842625
|
ruby
|
p03206
|
puts case gets.chomp
when 25
"Christmas"
when 24
"Christmas Eve"
when 23
"Christmas Eve Eve"
when 22
"Christmas Eve Eve Eve"
end
|
puts case gets.to_i
when 25
"Christmas"
when 24
"Christmas Eve"
when 23
"Christmas Eve Eve"
when 22
"Christmas Eve Eve Eve"
end
|
[
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 997,994
| 997,995
|
u132360211
|
ruby
|
p03206
|
REFERENCE_VALUE = 25
char = "Chrismas "
add_char = "Eve "
num = gets.to_i
(25 - num).abs.times do
char = char + add_char
end
puts char
|
REFERENCE_VALUE = 25
char = "Christmas "
add_char = "Eve "
num = gets.to_i
(25 - num).abs.times do
char = char + add_char
end
puts char
|
[
"literal.string.change",
"assignment.value.change"
] | 998,051
| 998,052
|
u510556034
|
ruby
|
p03206
|
REFERENCE_VALUE = 25
char = "Chrismas"
add_char = " Eve"
num = gets.to_i
(25 - num).abs.times do
char = char + add_char
end
puts char
|
REFERENCE_VALUE = 25
char = "Christmas "
add_char = "Eve "
num = gets.to_i
(25 - num).abs.times do
char = char + add_char
end
puts char
|
[
"literal.string.change",
"assignment.value.change"
] | 998,053
| 998,052
|
u510556034
|
ruby
|
p03206
|
a=gets.chomp.to_i
if a == 25
puts 'Christmas'
elsif a == 24
puts 'Christmas Eve'
elsif a == 23
puts 'Christmas Eve Eve'
elsif a == 24
puts 'Christmas Eve Eve Eve'
end
|
a=gets.chomp.to_i
if a == 25
puts 'Christmas'
elsif a == 24
puts 'Christmas Eve'
elsif a == 23
puts 'Christmas Eve Eve'
elsif a == 22
puts 'Christmas Eve Eve Eve'
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 998,086
| 998,087
|
u403638277
|
ruby
|
p03206
|
a = gets.chomp.to_i
if a == 25
puts "Christmas"
elsif a = 24
puts "Christmas Eve"
elsif a == 23
puts "Christmas Eve Eve"
elsif a == 22
puts "Christmas Eve Eve Eve"
end
|
a = gets.chomp.to_i
if a == 25
puts "Christmas"
elsif a == 24
puts "Christmas Eve"
elsif a == 23
puts "Christmas Eve Eve"
elsif a == 22
puts "Christmas Eve Eve Eve"
end
|
[
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 998,138
| 998,139
|
u264508862
|
ruby
|
p03206
|
d = gets.chomp.to_i
if d == 25
puts 'Cristmas'
elsif d == 24
puts 'Cristmas Eve'
elsif d == 23
puts 'Cristmas Eve Eve'
elsif d == 22
puts 'Cristmas Eve Eve Eve'
end
|
d = gets.chomp.to_i
if d == 25
puts 'Christmas'
elsif d == 24
puts 'Christmas Eve'
elsif d == 23
puts 'Christmas Eve Eve'
elsif d == 22
puts 'Christmas Eve Eve Eve'
end
|
[
"literal.string.change",
"call.arguments.change"
] | 998,196
| 998,197
|
u667739822
|
ruby
|
p03206
|
d = 25 - gets.to_i
puts 'Christmas' + 'Eve' * d
|
d = 25 - gets.to_i
puts 'Christmas' + ' Eve ' * d
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 998,234
| 998,235
|
u124214522
|
ruby
|
p03206
|
d = gets.chomp.to_i
if d == 25
puts "Christmas"
elsif d == 24
"Christmas Eve"
elsif d ==23
"Christmas Eve Eve"
else
"Christmas Eve Eve Eve"
end
|
d = gets.chomp.to_i
if d == 25
puts "Christmas"
elsif d == 24
puts "Christmas Eve"
elsif d ==23
puts "Christmas Eve Eve"
else
puts "Christmas Eve Eve Eve"
end
|
[
"io.output.change",
"call.add"
] | 998,411
| 998,412
|
u445624660
|
ruby
|
p03206
|
D = gets.to_i
if D==25 then
puts "Christmas"
elsif D==24 then
puts "Christmas Eveputs"
elsif D==23 then
puts "Christmas Eve Eve"
else
puts "Christmas Eve Eve Eve"
end
|
D = gets.to_i
if D==25 then
puts "Christmas"
elsif D==24 then
puts "Christmas Eve"
elsif D==23 then
puts "Christmas Eve Eve"
else
puts "Christmas Eve Eve Eve"
end
|
[
"literal.string.change",
"call.arguments.change"
] | 998,430
| 998,431
|
u792455295
|
ruby
|
p03206
|
#! /usr/bin/env ruby
input = STDIN.read.to_i
t = ['Cristmas']
for i in 0...(input - 25).abs
t.push('Eve')
end
puts t.join(' ')
|
input = STDIN.read.to_i
t = ['Christmas']
for i in 0...(input - 25).abs
t.push('Eve')
end
puts t.join(' ')
|
[
"literal.string.change",
"assignment.value.change"
] | 998,489
| 998,490
|
u346050999
|
ruby
|
p03207
|
N = gets.to_i
ps = N.times.map{gets.to_i}.sort.reverse
puts p[0]/2 + p[1..-1].inject(&:+)
|
N = gets.to_i
ps = N.times.map{gets.to_i}.sort.reverse
puts ps[0]/2 + ps[1..-1].inject(&:+)
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 998,786
| 998,787
|
u926099741
|
ruby
|
p03207
|
n = gets.to_i
items = n.times.map{gets.to_i}
items.sort
items[-1] = items[-1] / 2
puts items.inject(:+)
|
n = gets.to_i
items = n.times.map{gets.to_i}
items.sort!
items[-1] = items[-1] / 2
puts items.inject(:+)
|
[
"call.suffix.change"
] | 999,184
| 999,185
|
u105001881
|
ruby
|
p03207
|
n = gets.to_i
x = []
n.times do
x << gets.to_i
end
x.inject(&:+) - x.max / 2
|
n = gets.to_i
x = []
n.times do
x << gets.to_i
end
puts x.inject(&:+) - x.max / 2
|
[
"io.output.change",
"call.add"
] | 999,299
| 999,300
|
u012934214
|
ruby
|
p03207
|
p=[]
gets.chomp.to_i.times{p<<get.to_i}
p p.inject(:+)-p.sort[-1]/2
|
p=[]
gets.chomp.to_i.times{p<<gets.to_i}
p p.inject(:+)-p.sort[-1]/2
|
[
"call.arguments.change"
] | 999,354
| 999,355
|
u743561048
|
ruby
|
p03208
|
n,k = gets.split.map(&:to_i)
h = n.times.map{gets.to_i}.sort.reverse
ans = 10**10
(n-k).times do |i|
ans = [ans, h[i]-h[k+i-1]].min
end
puts ans
|
n,k = gets.split.map(&:to_i)
h = n.times.map{gets.to_i}.sort.reverse
ans = 10**10
(n-k+1).times do |i|
ans = [ans, h[i]-h[k+i-1]].min
end
puts ans
|
[
"expression.operation.binary.add"
] | 999,804
| 999,805
|
u238956837
|
ruby
|
p03208
|
n,k = gets.split.map(&:to_i)
h = n.times.map{gets.to_i}.sort.reverse
ans = 10**10
k.times do |i|
ans = [ans, h[i]-h[k+i-1]].min
end
puts ans
|
n,k = gets.split.map(&:to_i)
h = n.times.map{gets.to_i}.sort.reverse
ans = 10**10
(n-k+1).times do |i|
ans = [ans, h[i]-h[k+i-1]].min
end
puts ans
|
[] | 999,806
| 999,805
|
u238956837
|
ruby
|
p03208
|
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
if (trees[i+k-1] - [i]) < res
res = trees[i+k-1] - trees[i]
end
end
puts res
|
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
if (trees[i+k-1] - trees[i]) < res
res = trees[i+k-1] - trees[i]
end
end
puts res
|
[
"control_flow.branch.if.condition.change"
] | 1,000,106
| 1,000,107
|
u105001881
|
ruby
|
p03208
|
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
if trees[i+k-1] - [i] < res
res = trees[i+k-1] - trees[i]
end
end
puts res
|
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
if (trees[i+k-1] - trees[i]) < res
res = trees[i+k-1] - trees[i]
end
end
puts res
|
[
"control_flow.branch.if.condition.change"
] | 1,000,108
| 1,000,107
|
u105001881
|
ruby
|
p03208
|
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
if trees[i+k-1] - [i] < res
res = trees[i+k-1] - [i]
end
end
puts res
|
n, k = gets.split.map(&:to_i)
trees = n.times.map{gets.to_i}
trees.sort!
res = 1000000000
for i in 0..(n-k) do
if (trees[i+k-1] - trees[i]) < res
res = trees[i+k-1] - trees[i]
end
end
puts res
|
[
"control_flow.branch.if.condition.change"
] | 1,000,109
| 1,000,107
|
u105001881
|
ruby
|
p03207
|
_,a=$<.map &:to_i;p a.inject(:+)-a.max/2
|
_,*a=$<.map &:to_i;p a.inject(:+)-a.max/2
|
[] | 1,000,465
| 1,000,466
|
u657913472
|
ruby
|
p03208
|
n, k = gets.split.map(&:to_i)
trees = []
n.times do
trees << gets.to_i
end
trees.sort!
ans = trees[-1] - trees[0]
n.times do |i|
break if trees[i+2].nil?
diff = trees[i+2] - trees[i]
ans = [ans, diff].min
end
puts ans
|
# comment test comment test
# comment test comment test
# comment test comment test
# comment test comment test
# comment test comment test
n, k = gets.split.map(&:to_i)
trees = []
n.times do
trees << gets.to_i
end
trees.sort!
ans = trees[-1] - trees[0]
n.times do |i|
break if trees[i+k-1].nil?
diff = trees[i+k-1] - trees[i]
ans = [ans, diff].min
end
puts ans
|
[
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,000,606
| 1,000,607
|
u298628832
|
ruby
|
p03208
|
n, k = gets.split.map(&:to_i)
trees = []
n.times do
trees << gets.to_i
end
trees.sort!
ans = trees[-1] - trees[0]
n.times do |i|
break if trees[i+2].nil?
diff = trees[i+2] - trees[i]
ans = [ans, diff].min
end
puts ans
|
n, k = gets.split.map(&:to_i)
trees = []
n.times do
trees << gets.to_i
end
trees.sort!
ans = trees[-1] - trees[0]
n.times do |i|
break if trees[i+k-1].nil?
diff = trees[i+k-1] - trees[i]
ans = [ans, diff].min
end
puts ans
|
[
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,000,606
| 1,000,608
|
u298628832
|
ruby
|
p03208
|
N, K = gets.split(' ').map(&:to_i)
h = []
N.times do
h.push(gets.to_i)
end
h.sort!
op = []
(N - K).times do |i|
op.push(h[i + K] - h[i])
end
puts op.min
|
N, K = gets.split(' ').map(&:to_i)
h = []
N.times do
h.push(gets.to_i)
end
h.sort!
op = []
(N - K + 1).times do |i|
op.push(h[i + K - 1] - h[i])
end
puts op.min
|
[
"expression.operation.binary.add"
] | 1,000,955
| 1,000,956
|
u548834738
|
ruby
|
p03208
|
N, K = gets.split(' ').map(&:to_i)
h = []
N.times do
h.push(gets.to_i)
end
h.sort!
op = []
(N - K).times do |i|
op.push(h[i + K - 1] - h[i])
end
puts op.min
|
N, K = gets.split(' ').map(&:to_i)
h = []
N.times do
h.push(gets.to_i)
end
h.sort!
op = []
(N - K + 1).times do |i|
op.push(h[i + K - 1] - h[i])
end
puts op.min
|
[
"expression.operation.binary.add"
] | 1,000,957
| 1,000,956
|
u548834738
|
ruby
|
p03208
|
n, k = gets.split.map &:to_i
a = []
n.times do |i|
a[i] = gets.to_i
end
a.sort!
min_h = 10**10
(a.length-k+1).times do |i|
h = a[i..i+k-1]
if (h[k-1].to_i - h[0].to_i) < min_h
min_h = h[k-1].to_i - h[i].to_i
end
end
puts min_h
|
n, k = gets.split.map &:to_i
a = []
n.times do |i|
a[i] = gets.to_i
end
a.sort!
min_h = 10**10
(a.length-k+1).times do |i|
h = a[i..i+k-1]
if (h[k-1].to_i - h[0].to_i) < min_h
min_h = h[k-1].to_i - h[0].to_i
end
end
puts min_h
|
[
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 1,001,279
| 1,001,280
|
u475329018
|
ruby
|
p03208
|
n_ks = gets.chomp
n_ks = n_ks.split(" ")
n = n_ks[0].to_i
k = n_ks[1].to_i
h = Array.new()
for i in 0..n-1
h[i] = gets.chomp.to_i
end
h.sort!
min_dif = nil
for i in 0..n-1
dif = h[k+i-1]-h[i]
if min_dif == nil || dif <= min_dif
min_dif = dif
end
end
puts min_dif.to_s
|
n_ks = gets.chomp
n_ks = n_ks.split(" ")
n = n_ks[0].to_i
k = n_ks[1].to_i
h = Array.new()
for i in 0..n-1
h[i] = gets.chomp.to_i
end
h.sort!
min_dif = nil
for i in 0..n-k
dif = h[k+i-1]-h[i]
if min_dif == nil || dif <= min_dif
min_dif = dif
end
end
puts min_dif.to_s
|
[
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.change"
] | 1,001,331
| 1,001,332
|
u667739822
|
ruby
|
p03208
|
n,k=gets.split.map(&:to_i)
nums=Array.new(n)
for i in 0..n-1 do
nums[i]=gets.to_i
end
nums.sort
ans=1e9
for i in 0..(n-k) do
tmp=nums[i+k-1]-nums[i]
ans=[ans,tmp].min
end
puts ans
|
n,k=gets.split.map(&:to_i)
nums=Array.new(n)
for i in 0..n-1 do
nums[i]=gets.to_i
end
nums=nums.sort
ans=1e9
for i in 0..(n-k) do
tmp=nums[i+k-1]-nums[i]
ans=[ans,tmp].min
end
puts ans
|
[
"assignment.add"
] | 1,001,590
| 1,001,591
|
u415041731
|
ruby
|
p03208
|
n,k = gets.chomp.split.map(&:to_i)
h = []
n.times { h << gets.to_i }
h.sort!
min = (h[0]-h[-1+k]).abs
(0..n-k).each do |i|
min = [min, (h[i]-h[i+2]).abs].min
end
puts min
|
n,k = gets.chomp.split.map(&:to_i)
h = []
n.times { h << gets.to_i }
h.sort!
min = (h[0]-h[-1+k]).abs
(0..n-k).each do |i|
min = [min, (h[i]-h[i-1+k]).abs].min
end
puts min
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 1,001,719
| 1,001,720
|
u574326823
|
ruby
|
p03208
|
N,K = gets.chomp.split(" ").map(&:to_i)
h_s = []
N.times do |i|
h_s << gets.chomp.to_i
end
h_s = h_s.sort
sort_h_s = []
(h_s.length-K+1).times do |i|
p i+K, i
sort_h_s << h_s[i+K-1] - h_s[i]
end
puts sort_h_s.min
|
N,K = gets.chomp.split(" ").map(&:to_i)
h_s = []
N.times do |i|
h_s << gets.chomp.to_i
end
h_s = h_s.sort
sort_h_s = []
(h_s.length-K+1).times do |i|
sort_h_s << h_s[i+K-1] - h_s[i]
end
puts sort_h_s.min
|
[
"call.remove"
] | 1,001,799
| 1,001,800
|
u966695319
|
ruby
|
p03208
|
n, k = gets.chomp.split(' ').map(&:to_i)
data = []
min = 1000000000000
n.times do
data << gets.chomp.to_i
end
data.sort!()
for i in 0..(n-k)
_min = data[i]
_max = data[i+2]
min = _max - _min if (_max-_min) < min
end
puts min
|
n, k = gets.chomp.split(' ').map(&:to_i)
data = []
min = 1000000000000
n.times do
data << gets.chomp.to_i
end
data.sort!()
for i in 0..(n-k)
_min = data[i]
_max = data[i+k-1]
min = _max - _min if (_max-_min) < min
end
puts min
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 1,001,875
| 1,001,876
|
u354075848
|
ruby
|
p03208
|
n, k = gets.split.map &:to_i
trees = []
n.times do
trees << gets.to_i
end
trees.sort!
ans = 1E6
for i in 0 .. n - k + 1
min = trees[i + k - 1] - trees[i]
ans = [min, ans].min
end
puts ans
|
n, k = gets.split.map &:to_i
trees = []
n.times do
trees << gets.to_i
end
trees.sort!
ans = 1E9 + 10
for i in 0 .. n - k
min = trees[i + k - 1] - trees[i]
ans = [min, ans].min
end
puts ans
|
[
"literal.number.float.change",
"assignment.value.change",
"expression.operation.binary.remove"
] | 1,002,638
| 1,002,639
|
u785521224
|
ruby
|
p03210
|
if [3,5,7].include?(gets.chomp)
puts "YES"
else
puts "NO"
end
|
if [3,5,7].include?(gets.to_i)
puts "YES"
else
puts "NO"
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,003,106
| 1,003,107
|
u059126963
|
ruby
|
p03210
|
s=gets.to_i
a=[3,5,7]
puts (a.include?(s))? :Yes : :No
|
s=gets.to_i
a=[3,5,7]
puts (a.include?(s))? :YES : :NO
|
[
"call.arguments.change"
] | 1,003,113
| 1,003,114
|
u977506075
|
ruby
|
p03210
|
X = gets.to_i
if X == 7 || X == 5 || X == 3
puts "Yes"
else
puts "No"
end
|
X = gets.to_i
if X == 7 || X == 5 || X == 3
puts "YES"
else
puts "NO"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,003,253
| 1,003,254
|
u920244601
|
ruby
|
p03210
|
X = gets.to_i
puts [7, 5, 3].include?(X) ? "Yes" : "No"
|
X = gets.to_i
puts [7, 5, 3].include?(X) ? "YES" : "NO"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,003,524
| 1,003,525
|
u693378622
|
ruby
|
p03210
|
x=gets.chomp
puts "357".include?(x)? "Yes":"No"
|
x=gets.chomp
puts "357".include?(x)? "YES":"NO"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,003,756
| 1,003,757
|
u408023666
|
ruby
|
p03210
|
x = gets.to_i
puts 3==x || 5==x || 7==x ? "Yes" : "No"
|
x = gets.to_i
puts 3==x || 5==x || 7==x ? "YES" : "NO"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,003,872
| 1,003,873
|
u561391668
|
ruby
|
p03210
|
year = gets.chomp.to_i
p [3,5,7].include?(year) ? "YES" : "NO"
|
year = gets.chomp.to_i
puts [3,5,7].include?(year) ? "YES" : "NO"
|
[
"call.function.change",
"io.output.change"
] | 1,003,989
| 1,003,990
|
u771770008
|
ruby
|
p03210
|
puts [3,7,5].include?(gets.to_i) ? "yes" : "no"
|
puts [3,7,5].include?(gets.to_i) ? "YES" : "NO"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,232
| 1,004,233
|
u816786287
|
ruby
|
p03210
|
puts [3,5,7].include?(gets.to_i) ? :yes: :no
|
puts [3,5,7].include?(gets.to_i) ? :YES : :NO
|
[
"call.arguments.change"
] | 1,004,463
| 1,004,464
|
u049159332
|
ruby
|
p03210
|
puts [3,5,7].include?(gets.to_i) ? :yes : :no
|
puts [3,5,7].include?(gets.to_i) ? :YES : :NO
|
[
"call.arguments.change"
] | 1,004,465
| 1,004,464
|
u049159332
|
ruby
|
p03210
|
x=gets.to_i
case x
when 7
print "yes"
when 5
print "yes"
when 3
print "yes"
else
print "no"
end
|
x=gets.to_i
case x
when 7
print "YES"
when 5
print "YES"
when 3
print "YES"
else
print "NO"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,466
| 1,004,467
|
u049159332
|
ruby
|
p03210
|
x = gets.to_i
puts (x == 7 || x == 5 || x == 3 ? "YES" : "No")
|
x = gets.to_i
puts (x == 7 || x == 5 || x == 3 ? "YES" : "NO")
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,495
| 1,004,496
|
u581928831
|
ruby
|
p03210
|
x = gets.to_i
p (x == 7 || x == 5 || x == 3 ? "YES" : "No")
|
x = gets.to_i
puts (x == 7 || x == 5 || x == 3 ? "YES" : "NO")
|
[
"call.function.change",
"io.output.change",
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,497
| 1,004,496
|
u581928831
|
ruby
|
p03210
|
puts ((X = (gets.to_i)) == 3 || X == 5 || X == 7) ? "Yes" : "No"
|
puts ((X = gets.to_i) == 3 || X == 5 || X == 7) ? "YES" : "NO"
|
[
"control_flow.branch.if.condition.change",
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,510
| 1,004,511
|
u538351278
|
ruby
|
p03210
|
y =gets.split.map(&:to_i)
if y==3 ||y==5 ||y==7
puts "YES"
else
puts "NO"
end
|
y =gets.to_i
if y==3 ||y==5 ||y==7
puts "YES"
else
puts "NO"
end
|
[
"assignment.value.change",
"identifier.change",
"call.remove"
] | 1,004,646
| 1,004,647
|
u760842625
|
ruby
|
p03210
|
y =gets.split.map(&:to_i)
if y==3||y==5||y==7
puts "YES"
else
puts "NO"
end
|
y =gets.to_i
if y==3 ||y==5 ||y==7
puts "YES"
else
puts "NO"
end
|
[
"assignment.value.change",
"identifier.change",
"call.remove"
] | 1,004,648
| 1,004,647
|
u760842625
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.