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 |
|---|---|---|---|---|---|---|---|
p03636 | s=gets
print s[0],s.size-3,s[-1] | s=gets
print s[0],s.size-3,s[-2] | [
"literal.number.integer.change",
"variable_access.subscript.index.change",
"call.arguments.change"
] | 1,326,001 | 1,326,002 | u172873334 | ruby |
p03636 | s = gets.chomp.chars
print s[0], s.size - 2, s[1], "\n" | s = gets.chomp.chars
print s[0], s.size - 2, s[-1], "\n" | [
"expression.operation.unary.add",
"call.arguments.change"
] | 1,326,063 | 1,326,064 | u785521224 | ruby |
p03636 | s = gets.chomp
first = s[0]
len = s.size
str = len - 2
last = s[len - 1]
puts first + str + last
| s = gets.chomp
first = s[0]
len = s.size
str = len - 2
last = s[len - 1]
puts first + str.to_s + last
| [
"call.add"
] | 1,326,340 | 1,326,341 | u151483411 | ruby |
p03636 | s = gets.chomp
puts s.length
puts "#{s[0]}#{s.length-2}#{s[s.length-1]}\n" | s = gets.chomp
puts "#{s[0]}#{s.length-2}#{s[s.length-1]}" | [
"call.remove",
"literal.string.change",
"call.arguments.change"
] | 1,326,344 | 1,326,345 | u306154131 | ruby |
p03636 | s = gets.chomp
puts s.length
puts "#{s[0]}#{s.length-2}#{s[s.length-1]}" | s = gets.chomp
puts "#{s[0]}#{s.length-2}#{s[s.length-1]}" | [
"call.remove"
] | 1,326,346 | 1,326,345 | u306154131 | ruby |
p03636 | h = gets.chomp
puts h[0] + (h.size-2).to_i + h[h.size-1]
| h = gets.chomp
puts h[0] + (h.size-2).to_s + h[h.size-1] | [
"call.function.change",
"type_conversion.to_string.change"
] | 1,326,347 | 1,326,348 | u677020059 | ruby |
p03636 | h = gets
print h[0]
print (h.size-2).to_i
puts h[h.size-1]
| h = gets.chomp
puts h[0] + (h.size-2).to_s + h[h.size-1] | [
"assignment.value.change",
"call.add",
"io.output.change"
] | 1,326,349 | 1,326,348 | u677020059 | ruby |
p03636 | h = gets
print h[0]
print (h.size-2).to_i
puts h[h.size-1]
| h = gets.chomp
print h[0]
print (h.size-2).to_i
puts h[h.size-1]
| [
"call.add"
] | 1,326,349 | 1,326,350 | u677020059 | ruby |
p03636 | h = gets
print h[0]
print (h.size-2)
puts h[h.size-1]
| h = gets.chomp
print h[0]
print (h.size-2).to_i
puts h[h.size-1]
| [
"call.add"
] | 1,326,351 | 1,326,350 | u677020059 | ruby |
p03636 | s = gets
a= s[0] + (s.length-2).to_s + s[-1]
puts a.to_s | s = gets.chomp
a= s[0] + (s.length-2).to_s + s[-1]
puts a.to_s | [
"call.add"
] | 1,326,434 | 1,326,435 | u974214237 | ruby |
p03636 | s = gets
a= s[0] + (s.length-2).to_s + s[s.length-1]
puts a.to_s
| s = gets.chomp
a= s[0] + (s.length-2).to_s + s[-1]
puts a.to_s | [
"call.add",
"call.remove"
] | 1,326,436 | 1,326,435 | u974214237 | ruby |
p03636 | s = gets
puts s[0]+(s.length-2).to_s+s[s.length-1] | s = gets.chomp.chars
puts s[0]+(s.length-2).to_s+s[s.length-1]
| [
"call.add"
] | 1,326,467 | 1,326,468 | u445624660 | ruby |
p03636 | s = gets
puts s[0] + s.slice(1..-2).size.to_s + s[-1] | s = gets.chomp!
puts s[0] + s.slice(1..-2).size.to_s + s[-1] | [
"call.add"
] | 1,326,485 | 1,326,486 | u617587005 | ruby |
p03636 | str = gets.chomp.split("")
puts str
puts "#{str[0]}" + "#{str.count-2}" + "#{str[str.count-1]}"
| str = gets.chomp.split("")
puts "#{str[0]}" + "#{str.count-2}" + "#{str[str.count-1]}"
| [
"call.remove"
] | 1,326,506 | 1,326,507 | u501869915 | ruby |
p03636 | s = gets
puts s[0] + (s.length-2).to_s + s[-1] | s = gets.chomp
puts s[0] + (s.length-2).to_s + s[-1] | [
"call.add"
] | 1,326,529 | 1,326,530 | u250000175 | ruby |
p03637 | n=gets.to_i
a=gets.split.map(&:to_i)
c4,c2,c1=0
a.each do |b|
if b%4==0
c4+=1
elsif b%2==0
c2+=1
else
c1+=1
end
end
if c4>=c1 || c1-c4==1 && c2==0
puts :Yes
else
puts :No
end
| n=gets.to_i
a=gets.split.map(&:to_i)
c4,c2,c1=0,0,0
a.each do |b|
if b%4==0
c4+=1
elsif b%2==0
c2+=1
else
c1+=1
end
end
if c4>=c1 || c1-c4==1 && c2==0
puts :Yes
else
puts :No
end
| [] | 1,326,598 | 1,326,599 | u744908753 | ruby |
p03636 | s = gets
puts s[0] + (s.length - 2 ).to_s + s[s.length-1] | s = gets.chomp
puts s[0] + (s.length - 2 ).to_s + s[-1] | [
"call.add",
"call.remove"
] | 1,326,703 | 1,326,704 | u214983738 | ruby |
p03636 | s = gets
print s[0] + (s.length - 2 ).to_s + s[-1] | s = gets.chomp
puts s[0] + (s.length - 2 ).to_s + s[-1] | [
"assignment.value.change",
"call.add",
"io.output.change"
] | 1,326,705 | 1,326,704 | u214983738 | ruby |
p03636 | s = gets
puts s[0] + (s.length - 2 ).to_s + s[-1] | s = gets.chomp
puts s[0] + (s.length - 2 ).to_s + s[-1] | [
"call.add"
] | 1,326,706 | 1,326,704 | u214983738 | ruby |
p03636 | s=gets;puts s[0]+(s.size-2).to_s+s[-2] | s=gets;puts s[0]+(s.size-3).to_s+s[-2] | [
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 1,326,707 | 1,326,708 | u079330987 | ruby |
p03636 | s=gets;puts s[0]+(s.size-3).to_s+s[-1] | s=gets;puts s[0]+(s.size-3).to_s+s[-2] | [
"literal.number.integer.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,326,709 | 1,326,708 | u079330987 | ruby |
p03636 | s = gets.chomp
puts(s[0] + (s.length - 2) + s[s.length - 1]) | s = gets.chomp
puts (s[0] + (s.length - 2).to_s + s[s.length - 1]) | [
"call.add"
] | 1,326,712 | 1,326,713 | u001025229 | ruby |
p03637 | n = gets.to_i
a = gets.chomp.split.map(&:to_i)
b2 = a.select { |item| item % 2 == 0 }.count
b4 = a.select { |item| item % 4 == 0 }.count
if b4*2 >= n || (b2/2)+b4 >= n/2
puts 'Yes'
else
puts 'No'
end
| n = gets.to_i
a = gets.chomp.split.map(&:to_i)
b2 = a.select { |item| item % 4 == 2 }.count
b4 = a.select { |item| item % 4 == 0 }.count
if b4*2 >= n || (b2/2)+b4 >= n/2
puts 'Yes'
else
puts 'No'
end
| [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,326,958 | 1,326,959 | u585819925 | ruby |
p03637 | n = gets.chomp.to_i
a = gets.split.map(&:to_i)
h = Hash.new(0)
a.each do |e|
if e % 4 == 0
h[4] += 1
elsif e % 2 == 0
h[2] += 1
else
h[1] += 1
end
end
if h[2] > 1
n -= h[2]
if h[4] >= n/2 + 1
puts 'Yes'
else
puts 'No'
end
else
if h[4] >= n/2
puts 'Yes'
else
puts 'No'
end
end
| n = gets.chomp.to_i
a = gets.split.map(&:to_i)
h = Hash.new(0)
a.each do |e|
if e % 4 == 0
h[4] += 1
elsif e % 2 == 0
h[2] += 1
else
h[1] += 1
end
end
if h[2] > 1
n -= h[2]
if h[4] >= (n/2.0).ceil
puts 'Yes'
else
puts 'No'
end
else
if h[4] >= n/2
puts 'Yes'
else
puts 'No'
end
end
| [
"control_flow.branch.if.condition.change",
"call.add"
] | 1,327,634 | 1,327,635 | u434509016 | ruby |
p03637 | N = gets.to_i
AS = gets.split.map(&:to_i)
n0 = n1 = n2 = 0
AS.each do |n|
if n % 4 == 0 then n2 += 1
elsif n % 2 == 0 then n1 += 1
else n0 += 1
end
end
if n2 >= N/2
puts "Yes"
elsif n1 >= N - (n2*2 + 1)
puts "Yes"
else
puts "No"
end
| N = gets.to_i
AS = gets.split.map(&:to_i)
n0 = n1 = n2 = 0
AS.each do |n|
if n % 4 == 0 then n2 += 1
elsif n % 2 == 0 then n1 += 1
else n0 += 1
end
end
if n2 >= N/2
puts "Yes"
elsif n1 >= N - (n2*2)
puts "Yes"
else
puts "No"
end
| [
"expression.operation.binary.remove"
] | 1,327,673 | 1,327,674 | u437302815 | ruby |
p03637 | N = gets.to_i
a = gets.split.map(&:to_i)
even = a.select(&:even?)
four = even.select {|i| i % 4 == 0 }
x = four.size
y = even.size - x
z = a.size - x - y
if x * 2 + 1 >= N || x * 2 + y >= N
puts "YES"
else
puts "NO"
end
| N = gets.to_i
a = gets.split.map(&:to_i)
even = a.select(&:even?)
four = even.select {|i| i % 4 == 0 }
x = four.size
y = even.size - x
z = a.size - x - y
if x * 2 + 1 >= N || x * 2 + y >= N
puts "Yes"
else
puts "No"
end
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,327,675 | 1,327,676 | u736611421 | ruby |
p03639 | N = gets.to_i
a = gets.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
print 'Yes'
else
p 'No'
end | N = gets.to_i
a = gets.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
print 'Yes'
else
print 'No'
end | [
"call.function.change",
"io.output.change"
] | 1,328,497 | 1,328,498 | u065618194 | ruby |
p03639 | N = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
p 'Yes'
else
p 'No'
end | N = gets.to_i
a = gets.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
print 'Yes'
else
print 'No'
end | [
"call.remove",
"call.function.change",
"io.output.change"
] | 1,328,499 | 1,328,498 | u065618194 | ruby |
p03639 | N = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
p 'Yes'
else
p 'No'
end | N = gets.to_i
a = gets.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
print 'Yes'
else
print 'No'
end | [
"call.remove",
"call.function.change",
"io.output.change"
] | 1,328,500 | 1,328,498 | u065618194 | ruby |
p03639 | N = gets.to_i
a = gets.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
p 'Yes'
else
p 'No'
end | N = gets.to_i
a = gets.split(' ').map(&:to_i)
o = 0
four = 0
a.each do |ai|
if ai.odd?
o += 1
elsif ai % 4 == 0
four += 1
end
end
if o <= four || 2 * four + 1 == N
print 'Yes'
else
print 'No'
end | [
"call.function.change",
"io.output.change"
] | 1,328,501 | 1,328,498 | u065618194 | ruby |
p03639 | n=gets.to_i
a=gets.split.map &:to_i
a1,a2,a4 = [a.count{|e|e%2==1},a.count{|e|e%4==2},a.count{|e|e%4==0}]
if a1>a4+[1,a2].min
puts :No
else
puts :Yes
end | n=gets.to_i
a=gets.split.map &:to_i
a1,a2,a4 = [a.count{|e|e%2==1},a.count{|e|e%4==2},a.count{|e|e%4==0}]
if a1>a4+1-[1,a2].min
puts :No
else
puts :Yes
end | [
"control_flow.branch.if.condition.change"
] | 1,328,860 | 1,328,861 | u554838392 | ruby |
p03639 | n=gets.to_i
a=gets.split.map &:to_i
a1,a2,a4 = [a.count{|e|e%2==1},a.count{|e|e%4==2},a.count{|e|e%4==0}]
if a1>a4+[1,a2].max
puts :No
else
puts :Yes
end | n=gets.to_i
a=gets.split.map &:to_i
a1,a2,a4 = [a.count{|e|e%2==1},a.count{|e|e%4==2},a.count{|e|e%4==0}]
if a1>a4+1-[1,a2].min
puts :No
else
puts :Yes
end | [
"control_flow.branch.if.condition.change",
"misc.opposites",
"identifier.change"
] | 1,328,862 | 1,328,861 | u554838392 | ruby |
p03644 | n = gets.to_i
max = 0
maxCnt = 0
(1..n).each do |val|
tmpCnt = 0
if val.odd?
next
else
calcVal = val
while calcVal.even?
calcVal /= 2
tmpCnt += 1
end
end
if tmpCnt > maxCnt
maxCnt = tmpCnt
max = val
end
end
puts max | n = gets.to_i
max = 1
maxCnt = 0
(1..n).each do |val|
tmpCnt = 0
if val.odd?
next
else
calcVal = val
while calcVal.even?
calcVal /= 2
tmpCnt += 1
end
end
if tmpCnt > maxCnt
maxCnt = tmpCnt
max = val
end
end
puts max | [
"literal.number.integer.change",
"assignment.value.change"
] | 1,330,553 | 1,330,554 | u994502918 | ruby |
p03644 | require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
return bool ? y : n
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
if n==1
return Array.new(size){init}
else
return Array.new(n).map{Array.new(size){init}}
end
end
n=gets.to_i
max=1
ans=1
for i in 2..n
count=i.prime_division
if count[0][0]==2 and count[0][1]>max
max=count[0][1]
ans=i
end
end
puts ans | require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
return bool ? y : n
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
if n==1
return Array.new(size){init}
else
return Array.new(n).map{Array.new(size){init}}
end
end
n=gets.to_i
max=1
ans=1
for i in 2..n
count=i.prime_division
if count[0][0]==2 and count[0][1]>=max
max=count[0][1]
ans=i
end
end
puts ans | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,331,117 | 1,331,118 | u415400221 | ruby |
p03644 | n = gets.chomp.to_i
ret = 0
(1..n).each do |i|
break if 2 ** i > n
ret = 2 ** i
end
puts ret
| n = gets.chomp.to_i
ret = 0
(0..n-1).each do |i|
break if 2 ** i > n
ret = 2 ** i
end
puts ret
| [
"literal.number.integer.change"
] | 1,331,137 | 1,331,138 | u104678771 | ruby |
p03637 | eval"N,*A="+(dd).split*?,;g=0;A.map{|a|g+=1[a%4]+1[a%2]};puts g/2>=N/2?:Yes: :No | eval"N,*A="+`dd`.split*?,;g=0;A.map{|a|g+=1[a%4]+1[a%2]};puts g/2>=N/2?:Yes: :No | [
"call.arguments.change",
"expression.operation.binary.change"
] | 1,331,223 | 1,331,224 | u032223772 | ruby |
p03644 | n = gets.chomp.to_i
ans = 1
while n > ans
if n < ans*2
puts ans
break
else
ans *= 2
end
end
| n = gets.chomp.to_i
ans = 1
while n >= ans
if n < ans*2
puts ans
break
else
ans *= 2
end
end
| [
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 1,331,386 | 1,331,387 | u928941036 | ruby |
p03644 | n = gets.to_i
max = 0
array = []
(1..n).each do |num|
cnt = 0
while true do
if num % 2 == 0
cnt += 1
num /= 0
else
break
end
end
array.push(cnt)
end
puts 2** array.max | n = gets.to_i
array = []
(1..n).each do |num|
cnt = 0
while true
if num % 2 == 0
cnt += 1
num /= 2
else
break
end
end
array.push(cnt)
end
puts 2** array.max | [
"literal.number.integer.change"
] | 1,331,413 | 1,331,414 | u809809975 | ruby |
p03644 | n = gets.to_i
array = []
(1..n).each do |num|
cnt = 0
while true do
if num % 2 == 0
cnt += 1
num /= 0
else
break
end
end
array.push(cnt)
end
puts 2** array.max | n = gets.to_i
array = []
(1..n).each do |num|
cnt = 0
while true
if num % 2 == 0
cnt += 1
num /= 2
else
break
end
end
array.push(cnt)
end
puts 2** array.max | [
"literal.number.integer.change"
] | 1,331,415 | 1,331,414 | u809809975 | ruby |
p03644 | n = gets.to_i
max = 0
array = []
(1..n).each do |num|
cnt = 0
while true do
if num % 2 == 0
cnt += 1
num /= 0
else
break
end
end
array.push(cnt)
end
puts 2** array.max | n = gets.to_i
array = []
(1..n).each do |num|
cnt = 0
while true do
if num % 2 == 0
cnt += 1
num /= 2
else
break
end
end
array.push(cnt)
end
puts 2** array.max | [
"literal.number.integer.change"
] | 1,331,413 | 1,331,416 | u809809975 | ruby |
p03644 | n = gets.to_i
array = []
(1..n).each do |num|
cnt = 0
while true do
if num % 2 == 0
cnt += 1
num /= 0
else
break
end
end
array.push(cnt)
end
puts 2** array.max | n = gets.to_i
array = []
(1..n).each do |num|
cnt = 0
while true do
if num % 2 == 0
cnt += 1
num /= 2
else
break
end
end
array.push(cnt)
end
puts 2** array.max | [
"literal.number.integer.change"
] | 1,331,415 | 1,331,416 | u809809975 | ruby |
p03644 | n = gets.chomp.to_i
for i in 0..n
if 2**i > n
print(2**(i- 1))
end
end | n = gets.chomp.to_i
for i in 0..n
if 2**i > n
print(2**(i- 1))
exit()
end
end | [
"call.add"
] | 1,331,507 | 1,331,508 | u691896522 | ruby |
p03644 | p [*2..(gets.to_i)].select{|i|
tmp = i
while true
break if (tmp%2)!=0
tmp/=2
end
next tmp==1 ? 1 : -1
}[-1] | p [*1..(gets.to_i)].select{|i|
tmp = i
while true
break if (tmp%2)!=0
tmp/=2
end
next tmp==1 ? true : false
}[-1] | [
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.unary.remove"
] | 1,331,521 | 1,331,522 | u630043039 | ruby |
p03644 | n = gets.to_i
ans = 128
until ans < n do
ans /= 2
end
puts ans |
n = gets.to_i
ans = 128
while ans > n do
ans /= 2
end
puts ans | [
"control_flow.loop.while.condition.change",
"misc.opposites",
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 1,331,766 | 1,331,767 | u802039083 | ruby |
p03644 | num = gets.to_i
puts num
ans = 1
if 2<=num && num<4 then
ans = 2
elsif 4<=num && num<8 then
ans = 4
elsif 8<=num && num<16 then
ans = 8
elsif 16<=num && num<32 then
ans = 16
elsif 32<=num && num<64 then
ans = 32
elsif 64<=num then
ans = 64
end
puts ans | num = gets.to_i
ans = 1
if 2<=num && num<4 then
ans = 2
elsif 4<=num && num<8 then
ans = 4
elsif 8<=num && num<16 then
ans = 8
elsif 16<=num && num<32 then
ans = 16
elsif 32<=num && num<64 then
ans = 32
elsif 64<=num then
ans = 64
end
puts ans | [
"call.remove"
] | 1,332,070 | 1,332,071 | u656481579 | ruby |
p03644 | # 正整数 N が与えられるので、
# 1 以上 N 以下の整数のうち、最も 2 で割れる回数が多いものを求めてください。
n = gets.chomp.to_i
check_num, check_val = 1, 1
(1..n).each do |v|
next if (v%2) != 0
num, test = 0, v
while test > 1
test = test/2
num += 1
end
if check_num < num
check_num = num
check_val = v
end
end
p check_val | # 正整数 N が与えられるので、
# 1 以上 N 以下の整数のうち、最も 2 で割れる回数が多いものを求めてください。
n = gets.chomp.to_i
check_num, check_val = 0, 1
(1..n).each do |v|
next if (v%2) != 0
num, test = 0, v
while test > 1
test = test/2
num += 1
end
if check_num < num
check_num = num
check_val = v
end
end
p check_val | [
"literal.number.integer.change",
"assignment.value.change"
] | 1,332,124 | 1,332,125 | u496981480 | ruby |
p03644 | n = gets.to_i
i=1
while i<n
i*=2
end
puts i | n = gets.to_i
i=1
while i*2<=n do
i*=2
end
puts i | [
"expression.operation.binary.change"
] | 1,332,214 | 1,332,215 | u374190629 | ruby |
p03644 | n = gets.to_i
ans = [1, 1]
for i in 1..n do
x = i
count = 0
while (i % 2).zero?
i = i / 2
count += 1
end
if count > ans[1]
ans[0] = x
ans[1] = count
end
end
puts ans[0] | n = gets.to_i
ans = [1, 1]
for i in 1..n do
x = i
count = 0
while (i % 2).zero?
i = i / 2
count += 1
end
if count >= ans[1]
ans[0] = x
ans[1] = count
end
end
puts ans[0] | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,332,222 | 1,332,223 | u239218660 | ruby |
p03644 | n = gets.to_i
count = 0
max_count = 0
max_num = 0
original_num = 0
1.upto(n) do |num|
original_num = num
while num.even?
num /= 2
count += 1
end
if max_count < count
max_count = count
max_num = original_num
end
count = 0
end
puts max_num | n = gets.to_i
count = 0
max_count = 0
max_num = 1
original_num = 0
1.upto(n) do |num|
original_num = num
while num.even?
num /= 2
count += 1
end
if max_count < count
max_count = count
max_num = original_num
end
count = 0
end
puts max_num | [
"literal.number.integer.change",
"assignment.value.change"
] | 1,332,504 | 1,332,505 | u653737129 | ruby |
p03644 | n = gets.to_i
cnt = -1
max_n = 0
(1..n).each do |i|
next unless i.even?
c = 0
_i = i
while _i.even? do
_i /= 2
c += 1
end
if c > cnt
cnt = c
max_n = i
end
end
puts max_n | n = gets.to_i
cnt = -1
max_n = 1
(1..n).each do |i|
next unless i.even?
c = 0
_i = i
while _i.even? do
_i /= 2
c += 1
end
if c > cnt
cnt = c
max_n = i
end
end
puts max_n | [
"literal.number.integer.change",
"assignment.value.change"
] | 1,332,730 | 1,332,731 | u647522078 | ruby |
p03644 | n=gets.to_i
puts 2**(100.times.find{|x|2**x <= n}) | n=gets.to_i
puts 2**(100.times.select{|x|2**x<=n}.max) | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"call.add"
] | 1,332,739 | 1,332,740 | u056944756 | ruby |
p03644 | N = gets.split.map(&:to_i)
i = 1
while true
if(i >= N[0])
if(N[0] == 1)
puts("1")
break
end
puts("#{i/2}")
break
end
i = i*2
end | N = gets.split.map(&:to_i)
i = 1
while true
if(i > N[0])
if(N[0] == 1)
puts("1")
break
end
puts("#{i/2}")
break
end
i = i*2
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,332,749 | 1,332,750 | u053324284 | ruby |
p03644 | N = gets.split.map(&:to_i)
i = 1
while true
if(i >= N[0])
if(N[0] = 1)
puts("1")
break
end
puts("#{i/2}")
break
end
i = i*2
end | N = gets.split.map(&:to_i)
i = 1
while true
if(i > N[0])
if(N[0] == 1)
puts("1")
break
end
puts("#{i/2}")
break
end
i = i*2
end | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 1,332,751 | 1,332,750 | u053324284 | ruby |
p03644 | N = gets.to_i
result = 1
while result <= n
result = result*2
end
puts result/2 | N = gets.to_i
result = 1
while result <= N
result = result*2
end
puts result/2 | [
"expression.operation.binary.change"
] | 1,332,944 | 1,332,945 | u416438774 | ruby |
p03644 | #encoding: utf-8
num = 1;
inputNum = STDIN.gets.to_i;
num *= 2 until num > inputNum
STDOUT.puts x / 2; | #encoding: utf-8
num = 1;
inputNum = STDIN.gets.to_i;
num *= 2 until num > inputNum
STDOUT.puts num / 2; | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,332,948 | 1,332,949 | u989352561 | ruby |
p03644 | n = gets.to_i
answer = 1
while answer * 2 < n do
answer *= 2
end
print answer
| n = gets.to_i
answer = 1
while answer * 2 <= n do
answer *= 2
end
print answer
| [
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 1,333,045 | 1,333,046 | u848783748 | ruby |
p03645 | n,m = gets.chomp.split(' ').map(&:to_i)
hoge = []
fuga = []
m.times do
a,b = gets.chomp.split(' ').map(&:to_i)
if (a == 1)
hoge << b
elsif (b == 5)
fuga << a
end
end
puts (hoge & fuga).length > 0 ? 'POSSIBLE' : 'IMPOSSIBLE' | n,m = gets.chomp.split(' ').map(&:to_i)
hoge = []
fuga = []
m.times do
a,b = gets.chomp.split(' ').map(&:to_i)
if (a == 1)
hoge << b
elsif (b == n)
fuga << a
end
end
puts (hoge & fuga).length > 0 ? 'POSSIBLE' : 'IMPOSSIBLE' | [
"identifier.replace.add",
"literal.replace.remove",
"control_flow.branch.if.condition.change"
] | 1,333,216 | 1,333,217 | u546441021 | ruby |
p03645 | n, m = gets.split.map(&:to_i)
firsts = []
lasts = []
m.times.map do
a, b = gets.split.map(&:to_i)
firsts << b if a == 1
lasts << a if b == n
end
puts [firsts & lasts].empty? ? "IMPOSSIBLE" : "POSSIBLE"
| n, m = gets.split.map(&:to_i)
firsts = []
lasts = []
m.times.map do
a, b = gets.split.map(&:to_i)
firsts << b if a == 1
lasts << a if b == n
end
puts (firsts & lasts).empty? ? "IMPOSSIBLE" : "POSSIBLE"
| [
"control_flow.branch.if.condition.change"
] | 1,333,356 | 1,333,357 | u889326464 | ruby |
p03644 | n=k=gets.to_i;n=k while n>k=n&-n;p n | n=k=gets.to_i;n-=k while n>k=n&-n;p n | [
"assignment.value.change"
] | 1,333,565 | 1,333,566 | u280667879 | ruby |
p03645 | n, m = gets.split.map(&:to_i)
isl = {}
m.times do
i, j = gets.split.map(&:to_i)
[[i, j], [j, i]].each do |k, l|
if [1, n].include? k
if isl[l]
puts 'POSSIBLE'
exit
end
isl[l] = true
end
end
end
puts 'INPOSSIBLE'
| n, m = gets.split.map(&:to_i)
isl = {}
m.times do
i, j = gets.split.map(&:to_i)
[[i, j], [j, i]].each do |k, l|
if [1, n].include? k
if isl[l]
puts 'POSSIBLE'
exit
end
isl[l] = true
end
end
end
puts 'IMPOSSIBLE'
| [
"literal.string.change",
"call.arguments.change"
] | 1,333,993 | 1,333,994 | u214983738 | ruby |
p03651 | N,K,*A=(dd).split.map &:to_i;puts"#{:IM if K%A.reduce(:gcd)>0||K>A.max}POSSIBLE" | N,K,*A=`dd`.split.map &:to_i;puts"#{:IM if K%A.reduce(:gcd)>0||K>A.max}POSSIBLE" | [
"assignment.value.change"
] | 1,336,213 | 1,336,214 | u032223772 | ruby |
p03651 | # https://atcoder.jp/contests/agc018/tasks/agc018_a
n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
gcd = nums[0]
nums.each { |i| gcd = gcd.gcd(i) }
max = nums.max
diff = (max - k).abs
puts diff % gcd == 0 ? 'POSSIBLE' : 'IMPOSSIBLE' | # https://atcoder.jp/contests/agc018/tasks/agc018_a
n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
gcd = nums[0]
nums.each { |i| gcd = gcd.gcd(i) }
max = nums.max
diff = (max - k).abs
puts diff % gcd == 0 && max >= k ? 'POSSIBLE' : 'IMPOSSIBLE' | [
"control_flow.branch.if.condition.change"
] | 1,336,268 | 1,336,269 | u624505752 | ruby |
p03652 | N, M = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }
open_event = Array.new(N + 1, true)
ans = N
(M - 1).times do
stop_event_id = -1
counter = Hash.new(0)
max_cnt = 0
N.times do |i|
event_id = A[i].find { |a| open_event[a] }
counter[event_id] += 1
if max_cnt < counter[event_id]
max_cnt = counter[event_id]
stop_event_id = event_id
end
end
ans = max_cnt if ans > max_cnt
if stop_event_id != -1
open_event[stop_event_id] = false
end
end
puts ans
| N, M = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }
open_event = Array.new(M + 1, true)
ans = N
(M - 1).times do
stop_event_id = -1
counter = Hash.new(0)
max_cnt = 0
N.times do |i|
event_id = A[i].find { |a| open_event[a] }
counter[event_id] += 1
if max_cnt < counter[event_id]
max_cnt = counter[event_id]
stop_event_id = event_id
end
end
ans = max_cnt if ans > max_cnt
if stop_event_id != -1
open_event[stop_event_id] = false
end
end
puts ans
| [
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,337,049 | 1,337,050 | u740836226 | ruby |
p03652 | require 'pp'
IS_DEBUG = true
# IS_DEBUG = false
def dputs str
if(IS_DEBUG)
puts str
end
end
def dpp str
if(IS_DEBUG)
pp str
end
end
N,M = gets.chomp.split(' ').map{|n| n.to_i}
row=N
col=M
A=Array.new(row){Array.new(col)}
0.upto(row-1){|i|
A[i]=gets.chomp.split(' ').map{|n| n.to_i}
}
F=Array.new(col+1){true}
def calc(a,f)
h = {}
a.each{|l|
l.each{|v|
if(f[v])
h[v].nil? ? h[v]=1 : h[v]+=1
break
end
}
}
h.max{|a,b| a[1] <=> b[1]}
end
minval = N+1
for i in 0..(M-1)
key,val = calc(A,F)
minval > val ? minval = val : val
F[key] = false
dputs "#{key},#{val}"
end
puts minval
| require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
if(IS_DEBUG)
puts str
end
end
def dpp str
if(IS_DEBUG)
pp str
end
end
N,M = gets.chomp.split(' ').map{|n| n.to_i}
row=N
col=M
A=Array.new(row){Array.new(col)}
0.upto(row-1){|i|
A[i]=gets.chomp.split(' ').map{|n| n.to_i}
}
F=Array.new(col+1){true}
def calc(a,f)
h = {}
a.each{|l|
l.each{|v|
if(f[v])
h[v].nil? ? h[v]=1 : h[v]+=1
break
end
}
}
h.max{|a,b| a[1] <=> b[1]}
end
minval = N+1
for i in 0..(M-1)
key,val = calc(A,F)
minval > val ? minval = val : val
F[key] = false
dputs "#{key},#{val}"
end
puts minval
| [
"misc.opposites",
"assignment.value.change"
] | 1,337,210 | 1,337,211 | u415591191 | ruby |
p03657 | a, b = gets.chomp.split(" ").map(&:to_i)
ans = a % 3 == 0 || b % 3 == 0 || a+b % 3 == 0
puts ans ? "Possible" : "Impossible" | a, b = gets.chomp.split(" ").map(&:to_i)
ans = a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0
puts ans ? "Possible" : "Impossible" | [] | 1,338,138 | 1,338,139 | u466332671 | ruby |
p03657 | a,b=gets.split.map(&:to_i)
puts (a+b%3==0 || a%3==0 || b%3==0)? "Possible" : "Impossible" | a,b=gets.split.map(&:to_i)
puts ((a+b)%3==0 || a%3==0 || b%3==0)? "Possible" : "Impossible" | [
"control_flow.branch.if.condition.change"
] | 1,338,180 | 1,338,181 | u085647568 | ruby |
p03657 | A, B = gets.chomp.split(" ").map(:to_i)
if A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0 then
puts "Possible"
else
puts "Impossible"
end | A, B = gets.chomp.split(" ").map(&:to_i)
if A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0 then
puts "Possible"
else
puts "Impossible"
end | [
"call.arguments.change"
] | 1,338,355 | 1,338,356 | u339791405 | ruby |
p03657 | a, b = gets.split.map(&:to_i)
if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0
puts 'Possible'
else
puts 'Inpossible'
end | a, b = gets.split.map(&:to_i)
if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0
puts 'Possible'
else
puts 'Impossible'
end | [
"literal.string.change",
"call.arguments.change"
] | 1,338,357 | 1,338,358 | u039293076 | ruby |
p03657 | s = gets.chomp
a,b = s.split(" ")
a = a.to_i
b = b.to_i
if a%3 == 0 || b%3 == 0 || (a+b)%3 == 0
puts "Possible"
else
puts "Inpossible"
end | s = gets.chomp
a,b = s.split(" ")
a = a.to_i
b = b.to_i
if a%3 == 0 || b%3 == 0 || (a+b)%3 == 0
puts "Possible"
else
puts "Impossible"
end | [
"literal.string.change",
"call.arguments.change"
] | 1,338,457 | 1,338,458 | u145950990 | ruby |
p03657 | A,B = gets.to_i
if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0
puts("Possible")
else puts("Impossible")
end | A,B = gets.split.map(&:to_i)
if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0
puts("Possible")
else puts("Impossible")
end
| [
"assignment.value.change",
"identifier.change",
"call.add"
] | 1,338,736 | 1,338,737 | u241469130 | ruby |
p03657 | A,B = `dd`.split.map &:to_i
puts [A,B,A+B].include?{ |a| a % 3 == 0 } ? "Possible" : "Impossible" | A,B = `dd`.split.map &:to_i
puts [A,B,A+B].any?{ |a| a % 3 == 0 } ? "Possible" : "Impossible" | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,338,787 | 1,338,788 | u670503797 | ruby |
p03657 | a,b = gets.split.map(&:to_i)
if a + b % 3 == 0 || a % 3 == 0 || b % 3 == 0
puts "Possible"
else
puts "Impossible"
end | a,b = gets.split.map(&:to_i)
if (a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0
puts "Possible"
else
puts "Impossible"
end | [
"control_flow.branch.if.condition.change"
] | 1,338,799 | 1,338,800 | u502774641 | ruby |
p03657 | a,b = get.chomp.split.map(&:to_i)
puts a*b*(a+b)%3 == 0 ? 'Possible' : 'Impossible' | a,b = gets.chomp.split.map(&:to_i)
puts a*b*(a+b)%3 == 0 ? 'Possible' : 'Impossible' | [
"assignment.value.change",
"identifier.change"
] | 1,338,898 | 1,338,899 | u939552576 | ruby |
p03657 | a,b=gets.split
a=a.to_i
b=b.to_i
c=a+b
if a%3==0 || b%3==0 || c%3==0
puts "POSSIBLE"
else puts "IMPOSSIBLE"
end | a,b=gets.split
a=a.to_i
b=b.to_i
c=a+b
if a%3==0 || b%3==0 || c%3==0
puts "Possible"
else puts "Impossible"
end | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,339,142 | 1,339,143 | u506544056 | ruby |
p03657 | A, B = gets.split.map(&:to_i)
puts (A % 3 == 0 or B % 3 == 0 or (A + B) % 3) == 0 ? 'Possible' : 'Impossible' | A, B = gets.split.map(&:to_i)
puts (A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0) ? 'Possible' : 'Impossible' | [
"control_flow.branch.if.condition.change"
] | 1,339,158 | 1,339,159 | u304198114 | ruby |
p03657 | a, b = gets.chomp.split.map(&:to_i)
if a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0
puts 'Possible'
else
puts 'Possible'
end
| a, b = gets.chomp.split.map(&:to_i)
if a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0
puts 'Possible'
else
puts 'Impossible'
end
| [
"literal.string.change",
"call.arguments.change"
] | 1,339,243 | 1,339,244 | u336462267 | ruby |
p03658 | n, k = gets.strip.split.map(&:to_i)
array = gets.split("").map(&:to_i).sort.reverse
count = 0
array[0..(k - 1)].each do |i|
count += i
end
puts count | n, k = gets.strip.split.map(&:to_i)
array = gets.split.map(&:to_i).sort.reverse
count = 0
array[0..(k - 1)].each do |i|
count += i
end
puts count | [
"call.arguments.change"
] | 1,339,385 | 1,339,386 | u514143079 | ruby |
p03658 | n,k=gets.split.map(&:to_i)
puts gets.split.map(&:to_i).sort[0..k-1].inject(:+)
| n,k=gets.split.map(&:to_i)
puts gets.split.map(&:to_i).sort.reverse[0..k-1].inject(:+) | [
"call.add"
] | 1,339,456 | 1,339,457 | u085647568 | ruby |
p03658 | n,k=gets.split.map(&:to_i)
array=gets.split.map(&:to_i).sort[0..k-1].inject(:+)
| n,k=gets.split.map(&:to_i)
puts gets.split.map(&:to_i).sort.reverse[0..k-1].inject(:+) | [
"call.add"
] | 1,339,458 | 1,339,457 | u085647568 | ruby |
p03658 | n,k=gets.split.map(&:to_i)
l = gets.split(" ").map(&:to_i).sort.reverse[0..k]
puts l.inject(:+) | n,k=gets.split.map(&:to_i)
l = gets.split(" ").map(&:to_i).sort.reverse[0...k]
puts l.inject(:+) | [] | 1,339,611 | 1,339,612 | u374190629 | ruby |
p03658 | n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
p a
p a[-k..-1].inject(:+)
| n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
p a[-k..-1].inject(:+)
| [
"call.remove"
] | 1,339,681 | 1,339,682 | u875730451 | ruby |
p03658 | N,K = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
def swap(a,i,j)
tmp = a[i]
a[i] = a[j]
a[j] = tmp
return a
end
def bubble(a,k)
for i in 0..(k-2)
if a[i] > a[i+1]
swap(a,i,i+1)
end
return a
end
end
def bubble_sort(a)
k = a.length
while k > 1
bubble(a,k)
k = k-1
end
return a
end
bubble_sort(l)
sum = 0
for i in (N-K)..(N-1)
sum = sum + l[i]
end
puts(sum) | N,K = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
def swap(a,i,j)
tmp = a[i]
a[i] = a[j]
a[j] = tmp
return a
end
def bubble(a,k)
for i in 0..(k-2)
if a[i] > a[i+1]
swap(a,i,i+1)
end
end
return a
end
def bubble_sort(a)
k = a.length
while k > 1
bubble(a,k)
k = k-1
end
return a
end
bubble_sort(l)
sum = 0
for i in (N-K)..(N-1)
sum = sum + l[i]
end
puts(sum) | [] | 1,339,768 | 1,339,769 | u241469130 | ruby |
p03658 | N, K = gets.chomp.split(" ").map(&:to_i)
l = gets.chomp.split(" ").map(&:to_i)
Nsort = N.sort{|a,b| b<=>a}
total = 0
K.times do |i|
total += Nsort[i]
end
puts total | N, K = gets.chomp.split(" ").map(&:to_i)
Length = gets.chomp.split(" ").map(&:to_i)
Nsort = Length.sort{|a,b| b<=>a}
total = 0
K.times do |i|
total += Nsort[i]
end
puts total | [
"assignment.variable.change",
"assignment.value.change"
] | 1,339,857 | 1,339,858 | u151483411 | ruby |
p03658 | N, K = gets.split(' ').map(&:to_i)
gets.split(' ').map(&:to_i).sort.slice(l.length - K, K).inject(&:+) | N, K = gets.split(' ').map(&:to_i)
l = gets.split(' ').map(&:to_i)
p l.sort.slice(l.length - K, K).inject(&:+) | [
"call.add"
] | 1,339,958 | 1,339,959 | u065618194 | ruby |
p03659 | n=gets.to_i
a=gets.split.map(&:to_i)
sum=[a[0]]
all=a.sum
ans=2*a[0]-all
if n-1>2
(1...n-1).each do |i|
sum[i]=sum[i-1]+a[i]
ans=[ans,(sum[i]-all+sum[i]).abs].min
end
end
p ans
| n=gets.to_i
a=gets.split.map(&:to_i)
sum=[a[0]]
all=a.sum
ans=(2*a[0]-all).abs
if n-1>2
(1...n-1).each do |i|
sum[i]=sum[i-1]+a[i]
ans=[ans,(sum[i]-all+sum[i]).abs].min
end
end
p ans
| [
"call.add"
] | 1,340,040 | 1,340,041 | u966810027 | ruby |
p03659 | n=gets.to_i
a=gets.split.map(&:to_i)
sum=[a[0]]
all=a.sum
ans=2*a[0]-all
if n-1>1
(1...n-1).each do |i|
sum[i]=sum[i-1]+a[i]
ans=[ans,(sum[i]-all+sum[i]).abs].min
end
end
p ans
| n=gets.to_i
a=gets.split.map(&:to_i)
sum=[a[0]]
all=a.sum
ans=(2*a[0]-all).abs
if n-1>2
(1...n-1).each do |i|
sum[i]=sum[i-1]+a[i]
ans=[ans,(sum[i]-all+sum[i]).abs].min
end
end
p ans
| [
"call.add",
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,340,042 | 1,340,041 | u966810027 | ruby |
p03659 | n=gets.to_i
a=gets.split.map(&:to_i)
index=0
v=a.inject(&:+)
result=[]
left=0
while index<=a.length-1
left+=a[index]
right=v-left
result<<(right-left).abs
index+=1
end
p result.min | n=gets.to_i
a=gets.split.map(&:to_i)
index=0
v=a.inject(&:+)
result=[]
left=0
while index<=a.length-2
left+=a[index]
right=v-left
result<<(left-right).abs
index+=1
end
p result.min | [
"literal.number.integer.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 1,340,328 | 1,340,329 | u590472228 | ruby |
p03659 | N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
all = A.inject(:+)
wk = A[0]
ans = (all - 2 * wk).abs
(1..(A.size-2)).each{|i|
wk += A[i]
tmp = (all - 2 * wk).abs
if ans > tmp then
ans = tmp
else
break
end
}
puts ans
| N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
all = A.inject(:+)
wk = A[0]
ans = (all - 2 * wk).abs
(1..(A.size-2)).each{|i|
wk += A[i]
tmp = (all - 2 * wk).abs
if ans > tmp then
ans = tmp
end
}
puts ans
| [
"control_flow.break.remove"
] | 1,340,658 | 1,340,659 | u276517671 | ruby |
p03659 | N = gets.to_i
A = gets.split.map(&:to_i)
sum = A.inject(&:+)
min = 10 ** 9 + 1
s = 0
0.upto(N - 1) do |i|
s = s + A[i]
a = sum - s
min = (s - a).abs < min ? (s - a).abs : min
end
puts min | N = gets.to_i
A = gets.split.map(&:to_i)
sum = A.inject(&:+)
min = 10 ** 9 * 2 + 1
s = 0
0.upto(N - 2) do |i|
s = s + A[i]
a = sum - s
min = (s - a).abs < min ? (s - a).abs : min
end
puts min | [
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,340,662 | 1,340,661 | u039293076 | ruby |
p03659 | n = gets.to_i
a = gets.split(' ').map{ |a| a.to_i }
sunuke = 0
arai = a.inject(:+)
ans = Array.new(n, 2* 10 ** 5)
n.times do |i|
v = a.shift
break if a.empty?
sunuke += v
arai -= v
ans[i] = (sunuke - arai).abs
end
puts ans.min
| n = gets.to_i
a = gets.split(' ').map{ |a| a.to_i }
sunuke = 0
arai = a.inject(:+)
ans = Array.new(n, Float::INFINITY)
n.times do |i|
v = a.shift
break if a.empty?
sunuke += v
arai -= v
ans[i] = (sunuke - arai).abs
end
puts ans.min
| [
"expression.operation.binary.remove"
] | 1,341,489 | 1,341,490 | u698501698 | ruby |
p03659 | n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
s = 0
n.times{|i| s += a[i]}
min = 4 * 1e+9
x = 0
n.times do |i|
x += a[i]
y = s - x
min = [min, (x - y).abs].min
end
puts min.to_s | n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
s = 0
n.times{|i| s += a[i]}
min = 4 * 1e+9
x = 0
(n - 1).times do |i|
x += a[i]
y = s - x
min = [min, (x - y).abs].min
end
puts min.to_s | [] | 1,341,631 | 1,341,632 | u198355306 | ruby |
p03657 | sh = 3
a, b = gets.split.map{|x| x.to_i}
ab = a + b
if a % sh == 0 or b % sh == 0 or ab % sh ==0
puts "Posible"
else
puts "Impossible"
end
| sh = 3
a, b = gets.split.map{|x| x.to_i}
ab = a + b
if a % sh == 0 or b % sh == 0 or ab % sh ==0
puts "Possible"
else
puts "Impossible"
end
| [
"literal.string.change",
"call.arguments.change"
] | 1,341,691 | 1,341,692 | u428012835 | ruby |
p03659 | n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
sum = a.inject(&:+)
x = Array.new(n)
x[0] = a[0]
ans = (x[0] * 2 - sum).abs
for i in 1..n-1
x[i] = x[i-1] + a[i]
ans = (x[i] * 2 - sum).abs if ans > (x[i] * 2 - sum).abs
end
puts ans
| n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
sum = a.inject(&:+)
x = Array.new(n)
x[0] = a[0]
ans = (x[0] * 2 - sum).abs
for i in 1..n-2
x[i] = x[i-1] + a[i]
ans = (x[i] * 2 - sum).abs if ans > (x[i] * 2 - sum).abs
end
puts ans
| [
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,341,869 | 1,341,870 | u868089307 | ruby |
p03659 | n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
sum = a.inject(&:+)
x = Array.new(n)
x[0] = a[0]
ans = (x[0] * 2 - sum).abs
for i in 1..n-1
x[i] = x[i-1] + a[i-1]
ans = (x[i] * 2 - sum).abs if ans > (x[i] * 2 - sum).abs
end
puts ans
| n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
sum = a.inject(&:+)
x = Array.new(n)
x[0] = a[0]
ans = (x[0] * 2 - sum).abs
for i in 1..n-2
x[i] = x[i-1] + a[i]
ans = (x[i] * 2 - sum).abs if ans > (x[i] * 2 - sum).abs
end
puts ans
| [
"literal.number.integer.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 1,341,871 | 1,341,870 | u868089307 | ruby |
p03659 | a=gets.to_i
array=gets.split.map(&:to_i)
kei=0
j=0
a.times{
kei+=array[j]
j=j+1
}
array2=[]
i=0
answer=0
(a-1).times{
answer=answer+array[i]
array2<<(2*answer-kei).abs
i=i+1
}
p array2
puts array2.min | a=gets.to_i
array=gets.split.map(&:to_i)
kei=0
j=0
a.times{
kei+=array[j]
j=j+1
}
array2=[]
i=0
answer=0
(a-1).times{
answer=answer+array[i]
array2<<(2*answer-kei).abs
i=i+1
}
puts array2.min | [
"call.remove"
] | 1,341,967 | 1,341,968 | u506544056 | ruby |
p03659 | a=gets.to_i
array=gets.split.map(&:to_i)
kei=0
j=0
a.times{
kei+=array[j]
j=j+1
}
array2=[]
i=0
answer=0
a.times{
answer=answer+array[i]
array2<<(2*answer-kei).abs
i=i+1
}
puts array2.min | a=gets.to_i
array=gets.split.map(&:to_i)
kei=0
j=0
a.times{
kei+=array[j]
j=j+1
}
array2=[]
i=0
answer=0
(a-1).times{
answer=answer+array[i]
array2<<(2*answer-kei).abs
i=i+1
}
puts array2.min | [] | 1,341,969 | 1,341,968 | u506544056 | ruby |
p03659 | io = STDIN
n=io.gets.to_i
aa=io.gets.split.map(&:to_i)
sum=aa.inject(:+)
x,y=aa[0],sum-aa[0]
min=Float::INFINITY
if aa.size==2
puts x>y ? x-y : y-x
else
(1...(aa.size)).each do |i|
x+=aa[i]
y-=aa[i]
min=[min, x>y ? x-y : y-x ].min
end
end
puts min
| io = STDIN
n=io.gets.to_i
aa=io.gets.split.map(&:to_i)
sum=aa.inject(:+)
x,y=aa[0],sum-aa[0]
min=Float::INFINITY
if aa.size==2
min= x>y ? x-y : y-x
else
(1...(aa.size-1)).each do |i|
x+=aa[i]
y-=aa[i]
min=[min, x>y ? x-y : y-x ].min
end
end
puts min
| [
"assignment.variable.change"
] | 1,342,015 | 1,342,016 | u132360211 | ruby |
p03659 | n,*a=`dd`.split.map &:to_i
(n-1).times{|i|a[i+1]+=a[i]}
p (0...n).map{|i|(2*a[i]-a[n-1]).abs}.min | n,*a=`dd`.split.map &:to_i;(n-1).times{|i|a[i+1]+=a[i]};p (0..n-2).map{|i|(2*a[i]-a[-1]).abs}.min | [
"call.arguments.change"
] | 1,342,069 | 1,342,070 | u280667879 | ruby |
p03657 | a,b = gets.chop.split.map(&:to_i)
[a,b,a+b].each do |x|
if x%3 == 0
puts 'Possible'
exit!
end
end
puts 'Impossible' | a,b = gets.chop.split.map(&:to_i)
[a,b,a+b].each do |x|
if x%3 == 0
puts 'Possible'
exit
end
end
puts 'Impossible' | [
"call.suffix.change"
] | 1,342,394 | 1,342,395 | u636683284 | ruby |
p03660 | n = gets.chomp.to_i
tree = Array.new(n)
n.times { |i| tree[i] = [] }
(n - 1).times do
a, b = gets.chomp.split(' ').map { |i| i.to_i - 1 }
tree[a] << b
tree[b] << a
end
distances = Array.new(n, 100001)
queue = [0]
visited = Hash.new(false)
distance = 0
until queue.empty?
length = queue.length
length.times do
q = queue.shift
next if visited[q]
visited[q] = true
distances[q] = distance
tree[q].each do |t|
next if visited[t]
queue << t
end
end
distance += 1
end
route = [n - 1]
current = n - 1
while route.first != 0 do
tree[current].each do |i|
if distances[current] - distances[i] == 1
current = i
route.unshift(i)
break
end
end
end
start_index = route.length % 2 == 0 ? (route.length / 2) - 1 : route.length / 2
start = route[start_index]
close = route[start_index + 1]
tree[start].delete(close)
queue = [start]
visited = Hash.new(false)
fennec_count = 0
until queue.empty?
q = queue.pop
next if visited[q]
visited[q] = true
fennec_count += 1
tree[q].each do |t|
next if visited[t]
queue << t
end
end
puts fennec_count > n - fennec_count ? 'Fennec' : 'Sunuke' | n = gets.chomp.to_i
tree = Array.new(n)
n.times { |i| tree[i] = [] }
(n - 1).times do
a, b = gets.chomp.split(' ').map { |i| i.to_i - 1 }
tree[a] << b
tree[b] << a
end
distances = Array.new(n, 100001)
queue = [0]
visited = Hash.new(false)
distance = 0
until queue.empty?
length = queue.length
length.times do
q = queue.shift
next if visited[q]
visited[q] = true
distances[q] = distance
tree[q].each do |t|
next if visited[t]
queue << t
end
end
distance += 1
end
route = [n - 1]
current = n - 1
while route.first != 0 do
tree[current].each do |i|
if distances[current] - distances[i] == 1
current = i
route.unshift(i)
break
end
end
end
start_index = route.length % 2 == 0 ? (route.length / 2) - 1 : route.length / 2
start = route[start_index]
close = route[start_index + 1]
tree[start].delete(close)
queue = [start]
visited = Hash.new(false)
fennec_count = 0
until queue.empty?
q = queue.pop
next if visited[q]
visited[q] = true
fennec_count += 1
tree[q].each do |t|
next if visited[t]
queue << t
end
end
puts fennec_count > n - fennec_count ? 'Fennec' : 'Snuke' | [
"literal.string.change",
"call.arguments.change"
] | 1,342,928 | 1,342,929 | u857510905 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.