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 |
|---|---|---|---|---|---|---|---|
p02957 | n, m = gets.chomp.split.map(&:to_i)
if (n + m) % 2 == 0 then
puts (n + m) % 2
else
puts "IMPOSSIBLE"
end | n, m = gets.chomp.split.map(&:to_i)
if (n + m) % 2 == 0 then
puts (n + m) / 2
else
puts "IMPOSSIBLE"
end | [
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 762,040 | 762,041 | u163052359 | ruby |
p02957 | a, b = gets.chomp.split.map(&:to_i)
x = a + b
puts if x.modulo(2).zero? ? x / 2 : 'IMPOSSIBLE'
| a, b = gets.chomp.split.map(&:to_i)
x = a + b
puts x.modulo(2).zero? ? x / 2 : 'IMPOSSIBLE' | [] | 762,104 | 762,105 | u824361483 | ruby |
p02958 | N = gets.to_i
P = gets.split.map(&:to_i)
s = P.sort
diff = 0
(0...N).each do |i|
if P[i] != s[i]
diff += 1
end
end
if diff <= 2
print "Yes\n"
else
print "No\n"
end | N = gets.to_i
P = gets.split.map(&:to_i)
s = P.sort
diff = 0
(0...N).each do |i|
if P[i] != s[i]
diff += 1
end
end
if diff <= 2
print "YES\n"
else
print "NO\n"
end | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 763,022 | 763,023 | u354261726 | ruby |
p02958 | n = gets.to_i
p = gets.split("\s").map(&:to_i)
p_sorted = p.sort
count = 0
n.times do |i|
if p[i] != p_sorted[i]
count += 1
end
end
print count <= 2 ? 'Yes' : 'No' | n = gets.to_i
p = gets.split("\s").map(&:to_i)
p_sorted = p.sort
count = 0
n.times do |i|
if p[i] != p_sorted[i]
count += 1
end
end
print count <= 2 ? 'YES' : 'NO'
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 763,147 | 763,148 | u458429268 | ruby |
p02958 | n = gets.to_i
p = gets.split.map(&:to_i)
for i in 1..n do
if p[i-1] != i
q = p[p[i-1]-1]
p[p[i-1]-1] = p[i-1]
p[i-1] = q
break
end
end
p p
for i in 1..n do
if p[i-1] != i
puts "NO"
exit
end
end
puts "YES"
| n = gets.to_i
p = gets.split.map(&:to_i)
for i in 1..n do
if p[i-1] != i
q = p[p[i-1]-1]
p[p[i-1]-1] = p[i-1]
p[i-1] = q
break
end
end
#p p
for i in 1..n do
if p[i-1] != i
puts "NO"
exit
end
end
puts "YES"
| [
"call.remove"
] | 763,686 | 763,687 | u803684095 | ruby |
p02958 | n = gets.to_i
p = gets.split.map(&:to_i)
c = 0
n.times do |i|
cnt += 1 if p[i] != i+1
end
puts cnt > 2 ? "NO" : "YES"
| n = gets.to_i
p = gets.split.map(&:to_i)
c = 0
n.times do |i|
c += 1 if p[i] != i+1
end
puts c > 2 ? "NO" : "YES"
| [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 763,761 | 763,762 | u585819925 | ruby |
p02958 | n = gets.to_i
array = gets.split.map(&:to_i)
one_to_n = (1..n).to_a
count = 0
ans = 'NO'
(0..n-1).each do |i|
if array[i] != one_to_n[i]
count += 1
end
end
if count == 2
ans = 'YES'
end
puts ans | n = gets.to_i
array = gets.split.map(&:to_i)
one_to_n = (1..n).to_a
count = 0
ans = 'NO'
(0..n-1).each do |i|
if array[i] != one_to_n[i]
count += 1
end
end
if count <= 2
ans = 'YES'
end
puts ans | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 763,784 | 763,785 | u866325115 | ruby |
p02958 | n,*a=`dd`.split.map(&:to_i)
b=a.sort
c=0
n.times do |i|
c+=1 if a[i]!=b[i]
if c>1
puts 'NO'
exit
end
end
puts 'YES' | n,*a=`dd`.split.map(&:to_i)
b=a.sort
c=0
n.times do |i|
c+=1 if a[i]!=b[i]
if c>2
puts 'NO'
exit
end
end
puts 'YES'
| [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 763,909 | 763,910 | u966810027 | ruby |
p02958 | N = gets.to_i
pn = gets.split.map(&:to_i)
count = 0
a.upto(N){|i|
count += 1 if pn[i] != i
}
puts (count == 0 || count == 2) ? "YES" : "NO" | N = gets.to_i
pn = gets.split.map(&:to_i)
count = 0
1.upto(N){|i|
count += 1 if pn[(i-1)] != i
}
puts (count == 0 || count == 2) ? "YES" : "NO" | [
"identifier.replace.remove",
"literal.replace.add",
"control_flow.branch.if.condition.change"
] | 763,988 | 763,989 | u502306384 | ruby |
p02958 | # require "enumerator"
N = gets
P = gets
P_arry = P.split(" ")
P_int = P_arry.map {|p|
p.to_i
}
isBreak = false
failure_count = 0
if P_int.each_cons(2).all? {|a, b| a <= b }
isBreak = true
print "Yes"
exit
end
for i in 0..N.to_i-1
for j in 0..N.to_i-1
if i >= j
next
end
if P_int[i] > P_int[j]
P_int[i],P_int[j] = P_int[j],P_int[i]
if P_int.each_cons(2).all? {|a, b| a <= b }
isBreak = true
break
else
failure_count = failure_count + 1
P_int[i],P_int[j] = P_int[j],P_int[i]
end
end
end
break if isBreak || (failure_count > 0)
end
if isBreak
print "Yes"
else
print "No"
end | # require "enumerator"
N = gets
P = gets
P_arry = P.split(" ")
P_int = P_arry.map {|p|
p.to_i
}
isBreak = false
failure_count = 0
if P_int.each_cons(2).all? {|a, b| a <= b }
isBreak = true
print "YES"
exit
end
for i in 0..N.to_i-1
for j in 0..N.to_i-1
if i >= j
next
end
if P_int[i] > P_int[j]
P_int[i],P_int[j] = P_int[j],P_int[i]
if P_int.each_cons(2).all? {|a, b| a <= b }
isBreak = true
break
else
failure_count = failure_count + 1
P_int[i],P_int[j] = P_int[j],P_int[i]
end
end
end
break if isBreak || (failure_count > 0)
end
if isBreak
print "YES"
else
print "NO"
end | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 764,140 | 764,141 | u570252969 | ruby |
p02958 | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
def r_sort(a) a.sort{|a,b|b<=>a} end
n = inp[0]
p = inp
f = false
c = 0
p.each.with_index do |d,i|
if((p[d-1]-1)!=i)
c+=1
end
end
puts (c==0 or c==2)? "YES" : "NO" | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
def r_sort(a) a.sort{|a,b|b<=>a} end
n = inp[0]
p = inp
f = false
c = 0
p.each.with_index do |d,i|
if((p[i]-1)!=i)
c+=1
end
end
puts (c==0 or c==2)? "YES" : "NO" | [
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 764,254 | 764,255 | u145123922 | ruby |
p02958 | n = gets.to_i
s = gets.split.map &:to_i
puts (0...n-1).each.count{|i| s[i] != i} > 2 ? "NO" : "YES"
| N = gets.to_i
s = gets.split.map &:to_i
puts (0...N).each.count {|i| s[i] != i+1 } > 2 ? "NO" : "YES" | [
"assignment.variable.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 764,466 | 764,467 | u562082015 | ruby |
p02958 | n = gets.to_i
a = gets.split.map(&:to_i)
puts (((0...n).count{|i| a[i]!=i+1}<3) ? :YES : NO)
| n = gets.to_i
a = gets.split.map(&:to_i)
puts (((0...n).count{|i| a[i]!=i+1}<3) ? :YES : :NO) | [
"call.arguments.change"
] | 764,478 | 764,479 | u976045235 | ruby |
p02958 | n = gets.to_i
a = gets.split.map(&:to_i)
puts ((0...n).count{|i| a[i]!=i+1}<2 ? :YES : NO) | n = gets.to_i
a = gets.split.map(&:to_i)
puts (((0...n).count{|i| a[i]!=i+1}<3) ? :YES : :NO) | [
"call.arguments.change",
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 764,480 | 764,479 | u976045235 | ruby |
p02958 | num = gets.to_i
ary = gets.split().map(&:to_i)
sorted_ary = ary.sort
diff_ary = ary.zip(sorted_ary).map{|attr| attr.first - attr.last}
diff_size = diff_ary.reject(&:zero?)
if diff_size == 0 || diff_size == 2
puts "YES"
else
puts "NO"
end | num = gets.to_i
ary = gets.split().map(&:to_i)
sorted_ary = ary.sort
diff_ary = ary.zip(sorted_ary).map{|attr| attr.first - attr.last}
diff_size = diff_ary.reject(&:zero?).size
if diff_size == 0 || diff_size == 2
puts "YES"
else
puts "NO"
end | [
"call.add"
] | 764,682 | 764,683 | u792512290 | ruby |
p02958 | n = gets.to_i
q = gets.split.map(&:to_i)
count = 0
x = q.sort
n.times{|i|
count += 1 if q[i] != x[i]
}
if count == 0 or count == 2
puts "Yes"
else
puts "No"
end
| n = gets.to_i
q = gets.split.map(&:to_i)
count = 0
x = q.sort
n.times{|i|
count += 1 if q[i] != x[i]
}
if count == 0 or count == 2
puts "YES"
else
puts "NO"
end | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 764,730 | 764,731 | u054055736 | ruby |
p02958 | n = gets.to_i
ary = gets.split.map(&:to_i)
a_sort = ary.sort
if ary == a_sort
puts "Yes"
exit
end
swap = []
n.times do |i|
swap.push(i) if ary[i] != a_sort[i]
end
if swap.size != 2
puts "No"
exit
end
ary[swap[0]],ary[swap[1]] = ary[swap[1]],ary[swap[0]]
if ary == a_sort
puts "Yes"
else
puts "No"
end
| n = gets.to_i
ary = gets.split.map(&:to_i)
a_sort = ary.sort
if ary == a_sort
puts "YES"
exit
end
swap = []
n.times do |i|
swap.push(i) if ary[i] != a_sort[i]
end
if swap.size != 2
puts "NO"
exit
end
ary[swap[0]],ary[swap[1]] = ary[swap[1]],ary[swap[0]]
if ary == a_sort
puts "YES"
else
puts "NO"
end
| [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 764,779 | 764,778 | u622469330 | ruby |
p02958 | m = gets.to_i
a = gets.split.map(&:to_i)
b = a.sort
t = []
a.each_with_index do |v,i|
a[i] == b[i] ?t.push(1):t.push(0)
end
p t.count(0) >2 ? "NO":"YES"
| m = gets.to_i
a = gets.split.map(&:to_i)
b = a.sort
t = []
a.each_with_index do |v,i|
a[i] == b[i] ?t.push(1):t.push(0)
end
puts t.count(0) >2 ? "NO":"YES"
| [
"call.function.change",
"io.output.change"
] | 764,816 | 764,817 | u467484398 | ruby |
p02958 | n = gets.to_i
p = gets.split.map(&:to_i)
r = 'NO'
s = []
1.upto(n) do |i|
if i != p[i - 1]
s.push([i, p[i - 1]])
end
end
p s
if s.length == 2
if s[0][1] == s[1][0] &&
s[1][0] == s[0][1]
r = 'YES'
end
elsif s.length == 0
r = 'YES'
end
puts r
| n = gets.to_i
p = gets.split.map(&:to_i)
r = 'NO'
s = []
1.upto(n) do |i|
if i != p[i - 1]
s.push([i, p[i - 1]])
end
end
if s.length == 2
if s[0][1] == s[1][0] &&
s[1][1] == s[0][0]
r = 'YES'
end
elsif s.length == 0
r = 'YES'
end
puts r
| [
"call.remove",
"literal.number.integer.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 765,003 | 765,004 | u409614401 | ruby |
p02958 | # 入力の受け取り
n = gets.to_i
array_p = gets.split(" ").map!{|i | i.to_i}
# 入れ替え回数のカウント
swap = 0
array_p.each_with_index do |num, index|
unless num == (index + 1)
swap = swap + 1
end
end
if swap == 0 || swap == 2
p "YES"
else
p "NO"
end | n = gets.to_i
array_p = gets.split(" ").map!{|i | i.to_i}
swap = 0
array_p.each_with_index do |num, index|
unless num == (index + 1)
swap = swap + 1
end
end
if swap == 0 || swap == 2
puts "YES"
else
puts "NO"
end | [
"call.function.change",
"io.output.change"
] | 765,040 | 765,041 | u176517109 | ruby |
p02958 | n=gets.to_i
a=gets.chomp.split.map(&:to_i)
b=a.sort
counter=0
a.each_with_index do|x,i|
if x != b[i]
counter=counter+1
end
end
if (counter=0 || counter=2)
puts "YES"
else
puts "NO"
end | n=gets.to_i
a=gets.chomp.split.map(&:to_i)
b=a.sort
counter=0
a.each_with_index do|x,i|
if x != b[i]
counter=counter+1
end
end
if counter==0 || counter==2
puts "YES"
else
puts "NO"
end | [
"control_flow.branch.if.condition.change",
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 765,274 | 765,275 | u562148988 | ruby |
p02958 | n = gets.to_i
p = gets.split.map(&:to_i)
puts p.each_with_idex(1).count { |n, i| n != i } <= 2 ? 'YES' : 'NO' | n = gets.to_i
p = gets.split.map(&:to_i)
puts p.each.with_index(1).count { |n, i| n != i } <= 2 ? 'YES' : 'NO' | [
"identifier.change",
"control_flow.branch.if.condition.change",
"call.add"
] | 765,288 | 765,289 | u793733774 | ruby |
p02958 | i = gets.to_i
n = gets.chomp.split.map(&:to_i)
a = n.sort
p a
p n
cnt = 0
n.size.times do |block|
if n[block] != a[block]
cnt += 1
end
end
if cnt == 2 or cnt == 0 then
puts "YES"
else
puts "NO"
end | i = gets.to_i
n = gets.chomp.split.map(&:to_i)
a = n.sort
cnt = 0
n.size.times do |block|
if n[block] != a[block]
cnt += 1
end
end
if cnt == 2 or cnt == 0 then
puts "YES"
else
puts "NO"
end | [
"call.remove"
] | 765,324 | 765,325 | u163052359 | ruby |
p02958 | n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
(1..n).each do |i|
unless a[i-1] == i
count += 1
end
end
if count == 0
puts "YES"
exit
end
if count == 2
puts "YES"
exit
end
puts "N0" | n = gets.to_i
a = gets.split.map(&:to_i)
count = 0
(1..n).each do |i|
unless a[i-1] == i
count += 1
end
end
if count == 0
puts "YES"
exit
end
if count == 2
puts "YES"
exit
end
puts "NO" | [
"literal.string.change",
"call.arguments.change"
] | 765,471 | 765,472 | u757568397 | ruby |
p02958 | n = gets.to_i
p = gets.split.map(&:to_i)
cnt = 0
n.times do |i|
if i+1 != p[i]
cnt += 1
end
end
if cnt == 2
puts 'YES'
else
puts 'NO'
end
| n = gets.to_i
p = gets.split.map(&:to_i)
cnt = 0
n.times do |i|
if i+1 != p[i]
cnt += 1
end
end
if cnt == 2 or cnt == 0
puts 'YES'
else
puts 'NO'
end
| [
"control_flow.branch.if.condition.change"
] | 765,788 | 765,789 | u178515699 | ruby |
p02959 | n=gets.to_i
s=gets.split.map &:to_i
a=gets.split.map &:to_i
sum=0
for i in 0..n-1
if s[i]<a[i]
sum+= (a[i]>=(s[i]+s[i+1]))? (s[i]+s[i+1]):a[i]
s[i+1]-= a[i]-s[i]
s[i+1]=0 if s[i+1]<=0
else
sum+=s[i]
end
end
puts sum
| n=gets.to_i
s=gets.split.map &:to_i
a=gets.split.map &:to_i
sum=0
for i in 0..n-1
if s[i]<a[i]
sum+= (a[i]>=(s[i]+s[i+1]))? (s[i]+s[i+1]):a[i]
s[i+1]-= a[i]-s[i]
s[i+1]=0 if s[i+1]<=0
else
sum+=a[i]
end
end
puts sum
| [
"identifier.change"
] | 765,945 | 765,946 | u977506075 | ruby |
p02959 | n=gets.to_i
s=gets.split.map &:to_i
a=gets.split.map &:to_i
sum=0
for i in 0..n-1
if s[i]<a[i]
sum+= (a[i]>=(s[i]+s[i+1]))? (s[i]+s[i+1]):a[i]
s[i+1]-= a[i]-s[i]
s[i+1]=0 if s[i+1]<=0
else
sum+=s[i]
end
end
p s
| n=gets.to_i
s=gets.split.map &:to_i
a=gets.split.map &:to_i
sum=0
for i in 0..n-1
if s[i]<a[i]
sum+= (a[i]>=(s[i]+s[i+1]))? (s[i]+s[i+1]):a[i]
s[i+1]-= a[i]-s[i]
s[i+1]=0 if s[i+1]<=0
else
sum+=a[i]
end
end
puts sum
| [
"identifier.change"
] | 765,947 | 765,946 | u977506075 | ruby |
p02959 | N = gets.to_i
a = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ans = 0
(0...N).each do |i|
b = B[i]
if a[i] <= b
ans += a[i]
b -= a[i]
else
ans += b
next
end
if a[i+1] <= b
ans += a[i+1]
a[i+1] -= b
else
ans += b
a[i+1] -= b
end
end
p ans | N = gets.to_i
a = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ans = 0
(0...N).each do |i|
b = B[i]
if a[i] <= b
ans += a[i]
b -= a[i]
else
ans += b
next
end
if a[i+1] <= b
ans += a[i+1]
a[i+1] = 0
else
ans += b
a[i+1] -= b
end
end
p ans | [] | 766,017 | 766,018 | u354261726 | ruby |
p02959 | n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
count = 0
n.times do |i|
if a[i] <= b[i] && a[i] + a[i+1] >= b[i]
count += b[i]
a[i+1] = a[i+1] + a[i] - b[i]
end
if a[i] <= b[i] && a[i] + a[i+1] < b[i]
count += a[i] + a[i+1]
a[i+1] = 0
end
if a[i] > b[i]
count += b[i]
end
end
puts count | n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
count = 0
n.times do |i|
if a[i] <= b[i] && a[i] + a[i+1] >= b[i]
count += b[i]
a[i+1] = a[i+1] + a[i] - b[i]
next
end
if a[i] <= b[i] && a[i] + a[i+1] < b[i]
count += a[i] + a[i+1]
a[i+1] = 0
next
end
if a[i] > b[i]
count += b[i]
next
end
end
puts count | [] | 766,038 | 766,039 | u412789323 | ruby |
p02955 | eval"N,K,*A="+`dd`.split*?,
s,*l=eval A*?+
1.upto(3e4){|j|s%j<1&&l<<j<<s/j}
p l.select{|h|t=0
K>=A.map{|x|x%h}.sort.map{|x|t+=x}[-t/h]}.max | eval"N,K,*A="+`dd`.split*?,
s,*l=eval A*?+
1.upto(3e4){|j|s%j<1&&l<<j<<s/j}
p l.select{|h|t=0
K>=A.map{|x|x%h}.sort.map{|x|t+=x}[~t/h]}.max | [
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 766,551 | 766,552 | u657913472 | ruby |
p02955 | eval"N,K,*A="+`dd`.split*?,
s,*l=eval A*?+
1.upto(3e4){|j|s%j<1&&l<<j<<s/j}
p l.select{|h|t=0
K>=A.map{|x|x%h}.sort.map{|x|t+=x}[-t/h]}.max | eval"N,K,*A="+`dd`.split*?,
s,*l=eval A*?+
1.upto(3e4){|j|s%j<1&&l<<j<<s/j}
p l.select{|h|t=0
K>=A.map{|x|x%h}.sort.map{|x|t+=x}[-t/h-1]}.max | [
"expression.operation.binary.add"
] | 766,551 | 766,553 | u657913472 | ruby |
p02955 | n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
sum = a.inject(&:+)
divs = []
t = 1
while t * t <= sum
if sum % t == 0
divs << t
divs << sum / t if sum / t != t
end
t += 1
end
divs.sort!.reverse!
divs.each do |d|
r = a.map { |ai| ai % d }
r.sort!
sumr = [tmp = 0].concat(r.map { |ri| tmp += ri })
rdiff = r.map { |ri| d - ri }
sumrd = [tmp = 0].concat(rdiff.map { |ri| tmp += ri })
n.times do |i|
if k >= sumr[i] - sumr[0] && sumr[i] - sumr[0] == sumrd[n] - sumrd[i]
puts d
exit
end
end
end
| n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
sum = a.inject(&:+)
divs = []
t = 1
while t * t <= sum
if sum % t == 0
divs << t
divs << sum / t if sum / t != t
end
t += 1
end
divs.sort!.reverse!
divs.each do |d|
r = a.map { |ai| ai % d }
r.sort!
sumr = [tmp = 0].concat(r.map { |ri| tmp += ri })
rdiff = r.map { |ri| d - ri }
sumrd = [tmp = 0].concat(rdiff.map { |ri| tmp += ri })
n.times do |i|
if k >= sumr[i] - sumr[0] && sumr[i] - sumr[0] == sumrd[n] - sumrd[i]
puts d
exit
end
end
end
puts 1 | [
"call.add"
] | 766,592 | 766,593 | u706695185 | ruby |
p02959 | N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)
def beat_monsters(i, j)
if A[i] > B[j]
tmp = B[j]
A[i] -= B[j]
A[j] = 0
tmp
else
tmp = A[i]
A[i] = 0
B[j] -= tmp
tmp
end
end
ans = 0
for i in 0..N-1 do
ans += beat_monsters(i, i)
ans += beat_monsters(i + 1, i) if B[i] > 0
end
puts(ans) | N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)
def beat_monsters(i, j)
if A[i] > B[j]
tmp = B[j]
A[i] -= B[j]
B[j] = 0
tmp
else
tmp = A[i]
A[i] = 0
B[j] -= tmp
tmp
end
end
ans = 0
for i in 0..N-1 do
ans += beat_monsters(i, i)
ans += beat_monsters(i + 1, i) if B[i] > 0
end
puts(ans) | [
"assignment.variable.change"
] | 767,018 | 767,019 | u310842158 | ruby |
p02959 | N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ret = 0
monsters = A[0]
N.times do |i|
if monsters <= B[i]
power = B[i] - monsters
ret += monsters
if A[i + 1] <= power
monsters = 0
ret += A[i + 1]
else
remain = A[i + 1] - power
ret += power
end
else
monsters = A[i + 1]
ret += B[i]
end
end
puts ret | N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
ret = 0
monsters = A[0]
N.times do |i|
if monsters <= B[i]
power = B[i] - monsters
ret += monsters
if A[i + 1] <= power
monsters = 0
ret += A[i + 1]
else
monsters = A[i + 1] - power
ret += power
end
else
monsters = A[i + 1]
ret += B[i]
end
end
puts ret | [
"assignment.variable.change",
"identifier.change"
] | 767,393 | 767,394 | u559342926 | ruby |
p02959 | ##C - City Savers
#1行目
hoge = gets.chomp.to_i
#2,3行目読み込み
x = gets.chomp.split(" ").map!{|i | i.to_i}
y = gets.chomp.split(" ").map!{|i | i.to_i}
unchi = 0
for i in 0..(hoge-1) do
if x[i] >= y[i]
unchi = unchi + y[i]
elsif x[i] + x[i+1] > y[i]
x[i+1] = x[i+1] -y[1] + x[i]
unchi = unchi + y[i]
else
unchi = unchi + x[i] + x[i +1]
x[i+1] = 0
end
end
print unchi | ##C - City Savers
#1行目
hoge = gets.chomp.to_i
#2,3行目読み込み
x = gets.chomp.split(" ").map!{|i | i.to_i}
y = gets.chomp.split(" ").map!{|i | i.to_i}
unchi = 0
for i in 0..(hoge-1) do
if x[i] >= y[i]
unchi = unchi + y[i]
elsif x[i] + x[i+1] > y[i]
x[i+1] = x[i+1] -y[i] + x[i]
unchi = unchi + y[i]
else
unchi = unchi + x[i] + x[i +1]
x[i+1] = 0
end
end
print unchi | [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 767,951 | 767,952 | u401248484 | ruby |
p02959 | require 'byebug'
count = 0
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
N.times do |i| # 大元のループ
# モンスターと勇者の数の大小を比較して条件分岐
if A[i] >= B[i]
count += B[i]
else
count += A[i]
B[i] -= A[i]
if A[i+1] >= B[i]
count += B[i]
A[i+1] -= B[i]
else
count += A[i+1]
A[i+1] = 0
end
end
end
puts count
| count = 0
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
N.times do |i|
if A[i] >= B[i]
count += B[i]
else
count += A[i]
B[i] -= A[i]
if A[i+1] >= B[i]
count += B[i]
A[i+1] -= B[i]
else
count += A[i+1]
A[i+1] = 0
end
end
end
puts count
| [
"call.remove"
] | 767,995 | 767,996 | u079732127 | ruby |
p02959 | N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
count = 0
N.times do |i|
if A[i] < B[i]
count += A[i]
B[i] -= A[i]
if A[i+1] < B[i]
count += A[i+1]
A[1] = 0
else
count += B[i]
A[i+1] -= B[i]
end
else
count += B[i]
end
end
puts count | N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
count = 0
N.times do |i|
if A[i] < B[i]
count += A[i]
B[i] -= A[i]
if A[i+1] < B[i]
count += A[i+1]
A[i+1] = 0
else
count += B[i]
A[i+1] -= B[i]
end
else
count += B[i]
end
end
puts count | [
"assignment.change"
] | 768,029 | 768,030 | u326562452 | ruby |
p02969 | r = gets.split.map( &:to_i )
puts 3*r*r | r = gets.to_i
puts 3 * r * r | [
"assignment.value.change",
"identifier.change",
"call.remove"
] | 772,509 | 772,510 | u408023666 | ruby |
p02969 | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
def r_sort(a) a.sort{|a,b|b<=>a} end
p 3*inp[0]**3 | #exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
def r_sort(a) a.sort{|a,b|b<=>a} end
p 3*inp[0]**2 | [
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 772,577 | 772,578 | u145123922 | ruby |
p02969 | r=gets.to_i
puts 3*a*a | r=gets.to_i
puts 3*r*r | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 772,633 | 772,634 | u883824971 | ruby |
p02969 | a = gets.to_i
puts 2*a*a | a = gets.to_i
puts 3*a*a | [
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 772,691 | 772,692 | u193470608 | ruby |
p02969 | r = gets.chomp.to_i
puts 3 * 4**2 | r = gets.chomp.to_i
puts 3 * (r**2) | [
"call.arguments.change",
"expression.operation.binary.change",
"call.add"
] | 772,729 | 772,730 | u303448696 | ruby |
p02969 | r = gets()
puts 3 * (r ** 2)
| r = gets().to_i
puts 3 * (r ** 2)
| [
"call.add"
] | 772,977 | 772,978 | u810246563 | ruby |
p02970 | line = gets.split(' ').map(&:to_i)
N = line[0]
D = line[1]
hanni = 2*D
if N%hanni== 0 then
puts(N/hanni)
else
puts(N/hanni+1)
end | line = gets.split(' ').map(&:to_i)
N = line[0]
D = line[1]
hanni = 2*D+1
if N%hanni== 0 then
puts(N/hanni)
else
puts(N/hanni+1)
end | [
"assignment.change"
] | 773,150 | 773,151 | u047572420 | ruby |
p02970 | n,d=gets.split.map(&:to_i)
q,r=n.divmod(2*d)
p q+(r>0?1:0) | n,d=gets.split.map(&:to_i)
q,r=n.divmod(2*d+1)
p q+(r>0?1:0) | [
"assignment.change"
] | 773,813 | 773,814 | u408023666 | ruby |
p02970 | N,D = gets.split.map(&:to_i)
p (N/(D*2+1)).ceil | N,D = gets.split.map(&:to_i)
p (N/(D*2.0+1)).ceil | [
"call.arguments.change",
"expression.operation.binary.change"
] | 773,993 | 773,994 | u502306384 | ruby |
p02970 | array=gets.chomp.split(" ").map(&:to_i)
n=array[0]
d=array[1]
a=n/(d*2+1)
if a%(d*2+1)!=0
a=a+1
end
puts a | array=gets.chomp.split.map(&:to_i)
n=array[0]
d=array[1]
a=n/(d*2+1)
if n%(d*2+1)!=0
a=a+1
end
puts a | [
"call.arguments.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 774,094 | 774,095 | u389979392 | ruby |
p02970 | n, d = gets.split.map(&:to_i)
count = 0
i = 1
until i >= n
i += 2 * d + 1
count += 1
end
puts count
| n, d = gets.split.map(&:to_i)
count = 0
i = 0
until i >= n
i += 2 * d + 1
count += 1
end
puts count
| [
"literal.number.integer.change",
"assignment.value.change"
] | 774,233 | 774,234 | u306465660 | ruby |
p02970 | n, d = gets.chomp.split(" ").map(&:to_i)
tmp = n
ans = 0
for i in 1..n do
tmp = tmp - d * 2 + 1
if tmp <= 0
ans = i
break
end
end
print(ans) | n, d = gets.chomp.split(" ").map(&:to_i)
tmp = n
ans = 0
for i in 1..n do
tmp -= d + d + 1
if tmp <= 0
ans = i
break
end
end
print(ans) | [
"assignment.compound.arithmetic.replace.add",
"expression.operator.arithmetic.replace.remove",
"expression.operation.binary.change"
] | 774,264 | 774,265 | u310842158 | ruby |
p02970 | N, D = *gets.chomp.split.map(&:to_i)
puts (N / (D * 2).to_r).ceil
| N, D = *gets.chomp.split.map(&:to_i)
puts (N / (D * 2 + 1).to_r).ceil
| [
"expression.operation.binary.add"
] | 774,377 | 774,378 | u252459200 | ruby |
p02970 | N,D=gets.chomp.split.map(&:to_i)
puts (N+1)/(D*2+1) | N,D=gets.chomp.split.map(&:to_i)
puts (N-1)/(D*2+1)+1
| [
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 774,492 | 774,493 | u868089307 | ruby |
p02970 | N,D=gets.split.map &:to_i
p (N+D-1)/(2*D+1) | N,D=gets.split.map &:to_i
p (N+2*D)/(2*D+1) | [
"expression.operation.binary.remove"
] | 774,562 | 774,563 | u572745161 | ruby |
p02970 | def main()
# stdin = $stdin.readlines.map {|i| i.chomp().to_i }
stdin = gets.chomp.split(" ").map {|i| i.chomp().to_i }
n = stdin[0]
d = stdin[1]
com = n/(d*2+1)
print com
if n%(d*2+1)==0
print com
else
print com+1
end
end
main() | def main()
# stdin = $stdin.readlines.map {|i| i.chomp().to_i }
stdin = gets.chomp.split(" ").map {|i| i.chomp().to_i }
n = stdin[0]
d = stdin[1]
com = n/(d*2+1)
if n%(d*2+1)==0
print com
else
print com+1
end
end
main() | [
"call.remove"
] | 774,720 | 774,721 | u258908951 | ruby |
p02970 | a=gets.split.map(&:to_i)
l=a[1]+1
m=l+a[1]
can=m-l+1
i=0
while i*can<a[0]
i+=1
end
puts i
| a=gets.split.map(&:to_i)
l=a[1]+1
m=l+a[1]
can=m-1+1
i=0
while i*can<a[0]
i+=1
end
puts i
| [
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"expression.operation.binary.change"
] | 774,780 | 774,781 | u585819925 | ruby |
p02970 |
# describe Abc134B do
# context 'test' do
# it 'sample' do
# expect(Abc134B.calc(6, 2)).to be(2)
# expect(Abc134B.calc(14, 3)).to be(2)
# expect(Abc134B.calc(20, 4)).to be(3)
# end
# end
# end
class Abc134B
def self.input()
n, d = STDIN.gets.split(/\s/).map(&:to_i)
[n, d]
end
def self.output(result)
puts result
end
def self.calc(n, d)
(n.to_f / (2 * d + 1)).ceil
end
def self.main()
n, d = input()
result = calc(n, d)
output(result)
end
end
if __FILE__ == $0
Abc134A.main
exit
end |
# describe Abc134B do
# context 'test' do
# it 'sample' do
# expect(Abc134B.calc(6, 2)).to be(2)
# expect(Abc134B.calc(14, 3)).to be(2)
# expect(Abc134B.calc(20, 4)).to be(3)
# end
# end
# end
class Abc134B
def self.input()
n, d = STDIN.gets.split(/\s/).map(&:to_i)
[n, d]
end
def self.output(result)
puts result
end
def self.calc(n, d)
(n.to_f / (2 * d + 1)).ceil
end
def self.main()
n, d = input()
result = calc(n, d)
output(result)
end
end
if __FILE__ == $0
Abc134B.main
exit
end | [] | 774,867 | 774,868 | u517615862 | ruby |
p02971 | n = gets.to_i
max = 0
second = 0
max_index = 0
n.times{|i|
val = gets.to_i
if val > max
second = max
max = val
max_index = i
else val > second
second = val
end
}
n.times{|i|
puts i == max_index ? second : max
} | n = gets.to_i
max = 0
second = 0
max_index = 0
n.times{|i|
val = gets.to_i
if val > max
second = max
max = val
max_index = i
elsif val > second
second = val
end
}
n.times{|i|
puts i == max_index ? second : max
} | [] | 775,484 | 775,485 | u714769076 | ruby |
p02971 | N = gets.to_i
a = gets.to_i
m1 = a
m2 = a
mi= 0
A = 1.upto(N - 1) do |i|
a = gets.to_i
if m1 < a
mi = i
m2 = m1
m1 = a
elsif m2 < a
m2 = a
end
end
0.upto(N - 1) do |i|
puts i == mi ? m2 : m1
end | N = gets.to_i
a = gets.to_i
m1 = a
m2 = 0
mi= 0
1.upto(N - 1) do |i|
a = gets.to_i
if m1 < a
mi = i
m2 = m1
m1 = a
elsif m2 < a
m2 = a
end
end
0.upto(N - 1) do |i|
puts i == mi ? m2 : m1
end
| [
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add"
] | 775,506 | 775,507 | u039293076 | ruby |
p02971 | n = gets.chomp.to_i
a_arr = n.times.map{gets.to_i}
max = 0
max_i = -1
a_arr.each_with_index do |a, i|
if a > max then
max = a
max_i = i
end
end
second = 0
a_arr.each_with_index do |a, i|
if a > second && i != max_i then
second = a
end
end
(0..a_arr.length-1).each do |i|
if max_i == i then
puts max
else
puts second
end
end
| n = gets.chomp.to_i
a_arr = n.times.map{gets.to_i}
max = 0
max_i = -1
a_arr.each_with_index do |a, i|
if a > max then
max = a
max_i = i
end
end
second = 0
a_arr.each_with_index do |a, i|
if a > second && i != max_i then
second = a
end
end
(0..a_arr.length-1).each do |i|
if max_i == i then
puts second
else
puts max
end
end
| [
"call.remove",
"call.add"
] | 775,599 | 775,600 | u257668305 | ruby |
p02971 | n,*a=$<.map &:to_i
m=a.max
n=a.sort[0..-1].max
puts a.map{|x|x!=m ? m : n} | n,*a=$<.map &:to_i
m,n=a.max,a.sort[0..-2].max
puts a.map{|x|x!=m ? m : n} | [
"assignment.value.change",
"literal.number.integer.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 775,603 | 775,604 | u408023666 | ruby |
p02971 | n = gets.chomp.to_i
a = readlines.map(&:chomp).map(&:to_i)
a_max = a.sort[0]
a_second = a.sort[1]
n.times do |i|
if a[i] == a_max
puts(a_second)
next
end
puts(a_max)
end | n = gets.chomp.to_i
a = readlines.map(&:chomp).map(&:to_i)
a_max = a.sort.reverse[0]
a_second = a.sort.reverse[1]
n.times do |i|
if a[i] == a_max
puts(a_second)
next
end
puts(a_max)
end | [
"call.add"
] | 775,719 | 775,720 | u429775245 | ruby |
p02971 | n = gets.to_i
max_1 = [-1,0]
max_2 = 0
n.times do |i|
x = gets.to_i
if x >= max_1[1] then
max_2 = max_1[1]
max_1 = [i,x]
elsif x >= max_2[1]
max_2 = x
end
end
ans = Array.new(n,max_1[1])
ans[max_1[0]] = max_2
puts ans | n = gets.to_i
max_1 = [-1,0]
max_2 = 0
n.times do |i|
x = gets.to_i
if x >= max_1[1] then
max_2 = max_1[1]
max_1 = [i,x]
elsif x >= max_2
max_2 = x
end
end
ans = Array.new(n,max_1[1])
ans[max_1[0]] = max_2
puts ans | [] | 775,768 | 775,769 | u692254521 | ruby |
p02971 | n=gets.to_i
a=[]
n.times{a<<gets.to_i}
b=a.sort
0.upto(n-1){|i|puts n[i]==b[-1]?b[-2]:b[-1]} | n=gets.to_i
a=[]
n.times{a<<gets.to_i}
b=a.sort
0.upto(n-1){|i|puts a[i]==b[-1]?b[-2]:b[-1]}
| [] | 775,855 | 775,856 | u883824971 | ruby |
p02971 | n = gets.chomp.to_i
a = []
n.times { a << gets.to_i }
max = a.max
index = a.find_index(max)
b = a.dup
b.delete_at(i)
max2 = b.max
n.times do |i|
if i == index
print("#{max2}\n")
else
print("#{max}\n")
end
end | n = gets.chomp.to_i
a = []
n.times { a << gets.to_i }
max = a.max
index = a.find_index(max)
b = a.dup
b.delete_at(index)
max2 = b.max
n.times do |i|
if i == index
print("#{max2}\n")
else
print("#{max}\n")
end
end | [
"identifier.change",
"call.arguments.change"
] | 776,055 | 776,056 | u221163535 | ruby |
p02971 | input = readlines.map{|x|x.to_i}
n = input[0]
a_list = input.slice(1, n)
max_value = a_list.max
sorted_a_list = a_list.uniq.sort
a_list.each {|a|
if max_value == a
p sorted_a_list[n-2]
elsif
p max_value
end
} | input = readlines.map{|x|x.to_i}
n = input[0]
a_list = input.slice(1, n)
max_value = a_list.max
sorted_a_list = a_list.sort
a_list.each {|a|
if max_value == a
p sorted_a_list[n-2]
elsif
p max_value
end
} | [
"call.remove"
] | 776,059 | 776,060 | u604344785 | ruby |
p02971 | n = gets.chomp.to_i
num = n.times.map{ gets.to_i }
max = num.max
count = 0
n.times do |i|
if num[i] == max
if count == 0
ox = num[i]
num[i] = 0
semimax = num.max
end
puts semimax
if count == 0
num[i] = ox
count += 1
end
else
puts max
end
end | n = gets.chomp.to_i
num = n.times.map{ gets.to_i }
max = num.max
semimax = 0
count = 0
n.times do |i|
if num[i] == max
if count == 0
ox = num[i]
num[i] = 0
semimax = num.max
end
puts semimax
if count == 0
num[i] = ox
count += 1
end
else
puts max
end
end | [
"assignment.add"
] | 776,100 | 776,101 | u512524057 | ruby |
p02971 | N = gets.chomp.to_i
a = 0
max_n = 0
max_i = 0
second = 0
for i in 1...N do
a = gets.chomp.to_i
if a > max_n
second = max_n
max_n = a
max_i = i
elsif a > second
second = a
end
end
for i in 0...N do
if i == max_i
puts second
else
puts max_n
end
end | N = gets.chomp.to_i
a = 0
max_n = 0
max_i = 0
second = 0
for i in 1..N do
a = gets.chomp.to_i
if a > max_n
second = max_n
max_n = a
max_i = i
elsif a > second
second = a
end
end
for i in 1..N do
if i == max_i
puts second
else
puts max_n
end
end | [
"literal.number.integer.change"
] | 776,190 | 776,191 | u349832549 | ruby |
p02971 | n = gets.to_i
a = []
n.times { a << gets.to_i }
a.sort!
a.each do |i|
if i == a[n -1]
puts a[n - 2]
else
puts a[n - 1]
end
end | n = gets.to_i
a = []
n.times { a << gets.to_i }
max = a.sort
a.each do |i|
if i == max[n -1]
puts max[n - 2]
else
puts max[n - 1]
end
end | [
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change",
"call.arguments.change",
"io.output.change"
] | 776,297 | 776,298 | u457499130 | ruby |
p02971 | n = gets.to_i
nums = []
max = 0
second_max = 0
n.times do |i|
num = gets.to_i
nums << num
if num > max
max = num
else num > second_max
second_max = num
end
end
n.times do |i|
res = max
if nums[i] == max
res = second_max
end
puts res
end
| n = gets.to_i
nums = []
max = 0
second_max = 0
n.times do |i|
num = gets.to_i
nums << num
if num > max
second_max = max
max = num
elsif num > second_max
second_max = num
end
end
# puts "max: #{max}"
# puts "second_max: #{second_max}"
n.times do |i|
res = max
if nums[i] == max
res = second_max
end
puts res
end
| [
"assignment.add"
] | 776,435 | 776,436 | u624505752 | ruby |
p02972 | n = gets.to_i
as = gets.chomp.split.map(&:to_i)
bs = Array.new(n+1,0)
cnt = 0
ans = []
(1..n).reverse_each do |i|
sum = 0
j = i
loop do
i += i
break if i > n
sum += bs[i]
end
if as[j-1] != sum % 2
bs[j] = 1
cnt += 1
ans << j
else
bs[j] = 0
end
end
puts cnt
puts ans.sort.join(" ") if !ans.empty? | n = gets.to_i
as = gets.chomp.split.map(&:to_i)
bs = Array.new(n+1,0)
cnt = 0
ans = []
(1..n).reverse_each do |i|
sum = 0
j = i
loop do
i += j
break if i > n
sum += bs[i]
end
if as[j-1] != sum % 2
bs[j] = 1
cnt += 1
ans << j
else
bs[j] = 0
end
end
puts cnt
puts ans.sort.join(" ") if !ans.empty? | [
"identifier.change"
] | 777,321 | 777,322 | u191196346 | ruby |
p02972 | n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
result = Array.new(n, 0)
possible = true
possibles = []
(n - 1).downto(0) do |i|
if i + 1 > n / 2
result[i] = arr[i]
else
loop_max = n / (i + 1)
bit = 0
2.upto(loop_max) do |j|
bit = (bit + arr[(i + 1) * j - 1]) % 2
end
result[i] = (arr[i] + bit) % 2
end
possibles.unshift(i + 1) if result[i] == 1
end
if possible
if possibles.count > 0
puts possibles.count
puts possibles.join(' ')
else
puts 0
end
else
puts '-1'
end | n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
result = Array.new(n, 0)
possible = true
possibles = []
(n - 1).downto(0) do |i|
if i + 1 > n / 2
result[i] = arr[i]
else
loop_max = n / (i + 1)
bit = 0
2.upto(loop_max) do |j|
bit = (bit + result[(i + 1) * j - 1]) % 2
end
result[i] = (arr[i] + bit) % 2
end
possibles.unshift(i + 1) if result[i] == 1
end
if possible
if possibles.count > 0
puts possibles.count
puts possibles.join(' ')
else
puts 0
end
else
puts '-1'
end | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 778,366 | 778,367 | u857510905 | ruby |
p02972 | N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
d = N.times.map { -1 }
(a.size - 1).downto(0).each do |i|
k = 2
s = 0
while ((i + 1) * k <= N)
s += a[(i +1) * k - 1]
k += 1
end
if (s % 2 == a[i])
d[i] = 0
else
d[i] = 1
end
end
r = []
d.each.with_index do |dd, i|
if dd == 1
r << i + 1
end
end
p r.size
if r.size > 0
print r.join(" ")
end | N = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
d = N.times.map { -1 }
(a.size - 1).downto(0).each do |i|
k = 2
s = 0
while (((i + 1) * k -1) < N)
s += d[(i + 1) * k - 1]
k += 1
end
if (s % 2 == a[i])
d[i] = 0
else
d[i] = 1
end
end
r = []
d.each.with_index do |dd, i|
if dd == 1
r << i + 1
end
end
p r.size
if r.size > 0
print r.join(" ")
end | [
"expression.operation.binary.change",
"identifier.change"
] | 778,483 | 778,484 | u328294851 | ruby |
p02972 | def method_name(n, ai)
bi = Array.new(n, 0)
n.downto(1) do |i|
sum = (2*i).step(n, i).inject{|sum, j| sum += bi[j-1]}
bi[i-1] = 1 if sum.odd? != ai[i-1].odd?
end
puts bi.inject(&:+)
bi.each_with_index{|v, k| puts k + 1 if v == 1}
end
n = gets.chomp.to_i
ai = gets.chomp.split.map(&:to_i)
method_name(n, ai)
| def method_name(n, ai)
bi = Array.new(n, 0)
n.downto(1) do |i|
sum = (2*i).step(n, i).inject(0){|v, j| v += bi[j-1]}
bi[i-1] = 1 if sum.odd? != ai[i-1].odd?
end
puts bi.inject(:+)
bi.each_with_index{|v, k| puts k + 1 if v == 1}
end
n = gets.chomp.to_i
ai = gets.chomp.split.map(&:to_i)
method_name(n, ai) | [
"call.arguments.add",
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 778,557 | 778,558 | u516361212 | ruby |
p02972 | N = gets.to_i
A = gets.split.map(&:to_i)
memo = Array.new(N+1){ 0 }
ans = []
N.downto(1) do | i |
hop = 1
cnt = 0
# ボールが入っている箱を数え, cntに加算.
# e.g. i=3なら3, 6, 9...の箱を調べる.
while hop * i <= N
cnt += memo[hop * i - 1]
hop += 1
end
#
if cnt % 2 != A[i - 1]
ans << i
memp[i - 1] += 1
end
end
puts ans.size
puts ans.join(' ') if ans.size != 0 | N = gets.to_i
A = gets.split.map(&:to_i)
memo = Array.new(N+1){ 0 }
ans = []
N.downto(1) do | i |
hop = 1
cnt = 0
# ボールが入っている箱を数え, cntに加算.
# e.g. i=3なら3, 6, 9...の箱を調べる.
while hop * i <= N
cnt += memo[hop * i - 1]
hop += 1
end
#
if cnt % 2 != A[i - 1]
ans << i
memo[i - 1] += 1
end
end
puts ans.size
puts ans.join(' ') if ans.size != 0 | [
"identifier.change"
] | 778,829 | 778,830 | u366779547 | ruby |
p02972 | N = gets.to_i
a_list = gets.split.map(&:to_i)
ans = Array.new(N) { 0 }
N.downto(1) do |i|
if i + i > N
ans[i - 1] = a_list[i - 1]
else
sum = 0
ii = i
while ii <= N
sum += ans[i - 1]
ii += i
end
ans[i - 1] = (a_list[i - 1] - (sum % 2)).abs
end
end
puts ans.count { |n| n == 1 }
ids = ans.map.with_index { |a, i| [a, i] }.select do |a, i|
a == 1
end.map { |_, i| i + 1 }
puts ids.join(' ')
| N = gets.to_i
a_list = gets.split.map(&:to_i)
ans = Array.new(N) { 0 }
N.downto(1) do |i|
if i + i > N
ans[i - 1] = a_list[i - 1]
else
sum = 0
ii = i
while ii <= N
sum += ans[ii - 1]
ii += i
end
ans[i - 1] = (a_list[i - 1] - (sum % 2)).abs
end
end
puts ans.count { |n| n == 1 }
ids = ans.map.with_index { |a, i| [a, i] }.select do |a, i|
a == 1
end.map { |_, i| i + 1 }
puts ids.join(' ')
| [
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 778,843 | 778,844 | u012133968 | ruby |
p02972 | n = gets.to_i
a = gets.split.map(&:to_i)
b = []
count = 0
x = Array.new(n)
(n).downto(1) {|i|
sum = 0
k = 2 * i
while k <= n
sum += a[k - 1]
k += i
end
if sum % 2 == a[i - 1] then
x[i - 1] = 0
else
x[i - 1] = 1
b.push(i)
count += 1
end
}
puts count
puts b.join(' ')
| n = gets.to_i
a = gets.split.map(&:to_i)
b = []
count = 0
x = Array.new(n)
(n).downto(1) {|i|
sum = 0
k = 2 * i
while k <= n
sum += x[k - 1]
k += i
end
if sum % 2 == a[i - 1] then
x[i - 1] = 0
else
x[i - 1] = 1
b.push(i)
count += 1
end
}
puts count
puts b.join(' ')
| [
"identifier.change"
] | 779,123 | 779,124 | u420267469 | ruby |
p02972 | n = gets.to_i
a = gets.split.map(&:to_i)
b = []
count = 0
x = Array.new(n)
(n).downto(1) {|i|
sum = 0
k = 2 * i
while k <= n
sum += a[k - 1]
k += i
end
if sum % 2 == a[i - 1] then
x[i - 1] = 0
else
x[i - 1] = 1
b.push(i)
count += 1
end
}
puts count
puts b.join
| n = gets.to_i
a = gets.split.map(&:to_i)
b = []
count = 0
x = Array.new(n)
(n).downto(1) {|i|
sum = 0
k = 2 * i
while k <= n
sum += x[k - 1]
k += i
end
if sum % 2 == a[i - 1] then
x[i - 1] = 0
else
x[i - 1] = 1
b.push(i)
count += 1
end
}
puts count
puts b.join(' ')
| [
"identifier.change",
"call.arguments.add"
] | 779,125 | 779,124 | u420267469 | ruby |
p02972 | N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = N/2
c = a.clone
ball = Array.new
for i in 0..b-1
ball << b+i+1 if a[b+i] == 1
end
(b).downto(0) do |i|
count = 0
i.step(N-1, i+1) do |j|
count += 1 if c[j] == 1
end
if count % 2 == a[i]
if c[i] == 1
ball << i+1
end
else
if c[i] == 1
c[i] = 0
else
c[i] = 1
ball << i+1
end
end
end
puts ball.length
puts ball.join(" ") if ball.length != 0
| N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = N/2
c = a.clone
ball = Array.new
for i in 0..b
ball << b+i+1 if a[b+i] == 1
end
(b-1).downto(0) do |i|
count = 0
i.step(N-1, i+1) do |j|
count += 1 if c[j] == 1
end
if count % 2 == a[i]
if c[i] == 1
ball << i+1
end
else
if c[i] == 1
c[i] = 0
else
c[i] = 1
ball << i+1
end
end
end
puts ball.length
puts ball.join(" ") if ball.length != 0
| [
"expression.operation.binary.remove"
] | 779,314 | 779,315 | u307452818 | ruby |
p02972 | N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = N/2
c = a.clone
ball = Array.new
for i in 0..b-1
ball << b+i+1 if a[b+i] == 1
end
(b-1).downto(0) do |i|
count = 0
i.step(N-1, i+1) do |j|
count += 1 if c[j] == 1
end
if count % 2 == a[i]
if c[i] == 1
ball << i+1
end
else
if c[i] == 1
c[i] = 0
else
c[i] = 1
ball << i+1
end
end
end
puts ball.length
puts ball.join(" ") if ball.length != 0
| N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = N/2
c = a.clone
ball = Array.new
for i in 0..b
ball << b+i+1 if a[b+i] == 1
end
(b-1).downto(0) do |i|
count = 0
i.step(N-1, i+1) do |j|
count += 1 if c[j] == 1
end
if count % 2 == a[i]
if c[i] == 1
ball << i+1
end
else
if c[i] == 1
c[i] = 0
else
c[i] = 1
ball << i+1
end
end
end
puts ball.length
puts ball.join(" ") if ball.length != 0
| [
"expression.operation.binary.remove"
] | 779,316 | 779,315 | u307452818 | ruby |
p02972 | N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = N/2
c = a.clone
ball = Array.new
for i in 0..b-1
ball << b+i if a[b+i] == 1
end
(b-1).downto(0) do |i|
count = 0
i.step(N-1, i+1) do |j|
count += 1 if c[j] == 1
end
if count % 2 == a[i]
if c[i] == 1
ball << i+1
end
else
if c[i] == 1
c[i] = 0
else
c[i] = 1
ball << i+1
end
end
end
puts ball.length
puts ball.join(" ") if ball.length != 0
| N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = N/2
c = a.clone
ball = Array.new
for i in 0..b
ball << b+i+1 if a[b+i] == 1
end
(b-1).downto(0) do |i|
count = 0
i.step(N-1, i+1) do |j|
count += 1 if c[j] == 1
end
if count % 2 == a[i]
if c[i] == 1
ball << i+1
end
else
if c[i] == 1
c[i] = 0
else
c[i] = 1
ball << i+1
end
end
end
puts ball.length
puts ball.join(" ") if ball.length != 0
| [
"expression.operation.binary.remove"
] | 779,317 | 779,315 | u307452818 | ruby |
p02972 | N = gets.chomp.to_i
a = [nil] + gets.chomp.split(" ").map(&:to_i)
insert = Array.new(N + 1, 0)
a.each_with_index.reverse_each do |val, i|
next if i == 0
if N < i * 2
insert[i] = a[i]
else
buf = 0
for j in 2..(N / i)
buf = buf ^ a[i * j]
end
insert[i] = buf ^ a[i]
end
end
puts insert.inject(:+)
puts insert.zip((0..N).to_a).select{|val, i| val == 1}.map{|val, i| i}.join(" ") if insert.uniq.size == 2 | N = gets.chomp.to_i
a = [nil] + gets.chomp.split(" ").map(&:to_i)
insert = Array.new(N + 1, 0)
a.each_with_index.reverse_each do |val, i|
next if i == 0
if N < i * 2
insert[i] = a[i]
else
buf = 0
for j in 2..(N / i)
buf = buf ^ insert[i * j]
end
insert[i] = buf ^ a[i]
end
end
puts insert.inject(:+)
puts insert.zip((0..N).to_a).select{|val, i| val == 1}.map{|val, i| i}.join(" ") if insert.uniq.size == 2 | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 780,256 | 780,257 | u655122274 | ruby |
p02973 | def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
n = inp[0]
it = []
n.times do
it << inp[0]
end
len = [it.shift]
it.each do |d|
ind = nil
if(ind = len.bsearch_index{|x|x >= d})
if(ind - 1 < 0)
len.push(d)
next
end
len[ind-1] = d
else
len[-1] = d
end
end
p len.size
| def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def r_up(a, b) (a+b-1)/b end
n = inp[0]
it = []
n.times do
it << inp[0]
end
len = [it.shift]
it.each do |d|
ind = nil
if(ind = len.bsearch_index{|x|x >= d})
if(ind - 1 < 0)
len.unshift(d)
next
end
len[ind-1] = d
else
len[-1] = d
end
end
p len.size
| [
"misc.opposites",
"identifier.change"
] | 780,384 | 780,385 | u145123922 | ruby |
p02973 | n = gets.chomp.to_i
stack = []
for i in 1..n do
a = gets.chomp.to_i
if stack.empty?
stack.push(a)
next
end
head = 0
tail = (stack.size) -1
mid = (head+tail)/2
if stack[tail] >= a
stack.push(a)
next
end
while head < tail
if stack[mid] >= a
head = mid+1
else
tail = mid-1
end
mid = (head+tail)/2
end
stack[mid] = a
end
p stack.size | n = gets.chomp.to_i
stack = []
for i in 1..n do
a = gets.chomp.to_i
# print a,stack,"\n"
if stack.empty?
stack.push(a)
next
end
head = 0
tail = (stack.size) -1
mid = (head+tail)/2
if stack[tail] >= a
stack.push(a)
next
end
while head < tail
if stack[mid] >= a
head = mid+1
else
tail = mid
end
mid = (head+tail)/2
end
stack[mid] = a
end
p stack.size | [
"expression.operation.binary.remove"
] | 780,447 | 780,448 | u988912858 | ruby |
p02973 | n = gets.chomp.to_i
stack = []
for i in 1..n do
a = gets.chomp.to_i
if stack.empty?
stack.push(a)
next
end
head = 0
tail = (stack.size) -1
mid = (head+tail)/2
if stack[tail] > a
stack.push(a)
next
end
while head < tail
if stack[mid] > a
head = mid+1
else
tail = mid-1
end
mid = (head+tail)/2
end
stack[mid] = a
end
p stack.size | n = gets.chomp.to_i
stack = []
for i in 1..n do
a = gets.chomp.to_i
# print a,stack,"\n"
if stack.empty?
stack.push(a)
next
end
head = 0
tail = (stack.size) -1
mid = (head+tail)/2
if stack[tail] >= a
stack.push(a)
next
end
while head < tail
if stack[mid] >= a
head = mid+1
else
tail = mid
end
mid = (head+tail)/2
end
stack[mid] = a
end
p stack.size | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 780,449 | 780,448 | u988912858 | ruby |
p02973 | # https://atcoder.jp/contests/abc006/tasks/abc006_4
class Array
def lis
b_ary = [self[0]]
self[1..-1].each do |v|
# 広義単調増加 { |x| x > v }
# index = b_ary.bsearch_index { |x| x > v }
# 狭義単調増加 { |x| x >= v }
# index = b_ary.bsearch_index { |x| x >= v }
# 広義単調減少 { |x| x < v }
index = b_ary.bsearch_index { |x| x < v }
# 狭義単調減少 { |x| x <= v }
# index = b_ary.bsearch_index { |x| x <= v }
if index
b_ary[index] = v
else
b_ary << v
end
end
return b_ary.size
end
end
n = gets.to_i
puts n - n.times.with_object([]) { |i,obj| obj << gets.to_i }.map { |i| i.to_i }.lis | # https://atcoder.jp/contests/abc006/tasks/abc006_4
class Array
def lis
b_ary = [self[0]]
self[1..-1].each do |v|
# 広義単調増加 { |x| x > v }
# index = b_ary.bsearch_index { |x| x > v }
# 狭義単調増加 { |x| x >= v }
# index = b_ary.bsearch_index { |x| x >= v }
# 広義単調減少 { |x| x < v }
index = b_ary.bsearch_index { |x| x < v }
# 狭義単調減少 { |x| x <= v }
# index = b_ary.bsearch_index { |x| x <= v }
if index
b_ary[index] = v
else
b_ary << v
end
end
return b_ary.size
end
end
n = gets.to_i
puts n.times.with_object([]) { |i,obj| obj << gets.to_i }.map { |i| i.to_i }.lis | [
"expression.operation.binary.remove"
] | 780,500 | 780,501 | u987208743 | ruby |
p02973 | n = gets.to_i
as = []
n.times{ as << gets.to_i }
colors = []
as.each do |a|
i = colors.bsearch_index{|x| x < a }
if i.nil?
colors.unshift(a)
else
colors[i] = a
end
end
p colors.size
| n = gets.to_i
as = []
n.times{ as << gets.to_i }
colors = []
as.each do |a|
i = colors.bsearch_index{|x| x < a }
if i.nil?
colors << a
else
colors[i] = a
end
end
p colors.size
| [
"call.remove",
"call.arguments.change"
] | 780,524 | 780,525 | u069429049 | ruby |
p02973 | N = gets.to_i
A = N.times.map { gets.to_i }
def bsearch(ng:, ok:, &is_ok)
while (ok - ng).abs > 1
mid = (ok + ng) / 2
if is_ok.call(mid)
ok = mid
else
ng = mid
end
end
ok
end
list = []
A.each do |a|
i = bsearch(ng: list.size, ok: -1) do |j|
list[j] < a
end
if i == -1
list.push(a)
else
list[i] = a
end
end
puts list.size | N = gets.to_i
A = N.times.map { gets.to_i }
def bsearch(ng:, ok:, &is_ok)
while (ok - ng).abs > 1
mid = (ok + ng) / 2
if is_ok.call(mid)
ok = mid
else
ng = mid
end
end
ok
end
list = []
A.each do |a|
i = bsearch(ng: list.size, ok: -1) do |j|
list[j] < a
end
if i == -1
list.unshift(a)
else
list[i] = a
end
end
puts list.size | [
"misc.opposites",
"identifier.change"
] | 780,645 | 780,646 | u012133968 | ruby |
p02973 | n = gets.to_i
a = Array.new(n) { gets.to_i }
colors = [a[0]]
a[1..-1].each do |x|
i = colors.bsearch_index{|y| y > x}
if i.nil?
colors[-1] = x
elsif i == 0
colors.unshift(x)
else
colors[i-1] = x
end
end
puts colors.length | n = gets.to_i
a = Array.new(n) { gets.to_i }
colors = [a[0]]
a[1..-1].each do |x|
i = colors.bsearch_index{|y| y >= x}
if i.nil?
colors[-1] = x
elsif i == 0
colors.unshift(x)
else
colors[i-1] = x
end
end
puts colors.length | [
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 780,739 | 780,740 | u054274223 | ruby |
p02973 | N = gets.split.map &:to_i
A = $<.map &:to_i
curr = []
A.each{|a|
p [a]
idx = curr.bsearch_index{|b| b < a }
if idx.nil?
curr << a
else
curr[idx] = a
end
}
p curr.size | N = gets.split.map &:to_i
A = $<.map &:to_i
curr = []
A.each{|a|
idx = curr.bsearch_index{|b| b < a }
if idx.nil?
curr << a
else
curr[idx] = a
end
}
p curr.size | [
"call.remove"
] | 781,080 | 781,081 | u711705317 | ruby |
p02973 | n = gets.to_i
r = []
n.times do
input = gets.to_i
i = r.bsearch_index{|b| b < a }
if i.nil?
s << a
else
s[i] = input
end
end
puts r.size | n = gets.to_i
r = []
n.times do
input = gets.to_i
i = r.bsearch_index{|b| b < input }
if i.nil?
r << input
else
r[i] = input
end
end
puts r.size | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change",
"assignment.variable.change"
] | 781,349 | 781,350 | u868461642 | ruby |
p02973 | def lower_bound(a, l, r, v)
m = l
until m == r
l, r = a[m] < v ? [m, r] : [l, m]
m = l + (r-l+1)/2
end
return m
end
N = gets.to_i
probes = []
N.times{
a = gets.to_i
i = lower_bound(probes, 0, probes.length, a)
if i == 0
probes.unshift(a)
else
probes[i-1] = a
end
p probes
}
p probes.length
| def lower_bound(a, l, r, v)
m = l
until m == r
l, r = a[m] < v ? [m, r] : [l, m]
m = l + (r-l+1)/2
end
return m
end
N = gets.to_i
probes = []
N.times{
a = gets.to_i
i = lower_bound(probes, 0, probes.length, a)
if i == 0
probes.unshift(a)
else
probes[i-1] = a
end
}
p probes.length
| [
"call.remove"
] | 781,425 | 781,426 | u977697682 | ruby |
p02975 | n = gets.to_i
array = gets.split.map(&:to_i)
m = array.uniq.size
case m
when 1
if array.first == 0
puts 'Yes'
exit
end
when 2
x, y = a.uniq.sort
if x == 0 && array.count(y) == 2 * n / 3 && array.count(x) == n / 3
puts 'Yes'
exit
end
when 3
x, y, z = array.uniq
if x ^ y ^ z == 0 &&
array.count(x) == n / 3 && array.count(y) == n / 3 && array.count(z) == n / 3
puts 'Yes'
exit
end
end
puts 'No'
| # frozen_string_literal: true
n = gets.to_i
array = gets.split.map(&:to_i)
m = array.uniq.size
case m
when 1
if array.first == 0
puts 'Yes'
exit
end
when 2
x, y = array.uniq.sort
if x == 0 && array.count(y) == 2 * n / 3 && array.count(x) == n / 3
puts 'Yes'
exit
end
when 3
x, y, z = array.uniq
if x ^ y ^ z == 0 &&
array.count(x) == n / 3 && array.count(y) == n / 3 && array.count(z) == n / 3
puts 'Yes'
exit
end
end
puts 'No'
| [
"assignment.value.change",
"identifier.change"
] | 781,612 | 781,613 | u393913844 | ruby |
p02975 | n = gets.to_i
array = gets.split.map(&:to_i)
m = array.uniq.size
case m
when 1
if a.first == 0
puts 'Yes'
exit
end
when 2
x, y = a.uniq.sort
if x == 0 && array.count(y) == 2 * n / 3 && array.count(x) == n / 3
puts 'Yes'
exit
end
when 3
x, y, z = array.uniq
if x ^ y ^ z == 0 &&
array.count(x) == n / 3 && array.count(y) == n / 3 && array.count(z) == n / 3
puts 'Yes'
exit
end
end
puts 'No'
| # frozen_string_literal: true
n = gets.to_i
array = gets.split.map(&:to_i)
m = array.uniq.size
case m
when 1
if array.first == 0
puts 'Yes'
exit
end
when 2
x, y = array.uniq.sort
if x == 0 && array.count(y) == 2 * n / 3 && array.count(x) == n / 3
puts 'Yes'
exit
end
when 3
x, y, z = array.uniq
if x ^ y ^ z == 0 &&
array.count(x) == n / 3 && array.count(y) == n / 3 && array.count(z) == n / 3
puts 'Yes'
exit
end
end
puts 'No'
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"assignment.value.change"
] | 781,614 | 781,613 | u393913844 | ruby |
p02975 | n = gets.to_i
a = gets.split.map(&:to_i)
m = a.uniq.size
ans = 'No'
if m == 1
ans = 'Yes' if a[0] == 0
elsif m == 2
ans = 'Yes' if a[0] == 0 && a.count(0) * 3 == n
elsif m == 3
x, y, z = a.uniq
ans = 'Yes' if x ^ y == z && a.count(x) * 3 == n && a.count(y) * 3 == n
end
puts ans
| n = gets.to_i
a = gets.split.map(&:to_i).sort
m = a.uniq.size
ans = 'No'
if m == 1
ans = 'Yes' if a[0] == 0
elsif m == 2
ans = 'Yes' if a[0] == 0 && a.count(0) * 3 == n
elsif m == 3
x, y, z = a.uniq
ans = 'Yes' if x ^ y == z && a.count(x) * 3 == n && a.count(y) * 3 == n
end
puts ans
| [
"call.add"
] | 781,888 | 781,889 | u579668395 | ruby |
p02975 | N = gets.to_i
caps = gets.split.map(&:to_i)
check = caps.uniq
# 要素数が3の倍数、重複なしで3つ、もしくは
if !(N % 3 == 0 && check == 3 || caps.select{|cap| cap == 0}.size == caps.size)
puts 'No'
exit
end
puts caps.inject{|acc, cap| acc ^ cap} == 0 ? 'Yes' : 'No'
| N = gets.to_i
caps = gets.split.map(&:to_i)
check = caps.uniq
# 要素数が3の倍数、かつ、重複なしで3つ
if !(N % 3 == 0 || check == 3 || caps.select{|cap| cap == 0}.size == caps.size)
puts 'No'
exit
end
puts caps.inject{|acc, cap| acc ^ cap} == 0 ? 'Yes' : 'No'
| [
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 782,280 | 782,281 | u616694253 | ruby |
p02981 | n, a, b = gets.chomp.split.map(&:to_i)
puts [n*a, n*b].min | n, a, b = gets.chomp.split.map(&:to_i)
puts [n*a, b].min | [
"call.remove"
] | 784,234 | 784,235 | u147964866 | ruby |
p02981 | (N, A, B) = gets.chomp.split
N = N.to_i
A = A.to_i
B = B.to_i
train = N*A
if train > B
puts train
else
puts B
end | (N, A, B) = gets.chomp.split
N = N.to_i
A = A.to_i
B = B.to_i
train = N*A
if train < B
puts train
else
puts B
end | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 784,255 | 784,256 | u760636024 | ruby |
p02981 | n,a,b = gets.chomp.split("").map(&:to_i)
if a * n < b
puts a * n
else
puts b
end
| n,a,b = gets.chomp.split(" ").map(&:to_i)
if a * n < b
puts a * n
else
puts b
end
| [
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 784,399 | 784,400 | u012110567 | ruby |
p02981 | n,a,b = gets.chomp.split("").map(&:to_i)
if a*n < b
puts a*n
else
puts b
end
| n,a,b = gets.chomp.split(" ").map(&:to_i)
if a * n < b
puts a * n
else
puts b
end
| [
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 784,402 | 784,400 | u012110567 | ruby |
p02981 | n, a, b = gets.chomp.split().map(&:to_i)
puts n * a if n * a < b | n, a, b = gets.chomp.split().map(&:to_i)
puts n * a < b ? n * a : b
| [] | 784,897 | 784,898 | u541032448 | ruby |
p02981 | N,A,B=gets.chomp.split(" ").map(&:to_i);
x=[N*A,B].min
Print(x) | N,A,B=gets.chomp.split(" ").map(&:to_i)
x=[N*A,B].min
print(x) | [] | 784,997 | 784,998 | u918601425 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.