problem_id
stringlengths 6
6
| buggy_code
stringlengths 8
526k
| fixed_code
stringlengths 12
526k
| labels
listlengths 0
15
⌀ | buggy_submission_id
int64 1
1.54M
| fixed_submission_id
int64 2
1.54M
| user_id
stringlengths 10
10
| language
stringclasses 8
values |
|---|---|---|---|---|---|---|---|
p02760
|
a = 3.times.map{gets.split(' ').map(&:to_i)}
n = gets.to_i
b = readlines.map(&:to_i)
flag = 0
#横
3.times.each do |r|
if b.include?(a[r][0])
if b.include?(a[r][1])
if b.include?(a[r][2])
flag = 1
break
end
end
end
end
#縦
3.times.each do |c|
if b.include?(a[0][c])
if b.include?(a[1][c])
if b.include?(a[2][c])
flag = 1
end
end
end
end
if b.include?(a[0][0])
if b.include?(a[1][1])
if b.include?(a[2][2])
flag = 1
end
end
end
if b.include?(a[0][2])
if b.include?(a[1][1])
if b.include?(a[0][0])
flag = 1
end
end
end
if flag == 1
puts 'Yes'
else
puts 'No'
end
|
a = 3.times.map{gets.split(' ').map(&:to_i)}
n = gets.to_i
b = readlines.map(&:to_i)
flag = 0
#横
3.times.each do |r|
if b.include?(a[r][0])
if b.include?(a[r][1])
if b.include?(a[r][2])
flag = 1
break
end
end
end
end
#縦
3.times.each do |c|
if b.include?(a[0][c])
if b.include?(a[1][c])
if b.include?(a[2][c])
flag = 1
end
end
end
end
if b.include?(a[0][0])
if b.include?(a[1][1])
if b.include?(a[2][2])
flag = 1
end
end
end
if b.include?(a[0][2])
if b.include?(a[1][1])
if b.include?(a[2][0])
flag = 1
end
end
end
if flag == 1
puts 'Yes'
else
puts 'No'
end
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 548,306
| 548,307
|
u802039083
|
ruby
|
p02760
|
def get_i() #空白区切の入力を数値(整数)の配列で返す
return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
return bool ? y : n
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
if n==1
return Array.new(size){init}
else
return Array.new(n).map{Array.new(size){init}}
end
end
s=array(3,1,0)
3.times do|i|
s[i]=get_i
end
n=gets.to_i
ans=array(3,3,0)
b=array(n,1,0)
n.times do|i|
b=gets.to_i
3.times do|j|
3.times do|k|
ans[j][k]=1 if s[j][k]==b
end
end
end
if ans[1][1]==1 and ans[0][0]==1 and ans[2][2]==1
puts "Yes"
elsif ans[1][1]==1 and ans[2][0]==1 and ans[0][2]==1
puts "Yes"
else
flag=true
3.times do|i|
flag=true
3.times do|j|
if s[i][j]!=1
flag=false
break
end
end
if flag
break
end
end
if flag
puts "Yes"
else
3.times do|i|
flag=true
3.times do|j|
if s[j][i]!=1
flag=false
break
end
end
if flag
break
end
end
puts yn_judge(flag)
end
end
|
def get_i() #空白区切の入力を数値(整数)の配列で返す
return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
return bool ? y : n
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
if n==1
return Array.new(size){init}
else
return Array.new(n).map{Array.new(size){init}}
end
end
s=array(3,1,0)
3.times do|i|
s[i]=get_i
end
n=gets.to_i
ans=array(3,3,0)
b=array(n,1,0)
n.times do|i|
b=gets.to_i
3.times do|j|
3.times do|k|
ans[j][k]=1 if s[j][k]==b
end
end
end
if ans[1][1]==1 and ans[0][0]==1 and ans[2][2]==1
puts "Yes"
elsif ans[1][1]==1 and ans[2][0]==1 and ans[0][2]==1
puts "Yes"
else
flag=true
3.times do|i|
flag=true
3.times do|j|
if ans[i][j]!=1
flag=false
break
end
end
if flag
break
end
end
if flag
puts "Yes"
else
3.times do|i|
flag=true
3.times do|j|
if ans[j][i]!=1
flag=false
break
end
end
if flag
break
end
end
puts yn_judge(flag)
end
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 548,375
| 548,376
|
u415400221
|
ruby
|
p02760
|
a1 = gets.split.map &:to_i
a2 = gets.split.map &:to_i
a3 = gets.split.map &:to_i
check1 = [0,0,0]
check2 = [0,0,0]
check3 = [0,0,0]
n = gets.to_i
n.times do |a|
b = gets.to_i
if a1.include?(b)
check1[a1.index(b)] = 1
elsif a2.include?(b)
check1[a2.index(b)] = 1
elsif a3.include?(b)
check1[a3.index(b)] = 1
end
end
yes = 0
3.times do |a|
yes = 1 if (check1[a] + check2[a] + check3[a]) == 3
end
yes = 1 if (check1[0] + check2[1] + check3[2]) == 3
yes = 1 if (check1[2] + check2[1] + check3[0]) == 3
if yes == 1
print "Yes"
elsif (check1.inject(:+) == 3) || (check2.inject(:+) == 3) || (check3.inject(:+) == 3)
print "Yes"
else
print "No"
end
|
a1 = gets.split.map &:to_i
a2 = gets.split.map &:to_i
a3 = gets.split.map &:to_i
check1 = [0,0,0]
check2 = [0,0,0]
check3 = [0,0,0]
n = gets.to_i
n.times do |a|
b = gets.to_i
if a1.include?(b)
check1[a1.index(b)] = 1
elsif a2.include?(b)
check2[a2.index(b)] = 1
elsif a3.include?(b)
check3[a3.index(b)] = 1
end
end
yes = 0
3.times do |a|
yes = 1 if (check1[a] + check2[a] + check3[a]) == 3
end
yes = 1 if (check1[0] + check2[1] + check3[2]) == 3
yes = 1 if (check1[2] + check2[1] + check3[0]) == 3
if yes == 1
print "Yes"
elsif ((check1.inject(:+) == 3) || (check2.inject(:+) == 3) || (check3.inject(:+) == 3))
print "Yes"
else
print "No"
end
|
[
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 548,414
| 548,415
|
u953495504
|
ruby
|
p02760
|
a = 3.times.map { gets.split.map(&:to_i) }
n = gets.chomp.to_i
b = []
ans = "N0"
n.times do
b.push(gets.chomp.to_i)
end
b.each do |b|
3.times do |i|
3.times do |j|
if a[i][j] == b then
a[i][j] = -1
end
end
end
end
ans = "Yes" if (a[0][0] + a[0][1] + a[0][2] == -3)
ans = "Yes" if (a[1][0] + a[1][1] + a[1][2] == -3)
ans = "Yes" if (a[2][0] + a[2][1] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][0] + a[2][0] == -3)
ans = "Yes" if (a[0][1] + a[1][1] + a[2][1] == -3)
ans = "Yes" if (a[0][2] + a[1][2] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][1] + a[2][2] == -3)
ans = "Yes" if (a[0][2] + a[1][1] + a[2][0] == -3)
puts "#{ans}"
|
a = 3.times.map { gets.split.map(&:to_i) }
n = gets.chomp.to_i
b = []
ans = "No"
n.times do
b.push(gets.chomp.to_i)
end
b.each do |b|
3.times do |i|
3.times do |j|
if a[i][j] == b then
a[i][j] = -1
end
end
end
end
ans = "Yes" if (a[0][0] + a[0][1] + a[0][2] == -3)
ans = "Yes" if (a[1][0] + a[1][1] + a[1][2] == -3)
ans = "Yes" if (a[2][0] + a[2][1] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][0] + a[2][0] == -3)
ans = "Yes" if (a[0][1] + a[1][1] + a[2][1] == -3)
ans = "Yes" if (a[0][2] + a[1][2] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][1] + a[2][2] == -3)
ans = "Yes" if (a[0][2] + a[1][1] + a[2][0] == -3)
puts ans
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 548,433
| 548,432
|
u571003347
|
ruby
|
p02760
|
a = 3.times.map { gets.split.map(&:to_i) }
n = gets.chomp.to_i
b = []
ans = "NO"
n.times do
b.push(gets.chomp.to_i)
end
b.each do |b|
3.times do |i|
3.times do |j|
if a[i][j] == b then
a[i][j] = -1
end
end
end
end
ans = "Yes" if (a[0][0] + a[0][1] + a[0][2] == -3)
ans = "Yes" if (a[1][0] + a[1][1] + a[1][2] == -3)
ans = "Yes" if (a[2][0] + a[2][1] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][0] + a[2][0] == -3)
ans = "Yes" if (a[0][1] + a[1][1] + a[2][1] == -3)
ans = "Yes" if (a[0][2] + a[1][2] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][1] + a[2][2] == -3)
ans = "Yes" if (a[0][2] + a[1][1] + a[2][0] == -3)
puts "#{ans}"
|
a = 3.times.map { gets.split.map(&:to_i) }
n = gets.chomp.to_i
b = []
ans = "No"
n.times do
b.push(gets.chomp.to_i)
end
b.each do |b|
3.times do |i|
3.times do |j|
if a[i][j] == b then
a[i][j] = -1
end
end
end
end
ans = "Yes" if (a[0][0] + a[0][1] + a[0][2] == -3)
ans = "Yes" if (a[1][0] + a[1][1] + a[1][2] == -3)
ans = "Yes" if (a[2][0] + a[2][1] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][0] + a[2][0] == -3)
ans = "Yes" if (a[0][1] + a[1][1] + a[2][1] == -3)
ans = "Yes" if (a[0][2] + a[1][2] + a[2][2] == -3)
ans = "Yes" if (a[0][0] + a[1][1] + a[2][2] == -3)
ans = "Yes" if (a[0][2] + a[1][1] + a[2][0] == -3)
puts ans
|
[
"literal.string.change",
"literal.string.case.change",
"assignment.value.change",
"call.arguments.change"
] | 548,434
| 548,432
|
u571003347
|
ruby
|
p02760
|
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
n = gets.chomp.to_i
d = []
n.times { d << gets.to_i }
if d.include?(a[0]) && d.include?(a[1]) && d.include?(a[2])
puts "Yes"
elsif d.include?(b[0]) && d.include?(b[1]) && d.include?(b[2])
puts "Yes"
elsif d.include?(c[0]) && d.include?(c[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[0]) && d.include?(c[0])
puts "Yes"
elsif d.include?(a[1]) && d.include?(b[1]) && d.include?(c[1])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[2]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[1]) && d.include?(c[0])
else
puts "No"
end
|
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
n = gets.chomp.to_i
d = []
n.times { d << gets.to_i }
if d.include?(a[0]) && d.include?(a[1]) && d.include?(a[2])
puts "Yes"
elsif d.include?(b[0]) && d.include?(b[1]) && d.include?(b[2])
puts "Yes"
elsif d.include?(c[0]) && d.include?(c[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[0]) && d.include?(c[0])
puts "Yes"
elsif d.include?(a[1]) && d.include?(b[1]) && d.include?(c[1])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[2]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[1]) && d.include?(c[0])
puts "Yes"
else
puts "No"
end
|
[
"call.add"
] | 548,440
| 548,441
|
u668278891
|
ruby
|
p02760
|
bingo = []
bingo[0] = gets.chomp.split(' ').map(&:to_i)
bingo[1] = gets.chomp.split(' ').map(&:to_i)
bingo[2] = gets.chomp.split(' ').map(&:to_i)
n = gets.chomp.to_i
numbers = []
for i in 1..n do
numbers.push(gets.chomp.to_i)
end
result = "No"
for row in bingo do
if (row - numbers).empty? then
result = "Yes"
end
end
for col in 0..2 do
column = []
for row in 0..2 do
column.push(bingo[row][col])
if (column - numbers).empty? then
result = "Yes"
end
end
end
slash = [bingo[0][0], bingo[1][1], bingo[2][2]]
if (slash - numbers).empty? then
result = "Yes"
end
rslash = [bingo[2][0], bingo[1][1], bingo[0][2]]
if (rslash - numbers).empty? then
result = "Yes"
end
print result
|
bingo = []
bingo[0] = gets.chomp.split(' ').map(&:to_i)
bingo[1] = gets.chomp.split(' ').map(&:to_i)
bingo[2] = gets.chomp.split(' ').map(&:to_i)
n = gets.chomp.to_i
numbers = []
for i in 1..n do
numbers.push(gets.chomp.to_i)
end
result = "No"
for row in bingo do
if (row - numbers).empty? then
result = "Yes"
end
end
for col in 0..2 do
column = []
for row in 0..2 do
column.push(bingo[row][col])
end
if (column - numbers).empty? then
result = "Yes"
end
end
slash = [bingo[0][0], bingo[1][1], bingo[2][2]]
if (slash - numbers).empty? then
result = "Yes"
end
rslash = [bingo[2][0], bingo[1][1], bingo[0][2]]
if (rslash - numbers).empty? then
result = "Yes"
end
print result
|
[] | 548,580
| 548,581
|
u394640249
|
ruby
|
p02760
|
bingo = []
bingo[0] = gets.chomp.split(' ').map(&:to_i)
bingo[1] = gets.chomp.split(' ').map(&:to_i)
bingo[2] = gets.chomp.split(' ').map(&:to_i)
n = gets.chomp.to_i
numbers = []
for i in 1..n do
numbers.push(gets.chomp.to_i)
end
result = ""
for row in bingo do
if (row - numbers).empty? then
result = "Yes"
end
end
for col in 0..2 do
column = []
for row in 0..2 do
column.push(bingo[row][col])
if (column - numbers).empty? then
result = "Yes"
end
end
end
slash = [bingo[0][0], bingo[1][1], bingo[2][2]]
if (slash - numbers).empty? then
result = "Yes"
end
rslash = [bingo[2][0], bingo[1][1], bingo[0][2]]
if (rslash - numbers).empty? then
result = "Yes"
end
print result
|
bingo = []
bingo[0] = gets.chomp.split(' ').map(&:to_i)
bingo[1] = gets.chomp.split(' ').map(&:to_i)
bingo[2] = gets.chomp.split(' ').map(&:to_i)
n = gets.chomp.to_i
numbers = []
for i in 1..n do
numbers.push(gets.chomp.to_i)
end
result = "No"
for row in bingo do
if (row - numbers).empty? then
result = "Yes"
end
end
for col in 0..2 do
column = []
for row in 0..2 do
column.push(bingo[row][col])
end
if (column - numbers).empty? then
result = "Yes"
end
end
slash = [bingo[0][0], bingo[1][1], bingo[2][2]]
if (slash - numbers).empty? then
result = "Yes"
end
rslash = [bingo[2][0], bingo[1][1], bingo[0][2]]
if (rslash - numbers).empty? then
result = "Yes"
end
print result
|
[
"literal.string.change",
"assignment.value.change"
] | 548,582
| 548,581
|
u394640249
|
ruby
|
p02760
|
Bingos = Array.new(8) { |_i| [] }
A1s = gets.split.map(&:to_i)
Bingos[0] << A1s[0]
Bingos[0] << A1s[1]
Bingos[0] << A1s[2]
Bingos[3] << A1s[0]
Bingos[4] << A1s[1]
Bingos[5] << A1s[2]
Bingos[6] << A1s[0]
Bingos[7] << A1s[2]
A2s = gets.split.map(&:to_i)
Bingos[1] << A2s[0]
Bingos[1] << A2s[1]
Bingos[1] << A2s[2]
Bingos[3] << A2s[0]
Bingos[4] << A2s[1]
Bingos[5] << A2s[2]
Bingos[6] << A2s[1]
Bingos[7] << A2s[1]
A3s = gets.split.map(&:to_i)
Bingos[2] << A3s[0]
Bingos[2] << A3s[1]
Bingos[2] << A3s[2]
Bingos[3] << A3s[0]
Bingos[4] << A3s[1]
Bingos[5] << A3s[2]
Bingos[6] << A3s[2]
Bingos[7] << A3s[0]
hits = (0..7).map { |i| [i, 0] }.to_h
N = gets.to_i
N.times do |i|
b = gets.to_i
(0..7).each do |x|
hits[x] += 1 if Bingos[x].find_index(b)
end
end
hits.values.each do |v|
next unless v == 3
puts 'yes'
exit
end
puts 'no'
|
Bingos = Array.new(8) { |_i| [] }
A1s = gets.split.map(&:to_i)
Bingos[0] << A1s[0]
Bingos[0] << A1s[1]
Bingos[0] << A1s[2]
Bingos[3] << A1s[0]
Bingos[4] << A1s[1]
Bingos[5] << A1s[2]
Bingos[6] << A1s[0]
Bingos[7] << A1s[2]
A2s = gets.split.map(&:to_i)
Bingos[1] << A2s[0]
Bingos[1] << A2s[1]
Bingos[1] << A2s[2]
Bingos[3] << A2s[0]
Bingos[4] << A2s[1]
Bingos[5] << A2s[2]
Bingos[6] << A2s[1]
Bingos[7] << A2s[1]
A3s = gets.split.map(&:to_i)
Bingos[2] << A3s[0]
Bingos[2] << A3s[1]
Bingos[2] << A3s[2]
Bingos[3] << A3s[0]
Bingos[4] << A3s[1]
Bingos[5] << A3s[2]
Bingos[6] << A3s[2]
Bingos[7] << A3s[0]
hits = (0..7).map { |i| [i, 0] }.to_h
N = gets.to_i
N.times do |i|
b = gets.to_i
(0..7).each do |x|
hits[x] += 1 if Bingos[x].find_index(b)
end
end
hits.values.each do |v|
next unless v == 3
puts 'Yes'
exit
end
puts 'No'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 548,690
| 548,691
|
u468215811
|
ruby
|
p02760
|
a = 3.times.map{gets.split.map(&:to_i)}
n = gets.to_i
b = n.times.map{gets.to_i}
i = 0
j =0
ans = [[0,0,0],[0,0,0],[0,0,0]]
a.each do |c|
c.each do |d|
if ans[i][j] == 0
b.each do |t|
if t == d
ans[i][j] =1
end
end
end
j +=1
end
j=0
i +=1
end
#p a
#p ans
array2 = ans.flatten
if(array2[0]+array2[3]+ array2[6]==3)
puts "Yes"
exit
elsif (array2[1]+array2[4]+ array2[7]==3)
puts "Yes"
exit
elsif(array2[2]+array2[5]+ array2[8]==3)
puts "Yes"
exit
elsif (array2[0]+array2[1]+ array2[2]==3)
puts "Yes"
exit
elsif (array2[3]+array2[4]+ array2[5]==3)
puts "Yes"
exit
elsif (array2[6]+array2[7]+ array2[8]==3)
puts "Yes"
exit
elsif (array2[0]+array2[4]+ array2[8]==3)
puts "Yes"
exit
elsif (array2[2]+array2[4]+ array2[6]==3)
puts "Yes"
exit
else
p No
end
|
a = 3.times.map{gets.split.map(&:to_i)}
n = gets.to_i
b = n.times.map{gets.to_i}
i = 0
j =0
ans = [[0,0,0],[0,0,0],[0,0,0]]
a.each do |c|
c.each do |d|
if ans[i][j] == 0
b.each do |t|
if t == d
ans[i][j] =1
end
end
end
j +=1
end
j=0
i +=1
end
#p a
#p ans
array2 = ans.flatten
if(array2[0]+array2[3]+ array2[6]==3)
puts "Yes"
exit
elsif (array2[1]+array2[4]+ array2[7]==3)
puts "Yes"
exit
elsif(array2[2]+array2[5]+ array2[8]==3)
puts "Yes"
exit
elsif (array2[0]+array2[1]+ array2[2]==3)
puts "Yes"
exit
elsif (array2[3]+array2[4]+ array2[5]==3)
puts "Yes"
exit
elsif (array2[6]+array2[7]+ array2[8]==3)
puts "Yes"
exit
elsif (array2[0]+array2[4]+ array2[8]==3)
puts "Yes"
exit
elsif (array2[2]+array2[4]+ array2[6]==3)
puts "Yes"
exit
else
puts "No"
end
|
[
"call.function.change",
"io.output.change",
"call.arguments.change"
] | 548,897
| 548,898
|
u990653216
|
ruby
|
p02760
|
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
n = gets.to_i
arr = []
n.times do
arr << gets.to_i
end
arr.each do |v|
(0..2).to_a.each do |i|
a[i] = nil if a[i] == v
b[i] = nil if b[i] == v
c[i] = nil if c[i] == v
end
end
tate1 = [a[0],b[0],c[0]].count{|n| n == nil}
tate2 = [a[1],b[1],c[1]].count{|n| n == nil}
tate3 = [a[2],b[2],c[3]].count{|n| n == nil}
yoko1 = [a[0],a[1],a[2]].count{|n| n == nil}
yoko2 = [b[0],b[1],b[2]].count{|n| n == nil}
yoko3 = [c[0],c[1],c[2]].count{|n| n == nil}
naname1 = [a[0],b[1],c[2]].count{|n| n == nil}
naname2 = [a[2],b[1],c[0]].count{|n| n == nil}
if tate1 ==3 || tate2 ==3 || tate3 ==3 || yoko1 ==3 || yoko2 ==3 || yoko3 ==3 || naname1==3 || naname2 ==3
puts "Yes"
else
puts "No"
end
|
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
n = gets.to_i
arr = []
n.times do
arr << gets.to_i
end
arr.each do |v|
(0..2).to_a.each do |i|
a[i] = nil if a[i] == v
b[i] = nil if b[i] == v
c[i] = nil if c[i] == v
end
end
tate1 = [a[0],b[0],c[0]].count{|n| n == nil}
tate2 = [a[1],b[1],c[1]].count{|n| n == nil}
tate3 = [a[2],b[2],c[2]].count{|n| n == nil}
yoko1 = [a[0],a[1],a[2]].count{|n| n == nil}
yoko2 = [b[0],b[1],b[2]].count{|n| n == nil}
yoko3 = [c[0],c[1],c[2]].count{|n| n == nil}
naname1 = [a[0],b[1],c[2]].count{|n| n == nil}
naname2 = [a[2],b[1],c[0]].count{|n| n == nil}
if tate1 ==3 || tate2 ==3 || tate3 ==3 || yoko1 ==3 || yoko2 ==3 || yoko3 ==3 || naname1==3 || naname2 ==3
puts "Yes"
else
puts "No"
end
|
[
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change"
] | 549,051
| 549,052
|
u012110567
|
ruby
|
p02760
|
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
n = gets.to_i
arr = []
n.times do
arr << gets.to_i
end
arr.each do |v|
(0..2).to_a.each do |i|
a[i] = nil if a[i] == v
b[i] = nil if b[i] == v
c[i] = nil if c[i] == v
end
end
tate1 = [a[0],b[0],c[0]].count{|n| n == nil}
tate2 = [a[1],b[1],c[1]].count{|n| n == nil}
tate3 = [a[2],b[2],c[3]].count{|n| n == nil}
yoko1 = [a[0],a[1],a[2]].count{|n| n == nil}
yoko2 = [b[0],b[1],b[2]].count{|n| n == nil}
yoko3 = [a[0],a[1],a[2]].count{|n| n == nil}
naname1 = [a[0],b[1],c[2]].count{|n| n == nil}
naname2 = [a[2],b[1],c[0]].count{|n| n == nil}
if tate1 ==3 || tate2 ==3 || tate3 ==3 || yoko1 ==3 || yoko2 ==3 || yoko3 ==3 || naname1==3 || naname2 ==3
puts "Yes"
else
puts "No"
end
|
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
n = gets.to_i
arr = []
n.times do
arr << gets.to_i
end
arr.each do |v|
(0..2).to_a.each do |i|
a[i] = nil if a[i] == v
b[i] = nil if b[i] == v
c[i] = nil if c[i] == v
end
end
tate1 = [a[0],b[0],c[0]].count{|n| n == nil}
tate2 = [a[1],b[1],c[1]].count{|n| n == nil}
tate3 = [a[2],b[2],c[2]].count{|n| n == nil}
yoko1 = [a[0],a[1],a[2]].count{|n| n == nil}
yoko2 = [b[0],b[1],b[2]].count{|n| n == nil}
yoko3 = [c[0],c[1],c[2]].count{|n| n == nil}
naname1 = [a[0],b[1],c[2]].count{|n| n == nil}
naname2 = [a[2],b[1],c[0]].count{|n| n == nil}
if tate1 ==3 || tate2 ==3 || tate3 ==3 || yoko1 ==3 || yoko2 ==3 || yoko3 ==3 || naname1==3 || naname2 ==3
puts "Yes"
else
puts "No"
end
|
[
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"identifier.change"
] | 549,053
| 549,052
|
u012110567
|
ruby
|
p02760
|
arr = []
3.times do
s = gets.split.map &:to_i
arr << s
end
n = gets.to_i
num = []
count = 0
n.times do
b = gets.to_i
(0...3).each do |i|
if arr[i].include?(b)
h = arr[i].index(b)
arr[i][h] = 0
end
end
end
check = 0
(0...3).each do |i|
(0...3).each do |j|
count += 1 if arr[i][j].zero?
end
if count == 3
check = 1
end
count = 0
end
count = 0
(0...3).each do |i|
(0...3).each do |j|
count += 1 if arr[j][i].zero?
if count == 3
check = 1
end
count = 0
end
end
if arr[0][0].zero? && arr[1][1].zero? && arr[2][2].zero?
check = 1
end
if arr[0][2].zero? && arr[1][1].zero? && arr[2][0].zero?
check = 1
end
if check == 1
puts :Yes
else
puts :No
end
|
arr = []
3.times do
s = gets.split.map &:to_i
arr << s
end
n = gets.to_i
num = []
count = 0
n.times do
b = gets.to_i
(0...3).each do |i|
if arr[i].include?(b)
h = arr[i].index(b)
arr[i][h] = 0
end
end
end
check = 0
(0...3).each do |i|
(0...3).each do |j|
count += 1 if arr[i][j].zero?
end
if count == 3
check = 1
end
count = 0
end
count = 0
(0...3).each do |i|
(0...3).each do |j|
count += 1 if arr[j][i].zero?
end
if count == 3
check = 1
end
count = 0
end
if arr[0][0].zero? && arr[1][1].zero? && arr[2][2].zero?
check = 1
end
if arr[0][2].zero? && arr[1][1].zero? && arr[2][0].zero?
check = 1
end
if check == 1
puts :Yes
else
puts :No
end
|
[] | 549,165
| 549,166
|
u437368899
|
ruby
|
p02760
|
as = []
bingo = []
3.times{
a = gets.split.map(&:to_i)
as << a
temp = {}
a.each{ |aa|
temp[aa] = false
}
bingo << temp
}
3.times{ |i|
temp = {}
temp[as[0][i]] = false
temp[as[1][i]] = false
temp[as[2][i]] = false
bingo << temp
}
temp = {}
temp[as[0][0]] = false
temp[as[1][1]] = false
temp[as[2][2]] = false
bingo << temp
temp = {}
temp[as[2][0]] = false
temp[as[1][1]] = false
temp[as[0][2]] = false
bingo << temp
print bingo
puts
n = gets.to_i
n.times{
b = gets.to_i
bingo.each{ |bingo_e|
if bingo_e[b] == false then
bingo_e[b] = true
end
}
}
if bingo.select{ |b| b.values == [true,true,true]}.size > 0 then
puts 'Yes'
else
puts 'No'
end
|
as = []
bingo = []
3.times{
a = gets.split.map(&:to_i)
as << a
temp = {}
a.each{ |aa|
temp[aa] = false
}
bingo << temp
}
3.times{ |i|
temp = {}
temp[as[0][i]] = false
temp[as[1][i]] = false
temp[as[2][i]] = false
bingo << temp
}
temp = {}
temp[as[0][0]] = false
temp[as[1][1]] = false
temp[as[2][2]] = false
bingo << temp
temp = {}
temp[as[2][0]] = false
temp[as[1][1]] = false
temp[as[0][2]] = false
bingo << temp
n = gets.to_i
n.times{
b = gets.to_i
bingo.each{ |bingo_e|
if bingo_e[b] == false then
bingo_e[b] = true
end
}
}
if bingo.select{ |b| b.values == [true,true,true]}.size > 0 then
puts 'Yes'
else
puts 'No'
end
|
[
"call.remove",
"io.output.change"
] | 549,252
| 549,253
|
u874414087
|
ruby
|
p02760
|
=begin
A A A
A A A
A A A
N
b1
...
bn
=end
as1 = gets.chomp.split(" ").map(&:to_i)
as2 = gets.chomp.split(" ").map(&:to_i)
as3 = gets.chomp.split(" ").map(&:to_i)
as = as1 + as2 + as3
n = gets.chomp.to_i
bs = []
for i in (0...n) do
bs << gets.chomp.to_i
end
bingos = Array.new(9, false)
bs.each do |b|
if (i = as.index(b))
bingos[i] = true
end
end
answer = false
[
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,5],
].each do |i1,j1,k1|
if bingos[i1] && bingos[j1] && bingos[k1]
answer = true
end
end
if answer
puts "Yes"
else
puts "No"
end
|
=begin
A A A
A A A
A A A
N
b1
...
bn
=end
as1 = gets.chomp.split(" ").map(&:to_i)
as2 = gets.chomp.split(" ").map(&:to_i)
as3 = gets.chomp.split(" ").map(&:to_i)
as = as1 + as2 + as3
n = gets.chomp.to_i
bs = []
for i in (0...n) do
bs << gets.chomp.to_i
end
bingos = Array.new(9, false)
bs.each do |b|
if (i = as.index(b))
bingos[i] = true
end
end
answer = false
[
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6],
].each do |i1,j1,k1|
if bingos[i1] && bingos[j1] && bingos[k1]
answer = true
end
end
if answer
puts "Yes"
else
puts "No"
end
|
[
"literal.number.integer.change"
] | 549,312
| 549,313
|
u462011322
|
ruby
|
p02760
|
bingo = []
bingo.push gets.split(' ').map(&:to_i)
bingo.push gets.split(' ').map(&:to_i)
bingo.push gets.split(' ').map(&:to_i)
re = []
n = gets.to_i
n.times do
re.push gets.to_i
end
p re
re.each do |r|
0.upto 2 do |g|
0.upto 2 do |s|
bingo[g][s] = 0 if r == bingo[g][s]
end
end
end
p bingo
3.times do |i|
if bingo[i].all? { |b| b == 0 }
puts 'Yes'
exit
end
end
3.times do |i|
t = 0
3.times do |j|
t += bingo[j][i]
end
if t == 0
puts 'Yes'
exit
end
end
t = 0
3.times do |i|
t += bingo[i][i]
end
if t == 0
puts 'Yes'
exit
end
t = 0
3.times do |i|
t += bingo[i][2 - i]
end
if t == 0
puts 'Yes'
exit
end
puts 'No'
|
bingo = []
bingo.push gets.split(' ').map(&:to_i)
bingo.push gets.split(' ').map(&:to_i)
bingo.push gets.split(' ').map(&:to_i)
re = []
n = gets.to_i
n.times do
re.push gets.to_i
end
re.each do |r|
0.upto 2 do |g|
0.upto 2 do |s|
bingo[g][s] = 0 if r == bingo[g][s]
end
end
end
3.times do |i|
if bingo[i].all? { |b| b == 0 }
puts 'Yes'
exit
end
end
3.times do |i|
t = 0
3.times do |j|
t += bingo[j][i]
end
if t == 0
puts 'Yes'
exit
end
end
t = 0
3.times do |i|
t += bingo[i][i]
end
if t == 0
puts 'Yes'
exit
end
t = 0
3.times do |i|
t += bingo[i][2 - i]
end
if t == 0
puts 'Yes'
exit
end
puts 'No'
|
[
"call.remove"
] | 549,550
| 549,551
|
u259578064
|
ruby
|
p02760
|
arr = []
3.times do |i|
arr[i] = gets.split.map(&:to_i)
end
num = gets.to_i
num.times do |g|
tmp = gets.to_i
3.times do |i|
num.times do |j|
if tmp == arr[i][j]
arr[i][j] = 0
end
end
end
end
3.times do |i|
if arr[i][0] == arr[i][1] && arr[i][1] == arr[i][2]
key = 1
end
end
3.times do |i|
if arr[0][i] == arr[1][i] && arr[1][i] == arr[2][i]
key = 1
end
end
if arr[0][0] == arr[1][1] && arr[1][1] == arr[2][2]
key = 1
elsif arr[0][2] == arr[1][1] && arr[1][1] == arr[2][0]
key = 1
end
if key == 1
puts "Yes"
else
puts "No"
end
|
arr = []
key = 0
3.times do |i|
arr[i] = gets.split.map(&:to_i)
end
num = gets.to_i
num.times do |g|
tmp = gets.to_i
3.times do |i|
num.times do |j|
if tmp == arr[i][j]
arr[i][j] = 0
end
end
end
end
3.times do |i|
if arr[i][0] == arr[i][1] && arr[i][1] == arr[i][2]
key = 1
end
end
3.times do |i|
if arr[0][i] == arr[1][i] && arr[1][i] == arr[2][i]
key = 1
end
end
if arr[0][0] == arr[1][1] && arr[1][1] == arr[2][2]
key = 1
elsif arr[0][2] == arr[1][1] && arr[1][1] == arr[2][0]
key = 1
end
if key == 1
puts "Yes"
else
puts "No"
end
|
[
"assignment.add"
] | 549,561
| 549,562
|
u021866120
|
ruby
|
p02760
|
a= gets.split.map(&:to_i)
b= gets.split.map(&:to_i)
c= gets.split.map(&:to_i)
d = []
n = gets.to_i
for j in 0..n-1 do
num = gets.to_i
d << num
end
if d.include?(a[0]) && d.include?(a[1]) && d.include?(a[2])
puts "Yes"
elsif d.include?(b[0]) && d.include?(b[0]) && d.include?(b[0])
puts "Yes"
elsif d.include?(c[0]) && d.include?(c[0]) && d.include?(c[0])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[0]) && d.include?(c[0])
puts "Yes"
elsif d.include?(a[1]) && d.include?(b[1]) && d.include?(c[1])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[2]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[1]) && d.include?(c[0])
puts "Yes"
else
puts "No"
end
|
a= gets.split.map(&:to_i)
b= gets.split.map(&:to_i)
c= gets.split.map(&:to_i)
d = []
n = gets.to_i
for j in 0..n-1 do
num = gets.to_i
d << num
end
if d.include?(a[0]) && d.include?(a[1]) && d.include?(a[2])
puts "Yes"
elsif d.include?(b[0]) && d.include?(b[1]) && d.include?(b[2])
puts "Yes"
elsif d.include?(c[0]) && d.include?(c[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[0]) && d.include?(c[0])
puts "Yes"
elsif d.include?(a[1]) && d.include?(b[1]) && d.include?(c[1])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[2]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[0]) && d.include?(b[1]) && d.include?(c[2])
puts "Yes"
elsif d.include?(a[2]) && d.include?(b[1]) && d.include?(c[0])
puts "Yes"
else
puts "No"
end
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 549,568
| 549,569
|
u945412921
|
ruby
|
p02760
|
A = []
3.times do
A << gets.chomp.split.map(&:to_i)
end
n = gets.chomp.to_i
b = []
n.times do |i|
b << gets.chomp.to_i
end
3.times do |i|
3.times do |j|
flag = false
n.times do |k|
flag = true if b[k] == A[i][j]
end
if flag == true
A[i][j] = 1
else
A[i][j] = 0
end
end
end
if A[0][0] == 1 && A[1][1] == 1 && A[2][2] == 1
puts 'Yes'
exit
end
if A[0][2] == 1 && A[1][1] == 1 && A[2][0] == 1
puts 'Yes'
exit
end
3.times do |i|
if A[i][0] == 1 && A[i][1] == 1 && A[i][2]
puts 'Yes'
exit
end
end
3.times do |j|
if A[0][j] == 1 && A[1][j] == 1 && A[2][j]
puts 'Yes'
exit
end
end
puts 'No'
|
A = []
3.times do
A << gets.chomp.split.map(&:to_i)
end
n = gets.chomp.to_i
b = []
n.times do |i|
b << gets.chomp.to_i
end
3.times do |i|
3.times do |j|
flag = false
n.times do |k|
flag = true if b[k] == A[i][j]
end
if flag == true
A[i][j] = 1
else
A[i][j] = 0
end
end
end
if A[0][0] == 1 && A[1][1] == 1 && A[2][2] == 1
puts 'Yes'
exit
end
if A[0][2] == 1 && A[1][1] == 1 && A[2][0] == 1
puts 'Yes'
exit
end
3.times do |i|
if A[i][0] == 1 && A[i][1] == 1 && A[i][2] == 1
puts 'Yes'
exit
end
end
3.times do |j|
if A[0][j] == 1 && A[1][j] == 1 && A[2][j] == 1
puts 'Yes'
exit
end
end
puts 'No'
|
[
"control_flow.branch.if.condition.change"
] | 549,720
| 549,721
|
u157887852
|
ruby
|
p02761
|
n,m = gets.chomp.split(' ').map(&:to_i)
ans = Array.new(n){false}
m.times do
s,c = gets.chomp.split(' ').map(&:to_i)
if (ans[s-1] == false) || (ans[s-1] == c)
ans[s-1] = c
else
puts -1
exit
end
end
p ans
if (ans.size == 1) && (ans[0] == 0||ans[0] == false)
puts 0
elsif (ans[0] == 0)
puts -1
else
ans = ans.map{|a|
if a == false
0
else
a
end
}
if ans[0] == 0
ans[0] = 1
end
puts ans.join
end
|
n,m = gets.chomp.split(' ').map(&:to_i)
ans = Array.new(n){false}
m.times do
s,c = gets.chomp.split(' ').map(&:to_i)
if (ans[s-1] == false) || (ans[s-1] == c)
ans[s-1] = c
else
puts -1
exit
end
end
if (ans.size == 1) && (ans[0] == 0||ans[0] == false)
puts 0
elsif (ans[0] == 0)
puts -1
else
ans = ans.map{|a|
if a == false
0
else
a
end
}
if ans[0] == 0
ans[0] = 1
end
puts ans.join
end
|
[
"call.remove"
] | 550,077
| 550,078
|
u710018917
|
ruby
|
p02761
|
def solve
n, m = gets.split.map!(&:to_i)
arr = []
flg = false
(0..(m - 1)).each do |i|
arr[i] = gets.split.map!(&:to_i)
end
(0..1001).each do |j|
return - 1 if j == 1000
next if j.to_s.length != n
arr.each do |v|
if j.to_s[v[0] - 1] != v[1].to_s
break
else
flg = true
end
end
return j if flg
end
end
print solve
|
def solve
n, m = gets.split.map!(&:to_i)
arr = []
flg = true
(0..(m - 1)).each do |i|
arr[i] = gets.split.map!(&:to_i)
end
(0..1001).each do |j|
return - 1 if j == 1000
next if j.to_s.length != n
arr.each do |v|
if j.to_s[v[0] - 1] != v[1].to_s
flg = false
break
else
flg = true
end
end
return j if flg
end
end
print solve
|
[
"misc.opposites",
"assignment.value.change"
] | 550,625
| 550,626
|
u595657182
|
ruby
|
p02761
|
n, m = readline.split(' ').map(&:to_i)
c = Array.new(n)
cant = false
0.upto(m - 1) do |num|
a, b = readline.split(' ').map(&:to_i)
cant = true if !c[a - 1].nil? && c[a - 1] != b
c[a - 1] = b
end
if cant
puts '-1'
elsif n >= 2 && c[0] == 0
puts '-1'
else
c[0] = 1 if c[0].nil?
puts c.map { |num| num.nil? ? 0:num }.join('')
end
|
n, m = readline.split(' ').map(&:to_i)
c = Array.new(n)
cant = false
0.upto(m - 1) do |num|
a, b = readline.split(' ').map(&:to_i)
cant = true if !c[a - 1].nil? && c[a - 1] != b
c[a - 1] = b
end
if cant
puts '-1'
elsif n >= 2 && c[0] == 0
puts '-1'
else
c[0] = 1 if n >= 2 && c[0].nil?
puts c.map { |num| num.nil? ? 0:num }.join('')
end
|
[
"control_flow.branch.if.condition.change"
] | 550,690
| 550,691
|
u214887789
|
ruby
|
p02761
|
require "pry-byebug"
N,M = gets.split.map(&:to_i)
ary = []
M.times do |m|
s,c = gets.split.map(&:to_i)
ary << {s:s, c:c}
end
0.upto(1000) do |num|
# N桁になっていない
str = num.to_s
digits = str.length
next if digits != N
found = true
ary.each do |elm|
s = elm[:s]
c = elm[:c]
#binding.pry if num == 702
if digits < s
found = false
break
end
if str[s-1].to_i != c
found = false
break
end
end
if found
puts str
exit
end
end
puts "-1"
|
#require "pry-byebug"
N,M = gets.split.map(&:to_i)
ary = []
M.times do |m|
s,c = gets.split.map(&:to_i)
ary << {s:s, c:c}
end
0.upto(1000) do |num|
# N桁になっていない
str = num.to_s
digits = str.length
next if digits != N
found = true
ary.each do |elm|
s = elm[:s]
c = elm[:c]
#binding.pry if num == 702
if digits < s
found = false
break
end
if str[s-1].to_i != c
found = false
break
end
end
if found
puts str
exit
end
end
puts "-1"
|
[
"call.remove"
] | 551,408
| 551,409
|
u645787471
|
ruby
|
p02761
|
n, m = gets.chomp.split(" ").map(&:to_i)
sc = m.times.map { gets.chomp.split(" ").map(&:to_i) }
ans = Array.new(n, nil)
sc.each do |s, c|
if ans[s - 1].nil?
ans[s - 1] = c
elsif ans[s - 1] != c
puts "-1"
exit
end
end
ans[0] = 1 if ans[0].nil?
if ans[0] == 0 && n > 1
puts "-1"
exit
end
puts ans.map(&:to_i).join
|
n, m = gets.chomp.split(" ").map(&:to_i)
sc = m.times.map { gets.chomp.split(" ").map(&:to_i) }
ans = Array.new(n, nil)
sc.each do |s, c|
if ans[s - 1].nil?
ans[s - 1] = c
elsif ans[s - 1] != c
puts "-1"
exit
end
end
ans[0] = 1 if ans[0].nil? && n > 1
if ans[0] == 0 && n > 1
puts "-1"
exit
end
puts ans.map(&:to_i).join
|
[
"control_flow.branch.if.condition.change"
] | 551,639
| 551,640
|
u390727364
|
ruby
|
p02761
|
# Nで指定された桁に入り切らないケースは「1 ≤ si ≤ N」よりあり得ない
N, M = gets.split.map(&:to_i)
s, c = [], Array.new(N)
M.times do
_s, _c = gets.split.map(&:to_i)
s << _s
# 同一桁に違う値が指定されている場合
if c[_s - 1] && c[_s - 1] != _c
puts -1
exit
end
c[_s - 1] = _c
end
# 1桁目が0の場合はNG(ただし1桁の場合は0を許容する)
if N != 1 && s.find { |_s| _s == 1 && c[_s - 1].zero? }
puts -1
exit
end
puts c[0..(N - 1)].map.with_index { |_c, i| _c ? _c : (i.zero? ? 1 : 0) }.join
|
# Nで指定された桁に入り切らないケースは「1 ≤ si ≤ N」よりあり得ない
N, M = gets.split.map(&:to_i)
s, c = [], Array.new(N)
M.times do
_s, _c = gets.split.map(&:to_i)
s << _s
# 同一桁に違う値が指定されている場合
if c[_s - 1] && c[_s - 1] != _c
puts -1
exit
end
c[_s - 1] = _c
end
# 1桁目が0の場合はNG(ただし1桁の場合は0を許容する)
if N != 1 && s.find { |_s| _s == 1 && c[_s - 1].zero? }
puts -1
exit
end
puts c[0..(N - 1)].map.with_index { |_c, i| _c ? _c : (i.zero? && N != 1 ? 1 : 0) }.join
|
[
"control_flow.branch.if.condition.change"
] | 552,554
| 552,555
|
u764026162
|
ruby
|
p02761
|
str = gets.split
N,M = str[0].to_i, str[1].to_i
a = Array.new(M){Array.new(2)}
for i in 0...M do
str = gets.split
a[i][0],a[i][1] = str[0].to_i, str[1].to_i
end
if N == 1
b = 10
for i in 0...M do
c = a[i][1]
if b == 10
b = c
elsif b != c
b = -1
end
end
answer = b
if answer == 10
answer = 0
end
puts answer
else
b = Array.new(N,10)
answer = 0
for i in 0...M do
c = a[i][1]
d = a[i][0]
if b[d-1] == 10
b[d-1] = c
elsif b[d-1] != c
answer = -1
end
end
if b[0] == 0
answer = -1
end
if answer == -1
puts answer
else
for i in 0...M do
if b[-i-1] == 10 && i == M-1
answer += 10**i
elsif b[-i-1] == 10
answer += 0
else
answer += b[-i-1] * (10**i)
end
end
puts answer
end
end
|
str = gets.split
N,M = str[0].to_i, str[1].to_i
a = Array.new(M){Array.new(2)}
for i in 0...M do
str = gets.split
a[i][0],a[i][1] = str[0].to_i, str[1].to_i
end
if N == 1
b = 10
for i in 0...M do
c = a[i][1]
if b == 10
b = c
elsif b != c
b = -1
end
end
answer = b
if answer == 10
answer = 0
end
puts answer
else
b = Array.new(N,10)
answer = 0
for i in 0...M do
c = a[i][1]
d = a[i][0]
if b[d-1] == 10
b[d-1] = c
elsif b[d-1] != c
answer = -1
end
end
if b[0] == 0
answer = -1
end
if answer == -1
puts answer
else
for i in 0...N do
if b[-i-1] == 10 && i == N-1
answer += 10**i
elsif b[-i-1] == 10
answer += 0
else
answer += b[-i-1] * (10**i)
end
end
puts answer
end
end
|
[
"control_flow.branch.if.condition.change"
] | 552,706
| 552,707
|
u349832549
|
ruby
|
p02761
|
n, m = gets.chomp.split.map(&:to_i)
js = []
m.times do
js.push gets.chomp.split.map(&:to_i)
end
ng = true
0.upto(999) do |x|
f = true
xs = x.to_s
next if xs.size != n
p xs
p js
js.each do |s, c|
if xs.size < s
f = false
break
end
if xs[s-1] != c.to_s
f == false
break
end
end
if f
ng = false
puts x
break
end
end
if ng
puts -1
end
|
n, m = gets.chomp.split.map(&:to_i)
js = []
m.times do
js.push gets.chomp.split.map(&:to_i)
end
ng = true
0.upto(999) do |x|
f = true
xs = x.to_s
next if xs.size != n
js.each do |s, c|
if xs.size < s
f = false
break
end
if xs[s-1] != c.to_s
f = false
break
end
end
if f
ng = false
puts x
break
end
end
if ng
puts -1
end
|
[
"call.remove",
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 553,304
| 553,305
|
u946334556
|
ruby
|
p02761
|
n,m = gets.split.map(&:to_i)
s = []
x = 0
m.times do
a,b = gets.split.map(&:to_i)
if n != 1 && a == 1 && b == 0
x = 1
else
s << [a,b]
end
end
ar = Array.new(n)
s.each do |i|
if ar[(i[0])-1] == nil
ar[(i[0])-1] = i[1]
elsif ar[(i[0])-1] != i[1]
x = 1
end
end
if x == 1
puts "-1"
else
ans = ""
for f in 0..(n-1)
if ar[f] == nil
if f == 0
ar[f] = 1
else
ar[f] = 0
end
end
end
ar.each do |j|
ans += "#{j}"
end
puts ans
end
|
n,m = gets.split.map(&:to_i)
s = []
x = 0
m.times do
a,b = gets.split.map(&:to_i)
if n != 1 && a == 1 && b == 0
x = 1
else
s << [a,b]
end
end
ar = Array.new(n)
s.each do |i|
if ar[(i[0])-1] == nil
ar[(i[0])-1] = i[1]
elsif ar[(i[0])-1] != i[1]
x = 1
end
end
if x == 1
puts "-1"
else
ans = ""
for f in 0..(n-1)
if ar[f] == nil
if f == 0 && n != 1
ar[f] = 1
else
ar[f] = 0
end
end
end
ar.each do |j|
ans += "#{j}"
end
puts ans
end
|
[
"control_flow.branch.if.condition.change"
] | 553,314
| 553,315
|
u911373146
|
ruby
|
p02762
|
class UnionFind
def initialize(n); @data = Array.new(n, -1); end
def find(a); @data[a] < 0 ? a : @data[a] = find(@data[a]); end
def same?(a, b); find(a) == find(b); end
def size(a); -@data[find(a)]; end
def unite(a, b)
a = find(a)
b = find(b)
return if a == b
a, b = b, a if @data[a] > @data[b]
@data[a] += @data[b]
@data[b] = a
end
end
n, m, k = gets.chomp.split(" ").map(&:to_i)
UF = UnionFind.new(n)
FR = Array.new(n){[]}
BL = Array.new(n){[]}
m.times do
a, b = gets.chomp.split(" ").map(&:to_i)
a -= 1
b -= 1
UF.unite(a, b)
FR[a] << b
FR[b] << a
end
k.times do
a, b = gets.chomp.split(" ").map(&:to_i)
a -= 1
b -= 1
BL[a] << b
BL[b] << a
end
ans = n.times.map do |i|
count = UF.size(i)
FR[i].each do |j|
count -= 1 if UF.same?(i, j)
end
BL[i].each do |l|
count -= 1 if UF.same(i, l)
end
count -= 1
end
puts ans.join(" ")
|
class UnionFind
def initialize(n); @data = Array.new(n, -1); end
def find(a); @data[a] < 0 ? a : @data[a] = find(@data[a]); end
def same?(a, b); find(a) == find(b); end
def size(a); -@data[find(a)]; end
def unite(a, b)
a = find(a)
b = find(b)
return if a == b
a, b = b, a if @data[a] > @data[b]
@data[a] += @data[b]
@data[b] = a
end
end
n, m, k = gets.chomp.split(" ").map(&:to_i)
UF = UnionFind.new(n)
FR = Array.new(n){[]}
BL = Array.new(n){[]}
m.times do
a, b = gets.chomp.split(" ").map(&:to_i)
a -= 1
b -= 1
UF.unite(a, b)
FR[a] << b
FR[b] << a
end
k.times do
a, b = gets.chomp.split(" ").map(&:to_i)
a -= 1
b -= 1
BL[a] << b
BL[b] << a
end
ans = n.times.map do |i|
count = UF.size(i)
FR[i].each do |j|
count -= 1 if UF.same?(i, j)
end
BL[i].each do |l|
count -= 1 if UF.same?(i, l)
end
count -= 1
end
puts ans.join(" ")
|
[
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 554,215
| 554,216
|
u729911058
|
ruby
|
p02761
|
n, m = gets.split.map(&:to_i)
s = []
c = []
for i in 0..m-1
a, b = gets.split.map(&:to_i)
s << a
c << b
end
ans = -1
for k in 1..999
next if k.to_s.length != n
flag = true
s.each_with_index do |si, i|
if k.to_s[si-1] != c[i].to_s
flag = false
end
end
if flag
ans = k
break
end
end
puts ans
|
n, m = gets.split.map(&:to_i)
s = []
c = []
for i in 0..m-1
a, b = gets.split.map(&:to_i)
s << a
c << b
end
ans = -1
for k in 0..999
next if k.to_s.length != n
flag = true
s.each_with_index do |si, i|
if k.to_s[si-1] != c[i].to_s
flag = false
end
end
if flag
ans = k
break
end
end
puts ans
|
[
"literal.number.integer.change"
] | 554,297
| 554,298
|
u335381753
|
ruby
|
p02760
|
bingo = Array.new
(0..2).each{gets.chomp.split(" ").map(&:to_i).each{|b| bingo.push(b)}}
a = gets.chomp.to_i
a.times do
b = gets.chomp.to_i
bingo.map!{|bin| bin = bin == b ? -114514 : bin}
end
f3 = true
f4 = true
3.times do |i|
flag = true
f2 = true
3.times do |j|
flag = false if bingo[i * 3 + j] != -114514
f2 = false if bingo[i + 3 * j] != -114514
end
f3 = false if bingo[4 * i] != -114514
f4 = false if bingo[2 * i] != -114514
if flag || f2 then
puts "Yes"
exit
end
end
if f3 || f4 then
puts "Yes"
else
puts "No"
end
#p bingo
|
bingo = Array.new
(0..2).each{gets.chomp.split(" ").map(&:to_i).each{|b| bingo.push(b)}}
a = gets.chomp.to_i
a.times do
b = gets.chomp.to_i
bingo.map!{|bin| bin = bin == b ? -114514 : bin}
end
f3 = true
f4 = true
3.times do |i|
flag = true
f2 = true
3.times do |j|
flag = false if bingo[i * 3 + j] != -114514
f2 = false if bingo[i + 3 * j] != -114514
end
f3 = false if bingo[4 * i] != -114514
f4 = false if bingo[2 * (i+1)] != -114514
if flag || f2 then
puts "Yes"
exit
end
end
if f3 || f4 then
puts "Yes"
else
puts "No"
end
#p bingo
|
[
"control_flow.branch.if.condition.change"
] | 554,538
| 554,539
|
u409390792
|
ruby
|
p02760
|
a = 3.times.map { gets.chomp.split(" ").map(&:to_i) }
n = gets.to_i
b = n.times.map { gets.to_i }
def check(arr)
if arr.empty?
puts "Yes"
exit
end
end
def checks(arr, b)
arr.each do |ai|
check(ai - b)
end
end
check([a[0][0], a[1][1], a[2][2]] - b)
check([a[2][0], a[1][1], a[0][2]] - b)
checks(a, b)
a.transpose
checks(a, b)
puts "No"
|
a = 3.times.map { gets.chomp.split(" ").map(&:to_i) }
n = gets.to_i
b = n.times.map { gets.to_i }
def check(arr)
if arr.empty?
puts "Yes"
exit
end
end
def checks(arr, b)
arr.each do |ai|
check(ai - b)
end
end
check([a[0][0], a[1][1], a[2][2]] - b)
check([a[2][0], a[1][1], a[0][2]] - b)
checks(a, b)
a = a.transpose
checks(a, b)
puts "No"
|
[
"assignment.add"
] | 554,624
| 554,625
|
u390727364
|
ruby
|
p02763
|
N = gets.to_i
S = gets.chomp.chars
Q = gets.to_i
Query = []
Q.times {
qu << gets.chomp.split(" ")
}
s = Hash.new{|h, k| h[k] = []}
(0...N).each {|i|
s[S[i]] << (i+1)
}
qu.each {|f, a, b|
if f == '1' then
a_i = a.to_i
if S[a_i-1] != b then
idx = s[S[a_i-1]].bsearch_index{|x| x >= a_i}
s[S[a_i-1]].delete_at(idx)
S[a_i-1] = b
idx = s[b].bsearch_index{|x| x >= a_i}
idx.nil? ? s[b] << a_i : s[b].insert(idx, a_i)
end
else
l, r = [a.to_i, b.to_i]
ans = 0
(0..25).each {|i|
sl = s[(97+i).chr].bsearch{|x| x >= l}
ans += 1 if (not sl.nil?) && sl <= r
}
puts ans
end
}
|
N = gets.to_i
S = gets.chomp.chars
Q = gets.to_i
qu = []
Q.times {
qu << gets.chomp.split(" ")
}
s = Hash.new{|h, k| h[k] = []}
(0...N).each {|i|
s[S[i]] << (i+1)
}
qu.each {|f, a, b|
if f == '1' then
a_i = a.to_i
if S[a_i-1] != b then
idx = s[S[a_i-1]].bsearch_index{|x| x >= a_i}
s[S[a_i-1]].delete_at(idx)
S[a_i-1] = b
idx = s[b].bsearch_index{|x| x >= a_i}
idx.nil? ? s[b] << a_i : s[b].insert(idx, a_i)
end
else
l, r = [a.to_i, b.to_i]
ans = 0
(0..25).each {|i|
sl = s[(97+i).chr].bsearch{|x| x >= l}
ans += 1 if (not sl.nil?) && sl <= r
}
puts ans
end
}
|
[
"assignment.variable.change"
] | 554,871
| 554,872
|
u729911058
|
ruby
|
p02765
|
n, r = gets.split.map(&:to_i)
puts r + (n>=0 ? 0 : 100*(10-n))
|
n, r = gets.split.map(&:to_i)
puts r + (n>=10 ? 0 : 100*(10-n))
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 555,389
| 555,390
|
u358554431
|
ruby
|
p02765
|
n, r = gets.to_i
def rate(n, r)
if (n < 10)
r + 100*(10 - n)
else
r
end
end
puts rate(n,r)
|
n, r = gets.split.map(&:to_i)
def rate(n, r)
if (n < 10)
r + 100*(10 - n)
else
r
end
end
puts rate(n,r)
|
[
"assignment.value.change",
"identifier.change",
"call.add"
] | 556,422
| 556,423
|
u552761221
|
ruby
|
p02765
|
N,R = gets.chomp.split(' ').map(&:to_i)
puts (N < 10) ? 2919 + 100 * (10 - N) : R
|
N,R = gets.chomp.split(' ').map(&:to_i)
puts (N < 10) ? R + 100 * (10 - N) : R
|
[
"call.arguments.change",
"expression.operation.binary.change"
] | 556,471
| 556,472
|
u965436898
|
ruby
|
p02765
|
N,R = gets.split.map &:to_i
p R - 100 * [10 - N, 0].max
|
N,R = gets.split.map &:to_i
p R + 100 * [10 - N, 0].max
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 556,537
| 556,538
|
u670503797
|
ruby
|
p02765
|
n,r = gets.split.map(&:to_i)
if n >= 10
p r
else
p r - 100 * (10 - n)
end
|
n,r = gets.split.map(&:to_i)
if n >= 10
p r
else
p r + 100 * (10 - n)
end
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 556,807
| 556,808
|
u945412921
|
ruby
|
p02765
|
n, r = gets.split.map(&:to_i)
puts i = r + (100*(10 - n))
|
n, r = gets.split.map(&:to_i)
puts n >= 10 ? r : r + (100*(10 - n))
|
[] | 557,595
| 557,596
|
u341279393
|
ruby
|
p02765
|
input = gets.chomp.split("") # array
n = input[0].to_i
# n = 20
r = input[1].to_i
# r = 10
n >= 10 ? ans = r : ans = r - 100*(10-n)
print ("#{ans}\n")
|
input = gets.chomp.split(" ") # array
n = input[0].to_i
# n = 20
r = input[1].to_i
# r = 10
#puts " #{n} + #{r} "
n >= 10 ? ans = r : ans = r + 100*(10-n)
print("#{ans}\n")
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 557,730
| 557,731
|
u713980442
|
ruby
|
p02765
|
a=gets.chomp.split.map(&:to_i)
b=0
if a[0]<10
b=100*(10-a[0])
end
puts a+b
|
a=gets.chomp.split.map(&:to_i)
b=0
if a[0]<10
b=100*(10-a[0])
end
puts a[1]+b
|
[] | 558,135
| 558,136
|
u175113369
|
ruby
|
p02765
|
N, R = gets.split.map &:to_i
p R - (10 - [10, N].min) * 100
|
N, R = gets.split.map &:to_i
p R + (10 - [10, N].min) * 100
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 558,156
| 558,157
|
u711705317
|
ruby
|
p02765
|
n, r = gets.split.map(&:to_i)
puts n >= 10 ? r : r - (100 * (10 - n))
|
n, r = gets.split.map(&:to_i)
puts n >= 10 ? r : r + (100 * (10 - n))
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 558,308
| 558,309
|
u604352408
|
ruby
|
p02766
|
n,k = gets.split(" ").map(&:to_i)
i = 0
while n > k**i
i = i + 1
end
puts i
|
n,k = gets.split(" ").map(&:to_i)
i = 0
while n >= k**i
i = i + 1
end
puts i
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 558,610
| 558,609
|
u944733909
|
ruby
|
p02766
|
n, K = gets.split.map(&:to_i)
c = 0
c += 1 while n > K**c
p c
|
n, K = gets.split.map(&:to_i)
c = 0
c += 1 while n >= K**c
p c
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 558,798
| 558,799
|
u091810847
|
ruby
|
p02766
|
N, K = gets.strip.split.map(&:to_i)
puts N.to_s(K)
|
N, K = gets.strip.split.map(&:to_i)
puts (N.to_s(K)).size
|
[
"call.arguments.change",
"call.add"
] | 558,899
| 558,900
|
u313103408
|
ruby
|
p02766
|
n,k = gets.chomp.split(' ').mao(&:to_i)
puts n.to_s(k).size
|
n,k = gets.chomp.split(' ').map(&:to_i)
puts n.to_s(k).size
|
[
"assignment.value.change",
"identifier.change"
] | 558,923
| 558,924
|
u575740023
|
ruby
|
p02766
|
n, k = gets.split().map(&:to_i)
puts Math.log(n, k).ceil
|
n, k = gets.split().map(&:to_i)
puts Math.log(n, k).floor + 1
|
[
"misc.opposites",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 559,246
| 559,247
|
u620219777
|
ruby
|
p02766
|
n,k =gets.split.map(&:to_i)
puts n.to_s(k)
|
n,k =gets.split.map(&:to_i)
puts n.to_s(k).size
|
[
"call.add"
] | 559,514
| 559,515
|
u124214522
|
ruby
|
p02766
|
# Your code here!
num, base = gets.chop.split.map(&:to_i)
tmp = 0
a = 0
while tmp < num do
a+=1
tmp = base**a
end
p a
|
# Your code here!
num, base = gets.chop.split.map(&:to_i)
tmp = 0
a = 0
while tmp <= num do
a+=1
tmp = base**a
end
p a
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 559,914
| 559,915
|
u249327445
|
ruby
|
p02766
|
x,y=gets.chomp.split(" ").map(&:to_i);
n = 1
while x > y
x = x / y
n = n+1
end
p n
|
x,y=gets.chomp.split(" ").map(&:to_i);
n = 1
while x >= y
x = x / y
n = n+1
end
p n
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 560,049
| 560,050
|
u688809543
|
ruby
|
p02766
|
n, k = gets.chomp.split.map(&:to_i)
num = k
count = 0
if n < k then
puts "#{1}"
else
while n > num do
num = num * k
count += 1
end
puts "#{count + 1}"
end
|
n, k = gets.chomp.split.map(&:to_i)
num = k
count = 0
if n < k then
puts "#{1}"
else
while n >= num do
num = num * k
count += 1
end
puts "#{count + 1}"
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 560,067
| 560,068
|
u571003347
|
ruby
|
p02766
|
n, k = gets.split.map(&:to_i)
puts n.to_s(k)
|
n, k = gets.split.map(&:to_i)
puts n.to_s(k).size
|
[
"call.add"
] | 560,133
| 560,134
|
u341279393
|
ruby
|
p02766
|
N, K = gets.split.map(&:to_i)
n = 0
while N > K ** n do
n += 1
end
p n
|
N, K = gets.split.map(&:to_i)
n = 0
while N >= K ** n do
n += 1
end
p n
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 560,473
| 560,474
|
u638552534
|
ruby
|
p02766
|
n,k = gets.split.map(&:to_i)
i = 1
while n > k
n /= k
i += 1
end
puts i
|
n,k = gets.split.map(&:to_i)
i = 1
while n >= k
n /= k
i += 1
end
puts i
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 560,491
| 560,492
|
u437368899
|
ruby
|
p02766
|
str = gets
nk = str.split(" ").map(&:to_i)
n = nk[0]
k = nk[1]
puts Math.log(n,k).to_r.ceil
|
str = gets
nk = str.split(" ").map(&:to_i)
n = nk[0]
k = nk[1]
puts Math.log(n,k).floor + 1
|
[] | 560,584
| 560,585
|
u996249561
|
ruby
|
p02766
|
str = gets
nk = str.split(" ").map(&:to_i)
n = nk[0]
k = nk[1]
puts Math.log(n,k).ceil
|
str = gets
nk = str.split(" ").map(&:to_i)
n = nk[0]
k = nk[1]
puts Math.log(n,k).floor + 1
|
[
"misc.opposites",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 560,586
| 560,585
|
u996249561
|
ruby
|
p02766
|
n, k = gets.split(" ")
puts n.to_i.to_s(k.to_i)
|
n, k = gets.split(" ")
puts n.to_i.to_s(k.to_i).length
|
[
"call.add"
] | 560,611
| 560,612
|
u214496164
|
ruby
|
p02766
|
num, base = gets.split(' ').map(&:to_i)
size = 1
while true do
if num > base ** size
size += 1
else
break
end
end
puts size
|
num, base = gets.split(' ').map(&:to_i)
size = 1
while true do
if num >= base ** size
size += 1
else
break
end
end
puts size
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 560,619
| 560,620
|
u647061136
|
ruby
|
p02766
|
#!/usr/bin/env ruby
(n, k) = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }
ans = 1
num = k
while n > num do
num = num * k
ans = ans + 1
end
puts ans
|
#!/usr/bin/env ruby
(n, k) = STDIN.gets.chomp.split(/\s/).map { |e| e.to_i }
ans = 1
num = k
while n >= num do
num = num * k
ans = ans + 1
end
puts ans
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 560,966
| 560,967
|
u250545805
|
ruby
|
p02767
|
n = gets.to_i
arr = gets.split(" ").map(&:to_i)
ave = (1.0 * arr.sum / n).ceil
puts arr.map{|i| (i - ave) ** 2 }.sum
|
n = gets.to_i
arr = gets.split(" ").map(&:to_i)
ave = (1.0 * arr.sum / n).round
puts arr.map{|i| (i - ave) ** 2 }.sum
|
[
"assignment.value.change",
"identifier.change"
] | 561,434
| 561,435
|
u771770008
|
ruby
|
p02767
|
n = gets.to_i
x = gets.split.map(&:to_i)
x.sort!
s = (x.inject(:+) / n.to_f).ceil
mas = x.map{|i| (i - s)**2}
puts mas.inject(:+)
|
n = gets.to_i
x = gets.split.map(&:to_i)
x.sort!
s = (x.inject(:+) / n.to_f).round
mas = x.map{|i| (i - s)**2}
puts mas.inject(:+)
|
[
"assignment.value.change",
"identifier.change"
] | 562,122
| 562,123
|
u437368899
|
ruby
|
p02767
|
n = gets.chomp.to_i
x = gets.chomp.split(" ").map(&:to_i)
total = nil
(x.min..x.max).map do |c|
sum = x.map{ |e| (c - e)**2 }.inject(:+)
total = sum if c == x.min
if sum <= total
total = sum
else
break
end
p sum, c
end
p total
|
n = gets.chomp.to_i
x = gets.chomp.split(" ").map(&:to_i)
total = nil
(x.min..x.max).map do |c|
sum = x.map{ |e| (c - e)**2 }.inject(:+)
total = sum if c == x.min
if sum <= total
total = sum
else
break
end
end
p total
|
[
"call.remove"
] | 562,800
| 562,801
|
u228197745
|
ruby
|
p02767
|
n = gets.to_i
m = gets.chomp.split(" ").map(&:to_f)
sum = 0
i = 0
total = (m.inject(:+) / n).ceil
n.times do
sum += (m[i] - total) ** 2
i += 1
end
puts sum.to_i
|
n = gets.to_i
m = gets.chomp.split(" ").map(&:to_f)
sum = 0
i = 0
total = (m.inject(:+) / n).round
n.times do
sum += (m[i] - total) ** 2
i += 1
end
puts sum.to_i
|
[
"assignment.value.change",
"identifier.change"
] | 562,871
| 562,872
|
u588907086
|
ruby
|
p02767
|
attrs = $stdin.read.split("\n")
num = attrs[0]
x_cors = attrs[1].split(' ').map(&:to_i)
min = x_cors.map { |num| num * num }.inject(:+)
pre_min = min + 1
p = 1
while pre_min > min do
pre_min = min
min = x_cors.map { |num| num * num }.inject(:+) - 2 * p * x_cors.inject(:+) + x_cors.length * p * p
# puts "p: #{p}, min: #{min}, pre_min: #{pre_min}"
p += 1
end
puts min
|
attrs = $stdin.read.split("\n")
num = attrs[0]
x_cors = attrs[1].split(' ').map(&:to_i)
min = x_cors.map { |num| num * num }.inject(:+)
pre_min = min + 1
p = 1
while pre_min > min do
pre_min = min
min = x_cors.map { |num| num * num }.inject(:+) - 2 * p * x_cors.inject(:+) + x_cors.length * p * p
# puts "p: #{p}, min: #{min}, pre_min: #{pre_min}"
p += 1
end
puts pre_min
|
[
"identifier.change",
"call.arguments.change"
] | 563,060
| 563,061
|
u220054981
|
ruby
|
p02767
|
n = gets.chomp!.to_i
ls = gets.split(" ").map(&:to_i)
ls = ls.sort
#p ls
start = ls.first + 1
goal = ls.last - 1
for i in start..goal do
score = 0
ls.each do |e|
score += (e - i)**2
end
if i == start
d = score
else
if score < d
d = score
end
end
end
p d
|
n = gets.chomp!.to_i
ls = gets.split(" ").map(&:to_i)
ls = ls.sort
#p ls
start = ls.first
goal = ls.last
for i in start..goal do
score = 0
ls.each do |e|
score += (e - i)**2
end
if i == start
d = score
else
if score < d
d = score
end
end
end
p d
|
[
"expression.operation.binary.remove"
] | 563,093
| 563,094
|
u911815052
|
ruby
|
p02767
|
_ = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
p = (a.inject(:+).to_f/a.length.to_f)
a.each do |num|
ans += (num-p)**2
end
puts ans.round
|
_ = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
p = (a.inject(:+).to_f/a.length.to_f).round
a.each do |num|
ans += (num-p)**2
end
puts ans
|
[
"call.add",
"call.remove"
] | 563,215
| 563,216
|
u523351024
|
ruby
|
p02767
|
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
p = (a.inject(:+).to_f/a.length.to_f)
a.each do |num|
ans += (num-p)**2
end
puts ans.round
|
_ = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
p = (a.inject(:+).to_f/a.length.to_f).round
a.each do |num|
ans += (num-p)**2
end
puts ans
|
[
"assignment.variable.change",
"identifier.change",
"call.add",
"call.remove"
] | 563,217
| 563,216
|
u523351024
|
ruby
|
p02767
|
n = gets.to_i
x = gets.split("\s").map(&:to_i)
min = nil
(x.max+1).times do |n_i|
sum = x.inject(0) { |res, x_i| res + (x_i - n_i)**2 }
min ||= sum
min = sum if sum < min
end
|
n = gets.to_i
x = gets.split("\s").map(&:to_i)
min = nil
(x.max+1).times do |n_i|
sum = x.inject(0) { |res, x_i| res + (x_i - n_i)**2 }
min ||= sum
min = sum if sum < min
end
p min
|
[
"call.add"
] | 563,712
| 563,713
|
u458429268
|
ruby
|
p02767
|
n = gets.to_i
x = gets.split("\s").map(&:to_i)
min = nil
x.max.times do |n_i|
sum = x.inject(0) { |res, x_i| res + (x_i - n_i)**2 }
min ||= sum
min = sum if sum < min
end
p min
|
n = gets.to_i
x = gets.split("\s").map(&:to_i)
min = nil
(x.max+1).times do |n_i|
sum = x.inject(0) { |res, x_i| res + (x_i - n_i)**2 }
min ||= sum
min = sum if sum < min
end
p min
|
[] | 563,714
| 563,713
|
u458429268
|
ruby
|
p02768
|
$MOD = 10 ** 9 + 7
def modpow(_n, _pp)
r = 1
n = _n
pp = _pp
while pp > 0
r = (r*n) % $MOD if pp&1 == 1
n = (n*n) % $MOD
pp = pp >> 1
end
return r
end
def fermatComb(n, k)
fermatComb(n, n - k) if k > n - k
denominator = 1 # 分母
numerator = 1 # 分子
k.times do |i|
denominator *= (n - i)
denominator %= $MOD
numerator *= (i + 1)
numerator %= $MOD
end
return denominator * modpow(numerator, $MOD - 2) % $MOD
end
n, a, b = gets.chomp.split.map(&:to_i)
ans = modpow(2, n) - 1
ans -= (fermatComb(n, a) + fermatComb(n, b)) % $MOD
puts ans
|
$MOD = 10 ** 9 + 7
def modpow(_n, _pp)
r = 1
n = _n
pp = _pp
while pp > 0
r = (r*n) % $MOD if pp&1 == 1
n = (n*n) % $MOD
pp = pp >> 1
end
return r
end
def fermatComb(n, k)
fermatComb(n, n - k) if k > n - k
denominator = 1 # 分母
numerator = 1 # 分子
k.times do |i|
denominator *= (n - i)
denominator %= $MOD
numerator *= (i + 1)
numerator %= $MOD
end
return denominator * modpow(numerator, $MOD - 2) % $MOD
end
n, a, b = gets.chomp.split.map(&:to_i)
ans = modpow(2, n) - 1
ans -= (fermatComb(n, a) + fermatComb(n, b)) % $MOD
puts ans % $MOD
|
[
"expression.operation.binary.add"
] | 563,915
| 563,916
|
u466332671
|
ruby
|
p02768
|
MOD = 1000000007
def conv(a,b)
if b > a/2
b = a - b
end
ans = 1
for i in 1..b
ans = ((ans * (a - (i - 1))) * INV[i]) % MOD
end
ans % MOD
end
def pow(x,n)
if n == 0
1
elsif n % 2 == 0
pow(x*x%MOD, n/2) % MOD
else
x * pow(x, n-1) % MOD
end
end
INV = []
def calc_fact(n)
INV[0] = pow(1, MOD-2)
for i in 1..n
INV[i] = pow(i, MOD-2)
end
end
n,a,b=gets.chomp.split(" ").map(&:to_i)
all = (pow(2,n) - 1) % MOD
if a > n/2
a = n - b
end
if b > n/2
b = n - b
end
calc_fact(a > b ? a : b)
all = all - conv(n,a) - conv(n,b)
all %= MOD
puts all
|
MOD = 1000000007
def conv(a,b)
if b > a/2
b = a - b
end
ans = 1
for i in 1..b
ans = ((ans * (a - (i - 1))) * INV[i]) % MOD
end
ans % MOD
end
def pow(x,n)
if n == 0
1
elsif n % 2 == 0
pow(x*x%MOD, n/2) % MOD
else
x * pow(x, n-1) % MOD
end
end
INV = []
def calc_fact(n)
INV[0] = pow(1, MOD-2)
for i in 1..n
INV[i] = pow(i, MOD-2)
end
end
n,a,b=gets.chomp.split(" ").map(&:to_i)
all = (pow(2,n) - 1) % MOD
if a > n/2
a = n - a
end
if b > n/2
b = n - b
end
calc_fact(a > b ? a : b)
all = all - conv(n,a) - conv(n,b)
all %= MOD
puts all
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 564,446
| 564,447
|
u265679940
|
ruby
|
p02771
|
x,y,z=gets.split.map!{|i| i.to_i}
if x==y && y==z
puts "No"
elsif x!=y && y!=z && a!=z
puts "No"
else
puts "Yes"
end
|
x,y,z=gets.split.map!{|i| i.to_i}
if x==y && y==z
puts "No"
elsif x!=y && y!=z && x!=z
puts "No"
else
puts "Yes"
end
|
[
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 565,344
| 565,345
|
u977506075
|
ruby
|
p02771
|
x,y,z=gets.split.map!{|i| i.to_i}
if x==y && y==z
puts "No"
elsif x!=y && y!=z
puts "No"
else
puts "Yes"
end
|
x,y,z=gets.split.map!{|i| i.to_i}
if x==y && y==z
puts "No"
elsif x!=y && y!=z && x!=z
puts "No"
else
puts "Yes"
end
|
[
"control_flow.branch.if.condition.change"
] | 565,346
| 565,345
|
u977506075
|
ruby
|
p02771
|
a,b,c=gets.chomp.split(" ").map(&:to_i)
if a==b and a==c
print "NO"
elsif a!=b and a!=c and b!=c
print "NO"
else
print "YES"
end
|
a,b,c=gets.chomp.split(" ").map(&:to_i)
if a==b and a==c
print "No"
elsif a!=b and a!=c and b!=c
print "No"
else
print "Yes"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 565,401
| 565,402
|
u492991702
|
ruby
|
p02771
|
a,b,c=gets.chomp.split(" ").map(&:to_i)
if a==b and a==c
print "no"
elsif a!=b and a!=c and b!=c
print "no"
else
print "yes"
end
|
a,b,c=gets.chomp.split(" ").map(&:to_i)
if a==b and a==c
print "No"
elsif a!=b and a!=c and b!=c
print "No"
else
print "Yes"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 565,403
| 565,402
|
u492991702
|
ruby
|
p02771
|
puts gets.split.map(&:to_i).uniq.size == 2 ? :YES : :No
|
puts gets.split.map(&:to_i).uniq.size == 2 ? :Yes : :No
|
[
"call.arguments.change"
] | 565,583
| 565,584
|
u091810847
|
ruby
|
p02771
|
gets.chomp.split(" ").group_by{|aa| aa }.each{|key, value| if value.length != 1 then puts "Yes"; exit end};puts "No"
|
gets.chomp.split(" ").group_by{|aa| aa }.each{|key, value| if value.length == 2 then puts "Yes"; exit end};puts "No"
|
[] | 565,946
| 565,947
|
u409390792
|
ruby
|
p02771
|
a,b,c = gets.chomp.split(' ').map(&:to_i)
ans = "No"
if a == b
if a != c
ans = "Yes"
end
elsif b == c
if a != c
ans = "Yes"
end
elsif a == c
if a != b
ans = "Yes"
end
end
p ans
|
a,b,c = gets.chomp.split(' ').map(&:to_i)
ans = "No"
if a == b
if a != c
ans = "Yes"
end
elsif b == c
if a != c
ans = "Yes"
end
elsif a == c
if a != b
ans = "Yes"
end
end
puts ans
|
[
"call.function.change",
"io.output.change"
] | 566,036
| 566,037
|
u965436898
|
ruby
|
p02771
|
a, b, c = gets.map(&:to_i)
def how(a, b, c)
if (a != b) && (b != c) && (c != a)
puts "No"
elsif a == b && b == c
puts "Yes"
else
puts "No"
end
end
puts how(a, b, c)
|
a, b, c = gets.split.map(&:to_i)
def how(a, b, c)
if (a != b) && (b != c) && (c != a)
puts "No"
elsif a == b && b == c
puts "No"
else
puts "Yes"
end
end
puts how(a, b, c)
|
[
"call.add",
"literal.string.change",
"call.arguments.change"
] | 566,123
| 566,124
|
u689835643
|
ruby
|
p02771
|
A,B,C = gets.split.map(&:to_i).sort
puts ((A == B) ^ (B == C)) ? "YES" : "NO"
|
A,B,C = gets.split.map(&:to_i).sort
puts ((A == B) ^ (B == C)) ? "Yes" : "No"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 566,522
| 566,523
|
u627981707
|
ruby
|
p02771
|
nums = gets.split(' ').map(&:to_i)
if nums[0] == nums[1] && nums[1] != nums[2]
puts 'Yes'
elsif nums[1] == nums[2] && nums[2] != nums[0]
puts 'Yes'
elsif nums[0] == nums[2] && nums[0] != nums[1]
puts 'yes'
else
puts 'No'
end
|
nums = gets.split(' ').map(&:to_i)
if nums[0] == nums[1] && nums[1] != nums[2]
puts 'Yes'
elsif nums[1] == nums[2] && nums[2] != nums[0]
puts 'Yes'
elsif nums[0] == nums[2] && nums[0] != nums[1]
puts 'Yes'
else
puts 'No'
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 566,829
| 566,831
|
u675450358
|
ruby
|
p02771
|
a, b, c = gets.chomp.split(" ").map(&:to_i)
if (a == b && a != c)
p "Yes"
elsif (a == c && a != b)
p "Yes"
elsif (b == c && b != a)
p "Yes"
else
p "No"
end
|
a, b, c = gets.chomp.split(" ").map(&:to_i)
if (a == b && a != c)
puts "Yes"
elsif (a == c && a != b)
puts "Yes"
elsif (b == c && b != a)
puts "Yes"
else
puts "No"
end
|
[
"call.function.change",
"io.output.change"
] | 567,107
| 567,108
|
u462011322
|
ruby
|
p02771
|
a, b, c = gets.split.map(&:to_i)
if a == b && a== c
puts 'No'
elsif a == b or a == c
puts 'Yes'
else
puts 'No'
end
|
a, b, c = gets.split.map(&:to_i)
if a == b && a== c
puts 'No'
elsif a == b or a == c or b == c
puts 'Yes'
else
puts 'No'
end
|
[
"control_flow.branch.if.condition.change"
] | 567,113
| 567,114
|
u393913844
|
ruby
|
p02771
|
a, b, c =gets.split
ans = 'No'
ans = 'Yes' if a == b && b != c
ans = 'Yes' if a == c && b != a
ans = 'Yes' if c == b && b != c
puts ans
|
a, b, c =gets.split
ans = 'No'
ans = 'Yes' if a == b && b != c
ans = 'Yes' if a == c && b != a
ans = 'Yes' if c == b && b != a
puts ans
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 567,319
| 567,320
|
u335381753
|
ruby
|
p02771
|
Ns = gets.chomp.split(' ').map(&:to_i)
puts Ns.uniq.count == 2 ? 'yes' : 'no'
|
Ns = gets.chomp.split(' ').map(&:to_i)
puts Ns.uniq.count == 2 ? 'Yes' : 'No'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 567,922
| 567,923
|
u889326464
|
ruby
|
p02771
|
Ns = gets.chomp.split(' ').map(&:to_i)
puts Ns.uniq.count == 2 ? 'yes' : 'no'
|
Ns = gets.chomp.split(' ').map(&:to_i)
puts Ns.uniq.count == 2 ? 'Yes' : 'No'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 567,924
| 567,923
|
u889326464
|
ruby
|
p02771
|
Ns = gets.chomp.split(' ').map(&:to_i)
puts Ns.uniq.count == 2 ? 'YES' : 'NO'
|
Ns = gets.chomp.split(' ').map(&:to_i)
puts Ns.uniq.count == 2 ? 'Yes' : 'No'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 567,925
| 567,923
|
u889326464
|
ruby
|
p02771
|
a,b,c = gets.split().map(&:to_i)
if a == b && b == c
puts "No"
elsif a != b && b != c
puts "No"
else
puts "Yes"
end
|
a,b,c = gets.split().map(&:to_i)
if a == b && b == c
puts "No"
elsif a != b && b != c && a != c
puts "No"
else
puts "Yes"
end
|
[
"control_flow.branch.if.condition.change"
] | 567,945
| 567,946
|
u244401500
|
ruby
|
p02772
|
n = gets
numbers = gets.split(" ").map(&:to_i)
evn_numbers = numbers.select(&:even?)
if evn_numbers.select { |n| (n % 3 == 0) || (n % 5 == 0) }.all?
puts "APPROVED"
else
puts "DENIED"
end
|
n = gets
numbers = gets.split(" ").map(&:to_i)
evn_numbers = numbers.select(&:even?)
if evn_numbers.map { |n| (n % 3 == 0) || (n % 5 == 0) }.all?
puts "APPROVED"
else
puts "DENIED"
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 568,075
| 568,076
|
u494874742
|
ruby
|
p02772
|
a=gets.chomp.split(" ").map(&:to_i)
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
b=gets
a=gets.chomp.split(" ").map(&:to_i)
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
[
"assignment.add"
] | 568,183
| 568,184
|
u678700651
|
ruby
|
p02772
|
a=gets.chomp.split(" ").map(&:to_i)
s=0
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
b=gets
a=gets.chomp.split(" ").map(&:to_i)
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
[
"assignment.add",
"assignment.remove"
] | 568,185
| 568,184
|
u678700651
|
ruby
|
p02772
|
a=gets.chomp.split(" ").map(&:to_i)
s=0
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
b=gets
a=gets.chomp.split(" ").map(&:to_i)
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
[
"assignment.add",
"assignment.remove"
] | 568,186
| 568,187
|
u341246457
|
ruby
|
p02772
|
a=gets.chomp.split(" ").map(&:to_i)
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
b=gets
a=gets.chomp.split(" ").map(&:to_i)
a.each do |e|
if e%2==0
if e%3==0 or e%5==0
else
print "DENIED"
exit
end
end
end
print "APPROVED"
|
[
"assignment.add"
] | 568,188
| 568,189
|
u492991702
|
ruby
|
p02772
|
n = $stdin.gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
flag = 0
n.times do |k|
if arr[k] % 2 == 0
if arr[k] % 3 == 0 || arr[k] == 0
# フラグはそのまま
else
flag = 1
break
end
end
end
if flag == 0
puts "APPROVED"
else
puts "DENIED"
end
|
n = $stdin.gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
flag = 0
n.times do |k|
if arr[k] % 2 == 0
if arr[k] % 3 == 0 || arr[k] % 5 == 0
# フラグはそのまま
else
flag = 1
break
end
end
end
if flag == 0
puts "APPROVED"
else
puts "DENIED"
end
|
[
"control_flow.branch.if.condition.change"
] | 568,276
| 568,277
|
u688809543
|
ruby
|
p02772
|
input = readlines()
n = input.shift.chomp.to_i
is_ok = true
input.chomp.split("\s").map{|x| x.to_i}.each do |item|
next if item.odd?
is_ok = false if item % 3 > 0 && item % 5 > 0
end
puts is_ok ? 'APPROVED' : 'DENIED'
|
input = readlines()
n = input.shift.chomp.to_i
is_ok = true
input.shift.chomp.split("\s").map{|x| x.to_i}.each do |item|
next if item.odd?
is_ok = false if item % 3 > 0 && item % 5 > 0
end
puts is_ok ? 'APPROVED' : 'DENIED'
|
[
"call.add"
] | 568,337
| 568,338
|
u810199299
|
ruby
|
p02772
|
n=gets.to_i
s=gets.split.map!(& to_i)
ans=0
pen=0
for i in 0..n-1
if s[i]%2==0
if s[i]%3==0 || s[i]%5==0
ans=1
else
pen=1
end
end
end
if ans==1 && pen==0 || ans==0 && pen==0
puts "APPROVED"
else
puts "DENIED"
end
|
n=gets.to_i
s=gets.split.map!(&:to_i)
ans=0
pen=0
for i in 0..n-1
if s[i]%2==0
if s[i]%3==0 || s[i]%5==0
ans=1
else
pen=1
end
end
end
if ans==1 && pen==0 || ans==0 && pen==0
puts "APPROVED"
else
puts "DENIED"
end
|
[
"assignment.value.change",
"call.arguments.change"
] | 568,400
| 568,401
|
u977506075
|
ruby
|
p02772
|
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
a.each do |i|
if i%2==1
next
elsif i%3==0 or i%5==0
next
else
puts "DENIED"
exit
end
end
puts "APROVED"
|
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
a.each do |i|
if i%2==1
next
elsif i%3==0 or i%5==0
next
else
puts "DENIED"
exit
end
end
puts "APPROVED"
|
[
"literal.string.change",
"call.arguments.change"
] | 568,696
| 568,697
|
u224392861
|
ruby
|
p02772
|
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
N.times do |i|
if i%2==1
next
elsif i%3==0 or i%5==0
next
else
puts "DENIED"
exit
end
end
puts "APROVED"
|
N=gets.to_i
a=gets.chomp.split.map(&:to_i)
a.each do |i|
if i%2==1
next
elsif i%3==0 or i%5==0
next
else
puts "DENIED"
exit
end
end
puts "APPROVED"
|
[
"identifier.change",
"literal.string.change",
"call.arguments.change"
] | 568,698
| 568,697
|
u224392861
|
ruby
|
p02772
|
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
even = a.select { |x| x.even? }
divide_3or5 = even.select { |x| x % 3 == 0 || n % 5 == 0 }
if even == divide_3or5
puts "APPROVED"
else
puts "DENIED"
end
|
n = gets.chop.to_i
a = gets.chop.split.map(&:to_i)
even = a.select { |x| x.even? }
divide_3or5 = even.select { |x| x % 3 == 0 || x % 5 == 0 }
if even == divide_3or5
puts "APPROVED"
else
puts "DENIED"
end
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 569,204
| 569,205
|
u087858979
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.