problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k ⌀ | fixed_code stringlengths 12 526k ⌀ | labels listlengths 0 15 ⌀ | buggy_submission_id int64 1 1.54M ⌀ | fixed_submission_id int64 2 1.54M ⌀ | user_id stringlengths 10 10 ⌀ | language stringclasses 9
values |
|---|---|---|---|---|---|---|---|
p02933 | a = gets.strip.to_i
s = gets.strip
s = 'red' if a >= 3200
puts s | a = gets.strip.to_i
s = gets.strip
s = 'red' if a < 3200
puts s | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 733,411 | 733,412 | u543681354 | ruby |
p02933 | a = gets.strip.to_i
s = gets.strip
s = 'pink' if a > 3200
puts s | a = gets.strip.to_i
s = gets.strip
s = 'red' if a < 3200
puts s | [
"literal.string.change",
"assignment.value.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 733,413 | 733,412 | u543681354 | ruby |
p02933 | a = gets.to_i
s = gets.strip
if a >= 3200 then
print("red")
else
print(s)
end | a = gets.to_i
s = gets.strip
if a < 3200 then
print("red")
else
print(s)
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 733,460 | 733,461 | u291303244 | ruby |
p02933 | a=gets.to_i
s=gets
puts a>=3200 ? :red : s | a=gets.to_i
s=gets
puts a<3200 ? :red : s | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 733,550 | 733,551 | u106964380 | ruby |
p02933 | a=gets.chomp.to_i
puts a>=3200 ? a : "red" | a=gets.chomp.to_i
b=gets
puts a>=3200 ? b : "red"
| [
"identifier.change",
"call.arguments.change"
] | 733,555 | 733,556 | u585819925 | ruby |
p02933 | a = gets.to_i
s = gets
if a>3200 then
print(s)
else
print("red")
end | a = gets.to_i
s = gets
if a>=3200 then
print(s)
else
print("red")
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 734,345 | 734,346 | u849186626 | ruby |
p02933 | a = gets.to_i
s = gets
if a>3200 then
p(s)
else
p("red")
end | a = gets.to_i
s = gets
if a>=3200 then
print(s)
else
print("red")
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"call.function.change",
"io.output.change"
] | 734,347 | 734,346 | u849186626 | ruby |
p02933 | a = gets.to_i
s = gets.chomp.to_s
if a >= 3200
puts 'red'
else
puts s
end | a = gets.to_i
s = gets.chomp.to_s
if a < 3200
puts 'red'
else
puts s
end
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 734,392 | 734,393 | u307452818 | ruby |
p02933 | puts gets.chomp.to_i > 3200 ? gets.chomp.to_s : 'red' | puts gets.chomp.to_i >= 3200 ? gets.chomp.to_s : 'red' | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 734,400 | 734,401 | u512524057 | ruby |
p02933 | a = gets.to_i
s = gets.chomp
puts a < 3200 ? s : :red | a = gets.to_i
s = gets.chomp
puts a >= 3200 ? s : :red | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 734,533 | 734,534 | u785521224 | ruby |
p02933 | a = gets.to_i
s = gets.chomp
if a > 3200
print("#{s}")
else
print("red")
end | a = gets.to_i
s = gets.chomp
if a >= 3200
print("#{s}")
else
print("red")
end
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 734,659 | 734,660 | u879573689 | ruby |
p02933 | if gets.to_i >= 3200
puts gets
else
puts 'pink'
end | if gets.to_i >= 3200
puts gets
else
puts 'red'
end | [
"literal.string.change",
"call.arguments.change"
] | 734,780 | 734,781 | u981932242 | ruby |
p02933 | a=gets.chomp.to_i
b=gets.chomp
puts a > 3200 ? b : "red" | a=gets.chomp.to_i
b=gets.chomp
puts a >= 3200 ? b : "red" | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 735,008 | 735,009 | u525844030 | ruby |
p02933 | print(gets.to_i>=3200 ? "red\n" : gets)
| print(gets.to_i<3200 ? "red\n" : gets) | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 735,012 | 735,013 | u720281401 | ruby |
p02933 | a = gets.to_i
s = gets.chomp
if a < 3200
puts s
else
puts 'red'
end | a = gets.to_i
s = gets.chomp
if a >= 3200
puts s
else
puts 'red'
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 735,038 | 735,040 | u054274223 | ruby |
p02933 | a = gets.to_i
s = gets.to_s
res = a >= 3200 ? s : 'pink'
puts res | a = gets.to_i
s = gets.to_s
res = a >= 3200 ? s : 'red'
puts res | [
"literal.string.change",
"assignment.value.change"
] | 735,090 | 735,091 | u630043039 | ruby |
p02933 | a = gets.chomp.to_i
s = gets.chomp
puts (a >= 3200 ? 'red' : s)
| a = gets.chomp.to_i
s = gets.chomp
puts (a >= 3200 ? s : 'red')
| [] | 735,126 | 735,127 | u112504572 | ruby |
p02933 | a = gets.strip.to_i
s = gets.strip
if a>=3200
p s
else
puts 'red'
end | a = gets.strip.to_i
s = gets.strip
if a>=3200
puts s
else
puts 'red'
end | [
"call.function.change",
"io.output.change"
] | 735,194 | 735,195 | u021358975 | ruby |
p02933 | a = gets.strip.to_i
s = gets.strip
if a>3200
p s
else
puts 'red'
end | a = gets.strip.to_i
s = gets.strip
if a>=3200
puts s
else
puts 'red'
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"call.function.change",
"io.output.change"
] | 735,196 | 735,195 | u021358975 | ruby |
p02933 | a=gets.to_i
s=gets.chomp
puts a>=3200?:red: s | a=gets.to_i
s=gets.chomp
puts a<3200?:red: s | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 735,199 | 735,200 | u025592199 | ruby |
p02933 | a, s = gets.to_i, gets.chomp
puts a < 3200 ? 'red' : 'pink' | a, s = gets.to_i, gets.chomp
puts a < 3200 ? 'red' : s | [
"call.arguments.change"
] | 735,383 | 735,384 | u333012034 | ruby |
p02933 | a = gets.to_s
s = gets.chomp
puts a >= 3200 ? s : 'red' | a = gets.to_i
s = gets.chomp
puts a >= 3200 ? s : 'red' | [
"call.function.change",
"type_conversion.to_integer.change",
"type_conversion.to_number.change"
] | 735,462 | 735,463 | u793801197 | ruby |
p02934 | n = gets.to_i
a = gets.split.map(&:to_i)
m = 0
n.times do |i|
m += 1.quo(a[i-1])
end
puts 1/m | n = gets.to_i
a = gets.split.map(&:to_i)
m = 0
n.times do |i|
m += 1.quo(a[i-1])
end
puts (1/m).to_f | [
"call.arguments.change",
"call.add"
] | 735,821 | 735,822 | u836913433 | ruby |
p02934 | n,*a=$<.read.split.map(&:to_i)
s=0
a.map{|x|s+=a.max/x}
p a.max/s.to_f | n,*a=$<.read.split.map(&:to_f)
s=0
a.map{|x|s+=a.max/x}
p a.max/s | [
"assignment.value.change",
"call.arguments.change",
"call.remove"
] | 735,829 | 735,830 | u408023666 | ruby |
p02934 | # your code goes here
n = gets.to_i
a_s = gets.split.map(&:to_i)
puts a_s
sum = 0.0
a_s.each do |a|
sum += 1 / a.to_f
end
puts 1.0 / sum | # your code goes here
n = gets.to_i
a_s = gets.split.map(&:to_i)
sum = 0.0
a_s.each do |a|
sum += 1 / a.to_f
end
puts 1.0 / sum | [
"call.remove"
] | 736,092 | 736,093 | u961226684 | ruby |
p02934 | n = gets.chomp.to_i
a = gets.split.map(&:to_i)
b=0.0
a.each do |v|
b+= 1.0/v
end
puts 1.0/v | n = gets.chomp.to_i
a = gets.split.map(&:to_i)
b=0.0
a.each do |v|
b+= 1.0/v
end
puts 1.0/b | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 736,269 | 736,270 | u467484398 | ruby |
p02934 | n=gets.chomp!.to_i
a = gets.chomp!.split(" ").map(&:to_i)
au = Array.new
a.each do |i|
u = 1.0 / i
au.push(u)
end
p a
as = au.inject(:+)
puts 1.0 / as
| n=gets.chomp!.to_i
a = gets.chomp!.split(" ").map(&:to_i)
au = Array.new
a.each do |i|
u = 1.0 / i
au.push(u)
end
#p a
as = au.inject(:+)
puts 1.0 / as
| [
"call.remove"
] | 736,314 | 736,315 | u911815052 | ruby |
p02934 | n, a_array = readlines.map(&:chomp)
n = n.to_i
a_array = a_array.split(' ').map(&:to_i)
p n
p a_array
result = Rational(1, a_array[0])
(1..(n-1)).each do |i|
result += Rational(1, a_array[i])
end
puts Rational(1, result).to_f | n, a_array = readlines.map(&:chomp)
n = n.to_i
a_array = a_array.split(' ').map(&:to_i)
result = Rational(1, a_array[0])
(1..(n-1)).each do |i|
result += Rational(1, a_array[i])
end
puts Rational(1, result).to_f | [
"call.remove"
] | 736,359 | 736,360 | u784968701 | ruby |
p02934 | # frozen_string_literal: true
a = gets.to_i
arry = gets.split(' ').map(&:to_i)
memo = arry.inject(0) do |memo, e|
memo += (1.to_f / e.to_f).to_f
p memo
memo
end
puts((1 / memo).to_f)
| # frozen_string_literal: true
a = gets.to_i
arry = gets.split(' ').map(&:to_i)
memo = arry.inject(0) do |memo, e|
memo += (1.to_f / e.to_f).to_f
memo
end
puts((1 / memo).to_f)
| [
"call.remove"
] | 736,371 | 736,372 | u393913844 | ruby |
p02935 | gets
p gets.split.map{|i|i.to_i*100}.sort.inject{|r,i| (r+i)/2}/100 | gets
p gets.split.map{|i|i.to_i*100}.sort.inject{|r,i| (r+i)/2.0}/100 | [
"call.arguments.change",
"expression.operation.binary.change"
] | 736,569 | 736,570 | u489339677 | ruby |
p02934 | gets
num = gets.chomp.split(" ").map(&:to_i)
ret = 0.0
num.each do |n|
ret += 1/n
end
ret = 1/ret
print("#{ret}") | gets
num = gets.chomp.split(" ").map(&:to_i)
ret = 0.0
num.each do |n|
ret += 1.0/n
end
ret = 1/ret
print("#{ret}")
| [
"expression.operation.binary.change"
] | 736,654 | 736,655 | u879573689 | ruby |
p02935 | n = gets.to_i
vs = gets.split.map(&:to_i).sort!
ans = vs.shift
ans = (ans + vs.shift) / 2 until vs.empty?
puts ans
| n = gets.to_i
vs = gets.split.map(&:to_i).sort!
ans = vs[0]
ans = (ans + vs.shift) / 2.0 until vs.empty?
puts ans
| [
"assignment.value.change",
"expression.operation.binary.change"
] | 736,856 | 736,857 | u889326464 | ruby |
p02935 | n = gets.to_i
vs = gets.split.map(&:to_i).sort!
ans = vs.shift
ans = (ans + vs.shift) / 2 until vs.empty?
puts ans
|
n = gets.to_i
vs = gets.split.map(&:to_i).sort!
ans = vs.shift
ans = (ans + vs.shift) / 2.0 until vs.empty?
puts ans
| [
"assignment.value.change",
"expression.operation.binary.change"
] | 736,856 | 736,858 | u889326464 | ruby |
p02935 | n,*v=gets(p).split.map &:to_f
p v.sort.reverse.reduce{|s,x|(s+x)/2} | n,*v=gets(p).split.map &:to_f
p v.sort.reduce{|s,x|(s+x)/2} | [
"call.remove"
] | 737,024 | 737,025 | u408023666 | ruby |
p02935 | n,*v=gets(p).split.map &:to_f
p v.sort.reverse.reduce{|s,x|s=(s+x)/2} | n,*v=gets(p).split.map &:to_f
p v.sort.reduce{|s,x|(s+x)/2} | [
"call.remove"
] | 737,026 | 737,025 | u408023666 | ruby |
p02935 | N = gets.to_i
vs = gets.split.map(&:to_i)
vs.sort!
sum = vs.shift
vs.each do | v |
sum = (sum + v) / 2
end
p sum | N = gets.to_i
vs = gets.split.map(&:to_i)
vs.sort!
sum = vs.shift.to_f
vs.each do | v |
sum = (sum + v) / 2
end
p sum | [
"call.add"
] | 737,080 | 737,081 | u366779547 | ruby |
p02935 | n=gets.to_i
v=gets.split.map(&:to_i)
ave=v.sort[0]
n.times do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| n=gets.to_i
v=gets.split.map(&:to_f)
ave=v.sort[0]
n.times do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| [
"assignment.value.change",
"call.arguments.change"
] | 737,095 | 737,096 | u882389182 | ruby |
p02935 | n=gets.to_i
v=gets.split.map(&:to_f)
ave=v.sort[0]
(1..n).each do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| n=gets.to_i
v=gets.split.map(&:to_f)
ave=v.sort[0]
n.times do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| [
"identifier.change"
] | 737,097 | 737,096 | u882389182 | ruby |
p02935 | n=gets.to_i
v=gets.split.map(&:to_f)
ave=0.0
n.times do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| n=gets.to_i
v=gets.split.map(&:to_f)
ave=v.sort[0]
n.times do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 737,098 | 737,096 | u882389182 | ruby |
p02935 | n=gets.to_i
v=gets.split.map(&:to_f)
ave=0.0
n.times do |i|
ave=(v[i]+ave)/2
end
print ave | n=gets.to_i
v=gets.split.map(&:to_f)
ave=v.sort[0]
n.times do |i|
ave=(v.sort[i]+ave)/2
end
print ave
| [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"call.add"
] | 737,099 | 737,096 | u882389182 | ruby |
p02935 | N = gets.to_i
V = gets.split.map!(&:to_i).sort!
p V
k = 2.0**(N-1)
ans = V[0] / k
1.upto(V.size - 1) do |i|
ans += V[i] / k
k /= 2
end
puts ans
| N = gets.to_i
V = gets.split.map!(&:to_i).sort!
k = 2.0**(N-1)
ans = V[0] / k
1.upto(V.size - 1) do |i|
ans += V[i] / k
k /= 2
end
puts ans
| [
"call.remove"
] | 737,233 | 737,234 | u638516820 | ruby |
p02935 | n = gets.to_i
arr = gets.split(" ").map{|i|i.to_i}.sort
(n-1).times{ |i|
arr.unshift(arr.shift(2).inject(:+))
}
puts arr[0] | n = gets.to_i
arr = gets.split(" ").map{|i|i.to_f}.sort
(n-1).times{ |i|
arr.unshift(arr.shift(2).inject(:+)/2)
}
puts arr[0] | [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 737,250 | 737,251 | u606976120 | ruby |
p02935 | n = gets.chop.to_i
v = gets.chop.split.map(&:to_f).sort
res = v.pop
while v.length > 0 do
res = (res + v.pop) / 2
end
p res | n = gets.chop.to_i
v = gets.chop.split.map(&:to_i).sort.reverse
res = v.pop
while v.length > 0 do
res = (res + v.pop) / 2.0
end
p res | [
"assignment.value.change",
"call.arguments.change",
"call.add",
"expression.operation.binary.change"
] | 737,292 | 737,293 | u860790033 | ruby |
p02935 | n = gets.chop.to_i
v = gets.chop.split.map(&:to_i).sort
res = v.pop
while v.length > 0 do
res = (res + v.pop) / 2
end
p res | n = gets.chop.to_i
v = gets.chop.split.map(&:to_i).sort.reverse
res = v.pop
while v.length > 0 do
res = (res + v.pop) / 2.0
end
p res | [
"call.add",
"assignment.value.change",
"expression.operation.binary.change"
] | 737,294 | 737,293 | u860790033 | ruby |
p02935 | n=gets.chop.to_i
v=gets.chomp.split(" ").map(&:to_f)
v2=v.sort
puts v2
num=v2[0]
for i in 0...n-1 do
num=(num+v2[i+1])/2
end
puts num | n=gets.chop.to_i
v=gets.chomp.split(" ").map(&:to_f)
v2=v.sort
num=v2[0]
for i in 0...n-1 do
num=(num+v2[i+1])/2
end
puts num | [
"call.remove"
] | 737,404 | 737,405 | u389979392 | ruby |
p02935 | n=gets.chop.to_i
v=gets.chomp.split(" ").map(&:to_f)
v.sort
num=v[0]
for i in 0...n-1 do
num=(num+v[i+1])/2
end
puts num | n=gets.chop.to_i
v=gets.chomp.split(" ").map(&:to_f)
v2=v.sort
num=v2[0]
for i in 0...n-1 do
num=(num+v2[i+1])/2
end
puts num | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 737,406 | 737,405 | u389979392 | ruby |
p02935 | n=gets.chop.to_i
v=gets.chomp.split(" ").map(&:to_f)
v.sort
num=v[0]
for i in 0...n-1 do
num=(num+v[i+1])/2
end
puts num
| n=gets.chop.to_i
v=gets.chomp.split(" ").map(&:to_f)
v2=v.sort
num=v2[0]
for i in 0...n-1 do
num=(num+v2[i+1])/2
end
puts num | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 737,407 | 737,405 | u389979392 | ruby |
p02935 | n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
puts a.inject {|x, y| (x+y)/2} | n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
puts a.inject {|x, y| (x+y)/2.0} | [
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 737,431 | 737,432 | u512524057 | ruby |
p02935 | N = gets.to_i
Vs = gets.split.map(&:to_i)
vs = Vs.dup
(N - 1).times{vs.sort; vs.push(vs.shift(2).inject(:+)/2.0)}
puts vs[0] | N = gets.to_i
Vs = gets.split.map(&:to_i)
vs = Vs.dup
(N - 1).times{vs.sort!; vs.push(vs.shift(2).inject(:+)/2.0)}
puts vs[0] | [
"call.suffix.change"
] | 737,571 | 737,572 | u304198114 | ruby |
p02935 | N = gets.to_i
Vs = gets.split.map(&:to_i)
vs = Vs.sort
(N - 1).times{vs.push(vs.shift(2).inject(:+)/2.0)}
puts vs[0] | N = gets.to_i
Vs = gets.split.map(&:to_i)
vs = Vs.dup
(N - 1).times{vs.sort!; vs.push(vs.shift(2).inject(:+)/2.0)}
puts vs[0] | [
"assignment.value.change",
"identifier.change"
] | 737,573 | 737,572 | u304198114 | ruby |
p02935 | n = gets.to_i
ary = gets.split.map(&:to_f).sort
ans = ary[0]
for i in 1 .. n - 1
ans = (ans + ary[i]) / 3
end
puts ans | n = gets.to_i
ary = gets.split.map(&:to_f).sort
ans = ary[0]
for i in 1 .. n - 1
ans = (ans + ary[i]) / 2
end
puts ans | [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 737,629 | 737,630 | u785521224 | ruby |
p02935 | gets
vals = gets.split(' ').map(&:to_i)
puts(vals.sort.inject{|sum, x| (sum + x) / 2 }) | gets
vals = gets.split(' ').map(&:to_i)
puts(vals.sort.inject{|sum, x| (sum + x) / 2.0 }) | [
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 737,707 | 737,708 | u054274223 | ruby |
p02935 | n = gets.to_i
arr = gets.split(" ").map(&:to_i).sort
b = arr[0]
p arr
p b
for i in 1..n-1 do
b = ((b + arr[i]).to_f / 2)
p b
end
puts b | n = gets.to_i
arr = gets.split(" ").map(&:to_i).sort
b = arr[0]
for i in 1..n-1 do
b = ((b + arr[i]).to_f / 2)
end
puts b | [
"call.remove"
] | 737,709 | 737,710 | u094826590 | ruby |
p02935 | n = gets.chomp.to_i
facts = gets.chomp.split(' ').map(&:to_i)
facts.sort!
value = 0
(1..(facts.length - 1)).each do |i|
if i == 1
value = ((facts[0] + facts[i])/2).to_f
else
value = ((value + facts[i])/2).to_f
end
end
puts "#{value}"
| n = gets.chomp.to_i
facts = gets.chomp.split(' ').map(&:to_i)
facts.sort!
value = 0
(1..(facts.length - 1)).each do |i|
if i == 1
value = ((facts[0] + facts[i])/2.0).to_f
else
value = ((value + facts[i])/2.0).to_f
end
end
puts "#{value}"
| [
"assignment.value.change",
"expression.operation.binary.change"
] | 737,711 | 737,712 | u683116963 | ruby |
p02935 | n = gets.to_i
vs = gets.chomp.split.map(&:to_i).sort
(n-1).times do
first = vs.shift
second = vs.shift
p first
p second
mix = (first+second)/2.0
vs.unshift(mix)
end
puts vs[0] | n = gets.to_i
vs = gets.chomp.split.map(&:to_i).sort
(n-1).times do
first = vs.shift
second = vs.shift
mix = (first+second)/2.0
vs.unshift(mix)
end
puts vs[0] | [
"call.remove"
] | 737,743 | 737,744 | u191196346 | ruby |
p02935 | n = gets.to_i
numbers = gets.split.map(&:to_i).sort
(n-1).times do
average = (numbers[0] + numbers[1])/2
numbers.shift
numbers.shift
numbers.unshift(average)
end
puts numbers | n = gets.to_i
numbers = gets.split.map(&:to_i).sort
(n-1).times do
average = ((numbers[0] + numbers[1]).to_f)/2
numbers.shift
numbers.shift
numbers.unshift(average)
end
puts numbers | [] | 737,860 | 737,861 | u874549552 | ruby |
p02935 | n = gets.chomp.to_i
v = gets.split.map(&:to_f)
v.sort!
while v.length > 1
num = (v[0] + v[1]) / 2
v.push(num)
v.shift(2)
end
puts v
| n = gets.chomp.to_i
v = gets.split.map(&:to_f)
v.sort!
while v.length > 1
num = (v[0] + v[1]) / 2
v.push(num)
v.shift(2)
v.sort!
end
puts v
| [
"call.add"
] | 737,897 | 737,898 | u876846619 | ruby |
p02935 | N = gets.to_i
V = gets.split.map(&:to_i).sort!
(N - 1).times do |_|
v1, v2 = V.shift(2)
v = (v1 + v2) / 2
V.unshift(v)
end
puts V.first
| N = gets.to_i
V = gets.split.map(&:to_i).sort!
(N - 1).times do |_|
v1, v2 = V.shift(2)
v = (v1 + v2) / 2.to_f
V.unshift(v)
end
puts V.first | [
"call.add"
] | 737,903 | 737,904 | u776649162 | ruby |
p02935 | =begin
a = gets.to_i
s = gets
if a < 3200
puts "red"
else
puts s
end
=end
=begin
b = gets.to_i
a = gets.split(" ").map{|x| x.to_f}
sum = 0.0
b.times do |i|
sum += 1/a[i]
end
p 1 / sum
=end
n = gets.to_i
a = gets.split(" ").map{|x| x.to_f}
while true
a.sort!
a.push((a[0] + a[1]) / 2.0)
a.delete_at(0)
a.delete_at(0)
break if a.size == 1
end
| =begin
a = gets.to_i
s = gets
if a < 3200
puts "red"
else
puts s
end
=end
=begin
b = gets.to_i
a = gets.split(" ").map{|x| x.to_f}
sum = 0.0
b.times do |i|
sum += 1/a[i]
end
p 1 / sum
=end
n = gets.to_i
a = gets.split(" ").map{|x| x.to_f}
while true
a.sort!
a.push((a[0] + a[1]) / 2.0)
a.delete_at(0)
a.delete_at(0)
break if a.size == 1
end
p a[0]
| [
"call.add"
] | 737,905 | 737,906 | u912087911 | ruby |
p02935 | io = STDIN
N=io.gets.to_i
v=io.gets.split.map(&:to_i).sort
def merge(a)
return a.inject(:+)/2.0 if a.size==2
merge a[2..-1] + [a[0..1].inject(:+)/2.0]
end
puts merge(v)
| io = STDIN
N=io.gets.to_i
v=io.gets.split.map(&:to_i).sort
def merge(a)
return a.inject(:+)/2.0 if a.size==2
merge (a[2..-1] + [a[0..1].inject(:+)/2.0]).sort
end
puts merge(v)
| [
"call.arguments.change",
"call.add"
] | 737,909 | 737,910 | u132360211 | ruby |
p02935 | t = gets.strip
s = gets.strip
s = s.split
for n in 0...s.length
s[n] = s[n].to_i
end
while s.length > 1
s.sort
b = (s[0] + s[1])/2.to_f
s.shift(2)
s.push(b)
end
print s[0] | t = gets.strip
s = gets.strip
s = s.split
for n in 0...s.length
s[n] = s[n].to_i
end
while s.length > 1
s = s.sort
b = (s[0] + s[1])/2.to_f
s.shift(2)
s.push(b)
end
print s[0] | [
"assignment.add"
] | 737,957 | 737,958 | u460204279 | ruby |
p02935 | t = gets.strip
s = gets.strip
s = s.split
for n in 0...s.length
s[n] = s[n].to_i
end
while s.length > 1
s.sort
b = (s[0] + s[1])/2.to_f
s.shift(2)
s.push(b)
end
print s | t = gets.strip
s = gets.strip
s = s.split
for n in 0...s.length
s[n] = s[n].to_i
end
while s.length > 1
s = s.sort
b = (s[0] + s[1])/2.to_f
s.shift(2)
s.push(b)
end
print s[0] | [
"assignment.add"
] | 737,959 | 737,958 | u460204279 | ruby |
p02935 | gets
a = gets.split.map{|x| x.to_i << 50}.sort!
while a.size > 1
a[0] = (a[0] + a[1]) / 2
a[1] = a[-1]
a.size -= 1
a.sort!
end
p f[0] / (1<<50).to_f | gets
a = gets.split.map{|x| x.to_i << 50}.sort!
while a.size > 1
a[0] = (a[0] + a[1]) / 2
a[1] = a[-1]
a.pop
a.sort!
end
p a[0] / (1<<50).to_f | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 738,049 | 738,050 | u720281401 | ruby |
p02935 | n = gets.to_i
a = gets.split(' ').map{|i| i.to_i}.sort
while a.length > 1
a << (a[0] + a[1]) / 2.to_f
p a
a.delete_at(0)
a.delete_at(0)
a.sort!
end
puts a[0].round(5) | n = gets.to_i
a = gets.split(' ').map{|i| i.to_i}.sort
while a.length > 1
a << (a[0] + a[1]) / 2.to_f
a.delete_at(0)
a.delete_at(0)
a.sort!
end
puts a[0].round(5) | [
"call.remove"
] | 738,057 | 738,058 | u239218660 | ruby |
p02935 | n = gets.to_i
a = gets.split(' ').map{|i| i.to_i}.sort
while a.length > 1
a << (a[0] + a[1]) / 2.0
a.delete_at(0)
a.delete_at(0)
a.sort
end
puts a[0].round(5) | n = gets.to_i
a = gets.split(' ').map{|i| i.to_i}.sort
while a.length > 1
a << (a[0] + a[1]) / 2.to_f
a.delete_at(0)
a.delete_at(0)
a.sort!
end
puts a[0].round(5) | [
"expression.operation.binary.change",
"call.add",
"call.suffix.change"
] | 738,059 | 738,058 | u239218660 | ruby |
p02937 | s=gets.chomp*2
t=gets.chomp
center = s.length/2
ret = 0
pos = 0
t.each_char do |c|
idx = s.index(c, pos+1)
if idx.nil?
p -1
exit 0
end
ret += idx - pos
pos = idx % center
end
p ret + 1
| s=gets.chomp*2
t=gets.chomp
center = s.length/2
ret = 0
pos = -1
t.each_char do |c|
idx = s.index(c, pos+1)
if idx.nil?
p -1
exit 0
end
ret += idx - pos
pos = idx % center
end
p ret
| [
"assignment.value.change",
"expression.operation.unary.add",
"expression.operation.binary.remove"
] | 739,541 | 739,542 | u852974293 | ruby |
p02937 | S,T=*$<
a=0
T.chop.chars{|c|b=a%N=S.size
a<0||a+=(x=S.index c)?(y=S[b..-1].index c)?y:x+N-b:~a}
p a | S,T=*$<
a=0
T.chop.chars{|c|b=a%~-N=S.size
a<0||a+=(x=S.index c)?(y=S[b..-1].index c)?y+1:x+N-b:~a}
p a | [] | 739,947 | 739,948 | u657913472 | ruby |
p02937 | S=gets.chop
a=0
gets.chop.chars{|c|
b=a%S.size
x=S.index c
y=S[b..-1].index c
a+=x ? y ? y+1 : x+S.size-b : p(-1)+exit
}
p a | S=gets.chop
a=0
gets.chop.chars{|c|
b=a%S.size
x=S.index c
y=S[b..-1].index c
a+=x ? y ? y+1 : x+S.size-b+1 : p(-1)+exit
}
p a | [
"expression.operation.binary.add"
] | 739,949 | 739,950 | u657913472 | ruby |
p02937 | ss = gets.chomp
tt = gets.chomp
cnt = 0
t = 0
while t<tt.length do
s = ss.index(tt[t])
if s.nil?
puts -1
exit
end
t += 1
if t == tt.length
cnt += s+1
break
end
while true do
s = ss.index(tt[t],s)
if s.nil?
cnt += ss.length
break
end
t += 1
if t == tt.length
cnt += s+1
break
end
end
end
puts cnt
| ss = gets.chomp
tt = gets.chomp
cnt = 0
t = 0
while t<tt.length do
s = ss.index(tt[t])
if s.nil?
puts -1
exit
end
t += 1
if t == tt.length
cnt += s+1
break
end
while true do
s = ss.index(tt[t],s+1)
if s.nil?
cnt += ss.length
break
end
t += 1
if t == tt.length
cnt += s+1
break
end
end
end
puts cnt
| [
"assignment.change"
] | 740,163 | 740,164 | u385631112 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev >= v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 740,459 | 740,460 | u868089307 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
p idx
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev >= v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"call.remove",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 740,461 | 740,460 | u868089307 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev >= v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 740,462 | 740,460 | u868089307 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x >= prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev >= v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change",
"io.output.change",
"control_flow.branch.if.condition.change"
] | 740,463 | 740,460 | u868089307 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s=s+s
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"assignment.add"
] | 740,459 | 740,464 | u868089307 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s=s+s
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"assignment.add"
] | 740,462 | 740,464 | u868089307 | ruby |
p02937 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x >= prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | s=gets.chomp.split("")
t=gets.chomp.split("")
idx=Hash.new { |h, k| h[k] = [] }
s=s+s
s.each_with_index do |c,i|
idx[c] << i
end
l = []
t.each do |c|
if idx[c].size == 0
puts -1
exit
end
if l.size == 0
prev = -1
else
prev = l[-1]
end
tmp = idx[c].bsearch {|x| x > prev}
if tmp == nil
l << idx[c][0]
else
l << tmp
end
end
prev=Float::INFINITY
cnt = 0
l.each do |v|
if prev > v
cnt += 1
end
prev = v
end
puts s.size * (cnt-1) + l[-1] + 1 | [
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change",
"io.output.change"
] | 740,463 | 740,464 | u868089307 | ruby |
p02937 | s = gets.chomp
t = gets.chomp
index = t.split("").uniq.map {|c| s.index c}
if index.include? nil
puts "-1"
exit
end
search_fieald = s + s
length = search_fieald.length
cache = {}
search_fieald.split("").each_with_index do |ss, i|
cache.has_key?(ss) ? cache[ss].push(i) : cache[ss] = [i]
end
unit = 0
current_pos = 0
t.split("").each do |tp|
find_pos = cache[tp].bsearch {|x| x >= current_pos }
if find_pos.nil?
unit += 1
current_pos = cache[tp][0]
else
current_pos = find_pos + 1
end
end
puts "#{unit * length + current_pos}"
| s = gets.chomp
t = gets.chomp
index = t.split("").uniq.map {|c| s.index c}
if index.include? nil
puts "-1"
exit
end
search_fieald = s + s
length = search_fieald.length
cache = {}
search_fieald.split("").each_with_index do |ss, i|
cache.has_key?(ss) ? cache[ss].push(i) : cache[ss] = [i]
end
unit = 0
current_pos = 0
t.split("").each do |tp|
find_pos = cache[tp].bsearch {|x| x >= current_pos }
if find_pos.nil?
unit += 1
current_pos = cache[tp][0] + 1
else
current_pos = find_pos + 1
end
end
puts "#{unit * length + current_pos}"
| [
"assignment.change"
] | 740,565 | 740,566 | u309439894 | ruby |
p02937 | s = gets.chomp
t = gets.chomp
wd = {}
s.chars.each.with_index do |c, i|
wd[c] ||= []
wd[c] << i
end
cnt = p = 0
fst = true
t.chars.each do |c|
d = wd[c]
if d.nil?
puts -1
exit
end
if fst
fst = false
next if d[0] == c
end
if d[-1] <= p
p = d[0]
cnt += 1
next
end
if d[0] > p
p = d[0]
next
end
p = d.bsearch { |i| i > p }
end
puts s.length * cnt + p + 1 | s = gets.chomp
t = gets.chomp
wd = {}
s.chars.each.with_index do |c, i|
wd[c] ||= []
wd[c] << i
end
cnt = p = 0
fst = true
t.chars.each do |c|
d = wd[c]
if d.nil?
puts -1
exit
end
if fst
fst = false
next if d[0] == 0
end
if d[-1] <= p
p = d[0]
cnt += 1
next
end
if d[0] > p
p = d[0]
next
end
p = d.bsearch { |i| i > p }
end
puts s.length * cnt + p + 1 | [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.branch.if.condition.change"
] | 740,592 | 740,593 | u620639655 | ruby |
p02937 | s = gets.chomp
t = gets.chomp
len = s.length
dic = Hash.new{}
len.times do |i|
c = s[i]
if dic[c]
dic[c].push(i)
else
dic[c] = [i]
end
end
period = 0
now = -1
checker = true
t.length.times do |i|
char = t[i]
if dic[char].empty?
checker = false
break
else
nxt = dic[char].bsearch{|n| n > now}
if nxt == nil
nxt = dic[char][0]
period += 1
end
now = nxt
end
end
if checker
puts period * len + now + 1
else
puts -1
end | s = gets.chomp
t = gets.chomp
len = s.length
dic = Hash.new{}
len.times do |i|
c = s[i]
if dic[c]
dic[c].push(i)
else
dic[c] = [i]
end
end
period = 0
now = -1
checker = true
t.length.times do |i|
char = t[i]
if dic[char] == nil
checker = false
break
else
nxt = dic[char].bsearch{|n| n > now}
if nxt == nil
nxt = dic[char][0]
period += 1
end
now = nxt
end
end
if checker
puts period * len + now + 1
else
puts '-1'
end | [
"call.arguments.change"
] | 740,668 | 740,669 | u548834738 | ruby |
p02937 | s = gets.chomp.chars
t = gets.chomp.chars
table = {}
s.each.with_index do |ch, i|
table[ch] = [] unless table[ch]
table[ch].push(i)
end
i = 0
loop_count = 0
pos = -1
t.each do |ch|
unless table[ch]
puts '-1'
exit 0
end
j = table[ch].bsearch { |j| j > i }
unless j
j = table[ch][0]
loop_count += 1
end
i = j
pos = loop_count * s.size + j + 1
end
puts pos
| s = gets.chomp.chars
t = gets.chomp.chars
table = {}
s.each.with_index do |ch, i|
table[ch] = [] unless table[ch]
table[ch].push(i)
end
i = -1
loop_count = 0
pos = -1
t.each do |ch|
unless table[ch]
puts '-1'
exit 0
end
j = table[ch].bsearch { |j| j > i }
unless j
j = table[ch][0]
loop_count += 1
end
i = j
pos = loop_count * s.size + j + 1
end
puts pos
| [
"assignment.value.change",
"expression.operation.unary.add"
] | 740,875 | 740,876 | u012133968 | ruby |
p02939 | #input of int(split by space)
def get_i()
return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
return bool ? y : n
end
#create of array
def array(size1,init=nil,size2=-1)
if size2==-1
return Array.new(size1){init}
else
return Array.new(size2){Array.new(size1){init}}
end
end
def max(a,b)
return a>b ? a : b
end
def min(a,b)
return a>b ? b : a
end
INF=Float::INFINITY
S=get_nsp
N=S.size
dp=array(S.size,0)
dp[0]=1
if S[0]==S[1]
dp[1]=1
else
dp[1]=2
end
if S[0]!=S[1] and S[1]!=S[2]
dp[2]=3
else
dp[2]=2
end
3.upto(N-1) do|i|
if S[i-1]==S[i]
dp[i]=dp[i-3]+2
else
dp[i]=dp[i-2]+1
end
end
puts dp[N-1] | #input of int(split by space)
def get_i()
return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
return bool ? y : n
end
#create of array
def array(size1,init=nil,size2=-1)
if size2==-1
return Array.new(size1){init}
else
return Array.new(size2){Array.new(size1){init}}
end
end
def max(a,b)
return a>b ? a : b
end
def min(a,b)
return a>b ? b : a
end
INF=Float::INFINITY
S=get_nsp
N=S.size
dp=array(S.size,0)
dp[0]=1
if S[0]==S[1]
dp[1]=1
else
dp[1]=2
end
if S[0]!=S[1] and S[1]!=S[2]
dp[2]=3
else
dp[2]=2
end
3.upto(N-1) do|i|
if S[i-1]==S[i]
dp[i]=dp[i-3]+2
else
dp[i]=dp[i-1]+1
end
end
puts dp[N-1] | [
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 741,375 | 741,376 | u415400221 | ruby |
p02939 | s=gets.chop.chars
c,i=0,1
while i<s.size
if s[i-1]==s[i]
c-=1
i+=2
end
i+=1
end
p c | s=gets.chop.chars
c=s.size
i=1
while i<s.size
if s[i-1]==s[i]
c-=1
i+=2
end
i+=1
end
p c | [
"call.add"
] | 741,433 | 741,434 | u408023666 | ruby |
p02939 | inputs = readlines
s = inputs[0]
pre_word = "0"
word = ""
count = 0
s.chars do |c|
word += c
unless pre_word == word
pre_word = word
word = ""
count += 1
end
end
puts count
| inputs = readlines
s = inputs[0].chomp
pre_word = "0"
word = ""
count = 0
s.chars do |c|
word += c
unless pre_word == word
pre_word = word
word = ""
count += 1
end
end
puts count
| [
"call.add"
] | 741,517 | 741,518 | u622715972 | ruby |
p02939 | s = gets.chomp
n = s.length
dp = Array.new(n+1){[0,0]}
dp[1][0] = 1
dp[2][1] = 1
1.upto(n-1) do |i|
if s[i-1] == s[i]
dp[i+1][0] = dp[i][1] + 1
else
dp[i+1][0] = dp[i].max + 1
end
if i >= 3 && s[i-3,2] == s[i-1,2]
dp[i+1][1] = dp[i][0] + 1
else
dp[i+1][1] = dp[i-1].max + 1
end
end
p dp[n].max | s = gets.chomp
n = s.length
dp = Array.new(n+1){[0,0]}
dp[1][0] = 1
dp[2][1] = 1
1.upto(n-1) do |i|
if s[i-1] == s[i]
dp[i+1][0] = dp[i][1] + 1
else
dp[i+1][0] = dp[i].max + 1
end
if i >= 3 && s[i-3,2] == s[i-1,2]
dp[i+1][1] = dp[i-1][0] + 1
else
dp[i+1][1] = dp[i-1].max + 1
end
end
p dp[n].max | [
"assignment.change"
] | 741,607 | 741,608 | u123276241 | ruby |
p02939 | s = gets.chomp
mae = ""
now = ""
ans = 0
s.each_char do |c|
now += c
if(ans != mae)
mae = ans
now = ""
ans += 1
end
end
p ans | s = gets.chomp
mae = ""
now = ""
ans = 0
s.each_char do |c|
now += c
if(now != mae)
mae = now
now = ""
ans += 1
end
end
p ans
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 741,611 | 741,610 | u145123922 | ruby |
p02939 | s = gets.chomp
mae = ""
now = ""
ans = 0
s.each_char do |c|
now += c
if(ans != mae)
mae = ans
now = ""
ans += 1
end
end
p cc | s = gets.chomp
mae = ""
now = ""
ans = 0
s.each_char do |c|
now += c
if(now != mae)
mae = now
now = ""
ans += 1
end
end
p ans
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"assignment.value.change",
"call.arguments.change"
] | 741,612 | 741,610 | u145123922 | ruby |
p02945 | a,b = gets.split(" ").map(&:to_i);
x = Array.new(3)
x[0] = a + b; x[1] = a * b; x[2] = a - b;
x.sort
puts x[2] | a,b = gets.split(" ").map(&:to_i);
x = Array.new(3)
x[0] = a + b; x[1] = a * b; x[2] = a - b;
x.sort!
puts x[2]
| [
"call.suffix.change"
] | 743,890 | 743,891 | u307452818 | ruby |
p02945 | nums = gets.chomp.split(' ').map(&:to_i)
results = [(nums[0] + nums[1]),
(nums[0] - nums[1]),
(nums[0] * nums[1])]
puts result.max | nums = gets.chomp.split(' ').map(&:to_i)
results = [(nums[0] + nums[1]),
(nums[0] - nums[1]),
(nums[0] * nums[1])]
puts results.max | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 744,495 | 744,496 | u808711621 | ruby |
p02946 | a,b=gets.split.map(&:to_i)
puts [*b-a-1..b+a-1].join ' ' | a,b=gets.split.map(&:to_i)
puts [*b-a+1..b+a-1].join ' '
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 744,857 | 744,858 | u966810027 | ruby |
p02946 | k,x = gets.split.map(:to_i)
puts ((x-k+1)..(x+k-1)).to_a.join(" ") | k,x = gets.split.map(&:to_i)
puts ((x-k+1)..(x+k-1)).to_a.join(" ")
| [
"call.arguments.change"
] | 745,271 | 745,272 | u624505752 | ruby |
p02946 | k,x = gets.split.map(:to_i)
puts ((x-k+1)..(x+k+1)).to_a.join(" ") | k,x = gets.split.map(&:to_i)
puts ((x-k+1)..(x+k-1)).to_a.join(" ")
| [
"call.arguments.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 745,273 | 745,272 | u624505752 | ruby |
p02946 | k, x = gets.split.map(&:to_i)
start = x - k + 1
fin = x + k - 1
p "#{(start..fin).to_a}".gsub(/[\[\],]/, "") | k, x = gets.split.map(&:to_i)
start = x - k + 1
fin = x + k - 1
puts "#{(start..fin).to_a}".gsub(/[\[\],]/, "") | [
"call.function.change",
"io.output.change"
] | 745,548 | 745,549 | u617691573 | ruby |
p02946 | input = gets.chomp.split("")
k = input[0].to_i
x = input[1].to_i
min = x - (k-1)
max = x + (k-1)
out = ""
while min <= max do
out = out + min.to_s + " "
min = min + 1
end
out.slice!(out.length()-1)
puts out | # 石が200万個
# 0を含めて座標が-100万から100万まで
input = gets.chomp.split(" ")
k = input[0].to_i
x = input[1].to_i
min = x - (k-1)
max = x + (k-1)
out = ""
while min <= max do
out = out + min.to_s + " "
min = min + 1
end
out.slice!(out.length()-1)
puts out | [
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 745,725 | 745,726 | u486374018 | ruby |
p02946 | input = gets.chomp.split("")
k = input[0].to_i
x = input[1].to_i
min = x - (k-1)
max = x + (k+1)
out = ""
while min <= max do
out = out + min.to_s + " "
min = min + 1
end
out.slice!(out.length()-1)
puts out | # 石が200万個
# 0を含めて座標が-100万から100万まで
input = gets.chomp.split(" ")
k = input[0].to_i
x = input[1].to_i
min = x - (k-1)
max = x + (k-1)
out = ""
while min <= max do
out = out + min.to_s + " "
min = min + 1
end
out.slice!(out.length()-1)
puts out | [
"literal.string.change",
"assignment.value.change",
"call.arguments.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 745,727 | 745,726 | u486374018 | ruby |
p02947 | n = gets.to_i
s = Array(n){ gets.chomp.chars.sort}.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | n = gets.to_i
s = Array.new(n){ gets.chomp.bytes.sort }.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | [
"call.add",
"assignment.value.change",
"identifier.change"
] | 746,358 | 746,359 | u693378622 | ruby |
p02947 | n = gets.to_i
s = Array(n){ gets.chomp.chars.sort}.sort!
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | n = gets.to_i
s = Array.new(n){ gets.chomp.bytes.sort }.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | [
"call.add",
"assignment.value.change",
"identifier.change"
] | 746,360 | 746,359 | u693378622 | ruby |
p02947 | n = gets.to_i
s = Array(n){ gets.chomp.chars.sort}.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | n = gets.to_i
s = Array.new(n){ gets.chomp.chars.sort }.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | [
"call.add"
] | 746,358 | 746,361 | u693378622 | ruby |
p02947 | n = gets.to_i
s = Array(n){ gets.chomp.chars.sort}.sort!
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | n = gets.to_i
s = Array.new(n){ gets.chomp.chars.sort }.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | [
"call.add",
"assignment.value.change",
"identifier.change"
] | 746,360 | 746,361 | u693378622 | ruby |
p02947 | n = gets.to_i
s = Array(n){ gets.chomp.chars.sort}.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | n = gets.to_i
s = n.times.map{ gets.chomp.chars.sort }.sort
ans = 0
cnt = 0
n.times do |i|
if i == n - 1 or s[i] != s[i+1]
ans += (cnt+1)*cnt/2
cnt = 0
else
cnt += 1
end
end
puts ans | [
"call.remove",
"assignment.value.change",
"call.arguments.change",
"call.add"
] | 746,358 | 746,362 | u693378622 | ruby |
p02947 | N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.split.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.combination(2).size
end
puts count
| N = gets.to_i
s = Hash.new(-1)
count = 0
N.times do |i|
tmp = gets.chars.sort.join
s[tmp] += 1
end
s.each do |k, v|
count += (0..v).to_a.combination(2).size
end
puts count
| [
"assignment.value.change",
"identifier.change"
] | 746,557 | 746,558 | u729911058 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.