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 |
|---|---|---|---|---|---|---|---|
p03323 | a,b = gets.chomp.split.map(&:to_i)
puts a,b
if a > 8 or b > 8
puts ':('
else
puts 'Yay!'
end | a,b = gets.chomp.split.map(&:to_i)
if a > 8 or b > 8
puts ':('
else
puts 'Yay!'
end | [
"call.remove"
] | 1,099,093 | 1,099,094 | u634342027 | ruby |
p03323 |
Copy
x, y = gets.split(' ').map(&:to_i)
if x <= 8 && y <= 8
puts "Yay!"
else
puts ":("
end | x, y = gets.split(' ').map(&:to_i)
if x <= 8 && y <= 8
puts "Yay!"
else
puts ":("
end
| [] | 1,099,070 | 1,099,072 | u468878441 | ruby |
p03323 | x, y = gets.split(' ').map(&:to_i)
if x <= 8 || y <= 8
puts "Yay!"
else
puts ":("
end | x, y = gets.split(' ').map(&:to_i)
if x <= 8 && y <= 8
puts "Yay!"
else
puts ":("
end
| [
"misc.opposites",
"control_flow.branch.if.condition.change"
] | 1,099,074 | 1,099,072 | u468878441 | ruby |
p03323 | x, y = gets.split(' ').map(&:to_i)
if x <= 8 || y <= 8
"Yay!"
else
":("
end
| x, y = gets.split(' ').map(&:to_i)
if x <= 8 && y <= 8
puts "Yay!"
else
puts ":("
end
| [
"misc.opposites",
"control_flow.branch.if.condition.change",
"io.output.change",
"call.add"
] | 1,099,076 | 1,099,072 | u468878441 | ruby |
p03323 | input = gets.chomp.split(" ")
if input[0].to_i <= 8 && input[1].to_i <= 8
p "Yay!"
else
p ":("
end
| input = gets.chomp.split(" ")
if input[0].to_i <= 8 && input[1].to_i <= 8
puts "Yay!"
else
puts ":("
end
| [
"call.function.change",
"io.output.change"
] | 1,099,103 | 1,099,105 | u220501704 | ruby |
p03323 | input = gets.strip.split(" ")
if input[0].to_i <= 8 && input[1].to_i <= 8
p "Yay!"
else
p ":("
end | input = gets.chomp.split(" ")
if input[0].to_i <= 8 && input[1].to_i <= 8
puts "Yay!"
else
puts ":("
end
| [
"assignment.value.change",
"identifier.change",
"call.function.change",
"io.output.change"
] | 1,099,107 | 1,099,105 | u220501704 | ruby |
p03323 | input = gets.strip.split(" ")
if input[0].to_i <= 8 && input[1].to_i <= 8
p "Yay!"
else
p ":("
end
| input = gets.chomp.split(" ")
if input[0].to_i <= 8 && input[1].to_i <= 8
puts "Yay!"
else
puts ":("
end
| [
"assignment.value.change",
"identifier.change",
"call.function.change",
"io.output.change"
] | 1,099,109 | 1,099,105 | u220501704 | ruby |
p03323 | a, b = gets.chomp.split(" ").map(&:to_i);
if a <= 8 and b <= 8 then
puts "Yes"
else
puts "No"
end
| a, b = gets.chomp.split(" ").map(&:to_i);
if a <= 8 && b <= 8 then
puts "Yay!"
else
puts ":("
end
| [
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change"
] | 1,099,138 | 1,099,139 | u810735437 | ruby |
p03323 | a, b = gets.split.map(&:to_i)
puts ((a<=6 && b<=6) ? "Yay!" : ":(") | a, b = gets.split.map(&:to_i)
puts ((a<=8 && b<=8) ? "Yay!" : ":(")
| [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,099,188 | 1,099,189 | u573495181 | ruby |
p03323 | puts gets.split.map(&:to_i).max<9?"Yey!":":(" | puts gets.split.map(&:to_i).max<9?"Yay!":":(" | [
"literal.string.change",
"call.arguments.change"
] | 1,099,249 | 1,099,250 | u161323909 | ruby |
p03323 | a,b=gets.map(&:to_i)
if a<=8 && b<=8
puts "Yay!"
else
puts ":("
end
| a,b=gets.split.map(&:to_i)
if a<=8 && b<=8
puts "Yay!"
else
puts ":("
end | [
"call.add"
] | 1,099,260 | 1,099,261 | u671239754 | ruby |
p03323 | a, b = gets.split.map(&:to_i)
p(a<=8 && b<=8 ? 'Yay!' : ':(') | a, b = gets.split.map(&:to_i)
puts(a<=8 && b<=8 ? 'Yay!' : ':(') | [
"call.function.change",
"io.output.change"
] | 1,099,331 | 1,099,332 | u437302815 | ruby |
p03323 | a,b=gets.to_i
puts a<=8&&b<=8 ? "Yay!" : ":("
| a,b=gets.split.map &:to_i
puts a<=8&&b<=8 ? "Yay!" : ":("
| [
"assignment.value.change",
"identifier.change",
"call.add"
] | 1,099,364 | 1,099,365 | u785521224 | ruby |
p03323 | nums = gets.chomp.split(' ').map(&:to_i)
p (nums.find{ |n| n>8 } ? ':(' : 'Yay!')
| nums = gets.chomp.split(' ').map(&:to_i)
print (nums.find{ |n| n>8 } ? ':(' : 'Yay!')
| [
"call.function.change",
"io.output.change"
] | 1,099,474 | 1,099,475 | u808358934 | ruby |
p03323 | a,b=gets.chomp.split(" ").map(&:to_i);
if a >= 8 || b >= 8 then
ans = ":("
else
ans = "Yay!"
end
puts ans
| a,b=gets.chomp.split(" ").map(&:to_i);
if a > 8 || b > 8 then
ans = ":("
else
ans = "Yay!"
end
puts ans
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,099,480 | 1,099,481 | u501660472 | ruby |
p03319 | eval"p~-%d/~-%d+1"%gets.split | eval"p~-~-%d/~-%d+1"%gets.split | [
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,099,986 | 1,099,987 | u711705317 | ruby |
p03319 | eval"p~-%d/%d+1"%gets.split | eval"p~-~-%d/~-%d+1"%gets.split | [
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,099,988 | 1,099,987 | u711705317 | ruby |
p03324 | d,n=gets.split.map(&:to_i)
k = ""
if d == 0 && n == 100
puts 101
elsif d == 1 && n == 100
puts 1010
elsif d == 2 && n == 100
puts 1010000
else
d.times do
k += "00"
end
puts n.to_s + k
end
| d,n=gets.split.map(&:to_i)
k = ""
if d == 0 && n == 100
puts 101
elsif d == 1 && n == 100
puts 10100
elsif d == 2 && n == 100
puts 1010000
else
d.times do
k += "00"
end
puts n.to_s + k
end
| [
"literal.number.integer.change",
"call.arguments.change"
] | 1,102,674 | 1,102,675 | u543160080 | ruby |
p03324 | d,n=gets.split.map(&:to_i)
k = ""
if d == 0 && n == 100
puts 101
elsif d == 1 && n == 100
puts 10001
elsif d == 2 && n == 100
puts 1000001
else
d.times do
k += "00"
end
puts n.to_s + k
end
| d,n=gets.split.map(&:to_i)
k = ""
if d == 0 && n == 100
puts 101
elsif d == 1 && n == 100
puts 10100
elsif d == 2 && n == 100
puts 1010000
else
d.times do
k += "00"
end
puts n.to_s + k
end
| [
"literal.number.integer.change",
"call.arguments.change"
] | 1,102,676 | 1,102,675 | u543160080 | ruby |
p03325 | def progression_operation(num, arr)
count = 0
while true do
index_dev2 = -1
arr.each_with_index do | n, i |
if (n%2 == 0) then
index_dev2 = i
arr[i] = arr[i] >> 1
count += 1
end
end
if index_dev2 == -1 then
break
end
end
p count
end
input = gets()
input = gets()
progression = input.split(" ")
progression.map!(&:to_i)
progression_operation(number, progression)
| def progression_operation(arr)
count = 0
while true do
index_dev2 = -1
arr.each_with_index do | n, i |
if (n%2 == 0) then
index_dev2 = i
arr[i] = arr[i] >> 1
count += 1
end
end
if index_dev2 == -1 then
break
end
end
p count
end
input = gets()
input = gets()
progression = input.split(" ")
progression.map!(&:to_i)
progression_operation(progression)
| [
"call.arguments.change"
] | 1,103,111 | 1,103,112 | u266671911 | ruby |
p03325 | n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
#奇数かどうか
count = 0
for ai in a do
puts ai
s = ai%2
while s == 0
count = count+1
ai = ai/2
s = ai%2
end
end
puts count | n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
#奇数かどうか
count = 0
for ai in a do
s = ai%2
while s == 0
count = count+1
ai = ai/2
s = ai%2
end
end
puts count | [
"call.remove"
] | 1,103,113 | 1,103,114 | u634342027 | ruby |
p03325 | n=gets.to_i
s=gets.split.map &:to_i
p s
c=0
n.times do|i|
while s[i]%2==0
s[i]/=2
c+=1
end
end
p c
| n=gets.to_i
s=gets.split.map &:to_i
c=0
n.times do|i|
while s[i]%2==0
s[i]/=2
c+=1
end
end
p c
| [
"call.remove"
] | 1,103,269 | 1,103,270 | u785521224 | ruby |
p03325 | n = gets.to_i
a = gets.split(" ").map{|t| t.to_i }
cnt = 0
a.each{|m|
while (m & 1) == 1
cnt += 1
m /= 2
end
}
puts cnt
| n = gets.to_i
a = gets.split(" ").map{|t| t.to_i }
cnt = 0
a.each{|m|
while (m & 1) == 0
cnt += 1
m /= 2
end
}
puts cnt
| [
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,103,271 | 1,103,272 | u838194315 | ruby |
p03326 | _,*X=$<.map{_1.split.map &:to_i}
*s=1,-1
p s.product(s,s).map{|a,b,c|X.map{_1*a+_2*b+_3*c}.max(B[1]).sum}.max||0 | B,*X=$<.map{_1.split.map &:to_i}
*s=1,-1
p s.product(s,s).map{|a,b,c|X.map{_1*a+_2*b+_3*c}.max(B[1]).sum}.max | [
"assignment.variable.change",
"expression.operation.binary.remove"
] | 1,103,489 | 1,103,490 | u657913472 | ruby |
p03326 | _,*X=$<.map{_1.split.map &:to_i}
*s=1,-1
p s.product(s,s).map{|a,b,c|X.map{_1*a+_2*b+_3*c}.max(B[1]).sum}.max||0 | B,*X=$<.map{_1.split.map &:to_i}
*s=1,-1
p s.product(s,s).map{|a,b,c|X.map{_1*a+_2*b+_3*c}.max(B[1]).sum}.max||0 | [
"assignment.variable.change"
] | 1,103,489 | 1,103,491 | u657913472 | ruby |
p03326 | n,m=gets.split.map(&:to_i)
b,d,p =[],[],[]
n.times do |i|
b[i], d[i], p[i] = gets.chomp.split.map(&:to_i)
end
ans=0
[-1,1].each do |bx|
[-1,1].each do |dx|
[-1,1].each do |px|
result = n.times.map{|i|bx*b[i]+dx*d[i]+px*p[i]}.sort.reverse[0, m].inject(0, :+)
puts result
ans = result if ans < result
end
end
end
puts ans
## 他の方のコードを参考にしました。 | n,m=gets.split.map(&:to_i)
b,d,p =[],[],[]
n.times do |i|
b[i], d[i], p[i] = gets.chomp.split.map(&:to_i)
end
ans=0
[-1,1].each do |bx|
[-1,1].each do |dx|
[-1,1].each do |px|
result = n.times.map{|i|bx*b[i]+dx*d[i]+px*p[i]}.sort.reverse[0, m].inject(0, :+)
ans = result if ans < result
end
end
end
puts ans
## 他の方のコードを参考にしました。 | [
"call.remove"
] | 1,103,563 | 1,103,564 | u562148988 | ruby |
p03326 | n,m=gets.chomp.split.map(&:to_i)
b,d,p =[],[],[]
n.times do |i|
b[i], d[i], p[i] = gets.chomp.split.map(&:to_i)
end
ans=0
[-1,1].each do |bx|
[-1,1].each do |dx|
[-1,1].each do |px|
result = n.times.map{|i|bx*b[i]+dx*d[i]+px*p[i]}.reverse[0, m].inject(0, :+)
ans = result if ans < result
end
end
end
puts ans
## 他の方のコードを参考にしました。 | n,m=gets.split.map(&:to_i)
b,d,p =[],[],[]
n.times do |i|
b[i], d[i], p[i] = gets.chomp.split.map(&:to_i)
end
ans=0
[-1,1].each do |bx|
[-1,1].each do |dx|
[-1,1].each do |px|
result = n.times.map{|i|bx*b[i]+dx*d[i]+px*p[i]}.sort.reverse[0, m].inject(0, :+)
ans = result if ans < result
end
end
end
puts ans
## 他の方のコードを参考にしました。 | [
"call.remove",
"call.add"
] | 1,103,565 | 1,103,564 | u562148988 | ruby |
p03326 | N,M = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
arr = []
N.times {
arr << $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
}
puts [
[+1,+1,+1],
[+1,+1,-1],
[+1,-1,+1],
[+1,-1,-1],
[-1,+1,+1],
[-1,+1,-1],
[-1,-1,+1],
[-1,-1,-1],
].map { |b|
arr.map{ |a| a[0]*b[0]+a[1]*b[1]+a[2]*b[2] }.sort.last(M).inject(:+)
}.max | N,M = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
arr = []
N.times {
arr << $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
}
puts [
[+1,+1,+1],
[+1,+1,-1],
[+1,-1,+1],
[+1,-1,-1],
[-1,+1,+1],
[-1,+1,-1],
[-1,-1,+1],
[-1,-1,-1],
].map { |b|
arr.map{ |a| a[0]*b[0]+a[1]*b[1]+a[2]*b[2] }.sort.last(M).inject(:+)
}.max || 0 | [
"expression.operation.binary.add"
] | 1,103,676 | 1,103,677 | u670503797 | ruby |
p03326 | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes, ans = 0
for i in 0..7 do
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | # 最初に半角スペース区切りの整数を取ってきます。
n, m = gets.chomp.split(' ').map(&:to_i)
# [a, b, c]の配列がいっぱい入ってる配列,設定がケーキなのでcakes
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
# ビットの0,1と係数の-1,1を対応付けるメソッドを作っておきます( x = [-1,1] を作って x[i[n]] としても良いと思います。)
def cb(i); i==1 ? 1 : -1;end
# ケーキの値の和を入れる変数と、最大の和を入れる変数を作っておきます。
sum_cakes, ans = 0, 0
for i in 0..7 do
# 0..7 の 2進数表記の0/1を利用して、8通りの係数を表せますので、それを利用して各配列の和を計算し
# その和を降順ソートしてm個目までの和を取ります。 AtCoderのRubyは古いので.sumできません。
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | [] | 1,103,850 | 1,103,851 | u987208743 | ruby |
p03326 | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes, ans = 0
for i in 0..7 do
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes > ans
end
puts ans | # 最初に半角スペース区切りの整数を取ってきます。
n, m = gets.chomp.split(' ').map(&:to_i)
# [a, b, c]の配列がいっぱい入ってる配列,設定がケーキなのでcakes
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
# ビットの0,1と係数の-1,1を対応付けるメソッドを作っておきます( x = [-1,1] を作って x[i[n]] としても良いと思います。)
def cb(i); i==1 ? 1 : -1;end
# ケーキの値の和を入れる変数と、最大の和を入れる変数を作っておきます。
sum_cakes, ans = 0, 0
for i in 0..7 do
# 0..7 の 2進数表記の0/1を利用して、8通りの係数を表せますので、それを利用して各配列の和を計算し
# その和を降順ソートしてm個目までの和を取ります。 AtCoderのRubyは古いので.sumできません。
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | [
"control_flow.branch.if.condition.change"
] | 1,103,852 | 1,103,851 | u987208743 | ruby |
p03326 | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes,ans = 0, 0
for i in 0..7 do
sum_cakes ||= cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m]&.inject(:+)
ans = sum_cakes if sum_cakes > ans
end
puts ans | # 最初に半角スペース区切りの整数を取ってきます。
n, m = gets.chomp.split(' ').map(&:to_i)
# [a, b, c]の配列がいっぱい入ってる配列,設定がケーキなのでcakes
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
# ビットの0,1と係数の-1,1を対応付けるメソッドを作っておきます( x = [-1,1] を作って x[i[n]] としても良いと思います。)
def cb(i); i==1 ? 1 : -1;end
# ケーキの値の和を入れる変数と、最大の和を入れる変数を作っておきます。
sum_cakes, ans = 0, 0
for i in 0..7 do
# 0..7 の 2進数表記の0/1を利用して、8通りの係数を表せますので、それを利用して各配列の和を計算し
# その和を降順ソートしてm個目までの和を取ります。 AtCoderのRubyは古いので.sumできません。
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | [
"control_flow.branch.if.condition.change"
] | 1,103,853 | 1,103,851 | u987208743 | ruby |
p03326 | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes, ans = 0
for i in 0..7 do
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes, ans = 0, 0
for i in 0..7 do
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | [] | 1,103,850 | 1,103,854 | u987208743 | ruby |
p03326 | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes, ans = 0
for i in 0..7 do
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes > ans
end
puts ans | n, m = gets.chomp.split(' ').map(&:to_i)
cakes = []; n.times { cakes << gets.chomp.split(' ').map(&:to_i).to_a }
def cb(i); i==1 ? 1 : -1;end
sum_cakes, ans = 0, 0
for i in 0..7 do
sum_cakes = cakes.map { |cake| cb(i[0])*cake[0] + cb(i[1])*cake[1] + cb(i[2])*cake[2] }.sort.reverse[0,m].inject(:+)
ans = sum_cakes if sum_cakes &.> ans
end
puts ans | [
"control_flow.branch.if.condition.change"
] | 1,103,852 | 1,103,854 | u987208743 | ruby |
p03326 | N, M = gets.split.map(&:to_i)
XYZs = readlines.map{|l| l.split.map(&:to_i)}
puts [1, -1].repeated_permutation(3).map{|a, b, c| XYZs.map{|x, y, z| a*x + b*y + c*z}.sort.last(M).inject(:+)}.max | N, M = gets.split.map(&:to_i)
XYZs = readlines.map{|l| l.split.map(&:to_i)}
puts [1, -1].repeated_permutation(3).map{|a, b, c| XYZs.map{|x, y, z| a*x + b*y + c*z}.sort.last(M).inject(:+)}.max || 0 | [
"expression.operation.binary.add"
] | 1,103,911 | 1,103,912 | u304198114 | ruby |
p03326 | io = STDIN
$ar=[]
n,$m=io.gets.split.map(&:to_i)
n.times do
xyz=io.gets.split.map(&:to_i)
$ar << xyz
end
def cnv(zyx,abc)
zyx.zip(abc).inject(0){|s,(i,j)|s+i*j}
end
def calc(salt)
$ar.map{|xyz|cnv(xyz,salt)}.sort_by{|a|-a}.take($m).inject(:+)
end
ans=0
[
[1,1,1],
[-1,1,1],
[1,-1,1],
[1,1,-1],
[-1,-1,1],
[-1,1,-1],
[1,-1,-1],
[-1,-1,-1],
].each do |salt|
ans=[ans,calc(salt)].max
end
puts ans
| io = STDIN
$ar=[]
n,$m=io.gets.split.map(&:to_i)
n.times do
xyz=io.gets.split.map(&:to_i)
$ar << xyz
end
def cnv(zyx,abc)
zyx.zip(abc).inject(0){|s,(i,j)|s+i*j}
end
def calc(salt)
$ar.map{|xyz|cnv(xyz,salt)}.sort_by{|a|-a}.take($m).inject(:+)||0
end
ans=0
[
[1,1,1],
[-1,1,1],
[1,-1,1],
[1,1,-1],
[-1,-1,1],
[-1,1,-1],
[1,-1,-1],
[-1,-1,-1],
].each do |salt|
ans=[ans,calc(salt)].max
end
puts ans
| [
"expression.operation.binary.add"
] | 1,103,924 | 1,103,925 | u132360211 | ruby |
p03326 | (N , M) = gets.split.map(&:to_i)
array = []
Evaluation = Struct.new(:x,:y,:z)
N.times { (x,y,z) = gets.split.map(&:to_i); array.push(Evaluation.new(x,y,z)) }
ret = []
m1 = [1,-1]
m2 = [1,-1]
m3 = [1,-1]
m1.each {|tmp1| m2.each {|tmp2| m3.each{|tmp3| ret.push(array.map {|r| r.x*tmp1+r.y*tmp2+r.z*tmp3 }.sort {|a,b| b <=> a }[0...M].inject(:+)) }}}
puts ret.max | (N , M) = gets.split.map(&:to_i)
array = []
Evaluation = Struct.new(:x,:y,:z)
N.times { (x,y,z) = gets.split.map(&:to_i); array.push(Evaluation.new(x,y,z)) }
ret = [0]
m1 = [1,-1]
m2 = [1,-1]
m3 = [1,-1]
m1.each {|tmp1| m2.each {|tmp2| m3.each{|tmp3| ret.push(array.map {|r| r.x*tmp1+r.y*tmp2+r.z*tmp3 }.sort {|a,b| b <=> a }[0...M].inject(:+)) if M > 0 }}}
puts ret.max | [] | 1,103,942 | 1,103,943 | u039504682 | ruby |
p03326 | require"matrix";n,m=gets.split.map &:to_i;s=n.times.map{Vector[*gets.split.map(&:to_i)]};p 8.times.map{|b|v=Vector[(b&4)/2-1,(b&2)-1,(b&1)*2-1];s.map{|w|w.dot v}.sort.reverse.take(m).inject :+}.max | require"matrix";n,m=gets.split.map &:to_i;s=n.times.map{Vector[*gets.split.map(&:to_i)]};p 8.times.map{|b|v=Vector[(b&4)/2-1,(b&2)-1,(b&1)*2-1];s.map{|w|w.dot v}.sort.reverse.take(m).inject :+}.max||0 | [
"expression.operation.binary.add"
] | 1,104,027 | 1,104,028 | u019489252 | ruby |
p03326 | n, m = gets.split.map(&:to_i)
a = n.times.map { |i| gets.split.map(&:to_i) }
min_num = -10000000001
res = Array.new(2) { Array.new(2) { Array.new(2) { Array.new(m) { min_num } } } }
a.each do |a_eval|
[0, 1].repeated_permutation(3) do |i, j, k|
cake_eval = a_eval.zip([i, j, k]).map { |x, y| ((-1)**y) * x }.inject(:+)
next_eval = res[i][j][k] + [cake_eval]
res[i][j][k] = next_eval.sort.drop(1)
end
end
p res.flatten(2).map { |i| i.inject(:+) }.max | n, m = gets.split.map(&:to_i)
a = n.times.map { |i| gets.split.map(&:to_i) }
min_num = -10000000001 * 3
res = Array.new(2) { Array.new(2) { Array.new(2) { Array.new(m) { min_num } } } }
a.each do |a_eval|
[0, 1].repeated_permutation(3) do |i, j, k|
cake_eval = a_eval.zip([i, j, k]).map { |x, y| ((-1)**y) * x }.inject(:+)
next_eval = res[i][j][k] + [cake_eval]
res[i][j][k] = next_eval.sort.drop(1)
end
end
p res.flatten(2).map { |i| i.inject(:+) }.max.to_i | [
"call.add"
] | 1,104,064 | 1,104,062 | u782656139 | ruby |
p03326 | N, M = gets.split.map(&:to_i)
CAKES = readlines.map{|l| l.split.map(&:to_i)}
def score(cake, signs)
cake[0] * signs[0] +
cake[1] * signs[1] +
cake[2] * signs[2]
end
SIGNS = [1, -1].repeated_permutation(3)
p SIGNS.map{|signs|
#cs = CAKES.map.with_index(1){|c, i| [score(c, signs), c, i]}.sort_by(&:first).last(M)
#cs.map(&:first).inject(:+)
CAKES.map{|c| score(c, signs)}.sort.last(M).inject(:+)
}.max | N, M = gets.split.map(&:to_i)
CAKES = readlines.map{|l| l.split.map(&:to_i)}
def score(cake, signs)
cake[0] * signs[0] +
cake[1] * signs[1] +
cake[2] * signs[2]
end
SIGNS = [1, -1].repeated_permutation(3)
p SIGNS.map{|signs|
#cs = CAKES.map.with_index(1){|c, i| [score(c, signs), c, i]}.sort_by(&:first).last(M)
#cs.map(&:first).inject(:+)
CAKES.map{|c| score(c, signs)}.sort.last(M).inject(0, :+)
}.max | [
"call.arguments.add"
] | 1,104,068 | 1,104,069 | u437302815 | ruby |
p03327 | n = readline.to_i
puts n < 1000 ? "ABD" : "ABC" | puts readline.to_i < 1000 ? "ABC" : "ABD" | [
"call.remove",
"literal.string.change",
"call.arguments.change"
] | 1,104,274 | 1,104,275 | u353707427 | ruby |
p03327 | n = readline.to_i
puts n < 1000 ? "ABD" : "ABC" | n = readline.to_i
puts n < 1000 ? "ABC" : "ABD" | [
"literal.string.change",
"call.arguments.change"
] | 1,104,274 | 1,104,276 | u353707427 | ruby |
p03327 | a = gets.to_i
if a < 1000
puts 'ABC'
else
puts 'ADC'
end | a = gets.to_i
if a < 1000
puts 'ABC'
else
puts 'ABD'
end | [
"literal.string.change",
"call.arguments.change"
] | 1,104,287 | 1,104,288 | u962609087 | ruby |
p03327 | n = gets.to_i
n <= 999 ? answwer = "ABC" : answer = "ABD"
puts answer | n = gets.to_i
n <= 999 ? answer = "ABC" : answer = "ABD"
puts answer | [
"misc.typo",
"assignment.variable.change",
"identifier.change"
] | 1,104,291 | 1,104,292 | u333374716 | ruby |
p03327 | n = gets.chomp_to_i
if n >= 1000
print("ABD")
else
print("ABC")
end | n = gets.chomp.to_i
if n >= 1000
print("ABD")
else
print("ABC")
end | [
"assignment.value.change",
"identifier.change",
"call.add"
] | 1,104,316 | 1,104,317 | u691896522 | ruby |
p03326 | N, M = gets.split.map &:to_i
XYZ = $<.map{|s|
s.split.map &:to_i
}
signs = [1, -1]
p signs.product(signs, signs).map{|a,b,c|
XYZ.map{|x,y,z|
x*a + y*b + z*c
}.max(M).inject:+
}.max
| N, M = gets.split.map &:to_i
XYZ = $<.map{|s|
s.split.map &:to_i
}
signs = [1, -1]
p signs.product(signs, signs).map{|a,b,c|
XYZ.map{|x,y,z|
x*a + y*b + z*c
}.max(M).inject(0, :+)
}.max
| [
"call.arguments.add",
"call.arguments.change"
] | 1,104,464 | 1,104,465 | u711705317 | ruby |
p03326 | N, M = gets.split.map(&:to_i)
X = (1..N).map { gets.split.map(&:to_i) }
def max_positive(xs)
xs.map {|x, y, z| x+y+z }.sort.reverse.take(M).inject(&:+)
end
puts (
(
[-1, 1].product([-1, 1], [-1, 1]).map do |s|
xs = X.map do |x|
(0...3).map {|i| s[i]*x[i] }
end
max_positive(xs)
end
).max
)
| N, M = gets.split.map(&:to_i)
X = (1..N).map { gets.split.map(&:to_i) }
def max_positive(xs)
xs.map {|x, y, z| x+y+z }.sort.reverse.take(M).inject(0, &:+)
end
puts (
(
[-1, 1].product([-1, 1], [-1, 1]).map do |s|
xs = X.map do |x|
(0...3).map {|i| s[i]*x[i] }
end
max_positive(xs)
end
).max
)
| [
"call.arguments.add"
] | 1,104,519 | 1,104,520 | u967136506 | ruby |
p03327 | n = gets.to_i
if n <= 999
puts "ABC#{n}"
else
puts "ABD"
end | n = gets.to_i
if n <= 999
puts "ABC"
else
puts "ABD"
end | [
"literal.string.change",
"call.arguments.change"
] | 1,104,628 | 1,104,629 | u053003310 | ruby |
p03327 | s=gets.to_i
(puts 999>=s )? "ABC":"ABD" | s=gets.to_i
puts 999>=s ? "ABC":"ABD" | [
"control_flow.branch.if.condition.change"
] | 1,104,639 | 1,104,640 | u069859306 | ruby |
p03327 | s=gets.to_i
puts 999>s ? "ABC":"ABD" | s=gets.to_i
puts 999>=s ? "ABC":"ABD" | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,104,641 | 1,104,640 | u069859306 | ruby |
p03327 | s=gets.to_i
p 999>s ? "ABC":"ABD" | s=gets.to_i
puts 999>=s ? "ABC":"ABD" | [
"call.function.change",
"io.output.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,104,642 | 1,104,640 | u069859306 | ruby |
p03327 | N = gets.to_i
puts N < 1000 ? 'ABC' : 'ABC'
| N = gets.to_i
puts N < 1000 ? 'ABC' : 'ABD' | [
"literal.string.change",
"call.arguments.change"
] | 1,104,833 | 1,104,834 | u627981707 | ruby |
p03327 | puts.gets.to_i<1000?:ABC: :ABD | puts gets.to_i<1000?"ABC":"ABD" | [
"control_flow.branch.if.condition.change"
] | 1,104,886 | 1,104,887 | u831999711 | ruby |
p03327 | s=gets.chomp
if s <= 999
puts "ABC"
else
puts "ABD"
end
| s=gets.to_i
if s <= 999
puts "ABC"
else
puts "ABD"
end
| [
"assignment.value.change",
"identifier.change"
] | 1,104,896 | 1,104,897 | u543160080 | ruby |
p03327 | n=gets.to_i
if n<1000
puts "ABC"
else
puts "ARC"
end | n=gets.to_i
if n<1000
puts "ABC"
else
puts "ABD"
end | [
"literal.string.change",
"call.arguments.change"
] | 1,104,941 | 1,104,942 | u394482932 | ruby |
p03327 | puts (gets.chomp.to_i < 100)? "ABC": "ABD" | puts (gets.chomp.to_i < 1000)? "ABC": "ABD"
| [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,104,985 | 1,104,986 | u145123922 | ruby |
p03327 | puts gets.to_i < 100 ? "ABC" : "ABD" | puts gets.to_i < 1000 ? "ABC" : "ABD" | [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,105,036 | 1,105,037 | u328735699 | ruby |
p03327 | p gets.to_i >= 1000 ? "ABD" : "ABC" | puts gets.to_i >= 1000 ? "ABD" : "ABC" | [
"call.function.change",
"io.output.change"
] | 1,105,220 | 1,105,221 | u510556034 | ruby |
p03328 | a, b = gets.chomp.split(' ').map(&:to_i)
n = b - a
sum = 0
n.times do |i|
break if sum >= a
sum += i
end
puts sum - a
| a, b = gets.chomp.split(' ').map(&:to_i)
n = b - a
sum = 0
n.times do |i|
sum += i
end
puts sum - a
| [] | 1,105,881 | 1,105,882 | u308793296 | ruby |
p03328 | a, b = gets.strip.split.map(&:to_i)
sum = 0
(b - a).times { |i| sum += i + 1 }
puts sum - a | a, b = gets.strip.split.map(&:to_i)
sum = 0
(b - a).times { |i| sum += i + 1 }
puts sum - b | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,106,006 | 1,106,007 | u707614029 | ruby |
p03328 | a, b = gets.strip.split.map(&:to_i)
sum = 0
(b - a).times { |i| sum += sum + i + 1 }
puts sum | a, b = gets.strip.split.map(&:to_i)
sum = 0
(b - a).times { |i| sum += i + 1 }
puts sum - b | [
"expression.operation.binary.remove"
] | 1,106,008 | 1,106,007 | u707614029 | ruby |
p03328 | a, b = gets.strip.split.map(&:to_i)
sum = 0
(b - a).times { |i| sum += i + 1 }
puts sum | a, b = gets.strip.split.map(&:to_i)
sum = 0
(b - a).times { |i| sum += i + 1 }
puts sum - b | [
"expression.operation.binary.add"
] | 1,106,009 | 1,106,007 | u707614029 | ruby |
p03329 | N=gets.to_i
ans = N;
for i in 1..N
cc=0
t=i
u=N-i
while t>0
cc+=t%6
t/=6
end
while u>0
cc+=u%9
u/=9
end
if ans>cc
ans=cc
end
end
puts ans | N=gets.to_i
ans = N;
for i in 0..N
cc=0
t=i
u=N-i
while t>0
cc+=t%6
t/=6
end
while u>0
cc+=u%9
u/=9
end
if ans>cc
ans=cc
end
end
puts ans | [
"literal.number.integer.change"
] | 1,106,319 | 1,106,320 | u805977091 | ruby |
p03329 | N = gets.to_i
res = N
(0..N).each{|i|
c, t = 0, i
while t > 0 do
c += t%6
t /= 6
end
t = N-i
while t > 0 do
c += t%9
t /= 9
end
res = c if res > c
p [res,i]
}
p res | N = gets.to_i
res = N
(0..N).each{|i|
c, t = 0, i
while t > 0 do
c += t%6
t /= 6
end
t = N-i
while t > 0 do
c += t%9
t /= 9
end
res = c if res > c
}
p res | [
"call.remove"
] | 1,106,678 | 1,106,679 | u091810847 | ruby |
p03329 | n = gets.to_i
dp = Array.new(n + 1, 100000)
dp[0] = 0
m = [1]
x = 6
while x < n do
m << x
x *= 6
end
x = 9
while x < n do
m << x
x *= 9
end
(1..n).each do |i|
m.each do |j|
if i - j >= 0
dp[i] = [dp[i], dp[i - j] + 1].min
end
end
end
puts dp[n]
| n = gets.to_i
dp = Array.new(n + 1, 100000)
dp[0] = 0
m = [1]
x = 6
while x <= n do
m << x
x *= 6
end
x = 9
while x <= n do
m << x
x *= 9
end
(1..n).each do |i|
m.each do |j|
if i - j >= 0
dp[i] = [dp[i], dp[i - j] + 1].min
end
end
end
puts dp[n]
| [
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 1,106,957 | 1,106,958 | u457499130 | ruby |
p03329 | N = gets.strip.to_i
def chmin(a, b) a < b ? a : b end
INF = N
dp = Array.new(100100) { INF }
dp[0] = 0
N.times do |i|
dp[i + 1] = chmin(dp[i] + 1, dp[i + 1])
[6, 9].each do |p|
j = p
while j <= N
dp[i + j] = chmin(dp[i] + 1, dp[i + j])
j *= p
end
end
end
puts dp[N]
| N = gets.strip.to_i
def chmin(a, b) a < b ? a : b end
INF = N
dp = Array.new(1001000) { INF }
dp[0] = 0
N.times do |i|
dp[i + 1] = chmin(dp[i] + 1, dp[i + 1])
[6, 9].each do |p|
j = p
while j <= N
dp[i + j] = chmin(dp[i] + 1, dp[i + j])
j *= p
end
end
end
puts dp[N]
| [
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change"
] | 1,107,134 | 1,107,135 | u707614029 | ruby |
p03329 | # util functions
# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag
def pd(str)
p str if $debugFlag
end
def putsd(str)
puts str if $debugFlag
end
# input
inputs = []
lc = 0
while l = $stdin.gets do
if false
inputs << l.chomp.split(" ").map(&:to_s)
else
inputs << l.chomp.split(" ").map(&:to_i)
end
lc += 1
end
nn = inputs[0][0]
# input check
if $debugFlag
p "--- INPUT (begin) ---"
inputs.each do |l_i|
p l_i
end
p "--- INPUT (end) ---"
print "\n"
end
# body
if $debugFlag
end
def find6(n)
ret = 1
while n > ret*6
ret *= 6
end
return ret
end
def find9(n)
ret = 1
while n > ret*9
ret *= 9
end
return ret
end
$hh = {}
def rec(n, d)
return d if n == 0
return $hh["#{n},#{d}"] if $hh["#{n},#{d}"] != nil
n6 = find6(n)
n9 = find9(n)
$hh["#{n},#{d}"] = [rec(n - n6, d + 1), rec(n - n9, d + 1)].min
return $hh["#{n},#{d}"]
end
puts rec(nn, 0)
| # util functions
# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag
def pd(str)
p str if $debugFlag
end
def putsd(str)
puts str if $debugFlag
end
# input
inputs = []
lc = 0
while l = $stdin.gets do
if false
inputs << l.chomp.split(" ").map(&:to_s)
else
inputs << l.chomp.split(" ").map(&:to_i)
end
lc += 1
end
nn = inputs[0][0]
# input check
if $debugFlag
p "--- INPUT (begin) ---"
inputs.each do |l_i|
p l_i
end
p "--- INPUT (end) ---"
print "\n"
end
# body
if $debugFlag
end
def find6(n)
ret = 1
while n >= ret*6
ret *= 6
end
return ret
end
def find9(n)
ret = 1
while n >= ret*9
ret *= 9
end
return ret
end
$hh = {}
def rec(n, d)
return d if n == 0
return $hh["#{n},#{d}"] if $hh["#{n},#{d}"] != nil
n6 = find6(n)
n9 = find9(n)
$hh["#{n},#{d}"] = [rec(n - n6, d + 1), rec(n - n9, d + 1)].min
return $hh["#{n},#{d}"]
end
puts rec(nn, 0)
| [
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 1,107,157 | 1,107,158 | u714724786 | ruby |
p03329 | n = gets.chomp.to_i
# 9 ^ i + 6 ^ j + k
ans = n
n.times do |i|
x = 0
a = i
b = n - i
while a > 0
x += a % 6
a /= 6
end
while b > 0
x += b % 9
b /= 9
end
ans = [ans, x].min
end
puts ans | n = gets.chomp.to_i
# 9 ^ i + 6 ^ j + k
ans = n
0.upto(n) do |i|
x = 0
a = i
b = n - i
while a > 0
x += a % 6
a /= 6
end
while b > 0
x += b % 9
b /= 9
end
ans = [ans, x].min
end
puts ans | [
"identifier.replace.remove",
"literal.replace.add",
"identifier.change",
"call.arguments.add"
] | 1,107,353 | 1,107,354 | u910756197 | ruby |
p03329 | n = gets.to_i
res = n
for i in 0..10
cc = 0
t = i
while t>0
cc += t%6
t /= 6
end
t = n-i
while t>0
cc += t%9
t /= 9
end
if res>cc
res = cc
end
end
puts res | n = gets.to_i
res = n
for i in 0..n
cc = 0
t = i
while t>0
cc += t%6
t /= 6
end
t = n-i
while t>0
cc += t%9
t /= 9
end
if res>cc
res = cc
end
end
puts res | [
"identifier.replace.add",
"literal.replace.remove"
] | 1,107,424 | 1,107,425 | u550943777 | ruby |
p03329 | n=gets.to_i
k=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
s=Array.new(100001,0)
for j in 1..n
s[j]=j
end
for i in 1..11
if k[i] < n then
for j in k[i]..n
s[j]=1+s[j-k[i]] if s[j] > 1+s[j-k[i]]
end
end
end
puts s[n] | n=gets.to_i
k=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
s=Array.new(100001,0)
for j in 1..n
s[j]=j
end
for i in 1..11
if k[i] <= n then
for j in k[i]..n
s[j]=1+s[j-k[i]] if s[j] > 1+s[j-k[i]]
end
end
end
puts s[n] | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,107,453 | 1,107,454 | u707053380 | ruby |
p03329 | a=[1, 6, 36, 216, 1296, 7776, 46656]
b=[1,9, 81, 729, 6561, 59049, 531441]
n=gets.to_i
c=0
t=[n]
loop{
break if t.include?(0)
for k in 0...t.size
e=t[k]
for i in 0..5
if a[i]<=e
t<<e-a[i]
end
if b[i]<=e
t<<e-b[i]
end
break if n<a[i]
end
end
t.uniq!
c+=1
}
p c
| a=[1, 6, 36, 216, 1296, 7776, 46656]
b=[1,9, 81, 729, 6561, 59049, 531441]
n=gets.to_i
c=0
t=[n]
loop{
break if t.include?(0)
for k in 0...t.size
e=t[k]
for i in 0..6
if a[i]<=e
t<<e-a[i]
end
if b[i]<=e
t<<e-b[i]
end
break if n<a[i]
end
end
t.uniq!
c+=1
}
p c
| [
"literal.number.integer.change"
] | 1,107,546 | 1,107,547 | u610697662 | ruby |
p03330 | eval"N,C,*D="+`dd`.split*?,
r=*0...C
s,t,u=(0...N*N).group_by{|i|(i/N+i%N)%3}.map{|_,v|r.map{|t|s=0;v.map{|f|s+=D[~-D[~f]*C+t]};s}}
p r.permutation(3).map{|x,y,z|s[x]+t[y]+u[z]}.min | eval"N,C,*D="+`dd`.split*?,
r=*0...C
s,t,u=(0...N*N).group_by{|i|(i/N+i%N)%3}.map{|_,v|r.map{|t|s=0;v.map{|f|s+=D[~-D[~f]*C+t]};s}}
p N<2?0:r.permutation(3).map{|x,y,z|s[x]+t[y]+u[z]}.min | [
"call.arguments.change"
] | 1,107,971 | 1,107,973 | u019489252 | ruby |
p03331 | s = gets
if s[0] == '1' and s[1..-1] == '0'*(s.size-1)
ans = 10
else
ans = 0
s.size.times do |i| ans += s[i].to_i end
end
puts ans
| s = gets.chomp
if s[0] == '1' and s[1..-1] == '0'*(s.size-1)
ans = 10
else
ans = 0
s.size.times do |i| ans += s[i].to_i end
end
puts ans
| [
"call.add"
] | 1,108,107 | 1,108,108 | u714724786 | ruby |
p03331 | n=gets.to_i
array=[]
def sum_of_digits(c)
c.to_s.split("").map { |s| s.to_i }.inject(:+)
end
n.times do |a|
b=n-a
array.push(sum_of_digits(b)+sum_of_digits(a))
a+=1
end
p array.min | n=gets.to_i
array=[]
def sum_of_digits(c)
c.to_s.split("").map { |s| s.to_i }.inject(:+)
end
n.times do |a|
b=n-a
array.push(sum_of_digits(b)+sum_of_digits(a))
a+=1
end
array.delete(1)
p array.min
| [
"call.add"
] | 1,108,459 | 1,108,460 | u318909153 | ruby |
p03331 | n = gets.to_i
ans = []
(1..n).each do |a|
b = n - a
sum_a = a.to_s.chars.map(&:to_i).inject(:+)
sum_b = b.to_s.chars.map(&:to_i).inject(:+)
ans << (sum_a + sum_b)
end
puts ans.min | n = gets.to_i
ans = []
(1..n-1).each do |a|
b = n - a
sum_a = a.to_s.chars.map(&:to_i).inject(:+)
sum_b = b.to_s.chars.map(&:to_i).inject(:+)
ans << (sum_a + sum_b)
end
puts ans.min | [
"expression.operation.binary.add"
] | 1,108,473 | 1,108,474 | u809809975 | ruby |
p03331 | n = gets.to_i
ans = []
(2..n-1).each do |a|
b = n - a
sum_a = a.to_s.chars.map(&:to_i).inject(:+)
sum_b = b.to_s.chars.map(&:to_i).inject(:+)
ans << (sum_a + sum_b)
end
puts ans.min | n = gets.to_i
ans = []
(1..n-1).each do |a|
b = n - a
sum_a = a.to_s.chars.map(&:to_i).inject(:+)
sum_b = b.to_s.chars.map(&:to_i).inject(:+)
ans << (sum_a + sum_b)
end
puts ans.min | [
"literal.number.integer.change"
] | 1,108,644 | 1,108,645 | u239218660 | ruby |
p03331 | n = gets.to_i
ans = []
(2..n).each do |a|
b = n - a
sum_a = a.to_s.chars.map(&:to_i).inject(:+)
sum_b = b.to_s.chars.map(&:to_i).inject(:+)
ans << (sum_a + sum_b)
end
puts ans.min | n = gets.to_i
ans = []
(1..n-1).each do |a|
b = n - a
sum_a = a.to_s.chars.map(&:to_i).inject(:+)
sum_b = b.to_s.chars.map(&:to_i).inject(:+)
ans << (sum_a + sum_b)
end
puts ans.min | [
"literal.number.integer.change"
] | 1,108,646 | 1,108,645 | u239218660 | ruby |
p03331 | n = gets.to_i
if [10,100,1000,10000].include?(n)
p 10
else
p n.to_s.split(//).map(&:to_i).inject(:+)
end | n = gets.to_i
if [10,100,1000,10000,100000].include?(n)
p 10
else
p n.to_s.split(//).map(&:to_i).inject(:+)
end | [
"control_flow.branch.if.condition.change",
"literal.array.change"
] | 1,108,768 | 1,108,769 | u939552576 | ruby |
p03331 | n = gets.chomp.to_i
min = 10000000
sums = []
(1..n).each do |a|
sum = a.to_s.split("").map(&:to_i).inject(:+) + (n-a).to_s.split("").map(&:to_i).inject(:+)
sums.push(sum)
end
puts sums.min
| n = gets.chomp.to_i
sums = []
(1..n-1).each do |a|
sum = a.to_s.split("").map(&:to_i).inject(:+) + (n-a).to_s.split("").map(&:to_i).inject(:+)
sums.push(sum)
end
puts sums.min
| [
"assignment.remove",
"expression.operation.binary.add"
] | 1,109,002 | 1,109,003 | u191196346 | ruby |
p03331 | p n=gets.chars.map(&:to_i).reduce(:+)<2?10:n | p (n=gets.chars.map(&:to_i).reduce(:+))<2?10:n | [
"control_flow.branch.if.condition.change"
] | 1,109,077 | 1,109,078 | u514067551 | ruby |
p03331 | (n=gets.chars.map(&:to_i).reduce :+)<2?10:n | p (n=gets.chars.map(&:to_i).reduce(:+))<2?10:n | [
"io.output.change",
"call.add",
"control_flow.branch.if.condition.change"
] | 1,109,080 | 1,109,078 | u514067551 | ruby |
p03331 | N=gets.to_i
a = 1
b = 0
l = []
while a < (N / 2) && b < N do
b = N - a
m = 0
n = (a.to_s + b.to_s).split""
n.each do |k|
m += k.to_i
end
l << m
a += 1
end
puts l.min
| N=gets.to_i
a = 1
b = 0
l = []
while a < (N / 2) + 1 && b < N do
b = N - a
m = 0
n = (a.to_s + b.to_s).split""
n.each do |k|
m += k.to_i
end
l << m
a += 1
end
puts l.min
| [
"expression.operation.binary.add"
] | 1,109,097 | 1,109,098 | u543160080 | ruby |
p03331 | n = gets.to_i
answer = [*2..(n - 2)].map {|a|
[a, n - a].map {|b|
b.to_s.split('').map(&:to_i).reduce(:+)
}.reduce(:+)
}.min
puts answer | n = gets.to_i
answer = [*1..(n - 1)].map {|a|
[a, n - a].map {|b|
b.to_s.split('').map(&:to_i).reduce(:+)
}.reduce(:+)
}.min
puts answer | [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,109,184 | 1,109,185 | u820172510 | ruby |
p03331 | n = gets.to_i
answer = [*2..n].map {|a|
[a, n - a].map {|b|
b.to_s.split('').map(&:to_i).reduce(:+)
}.reduce(:+)
}.min
puts answer | n = gets.to_i
answer = [*1..(n - 1)].map {|a|
[a, n - a].map {|b|
b.to_s.split('').map(&:to_i).reduce(:+)
}.reduce(:+)
}.min
puts answer | [
"literal.number.integer.change",
"assignment.value.change"
] | 1,109,186 | 1,109,185 | u820172510 | ruby |
p03331 | n = gets.to_i
answer = [*0..n].map {|a|
[a, n - a].map {|b|
b.to_s.split('').map(&:to_i).reduce(:+)
}.reduce(:+)
}.min
puts answer | n = gets.to_i
answer = [*1..(n - 1)].map {|a|
[a, n - a].map {|b|
b.to_s.split('').map(&:to_i).reduce(:+)
}.reduce(:+)
}.min
puts answer | [
"literal.number.integer.change",
"assignment.value.change"
] | 1,109,187 | 1,109,185 | u820172510 | ruby |
p03332 | N,A,B,K=gets.split.map &:to_i;M=998244353;I=[1,1];*F=I;*R=I;2.upto(N){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M};r=0;0.upto(N){|a|b=(K-A*a)/B;0<=b&&A*a+B*b==N&&r=(r+F[N]**2*R[a]*R[N-a]*R[b]*R[N-b])%M};p r | N,A,B,K=gets.split.map &:to_i;M=998244353;I=[1,1];*F=I;*R=I;2.upto(N){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M};r=0;0.upto(N){|a|b=(K-A*a)/B;0<=b&&b<=N&&A*a+B*b==K&&r=(r+F[N]**2*R[a]*R[N-a]*R[b]*R[N-b])%M};p r | [
"expression.operation.binary.change"
] | 1,109,901 | 1,109,902 | u280667879 | ruby |
p03337 | a, b = gets.split.map &:to_i
p [a+b.a-b,a*b].max | a, b = gets.split.map &:to_i
p [a+b,a-b,a*b].max | [
"misc.typo",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,110,439 | 1,110,440 | u489339677 | ruby |
p03337 | a, b = gets.split.map :to_i
p [a+b.a-b,a*b].max | a, b = gets.split.map &:to_i
p [a+b,a-b,a*b].max | [
"call.arguments.change",
"misc.typo",
"expression.operation.binary.change"
] | 1,110,441 | 1,110,440 | u489339677 | ruby |
p03337 | a, b = gets.splito.map &:to_i
p [a + b. a - b, a * b].max
| a, b = gets.split.map &:to_i
p [a+b,a-b,a*b].max | [
"assignment.value.change",
"identifier.change",
"misc.typo",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,110,443 | 1,110,440 | u489339677 | ruby |
p03337 | arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
a = arr[0] + arr[1]
b = arr[0] - arr[1]
c = arr[0] * arr[1]
if
a >= b and a >= c
puts a
elsif
b >= a and b >= c
else
puts c
end
| arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end
a = arr[0] + arr[1]
b = arr[0] - arr[1]
c = arr[0] * arr[1]
if
a >= b and a >= c
puts a
elsif
b >= a and b >= c
puts b
else
puts c
end | [
"call.add"
] | 1,110,868 | 1,110,869 | u294388467 | ruby |
p03337 | A,B = gets.split.map(&:to_i)
U = Array.new
U[0] = A+B
U[1] = A-B
U[2] = A*b
max = -1000000000
for k in 0..2
if max < U[k]
max = U[k]
end
end
puts(max) | A,B = gets.split.map(&:to_i)
U = Array.new
U[0] = A+B
U[1] = A-B
U[2] = A*B
max = -1000000000
for k in 0..2
if max < U[k]
max = U[k]
end
end
puts(max) | [
"assignment.value.change",
"call.arguments.change"
] | 1,110,966 | 1,110,967 | u241469130 | ruby |
p03337 | a, b = gets.split(" ").map(&:to_i)
puts [a + b, a - b, a * b] | a, b = gets.split(" ").map(&:to_i)
puts [a + b, a - b, a * b].max | [
"call.add"
] | 1,111,155 | 1,111,156 | u581122825 | ruby |
p03337 | A,B = gets.split.map(&:to_i)
if A * B > A + B then
if A * B > A - B then
print A * B
else
if A + B > A - B then
print A + B
else
print A - B
end
end
end | A,B = gets.split.map(&:to_i)
if A * B > A + B and A * B > A - B then
print A * B
else
if A + B > A - B then
print A + B
else
print A - B
end
end
| [] | 1,111,499 | 1,111,500 | u869218119 | ruby |
p03337 | a,b = gets.split(" ").map { |e| e.to_i }
puts [a+b, a-b, a*b].ma | a,b = gets.split(" ").map { |e| e.to_i }
puts [a+b, a-b, a*b].max
| [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 1,111,533 | 1,111,534 | u698460655 | ruby |
p03337 | a,b = gest.strip.split.map(&:to_i)
puts [a*b,a+b,a-b].max | a,b = gets.strip.split.map(&:to_i)
puts [a*b,a+b,a-b].max
| [
"misc.typo",
"assignment.value.change",
"identifier.change"
] | 1,111,864 | 1,111,865 | u313103408 | ruby |
p03338 | n=gets.to_i
s=gets
ans=0
n.times{|l|
a=Hash.new(0)
for i in 0..l do
a[s[i].ord-'a'.ord]=1
end
b=Hash.new(0)
for i in l..n do
b[s[i].ord-'a'.ord]=1
end
tans=0
a.each{|k,v|
tans+=1 if b[k]==1
}
ans=[ans,tans].max
}
p ans | n=gets.to_i
s=gets
ans=0
n.times{|l|
a=Hash.new(0)
for i in 0..l do
a[s[i].ord-'a'.ord]=1
end
b=Hash.new(0)
for i in l+1..n do
b[s[i].ord-'a'.ord]=1
end
tans=0
a.each{|k,v|
tans+=1 if b[k]==1
}
ans=[ans,tans].max
}
p ans | [
"expression.operation.binary.add"
] | 1,111,923 | 1,111,924 | u604693716 | ruby |
p03338 | n = gets.to_i
s = gets.chomp
ans = 0
(n - 1).times do |i|
l = s.chars[0..i + 1]
r = s.chars[i + 1..-1]
i = (l & r).uniq
ans = i.size if i.size >= ans
end
puts ans
| n = gets.to_i
s = gets.chomp
ans = 0
(n - 1).times do |i|
l = s.chars[0..i]
r = s.chars[i + 1..-1]
i = (l & r).uniq
ans = i.size if i.size >= ans
end
puts ans
| [
"expression.operation.binary.remove"
] | 1,111,933 | 1,111,934 | u889326464 | ruby |
p03338 | n = gets.to_i
s = gets.chomp
ans = 0
n.times do |i|
u = s.chars.uniq
f = s[0..i].chars.uniq
l = s[i..-1].chars.uniq
t = f.size + l.size - u.size
ans = t if ans < t
end
p ans | n = gets.to_i
s = gets.chomp
ans = 0
n.times do |i|
u = s.chars.uniq
f = s[0..i].chars.uniq
l = s[i+1..-1].chars.uniq
# p [f,l,u]
t = f.size + l.size - u.size
ans = t if ans < t
end
p ans
| [
"assignment.change"
] | 1,111,961 | 1,111,962 | u693378622 | ruby |
p03338 | n = gets.to_i
s = gets.chomp
ans = 0
n.times do |i|
u = s.chars.uniq
f = s[0..i].chars.uniq
l = s[i..-1].chars.uniq
t = f.size + l.size - u.size
ans = t if ans < t
end
p ans | n = gets.to_i
s = gets.chomp
ans = 0
n.times do |i|
u = s.chars.uniq
f = s[0..i].chars.uniq
l = s[i+1..-1].chars.uniq
# p [f,l,u]
t = f.size + l.size - u.size
ans = t if ans < t
end
p ans | [
"assignment.change"
] | 1,111,961 | 1,111,963 | u693378622 | ruby |
p03338 | n = gets.to_i
s = gets.chomp.split("")
ar = []
(0..n-2).to_a.each do |i|
ar << (s[0..i] & s[i+1..-1]).count
end
| n = gets.to_i
s = gets.chomp.split("")
ar = []
(0..n-2).to_a.each do |i|
ar << (s[0..i] & s[i+1..-1]).count
end
puts ar.max
| [
"call.add"
] | 1,111,988 | 1,111,989 | u012110567 | ruby |
p03338 | N = gets.chomp.to_i
S = gets.chomp.split("")
def include_both(a1, a2)
a1.sort!.uniq!
a2.sort!.uniq!
count = 0
for i in 0...a1.length do
for j in 0...a2.length do
if a1[i] == a2[j] then
count += 1
end
end
end
count
end
max = 0
for i in 1..(N/2) do
s1 = S[0, i]
s2 = S[i, N-1]
max = [max, include_both(s1, s2)].max
end
puts max | N = gets.chomp.to_i
S = gets.chomp.split("")
def include_both(a1, a2)
a1.sort!.uniq!
a2.sort!.uniq!
count = 0
for i in 0...a1.length do
for j in 0...a2.length do
if a1[i] == a2[j] then
count += 1
break
end
end
end
count
end
max = 0
for i in 1...N do
s1 = S[0, i]
s2 = S[i, N-1]
max = [max, include_both(s1, s2)].max
end
puts max | [
"control_flow.break.add"
] | 1,112,092 | 1,112,093 | u339791405 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.