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 |
|---|---|---|---|---|---|---|---|
p03250
|
a,b,c = gets.split(' ').map{|n| n.to_i}.sort
puts a * 10 + b + c
|
a,b,c = gets.split(' ').map{|n| n.to_i}.sort
puts c * 10 + b + a
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,037,467
| 1,037,468
|
u578441226
|
ruby
|
p03250
|
a,b,c=gets.split.map(&to_i).sort.reverse
puts a*10+b+c
|
a,b,c=gets.split.map(&:to_i).sort.reverse
puts a*10+b+c
|
[
"assignment.value.change",
"call.arguments.change"
] | 1,037,693
| 1,037,694
|
u503549962
|
ruby
|
p03250
|
a, b, c = gets.chomp.split(' ').map(&:to_i)
if a > b && a > c
puts a * 10 + b + c
elsif b > a && b > c
puts a + b * 10 + c
else
puts a + b + c * 10
end
|
a, b, c = gets.chomp.split(' ').map(&:to_i)
if a >= b && a >= c
puts a * 10 + b + c
elsif b >= a && b >= c
puts a + b * 10 + c
else
puts a + b + c * 10
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,038,037
| 1,038,038
|
u823451365
|
ruby
|
p03251
|
n, m, x, y = gets.split.map(&:to_i)
x_max = (gets.split.map(&:to_i) + x).max
y_min = (gets.split.map(&:to_i) + y).min
if x_max <= y_min
puts "No War"
else
puts "War"
end
|
n, m, x, y = gets.split.map(&:to_i)
x_max = (gets.split.map(&:to_i) + [x]).max
y_min = (gets.split.map(&:to_i) + [y]).min
if x_max < y_min
puts "No War"
else
puts "War"
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,038,569
| 1,038,570
|
u714769076
|
ruby
|
p03250
|
l=gets.chomp.split.map(&:to_i)
p l
m=l.max
l.delete_at l.index m
n=l.max
l.delete_at l.index n
puts m*10+n+l[0]
|
l=gets.chomp.split.map(&:to_i)
m=l.max
l.delete_at l.index m
n=l.max
l.delete_at l.index n
puts m*10+n+l[0]
|
[
"call.remove"
] | 1,038,772
| 1,038,773
|
u207576661
|
ruby
|
p03251
|
n_,m_,x,y = gets.split.map(&:to_i)
xrray = gets.split.map(&:to_i)
yrray =gets.split.map(&:to_i)
xxrray = xrrau.push(x)
yyrray = yrray.push(y)
if xxrray.max < yyrray.min
puts "No War"
else
puts "War"
end
|
_n,_m,x,y = gets.split.map(&:to_i)
xrray = gets.split.map(&:to_i)
yrray =gets.split.map(&:to_i)
xxrray = xrray.push(x)
yyrray = yrray.push(y)
if xxrray.max < yyrray.min
puts "No War"
else
puts "War"
end
|
[
"assignment.variable.change",
"identifier.change",
"assignment.value.change"
] | 1,039,020
| 1,039,021
|
u987183622
|
ruby
|
p03251
|
n, m, _x, _y = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
(_x.._y).each do |z|
if x.max < z && y.min >= z
puts 'No War'
exit
end
end
puts 'War'
|
n, m, _x, _y = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
((_x + 1).._y).each do |z|
if x.max < z && y.min >= z
puts 'No War'
exit
end
end
puts 'War'
|
[] | 1,039,126
| 1,039,127
|
u457499130
|
ruby
|
p03251
|
N, M, X, Y = gets.chomp.split.map(&:to_i)
x, y = 2.times.map {gets.chomp.split.map(&:to_i)}
puts [x.max, X+1].max <= [y.min, Y].min ? "No War" : "War"
|
N, M, X, Y = gets.chomp.split.map(&:to_i)
x, y = 2.times.map {gets.chomp.split.map(&:to_i)}
puts [x.max, X].max < [y.min, Y].min ? "No War" : "War"
|
[
"expression.operation.binary.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,039,228
| 1,039,229
|
u091810847
|
ruby
|
p03251
|
n,m,x,y=gets.split.map &:to_i
a=gets.split.map &:to_i
a<<x
x=a.max
b=gets.split.map &:to_i
b<<y
y=a.min
puts x>=y ?'War':'No War'
|
n,m,x,y=gets.split.map &:to_i
a=gets.split.map &:to_i
a<<x
x=a.max
b=gets.split.map &:to_i
b<<y
y=b.min
puts x>=y ?'War':'No War'
|
[] | 1,039,724
| 1,039,725
|
u459746049
|
ruby
|
p03251
|
n,m,xPos,yPos = gets.chomp.split(" ").map(&:to_i)
xPoses = gets.chomp.split(" ").map(&:to_i)
xPosMax = xPoses.max
yPoses = gets.chomp.split(" ").map(&:to_i)
yPosMin = yPoses.min
putsString = "War"
((xPos+1)..yPos).each do |value|
if xPosMax < value && yPosMin <= value
putsString = "No War"
break
end
end
puts putsString
|
n,m,xPos,yPos = gets.chomp.split(" ").map(&:to_i)
xPoses = gets.chomp.split(" ").map(&:to_i)
xPosMax = xPoses.max
yPoses = gets.chomp.split(" ").map(&:to_i)
yPosMin = yPoses.min
putsString = "War"
((xPos+1)..yPos).each do |value|
if xPosMax < value && yPosMin >= value
putsString = "No War"
break
end
end
puts putsString
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,039,829
| 1,039,830
|
u802371628
|
ruby
|
p03252
|
s = gets.chomp.chars
t = gets.chomp.chars
s_hash = Hash.new{}
s.each_with_index do |l, idx|
begin
s_hash[l].push idx
rescue
s_hash[l] = [idx]
end
end
t_hash = Hash.new{}
t.each_with_index do |l, idx|
begin
t_hash[l].push idx
rescue
t_hash[l] = [idx]
end
end
if s_values == t_values
puts "Yes"
else
puts "No"
end
|
s = gets.chomp.chars
t = gets.chomp.chars
s_hash = Hash.new{}
s.each_with_index do |l, idx|
begin
s_hash[l].push idx
rescue
s_hash[l] = [idx]
end
end
t_hash = Hash.new{}
t.each_with_index do |l, idx|
begin
t_hash[l].push idx
rescue
t_hash[l] = [idx]
end
end
if s_hash.values == t_hash.values
puts "Yes"
else
puts "No"
end
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 1,040,379
| 1,040,380
|
u792512290
|
ruby
|
p03251
|
N,M,X,Y=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
y=gets.split.map(&:to_i)
p z = [*X+1..Y]
puts z.map{|t|t > x.max && t <= y.min}.any? ? "No War" : "War"
|
N,M,X,Y=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
y=gets.split.map(&:to_i)
puts [*X+1..Y].map{|t|t > x.max && t <= y.min}.any? ? "No War" : "War"
|
[
"call.function.change",
"io.output.change",
"call.remove"
] | 1,040,563
| 1,040,564
|
u017744950
|
ruby
|
p03251
|
N,M,X,Y=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
y=gets.split.map(&:to_i)
puts [*X+1..Y].map{|t|t >= x.max && t <= y.min}.any? ? "No War" : "War"
|
N,M,X,Y=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
y=gets.split.map(&:to_i)
puts [*X+1..Y].map{|t|t > x.max && t <= y.min}.any? ? "No War" : "War"
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,040,565
| 1,040,564
|
u017744950
|
ruby
|
p03251
|
N,M,X,Y = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
y = gets.chomp.split(" ").map(&:to_i)
ok = false
(X+1..Y).each do |num|
if x.select{|n| n < num}.length == x.length && y.select{|n| n >= num}.length == y.length
ok = true
end
end
if ok
puts "No war"
else
puts "War"
end
|
N,M,X,Y = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
y = gets.chomp.split(" ").map(&:to_i)
ok = false
(X+1..Y).each do |num|
if x.select{|n| n < num}.length == x.length && y.select{|n| n >= num}.length == y.length
ok = true
end
end
if ok
puts "No War"
else
puts "War"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,040,624
| 1,040,625
|
u966695319
|
ruby
|
p03252
|
S = gets.chomp
T = gets.chomp
start = Array.new(26) { -1 }
goal = Array.new(26) { -1 }
impossibble = false
0.upto(S.size - 1) do |i|
s = S[i].ord - 'a'.ord
t = T[i].ord - 'a'.ord
if start[s] != -1 || goal[t] != -1
if start[s] != b || goal[t] != s
impossibble = true
break
end
end
start[s] = t
goal[t] = s
end
if impossibble
puts 'No'
else
puts 'Yes'
end
|
S = gets.chomp
T = gets.chomp
start = Array.new(26) { -1 }
goal = Array.new(26) { -1 }
impossibble = false
0.upto(S.size - 1) do |i|
s = S[i].ord - 'a'.ord
t = T[i].ord - 'a'.ord
if start[s] != -1 || goal[t] != -1
if start[s] != t || goal[t] != s
impossibble = true
break
end
end
start[s] = t
goal[t] = s
end
if impossibble
puts 'No'
else
puts 'Yes'
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,041,055
| 1,041,056
|
u237620737
|
ruby
|
p03251
|
(_, _, x, y), xs, ys = gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i)
zf, zt = x, y
if zf > zt
puts 'War'
else
xs.each {|xx| zf = xx if zf < xx }
ys.each {|yy| zt = yy if zt > yy }
puts zf <= zt ? 'No War' : 'War'
end
|
(_, _, x, y), xs, ys = gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i)
zf, zt = x, y # zf < z <= zt
if zf >= zt
puts 'War'
else
xs.each {|xx| zf = xx if zf < xx }
ys.each {|yy| zt = yy if zt >= yy }
puts zf < zt ? 'No War' : 'War'
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,041,266
| 1,041,267
|
u333012034
|
ruby
|
p03251
|
(_, _, x, y), xs, ys = gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i)
zf, zt = x + 1, y
if zf > zt
puts 'War'
else
xs.each {|xx| zf = xx if zf < xx }
ys.each {|yy| zt = yy if zt > yy }
puts zf <= zt ? 'No War' : 'War'
end
|
(_, _, x, y), xs, ys = gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i)
zf, zt = x, y # zf < z <= zt
if zf >= zt
puts 'War'
else
xs.each {|xx| zf = xx if zf < xx }
ys.each {|yy| zt = yy if zt >= yy }
puts zf < zt ? 'No War' : 'War'
end
|
[
"expression.operation.binary.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,041,268
| 1,041,267
|
u333012034
|
ruby
|
p03251
|
n, m, x, y = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
xs.push(x)
ys = gets.split.map(&:to_i)
ys.push(y)
puts (xs.max < ys.min and x < y) ? "No war" : "War"
|
n, m, x, y = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i)
xs.push(x)
ys = gets.split.map(&:to_i)
ys.push(y)
puts (xs.max < ys.min) ? "No War" : "War"
|
[
"expression.operation.binary.remove",
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,041,297
| 1,041,298
|
u712322283
|
ruby
|
p03252
|
s = gets.chomp.chars.map{|c| c.ord - 'a'.ord}
t = gets.chomp.chars.map{|c| c.ord - 'a'.ord}
matrix = Array.new(26){ Array.new(26, false) }
(0...s.size).each do |i|
matrix[s[i]][t[i]] = true
end
if matrix.all?{|row| row.count(true) <= 1} && matrix.tranpose.all?{|row| row.count(true) <= 1}
puts 'Yes'
else
puts 'No'
end
|
s = gets.chomp.chars.map{|c| c.ord - 'a'.ord}
t = gets.chomp.chars.map{|c| c.ord - 'a'.ord}
matrix = Array.new(26){ Array.new(26, false) }
(0...s.size).each do |i|
matrix[s[i]][t[i]] = true
end
if matrix.all?{|row| row.count(true) <= 1} && matrix.transpose.all?{|row| row.count(true) <= 1}
puts 'Yes'
else
puts 'No'
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,041,313
| 1,041,314
|
u794250528
|
ruby
|
p03252
|
#!/usr/bin/env ruby
s = gets.chomp.split(//)
t = gets.chomp.split(//)
h = Hash.new
nn = Hash.new
result = 'Yes'
s.size.times do |i|
if h.has_key?(s[i])
if (h[s[i]] != t[i])
result = 'No'
end
else
h[s[i]] = t[i]
end
if hh.has_key?(t[i])
if (hh[t[i]] != s[i])
result = 'No'
end
else
hh[t[i]] = s[i]
end
end
#if (h.values.size != h.values.uniq.size)
# result = 'No'
#end
#h.keys.each do |k|
# v = h[k]
# if (h[v] != k && !h[v])
# result = 'No'
# end
#end
puts result
|
#!/usr/bin/env ruby
s = gets.chomp.split(//)
t = gets.chomp.split(//)
h = Hash.new
hh = Hash.new
result = 'Yes'
s.size.times do |i|
if h.has_key?(s[i])
if (h[s[i]] != t[i])
result = 'No'
end
else
h[s[i]] = t[i]
end
if hh.has_key?(t[i])
if (hh[t[i]] != s[i])
result = 'No'
end
else
hh[t[i]] = s[i]
end
end
#if (h.values.size != h.values.uniq.size)
# result = 'No'
#end
#h.keys.each do |k|
# v = h[k]
# if (h[v] != k && !h[v])
# result = 'No'
# end
#end
#hh.keys.each do |k|
# v = hh[k]
# if (hh[v] != k && !hh[v])
# result = 'No'
# end
#end
puts result
|
[
"assignment.variable.change",
"identifier.change"
] | 1,041,445
| 1,041,446
|
u029843816
|
ruby
|
p03253
|
require 'prime'
n, m = gets.strip.split.map(&:to_i)
MOD = 10**9+7
dims = m.prime_division.map(&:last)
def power(n, k)
return 1 if k.zero?
if k.even?
power(n, k/2)**2 %MOD
else
n*power(n, (k-1)/2)**2 %MOD
end
end
maximum = n+dims.max
@factor = [1,1]
(2..maximum).each do |i|
@factor[i] = @factor[i-1] * i
@factor[i] %= MOD
end
@ifactor = [1,1]
@ifactor[maximum] = power(@factor[maximum], MOD-2)
(maximum-1).downto(2).each do |i|
@ifactor[i] = @ifactor[i+1]*(i+1)
@ifactor[i] %= MOD
end
result=1
dims.each do |d|
# (n+d)C(d)
comb = (@factor[n+d-1]*(@ifactor[n-1]*@ifactor[d]%MOD)%MOD)
result *= comb
result %= MOD
#p [n, d, comb, @factor[n+d-1], @ifactor[n-1], @ifactor[d]]
end
p result
|
require 'prime'
n, m = gets.strip.split.map(&:to_i)
MOD = 10**9+7
dims = m.prime_division.map(&:last)
def power(n, k)
return 1 if k.zero?
if k.even?
power(n, k/2)**2 %MOD
else
n*power(n, (k-1)/2)**2 %MOD
end
end
maximum = n+(dims.max || 0)
@factor = [1,1]
(2..maximum).each do |i|
@factor[i] = @factor[i-1] * i
@factor[i] %= MOD
end
@ifactor = [1,1]
@ifactor[maximum] = power(@factor[maximum], MOD-2)
(maximum-1).downto(2).each do |i|
@ifactor[i] = @ifactor[i+1]*(i+1)
@ifactor[i] %= MOD
end
result=1
dims.each do |d|
# (n+d)C(d)
comb = (@factor[n+d-1]*(@ifactor[n-1]*@ifactor[d]%MOD)%MOD)
result *= comb
result %= MOD
#p [n, d, comb, @factor[n+d-1], @ifactor[n-1], @ifactor[d]]
end
p result
|
[] | 1,041,593
| 1,041,594
|
u021358975
|
ruby
|
p03253
|
require 'prime'
require 'pp'
def ncr(n, r)
r = [r, n - r].min
return 1 if r == 0
return n if r == 1
numerator = (n - r + 1..n).to_a
denominator = (1..r).to_a
(2..r).each{|p|
pivot = denominator[p - 1]
if pivot > 1
offset = (n - r) % p
(p - 1).step(r - 1, p){|k|
numerator[k - offset] /= pivot
denominator[k] /= pivot
}
end
}
result = 1
(0..r - 1).each{|k|
result *= numerator[k] if numerator[k] > 1
}
return result
end
n, m = gets.split
n = n.to_i
m = m.to_i
factors = m.prime_division
as = factors.map { |x| x[1] }
pp as
ans = 1
for a in as
ans = ans * ncr(a + n - 1, n - 1) % 1000000007
end
puts ans
|
require 'prime'
def ncr(n, r)
r = [r, n - r].min
return 1 if r == 0
return n if r == 1
numerator = (n - r + 1..n).to_a
denominator = (1..r).to_a
(2..r).each{|p|
pivot = denominator[p - 1]
if pivot > 1
offset = (n - r) % p
(p - 1).step(r - 1, p){|k|
numerator[k - offset] /= pivot
denominator[k] /= pivot
}
end
}
result = 1
(0..r - 1).each{|k|
result *= numerator[k] if numerator[k] > 1
}
return result
end
n, m = gets.split
n = n.to_i
m = m.to_i
factors = m.prime_division
as = factors.map { |x| x[1] }
ans = 1
for a in as
ans = ans * ncr(a + n - 1, n - 1) % 1000000007
end
puts ans
|
[
"call.remove"
] | 1,041,882
| 1,041,883
|
u208002342
|
ruby
|
p03254
|
N,x = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
A.sort!
num = 0
A.each do |a|
if a <= x then
x -= a
num += 1
else
break
end
end
num -=1 if x != 0
puts num
|
N,x = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
A.sort!
num = 0
A.each do |a|
if a <= x then
x -= a
num += 1
else
x -= a
break
end
end
num -=1 if x > 0
puts num
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,042,084
| 1,042,085
|
u244257825
|
ruby
|
p03254
|
i , max = gets.split.map(&:to_i)
array = gets.split.map(&:to_i).sort
cnt = 0
(1..i-1).each do |n|
if max < array[n]
break
end
if n == array.length-1 && max > array[n]
break
end
max -= array[n]
cnt += 1
end
puts cnt
|
i , max = gets.split.map(&:to_i)
array = gets.split.map(&:to_i).sort
cnt = 0
(0..i-1).each do |n|
if max < array[n]
break
end
if n == array.length-1 && max > array[n]
break
end
max -= array[n]
cnt += 1
end
puts cnt
|
[
"literal.number.integer.change"
] | 1,042,409
| 1,042,410
|
u809809975
|
ruby
|
p03254
|
i , max = gets.split.map(&:to_i)
array = gets.split.map(&:to_i).sort
cnt = 0
(1..i-1).each do |n|
if max < array[n]
break
end
if n == array.length-1 && max > array[n]
break
end
max -= array[n]
count += 1
end
puts cnt
|
i , max = gets.split.map(&:to_i)
array = gets.split.map(&:to_i).sort
cnt = 0
(0..i-1).each do |n|
if max < array[n]
break
end
if n == array.length-1 && max > array[n]
break
end
max -= array[n]
cnt += 1
end
puts cnt
|
[
"literal.number.integer.change",
"identifier.change"
] | 1,042,411
| 1,042,410
|
u809809975
|
ruby
|
p03254
|
i , max = gets.chomp.split(" ").map(&:to_i)
array = gets.chomp.split(" ").map(&:to_i).sort
count =0
(0..i-1).each do |n|
if max<array[n]
break
end
if n == array.length-1 && max > array[n]
break
end
p max = max - array[n]
count += 1
end
puts count
|
i , max = gets.chomp.split(" ").map(&:to_i)
array = gets.chomp.split(" ").map(&:to_i).sort
count =0
(0..i-1).each do |n|
if max<array[n]
break
end
if n == array.length-1 && max > array[n]
break
end
max = max - array[n]
count += 1
end
puts count
|
[
"io.output.change",
"call.remove"
] | 1,042,475
| 1,042,476
|
u599631096
|
ruby
|
p03254
|
##N人の子供がいます。 子供たちには 1,2, .. ,N と番号が振られています。
##x個のお菓子を子供たちに配ることにしました。
##このとき、 x個のお菓子をすべて配り切らなければなりません。
##お菓子を貰わない子供がいても構いません。
##各i (1 ≤ i ≤ N) について、子供 i はちょうど ai個のお菓子を貰うと喜びます。
##お菓子を配る方法を工夫し、喜ぶ子供の人数を最大化しようとしています。
##喜ぶ子供の人数の最大値を求めてください。
##入力は以下の形式で標準入力から与えられる。
##N x
##a1 a2 .. aN
n, x = gets.chomp.split(" ").map(&:to_i)
last = n - 1
a_n = gets.chomp.split(" ").map(&:to_i)
##喜ぶ子供の人数の最大値を出力せよ。
a_m = []
a_n.each_index do |idx|
check = x - a_n[idx]
if check >= 0
if idx == last
a_m << x
else
x -= a_n[idx]
a_m << a_n[idx]
end
else
a_m << 0
end
end
# p a_n
# p a_m
num = 0
a_m.each_index do |idx|
num += 1 if a_m[idx] == a_n[idx]
end
p num
|
##N人の子供がいます。 子供たちには 1,2, .. ,N と番号が振られています。
##x個のお菓子を子供たちに配ることにしました。
##このとき、 x個のお菓子をすべて配り切らなければなりません。
##お菓子を貰わない子供がいても構いません。
##各i (1 ≤ i ≤ N) について、子供 i はちょうど ai個のお菓子を貰うと喜びます。
##お菓子を配る方法を工夫し、喜ぶ子供の人数を最大化しようとしています。
##喜ぶ子供の人数の最大値を求めてください。
##入力は以下の形式で標準入力から与えられる。
##N x
##a1 a2 .. aN
n, x = gets.chomp.split(" ").map(&:to_i)
last = n - 1
a_n = gets.chomp.split(" ").map(&:to_i).sort
##喜ぶ子供の人数の最大値を出力せよ。
a_m = []
a_n.each_index do |idx|
check = x - a_n[idx]
if check >= 0
if idx == last
a_m << x
else
x -= a_n[idx]
a_m << a_n[idx]
end
else
a_m << 0
end
end
# p a_n
# p a_m
num = 0
a_m.each_index do |idx|
num += 1 if a_m[idx] == a_n[idx]
end
p num
|
[
"call.add"
] | 1,042,558
| 1,042,559
|
u496981480
|
ruby
|
p03254
|
n,x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
ans=0
a.each{|v|
break if v>x
x-=v
ans+=1
}
ans-=1 if ans>0 && x>0
puts ans
|
n,x=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
ans=0
a.each{|v|
break if v>x
x-=v
ans+=1
}
ans-=1 if ans==n && x>0
puts ans
|
[] | 1,042,719
| 1,042,720
|
u726630158
|
ruby
|
p03254
|
n, x = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort.reverse
c = 0
n.times do |i|
next if x < a[i]
c += 1
x -= a[i]
end
if x != 0 && c == n
p c - 1
else
p c
end
|
n, x = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i).sort
c = 0
n.times do |i|
next if x < a[i]
c += 1
x -= a[i]
end
if x != 0 && c == n
p c - 1
else
p c
end
|
[
"call.remove"
] | 1,042,784
| 1,042,785
|
u527280956
|
ruby
|
p03254
|
N,x=gets.split.map &:to_i
a=gets.split.map(&:to_i).sort
c=0
N.times{|i|
if x>=a[i] then
x-=a[i]
c+=1
end
}
if c>0&&x>0 then c-=1 end
p c
|
N,x=gets.split.map &:to_i
a=gets.split.map(&:to_i).sort
c=0
N.times{|i|
if x>=a[i] then
x-=a[i]
c+=1
end
}
if c==N&&x>0 then c-=1 end
p c
|
[] | 1,043,159
| 1,043,160
|
u656771711
|
ruby
|
p03254
|
N,x=gets.split.map &:to_i
a=gets.split.map(&:to_i).sort
c=0
N.times{|i|
if x>=a[i] then
x-=a[i]
c+=1
end
}
if x>0 then c-=1 end
p c
|
N,x=gets.split.map &:to_i
a=gets.split.map(&:to_i).sort
c=0
N.times{|i|
if x>=a[i] then
x-=a[i]
c+=1
end
}
if c==N&&x>0 then c-=1 end
p c
|
[
"control_flow.branch.if.condition.change"
] | 1,043,161
| 1,043,160
|
u656771711
|
ruby
|
p03254
|
# 入力の受け取り
input_line = readlines
input_line_first = input_line[0].split(" ")
input_line_second = input_line[1].split(" ")
# 受け取るパラメータ
children_num = input_line_first[0].to_i
candy_num = input_line_first[1].to_i
children_want_candy_num_array = input_line_second.map(&:to_i)
# 欲しいお菓子の数配列を昇順にソー1ト
children_want_candy_num_array.sort!
# 喜ぶ子供の人数を最大化
happy_children_count = 0
children_want_candy_num_array.each do |want_candy_num|
candy_num = candy_num - want_candy_num
if candy_num < 0
break
end
happy_children_count += 1
end
if candy_num != 0
happy_children_count -= 1
end
# 喜ぶ人数の最大値を出力
p happy_children_count
|
# 入力の受け取り
input_line = readlines
input_line_first = input_line[0].split(" ")
input_line_second = input_line[1].split(" ")
# 受け取るパラメータ
children_num = input_line_first[0].to_i
candy_num = input_line_first[1].to_i
children_want_candy_num_array = input_line_second.map(&:to_i)
# 欲しいお菓子の数配列を昇順にソー1ト
children_want_candy_num_array.sort!
# 喜ぶ子供の人数を最大化
happy_children_count = 0
children_want_candy_num_array.each do |want_candy_num|
candy_num = candy_num - want_candy_num
if candy_num < 0
break
end
happy_children_count += 1
end
if candy_num > 0
happy_children_count -= 1
end
# 喜ぶ人数の最大値を出力
p happy_children_count
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,043,162
| 1,043,163
|
u053294083
|
ruby
|
p03254
|
Copy
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
a.each_with_index do |m, i|
sum += m
if x < sum
puts i
break
elsif x == sum
puts i + 1
break
end
if i == n - 1
puts n - 1
end
end
|
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
a.each_with_index do |m, i|
sum += m
if x < sum
puts i
break
elsif x == sum
puts i + 1
break
end
if i == n - 1
puts n - 1
end
end
|
[] | 1,043,212
| 1,043,213
|
u331906013
|
ruby
|
p03254
|
Copy
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
a.each_with_index do |m, i|
sum += m
if x < sum
puts i
break
elsif x == sum
puts i + 1
break
end
if i == n - 1
puts n
end
end
|
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
a.each_with_index do |m, i|
sum += m
if x < sum
puts i
break
elsif x == sum
puts i + 1
break
end
if i == n - 1
puts n - 1
end
end
|
[
"expression.operation.binary.add"
] | 1,043,214
| 1,043,213
|
u331906013
|
ruby
|
p03254
|
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
a.each_with_index do |m, i|
sum += m
if x < sum
puts i
break
elsif x == sum
puts i + 1
break
end
if i == n - 1
puts n
end
end
|
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
sum = 0
a.each_with_index do |m, i|
sum += m
if x < sum
puts i
break
elsif x == sum
puts i + 1
break
end
if i == n - 1
puts n - 1
end
end
|
[
"expression.operation.binary.add"
] | 1,043,215
| 1,043,213
|
u331906013
|
ruby
|
p03260
|
puts gets =~ /2/ ? "Yes" : "No"
|
puts gets =~ /2/ ? "No" : "Yes"
|
[
"literal.string.change",
"call.arguments.change"
] | 1,044,158
| 1,044,159
|
u693378622
|
ruby
|
p03260
|
a, b = gets.split(" ").map(&:to_i)
if a % 2 == 0 && b % 2 == 0
puts "No"
else
puts "Yes"
end
|
a, b = gets.split(" ").map(&:to_i)
if a % 2 == 0 || b % 2 == 0
puts "No"
else
puts "Yes"
end
|
[
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 1,044,168
| 1,044,169
|
u748406041
|
ruby
|
p03260
|
a, b = gets.split(" ").map(&:to_i)
if a % 2 != 0 && b % 2 != 0
puts "No"
else
puts "Yes"
end
|
a, b = gets.split(" ").map(&:to_i)
if a % 2 == 0 || b % 2 == 0
puts "No"
else
puts "Yes"
end
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,044,170
| 1,044,169
|
u748406041
|
ruby
|
p03260
|
a, b = gets.chomp.split.map(&:to_i)
ans = a * b
if ans % 3 == 0
puts "Yes"
else
puts "No"
end
|
a, b = gets.chomp.split.map(&:to_i)
ans = a * b
if ans % 2 == 0
puts "No"
else
puts "Yes"
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change",
"call.remove",
"call.add"
] | 1,044,311
| 1,044,312
|
u552761221
|
ruby
|
p03260
|
puts gets.split.map(&:to_i).any?(&:even?) ? "Yes" : "No"
|
puts gets.split.map(&:to_i).any?(&:even?) ? "No" : "Yes"
|
[
"literal.string.change",
"call.arguments.change"
] | 1,044,347
| 1,044,348
|
u370564845
|
ruby
|
p03260
|
a,b = gets.chomp.split.map(&:to_i)
puts [a,b].even? ? 'No' : 'Yes'
|
a,b = gets.chomp.split.map(&:to_i)
puts (a*b).even? ? 'No' : 'Yes'
|
[
"control_flow.branch.if.condition.change"
] | 1,044,571
| 1,044,572
|
u303448696
|
ruby
|
p03260
|
if gets.include? "2"
puts "no"
else
puts "yes"
end
|
if gets.include? "2"
puts "No"
else
puts "Yes"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,044,738
| 1,044,739
|
u714769076
|
ruby
|
p03260
|
a=gets.split.map(&:to_i)
for i in 1..3
if a[0]*a[1]*i%2 !=0
puts "Yes"
break
end
end
puts "No"
|
a=gets.split.map(&:to_i)
for i in 1..3
if a[0]*a[1]*i%2 !=0
puts "Yes"
exit
end
end
puts "No"
|
[
"control_flow.break.remove",
"control_flow.exit.add"
] | 1,044,788
| 1,044,789
|
u585819925
|
ruby
|
p03253
|
def combi(n,k)
k=n-k if 2*k > n
return 1 if k == 0
((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end
require 'prime'
N,M=gets.split.map &:to_i
f=M.prime_division
c=1
f.each{|x|
p x
c*=combi(x[1]+N-1,N-1)
c=c%(10**9+7)
}
p c
|
def combi(n,k)
k=n-k if 2*k > n
return 1 if k == 0
((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end
require 'prime'
N,M=gets.split.map &:to_i
f=M.prime_division
c=1
f.each{|x|
c*=combi(x[1]+N-1,N-1)
c=c%(10**9+7)
}
p c
|
[
"call.remove"
] | 1,044,850
| 1,044,851
|
u656771711
|
ruby
|
p03253
|
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
if(IS_DEBUG)
puts str
end
end
def dpp str
if(IS_DEBUG)
pp str
end
end
require 'complex'
def eratosthenes(n)
is_p = Array.new(n+1){true}
is_p[0] = false
is_p[1] = false
2.upto(N){|i|
if(is_p[i])
j = i+i
while(j<=N)
is_p[j]=false
j+=i
end
end
}
is_p
end
def prime_decomp(n,is_p)
h = {}
if(is_p[n])
h[n] = 1
return h
end
q = n
for d in 2..(Math.sqrt(n).to_i)
if(is_p[d])
dcnt = 0
while(q%d==0)
q /= d
dcnt += 1
end
dcnt != 0 ? h[d] = dcnt : 1
end
end
q != 1 ? h[q] = 1 : 1
dpp h
h
end
def comb(n,a)
return $fact[n] * $finv[a] % $mod * $finv[n-a] % $mod;
end
def pow(a,n)
prd = 1;
exp = a;
while(n > 0)
if((n&1)==1)
prd *= exp;
prd %= $mod;
end
exp *= exp;
exp %= $mod;
n >>= 1;
end
return prd;
end
# constant
NMAX = 100100;
$mod = 998244353;
$mod = 10**9+7;
$fact = Array.new(NMAX);
$finv = Array.new(NMAX);
# read
# preprocess
$fact[0] = 1;
$finv[0] = 1;
for i in 1..(NMAX)
$fact[i] = $fact[i-1] * i % $mod;
$finv[i] = pow($fact[i], $mod-2);
end
# main
N,M=gets.chomp.split(' ').map{|n| n.to_i}
num = 1
is_p = eratosthenes(Math.sqrt(M))
prime_decomp(M,is_p).each{|k,v|
num *= comb(v+N-1,v)
}
puts num
|
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
if(IS_DEBUG)
puts str
end
end
def dpp str
if(IS_DEBUG)
pp str
end
end
require 'complex'
def eratosthenes(n)
is_p = Array.new(n+1){true}
is_p[0] = false
is_p[1] = false
2.upto(N){|i|
if(is_p[i])
j = i+i
while(j<=N)
is_p[j]=false
j+=i
end
end
}
is_p
end
def prime_decomp(n,is_p)
h = {}
if(is_p[n])
h[n] = 1
return h
end
q = n
for d in 2..(Math.sqrt(n).to_i)
if(is_p[d])
dcnt = 0
while(q%d==0)
q /= d
dcnt += 1
end
dcnt != 0 ? h[d] = dcnt : 1
end
end
q != 1 ? h[q] = 1 : 1
dpp h
h
end
def comb(n,a)
return $fact[n] * $finv[a] % $mod * $finv[n-a] % $mod;
end
def pow(a,n)
prd = 1;
exp = a;
while(n > 0)
if((n&1)==1)
prd *= exp;
prd %= $mod;
end
exp *= exp;
exp %= $mod;
n >>= 1;
end
return prd;
end
# constant
NMAX = 100100;
$mod = 998244353;
$mod = 10**9+7;
$fact = Array.new(NMAX);
$finv = Array.new(NMAX);
# read
# preprocess
$fact[0] = 1;
$finv[0] = 1;
for i in 1..(NMAX)
$fact[i] = $fact[i-1] * i % $mod;
$finv[i] = pow($fact[i], $mod-2);
end
# main
N,M=gets.chomp.split(' ').map{|n| n.to_i}
num = 1
is_p = eratosthenes(Math.sqrt(M))
prime_decomp(M,is_p).each{|k,v|
num = num * comb(v+N-1,v) % $mod
}
puts num
|
[
"assignment.value.change"
] | 1,044,914
| 1,044,915
|
u415591191
|
ruby
|
p03253
|
require'prime';eval"N,M="+`tr \ ,`;r=1;M.prime_division.map{|n,k|k.times{|i|r=r*(N+k+~i)/-~i}};p r.%10**9+7
|
require'prime';eval"N,M="+`tr \\ ,`;r=1;M.prime_division.map{|n,k|k.times{|i|r=r*(N+k+~i)/-~i}};p r.%10**9+7
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,044,920
| 1,044,921
|
u280667879
|
ruby
|
p03260
|
A, B = gets.split.map(&:to_i)
p A*B%2==0? 'No':'Yes'
|
A, B = gets.split.map(&:to_i)
puts A*B%2==0? 'No':'Yes'
|
[
"call.function.change",
"io.output.change"
] | 1,045,158
| 1,045,159
|
u377726992
|
ruby
|
p03260
|
# ABC333
A,B = gets.chomp.split(" ").map(&:to_i)
flg = false
for i in 1..3 do
if A * B * i % 2 == 1
flg = true2 2
break
end
end
if flg == true
puts "Yes"
elsif flg == false
puts "No"
end
|
# ABC333
A,B = gets.chomp.split(" ").map(&:to_i)
flg = false
for i in 1..3 do
if A * B * i % 2 == 1
flg = true
break
end
end
if flg == true
puts "Yes"
elsif flg == false
puts "No"
end
|
[
"assignment.value.change",
"call.arguments.change"
] | 1,045,160
| 1,045,161
|
u743283842
|
ruby
|
p03260
|
def check(a, b)
3.times do |i|
ret = a * b * (i + 1)
return true if ret % 2 == 1
end
false
end
a, b = readliness.split(" ").map(&:to_i)
if check(a, b)
puts "Yes"
else
puts "No"
end
|
def check(a, b)
3.times do |i|
ret = a * b * (i + 1)
return true if ret % 2 == 1
end
false
end
a, b = STDIN.gets.split(" ").map(&:to_i)
if check(a, b)
puts "Yes"
else
puts "No"
end
|
[
"assignment.value.change",
"call.add"
] | 1,045,252
| 1,045,253
|
u017298112
|
ruby
|
p03260
|
a,b = gets.chops.split(" ").map!(&:to_i)
if a%2==1 && b%2==1
puts "Yes"
else
puts "No"
end
|
a,b = gets.chop.split(" ").map(&:to_i)
if a%2==1 && b%2==1
puts "Yes"
else
puts "No"
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,045,381
| 1,045,382
|
u422592877
|
ruby
|
p03260
|
a,b = gets.chops.split(" ").map(&:to_i)
if a%2==1 && b%2==1
puts "Yes"
else
puts "No"
end
|
a,b = gets.chop.split(" ").map(&:to_i)
if a%2==1 && b%2==1
puts "Yes"
else
puts "No"
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,045,383
| 1,045,382
|
u422592877
|
ruby
|
p03260
|
a =[]
a = gets.chomp.to_i
if (a[0] * a[1]) % 2 == 1
puts "Yes"
else
puts "No"
end
|
a = []
a = gets.split.map(&:to_i)
if (a[0] * a[1]) % 2 == 1
puts "Yes"
else
puts "No"
end
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.add"
] | 1,045,464
| 1,045,465
|
u614043796
|
ruby
|
p03260
|
# Your code here!
a,b = gets.split.map(&:to_i)
a = a*b
if(a%2==0)
puts "Yes"
else
puts "No"
end
|
# Your code here!
a,b = gets.split.map(&:to_i)
a = a*b
if(a%2==1)
puts "Yes"
else
puts "No"
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,045,561
| 1,045,562
|
u415041731
|
ruby
|
p03260
|
a, b = gets.split.map(&:to_i)
if a*b % 2 == 0
puts "Yes"
else
puts "No"
end
|
a, b = gets.split.map(&:to_i)
if a*b % 2 == 1
puts "Yes"
else
puts "No"
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,045,575
| 1,045,576
|
u592099403
|
ruby
|
p03260
|
a, b = gets.split.map(&:to_i)
if a % 2 and b % 2
puts 'Yes'
else
puts 'No'
end
|
a, b = gets.split.map(&:to_i)
if a % 2 == 1 and b % 2 == 1
puts 'Yes'
else
puts 'No'
end
|
[
"control_flow.branch.if.condition.change"
] | 1,045,577
| 1,045,578
|
u136869985
|
ruby
|
p03260
|
a,b = gets.chomp.split.map(&:to_i)
# p a,b
if a*b%2==1
puts 'yes'
else
puts 'no'
end
|
a,b = gets.chomp.split.map(&:to_i)
# p a,b
if a*b%2==1
puts 'Yes'
else
puts 'No'
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,045,618
| 1,045,619
|
u574326823
|
ruby
|
p03260
|
$><<`dd`[/2/]?:No: :Yes
|
puts`dd`[/2/]?:No: :Yes
|
[
"call.remove"
] | 1,045,725
| 1,045,726
|
u657913472
|
ruby
|
p03260
|
a,b=gets.chomp.split(" ").map(&:to_i);
if a*b % 2 == 0 then
puts "Yes"
else
puts "No"
end
|
a,b=gets.chomp.split(" ").map(&:to_i);
if a*b % 2 != 0 then
puts "Yes"
else
puts "No"
end
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,045,834
| 1,045,835
|
u501660472
|
ruby
|
p03260
|
a, b = gets.split(' ').map(&:to_i)
if (a * b).odd?
puts 'No'
else
puts 'Yes'
end
|
a, b = gets.split(' ').map(&:to_i)
if (a * b).odd?
puts 'Yes'
else
puts 'No'
end
|
[
"call.remove",
"call.add"
] | 1,045,918
| 1,045,919
|
u220501704
|
ruby
|
p03260
|
a, b = gets.chomp.split.map(&:to_i)
puts (a * b).odd? ? "YES" : "NO"
|
a, b = gets.chomp.split.map(&:to_i)
puts (a * b).odd? ? "Yes" : "No"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,045,930
| 1,045,931
|
u331906013
|
ruby
|
p03261
|
n = gets.to_i
wordArray = []
num = 0
n.times do
word = gets.chomp
wordArray.push(word)
end
ok1 = false
ok2 = false
if wordArray.count == wordArray.uniq.count
ok1 = true
end
(1..n-1).each do |w|
if wordArray[w-1][-1] == wordArray[w][0]
ok2 = true
end
end
if ok1 && ok2
puts "Yes"
else
puts "No"
end
|
n = gets.to_i
wordArray = []
num = 0
n.times do
word = gets.chomp
wordArray.push(word)
end
ok1 = false
ok2 = false
if wordArray.count == wordArray.uniq.count
ok1 = true
end
(1..n-1).each do |w|
if wordArray[w-1][-1] == wordArray[w][0]
ok2 = true
else
ok2 = false
break
end
end
if ok1 && ok2
puts "Yes"
else
puts "No"
end
|
[
"control_flow.break.add"
] | 1,046,594
| 1,046,595
|
u728874732
|
ruby
|
p03261
|
$stdin = DATA
n = gets.to_i
w = []
n.times do
w << gets.chomp
end
h = {}
w.each_with_index do |wi, i|
if h.has_key?(wi)
puts 'No'
exit
end
if i > 0 && wi[0] != w[i - 1][-1]
puts 'No'
exit
end
h[wi] = 0
end
puts 'Yes'
|
n = gets.to_i
w = []
n.times do
w << gets.chomp
end
h = {}
w.each_with_index do |wi, i|
if h.has_key?(wi)
puts 'No'
exit
end
if i > 0 && wi[0] != w[i - 1][-1]
puts 'No'
exit
end
h[wi] = 0
end
puts 'Yes'
|
[
"assignment.remove"
] | 1,046,613
| 1,046,614
|
u457499130
|
ruby
|
p03261
|
n = gets.to_i
s = Array.new(n)
for i in 0..(n-1)
s[i] = gets.chomp.split("")
end
flag = 0
wordcnt = Hash.new(0)
for i in 0..(n-1)
if i > 0
if s[i-1][-1] != s[i][0]
flag = 1
break
end
end
wordcnt[s[i].join] += 1
end
wordcnt.each do |cn|
if cn > 1
flag = 1
break
end
end
if flag > 0
puts "No"
else
puts "Yes"
end
|
n = gets.to_i
s = Array.new(n)
for i in 0..(n-1)
s[i] = gets.chomp.split("")
end
flag = 0
wordcnt = Hash.new(0)
for i in 0..(n-1)
if i > 0
if s[i-1][-1] != s[i][0]
flag = 1
break
end
end
wordcnt[s[i].join] += 1
end
wordcnt.each do |k, v|
if v > 1
flag = 1
break
end
end
if flag > 0
puts "No"
else
puts "Yes"
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,046,701
| 1,046,702
|
u326891688
|
ruby
|
p03261
|
n = gets.to_i
ws = Array.new(n){gets.chomp}
ans = ws==ws.uniq ? "Yes" : "No"
ws.each_with_index do |w,i|
if i < ws.length-1 && ws[i][-1] != ws[i+1][0]
flag = "No"
end
end
puts ans
|
n = gets.to_i
ws = Array.new(n){gets.chomp}
ans = ws==ws.uniq ? "Yes" : "No"
ws.each_with_index do |w,i|
if i < ws.length-1 && ws[i][-1] != ws[i+1][0]
ans = "No"
end
end
puts ans
|
[
"assignment.variable.change",
"identifier.change"
] | 1,046,816
| 1,046,817
|
u358554431
|
ruby
|
p03261
|
# frozen_string_literal: true
n = gets.chomp.to_i
w = []
n.times do
w.push gets.chomp
end
if w.size != w.uniq.size
puts 'No'
else
(n - 2).times do |i|
if w[i][-1] != w[i + 1][0]
puts 'No'
exit 0
end
end
puts 'Yes'
end
|
# frozen_string_literal: true
n = gets.chomp.to_i
w = []
n.times do
w.push gets.chomp
end
if w.size != w.uniq.size
puts 'No'
else
(n - 1).times do |i|
if w[i][-1] != w[i + 1][0]
puts 'No'
exit 0
end
end
puts 'Yes'
end
|
[
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,046,929
| 1,046,930
|
u434509016
|
ruby
|
p03261
|
n = gets.to_i
str = []
n.times do
s = gets.chomp
if(str.size!=0)
if(str[-1][-1]!=s[0]||str.find(s))
puts "No"
exit
end
end
str.push(s)
end
puts "Yes"
|
n = gets.to_i
str = []
n.times do
s = gets.chomp
if(str.size!=0)
if(str[-1][-1]!=s[0]||str.include?(s))
puts "No"
exit
end
end
str.push(s)
end
puts "Yes"
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,046,963
| 1,046,964
|
u415041731
|
ruby
|
p03261
|
COUNT = gets.to_i
array = readlines.map(&:chomp)
def run(array)
check_uniqueness(array) && check_order(array) ? :Yes : :No
end
def check_uniqueness(array)
array.uniq.size == array.size
end
def check_order(array)
array.map.with_index(1){|a,idx| a[-1] == array[idx][0] if idx < COUNT}.any?
end
puts run(array)
|
COUNT = gets.to_i
array = readlines.map(&:chomp)
def run(array)
check_uniqueness(array) && check_order(array) ? :Yes : :No
end
def check_uniqueness(array)
array.uniq.size == array.size
end
def check_order(array)
array.map.with_index(1){|a,idx| a[-1] == array[idx][0] if idx < COUNT}.compact.all?
end
puts run(array)
|
[
"identifier.change",
"call.add"
] | 1,046,970
| 1,046,971
|
u510556034
|
ruby
|
p03261
|
n = gets.to_i
w = n.times.map{gets.chomp}
ans = false
for i in 1..n-1
ans = false if w[i-1][-1] != w[i][0]
end
puts (ans && n == w.uniq.size) ? "Yes" : "No"
|
n = gets.to_i
w = n.times.map{gets.chomp}
ans = true
for i in 1..n-1
ans = false if w[i-1][-1] != w[i][0]
end
puts ans && n == w.uniq.size ? "Yes" : "No"
|
[
"misc.opposites",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 1,047,021
| 1,047,022
|
u506255180
|
ruby
|
p03261
|
n = gets.to_i
w = n.times.map{gets.chomp}
ans = false
for i in 1..n-1
ans = false if w[i-1][-1] != w[i][0]
end
puts (ans && n == w.uniq.size) ? "Yes" : "No"
|
n = gets.to_i
w = n.times.map{gets.chomp}
ans = true
for i in 1..n-1
ans = false if w[i-1][-1] != w[i][0]
end
puts (ans && n == w.uniq.size) ? "Yes" : "No"
|
[
"misc.opposites",
"assignment.value.change"
] | 1,047,021
| 1,047,023
|
u506255180
|
ruby
|
p03261
|
a=gets.to_i
b=a.times.map{gets.chomp.to_s}
d=1
stock="aa"
for c in b do
if d !=1 && c[-1]!=stock[0]
puts "No"
exit
end
stock=c
d +=1
end
if b.length == b.uniq.length then
puts "Yes"
else
puts "No"
end
|
a=gets.to_i
b=a.times.map{gets.chomp.to_s}
d=1
stock="aa"
for c in b do
if d !=1 && c[0]!=stock[-1]
puts "No"
exit
end
stock=c
d +=1
end
if b.length == b.uniq.length then
puts "Yes"
else
puts "No"
end
|
[
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"expression.operation.unary.remove",
"expression.operation.unary.add"
] | 1,047,100
| 1,047,102
|
u562148988
|
ruby
|
p03261
|
w=[]
n=gets.to_i.times{w<<gets.chop}
puts (1..(n-2)).all?{|i|w[i][-1]==w[i+1][0]}&&w.uniq.size==n ?:Yes: :No
|
w=[]
n=gets.to_i.times{w<<gets.chop}
puts (0..(n-2)).all?{|i|w[i][-1]==w[i+1][0]}&&w.uniq.size==n ?:Yes: :No
|
[] | 1,047,115
| 1,047,116
|
u752146271
|
ruby
|
p03261
|
n = gets.to_i
ws = (0...n).map { gets.chomp }
puts ws.size == ws.uniq.size && (1...n).map {|i| ws[i-1][-1] == ws[i][0] }.all? { true } ? 'Yes' : 'No'
|
n = gets.to_i
ws = (0...n).map { gets.chomp }
puts ws.size == ws.uniq.size && (1...n).map {|i| ws[i-1][-1] == ws[i][0] }.all? { |b| b } ? 'Yes' : 'No'
|
[
"control_flow.branch.if.condition.change"
] | 1,047,142
| 1,047,143
|
u333012034
|
ruby
|
p03261
|
num = gets.to_i
a = []
num.times do | i |
puts i
w = gets.chomp
if i != 0
if w[0] != a[-1][-1] || a.include?(w)
print "No"
break
end
end
if i == num-1
print "Yes"
end
a << w
end
|
num = gets.to_i
a = []
num.times do | i |
w = gets.chomp
if i != 0
if w[0] != a[-1][-1] || a.include?(w)
print "No"
break
end
end
if i == num-1
print "Yes"
end
a << w
end
|
[
"call.remove"
] | 1,047,167
| 1,047,168
|
u093975453
|
ruby
|
p03261
|
num = gets.to_i
a = []
num.times do | i |
puts i
w = gets.chomp
if i != 0
if w[1] != a[-1][-1] || a.include?(w)
print "No"
break
end
elsif i == num-1
print "Yes"
end
a << w
end
|
num = gets.to_i
a = []
num.times do | i |
w = gets.chomp
if i != 0
if w[0] != a[-1][-1] || a.include?(w)
print "No"
break
end
end
if i == num-1
print "Yes"
end
a << w
end
|
[
"call.remove",
"literal.number.integer.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 1,047,170
| 1,047,168
|
u093975453
|
ruby
|
p03261
|
n = gets.to_i
listed = {}
last = ""
ws = []
n.times{ |i|
ws.push(gets.chomp)
}
ws.each { |w|
p w
p last
if last == "" || (w[0] == last && listed[w].nil?)
else
print("No")
print("\n")
exit
end
listed[w] = true
last = w[w.length - 1]
}
print("Yes")
print("\n")
|
n = gets.to_i
listed = {}
last = ""
ws = []
n.times{ |i|
ws.push(gets.chomp)
}
ws.each { |w|
if last == "" || (w[0] == last && listed[w].nil?)
else
print("No")
print("\n")
exit
end
listed[w] = true
last = w[w.length - 1]
}
print("Yes")
print("\n")
|
[
"call.remove"
] | 1,047,171
| 1,047,172
|
u406084308
|
ruby
|
p03261
|
n = gets.to_i
listed = {}
last = ""
ws = []
n.times{ |i|
ws.push(gets)
}
ws.each { |w|
if last == "" || (w[0] == last && !listed[w].nil?)
else
print("No")
print("\n")
exit
end
listed[w] = true
last = w[w.length - 1]
}
print("Yes")
print("\n")
|
n = gets.to_i
listed = {}
last = ""
ws = []
n.times{ |i|
ws.push(gets.chomp)
}
ws.each { |w|
if last == "" || (w[0] == last && listed[w].nil?)
else
print("No")
print("\n")
exit
end
listed[w] = true
last = w[w.length - 1]
}
print("Yes")
print("\n")
|
[
"call.add",
"expression.operation.unary.logical.remove",
"control_flow.branch.if.condition.change"
] | 1,047,173
| 1,047,172
|
u406084308
|
ruby
|
p03261
|
wordslist = []
num = gets.to_i
for i in 1..num do
word = gets.chomp
if wordslist.include?(word)
puts "No"
exit
end
wordslist.push(word)
if i > 1
if word[0] != last
puts "No"
exit
end
end
last = word[-1]
end
puts "Yes"
|
wordslist = []
last = ""
num = gets.to_i
for i in 1..num do
word = gets.chomp
if wordslist.include?(word)
puts "No"
exit
end
wordslist.push(word)
if i > 1
if word[0] != last
puts "No"
exit
end
end
last = word[-1]
end
puts "Yes"
|
[
"assignment.add"
] | 1,047,178
| 1,047,179
|
u827568390
|
ruby
|
p03261
|
n = gets.chomp.to_i
words = n.times.map { gets.chomp }
if words.uniq.size != n || words.each_cons(2).any?{ |a, b| a[-1] != b[0] }
puts "NO"
else
puts "YES"
end
|
n = gets.chomp.to_i
words = n.times.map { gets.chomp }
if words.uniq.size != n || words.each_cons(2).any?{ |a, b| a[-1] != b[0] }
puts "No"
else
puts "Yes"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,047,224
| 1,047,225
|
u331906013
|
ruby
|
p03261
|
x=[];n=gets.to_i;pre=gets.chomp;x<<pre
(n-1).times do
str=gets.chomp
(x.include?(str)||pre[-1]!=str[0])&&(puts :No;exit)
pre=str
end;puts :Yes
|
x=[];n=gets.to_i;pre=gets.chomp;x<<pre
(n-1).times do
str=gets.chomp
(x.include?(str)||pre[-1]!=str[0])&&(puts :No;exit)
x<<str;pre=str
end;puts :Yes
|
[] | 1,047,316
| 1,047,317
|
u785521224
|
ruby
|
p03261
|
#!/usr/bin/env ruby
n = gets.chomp.to_i
words = Array.new
hash = Hash.new(0)
n.times do
str = gets.chomp
words << str
hash[str] += 1
end
vals = hash.values.uniq
vals.each do |v|
if (v > 1)
result = 'No'
end
end
first = words.shift
e = first.split(//)[-1]
if (result != 'No')
words.each do |w|
sp_string = w.split(//)
s = sp_string[0]
if (e == s)
e = sp_string[-1]
else
result = 'No'
break
end
end
result ||= 'Yes'
end
puts result
|
#!/usr/bin/env ruby
n = gets.chomp.to_i
words = Array.new
hash = Hash.new(0)
n.times do
str = gets.chomp
words << str
hash[str] += 1
end
result = nil
vals = hash.values.uniq
vals.each do |v|
if (v > 1)
result = 'No'
end
end
first = words.shift
e = first.split(//)[-1]
if (result != 'No')
words.each do |w|
sp_string = w.split(//)
s = sp_string[0]
if (e == s)
e = sp_string[-1]
else
result = 'No'
break
end
end
result ||= 'Yes'
end
puts result
|
[
"assignment.add"
] | 1,047,471
| 1,047,472
|
u029843816
|
ruby
|
p03261
|
#!/usr/bin/env ruby
n = gets.chomp.to_i
words = Array.new
hash = Hash.new(0)
n.times do
str = gets.chomp
words << str
hash[str] += 1
end
result = ''
vals = hash.values.uniq
vals.each do |v|
if (v > 1)
result = 'No'
end
end
first = words.shift
e = first.split(//)[-1]
if (result != 'No')
words.each do |w|
sp_string = w.split(//)
s = sp_string[0]
if (e == s)
e = sp_string[-1]
else
result = 'No'
break
end
end
result ||= 'Yes'
end
puts result
|
#!/usr/bin/env ruby
n = gets.chomp.to_i
words = Array.new
hash = Hash.new(0)
n.times do
str = gets.chomp
words << str
hash[str] += 1
end
result = nil
vals = hash.values.uniq
vals.each do |v|
if (v > 1)
result = 'No'
end
end
first = words.shift
e = first.split(//)[-1]
if (result != 'No')
words.each do |w|
sp_string = w.split(//)
s = sp_string[0]
if (e == s)
e = sp_string[-1]
else
result = 'No'
break
end
end
result ||= 'Yes'
end
puts result
|
[
"assignment.value.change"
] | 1,047,473
| 1,047,472
|
u029843816
|
ruby
|
p03261
|
#!/usr/bin/env ruby
n = gets.chomp.to_i
words = Array.new
hash = Hash.new(0)
n.times do
str = gets.chomp
words << str
hash[str] += 1
end
result = ''
vals = hash.values.uniq
vals.each do |v|
if (v > 1)
result = 'No'
end
end
first = words.shift
e = first.split(//)[-1]
if (result != 'No')
words.each do |w|
sp_string = w.split(//)
s = sp_string[0]
if (e == s)
e = sp_string[-1]
else
result = 'No'
break
end
end
result = 'Yes'
end
puts result
|
#!/usr/bin/env ruby
n = gets.chomp.to_i
words = Array.new
hash = Hash.new(0)
n.times do
str = gets.chomp
words << str
hash[str] += 1
end
result = nil
vals = hash.values.uniq
vals.each do |v|
if (v > 1)
result = 'No'
end
end
first = words.shift
e = first.split(//)[-1]
if (result != 'No')
words.each do |w|
sp_string = w.split(//)
s = sp_string[0]
if (e == s)
e = sp_string[-1]
else
result = 'No'
break
end
end
result ||= 'Yes'
end
puts result
|
[
"assignment.value.change"
] | 1,047,474
| 1,047,472
|
u029843816
|
ruby
|
p03261
|
puts`dd`[/
(.+)
(.+
)*\1
|(.)
(?!\3)./]?:No: :Yes
|
puts`dd`[/
(.+
)(.+
)*\1|(\D)
(?!\3)./]?:No: :Yes
|
[
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 1,047,534
| 1,047,535
|
u019489252
|
ruby
|
p03261
|
input = $stdin.read.split("\n")
input = input.slice(1, input.size - 2)
unless input.uniq.size == input.size
puts 'No'
exit
end
result = 'Yes'
input.each_with_index do |a, i|
break if input.size - 1 == i
a = a.split('')
next_a = input[i + 1].split('')
unless a[a.size - 1] == next_a[0]
result = 'No'
break
end
end
puts result
|
input = $stdin.read.split("\n")
input = input.slice(1, input.size - 1)
unless input.uniq.size == input.size
puts 'No'
exit
end
result = 'Yes'
input.each_with_index do |a, i|
break if input.size - 1 == i
a = a.split('')
next_a = input[i + 1].split('')
unless a[a.size - 1] == next_a[0]
result = 'No'
break
end
end
puts result
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,047,550
| 1,047,551
|
u220501704
|
ruby
|
p03261
|
a={}
s=""
res="Yes"
gets.to_i.times {
t=gets.chomp
res="No" if a[t] || (s>"" && s[-1]!=t[0])
a[t]=true;
}
puts res
|
a={}
s=""
res="Yes"
gets.to_i.times {
t=gets.chomp
res="No" if a[t] || (s>"" && s[-1]!=t[0])
a[s=t]=true;
}
puts res
|
[
"assignment.add"
] | 1,047,566
| 1,047,567
|
u503549962
|
ruby
|
p03261
|
def ascan; gets.split.map(&:to_i); end
dic = {}
last = nil
gets.to_i.times do
str = gets.chomp
if dic[str]
puts "No"; exit
end
if last && last[-1] != str[0]
puts "No"; exit
end
dic[str] = true
end
puts "Yes"
|
def ascan; gets.split.map(&:to_i); end
dic = {}
last = nil
gets.to_i.times do
str = gets.chomp
if dic[str]
puts "No"; exit
end
if last && last[-1] != str[0]
puts "No"; exit
end
last = str
dic[str] = true
end
puts "Yes"
|
[
"assignment.add"
] | 1,047,572
| 1,047,573
|
u079330987
|
ruby
|
p03262
|
def gcd(a,b)
a.gcd(b)
end
n,X = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-X).abs}
ans = x[0]
(1..(n-1)).each do |i|
ans = gcd(ans, x[1])
end
puts ans
|
def gcd(a,b)
a.gcd(b)
end
n,X = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-X).abs}
ans = x[0]
(1..(n-1)).each do |i|
ans = gcd(ans, x[i])
end
puts ans
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 1,047,975
| 1,047,976
|
u238956837
|
ruby
|
p03262
|
def gcd(a,b)
a.gcd(b)
end
n,X = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-X).abs}
ans = x[0]
print x
(1..(n-1)).each do |i|
ans = gcd(ans, x[1])
end
puts ans
|
def gcd(a,b)
a.gcd(b)
end
n,X = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-X).abs}
ans = x[0]
(1..(n-1)).each do |i|
ans = gcd(ans, x[i])
end
puts ans
|
[
"call.remove",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 1,047,977
| 1,047,976
|
u238956837
|
ruby
|
p03262
|
def gcd(a,b)
a.gcd(b)
end
n,x = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-x).abs}
ans = x[0]
(1..(n-1)).each do |i|
ans = gcd(ans, x[1])
end
puts ans
|
def gcd(a,b)
a.gcd(b)
end
n,X = gets.split.map(&:to_i)
x = gets.split.map{|v| (v.to_i-X).abs}
ans = x[0]
(1..(n-1)).each do |i|
ans = gcd(ans, x[i])
end
puts ans
|
[
"assignment.variable.change",
"assignment.value.change",
"expression.operation.binary.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 1,047,978
| 1,047,976
|
u238956837
|
ruby
|
p03262
|
N,y = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)
puts X.map{|x| x - y }.inject(&:gcd)
|
N,y = gets.split.map(&:to_i)
X = gets.split.map(&:to_i)
puts X.map{|x| (x - y).abs }.inject(&:gcd)
|
[
"call.arguments.change",
"call.add"
] | 1,048,530
| 1,048,531
|
u627981707
|
ruby
|
p03262
|
def gcd(n,m)
if n % m == 0
return n/m
end
return gcd(m,n%m)
end
datas = gets.split(" ").map{|nn|nn.to_i}
n = datas[0]
x = datas[1]
datas = gets.split(" ").map{|nn|nn.to_i}
datas.sort!
minus = []
1.upto(datas.size-1) do|nn|
minus << datas[nn] - datas[nn-1]
end
puts minus.inject(:gcd).to_s;
|
def gcd(n,m)
if n % m == 0
return n/m
end
return gcd(m,n%m)
end
datas = gets.split(" ").map{|nn|nn.to_i}
n = datas[0]
x = datas[1]
datas = gets.split(" ").map{|nn|nn.to_i}
datas << x
datas.sort!
minus = []
1.upto(datas.size-1) do|nn|
minus << datas[nn] - datas[nn-1]
end
puts minus.inject(:gcd).to_s;
|
[
"expression.operation.binary.add"
] | 1,048,618
| 1,048,619
|
u328174452
|
ruby
|
p03262
|
_,X=gets.split.map &:to_i;p gets.split.map{|i|i.to_i-X}.inject :gcd
|
_,X=gets.split.map &:to_i;p gets.split.map{|i|i.to_i-X}.inject 0,:gcd
|
[
"call.arguments.add"
] | 1,048,631
| 1,048,632
|
u782685137
|
ruby
|
p03262
|
n,x = gets.split.map(&:to_i)
a = gets.split.map{|i|i.to_i-x}.sort
ans = a[0]
for i in 1..n-1
ans = ans.gcd(a[i]-a[i-1])
end
puts ans
|
n,x = gets.split.map(&:to_i)
a = gets.split.map{|i|i.to_i-x}.sort
ans = a[0]
for i in 1..n-1
ans = ans.gcd(a[i]-a[i-1])
end
puts ans.abs
|
[
"call.add"
] | 1,048,748
| 1,048,749
|
u506255180
|
ruby
|
p03262
|
N,X = gets.split.map(&:to_i)
x = gets.split.map{|t|t.to_i-X}
p x.inject{|a,b| a.gcd(b)}
|
N,X = gets.split.map(&:to_i)
x = gets.split.map{|t|t.to_i-X}
p x.inject{|a,b| a.gcd(b)}.abs
|
[
"call.add"
] | 1,048,795
| 1,048,796
|
u397763977
|
ruby
|
p03262
|
module ArrayRefinement
refine Array do
# 配列に対する最小公倍数
def lcm
self.inject(:lcm)
end
# 配列に対する最大公約数
def gcd
self.inject(:gcd)
end
end
end
using ArrayRefinement
def main
n, x = gets.split.map(&:to_i)
nums = gets.split.map do |s|
i = s.to_i
i - x
end
puts nums.gcd
end
if __FILE__ == $0
main
end
|
module ArrayRefinement
refine Array do
# 配列に対する最小公倍数
def lcm
self.inject(:lcm)
end
# 配列に対する最大公約数
def gcd
self.inject(:gcd)
end
end
end
using ArrayRefinement
def main
n, x = gets.split.map(&:to_i)
nums = gets.split.map do |s|
i = s.to_i
i - x
end
puts nums.gcd.abs
end
if __FILE__ == $0
main
end
|
[
"call.add"
] | 1,048,833
| 1,048,834
|
u657749689
|
ruby
|
p03262
|
n, x = gets.chomp.split.map(&:to_i)
ax = gets.chomp.split.map(&:to_i)
ax = ax.delete_if {|i| i == x}
puts ax.map {|i| (i-x).abs}.min
|
n, x = gets.chomp.split.map(&:to_i)
ax = gets.chomp.split.map(&:to_i)
ax = ax.delete_if {|i| i == x}
puts ax.map {|i| (i-x).abs}.inject(:gcd)
|
[
"identifier.change",
"call.arguments.change",
"io.output.change",
"call.arguments.add"
] | 1,048,925
| 1,048,926
|
u427155858
|
ruby
|
p03262
|
require 'prime'
class Integer
def my_divisor_list2
return [1] if self == 1
Prime.prime_division(self).map do |e|
Array.new(e[1]+1).map.with_index do |element, i|
e[0]**i
end
end.inject{|p,q| p.product(q)}.map do |a|
[a].flatten.inject(&:*)
end.sort
end
end
inputs = gets
arr = inputs.split
num = arr[0].to_i
init_x = arr[1].to_i
citys = gets.split
citys.map!(&:to_i)
citys.map! {|a| (a - init_x).abs }
citys.sort!
arr = citys[0].my_divisor_list2.reverse!
flag = true
arr.each do |a|
citys.each do |x|
if x % a != 0 then
flag = false
next
end
end
if flag == true then
p a
break;
end
end
|
require 'prime'
class Integer
def my_divisor_list2
return [1] if self == 1
Prime.prime_division(self).map do |e|
Array.new(e[1]+1).map.with_index do |element, i|
e[0]**i
end
end.inject{|p,q| p.product(q)}.map do |a|
[a].flatten.inject(&:*)
end.sort
end
end
inputs = gets
arr = inputs.split
num = arr[0].to_i
init_x = arr[1].to_i
citys = gets.split
citys.map!(&:to_i)
citys.map! {|a| (a - init_x).abs }
citys.sort!
arr = citys[0].my_divisor_list2.reverse!
arr.each do |a|
flag = true
citys.each do |x|
if x % a != 0 then
flag = false
next
end
end
if flag == true then
p a
break;
end
end
|
[
"assignment.remove",
"assignment.add"
] | 1,048,966
| 1,048,967
|
u266671911
|
ruby
|
p03262
|
N,X = gets.chomp.split(" ").map(&:to_i)
points= gets.chomp.split(" ").map(&:to_i)
points.insert(X).sort!
dis=[]
points.each_with_index do |point,i|
if i!=0
dis << point - points[i-1]
end
end
def gcd(n, m)
n, m = m, n if m > n
#p [n, m]
loop {
r = n % m
break if r == 0
n, m = m, r
}
m
end
dis = dis.inject{|a, b| gcd(a, b)}
if dis
puts dis
else
puts points[0]-X
end
|
N,X = gets.chomp.split(" ").map(&:to_i)
points= gets.chomp.split(" ").map(&:to_i)
points << X
points.sort!
dis=[]
points.each_with_index do |point,i|
if i!=0
dis << point - points[i-1]
end
end
def gcd(n, m)
n, m = m, n if m > n
#p [n, m]
loop {
r = n % m
break if r == 0
n, m = m, r
}
m
end
dis = dis.inject{|a, b| gcd(a, b)}
if dis
puts dis
else
puts points[0]-X
end
|
[
"call.remove",
"call.arguments.change"
] | 1,049,119
| 1,049,120
|
u966695319
|
ruby
|
p03262
|
n,*x=`dd`.split.map &:to_i
puts x.sort.each_cons(2).map{|x,y|y-x}.min
|
n,*x=`dd`.split.map &:to_i
puts x.sort.each_cons(2).map{|x,y|y-x}.inject(:gcd)
|
[
"identifier.change",
"call.arguments.change",
"io.output.change",
"call.arguments.add"
] | 1,049,186
| 1,049,187
|
u503549962
|
ruby
|
p03262
|
def ascan; gets.split.map(&:to_i); end
N,X = ascan
p ascan.map{|e| e-X}.reduce(:gcd)
|
def ascan; gets.split.map(&:to_i); end
N,X = ascan
p ascan.map{|e| e-X}.reduce(:gcd).abs
|
[
"call.add"
] | 1,049,188
| 1,049,189
|
u079330987
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.