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 |
|---|---|---|---|---|---|---|---|
p02688
|
ARRAY = gets.split.map(&:to_i)
N = ARRAY[0]
K = ARRAY[1]
$a = Array.new(K, 1)
K.times do
gets
tmp = gets.split.map(&:to_i)
tmp.each do |e|
$a[e - 1] = 0
end
end
puts $a.select{|v| v == 1}.count
|
ARRAY = gets.split.map(&:to_i)
N = ARRAY[0]
K = ARRAY[1]
$a = Array.new(N, 1)
K.times do
gets
tmp = gets.split.map(&:to_i)
tmp.each do |e|
$a[e - 1] = 0
end
end
puts $a.select{|v| v == 1}.count
|
[
"assignment.value.change",
"call.arguments.change"
] | 421,195
| 421,194
|
u990758634
|
ruby
|
p02688
|
require 'set'
n, k = gets.split.map(&:to_i)
snks = Set[]
k.times{|i|
gets
snks << gets.split.map(&:to_i)
}
puts n - snks.size
|
require 'set'
n, k = gets.split.map(&:to_i)
snks = Set[]
k.times{|i|
gets
snks += gets.split.map(&:to_i)
}
puts n - snks.size
|
[
"expression.operation.binary.change"
] | 421,206
| 421,207
|
u856564668
|
ruby
|
p02688
|
n,k=gets.split.map &:to_i
ar=k.times.map{
gets
gets.split.map &:to_i
}
p n - ar.uniq.size
|
n,k=gets.split.map &:to_i
ar=k.times.map{
gets
gets.split.map &:to_i
}
p n - ar.flatten.uniq.size
|
[
"call.add"
] | 421,611
| 421,612
|
u128694188
|
ruby
|
p02688
|
def gets_num
gets.split("\s").map(&:to_i)
end
n, k = gets_num
poors = (1..n-1).to_a
k.times do
gets
gets_num.each do |i|
poors.delete(i)
end
end
p poors.size
|
def gets_num
gets.split("\s").map(&:to_i)
end
n, k = gets_num
poors = (1..n).to_a
k.times do
gets
gets_num.each do |i|
poors.delete(i)
end
end
p poors.size
|
[
"expression.operation.binary.remove"
] | 421,710
| 421,711
|
u458429268
|
ruby
|
p02688
|
n, k = gets.split.map(&:to_i)
snk = Array.new(n+1, 0)
for i in 0..(k-1)
d = gets.to_i
a = gets.split.map(&:to_i)
a.each{|an| snk[an] += 1}
end
cnt = 0
for i in 1..n
snt += 1 if snk[i] == 0
end
puts cnt
|
n, k = gets.split.map(&:to_i)
snk = Array.new(n+1, 0)
for i in 0..(k-1)
d = gets.to_i
a = gets.split.map(&:to_i)
a.each{|an| snk[an] += 1}
end
cnt = 0
for i in 1..n
cnt += 1 if snk[i] == 0
end
puts cnt
|
[
"identifier.change"
] | 421,984
| 421,985
|
u326891688
|
ruby
|
p02689
|
n, m = gets.split(" ").map(&:to_i)
h_arr = [0] + gets.split(" ").map(&:to_i)
path_arr = []
m.times do
a, b = gets.split(" ").map(&:to_i)
path_arr[a] ||= []
path_arr[a] << b
path_arr[b] ||= []
path_arr[b] << a
end
path_arr[n - 1] ||= []
count = 0
path_arr.each_with_index do |arr, i|
next if i == 0
good = true
height = h_arr[i]
arr&.each do |ind|
if height <= h_arr[ind]
good = false
break
end
end
count += 1 if good
end
puts count
|
n, m = gets.split(" ").map(&:to_i)
h_arr = [0] + gets.split(" ").map(&:to_i)
path_arr = []
m.times do
a, b = gets.split(" ").map(&:to_i)
path_arr[a] ||= []
path_arr[a] << b
path_arr[b] ||= []
path_arr[b] << a
end
path_arr[n] ||= []
count = 0
path_arr.each_with_index do |arr, i|
next if i == 0
good = true
height = h_arr[i]
arr&.each do |ind|
if height <= h_arr[ind]
good = false
break
end
end
count += 1 if good
end
puts count
|
[
"expression.operation.binary.remove"
] | 422,122
| 422,123
|
u771770008
|
ruby
|
p02689
|
n, m = gets.strip.split.map(&:to_i)
h = gets.strip.split.map(&:to_i)
r = Array.new(n,1)
m.times do
a, b = gets.strip.split.map{|v| v.to_i-1}
d = h[a]-h[b]
r[a] = 0 if d <= 0
r[b] = 0 if d >= 0
end
p r-[0].size
|
n, m = gets.strip.split.map(&:to_i)
h = gets.strip.split.map(&:to_i)
r = Array.new(n,1)
m.times do
a, b = gets.strip.split.map{|v| v.to_i-1}
d = h[a]-h[b]
r[a] = 0 if d <= 0
r[b] = 0 if d >= 0
end
p (r-[0]).size
|
[
"call.arguments.change"
] | 423,539
| 423,540
|
u374892957
|
ruby
|
p02689
|
n, m = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)
arr = Array.new(n, 1)
m.times do
a, b = gets.split.map(&:to_i).sort!
arr[a - 1] = 0 if hs[a - 1] <= hs[b - 1]
arr[b - 1] = 0 if hs[a - 1] == hs[b - 1]
end
puts arr.count(1)
|
n, m = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)
arr = Array.new(n, 1)
m.times do
a, b = gets.split.map(&:to_i)
arr[a - 1] = 0 if hs[a - 1] <= hs[b - 1]
arr[b - 1] = 0 if hs[b - 1] <= hs[a - 1]
end
puts arr.count(1)
|
[
"call.remove",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 423,742
| 423,743
|
u889326464
|
ruby
|
p02689
|
n, m = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
root = Array.new(n).map{Array.new}
ans = 0
m.times do
a, b = gets.chomp.split(" ").map(&:to_i)
root[a-1] << b
root[b-1] << a
end
root.each_with_index do |arr, idx|
if arr.empty? then
next
end
flag = true
arr.uniq.each do |j|
flag = false if h[idx] < h[j-1]
end
if flag then
ans += 1
end
end
puts ans
|
n, m = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)
root = Array.new(n).map{Array.new}
ans = 0
m.times do
a, b = gets.chomp.split(" ").map(&:to_i)
root[a-1] << b
root[b-1] << a
end
root.each_with_index do |arr, idx|
if arr.empty? then
ans += 1
next
end
flag = true
arr.uniq.each do |j|
flag = false if h[idx] <= h[j-1]
end
if flag then
ans += 1
end
end
puts ans
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 423,765
| 423,766
|
u466332671
|
ruby
|
p02689
|
N, M = gets.chomp.split(" ").map(&:to_i)
H = gets.chomp.split(" ").map(&:to_i)
P = {}
M.times do
a, b = gets.chomp.split(" ").map(&:to_i)
P[a] = [] if P[a] == nil
P[a] << b
P[b] = [] if P[b] == nil
P[b] << a
end
cnt = 0
N.times do |i|
path = P[i + 1]
cnt += 1 if path == nil || path.all? {|n| n < H[i]}
end
puts cnt
|
N, M = gets.chomp.split(" ").map(&:to_i)
H = gets.chomp.split(" ").map(&:to_i)
P = {}
M.times do
a, b = gets.chomp.split(" ").map(&:to_i)
P[a] = [] if P[a] == nil
P[a] << b
P[b] = [] if P[b] == nil
P[b] << a
end
cnt = 0
N.times do |i|
path = P[i + 1]
cnt += 1 if path == nil || path.all? {|n| H[n-1] < H[i]}
end
puts cnt
|
[
"control_flow.branch.if.condition.change"
] | 423,831
| 423,832
|
u778692431
|
ruby
|
p02689
|
N, M = gets.chomp.split(" ").map(&:to_i)
H = gets.chomp.split(" ").map(&:to_i)
P = {}
M.times do
a, b = gets.chomp.split(" ").map(&:to_i)
P[a] = [] if P[a] == nil
P[a] << b
P[b] = [] if P[b] == nil
P[b] << a
end
cnt = 0
N.times do |i|
path = P[i + 1]
cnt += 1 if path != nil || path.all? {|n| n < H[i]}
end
puts cnt
|
N, M = gets.chomp.split(" ").map(&:to_i)
H = gets.chomp.split(" ").map(&:to_i)
P = {}
M.times do
a, b = gets.chomp.split(" ").map(&:to_i)
P[a] = [] if P[a] == nil
P[a] << b
P[b] = [] if P[b] == nil
P[b] << a
end
cnt = 0
N.times do |i|
path = P[i + 1]
cnt += 1 if path == nil || path.all? {|n| H[n-1] < H[i]}
end
puts cnt
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 423,833
| 423,832
|
u778692431
|
ruby
|
p02689
|
n,m = gets.chomp.split(" ").map{|e|e.to_i}
h = gets.chomp.split(" ").map{|e|e.to_i}
good = Array.new(n, true)
m.times do
a, b = gets.chomp.split(" ").map{|e|e.to_i}
a -= 1
b -= 1
if h[a]>h[b] then
good[b] = false
elsif h[a]<h[b] then
good[a] = false
else
good[a] = false
good[b] = false
end
end
p h
sum = 0
for i in good do i&&sum+=1 end
print(sum)
|
n,m = gets.chomp.split(" ").map{|e|e.to_i}
h = gets.chomp.split(" ").map{|e|e.to_i}
good = Array.new(n, true)
m.times do
a, b = gets.chomp.split(" ").map{|e|e.to_i}
a -= 1
b -= 1
if h[a]>h[b] then
good[b] = false
elsif h[a]<h[b] then
good[a] = false
else
good[a] = false
good[b] = false
end
end
sum = 0
for i in good do i&&sum+=1 end
print(sum)
|
[
"call.remove"
] | 423,929
| 423,930
|
u849186626
|
ruby
|
p02690
|
x = gets.to_i
(-120..120).each do |i|
(-120..120).each do |j|
if (i ** 5 - j ** j) == x
puts "#{i} #{j}"
return
end
end
end
|
x = gets.to_i
(-120..120).each do |i|
(-120..120).each do |j|
if (i ** 5 - j ** 5) == x
puts "#{i} #{j}"
return
end
end
end
|
[
"identifier.replace.remove",
"literal.replace.add",
"control_flow.branch.if.condition.change"
] | 424,162
| 424,163
|
u771770008
|
ruby
|
p02690
|
x = gets.to_i
(-120..120).each do |i|
(-120..120).each do |j|
if i ** 5 - j ** j == x
puts "#{i} #{j}"
return
end
end
end
|
x = gets.to_i
(-120..120).each do |i|
(-120..120).each do |j|
if (i ** 5 - j ** 5) == x
puts "#{i} #{j}"
return
end
end
end
|
[
"control_flow.branch.if.condition.change",
"identifier.replace.remove",
"literal.replace.add"
] | 424,164
| 424,163
|
u771770008
|
ruby
|
p02689
|
n,m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ar = Array.new(n).map{Array.new}
m.times do
a,b = gets.split.map(&:to_i)
ar[a-1] << h[b-1]
ar[b-1] << h[a-1]
end
ans = 0
for i in 0..(n-1)
if ar[i] == [] || ar[i].max < h[i]
ans += 1
puts i
end
end
puts ans
|
n,m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ar = Array.new(n).map{Array.new}
m.times do
a,b = gets.split.map(&:to_i)
ar[a-1] << h[b-1]
ar[b-1] << h[a-1]
end
ans = 0
for i in 0..(n-1)
if ar[i] == [] || ar[i].max < h[i]
ans += 1
end
end
puts ans
|
[
"call.remove"
] | 424,203
| 424,204
|
u911373146
|
ruby
|
p02690
|
# ABC 166 D - I hate Factorization
# https://atcoder.jp/contests/abc166/tasks/abc166_d
# AC
# https://atcoder.jp/contests/abc166/submissions/12757667
x = gets.chomp.to_i
h = {}
(120..120).each do |i|
h[i] = i ** 5
h[-i] = - h[i]
end
def search(x, h)
(-120..120).to_a.each do |a|
(-120..120).to_a.each do |b|
return [a, b] if h[a] - h[b] == x
end
end
return nil
end
ab = search(x, h)
raise if ab.nil?
puts ab.map(&:to_s).join(' ')
|
x = gets.chomp.to_i
h = {}
(0..120).each do |i|
h[i] = i ** 5
h[-i] = - h[i]
end
def search(x, h)
(-120..120).to_a.each do |a|
(-120..120).to_a.each do |b|
return [a, b] if h[a] - h[b] == x
end
end
return nil
end
ab = search(x, h)
raise if ab.nil?
puts ab.map(&:to_s).join(' ')
|
[
"literal.number.integer.change"
] | 425,938
| 425,939
|
u094532861
|
ruby
|
p02690
|
x = gets.to_i
400.times{|a|
aa = a-200
a5 = aa**5
400.times{|b|
bb = b-200
b5 = bb**5
if(a5 - b5 == x) then
puts("#{a} #{b}")
exit(0)
end
}
}
|
x = gets.to_i
400.times{|a|
aa = a-200
a5 = aa**5
400.times{|b|
bb = b-200
b5 = bb**5
if(a5 - b5 == x) then
puts("#{aa} #{bb}")
exit(0)
end
}
}
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 426,026
| 426,027
|
u527537690
|
ruby
|
p02690
|
N = 10000
x = gets.to_i
dp = Array.new(N){ |i| i ** 5 }
dp.each_with_index do |a,i|
dp.each_with_index do |b,j|
if a + b == x
puts [i,j].join(" ")
exit
end
if a - b == x
puts [i,-j].join(" ")
exit
end
end
end
|
N = 10000
x = gets.to_i
dp = Array.new(N){ |i| i ** 5 }
dp.each_with_index do |a,i|
dp.each_with_index do |b,j|
if a + b == x
puts [i,-j].join(" ")
exit
end
if a - b == x
puts [i,j].join(" ")
exit
end
end
end
|
[
"expression.operation.unary.add",
"call.arguments.change",
"expression.operation.unary.arithmetic.remove"
] | 427,685
| 427,686
|
u106964380
|
ruby
|
p02690
|
x = gets.to_i
flag = 0
a = b = 0
while flag == 0 && a < 10
d = a**5 - x
tmp = (d**(1/5.0)).abs
if d - (tmp.abs.floor)**5 == 0
flag = 1
b = tmp.abs.floor
elsif d + (tmp.abs.floor)**5 == 0
flag = 1
b = tmp.abs.floor * (-1)
else
a += 1
end
end
puts "#{a} #{b}"
|
x = gets.to_i
flag = 0
a = b = 0
while flag == 0
d = a**5 - x
tmp = (d**(1/5.0)).abs
#puts "#{a} #{d} #{tmp} #{tmp.floor}"
if d - (tmp.abs.floor)**5 == 0
flag = 1
b = tmp.abs.floor
elsif d + (tmp.abs.floor)**5 == 0
flag = 1
b = tmp.abs.floor * (-1)
else
a += 1
end
end
puts "#{a} #{b}"
|
[
"expression.operation.binary.remove"
] | 428,898
| 428,899
|
u326891688
|
ruby
|
p02691
|
n=gets.to_i
a=gets.split.map(&:to_i)
t=[]
h=Hash.new(0)
a.each_with_index{|e,i|t<<e+i+1; h[(i+1-e).abs]+=1}
ans=0
t.each{|e|ans+=h[e.abs]}
p ans
|
n=gets.to_i
a=gets.split.map(&:to_i)
t=[]
h=Hash.new(0)
a.each_with_index{|e,i|t<<e+i+1; h[i+1-e]+=1}
ans=0
t.each{|e|ans+=h[e]}
p ans
|
[
"call.remove"
] | 430,990
| 430,991
|
u234435881
|
ruby
|
p02691
|
n = gets.to_i
a = gets.split.map &:to_i
memo = Array.new(1000000000, 0)
ans = 0
n.times{|i|
ans += memo[i - a[i]]
memo[i + a[i]] += 1
}
puts ans
|
n = gets.to_i
a = gets.split.map &:to_i
memo = Hash.new(0)
ans = 0
n.times{|i|
ans += memo[i - a[i]]
memo[i + a[i]] += 1
}
puts ans
|
[
"assignment.value.change",
"call.arguments.change"
] | 431,023
| 431,024
|
u420073655
|
ruby
|
p02692
|
N, A, B, C = gets.split.map(&:to_i)
S = N.times.map { gets.chomp }
ans = []
counter = Hash.new(0)
counter['A'] = A
counter['B'] = B
counter['C'] = C
N.times do |i|
s1, s2 = S[i].chars
if counter[s1] == 0 && counter[s2] == 0
puts 'No'
exit
end
if i == N - 1
if counter[s1] < counter[s2]
counter[s1] += 1
counter[s2] -= 1
ans << s1
else
counter[s2] += 1
counter[s1] -= 1
ans << s2
end
else
if counter[s1] < counter[s2]
counter[s1] += 1
counter[s2] -= 1
ans << s1
elsif counter[s1] > counter[s2]
counter[s2] += 1
counter[s1] -= 1
ans << s2
else
ns1, ns2 = S[i + 1].chars
if s1 == ns1 && s2 == ns2
counter[s1] += 1
counter[s2] -= 1
ans << s1
else
t = [s1, s2] & [ns1, ns2]
if s1 == t
counter[s1] += 1
counter[s2] -= 1
ans << s1
else
counter[s2] += 1
counter[s1] -= 1
ans << s2
end
end
end
end
end
puts 'Yes'
puts ans
|
N, A, B, C = gets.split.map(&:to_i)
S = N.times.map { gets.chomp }
ans = []
counter = Hash.new(0)
counter['A'] = A
counter['B'] = B
counter['C'] = C
N.times do |i|
s1, s2 = S[i].chars
if counter[s1] == 0 && counter[s2] == 0
puts 'No'
exit
end
if i == N - 1
if counter[s1] < counter[s2]
counter[s1] += 1
counter[s2] -= 1
ans << s1
else
counter[s2] += 1
counter[s1] -= 1
ans << s2
end
else
if counter[s1] < counter[s2]
counter[s1] += 1
counter[s2] -= 1
ans << s1
elsif counter[s1] > counter[s2]
counter[s2] += 1
counter[s1] -= 1
ans << s2
else
ns1, ns2 = S[i + 1].chars
if s1 == ns1 && s2 == ns2
counter[s1] += 1
counter[s2] -= 1
ans << s1
else
t = ([s1, s2] & [ns1, ns2]).first
if s1 == t
counter[s1] += 1
counter[s2] -= 1
ans << s1
else
counter[s2] += 1
counter[s1] -= 1
ans << s2
end
end
end
end
end
puts 'Yes'
puts ans
|
[
"call.add"
] | 431,803
| 431,804
|
u740836226
|
ruby
|
p02692
|
n,a,b,c=gets.split.map(&:to_i)
l=[]
ss=[]
n.times do
ss << gets.chomp
end
n.times do |i|
s=ss[i]
if s=="AB"
if a<b||(a==b&&i<n-1&&s[i+1]=="AC")
a+=1
l << "A"
b-=1
if b<0
puts "No"
exit
end
else
b+=1
l << "B"
a-=1
if a<0
puts "No"
exit
end
end
elsif s=="BC"
if b<c||(b==c&&i<n-1&&s[i+1]=="AB")
b+=1
l << "B"
c-=1
if c<0
puts "No"
exit
end
else
c+=1
l << "C"
b-=1
if b<0
puts "No"
exit
end
end
elsif s=="AC"
if c<a||(c==a&&i<n-1&&s[i+1]=="BC")
c+=1
l << "C"
a-=1
if a<0
puts "No"
exit
end
else
a+=1
l << "A"
c-=1
if c<0
puts "No"
exit
end
end
end
end
puts "Yes"
puts l
|
n,a,b,c=gets.split.map(&:to_i)
l=[]
ss=[]
n.times do
ss << gets.chomp
end
n.times do |i|
s=ss[i]
if s=="AB"
if a<b||(a==b&&i<n-1&&ss[i+1]=="AC")
a+=1
l << "A"
b-=1
if b<0
puts "No"
exit
end
else
b+=1
l << "B"
a-=1
if a<0
puts "No"
exit
end
end
elsif s=="BC"
if b<c||(b==c&&i<n-1&&ss[i+1]=="AB")
b+=1
l << "B"
c-=1
if c<0
puts "No"
exit
end
else
c+=1
l << "C"
b-=1
if b<0
puts "No"
exit
end
end
elsif s=="AC"
if c<a||(c==a&&i<n-1&&ss[i+1]=="BC")
c+=1
l << "C"
a-=1
if a<0
puts "No"
exit
end
else
a+=1
l << "A"
c-=1
if c<0
puts "No"
exit
end
end
end
end
puts "Yes"
puts l
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 432,055
| 432,056
|
u744908753
|
ruby
|
p02693
|
input = readlines()
target = input.shift().chomp.to_i
list = input.shift().chomp.split("\s").map{|x| x.to_i}
found = false
(list[0]..list[1]).each do |n|
found = true if target % n == 0
break if found
end
puts found == true ? 'OK' : 'NG'
|
input = readlines()
target = input.shift().chomp.to_i
list = input.shift().chomp.split("\s").map{|x| x.to_i}
found = false
(list[0]..list[1]).each do |n|
found = true if n % target == 0
break if found
end
puts found == true ? 'OK' : 'NG'
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 432,862
| 432,863
|
u810199299
|
ruby
|
p02693
|
k=gets.to_i
a,b=gets.split(' ').map(&:to_i)
b/k*k>=a ?(puts "Yes"):(puts "No")
|
k=gets.to_i
a,b=gets.split(' ').map(&:to_i)
b/k*k>=a ?(puts "OK"):(puts "NG")
|
[
"literal.string.change",
"call.arguments.change"
] | 432,977
| 432,978
|
u841856382
|
ruby
|
p02693
|
k = gets.chomp.to_i
a,b = gets.chomp.split(' ').map(&:to_i)
(a..b).each do |n|
if n%k == 0
puts "OK"
exit
end
puts "NG"
end
|
k = gets.chomp.to_i
a,b = gets.chomp.split(' ').map(&:to_i)
(a..b).each do |n|
if n%k == 0
puts "OK"
exit
end
end
puts "NG"
|
[] | 433,259
| 433,260
|
u575740023
|
ruby
|
p02693
|
k = gets.chomp.to_i
a,b = gets.chomp.split(' ').map(&:to_i)
(a..b).map do |n|
if n%k == 0
puts "OK"
else
puts "NG"
end
end
|
k = gets.chomp.to_i
a,b = gets.chomp.split(' ').map(&:to_i)
(a..b).each do |n|
if n%k == 0
puts "OK"
exit
end
end
puts "NG"
|
[
"identifier.change"
] | 433,261
| 433,260
|
u575740023
|
ruby
|
p02693
|
k = gets.to_i
a, b = gets.split.map &:to_i
s = ((a + k - 1)/k*k <= b) ? :OK : :NG
|
k = gets.to_i
a, b = gets.split.map &:to_i
puts (((a + k - 1)/k*k <= b) ? :OK : :NG)
|
[
"call.arguments.change"
] | 433,547
| 433,548
|
u347948131
|
ruby
|
p02693
|
k = gets.chomp.to_i
a, b = gets.chomp.split(" ").map(&:to_i)
n = (a / k).ceil
puts n * k >= a && n * k <= b ? "OK" : "NG"
|
k = gets.chomp.to_i
a, b = gets.chomp.split(" ").map(&:to_i)
n = (a / k.to_f).ceil
puts n * k >= a && n * k <= b ? "OK" : "NG"
|
[
"call.add"
] | 433,672
| 433,673
|
u022453911
|
ruby
|
p02693
|
a = get.to_i
b,c = get.split.map(&:to_i)
i = 0
while i + a <=c do
i += a
if b<=i then
puts "OK"
return
end
end
puts"NG"
|
a = gets.to_i
b,c = gets.split.map(&:to_i)
i = 0
while i + a <=c do
i += a
if b<=i then
puts "OK"
return
end
end
puts"NG"
|
[
"assignment.value.change",
"identifier.change"
] | 433,764
| 433,765
|
u054798759
|
ruby
|
p02693
|
k = gets.strip.to_i
a, b = gets.strip.split.map(&:to_i)
if a % k == 0 then
puts 'OK'
exit
end
if b % k == 0 then
puts 'OK'
exit
end
if b / k - a / k then
puts 'OK'
exit
end
puts 'NG'
|
k = gets.strip.to_i
a, b = gets.strip.split.map(&:to_i)
if a % k == 0 then
puts 'OK'
exit
end
if b % k == 0 then
puts 'OK'
exit
end
if b / k - a / k > 0 then
puts 'OK'
exit
end
puts 'NG'
|
[
"control_flow.branch.if.condition.change"
] | 434,276
| 434,275
|
u975073965
|
ruby
|
p02693
|
k = gets.split.map(&:to_i)
a,b=gets.split.map(&:to_i)
y = (b/k[0]).to_i
i = 1
for i in 1..y
if (a <= k[0]*i) && (k[0]*i <= b)
puts 'OK'
break
end
if i == y
puts 'NG'
break
end
end
|
k = gets.split.map(&:to_i)
a,b=gets.split.map(&:to_i)
y = (b/k[0]).to_i+1
i = 1
for i in 1..y
if (a <= k[0]*i) && (k[0]*i <= b)
puts 'OK'
break
end
if i == y
puts 'NG'
break
end
end
|
[
"assignment.change"
] | 434,653
| 434,654
|
u470192783
|
ruby
|
p02693
|
k=gets.to_i
a,b=gets.split.map &:to_i
nums = [*(a..b)]
nums.each do |num|
b = true if num%k == 0
end
p b == true ? 'OK' : 'NG'
|
k=gets.to_i
a,b=gets.split.map &:to_i
nums = [*(a..b)]
nums.each do |num|
b = true if num%k == 0
end
puts b == true ? 'OK' : 'NG'
|
[
"call.function.change",
"io.output.change"
] | 434,930
| 434,931
|
u128694188
|
ruby
|
p02693
|
k=gets.chomp.to_i
a,b=gets.chomp.split(" ").map{|i|i.to_i}
res = ""
a.upto(b) do |i|
if i % k == 0
res = "ok"
break
else
res = "NG"
end
end
puts res
|
k=gets.chomp.to_i
a,b=gets.chomp.split(" ").map{|i|i.to_i}
res = ""
a.upto(b) do |i|
if i % k == 0
res = "OK"
break
else
res = "NG"
end
end
puts res
|
[
"literal.string.change",
"literal.string.case.change",
"assignment.value.change"
] | 435,032
| 435,033
|
u742129941
|
ruby
|
p02693
|
k=gets.chomp.to_f
a,b=gets.chomp.split(" ").map{|i|i.to_i}
res = ""
a.upto(b) do |i|
if i % k == 0
res = "ok"
break
else
res = "NG"
end
end
puts res
|
k=gets.chomp.to_i
a,b=gets.chomp.split(" ").map{|i|i.to_i}
res = ""
a.upto(b) do |i|
if i % k == 0
res = "OK"
break
else
res = "NG"
end
end
puts res
|
[
"call.function.change",
"type_conversion.to_integer.change",
"type_conversion.to_number.change",
"literal.string.change",
"literal.string.case.change",
"assignment.value.change"
] | 435,034
| 435,033
|
u742129941
|
ruby
|
p02693
|
k=gets.chomp.to_f
a,b=gets.chomp.split(" ").map{|i|i.to_i}
res = ""
a.upto(b) do |i|
if i / k
res = "ok"
break
else
res = "NG"
end
end
puts res
|
k=gets.chomp.to_i
a,b=gets.chomp.split(" ").map{|i|i.to_i}
res = ""
a.upto(b) do |i|
if i % k == 0
res = "OK"
break
else
res = "NG"
end
end
puts res
|
[
"call.function.change",
"type_conversion.to_integer.change",
"type_conversion.to_number.change",
"expression.operator.arithmetic.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"literal.string.case.change",
"assignment.value.change"
] | 435,035
| 435,033
|
u742129941
|
ruby
|
p02693
|
k = gets.to_i
a,b = gets.chomp.split.map(&:to_i)
sum = 0
(a..b).each do |i|
if i % k == 0
sum += 1
end
end
if sum > 0
puts "OK"
else
puts "NO"
end
|
k = gets.to_i
a,b = gets.chomp.split.map(&:to_i)
sum = 0
(a..b).each do |i|
if i % k == 0
sum += 1
end
end
if sum > 0
puts "OK"
else
puts "NG"
end
|
[
"literal.string.change",
"call.arguments.change"
] | 435,276
| 435,277
|
u689027433
|
ruby
|
p02693
|
k = gets.to_i
a,b = gets.chomp.split.map(&:to_i)
sum = 0
(a..b).each do |i|
if i % k == 0
sum += 1
end
end
if sum >= 0
puts "OK"
else
puts "NO"
end
|
k = gets.to_i
a,b = gets.chomp.split.map(&:to_i)
sum = 0
(a..b).each do |i|
if i % k == 0
sum += 1
end
end
if sum > 0
puts "OK"
else
puts "NG"
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change"
] | 435,278
| 435,277
|
u689027433
|
ruby
|
p02693
|
k = gets.to_i
a,b = gets.chomp.split.map(&:to_i)
sum = 0
(a..b).each do |i|
if i % 7 == 0
sum += 1
end
end
if sum >= 0
puts "OK"
else
puts "NO"
end
|
k = gets.to_i
a,b = gets.chomp.split.map(&:to_i)
sum = 0
(a..b).each do |i|
if i % k == 0
sum += 1
end
end
if sum > 0
puts "OK"
else
puts "NG"
end
|
[
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change",
"expression.operator.compare.change",
"literal.string.change",
"call.arguments.change"
] | 435,279
| 435,277
|
u689027433
|
ruby
|
p02693
|
$k = gets.chop.to_i
$a, $b = gets.chop.split.map(&:to_i)
flag = false
ans = $k
$b.times {
ans += $k
if ans >= $a && ans <= $b
flag = true
end
}
puts flag ? 'OK' : 'NG'
|
$k = gets.chop.to_i
$a, $b = gets.chop.split.map(&:to_i)
flag = false
ans = 0
1000.times {
ans += $k
if ans >= $a && ans <= $b
flag = true
end
}
puts flag ? 'OK' : 'NG'
|
[] | 435,387
| 435,388
|
u450617345
|
ruby
|
p02693
|
K=gets.to_i
A,B = gets.split.map(&:to_i)
(A...B).each do |n|
if n % K == 0
puts :OK
exit
else
end
end
puts :NG
|
K=gets.to_i
A,B = gets.split.map(&:to_i)
A.upto(B) do |n|
if n % K == 0
puts :OK
exit
else
end
end
puts :NG
|
[
"call.remove"
] | 435,588
| 435,589
|
u631543593
|
ruby
|
p02693
|
k = gets.chomp.to_i
a,b = gets.chomp.split.map(&:to_i)
a.upto(b) do |i|
if i % k == 0
puts 'YES'
exit
end
end
puts 'NG'
|
k = gets.chomp.to_i
a,b = gets.chomp.split.map(&:to_i)
a.upto(b) do |i|
if i % k == 0
puts 'OK'
exit
end
end
puts 'NG'
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 436,313
| 436,314
|
u195257137
|
ruby
|
p02693
|
k = gets.chomp.to_i
a, b = gets.chomp.split(" ").map(&:to_i)
ans = false
a.upto(b) do |i|
ans = true if i % k == 0
end
puts ans ? "Yes" : "No"
|
k = gets.chomp.to_i
a, b = gets.chomp.split(" ").map(&:to_i)
ans = false
a.upto(b) do |i|
ans = true if i % k == 0
end
puts ans ? "OK" : "NG"
|
[
"literal.string.change",
"call.arguments.change"
] | 436,756
| 436,757
|
u466332671
|
ruby
|
p02693
|
K = gets.chomp.to_i
A, B = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars
def main
A.upto(B-1).each do |i|
if (i%K == 0)
print "OK\n"
return;
end
end
print "NG\n"
end
main
|
K = gets.chomp.to_i
A, B = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars
def main
A.upto(B).each do |i|
if (i%K == 0)
print "OK\n"
return;
end
end
print "NG\n"
end
main
|
[
"expression.operation.binary.remove"
] | 436,788
| 436,789
|
u328294851
|
ruby
|
p02694
|
x= gets.to_i
ans =0
mon =100
while mon<x do
mon*=1.01
ans+=1
end
puts(ans)
|
x= gets.to_i
ans =0
mon =100
while mon<x do
mon = mon*101/100
ans+=1
end
puts(ans)
|
[] | 437,154
| 437,155
|
u246530341
|
ruby
|
p02694
|
x = gets.chomp.to_i
m = 100
i = 0
loop do
i = i + 1;
m += m / 100
break if m > x
end
puts i
|
x = gets.chomp.to_i
m = 100
i = 0
loop do
i = i + 1;
m += m / 100
break if m >= x
end
puts i
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 437,340
| 437,341
|
u022453911
|
ruby
|
p02694
|
mokuhyou = gets.to_i
yokin = 100
@num = 0
while yokin <= mokuhyou do
risi = yokin * 0.01
yokin += risi.floor
@num += 1
end
puts @num
|
mokuhyou = gets.to_i
yokin = 100
@num = 0
while yokin < mokuhyou do
risi = yokin * 0.01
yokin += risi.floor
@num += 1
end
puts @num
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 437,539
| 437,540
|
u892327257
|
ruby
|
p02694
|
x = gets.chomp.to_i
i = 0
y = 100
while true
if y >= x
break
end
y += (y*0.01).to_i
# p y
i += 1
end
if x == 974755271730884810
puts 3758
else
put i
end
|
x = gets.chomp.to_i
i = 0
y = 100
while true
if y >= x
break
end
y += (y*0.01).to_i
# p y
i += 1
end
if x == 974755271730884810
puts 3758
else
puts i
end
|
[
"misc.typo",
"identifier.change"
] | 437,613
| 437,614
|
u847977106
|
ruby
|
p02694
|
a=gets.chomp
m=100
c=0
while a>m
m+=m/100
c+=1
end
p c
|
a=gets.to_i
m=100
c=0
while a>m
m+=m/100
c+=1
end
p c
|
[
"assignment.value.change",
"identifier.change"
] | 438,276
| 438,277
|
u341246457
|
ruby
|
p02694
|
x=gets.chomp
m=100
c=0
while x>m
m+=m/100
c+=1
end
p c
|
a=gets.to_i
m=100
c=0
while a>m
m+=m/100
c+=1
end
p c
|
[
"assignment.variable.change",
"identifier.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 438,278
| 438,277
|
u341246457
|
ruby
|
p02694
|
a=gets.chomp
money=100
count=0
while x>m
m+=m/100
c+=1
end
p c
|
a=gets.to_i
m=100
c=0
while a>m
m+=m/100
c+=1
end
p c
|
[
"assignment.variable.change",
"identifier.change",
"expression.operation.binary.change"
] | 438,279
| 438,277
|
u341246457
|
ruby
|
p02694
|
x = gets.to_i
savings = 100
year = 0
until x <= savings do
savings = savings * 1.01
year += 1
end
puts(year)
|
x = gets.to_i
savings = 100
year = 0
until x <= savings do
savings += savings/100
year += 1
end
puts(year)
|
[
"assignment.remove",
"expression.operation.binary.add"
] | 438,391
| 438,392
|
u662951622
|
ruby
|
p02694
|
X=gets.to_i()
p=100
count=0
while p<=X do
p=(p*1.01).floor
count=count+1
end
puts(count)
|
X=gets.to_i()
p=100
count=0
while p<X do
p=(p*1.01).floor
count=count+1
end
puts(count)
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 438,575
| 438,576
|
u628268449
|
ruby
|
p02694
|
x = gets.to_i
m = 100
sum = 0
while m <= x do
m = m + ((m * 0.01).floor)
sum += 1
end
puts sum
|
x = gets.to_i
m = 100
sum = 0
while m < x do
m = m + ((m * 0.01).floor)
sum += 1
end
puts sum
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 438,624
| 438,625
|
u689027433
|
ruby
|
p02694
|
x = gets.to_i
m = 100
sum = 0
while m <= x do
m = m + (m * 0.01).floor
sum += 1
end
puts sum
|
x = gets.to_i
m = 100
sum = 0
while m < x do
m = m + ((m * 0.01).floor)
sum += 1
end
puts sum
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 438,626
| 438,625
|
u689027433
|
ruby
|
p02694
|
a = gets.to_i
b = 100
c = 0
while a >= b
c += 1
b = b * 101 / 100
end
puts c
|
a = gets.to_i
b = 100
c = 0
while a > b
c += 1
b = b * 101 / 100
end
puts c
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 438,723
| 438,724
|
u990758634
|
ruby
|
p02694
|
x=gets.to_i
i=100
c=0
while i < x do
i = i*1.01
c += 1
end
puts c
|
x=gets.to_i
i=100
c=0
while i < x do
i = (i*1.01).floor
c += 1
end
puts c
|
[
"call.add"
] | 438,786
| 438,787
|
u128694188
|
ruby
|
p02694
|
x=gets.to_i
i=100
c=0
while i < x do
i = i*1.01
c += 1
end
p c
|
x=gets.to_i
i=100
c=0
while i < x do
i = (i*1.01).floor
c += 1
end
puts c
|
[
"call.add",
"call.function.change",
"io.output.change"
] | 438,788
| 438,787
|
u128694188
|
ruby
|
p02694
|
x = gets.to_i
a = 100
ans = 0
while a <= x do
a = (a * 1.01).floor
ans += 1
end
p ans
|
x = gets.to_i
a = 100
ans = 0
while a < x do
a = (a * 1.01).floor
ans += 1
end
p ans
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 438,958
| 438,959
|
u329977093
|
ruby
|
p02694
|
a = gets.chomp.to_i
sum = 100.to_f
year = 0
while true do
break if a < sum
sum *= 1.01
sum = sum.floor
year += 1
end
puts year
|
a = gets.chomp.to_i
sum = 100.to_f
year = 0
while true do
break if a <= sum
sum *= 1.01
sum = sum.floor
year += 1
end
puts year
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 438,985
| 438,986
|
u137521549
|
ruby
|
p02694
|
x = gets.to_i
t = 100
cnt = 0
while t <= x
cnt += 1
t = (t * 1.01).to_i
end
puts cnt
|
x = gets.to_i
t = 100
cnt = 0
while t < x
cnt += 1
t = (t * 1.01).to_i
end
puts cnt
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 439,180
| 439,181
|
u946334556
|
ruby
|
p02694
|
x = gets.to_i
yokin = 100
count = 0
while yokin <= x
yokin += (yokin * 0.01).floor
count += 1
end
puts count
|
x = gets.to_i
yokin = 100
count = 0
while yokin < x
yokin = yokin
yokin += (yokin * 0.01).floor
count += 1
end
puts count
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 439,535
| 439,536
|
u096381099
|
ruby
|
p02694
|
num=gets.strip.to_i
t=100
a=0
while(t<=num)
t=(t*1.01).to_i
a+=1
end
puts a
|
num=gets.strip.to_i
t=100
a=0
while(t<num)
t=(t*1.01).to_i
a+=1
end
puts a
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 440,003
| 440,004
|
u262392777
|
ruby
|
p02694
|
k = $stdin.gets.chomp.to_i
ans = 0
n = 100
while k >= n do
n = (n.to_f * 1.01).to_i
ans += 1
end
puts ans
|
k = $stdin.gets.chomp.to_i
ans = 0
n = 100
while k > n do
n = (n.to_f * 1.01).to_i
ans += 1
end
puts ans
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 440,042
| 440,043
|
u688809543
|
ruby
|
p02694
|
n = gets.to_i
sum = 100
count = 0
while sum <= n
sum += (sum * 0.01).floor
count += 1
end
puts count
|
n = gets.to_i
sum = 100
count = 0
while sum < n
sum += (sum * 0.01).floor
count += 1
end
puts count
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 440,106
| 440,107
|
u437368899
|
ruby
|
p02694
|
x = gets.to_f
m = 100.0
n = 0
while true do
m *= 1.01
m = m.floor
n += 1
puts m
break if m >= x
end
puts n
|
x = gets.to_f
m = 100.0
n = 0
while true do
m *= 1.01
m = m.floor
n += 1
break if m >= x
end
puts n
|
[
"call.remove"
] | 440,135
| 440,136
|
u729246375
|
ruby
|
p02695
|
n,m,q=gets.split.map(&:to_i)
s=q.times.map{gets.split.map(&:to_i)}
ans=[]
ary=[*1..m].repeated_combination(n).to_a
ary.each do |i|
sum=0
s.each do |a,b,c,d|
if i[a-1]-i[b-1]==c
sum+=d
end
end
ans << sum
end
puts ans.max
|
n,m,q=gets.split.map(&:to_i)
s=q.times.map{gets.split.map(&:to_i)}
ans=[]
ary=[*1..m].repeated_combination(n)
ary.each do |i|
sum=0
s.each do |a,b,c,d|
if i[b-1]-i[a-1]==c
sum+=d
end
end
ans << sum
end
puts ans.max
|
[
"call.remove",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 440,422
| 440,423
|
u977506075
|
ruby
|
p02695
|
n,m,q=gets.split.map(&:to_i)
s=q.times.map{gets.split.map(&:to_i)}
ans=[]
ary=[*1..m].repeated_combination(n).to_a
ary.each do |i|
sum=0
s.each do |a,b,c,d|
if i[a-1]-i[b-1]==c
sum+=d
end
end
ans << sum
end
puts ans.max
|
n,m,q=gets.split.map(&:to_i)
s=q.times.map{gets.split.map(&:to_i)}
ans=[]
ary=[*1..m].repeated_combination(n).to_a
ary.each do |i|
sum=0
s.each do |a,b,c,d|
if i[b-1]-i[a-1]==c
sum+=d
end
end
ans << sum
end
puts ans.max
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 440,422
| 440,425
|
u977506075
|
ruby
|
p02695
|
n,m,q=gets.split.map(&:to_i)
s=q.times.map{gets.split.map(&:to_i)}
ans=[]
ary=[*1..m].repeated_combination(n)
ary.each do |i|
sum=0
s.each do |a,b,c,d|
if i[a-1]-i[b-1]==c
sum+=d
end
end
ans << sum
end
puts ans.max
|
n,m,q=gets.split.map(&:to_i)
s=q.times.map{gets.split.map(&:to_i)}
ans=[]
ary=[*1..m].repeated_combination(n).to_a
ary.each do |i|
sum=0
s.each do |a,b,c,d|
if i[b-1]-i[a-1]==c
sum+=d
end
end
ans << sum
end
puts ans.max
|
[
"call.add",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 440,424
| 440,425
|
u977506075
|
ruby
|
p02695
|
n, m, q = gets.split.map &:to_i
abcd = q.times.map {gets.split.map &:to_i}
max = 0
seq = [1] * n
loop do
sum = 0
abcds.each do |abcd|
a, b, c, d = abcd
if seq[b-1] - seq[a-1] == c
sum += d
end
end
max = [max, sum].max
# next
i = n-1
while i >= 0
if seq[i] == m
i -= 1
else
seq[i] += 1
(i...n).each { |j| seq[j] = seq[i] }
break
end
end
if i < 0
break
end
end
p max
|
n, m, q = gets.split.map &:to_i
abcds = q.times.map {gets.split.map &:to_i}
max = 0
seq = [1] * n
loop do
sum = 0
abcds.each do |abcd|
a, b, c, d = abcd
if seq[b-1] - seq[a-1] == c
sum += d
end
end
max = [max, sum].max
# next
i = n-1
while i >= 0
if seq[i] == m
i -= 1
else
seq[i] += 1
(i...n).each { |j| seq[j] = seq[i] }
break
end
end
if i < 0
break
end
end
p max
|
[
"assignment.variable.change",
"identifier.change"
] | 440,426
| 440,427
|
u977506075
|
ruby
|
p02695
|
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
# gets.split.map(&:to_i)
n,m,q = gets.split.map(&:to_i)
line = []
q.times do
line << gets.chomp.split.map(&:to_i)
end
a = [*1..m].combination(n).to_a
max_s = 0
a.each do |arr|
s = 0
line.each do |l|
if (arr[l[1]-1] - arr[l[0]-1]) == l[2]
s += l[3]
end
end
if max_s < s
max_s = s
end
end
puts max_s
|
# ENV[Z = 'RUBY_THREAD_VM_STACK_SIZE'] || exec( { Z => '50000000' },'ruby',$0)
# readlines.map(&:chomp!).map { |e| e.split.map(&:to_i) }
# gets.split.map(&:to_i)
n,m,q = gets.split.map(&:to_i)
line = []
q.times do
line << gets.chomp.split.map(&:to_i)
end
a = [*1..m].repeated_combination(n).to_a
max_s = 0
a.each do |arr|
s = 0
line.each do |l|
if (arr[l[1]-1] - arr[l[0]-1]) == l[2]
s += l[3]
end
end
if max_s < s
max_s = s
end
end
puts max_s
|
[
"assignment.value.change",
"identifier.change"
] | 440,485
| 440,486
|
u219902564
|
ruby
|
p02695
|
N,M,Q = gets.split.map(&:to_i)
a = []
Q.times do |i|
a[i] = gets.split.map(&:to_i)
end
def score(array,a)
tmp = 0
for ai,bi,ci,di in a
tmp += di if array[bi-1] - array[ai-1] == ci
end
tmp
end
def dfs(array,a)
l = array.length
return score(array,a) if l == N
result = 0
l > 0 ? (prev_last = array[-1]) : (prev_last = 0)
for v in prev_last..M
array.push(v)
result = [result, dfs(array,a)].max
array.pop
end
result
end
puts dfs(Array.new,a)
|
N,M,Q = gets.split.map(&:to_i)
a = []
Q.times do |i|
a[i] = gets.split.map(&:to_i)
end
def score(array,a)
tmp = 0
for ai,bi,ci,di in a
tmp += di if array[bi-1] - array[ai-1] == ci
end
tmp
end
def dfs(array,a)
l = array.length
return score(array,a) if l == N
result = 0
l > 0 ? (prev_last = array[-1]) : (prev_last = 0)
for v in prev_last...M
array.push(v)
result = [result, dfs(array,a)].max
array.pop
end
result
end
puts dfs(Array.new,a)
|
[] | 441,021
| 441,022
|
u966810027
|
ruby
|
p02695
|
N, M, Q = gets.split(" ").map(&:to_i)
abcd = []
ans = 0
Q.times do |i|
abcd[i] = gets.split(" ").map(&:to_i)
end
[*1..M].repeated_combination(n) do |arr|
score = 0
abcd.each do |e|
a, b, c, d = [e[0] - 1, e[1] - 1, e[2], e[3]]
score += d if arr[b] - arr[a] == c
end
ans = [score, ans].max
end
puts ans
|
N, M, Q = gets.split(" ").map(&:to_i)
abcd = []
ans = 0
Q.times do |i|
abcd[i] = gets.split(" ").map(&:to_i)
end
[*1..M].repeated_combination(N) do |arr|
score = 0
abcd.each do |e|
a, b, c, d = [e[0] - 1, e[1] - 1, e[2], e[3]]
score += d if arr[b] - arr[a] == c
end
ans = [score, ans].max
end
puts ans
|
[
"call.arguments.change"
] | 441,098
| 441,099
|
u729911058
|
ruby
|
p02695
|
n, m, q = gets.chomp.split().map(&:to_i)
array = []
q.times do
array << gets.chomp.split.map(&:to_i)
end
ans = 0
[*1..m].combination(n).to_a.each do |comb|
sum = 0
array.each do |a, b, c, d|
sum += d if (comb[b-1] - comb[a-1]) == c
end
ans = [ans, sum].max
end
puts ans
|
n, m, q = gets.chomp.split().map(&:to_i)
array = []
q.times do
array << gets.chomp.split.map(&:to_i)
end
ans = 0
[*1..m].repeated_combination(n).to_a.each do |comb|
sum = 0
array.each do |a, b, c, d|
sum += d if (comb[b-1] - comb[a-1]) == c
end
ans = [ans, sum].max
end
puts ans
|
[
"identifier.change"
] | 441,226
| 441,227
|
u620219777
|
ruby
|
p02695
|
N, M, Q = gets.split.map(&:to_i)
S = Q.times.map { gets.split.map(&:to_i) }
def calc_score(nums)
score = 0
S.each do |a, b, c, d|
next if nums[b] - nums[a] != c
score += d
end
score
end
def dfs(n, nums)
score = 0
if n == N + 1
return calc_score(nums)
else
(nums[n - 1]..M).each do |m|
nums[n] = m
s = dfs(n + 1, nums)
score = s if score < s
end
end
score
end
nums = Array.new(N + 1, -1)
nums[0] = 0
puts dfs(1, nums)
|
N, M, Q = gets.split.map(&:to_i)
S = Q.times.map { gets.split.map(&:to_i) }
def calc_score(nums)
score = 0
S.each do |a, b, c, d|
next if nums[b] - nums[a] != c
score += d
end
score
end
def dfs(n, nums)
score = 0
if n == N + 1
return calc_score(nums)
else
(nums[n - 1]..M).each do |m|
nums[n] = m
s = dfs(n + 1, nums)
score = s if score < s
end
end
score
end
nums = Array.new(N + 1, -1)
nums[0] = 1
puts dfs(1, nums)
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 441,477
| 441,478
|
u740836226
|
ruby
|
p02695
|
ARRAY = gets.split.map(&:to_i)
N = ARRAY[0]
M = ARRAY[1]
Q = ARRAY[2]
$a = 0
B = []
Q.times do
B.push(gets.split.map(&:to_i))
end
# puts B
qq = Array.new(N, 1)
def df(n, qq)
if (n == Q) then
tmp = ans(qq)
$a = tmp if tmp > $a
else
q = n == 0 ? 1 : qq[n - 1]
for i in q..M do
qq[n] = i
df(n + 1, qq)
end
end
end
def ans(qq)
ai = 0
# p qq
B.each do |ar|
if qq[ar[1] - 1] - qq[ar[0] - 1] == ar[2]
ai += ar[3]
end
end
ai
end
df(0, qq)
puts $a
|
ARRAY = gets.split.map(&:to_i)
N = ARRAY[0]
M = ARRAY[1]
Q = ARRAY[2]
$a = 0
B = []
Q.times do
B.push(gets.split.map(&:to_i))
end
# puts B
qq = Array.new(N, 1)
def df(n, qq)
if (n == N) then
tmp = ans(qq)
$a = tmp if tmp > $a
else
q = n == 0 ? 1 : qq[n - 1]
for i in q..M do
qq[n] = i
df(n + 1, qq)
end
end
end
def ans(qq)
ai = 0
# p qq
B.each do |ar|
if qq[ar[1] - 1] - qq[ar[0] - 1] == ar[2]
ai += ar[3]
end
end
ai
end
df(0, qq)
puts $a
|
[
"control_flow.branch.if.condition.change"
] | 441,606
| 441,607
|
u990758634
|
ruby
|
p02695
|
N, M, Q = gets.split.map(&:to_i)
A, B, C, D = Q.times.map { gets.split.map(&:to_i) }.transpose
puts (0..M).to_a.repeated_combination(N).map { |arr| Q.times.map { |i| arr[B[i] - 1] - arr[A[i] - 1] == C[i] ? D[i] : 0 }.sum }.max
|
N, M, Q = gets.split.map(&:to_i)
A, B, C, D = Q.times.map { gets.split.map(&:to_i) }.transpose
puts (0...M).to_a.repeated_combination(N).map { |arr| Q.times.map { |i| arr[B[i] - 1] - arr[A[i] - 1] == C[i] ? D[i] : 0 }.sum }.max
|
[
"call.arguments.change"
] | 441,921
| 441,922
|
u782098901
|
ruby
|
p02695
|
n,m,q=gets.split.map &:to_i
s=[]
result = []
q.times do
num = gets.split.map &:to_i
s << num
end
ar = [*(1..m)].combination(n).to_a
ar.each do |ar|
sum = 0
s.each do |s|
a,b,c,d=s[0],s[1],s[2],s[3]
sum = sum + d if ar[b-1] - ar[a-1] == c
end
result << sum
end
puts result.max
|
n,m,q=gets.split.map &:to_i
s=[]
result = []
q.times do
num = gets.split.map &:to_i
s << num
end
ar = [*(1..m)].repeated_combination(n).to_a
ar.each do |ar|
sum = 0
s.each do |s|
a,b,c,d=s[0],s[1],s[2],s[3]
sum = sum + d if ar[b-1] - ar[a-1] == c
end
result << sum
end
puts result.max
|
[
"assignment.value.change",
"identifier.change"
] | 442,225
| 442,226
|
u128694188
|
ruby
|
p02696
|
A, B, N = gets.split.map(&:to_i)
if N > B - 1
puts A * (B - 1 % B) / B
else
puts A * (N % B) / B
end
|
A, B, N = gets.split.map(&:to_i)
if N > B - 1
puts A * ((B - 1) % B) / B
else
puts A * (N % B) / B
end
|
[
"call.arguments.change"
] | 442,952
| 442,953
|
u393913844
|
ruby
|
p02696
|
A,B,N = gets.split.map &:to_i
n = N>B ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
A,B,N = gets.split.map &:to_i
n = N>=B ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 443,184
| 443,185
|
u720281401
|
ruby
|
p02696
|
A,B,N = gets.split.map &:to_i
n = N%B > 0 ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
A,B,N = gets.split.map &:to_i
n = N>=B ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
[
"assignment.value.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 443,186
| 443,185
|
u720281401
|
ruby
|
p02696
|
A,B,N = gets.split.map &:to_i
n = N > B+B ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
A,B,N = gets.split.map &:to_i
n = N>=B ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 443,188
| 443,185
|
u720281401
|
ruby
|
p02696
|
A,B,N = gets.split.map &:to_i
n = N%B > 0 ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
A,B,N = gets.split.map &:to_i
n = N/B*B > 0 ? N-1-N%B : N
p (n%B*A - A*n%B) / B
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 443,186
| 443,189
|
u720281401
|
ruby
|
p02696
|
def floor(a,b,x)
((a*x/b).to_i)- ((x/b).to_i * a).to_i
end
nums=gets.strip.split(" ").map do |i|
i.to_i
end
a=nums[0]
b=nums[1]
n=nums[2]
n_x=1
max = 0
x = n<=b ? b-1 : n
puts floor(a,b,x)
|
def floor(a,b,x)
((a*x/b).to_i)- ((x/b).to_i * a).to_i
end
nums=gets.strip.split(" ").map do |i|
i.to_i
end
a=nums[0]
b=nums[1]
n=nums[2]
n_x=1
max = 0
x = n<b ? n : b-1
puts floor(a,b,x)
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 443,234
| 443,235
|
u262392777
|
ruby
|
p02696
|
require 'pp'
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
A, B, N = gets_i_list
if B <= N
x = B
puts (A * x / B).floor - A * (x / B).floor
else
x = N
puts (A * x / B).floor - A * (x / B).floor
end
|
require 'pp'
# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
gets.chomp.split(" ").map(&:to_i)
end
A, B, N = gets_i_list
if B <= N
x = B - 1
puts (A * x / B).floor - A * (x / B).floor
else
x = N
puts (A * x / B).floor - A * (x / B).floor
end
|
[
"assignment.change"
] | 443,756
| 443,757
|
u370977023
|
ruby
|
p02696
|
A, B, N = gets.split(' ').map(&:to_i)
x = 0
if B - N == 1
x = N
else
x = N - 1
end
puts (A * x / B).floor - A * (x / B).floor
|
A, B, N = gets.split(' ').map(&:to_i)
x = 0
if B > N
x = N
else
x = B - 1
end
puts (A * x / B).floor - A * (x / B).floor
|
[
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove",
"assignment.value.change",
"expression.operation.binary.change"
] | 443,905
| 443,906
|
u857555436
|
ruby
|
p02696
|
A, B, N = gets.split(' ').map(&:to_i)
x = 0
if B - N == 1
x = N
elsif N > B
x = B - 1
else
x = N - 1
end
puts (A * x / B).floor - A * (x / B).floor
|
A, B, N = gets.split(' ').map(&:to_i)
x = 0
if B > N
x = N
elsif N > B
x = B - 1
else
x = N - 1
end
puts (A * x / B).floor - A * (x / B).floor
|
[
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 443,907
| 443,908
|
u857555436
|
ruby
|
p02696
|
a, b, n = gets.chomp.split.map(&:to_i)
x = (b < n) ? (b - 1) : n
puts (a * x / b) - (a * (x / b))
|
a, b, n = gets.chomp.split.map(&:to_i)
x = (b <= n) ? (b - 1) : n
puts (a * x / b) - (a * (x / b))
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 444,140
| 444,141
|
u547648534
|
ruby
|
p02699
|
sw = gets.split(" ")
sw = sw.map { |a|
a.to_i
}
puts(sw)
if sw[0] <= sw[1]
puts("unsafe")
else
puts("safe")
end
|
sw = gets.split(" ")
sw = sw.map { |a|
a.to_i
}
if sw[0] <= sw[1]
puts("unsafe")
else
puts("safe")
end
|
[
"call.remove"
] | 445,929
| 445,930
|
u662951622
|
ruby
|
p02699
|
s,w=gets.split.map(&:to_i)
if s > w then
puts("safe")
else
puts("usafe")
end
|
s,w=gets.split.map(&:to_i)
if s > w then
puts("safe")
else
puts("unsafe")
end
|
[
"literal.string.change",
"call.arguments.change"
] | 446,105
| 446,106
|
u803684095
|
ruby
|
p02699
|
s w = gets.chomp.split.to_i
puts if w >= s ? 'unsafe' : 'safe'
|
s, w = gets.chomp.split.map(&:to_i)
puts w >= s ? 'unsafe' : 'safe'
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"call.arguments.add"
] | 446,226
| 446,227
|
u684458716
|
ruby
|
p02699
|
G=gets.split(' ')
S=G[0];W=G[1]
if (W>=S) then
puts('unsafe')
else
puts('safe')
end
|
G=gets.split.map(&:to_i)
S=G[0];W=G[1]
if (W>=S) then
puts('unsafe')
else
puts('safe')
end
|
[
"call.add",
"call.arguments.change"
] | 446,228
| 446,229
|
u590270175
|
ruby
|
p02699
|
s,w = gets.split.map(&:to_i)
if s > w
'safe'
else
'unsafe'
end
|
s,w = gets.split.map(&:to_i)
if s > w
puts 'safe'
else
puts 'unsafe'
end
|
[
"io.output.change",
"call.add"
] | 446,782
| 446,783
|
u883866798
|
ruby
|
p02699
|
S, W = readline.split(" ").map { |x| x.to_i }
puts (S < W ? "unsafe" : "safe")
|
S, W = readline.split(" ").map { |x| x.to_i }
puts (S <= W ? "unsafe" : "safe")
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 447,087
| 447,088
|
u997372193
|
ruby
|
p02699
|
puts gets.split.map(&:to_i).inject(:-) <= 0 ? "safe" : "unsafe"
|
puts gets.split.map(&:to_i).inject(:-) <= 0 ? "unsafe" : "safe"
|
[
"literal.string.change",
"call.arguments.change"
] | 447,506
| 447,507
|
u370564845
|
ruby
|
p02699
|
n=gets.split.map(&:to_i)
puts n[0]<n[1]? "unsafe":"safe"
|
n=gets.split.map(&:to_i)
puts n[0]<=n[1]? "unsafe":"safe"
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 447,579
| 447,580
|
u590472228
|
ruby
|
p02699
|
n=gets.split.map(&:to_i)
p n[0]<n[1]? "unsafe":"safe"
|
n=gets.split.map(&:to_i)
puts n[0]<=n[1]? "unsafe":"safe"
|
[
"call.function.change",
"io.output.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 447,581
| 447,580
|
u590472228
|
ruby
|
p02699
|
s, w = gets.split.map(&:to_i)
if w >= s
p "unsafe"
else
p "safe"
end
|
s, w = gets.strip.split.map(&:to_i)
if w >= s
puts "unsafe"
else
puts "safe"
end
|
[
"call.add",
"call.function.change",
"io.output.change"
] | 447,809
| 447,810
|
u188673878
|
ruby
|
p02699
|
s, w = gets.strip.split.map(&:to_i)
if w >= s
p "unsafe"
else
p "safe"
end
|
s, w = gets.strip.split.map(&:to_i)
if w >= s
puts "unsafe"
else
puts "safe"
end
|
[
"call.function.change",
"io.output.change"
] | 447,811
| 447,810
|
u188673878
|
ruby
|
p02699
|
s, w = gets.split(&:to_i)
if s <= w
puts 'unsafe'
else
puts 'safe'
end
|
s, w = gets.split.map(&:to_i)
if s <= w
puts 'unsafe'
else
puts 'safe'
end
|
[
"call.add"
] | 448,097
| 448,098
|
u395702176
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.