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 |
|---|---|---|---|---|---|---|---|
p03109
|
S=gets
if S <= "2019/04/30"
puts "Heisei"
else
puts "TBD"
end
|
S=gets.chomp
if S <= "2019/04/30"
puts "Heisei"
else
puts "TBD"
end
|
[
"call.add"
] | 921,915
| 921,916
|
u993494045
|
ruby
|
p03109
|
S=gets
if S <= "2019/04/30"
puts "Heisei"
elsif S > "2019/04/30"
puts "TBD"
end
|
S=gets.chomp
if S <= "2019/04/30"
puts "Heisei"
elsif S > "2019/04/30"
puts "TBD"
end
|
[
"call.add"
] | 921,917
| 921,918
|
u993494045
|
ruby
|
p03109
|
puts gets.chomp>'2019/04/30' ? :Heisei : :TBD
|
puts gets.chomp>'2019/04/30' ? :TBD : :Heisei
|
[] | 921,946
| 921,947
|
u161323909
|
ruby
|
p03107
|
s=gets.chomp.split("").map(&:to_i).sort
n=s.size
c0=0
s.each do |si|
if si==0
c0+=1
else
break
end
end
c1=n-c0
if c0==c1
puts 0
else
puts [c0,c1].min*2
end
|
s=gets.chomp.split("").map(&:to_i).sort
n=s.size
c0=0
s.each do |si|
if si==0
c0+=1
else
break
end
end
c1=n-c0
if c0==c1
puts n
else
puts [c0,c1].min*2
end
|
[
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change"
] | 921,956
| 921,957
|
u602591412
|
ruby
|
p03107
|
s=gets;p [s.count(?0),s.count(?1)].min
|
s=gets;p [s.count(?0),s.count(?1)].min*2
|
[] | 921,982
| 921,983
|
u280667879
|
ruby
|
p03110
|
n = gets.chomp.to_i
ary = []
n.times do
ary << gets.split(' ')
end
sum = 0
n.times do |i|
if ary[i][1] == "JPY"
sum += ary[i][0].to_i
else
sum += ary[i][0].to_i * 380000.0
end
end
puts sum
|
n = gets.chomp.to_i
ary = []
n.times do
ary << gets.split(' ')
end
sum = 0
n.times do |i|
if ary[i][1] == "JPY"
sum += ary[i][0].to_f
else
sum += ary[i][0].to_f * 380000.0
end
end
puts sum
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 922,320
| 922,321
|
u928941036
|
ruby
|
p03109
|
y,m,_=gets.split("/").map(&:to_i)
if y<2019 then
p("Heisei")
elsif m<5 then
p("Heisei")
else
p("TBD")
end
|
y,m,_=gets.split("/").map(&:to_i)
if y<2019 then
puts("Heisei")
elsif m<5 then
puts("Heisei")
else
puts("TBD")
end
|
[
"call.function.change",
"io.output.change"
] | 922,655
| 922,654
|
u604693716
|
ruby
|
p03109
|
s = gets.chomp.gsub("/", "").to_i
if s <= 20190430
puts "Heisei"
else
puts "TDB"
end
|
s = gets.chomp.gsub("/", "").to_i
if s <= 20190430
puts "Heisei"
else
puts "TBD"
end
|
[
"literal.string.change",
"call.arguments.change"
] | 922,747
| 922,748
|
u742213796
|
ruby
|
p03109
|
d=gets.delete('/').to_i
p (20190430 >= d) ? 'Heisei' : 'TBD'
|
d=gets.delete('/').to_i
puts (20190430 >= d) ? 'Heisei' : 'TBD'
|
[
"call.function.change",
"io.output.change"
] | 922,763
| 922,764
|
u098870186
|
ruby
|
p03109
|
year = gets.split('/').join.chomp
p year
if year <= "20190430"
puts "Heisei"
else
puts "TBD"
end
|
year = gets.split('/').join.chomp
if year <= "20190430"
puts "Heisei"
else
puts "TBD"
end
|
[
"call.remove"
] | 922,802
| 922,803
|
u452808393
|
ruby
|
p03110
|
n=gets.to_i
ans=0.0
n.times{
a,b=gets.split
ans+=a.to_i*(b=="JPY"?1:380000.0)
}
p(ans)
|
n=gets.to_i
ans=0.0
n.times{
a,b=gets.split
ans+=a.to_f*(b=="JPY"?1:380000.0)
}
p(ans)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 923,221
| 923,222
|
u604693716
|
ruby
|
p03110
|
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split
end
ary.delete_at(0)
okane = ary.map{|item|
if item[1]=="BTC" then
item[0].to_f*380000
else
item[0]
end
}
p okane
print okane.map(&:to_f).inject(:+)
|
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split
end
ary.delete_at(0)
okane = ary.map{|item|
if item[1]=="BTC" then
item[0].to_f*380000
else
item[0]
end
}
print okane.map(&:to_f).inject(:+)
|
[
"call.remove"
] | 923,298
| 923,299
|
u312004378
|
ruby
|
p03110
|
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split
end
ary.delete_at(0)
okane = ary.map{|item|
if item[1]=="BTC" then
item[0].to_f*3800000
else
item[0]
end
}
print okane.map(&:to_f).inject(:+)
|
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split
end
ary.delete_at(0)
okane = ary.map{|item|
if item[1]=="BTC" then
item[0].to_f*380000
else
item[0]
end
}
print okane.map(&:to_f).inject(:+)
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change"
] | 923,300
| 923,299
|
u312004378
|
ruby
|
p03110
|
BTC_TO_YEN = 380000.0
n = gets.chomp.to_i
amounts = []
units = []
n.times do
amount, unit = gets.chomp.split
amounts << amount.to_i
units << unit
end
sum = 0
n.times do |i|
if units[i] == 'JPY'
sum += amounts[i]
else
sum += amounts[i] * BTC_TO_YEN
end
end
puts sum
|
BTC_TO_YEN = 380000.0
n = gets.chomp.to_i
amounts = []
units = []
n.times do
amount, unit = gets.chomp.split
amounts << amount.to_f
units << unit
end
sum = 0
n.times do |i|
if units[i] == 'JPY'
sum += amounts[i]
else
sum += amounts[i] * BTC_TO_YEN
end
end
puts sum
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 923,506
| 923,507
|
u413207096
|
ruby
|
p03109
|
if gets.chomp.split('/')[1].to_i < 5; 'Heisei' else 'TBD' end
|
if gets.chomp.split('/')[1].to_i < 5; print 'Heisei' else print 'TBD' end
|
[
"io.output.change",
"call.add"
] | 923,689
| 923,690
|
u155403964
|
ruby
|
p03109
|
if gets.chomp.split('/')[1].to_i < 5;p 'Heisei' else p 'TBD' end
|
if gets.chomp.split('/')[1].to_i < 5; print 'Heisei' else print 'TBD' end
|
[
"call.function.change",
"io.output.change"
] | 923,691
| 923,690
|
u155403964
|
ruby
|
p03109
|
if gets.chomp.split('/')[1].to_i < 5;p 'Heisei';else;p 'TBD';end
|
if gets.chomp.split('/')[1].to_i < 5; print 'Heisei' else print 'TBD' end
|
[
"call.function.change",
"io.output.change",
"call.remove"
] | 923,692
| 923,690
|
u155403964
|
ruby
|
p03110
|
sum = 0
gets.to_i.times{
a,b=gets.split
sum += a.to_f * b=='JPY'? 1 : 380000.0
}
puts sum
|
sum=0
gets.to_i.times do
a,b=gets.split
sum+=a.to_f*(b=='JPY'?1:380000)
end
puts sum
|
[
"call.arguments.change"
] | 923,756
| 923,757
|
u863697780
|
ruby
|
p03110
|
sum = 0
gets.to_i.times{
a,b=gets.split
sum += a.to_f * b=='JPY'? 1 : 380000.0
}
puts sum
|
sum=0
gets.to_i.times{
a,b=gets.split
sum+=a.to_f*(b=='JPY'?1:380000)
}
puts sum
|
[
"call.arguments.change"
] | 923,756
| 923,758
|
u863697780
|
ruby
|
p03111
|
N, *ABC = gets.split.map(&:to_i)
l = []
N.times do
l << gets.to_i
end
cost = 10 ** 9
[0, 1, 2, 3].repeated_permutation(N).each do |arys|
next if [0, 1, 2, 3].any? { |i| !arys.include?(i) }
temp_cost = 0
length = [0, 0, 0] # a,b,c
mp = 0
N.times do |i|
if arys[i] != 3
length[arys[i]] += l[i]
mp += 10
end
end
temp_cost = mp
3.times do |i|
temp_cost += (length[i] - ABC[i]).abs
end
cost = cost > temp_cost ? temp_cost : cost
end
p cost - 30
|
N, *ABC = gets.split.map(&:to_i)
l = []
N.times do
l << gets.to_i
end
cost = 10 ** 9
[0, 1, 2, 3].repeated_permutation(N).each do |arys|
next if [0, 1, 2].any? { |i| !arys.include?(i) }
temp_cost = 0
length = [0, 0, 0] # a,b,c
mp = 0
N.times do |i|
if arys[i] != 3
length[arys[i]] += l[i]
mp += 10
end
end
temp_cost = mp
3.times do |i|
temp_cost += (length[i] - ABC[i]).abs
end
cost = cost > temp_cost ? temp_cost : cost
end
p cost - 30
|
[] | 923,991
| 923,992
|
u987208743
|
ruby
|
p03112
|
A,B,Q = gets.chomp.split(" ").map(&:to_i)
s = A.times.map{gets.to_i}
t = B.times.map{gets.to_i}
x = Q.times.map{gets.to_i}
s.sort!
t.sort!
Q.times do |i|
x1 = (0...s.size).bsearch{|j| s[j] >= x[i]}
y1 = (0...s.size).bsearch{|j| t[j] >= x[i]}
x2 = x1 == nil ? A-1 : x1-1
y2 = y1 == nil ? B-1 : y1-1
min = 10 ** 12
if x1 != nil && y2 != -1
d = [s[x1] - x[i], x[i] - t[y2]].min * 2 + [s[x1] - x[i], x[i] - t[y2]].max
min = d if d < min
puts "test"
end
if y1 != nil && x2 != -1
d = [t[y1] - x[i], x[i] - s[x2]].min * 2 + [t[y1] - x[i], x[i] - s[x2]].max
min = d if d < min
end
if x1 != nil && y1 != nil
d = [s[x1],t[y1]].max - x[i]
min = d if d < min
end
if x2 != -1 && y2 != -1
d = x[i] - [s[x2],t[y2]].min
min = d if d < min
end
puts min
end
|
A,B,Q = gets.chomp.split(" ").map(&:to_i)
s = A.times.map{gets.to_i}
t = B.times.map{gets.to_i}
x = Q.times.map{gets.to_i}
s.sort!
t.sort!
Q.times do |i|
x1 = (0...s.size).bsearch{|j| s[j] >= x[i]}
y1 = (0...t.size).bsearch{|j| t[j] >= x[i]}
x2 = x1 == nil ? A-1 : x1-1
y2 = y1 == nil ? B-1 : y1-1
min = 10 ** 12
if x1 != nil && y2 != -1
d = [s[x1] - x[i], x[i] - t[y2]].min * 2 + [s[x1] - x[i], x[i] - t[y2]].max
min = d if d < min
end
if y1 != nil && x2 != -1
d = [t[y1] - x[i], x[i] - s[x2]].min * 2 + [t[y1] - x[i], x[i] - s[x2]].max
min = d if d < min
end
if x1 != nil && y1 != nil
d = [s[x1],t[y1]].max - x[i]
min = d if d < min
end
if x2 != -1 && y2 != -1
d = x[i] - [s[x2],t[y2]].min
min = d if d < min
end
puts min
end
|
[
"assignment.value.change",
"identifier.change",
"call.remove"
] | 924,337
| 924,338
|
u265679940
|
ruby
|
p03112
|
A,B,Q = gets.chomp.split(" ").map(&:to_i)
s = A.times.map{gets.to_i}
t = B.times.map{gets.to_i}
x = Q.times.map{gets.to_i}
s.sort!
t.sort!
Q.times do |i|
x1 = (0...s.size).bsearch{|j| s[j] >= x[i]}
y1 = (0...s.size).bsearch{|j| t[j] >= x[i]}
x2 = x1 == nil ? A-1 : x1-1
y2 = y1 == nil ? B-1 : y1-1
min = 10 ** 12
if x1 != nil && y2 != -1
d = [s[x1] - x[i], x[i] - t[y2]].min * 2 + [s[x1] - x[i], x[i] - t[y2]].max
min = d if d < min
end
if y1 != nil && x2 != -1
d = [t[y1] - x[i], x[i] - s[x2]].min * 2 + [t[y1] - x[i], x[i] - s[x2]].max
min = d if d < min
end
if x1 != nil && y1 != nil
d = [s[x1],t[y1]].max - x[i]
min = d if d < min
end
if x2 != -1 && y2 != -1
d = x[i] - [s[x2],t[y2]].min
min = d if d < min
end
puts min
end
|
A,B,Q = gets.chomp.split(" ").map(&:to_i)
s = A.times.map{gets.to_i}
t = B.times.map{gets.to_i}
x = Q.times.map{gets.to_i}
s.sort!
t.sort!
Q.times do |i|
x1 = (0...s.size).bsearch{|j| s[j] >= x[i]}
y1 = (0...t.size).bsearch{|j| t[j] >= x[i]}
x2 = x1 == nil ? A-1 : x1-1
y2 = y1 == nil ? B-1 : y1-1
min = 10 ** 12
if x1 != nil && y2 != -1
d = [s[x1] - x[i], x[i] - t[y2]].min * 2 + [s[x1] - x[i], x[i] - t[y2]].max
min = d if d < min
end
if y1 != nil && x2 != -1
d = [t[y1] - x[i], x[i] - s[x2]].min * 2 + [t[y1] - x[i], x[i] - s[x2]].max
min = d if d < min
end
if x1 != nil && y1 != nil
d = [s[x1],t[y1]].max - x[i]
min = d if d < min
end
if x2 != -1 && y2 != -1
d = x[i] - [s[x2],t[y2]].min
min = d if d < min
end
puts min
end
|
[
"assignment.value.change",
"identifier.change"
] | 924,339
| 924,338
|
u265679940
|
ruby
|
p03112
|
INF = 10 ** 14
def compute_edge(arr, q)
i = arr.bsearch_index { |x| x >= q }
return [arr.last] if i.nil?
return [q] if arr[i] == q
return [arr[0]] if i == 0
return [arr[i - 1], arr[i]]
end
def lazy_faith(s, t, q)
ans = INF
compute_edge(s, q).each do |se|
min_cost = INF
cost = (se - q).abs
compute_edge(t, se).each do |te|
min_cost = [min_cost, cost + (se - te).abs].min
end
ans = [ans, min_cost].min
end
compute_edge(t, q).each do |te|
min_cost = INF
cost = (te - q).abs
compute_edge(s, te).each do |se|
min_cost = [min_cost, cost + (se - te).abs].min
end
ans = [ans, min_cost].min
end
ans
end
A, B, Q = gets.split.map(&:to_i)
s = []
A.tiems{ s << gets.to_i }
t = []
B.tiems{ t << gets.to_i }
Q.tiems do
puts lazy_faith(s, t, gets.to_i)
end
|
INF = 10 ** 14
def compute_edge(arr, q)
i = arr.bsearch_index { |x| x >= q }
return [arr.last] if i.nil?
return [q] if arr[i] == q
return [arr[0]] if i == 0
return [arr[i - 1], arr[i]]
end
def lazy_faith(s, t, q)
ans = INF
compute_edge(s, q).each do |se|
min_cost = INF
cost = (se - q).abs
compute_edge(t, se).each do |te|
min_cost = [min_cost, cost + (se - te).abs].min
end
ans = [ans, min_cost].min
end
compute_edge(t, q).each do |te|
min_cost = INF
cost = (te - q).abs
compute_edge(s, te).each do |se|
min_cost = [min_cost, cost + (se - te).abs].min
end
ans = [ans, min_cost].min
end
ans
end
A, B, Q = gets.split.map(&:to_i)
s = []
A.times{ s << gets.to_i }
t = []
B.times{ t << gets.to_i }
Q.times do
puts lazy_faith(s, t, gets.to_i)
end
|
[
"identifier.change"
] | 924,437
| 924,438
|
u976045502
|
ruby
|
p03112
|
# debug
debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if debugFlag
# util functions
def find_posmin(arr)
m = arr.max
arr.each do |e_i|
m = e_i if e_i > 0 and m > e_i
end
return m
end
# input
a, b, q = $stdin.gets.chomp.split(" ").map(&:to_i)
shrs = []
a.times do
shrs << $stdin.gets.chomp.to_i
end
tmps = []
b.times do
tmps << $stdin.gets.chomp.to_i
end
xs = []
q.times do
xs << $stdin.gets.chomp.to_i
end
# input check
if debugFlag
p "--- INPUT (begin) ---"
p shrs
p tmps
p xs
p "--- INPUT (end) ---"
print "\n"
end
# body
if debugFlag
end
xs.each do |x_i|
sw = nil
se = nil
tw = nil
te = nil
# shrs.size.times do |j|
# if x_i <= shrs[j]
# sw = shrs[j - 1] # can be nil
# se = shrs[j]
# break
# end
# end
j = shrs.bsearch_index { |s| x_i < s }
if j
sw = shrs[j - 1] # can be nil
se = shrs[j]
end
if se == nil
sw = shrs[-1]
elsif se == shrs[0]
sw = nil
end
# tmps.size.times do |j|
# if x_i <= tmps[j]
# tw = tmps[j - 1] # can be nil
# te = tmps[j]
# break
# end
# end
j = tmps.bsearch_index { |t| x_i < t }
if j
tw = tmps[j - 1] # can be nil
te = tmps[j]
end
if te == nil
tw = tmps[-1]
elsif te == tmps[0]
tw = nil
end
if debugFlag
p x_i
print "sw:"
p sw
print "se:"
p se
print "tw:"
p tw
print "te:"
p te
end
cur = x_i
costs = []
[te, tw].each do |t|
tmp_cost = 0
next if t == nil
tmp_cost += (cur - t).abs
[se, sw].each do |s|
next if s == nil
costs << (t - s).abs + tmp_cost
end
end
if te != nil and se != nil and te >= se
costs << (cur - te).abs
end
if tw != nil and sw != nil and tw <= sw
costs << (cur - tw).abs
end
cur = x_i
[se, sw].each do |s|
tmp_cost = 0
next if s == nil
tmp_cost += (cur - s).abs
[te, tw].each do |t|
next if t == nil
costs << (s - t).abs + tmp_cost
end
end
if te != nil and se != nil and te >= se
costs << (cur - se).abs
end
if sw != nil and tw != nil and sw <= tw
costs << (cur - sw).abs
end
#p costs
#print "---"
p costs.min
end
|
# debug
debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if debugFlag
# util functions
def find_posmin(arr)
m = arr.max
arr.each do |e_i|
m = e_i if e_i > 0 and m > e_i
end
return m
end
# input
a, b, q = $stdin.gets.chomp.split(" ").map(&:to_i)
shrs = []
a.times do
shrs << $stdin.gets.chomp.to_i
end
tmps = []
b.times do
tmps << $stdin.gets.chomp.to_i
end
xs = []
q.times do
xs << $stdin.gets.chomp.to_i
end
# input check
if debugFlag
p "--- INPUT (begin) ---"
p shrs
p tmps
p xs
p "--- INPUT (end) ---"
print "\n"
end
# body
if debugFlag
end
xs.each do |x_i|
sw = nil
se = nil
tw = nil
te = nil
# shrs.size.times do |j|
# if x_i <= shrs[j]
# sw = shrs[j - 1] # can be nil
# se = shrs[j]
# break
# end
# end
j = shrs.bsearch_index { |s| x_i < s }
if j
sw = shrs[j - 1] # can be nil
se = shrs[j]
end
if se == nil
sw = shrs[-1]
elsif se == shrs[0]
sw = nil
end
# tmps.size.times do |j|
# if x_i <= tmps[j]
# tw = tmps[j - 1] # can be nil
# te = tmps[j]
# break
# end
# end
j = tmps.bsearch_index { |t| x_i < t }
if j
tw = tmps[j - 1] # can be nil
te = tmps[j]
end
if te == nil
tw = tmps[-1]
elsif te == tmps[0]
tw = nil
end
if debugFlag
p x_i
print "sw:"
p sw
print "se:"
p se
print "tw:"
p tw
print "te:"
p te
end
cur = x_i
costs = []
[te, tw].each do |t|
tmp_cost = 0
next if t == nil
tmp_cost += (cur - t).abs
[se, sw].each do |s|
next if s == nil
costs << (t - s).abs + tmp_cost
end
end
if te != nil and se != nil and te >= se
costs << (cur - te).abs
end
if tw != nil and sw != nil and tw <= sw
costs << (cur - tw).abs
end
cur = x_i
[se, sw].each do |s|
tmp_cost = 0
next if s == nil
tmp_cost += (cur - s).abs
[te, tw].each do |t|
next if t == nil
costs << (s - t).abs + tmp_cost
end
end
if te != nil and se != nil and se >= te
costs << (cur - se).abs
end
if sw != nil and tw != nil and sw <= tw
costs << (cur - sw).abs
end
#p costs
#print "---"
p costs.min
end
|
[
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 924,847
| 924,848
|
u714724786
|
ruby
|
p03112
|
# debug
debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if debugFlag
# util functions
def find_posmin(arr)
m = arr.max
arr.each do |e_i|
m = e_i if e_i > 0 and m > e_i
end
return m
end
# input
a, b, q = $stdin.gets.chomp.split(" ").map(&:to_i)
shrs = []
a.times do
shrs << $stdin.gets.chomp.to_i
end
tmps = []
b.times do
tmps << $stdin.gets.chomp.to_i
end
xs = []
q.times do
xs << $stdin.gets.chomp.to_i
end
# input check
if debugFlag
p "--- INPUT (begin) ---"
p shrs
p tmps
p xs
p "--- INPUT (end) ---"
print "\n"
end
# body
if debugFlag
end
xs.each do |x_i|
sw = nil
se = nil
tw = nil
te = nil
# shrs.size.times do |j|
# if x_i <= shrs[j]
# sw = shrs[j - 1] # can be nil
# se = shrs[j]
# break
# end
# end
j = shrs.bsearch_index { |s| x_i <= s }
if j
sw = shrs[j - 1] # can be nil
se = shrs[j]
end
if se == nil
sw = shrs[-1]
elsif se == shrs[0]
sw = nil
end
# tmps.size.times do |j|
# if x_i <= tmps[j]
# tw = tmps[j - 1] # can be nil
# te = tmps[j]
# break
# end
# end
j = tmps.bsearch_index { |t| x_i <= t }
if j
tw = tmps[j - 1] # can be nil
te = tmps[j]
end
if te == nil
tw = tmps[-1]
elsif te == tmps[0]
tw = nil
end
if debugFlag
p x_i
print "sw:"
p sw
print "se:"
p se
print "tw:"
p tw
print "te:"
p te
end
cur = x_i
costs = []
[te, tw].each do |t|
tmp_cost = 0
next if t == nil
tmp_cost += (cur - t).abs
[se, sw].each do |s|
next if s == nil
costs << (t - s).abs + tmp_cost
end
end
if te != nil and se != nil and te >= se
costs << (cur - te).abs
end
if tw != nil and sw != nil and tw <= sw
costs << (cur - tw).abs
end
cur = x_i
[se, sw].each do |s|
tmp_cost = 0
next if s == nil
tmp_cost += (cur - s).abs
[te, tw].each do |t|
next if t == nil
costs << (s - t).abs + tmp_cost
end
end
if te != nil and se != nil and te >= se
costs << (cur - se).abs
end
if sw != nil and tw != nil and sw <= tw
costs << (cur - sw).abs
end
#p costs
#print "---"
p costs.min
end
|
# debug
debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if debugFlag
# util functions
def find_posmin(arr)
m = arr.max
arr.each do |e_i|
m = e_i if e_i > 0 and m > e_i
end
return m
end
# input
a, b, q = $stdin.gets.chomp.split(" ").map(&:to_i)
shrs = []
a.times do
shrs << $stdin.gets.chomp.to_i
end
tmps = []
b.times do
tmps << $stdin.gets.chomp.to_i
end
xs = []
q.times do
xs << $stdin.gets.chomp.to_i
end
# input check
if debugFlag
p "--- INPUT (begin) ---"
p shrs
p tmps
p xs
p "--- INPUT (end) ---"
print "\n"
end
# body
if debugFlag
end
xs.each do |x_i|
sw = nil
se = nil
tw = nil
te = nil
# shrs.size.times do |j|
# if x_i <= shrs[j]
# sw = shrs[j - 1] # can be nil
# se = shrs[j]
# break
# end
# end
j = shrs.bsearch_index { |s| x_i < s }
if j
sw = shrs[j - 1] # can be nil
se = shrs[j]
end
if se == nil
sw = shrs[-1]
elsif se == shrs[0]
sw = nil
end
# tmps.size.times do |j|
# if x_i <= tmps[j]
# tw = tmps[j - 1] # can be nil
# te = tmps[j]
# break
# end
# end
j = tmps.bsearch_index { |t| x_i < t }
if j
tw = tmps[j - 1] # can be nil
te = tmps[j]
end
if te == nil
tw = tmps[-1]
elsif te == tmps[0]
tw = nil
end
if debugFlag
p x_i
print "sw:"
p sw
print "se:"
p se
print "tw:"
p tw
print "te:"
p te
end
cur = x_i
costs = []
[te, tw].each do |t|
tmp_cost = 0
next if t == nil
tmp_cost += (cur - t).abs
[se, sw].each do |s|
next if s == nil
costs << (t - s).abs + tmp_cost
end
end
if te != nil and se != nil and te >= se
costs << (cur - te).abs
end
if tw != nil and sw != nil and tw <= sw
costs << (cur - tw).abs
end
cur = x_i
[se, sw].each do |s|
tmp_cost = 0
next if s == nil
tmp_cost += (cur - s).abs
[te, tw].each do |t|
next if t == nil
costs << (s - t).abs + tmp_cost
end
end
if te != nil and se != nil and se >= te
costs << (cur - se).abs
end
if sw != nil and tw != nil and sw <= tw
costs << (cur - sw).abs
end
#p costs
#print "---"
p costs.min
end
|
[
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change",
"io.output.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 924,849
| 924,848
|
u714724786
|
ruby
|
p03112
|
a,b,q=gets.split.map(&:to_i)
s = a.times.map{gets.to_i}.sort
sr= s.reverse
t = b.times.map{gets.to_i}.sort
tr= s.reverse
q.times.each do
x = gets.to_i
s1 = s.bsearch{|y| x <= y}
s2 = sr.bsearch{|y| x >= y}
t1 = t.bsearch{|y| x <= y}
t2 = tr.bsearch{|y| x >= y}
puts ([s1, s2].select{|x|x}.map do |s|
[t1, t2].select{|x|x}.map do |t|
[[s-x, t-s], [t-x, s-t]].map{|a| a.map(&:abs).inject(&:+)}.min
end.min
end.min)
end
|
a,b,q=gets.split.map(&:to_i)
s = a.times.map{gets.to_i}.sort
sr= s.reverse
t = b.times.map{gets.to_i}.sort
tr= t.reverse
q.times.each do
x = gets.to_i
s1 = s.bsearch{|y| x <= y}
s2 = sr.bsearch{|y| x >= y}
t1 = t.bsearch{|y| x <= y}
t2 = tr.bsearch{|y| x >= y}
puts ([s1, s2].select{|x|x}.map do |s|
[t1, t2].select{|x|x}.map do |t|
[[s-x, t-s], [t-x, s-t]].map{|a| a.map(&:abs).inject(&:+)}.min
end.min
end.min)
end
|
[
"assignment.value.change",
"identifier.change"
] | 924,993
| 924,994
|
u056944756
|
ruby
|
p03112
|
A, B, Q = gets.split.map(&:to_i)
INF = 10**12
s=[-INF]
A.times do |i|
s[i+1] = gets.to_i
end
s[A+1] = INF
t=[-INF]
B.times do |i|
t[i+1] = gets.to_i
end
t[B+1] = INF
x=[]
Q.times do |i|
x[i] = gets.to_i
end
Q.times do |i|
j = s.bsearch_index{|y| x[i] <= y}
k = t.bsearch_index{|y| x[i] <= y}
ans =[
(x[i]-s[j-1]).abs + [(s[j-1]-t[k-1]).abs, (s[j-1]-t[k]).abs].min,
(x[i]-s[j]).abs + [(s[j-1]-t[k-1]).abs, (s[j-1]-t[k]).abs].min,
(x[i]-t[k-1]).abs + [(t[k-1]-s[j-1]).abs, (t[k-1]-s[j]).abs].min,
(x[i]-t[k]).abs + [(t[k]-s[j-1]).abs,(t[k]-s[j]).abs].min
].min
puts ans
end
|
A, B, Q = gets.split.map(&:to_i)
INF = 10**12
s=[-INF]
A.times do |i|
s[i+1] = gets.to_i
end
s[A+1] = INF
t=[-INF]
B.times do |i|
t[i+1] = gets.to_i
end
t[B+1] = INF
x=[]
Q.times do |i|
x[i] = gets.to_i
end
Q.times do |i|
j = s.bsearch_index{|y| x[i] < y}
k = t.bsearch_index{|y| x[i] < y}
ans =[
(x[i]-s[j-1]).abs + [(s[j-1]-t[k-1]).abs, (s[j-1]-t[k]).abs].min,
(x[i]-s[j]).abs + [(s[j]-t[k-1]).abs, (s[j]-t[k]).abs].min,
(x[i]-t[k-1]).abs + [(t[k-1]-s[j-1]).abs, (t[k-1]-s[j]).abs].min,
(x[i]-t[k]).abs + [(t[k]-s[j-1]).abs,(t[k]-s[j]).abs].min
].min
puts ans
end
|
[
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change",
"io.output.change",
"expression.operation.binary.remove"
] | 925,010
| 925,011
|
u708550576
|
ruby
|
p03112
|
A,B,Q=gets.split.map &:to_i
I=1<<60
S=[-I]+A.times.map{gets.to_i}+[I]
T=[-I]+B.times.map{gets.to_i}+[I]
Q.times{
x=gets.to_i
b=S.bsearch_index{|e|x<e}||S.size
d=T.bsearch_index{|e|x<e}||T.size
r=I
[S[b-1],S[b]].each{|s|[T[b-1],T[b]].each{|t|
r=[r,(t-s).abs+(s-x).abs,(s-t).abs+(t-x).abs].min
}}
p r
}
|
A,B,Q=gets.split.map &:to_i
I=1<<60
S=[-I]+A.times.map{gets.to_i}+[I]
T=[-I]+B.times.map{gets.to_i}+[I]
Q.times{
x=gets.to_i
b=S.bsearch_index{|e|x<e}||S.size
d=T.bsearch_index{|e|x<e}||T.size
r=I
[S[b-1],S[b]].each{|s|[T[d-1],T[d]].each{|t|
r=[r,(t-s).abs+(s-x).abs,(s-t).abs+(t-x).abs].min
}}
p r
}
|
[
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 925,072
| 925,073
|
u280667879
|
ruby
|
p03125
|
a, b = gets.chomp.split.map(&:to_i)
ans = (b / a) % a
if ans == 0
puts b + a
else
puts b - a
end
|
a, b = gets.chomp.split.map(&:to_i)
ans = (b % a)
if ans == 0
puts b + a
else
puts b - a
end
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 925,153
| 925,154
|
u552761221
|
ruby
|
p03125
|
a,b=gets.split.map(&:to_i)
p (a%b==0)?a + b:b-a
|
a,b=gets.split.map(&:to_i)
p (b%a==0)?a + b:b-a
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 925,460
| 925,461
|
u803684095
|
ruby
|
p03125
|
a, b = gets.strip.split.map(&:to_i)
if b % a = 0
puts a+b
else
puts b-a
end
|
a, b = gets.strip.split.map(&:to_i)
puts b%a == 0 ? a+b : b-a
|
[
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo",
"io.output.change",
"call.remove"
] | 925,515
| 925,516
|
u115838990
|
ruby
|
p03125
|
a,b=gets.split.map(&:to_i)
puts a%b==0 ? a+b:b-a
|
a,b=gets.split.map(&:to_i)
puts b%a==0 ? a+b : b-a
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 925,527
| 925,528
|
u926099741
|
ruby
|
p03125
|
a, b = gets.split.map(&:to_i)
if b % a == 0 then
puts = a + b
else
puts = b - a
end
|
a, b = gets.split.map(&:to_i)
if b % a == 0
puts a + b
else
puts b - a
end
|
[] | 925,559
| 925,560
|
u451270227
|
ruby
|
p03125
|
a,b = gets.split(" ").map(&:to_i)
if b % a == 0
puts a + b
else
puts b / a
end
|
a,b = gets.split(" ").map(&:to_i)
if b % a == 0
puts a + b
else
puts b - a
end
|
[
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 925,579
| 925,580
|
u944733909
|
ruby
|
p03125
|
a, b = gets.chomp(" ").map(&:to_i)
if b % a == 0
puts (a + b)
else
puts (b - a)
end
|
a, b = gets.split(" ").map(&:to_i)
if b % a == 0
puts (a + b)
else
puts (b - a)
end
|
[
"assignment.value.change",
"identifier.change"
] | 925,872
| 925,873
|
u512524057
|
ruby
|
p03125
|
a, b = gets.chomp(" ").map(&:to_i)
if b % a == 0
puts a + b
else
puts b - a
end
|
a, b = gets.split(" ").map(&:to_i)
if b % a == 0
puts (a + b)
else
puts (b - a)
end
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 925,874
| 925,873
|
u512524057
|
ruby
|
p03125
|
a, b = gets.chomp(" ").map(&:to_i)
if b % a == 0
puts (a + b)
else
puts (b - a)
end
|
a, b = gets.split(" ").map(&:to_i)
if b % a == 0
puts (a + b)
else
puts (b - a)
end
|
[
"assignment.value.change",
"identifier.change"
] | 925,872
| 925,875
|
u512524057
|
ruby
|
p03125
|
a, b = gets.chomp(" ").map(&:to_i)
if b % a == 0
puts a + b
else
puts b - a
end
|
a, b = gets.split(" ").map(&:to_i)
if b % a == 0
puts (a + b)
else
puts (b - a)
end
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 925,874
| 925,875
|
u512524057
|
ruby
|
p03125
|
a, b = gets.split.map(&:to_i)
p b % a == 0 ? a + b : a - b
|
a, b = gets.split.map(&:to_i)
p b % a == 0 ? a + b : b - a
|
[
"expression.operation.binary.remove"
] | 925,898
| 925,899
|
u091810847
|
ruby
|
p03125
|
a, b = gets.split(' ').map(&:to_i)
if b % a == 0
puts a + b
else
puts - a + b
end
|
a, b = gets.split(' ').map(&:to_i)
if b % a == 0
puts a + b
else
puts (- a + b)
end
|
[
"call.arguments.change"
] | 926,148
| 926,149
|
u562753067
|
ruby
|
p03125
|
ab = gets.chomp.split(" ")
if ab[1].to_i % ab[0].to_i == 0
puts ab[0].to_i + ab[1].to_i
else
puts ab[1].to_i + ab[0].to_i
end
|
ab = gets.chomp.split(" ")
if ab[1].to_i % ab[0].to_i == 0
puts ab[0].to_i + ab[1].to_i
else
puts ab[1].to_i - ab[0].to_i
end
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 926,192
| 926,193
|
u538351278
|
ruby
|
p03125
|
A,B=gets.split.map(&:to_i)
if B%A === 0
A + B
else
B - A
end
|
A,B=gets.split.map(&:to_i)
if B%A === 0
puts A + B
else
puts B - A
end
|
[
"io.output.change",
"call.add"
] | 926,198
| 926,199
|
u317386998
|
ruby
|
p03125
|
A,B=gets.split.map(&:to_i)
if A%B === 0
A + B
else
B - A
end
|
A,B=gets.split.map(&:to_i)
if B%A === 0
puts A + B
else
puts B - A
end
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change",
"io.output.change",
"call.add"
] | 926,200
| 926,199
|
u317386998
|
ruby
|
p03125
|
input = gets
A=input.split(" ")[0].to_i
B=input.split(" ")[1].to_i
if B%A == 0 then
print A+B
else
print A-B
end
|
input = gets
A=input.split(" ")[0].to_i
B=input.split(" ")[1].to_i
if B%A == 0 then
print A+B
else
print B-A
end
|
[
"expression.operation.binary.remove"
] | 926,274
| 926,275
|
u312004378
|
ruby
|
p03125
|
input = gets
A=input.split(" ")[0].to_i
B=input.split(" ")[1].to_i
if B%A == 0 then
print A+B
else
A-B
end
|
input = gets
A=input.split(" ")[0].to_i
B=input.split(" ")[1].to_i
if B%A == 0 then
print A+B
else
print B-A
end
|
[
"call.add",
"expression.operation.binary.remove"
] | 926,276
| 926,275
|
u312004378
|
ruby
|
p03125
|
a,b = gets.chomp.split(' ').map(&:to_i)
if b%a==0
puts a+b
else
puts a-b
end
|
a,b = gets.chomp.split(' ').map(&:to_i)
if b%a==0
puts a+b
else
puts b-a
end
|
[
"expression.operation.binary.remove"
] | 926,629
| 926,630
|
u925626028
|
ruby
|
p03125
|
a, b = gets.split.map(&:to_i)
puts b % a == 0 ? a + b : b + a
|
a, b = gets.split.map(&:to_i)
puts b % a == 0 ? a + b : b - a
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 926,754
| 926,755
|
u785521224
|
ruby
|
p03125
|
a, b = gets.chomp.split.map(&:to_i)
if b%a == 0
puts a + b
else
puts b-q
end
|
a, b = gets.chomp.split.map(&:to_i)
if b%a == 0
puts a + b
else
puts b-a
end
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 926,857
| 926,858
|
u706730549
|
ruby
|
p03125
|
a, b = gets.split.map(&:to_i)
puts b % a ? a + b : b - a
|
a, b = gets.split.map(&:to_i)
puts (b % a).zero? ? a + b : b - a
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 927,001
| 927,002
|
u756963831
|
ruby
|
p03125
|
a, b = gets.split.map(&:to_i)
puts (b % a).zero? ? a + b : a - b
|
a, b = gets.split.map(&:to_i)
puts (b % a).zero? ? a + b : b - a
|
[
"expression.operation.binary.remove"
] | 927,003
| 927,002
|
u756963831
|
ruby
|
p03126
|
N,M = gets.chomp.split.map(&:to_i)
ary = (1..m).to_a
N.times do |i|
buf = gets.chomp.split.map(&:to_i)
ary = ary & buf[1..-1]
end
puts ary.length
|
N,M = gets.chomp.split.map(&:to_i)
ary = (1..M).to_a
N.times do |i|
buf = gets.chomp.split.map(&:to_i)
ary = ary & buf[1..-1]
end
puts ary.length
|
[
"assignment.value.change"
] | 927,141
| 927,142
|
u585819925
|
ruby
|
p03126
|
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
t = a.slice(0,a[0])
(n-1).times do |i|
a = gets.split.map(&:to_i)
a = a.slice(0,a[0])
t = t & a
end
# p t
p t.size
|
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
t = a.slice(1,a[0])
(n-1).times do |i|
a = gets.split.map(&:to_i)
a = a.slice(1,a[0])
t = t & a
end
# p t
p t.size
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change"
] | 927,381
| 927,382
|
u693378622
|
ruby
|
p03126
|
n, m = gets.split.map(&:to_i)
a = Array.new(m){|i| i+1}
n.times do
i = gets.split.map(&:to_i)
i.delete_at(0)
a = a & i
end
p a
|
n, m = gets.split.map(&:to_i)
a = Array.new(m){|i| i+1}
n.times do
i = gets.split.map(&:to_i)
i.delete_at(0)
a = a & i
end
p a.size
|
[
"call.add"
] | 927,864
| 927,865
|
u262994359
|
ruby
|
p03126
|
N, M = gets.split.map(&:to_i)
ary = []
N.times do
ary += gets.split.map(&:to_i)[1..-1]
end
puts (0...M).map{|m| ary.count(m)}.count(N)
|
N, M = gets.split.map(&:to_i)
ary = []
N.times do
ary += gets.split.map(&:to_i)[1..-1]
end
puts (1..M).map{|m| ary.count(m)}.count(N)
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 928,219
| 928,220
|
u139858699
|
ruby
|
p03127
|
N = gets.to_i
A = gets.split(' ').map(&:to_i)
hp = A[0]
(N - 1).times do |i|
hp = hp.gcd(A[i])
end
puts hp
|
N = gets.to_i
A = gets.split(' ').map(&:to_i)
hp = A[0]
N.times do |i|
hp = hp.gcd(A[i])
end
puts hp
|
[] | 929,183
| 929,184
|
u548834738
|
ruby
|
p03127
|
n = gets.to_i
a = gets.split.map(&:to_i)
result = a[0]
(1..n-1).each do |i|
result.gcd(a[i])
end
puts result
|
n = gets.to_i
a = gets.split.map(&:to_i)
result = a[0]
(1..n-1).each do |i|
result = result.gcd(a[i])
end
puts result
|
[
"assignment.add"
] | 929,222
| 929,223
|
u622469330
|
ruby
|
p03128
|
n, m = gets.strip.split.map(&:to_i)
as = gets.strip.split.map(&:to_i)
matched_numbers = [2, 5, 5, 4, 5, 6, 3, 7, 6].map.with_index {|e, i| [e, i+1] }.select {|e, i| as.include?(i+1) }.sort.to_h
#p matched_numbers
dp = Array.new(n+1, 0)
(1..n).each do |i|
tmp = matched_numbers[i].to_i.to_s
matched_numbers.each do |cost, number|
next if dp[i-cost].nil? || dp[i-cost].to_i.zero?
a = dp[i-cost].to_s
b = number.to_s
str = a<b ? (b+a) : (a+b)
tmp = str if tmp.length < str.length || (tmp.length==str.length && tmp < str)
end
dp[i] = tmp
end
#p dp
p dp[n].to_i
|
n, m = gets.strip.split.map(&:to_i)
as = gets.strip.split.map(&:to_i)
matched_numbers = [2, 5, 5, 4, 5, 6, 3, 7, 6].map.with_index {|e, i| [e, i+1] }.select {|e, i| as.include?(i) }.sort.to_h
#p matched_numbers
dp = Array.new(n+1, 0)
(1..n).each do |i|
tmp = matched_numbers[i].to_i.to_s
matched_numbers.each do |cost, number|
next if dp[i-cost].nil? || dp[i-cost].to_i.zero?
a = dp[i-cost].to_s
b = number.to_s
str = a<b ? (b+a) : (a+b)
tmp = str if tmp.length < str.length || (tmp.length==str.length && tmp < str)
end
dp[i] = tmp
end
#p dp
p dp[n].to_i
|
[
"expression.operation.binary.remove"
] | 930,434
| 930,435
|
u021358975
|
ruby
|
p03128
|
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
bar = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
bar2num = Hash.new(0)
A.each do |n|
b = bar[n]
bar2num[b] = n if n > bar2num[b]
end
B = bar2num.keys.sort.reverse
B.delete(7) if B.include?(2) && B.include?(5)
B.delete(7) if B.include?(3) && B.include?(4)
B.delete(6) if B.include?(2) || B.include?(3)
B.delete(5) if B.include?(2) && B.include?(3)
B.delete(4) if B.include?(2)
minbar = B.min
B.delete(minbar)
C = B.sort_by{|b| -bar2num[b]}.select{|b| bar2num[b] > bar2num[minbar]}
def calc(r)
ans = []
C.each do |b|
if r >= b
ans << b
r -= b
end
end
B.each do |b|
if r >= b
ans << b
r -= b
end
end
r == 0 ? ans : false
end
q, r = N.divmod minbar
10.times do
tmp = calc(r)
if tmp
tmp += Array.new(q, minbar)
puts tmp.map!{|b| bar2num[b]}.sort!.reverse!.join
break
end
q -= 1
r += minbar
end
|
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
bar = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
bar2num = Hash.new(0)
A.each do |n|
b = bar[n]
bar2num[b] = n if n > bar2num[b]
end
B = bar2num.keys.sort.reverse
B.delete(7) if B.include?(2) && B.include?(5)
B.delete(7) if B.include?(3) && B.include?(4)
B.delete(6) if B.include?(2) || B.include?(3)
B.delete(5) if B.include?(2) && B.include?(3)
B.delete(4) if B.include?(2)
minbar = B.min
B.delete(minbar)
C = B.sort_by{|b| -bar2num[b]}.select{|b| bar2num[b] > bar2num[minbar]}
def calc(r)
ans = []
C.each do |b|
if r >= b
ans << b
r -= b
redo
end
end
B.each do |b|
if r >= b
ans << b
r -= b
redo
end
end
r == 0 ? ans : false
end
q, r = N.divmod minbar
10.times do
tmp = calc(r)
if tmp
tmp += Array.new(q, minbar)
puts tmp.map!{|b| bar2num[b]}.sort!.reverse!.join
break
end
q -= 1
r += minbar
end
|
[] | 930,525
| 930,526
|
u004588855
|
ruby
|
p03129
|
N, K = gets.strip.split.map(&:to_i)
puts (N+1)/2 >= K ? :YES :NO
|
N, K = gets.chomp.split.map(&:to_i)
puts (N+1)/2 >= K ? :YES : :NO
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 930,978
| 930,979
|
u074306398
|
ruby
|
p03129
|
n, k = gets.chomp.split(" ").map(&:to_i)
x = (k - 1) * 2 + 1
if n >= x
puts "Yes"
else
puts "No"
end
|
n, k = gets.chomp.split(" ").map(&:to_i)
x = (k - 1) * 2 + 1
if n >= x
puts "YES"
else
puts "NO"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 931,141
| 931,142
|
u910756197
|
ruby
|
p03129
|
# 1以上N以下の異なる整数を、差が1の整数をともに選ばないようにK個選ぶことができるか判定する関数
# @param n
# @param k
# @return canGet
def canGetK(n, k)
mirginNum = (n - 1) / 2
canGet = (mirginNum + 1) >= k ? 'YES' : 'NO'
end
if __FILE__ == $0
input = gets.chomp
n,k = input.split(' ').first.to_i, input.split(' ').last.to_i
p canGetK(n, k)
end
|
# 1以上N以下の異なる整数を、差が1の整数をともに選ばないようにK個選ぶことができるか判定する関数
# @param n
# @param k
# @return canGet
def canGetK(n, k)
mirginNum = (n - 1) / 2
canGet = (mirginNum + 1) >= k ? 'YES' : 'NO'
end
if __FILE__ == $0
input = gets.chomp
n,k = input.split(' ').first.to_i, input.split(' ').last.to_i
puts canGetK(n, k)
end
|
[
"call.function.change",
"io.output.change"
] | 931,167
| 931,168
|
u512399955
|
ruby
|
p03129
|
N, K = gets.split.map(&:to_i)
puts N >= K * 2 ? 'YES' : 'NO'
|
N, K = gets.split.map(&:to_i)
puts N >= K * 2 - 1 ? 'YES' : 'NO'
|
[
"control_flow.branch.if.condition.change"
] | 931,226
| 931,227
|
u333012034
|
ruby
|
p03129
|
N, K = gets.split.map(&:to_i)
puts N > K * 2 ? 'YES' : 'NO'
|
N, K = gets.split.map(&:to_i)
puts N >= K * 2 - 1 ? 'YES' : 'NO'
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 931,228
| 931,227
|
u333012034
|
ruby
|
p03129
|
line = gets.chomp.split(" ").map(&:to_i)
n = line[0]
k = line[1]
ans = ((n + 1).to_f / 2).to_i
puts k <= ans ? "Yes" : "No"
|
line = gets.chomp.split(" ").map(&:to_i)
n = line[0]
k = line[1]
ans = ((n + 1).to_f / 2).to_i
puts k <= ans ? "YES" : "NO"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 931,371
| 931,372
|
u847478937
|
ruby
|
p03129
|
n,k = gets.split(" ").map!{|i| i.to_i}
if n % 2 == 0
sum = n/2
else sum = n/2 + 1
end
if sum >= k
puts 'Yes'
else puts 'No'
end
|
n,k = gets.split(" ").map!{|i| i.to_i}
if n % 2 == 0
sum = n/2
else sum = n/2 + 1
end
if sum >= k
puts 'YES'
else puts 'NO'
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 931,695
| 931,696
|
u974214237
|
ruby
|
p03130
|
ans = Array.new(5,0)
3.times do
a,b = gets.split.map(&:to_i)
ans[a] += 1
ans[b] += 1
end
puts ans.index{|e| e > 2} ? "No" : "Yes"
|
ans = Array.new(5,0)
3.times do
a,b = gets.split.map(&:to_i)
ans[a] += 1
ans[b] += 1
end
puts ans.index{|e| e > 2} ? "NO" : "YES"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 931,853
| 931,854
|
u692254521
|
ruby
|
p03130
|
a=$<.read.split.map &:to_i
t=[0]*4
a.map{|x|t[x-1]+=1}
puts t.max>3?'NO':'YES'
|
a=$<.read.split.map &:to_i
t=[0]*4
puts a.map{|x|t[x-1]+=1}.max>2?'NO':'YES'
|
[
"io.output.change",
"call.add",
"call.remove",
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 931,871
| 931,872
|
u408023666
|
ruby
|
p03128
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map{p};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p};q.any?&&d[i]=q.max};p d[N]
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=gets.split.map &:to_i;d=[0]+A.map{};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
[
"assignment.value.change",
"expression.operation.binary.change",
"io.output.change",
"call.remove",
"call.add"
] | 932,044
| 932,045
|
u205561862
|
ruby
|
p03128
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map;0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=gets.split.map &:to_i;d=[0]+A.map{};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
[
"assignment.value.change",
"expression.operation.binary.change"
] | 932,046
| 932,045
|
u205561862
|
ruby
|
p03128
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map;0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map{};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
[] | 932,046
| 932,047
|
u205561862
|
ruby
|
p03128
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map;0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=B=gets.split.map &:to_i;d=[0]+B.map{p};0.upto(N){|i|q=A.map{|x|c[x]<=i&&d[t=i-c[x]]?d[t]*10+x:p}.compact;q.any?&&d[i]=q.max};p d[N]
|
[] | 932,046
| 932,048
|
u205561862
|
ruby
|
p03129
|
n, k = gets.chomp.split.map(&:to_i)
if (n + 1) / 2 >= 2
print "YES"
else
print "NO"
end
|
n, k = gets.chomp.split.map(&:to_i)
if (n + 1) / 2 >= k
print "YES"
else
print "NO"
end
|
[
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change"
] | 932,503
| 932,504
|
u326891688
|
ruby
|
p03131
|
line = gets.chomp.split(" ").map(&:to_i)
k = line[0] + 1
a = line[1]
b = line[2]
diff = b - a
k = k - a
total = a
if diff == 1
total = k + a
elsif k % 2 == 0
times = (k.to_f / 2).to_i
total += diff * times
else
times = ((k - 1).to_f / 2).to_i
total += diff * times
total += 1
end
puts total
|
line = gets.chomp.split(" ").map(&:to_i)
k = line[0] + 1
a = line[1]
b = line[2]
diff = b - a
k = k - a
total = a
if diff <= 1
total = k + a
elsif k % 2 == 0
times = (k.to_f / 2).to_i
total += diff * times
else
times = ((k - 1).to_f / 2).to_i
total += diff * times
total += 1
end
puts total
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 933,366
| 933,367
|
u847478937
|
ruby
|
p03131
|
kab = gets.split(" ").map{|a|a.to_i}
k = kab[0]
a = kab[1]
b = kab[2]
if a+2 >= b then
answer = 1+k
elsif a+1 > k then
answer = 1+k
elsif (k-a-1)%2==0 then
answer = b+((k-a-1)/2)*(b-a)
elsif (k-a-1)%2==1 then
answer = b+((k-a-2)/2)*(b-1)+1
end
puts answer
|
kab = gets.split(" ").map{|a|a.to_i}
k = kab[0]
a = kab[1]
b = kab[2]
if a+2 >= b then
answer = 1+k
elsif a+1 > k then
answer = 1+k
elsif (k-a-1)%2==0 then
answer = b+((k-a-1)/2)*(b-a)
elsif (k-a-1)%2==1 then
answer = b+((k-a-2)/2)*(b-a)+1
end
puts answer
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.change"
] | 933,403
| 933,404
|
u257354345
|
ruby
|
p03131
|
kab = gets.split(" ").map{|a|a.to_i}
k = kab[0]
a = kab[1]
b = kab[2]
if a+2 >= b then
answer = 1+k
elsif a+1 > k then
answer = a+k
elsif (k-a-1)%2==0 then
answer = b+((k-a-1)/2)*(b-a)
elsif (k-a-1)%2==1 then
answer = b+((k-a-2)/2)*(b-1)+1
end
puts answer
|
kab = gets.split(" ").map{|a|a.to_i}
k = kab[0]
a = kab[1]
b = kab[2]
if a+2 >= b then
answer = 1+k
elsif a+1 > k then
answer = 1+k
elsif (k-a-1)%2==0 then
answer = b+((k-a-1)/2)*(b-a)
elsif (k-a-1)%2==1 then
answer = b+((k-a-2)/2)*(b-a)+1
end
puts answer
|
[
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"expression.operation.binary.change",
"identifier.replace.add",
"literal.replace.remove"
] | 933,405
| 933,404
|
u257354345
|
ruby
|
p03135
|
puts gets.split.map(&:to_i).inject(:/)
|
puts gets.split.map(&:to_f).inject(:/)
|
[
"call.arguments.change"
] | 934,123
| 934,124
|
u370564845
|
ruby
|
p03135
|
t,x = gets.split.map(&:to_f)
puts = t/x
|
t, x = gets.split.map(&:to_f)
puts t/x
|
[] | 934,187
| 934,188
|
u451270227
|
ruby
|
p03135
|
t,x = gets.split.map(&:to_i)
puts (t/x)
|
t,x = gets.split.map(&:to_i)
puts (t/x.to_f)
|
[
"call.add"
] | 934,531
| 934,532
|
u895926909
|
ruby
|
p03135
|
t,x = gets.split(" ").map(&:to_i)
puts t/x
|
t,x = gets.split(" ").map(&:to_i)
puts t/x.to_f
|
[
"call.add"
] | 934,562
| 934,563
|
u202708319
|
ruby
|
p03135
|
t,x=gets.split.map(&:to_i)
p x/t.to_f
|
t,x=gets.split.map(&:to_i)
p t/x.to_f
|
[
"expression.operation.binary.remove"
] | 934,582
| 934,583
|
u408023666
|
ruby
|
p03135
|
a=gets.split.map(&:to_f)
puts a[0]/[1]
|
a=gets.split.map(&:to_f)
puts a[0]/a[1]
|
[
"call.arguments.change"
] | 934,661
| 934,662
|
u585819925
|
ruby
|
p03135
|
input = gets
A=input.split(" ")[0].to_i
B=input.split(" ")[1].to_u
print A/B.to_f
|
input = gets
A=input.split(" ")[0].to_i
B=input.split(" ")[1].to_i
print A/B.to_f
|
[
"assignment.value.change",
"identifier.change"
] | 934,776
| 934,777
|
u312004378
|
ruby
|
p03135
|
t,x = gets.split(" ").map{|i|i.to_i}
puts format("%.10f",x.quo(t).to_f)
|
t,x = gets.split(" ").map{|i|i.to_i}
puts format("%.10f",t.quo(x).to_f)
|
[
"identifier.change",
"call.arguments.change"
] | 934,864
| 934,865
|
u951980350
|
ruby
|
p03135
|
t,x = gets.split.map(&:to_i)
puts t/x
|
t,x = gets.split.map(&:to_f)
puts t/x
|
[
"assignment.value.change",
"call.arguments.change"
] | 934,930
| 934,931
|
u053656954
|
ruby
|
p03135
|
T, X = gets.split.map(&:to_i)
puts T/X
|
T, X = gets.split.map(&:to_f)
puts T/X
|
[
"assignment.value.change",
"call.arguments.change"
] | 934,914
| 934,915
|
u670006196
|
ruby
|
p03135
|
input = gets.chomp.split(' ').map{ |v| v.to_i }
puts input[0] / input[1]
|
input = gets.chomp.split(' ').map{ |v| v.to_f }
puts input[0] / input[1]
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 935,178
| 935,179
|
u277797473
|
ruby
|
p03135
|
t,x = gets.split.map(&:to_i)
puts t / x
|
t,x = gets.split.map(&:to_i)
puts t / x.to_f
|
[
"call.add"
] | 935,202
| 935,203
|
u386131832
|
ruby
|
p03136
|
N, *l = $stdin.read.split(/\s/).map(&:to_i)
l.sort!
lmax = l.pop
lrest = l.reduce(0) {|s, a| s + a }
puts (lmax < lrest) ? 'YES' : 'NO'
|
N, *l = $stdin.read.split(/\s/).map(&:to_i)
l.sort!
lmax = l.pop
lrest = l.reduce(0) {|s, a| s + a }
puts (lmax < lrest) ? 'Yes' : 'No'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 935,524
| 935,525
|
u937432912
|
ruby
|
p03136
|
n,*a=`dd`.split.map(&:to_i)
s=a.sum
a.each do |i|
if s-i<i
puts 'No'
exit
end
end
puts 'Yes'
|
n,*a=`dd`.split.map(&:to_i)
s=a.sum
a.each do |i|
if s-i<=i
puts 'No'
exit
end
end
puts 'Yes'
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 935,688
| 935,689
|
u966810027
|
ruby
|
p03136
|
n = gets.chomp
lengths = gets.chomp.split(' ').map(&:to_i)
max = lengths.max
sum = lengths.inject(&:+) - max
puts (max - sum) > 0 ? 'Yes' : 'No'
|
n = gets.chomp
lengths = gets.chomp.split(' ').map(&:to_i)
max = lengths.max
sum = lengths.inject(&:+) - max
puts (sum - max) > 0 ? 'Yes' : 'No'
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change"
] | 935,983
| 935,984
|
u913313885
|
ruby
|
p03136
|
n = gets.chomp
lengths = gets.chomp.split(' ').map(&:to_i)
max = lengths.max
sum = lengths.inject(&:+) - max
puts (max - sum) > 0 ? 'yes' : 'no'
|
n = gets.chomp
lengths = gets.chomp.split(' ').map(&:to_i)
max = lengths.max
sum = lengths.inject(&:+) - max
puts (sum - max) > 0 ? 'Yes' : 'No'
|
[
"expression.operation.binary.remove",
"control_flow.branch.if.condition.change",
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 935,985
| 935,984
|
u913313885
|
ruby
|
p03136
|
n = gets.to_i
sides = gets.split.map(&:to_i).sort
if sides[-1] > sides[0..-2].inject(:+)
puts 'Yes'
else
puts 'No'
end
|
n = gets.to_i
sides = gets.split.map(&:to_i).sort
if sides[-1] < sides[0..-2].inject(:+)
puts 'Yes'
else
puts 'No'
end
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 936,023
| 936,024
|
u866325115
|
ruby
|
p03136
|
n = gets.to_i
l = gets.split.map(&:to_i).sort
lMax = l[-1]
sum = 0
l[0..-2].map do |x|
sum += x
end
if lMax < sum
p "Yes"
else
p "No"
end
|
n = gets.to_i
l = gets.split.map(&:to_i).sort
lMax = l[-1]
sum = 0
l[0..-2].map do |x|
sum += x
end
if lMax < sum
puts "Yes"
else
puts "No"
end
|
[
"call.function.change",
"io.output.change"
] | 936,052
| 936,053
|
u968699140
|
ruby
|
p03136
|
n_polygon = gets.to_i
l_array = gets.chomp.split('').map(&:to_i)
max_num = l_array.max
sum = -max_num
l_array.each { |l| sum += l }
if (max_num < sum)
puts 'Yes'
else
puts 'No'
end
|
n_polygon = gets.to_i
l_array = gets.chomp.split(' ').map(&:to_i)
max_num = l_array.max
sum = -max_num
l_array.each { |l| sum += l }
if (max_num < sum)
puts 'Yes'
else
puts 'No'
end
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 936,151
| 936,152
|
u784968701
|
ruby
|
p03136
|
N = gets.to_i
L = gets.split().map(&:to_i)
max = L.max
sum = 0
N.times{|i| sum += L[i]}
puts max < sum - max ? 'YES' : 'NO'
|
N = gets.to_i
L = gets.split().map(&:to_i)
max = L.max
sum = 0
N.times{|i| sum += L[i]}
puts max < sum - max ? 'Yes' : 'No'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 936,575
| 936,576
|
u163340796
|
ruby
|
p03136
|
N = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)
a = a.sort
amax=a[-1]
sum = 0
a.pop
a.each{|i| sum+=i}
if amax < sum
puts"YES"
else
puts "NO"
end
|
N = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)
a = a.sort
amax=a[-1]
sum = 0
a.pop
a.each{|i| sum+=i}
if amax < sum
puts"Yes"
else
puts "No"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 936,579
| 936,580
|
u925626028
|
ruby
|
p03136
|
n = gets.to_i
l =gets.split(" ").map!{|i| i.to_i}
max = 0
sum = 0
n.times do |j|
if max < l[j] then max = l[j] end
sum += l[j]
end
sum = sum - max
if max < sum
puts 'Yes'
else 'No'
end
|
n = gets.to_i
l = gets.split(" ").map!{|i| i.to_i}
max = 0
sum = 0
n.times do |j|
if max < l[j] then max = l[j] end
sum += l[j]
end
sum = sum - max
if max < sum
puts 'Yes'
else puts 'No'
end
|
[
"io.output.change",
"call.add"
] | 936,607
| 936,608
|
u974214237
|
ruby
|
p03136
|
n = gets.chomp.split(' ').map(&:to_i)[0]
l = gets.chomp.split(' ').map(&:to_i)
if l.inject(:+) - l.max > l.max
puts 'yes'
else
puts 'no'
end
|
n = gets.chomp.split(' ').map(&:to_i)[0]
l = gets.chomp.split(' ').map(&:to_i)
if l.inject(:+) - l.max > l.max
puts 'Yes'
else
puts 'No'
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 936,617
| 936,618
|
u454343817
|
ruby
|
p03136
|
gets;
v=gets.split.map(&:to_i);
p v.reduce(:+) > v.max() * 2 ? "Yes" : "No"
|
gets;
v=gets.split.map(&:to_i);
print v.reduce(:+) > v.max() * 2 ? "Yes" : "No"
|
[
"call.function.change",
"io.output.change"
] | 936,649
| 936,650
|
u702482655
|
ruby
|
p03136
|
gets;
v=gets.split.map(&:to_i);
p v.reduce(:+) < v.max() * 2 ? "Yes" : "No"
|
gets;
v=gets.split.map(&:to_i);
print v.reduce(:+) > v.max() * 2 ? "Yes" : "No"
|
[
"call.function.change",
"io.output.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 936,651
| 936,650
|
u702482655
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.