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 |
|---|---|---|---|---|---|---|---|
p03227
|
s = gets.chomp.split("")
if s.length == 3
print s.sort.reverse.join("").downcase
elsif s.length == 2
print s.join("").downcase
end
|
s = gets.chomp.split("")
if s.length == 3
print s.reverse.join("").downcase
elsif s.length == 2
print s.join("").downcase
end
|
[
"call.remove"
] | 1,020,044
| 1,020,045
|
u990788654
|
ruby
|
p03228
|
(a,b,n) = STDIN.gets.chomp.split(/ +/).map(&:to_i)
n.times do |i|
if i % 2 == 0
if a % 2 == 1
a-=1
end
a/=2
b+=a
else
if b %2 == 1
b-=1
end
b /= 2
a += a
end
end
puts "%d %d" % [a,b]
|
(a,b,n) = STDIN.gets.chomp.split(/ +/).map(&:to_i)
n.times do |i|
if i % 2 == 0
if a % 2 == 1
a -= 1
end
a /= 2
b += a
else
if b % 2 == 1
b -= 1
end
b /= 2
a += b
end
end
puts "%d %d" % [ a, b ]
|
[
"identifier.change"
] | 1,020,204
| 1,020,205
|
u993842615
|
ruby
|
p03220
|
g=proc{gets.split.map &:to_i}
N=g.call
T,A=g.call
H=g.call
p (1..N).min_by{|x|(A-T+H[x-1]*0.006).abs}
|
g=proc{gets.split.map &:to_i}
N=gets.to_i
T,A=g.call
H=g.call
p (1..N).min_by{|x|(A-T+H[x-1]*0.006).abs}
|
[
"assignment.value.change",
"identifier.change"
] | 1,020,282
| 1,020,283
|
u811480234
|
ruby
|
p03220
|
n = gets.chomp.to_i
t,a = gets.split.map(&:to_f)
line = gets.split.map(&:to_f)
line = line.map{ |i| t - i * 0.006}
tmp = (line[0] - a).abs
cnt = 0
for i in (1..(line.size-1))
if tmp > (line[i] - a).abs
tmp = line[i]
cnt = i
end
end
puts cnt + 1
|
n = gets.chomp.to_i
t,a = gets.split.map(&:to_f)
line = gets.split.map(&:to_f)
line = line.map{ |i| t - i * 0.006}
tmp = (line[0] - a).abs
cnt = 0
for i in (1..(line.size-1))
if tmp > (line[i] - a).abs
tmp = (line[i] - a).abs #差の絶対値のを比較する。
cnt = i
end
end
puts cnt + 1
|
[
"call.add"
] | 1,020,389
| 1,020,390
|
u295797489
|
ruby
|
p03229
|
n = gets.to_i
arr = Array.new(n)
n.times do |i|
arr[i] = gets.to_i
end
arr = arr.sort
m = n / 2
if n % 2 == 0
sum = -2 * arr[0..(m - 2)].sum
sum += 2 * arr[(m + 1)..-1].sum
sum += arr[m] - arr[m - 1]
else
sum = -2 * arr[0..(m-2)].sum
sum += 2 * arr[(m+2)..-1].sum
sum1 = sum + 2 * arr[m + 1] - arr[m] - arr[m - 1]
sum2 = sum + arr[m + 1] + arr[m] - 2 * arr[m - 1]
sum = [sum1, sum2].max
end
puts sum
|
n = gets.to_i
arr = Array.new(n)
n.times do |i|
arr[i] = gets.to_i
end
arr = arr.sort
m = n / 2
if n % 2 == 0
sum = -2 * arr[0...(m - 1)].sum
sum += 2 * arr[(m + 1)..-1].sum
sum += arr[m] - arr[m - 1]
else
sum = -2 * arr[0...(m - 1)].sum
sum += 2 * arr[(m + 2)..-1].sum
sum1 = sum + 2 * arr[m + 1] - arr[m] - arr[m - 1]
sum2 = sum + arr[m + 1] + arr[m] - 2 * arr[m - 1]
sum = [sum1, sum2].max
end
puts sum
|
[
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 1,020,751
| 1,020,752
|
u771770008
|
ruby
|
p03230
|
n=gets.to_i
k=1
i=1
s=[]
while k<=100000
if n==k
puts "Yes"
puts k
(i+1).times do
s << []
end
c=0
cc=i-1
(i/3).times do |a|
3.times do |j|
(i-3*a).times do |b|
s[3*a+j] << a+cc*j+b+1+c
end
end
s[3*a+2][-1]=s[3*a][3*a]
(i+1-3*(a+1)).times do |j|
3.times do |b|
s[3*(a+1)+j] << s[3*a+b][3*a+j+1]
end
end
c=c+cc*3-1
cc-=3
end
if i%3==1
s[-2] << c+(i/3)+1
s[-1] << c+(i/3)+1
elsif i%3==2
s[-3] << c+(i/3)+1
s[-3] << c+(i/3)+2
s[-2] << c+(i/3)+2
s[-2] << c+(i/3)+3
s[-1] << c+(i/3)+3
s[-1] << c+(i/3)+1
end
(i+1).times do |j|
puts [i,s[j].join(" ")].join(" ")
end
exit
end
i+=1
k+=i
end
puts "No"
|
n=gets.to_i
k=1
i=1
s=[]
while k<=100000
if n==k
puts "Yes"
puts i+1
(i+1).times do
s << []
end
c=0
cc=i-1
(i/3).times do |a|
3.times do |j|
(i-3*a).times do |b|
s[3*a+j] << a+cc*j+b+1+c
end
end
s[3*a+2][-1]=s[3*a][3*a]
(i+1-3*(a+1)).times do |j|
3.times do |b|
s[3*(a+1)+j] << s[3*a+b][3*a+j+1]
end
end
c=c+cc*3-1
cc-=3
end
if i%3==1
s[-2] << c+(i/3)+1
s[-1] << c+(i/3)+1
elsif i%3==2
s[-3] << c+(i/3)+1
s[-3] << c+(i/3)+2
s[-2] << c+(i/3)+2
s[-2] << c+(i/3)+3
s[-1] << c+(i/3)+3
s[-1] << c+(i/3)+1
end
(i+1).times do |j|
puts [i,s[j].join(" ")].join(" ")
end
exit
end
i+=1
k+=i
end
puts "No"
|
[
"call.arguments.change"
] | 1,021,192
| 1,021,193
|
u744908753
|
ruby
|
p03230
|
n = gets.chomp.to_i
s = 3
d = 3
w = 2
fld = false
while s < 10**5 do
if s == n then
flg = true
break
end
s += d
d += 1
w += 1
end
if flg then
puts("Yes")
h = w + 1
a = Array.new(h).map{Array.new(w, 0)}
# ななめ
num = 1
add = w
for j in 0..(w - 1) do
for i in [j, j+1] do
a[i][j] = num
end
num += add
add -= 1
end
#右上
for i in 0..(h - 1) do
for j in i+1..(w - 1) do
a[i][j] = a[i][j - 1] + 1
end
end
#左上
for j in 0..(w - 1) do
for i in (j+2)..(h - 1) do
a[i][j] = a[i-1][j] + 1
end
end
# 結果の出力
puts(h)
for i in 0..(h - 1) do
print(w.to_s + " ")
for j in 0..(w - 1) do
print(a[i][j].to_s + " ")
end
print("\n")
end
if false then
for i in 0..(h - 1) do
for j in 0..(w - 1) do
print(a[i][j].to_s + " ")
end
print("\n")
end
end
else
puts("No")
end
|
n = gets.chomp.to_i
s = 1
d = 2
w = 1
fld = false
while s < 10**5 do
if s == n then
flg = true
break
end
s += d
d += 1
w += 1
end
if flg then
puts("Yes")
h = w + 1
a = Array.new(h).map{Array.new(w, 0)}
# ななめ
num = 1
add = w
for j in 0..(w - 1) do
for i in [j, j+1] do
a[i][j] = num
end
num += add
add -= 1
end
#右上
for i in 0..(h - 1) do
for j in i+1..(w - 1) do
a[i][j] = a[i][j - 1] + 1
end
end
#左上
for j in 0..(w - 1) do
for i in (j+2)..(h - 1) do
a[i][j] = a[i-1][j] + 1
end
end
# 結果の出力
puts(h)
for i in 0..(h - 1) do
print(w.to_s + " ")
for j in 0..(w - 1) do
print(a[i][j].to_s + " ")
end
print("\n")
end
if false then
for i in 0..(h - 1) do
for j in 0..(w - 1) do
print(a[i][j].to_s + " ")
end
print("\n")
end
end
else
puts("No")
end
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 1,021,736
| 1,021,737
|
u716826907
|
ruby
|
p03230
|
N = gets.to_i
k = (1..N).find{|k|
k + (k * (k-1))/2 == N
}
if k.nil?
puts "No"; exit
end
puts "Yes"
puts "#{k} " + (1..k).to_a.join(' ')
sets = Array.new(k){|i| [i+1] }
n = k+1
for u in 0...k
for v in (u+1)...k
sets[u] << n
sets[v] << n
n += 1
end
end
sets.each do |set|
puts "#{k} " + set.join(' ')
end
|
N = gets.to_i
k = (1..N).find{|k|
k + (k * (k-1))/2 == N
}
if k.nil?
puts "No"; exit
end
puts "Yes"
puts k+1
puts "#{k} " + (1..k).to_a.join(' ')
sets = Array.new(k){|i| [i+1] }
n = k+1
for u in 0...k
for v in (u+1)...k
sets[u] << n
sets[v] << n
n += 1
end
end
sets.each do |set|
puts "#{k} " + set.join(' ')
end
|
[
"call.add"
] | 1,021,828
| 1,021,829
|
u437302815
|
ruby
|
p03231
|
def gcd(lhs, rhs)
return lhs if rhs == 0
return gcd(rhs, lhs) if lhs < rhs
mod = lhs % rhs
div = (lhs - mod) / rhs
return gcd(rhs, mod)
end
s_length, t_length = gets.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
gcd_res = gcd(s_length, t_length)
x_length = s_length * t_length / gcd_res
ok = true
(x_length / gcd_res).times do |i|
if s[i * s_length / gcd_res] != t[i * t_length / gcd_res]
ok = false
break
end
end
if ok
puts x_length
else
puts -1
end
|
def gcd(lhs, rhs)
return lhs if rhs == 0
return gcd(rhs, lhs) if lhs < rhs
mod = lhs % rhs
div = (lhs - mod) / rhs
return gcd(rhs, mod)
end
s_length, t_length = gets.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
gcd_res = gcd(s_length, t_length)
x_length = s_length * t_length / gcd_res
ok = true
gcd_res.times do |i|
if s[i * s_length / gcd_res] != t[i * t_length / gcd_res]
ok = false
break
end
end
if ok
puts x_length
else
puts -1
end
|
[] | 1,022,302
| 1,022,303
|
u664737319
|
ruby
|
p03231
|
n, m = gets.chomp.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
l = [n, m].inject(:gcd)
i = 0
j = 0
while i < n && j < m
puts i
puts j
if s[i] != t[j]
puts -1
exit
end
i += n / l
j += m / l
end
puts n/l*m
|
n, m = gets.chomp.split.map(&:to_i)
s = gets.chomp
t = gets.chomp
l = [n, m].inject(:gcd)
i = 0
j = 0
while i < n && j < m
if s[i] != t[j]
puts -1
exit
end
i += n / l
j += m / l
end
puts n/l*m
|
[
"call.remove"
] | 1,022,611
| 1,022,612
|
u527280956
|
ruby
|
p03232
|
eval'*A=#'+`tr ' ' ,`
s=m=10**9+7
f=1
i=0
p A.map{i+=1
f=f*i%m
s+=i.pow(m-2,m)
_1*~-s+A[~i]*s}*f%m
|
eval'*A=#'+`tr ' ' ,`
s=m=10**9+7
f=1
i=0
p A.sum{i+=1
f=f*i%m
s+=i.pow m-2,m
_1*~-s+A[-i]*s}*f%m
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"variable_access.subscript.index.change"
] | 1,022,809
| 1,022,811
|
u657913472
|
ruby
|
p03232
|
eval'*A=#'+`tr ' ' ,`
s=m=10**9+7
f=1
i=0
p A.map{i+=1
f=f*i%m
s+=i.pow(m-2,m)
_1*~-s+A[-i]*s}*f%m
|
eval'*A=#'+`tr ' ' ,`
s=m=10**9+7
f=1
i=0
p A.sum{i+=1
f=f*i%m
s+=i.pow m-2,m
_1*~-s+A[-i]*s}*f%m
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,022,813
| 1,022,811
|
u657913472
|
ruby
|
p03232
|
n,a=`dd`.split.map &:to_i
M=10**9+7;I=[1,1];*F=I;*T=0,1
2.upto(n){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;T<<(T[-1]+z)%M}
r=0
n.times{|i|r=(r+a[i]*(T[i+1]+T[n-i]-1))%M}
p r*F[n]%M
|
n,*a=`dd`.split.map &:to_i
M=10**9+7;I=[1,1];*F=I;*T=0,1
2.upto(n){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;T<<(T[-1]+z)%M}
r=0
n.times{|i|r=(r+a[i]*(T[i+1]+T[n-i]-1))%M}
p r*F[n]%M
|
[] | 1,023,115
| 1,023,116
|
u280667879
|
ruby
|
p03238
|
puts (gets == "1") ? "Hello World" : [gets, gets].map(&:to_i).inject(:+)
|
puts (gets.to_i == 1) ? "Hello World" : [gets, gets].map(&:to_i).inject(:+)
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 1,023,815
| 1,023,816
|
u370564845
|
ruby
|
p03238
|
n = gets.chomp
if n == 2
a = gets.chomp.to_i
b = gets.chomp.to_i
puts a+b
else
puts 'Hello World'
end
|
n = gets.chomp.to_i
if n == 2
a = gets.chomp.to_i
b = gets.chomp.to_i
puts a+b
else
puts 'Hello World'
end
|
[
"call.add"
] | 1,023,883
| 1,023,884
|
u157887852
|
ruby
|
p03238
|
case gets.chomp
when 1
puts 'Hello World'
when 2
puts gets.to_i + gets.to_i
end
|
case gets.to_i
when 1
puts 'Hello World'
when 2
puts gets.to_i + gets.to_i
end
|
[
"identifier.change"
] | 1,023,893
| 1,023,894
|
u056944756
|
ruby
|
p03238
|
n = gets.to_i
result = "Hello World"
ary = []
sum = 1
if n == 2
2.times do |i|
ary.push(gets.to_i)
end
ary.each do |n|
sum = sum + n.to_i
end
result = sum
end
puts result
|
n = gets.to_i
result = "Hello World"
ary = []
sum = 0
if n == 2
2.times do |i|
ary.push(gets.to_i)
end
ary.each do |n|
sum = sum + n.to_i
end
result = sum
end
puts result
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 1,023,960
| 1,023,961
|
u944733909
|
ruby
|
p03238
|
n = gets.to_i
result = "Hello World"
ary = []
sum = 1
if n == 2
2.times do |i|
ary.push(gets.to_i)
end
ary.each do |n|
sum = sum * n.to_i
end
result = sum
end
puts result
|
n = gets.to_i
result = "Hello World"
ary = []
sum = 0
if n == 2
2.times do |i|
ary.push(gets.to_i)
end
ary.each do |n|
sum = sum + n.to_i
end
result = sum
end
puts result
|
[
"literal.number.integer.change",
"assignment.value.change",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 1,023,962
| 1,023,961
|
u944733909
|
ruby
|
p03238
|
n=gets
if n=="1" then
puts "Hello World"
else
a=gets.to_i
b=gets.to_i
puts a+b
end
|
n=gets.chomp
if n=="1" then
puts "Hello World"
else
a=gets.to_i
b=gets.to_i
puts a+b
end
|
[
"call.add"
] | 1,024,342
| 1,024,343
|
u168443921
|
ruby
|
p03238
|
n=gets.to_i;a=gets.to_i;b=gets.to_i;
p n == 1 ? 'Hello World': a + b
|
n=gets.to_i;a=gets.to_i;b=gets.to_i;
puts n == 1 ? 'Hello World': a + b
|
[
"call.function.change",
"io.output.change"
] | 1,024,497
| 1,024,498
|
u811480234
|
ruby
|
p03238
|
age = get.to_i
if age == 1
puts "Hello World"
else
a,b = 2.times.map{gets.to_i}
puts a + b
end
|
age = gets.to_i
if age == 1
puts "Hello World"
else
a,b = 2.times.map{gets.to_i}
puts a + b
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,024,531
| 1,024,532
|
u627981707
|
ruby
|
p03238
|
i = gets.chomp
if i == "A"
puts "Hello World"
else
a = gets.chomp.to_i
b = gets.chomp.to_i
puts a + b
end
|
i = gets.chomp.to_i
if i == 1
puts "Hello World"
else
a = gets.chomp.to_i
b = gets.chomp.to_i
puts a + b
end
|
[
"call.add",
"control_flow.branch.if.condition.change"
] | 1,024,760
| 1,024,761
|
u602984196
|
ruby
|
p03238
|
input = $stdin.readlines
n=input[0].chomp.to_i
case n
when 1 then
p 'Hello World'
when 2 then
p input[1].chomp.to_i+input[2].chomp.to_i
end
|
input = $stdin.readlines
n=input[0].chomp.to_i
case n
when 1 then
puts 'Hello World'
when 2 then
p input[1].chomp.to_i+input[2].chomp.to_i
end
|
[
"call.function.change",
"io.output.change"
] | 1,024,951
| 1,024,952
|
u411903982
|
ruby
|
p03238
|
input = $stdin.readlines
n=input[0].chomp.to_i
case n
when 1 then
p "Hello World"
when 2 then
p input[1].chomp.to_i+input[2].chomp.to_i
end
|
input = $stdin.readlines
n=input[0].chomp.to_i
case n
when 1 then
puts 'Hello World'
when 2 then
p input[1].chomp.to_i+input[2].chomp.to_i
end
|
[
"literal.string.change",
"call.arguments.change"
] | 1,024,953
| 1,024,952
|
u411903982
|
ruby
|
p03238
|
age = gets.to_i
if age == 1
p 'Hello World'
elsif age == 2
a = gets.to_i
b = gets.to_i
p a + b
end
|
age = gets.to_i
if age == 1
puts 'Hello World'
elsif age == 2
a = gets.to_i
b = gets.to_i
puts a + b
end
|
[
"call.function.change",
"io.output.change"
] | 1,024,987
| 1,024,988
|
u094197486
|
ruby
|
p03239
|
n,t = gets.stirp.split.map(&:to_i)
ary = []
n.times do
a,b = gets.stirp.split.map(&:to_i)
if b <= t
ary.unshift(a)
end
end
if ary.size == 0
puts "TLE"
else
puts ary.min
end
|
n,t = gets.strip.split.map(&:to_i)
ary = []
n.times do
a,b = gets.strip.split.map(&:to_i)
if b <= t
ary.unshift(a)
end
end
if ary.size == 0
puts "TLE"
else
puts ary.min
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,025,057
| 1,025,058
|
u313103408
|
ruby
|
p03238
|
#! /usr/bin/env ruby
input = STDIN.read.split("\n").map{|l| l.to_i}
age = input[0]
if age == 1 then
p "Hello World"
else
p input[1] + input[2]
end
|
input = STDIN.read.split("\n").map{|l| l.to_i}
age = input[0]
if age == 1 then
puts "Hello World"
else
puts input[1] + input[2]
end
|
[
"call.function.change",
"io.output.change"
] | 1,025,083
| 1,025,084
|
u346050999
|
ruby
|
p03239
|
n,t=gets.split.map(&:to_i)
puts n.times.map{gets.split.map(&:to_i)}.select{|c,tt| tt<=t}.map{|c,_|c}.min
|
n,t=gets.split.map(&:to_i)
puts n.times.map{gets.split.map(&:to_i)}.select{|c,tt| tt<=t}.map{|c,_|c}.min || 'TLE'
|
[
"expression.operation.binary.add"
] | 1,025,491
| 1,025,492
|
u056944756
|
ruby
|
p03239
|
N,T=gets.chomp.split.map(&:to_i)
ans=10000
N.times{
buf=gets.chomp.split.map(:to_i)
ans=[ans,buf[0]] if buf[1] <= T
}
puts ans==10000 ? "TLE" : ans
|
N,T=gets.chomp.split.map(&:to_i)
ans=10000
N.times{
buf=gets.chomp.split.map(&:to_i)
ans=[ans,buf[0]].min if buf[1] <= T
}
puts ans==10000 ? "TLE" : ans
|
[
"call.arguments.change",
"call.add"
] | 1,025,593
| 1,025,594
|
u585819925
|
ruby
|
p03239
|
n,t = gets.chomp.split.map(&:to_i)
rs = n.times.map{gets.chomp.split.map(&:to_i)}.sort_by(&:first)
ans = "TLE"
rs.each do |r|
if r[1] < t
ans = r[0].to_s
break
end
end
puts ans
|
n,t = gets.chomp.split.map(&:to_i)
rs = n.times.map{gets.chomp.split.map(&:to_i)}.sort_by(&:first)
ans = "TLE"
rs.each do |r|
if r[1] <= t
ans = r[0].to_s
break
end
end
puts ans
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,025,878
| 1,025,879
|
u191196346
|
ruby
|
p03239
|
n,t = gets.split.map(&:to_i)
ary = []
n.times do
ci,ti = gets.split.map(&:to_i)
ary.push(ci) if ti <= t
end
if ary.nil?
puts "TLE"
else
puts ary.min
end
|
n,t = gets.split.map(&:to_i)
ary = []
n.times do
ci,ti = gets.split.map(&:to_i)
ary.push(ci) if ti <= t
end
if ary.empty?
puts "TLE"
else
puts ary.min
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,026,087
| 1,026,088
|
u622469330
|
ruby
|
p03239
|
n,t = gets.split.map(&:to_i)
ary = []
n.times do
ci,ti = gets.split.map(&:to_i)
ary.push(ci) if ti <= t
end
if any.nil?
puts "TLE"
else
puts ary.min
end
|
n,t = gets.split.map(&:to_i)
ary = []
n.times do
ci,ti = gets.split.map(&:to_i)
ary.push(ci) if ti <= t
end
if ary.empty?
puts "TLE"
else
puts ary.min
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,026,089
| 1,026,088
|
u622469330
|
ruby
|
p03239
|
choices, limit_time = gets.split.map(&:to_i)
a = (1..choices).map{ |a|
x,required_time = gets.split.map(&:to_i)
x if required_time <= limit_time}.compact
p a.empty? ? "TLE" : a.min
|
choices, limit_time = gets.split.map(&:to_i)
a = (1..choices).map{ |a|
x,required_time = gets.split.map(&:to_i)
x if required_time <= limit_time}.compact
puts a.empty? ? "TLE" : a.min
|
[
"call.function.change",
"io.output.change"
] | 1,026,279
| 1,026,280
|
u510556034
|
ruby
|
p03239
|
n,t = gets.split.map(&:to_i)
a =[]
b = []
for i in 0..n - 1
a[i] = gets.split.map(&:to_i)
if a[i][1] <= t
b << a[i][0]
end
end
if b == nil
puts "TLE"
else
puts b.sort[0]
end
|
n,t = gets.split.map(&:to_i)
a =[]
b = []
for i in 0..n - 1
a[i] = gets.split.map(&:to_i)
if a[i][1] <= t
b << a[i][0]
end
end
if b == []
puts "TLE"
else
puts b.sort[0]
end
|
[
"control_flow.branch.if.condition.change"
] | 1,026,419
| 1,026,420
|
u990788654
|
ruby
|
p03239
|
n,t = gets.split.map(&:to_i)
a =[]
b = []
for i in 0..n - 1
a[i] = gets.split.map(&:to_i)
if a[i][1] <= t
b << a[i][0]
end
end
if b == nil
puts "TEL"
else
puts b.sort[0]
end
|
n,t = gets.split.map(&:to_i)
a =[]
b = []
for i in 0..n - 1
a[i] = gets.split.map(&:to_i)
if a[i][1] <= t
b << a[i][0]
end
end
if b == []
puts "TLE"
else
puts b.sort[0]
end
|
[
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change"
] | 1,026,421
| 1,026,420
|
u990788654
|
ruby
|
p03239
|
N, T = gets.split.map {|w| w.chomp.to_i}
@ct = []
(1..N).each do
c, t = gets.split.map {|w| w.chomp.to_i}
@ct.push({:c => c, :t => t})
end
if m = @ct.select{|w| w[:t] <= T}.min{|a, b| a[:t] <=> b[:t]}
puts m[:c]
else
puts "TLE"
end
|
N, T = gets.split.map {|w| w.chomp.to_i}
@ct = []
(1..N).each do
c, t = gets.split.map {|w| w.chomp.to_i}
@ct.push({:c => c, :t => t})
end
if m = @ct.select{|w| w[:t] <= T}.min{|a, b| a[:c] <=> b[:c]}
puts m[:c]
else
puts "TLE"
end
|
[
"assignment.value.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 1,026,583
| 1,026,584
|
u086605796
|
ruby
|
p03239
|
n, t = gets.chomp.split(' ').map(&:to_i)
pattern_array = []
for i in 1..n
pattern_array << gets.chomp.split(' ').map(&:to_i)
end
p = pattern_array.select {|i| i[1] <= t}.map{|c| c[0]}.first
puts p.nil? ? 'TLE' : p
|
n, t = gets.chomp.split(' ').map(&:to_i)
pattern_array = []
for i in 1..n
pattern_array << gets.chomp.split(' ').map(&:to_i)
end
p = pattern_array.select {|i| i[1] <= t}.map{|c| c[0]}.min
puts p.nil? ? 'TLE' : p
|
[
"assignment.value.change",
"identifier.change"
] | 1,026,587
| 1,026,588
|
u568319388
|
ruby
|
p03239
|
n, t = gets.chomp.split(' ').map(&:to_i)
pattern_array = []
for i in 1..n
pattern_array << gets.chomp.split(' ').map(&:to_i)
end
p = pattern_array.select {|i| i[1] <= t}.map{|c| c[0]}.first
puts c.nil? ? 'TLE' : c
|
n, t = gets.chomp.split(' ').map(&:to_i)
pattern_array = []
for i in 1..n
pattern_array << gets.chomp.split(' ').map(&:to_i)
end
p = pattern_array.select {|i| i[1] <= t}.map{|c| c[0]}.min
puts p.nil? ? 'TLE' : p
|
[
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 1,026,589
| 1,026,588
|
u568319388
|
ruby
|
p03239
|
N, T = gets.split.map!{|x| x.to_i}
input = Array.new
(0..(N - 1)).each do
input << gets.split.map!{|x| x.to_i}
end
nominee = Array.new
input.each do |r|
cost = r[0]
time = r[1]
nominee << [cost, time] if time < T
end
result = nominee.map {|i| i[0]}.min
if result.nil?
puts 'TLE'
else
puts result
end
|
N, T = gets.split.map!{|x| x.to_i}
input = Array.new
(0..(N - 1)).each do
input << gets.split.map!{|x| x.to_i}
end
nominee = Array.new
input.each do |r|
cost = r[0]
time = r[1]
nominee << [cost, time] if time <= T
end
result = nominee.map {|i| i[0]}.min
if result.nil?
puts 'TLE'
else
puts result
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,026,662
| 1,026,663
|
u559172648
|
ruby
|
p03239
|
data = gets.split(" ")
limit = data[1].to_i
count = data[0].to_i
db=Array.new
count.times do |i|
d = gets.split(" ")
db.push(d)
end
db = db.find_all {|item| item[1].to_i < limit.to_i}
int = 10000
db.each do |d|
i = d[0].to_i
if i < int
int = i
end
end
if int == 10000
puts "TLE"
else
puts int
end
|
data = gets.split(" ")
limit = data[1].to_i
count = data[0].to_i
db=Array.new
count.times do |i|
d = gets.split(" ")
db.push(d)
end
db = db.find_all {|item| item[1].to_i <= limit.to_i}
int = 10000
db.each do |d|
i = d[0].to_i
if i < int
int = i
end
end
if int == 10000
puts "TLE"
else
puts int
end
|
[
"expression.operator.compare.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,026,848
| 1,026,849
|
u809037624
|
ruby
|
p03240
|
n = gets.chomp.to_i
x = []
y = []
h = []
n.times do |i|
x[i], y[i], h[i] = gets.chomp.split.map(&:to_i)
end
101.times do |xx|
101.times do |yy|
highest = nil
n.times do |i|
if h[i] != 0
highest = h[i] + (x[i] - xx).abs + (y[i] - yy)
break
end
end
flag = true
n.times do |i|
if h[i] != [highest - (x[i] - xx).abs - (y[i] - yy).abs, 0].max
flag = false
break
end
end
if flag
puts "#{xx} #{yy} #{highest}"
exit
end
end
end
|
n = gets.chomp.to_i
x = []
y = []
h = []
n.times do |i|
x[i], y[i], h[i] = gets.chomp.split.map(&:to_i)
end
101.times do |xx|
101.times do |yy|
highest = nil
n.times do |i|
if h[i] != 0
highest = h[i] + (x[i] - xx).abs + (y[i] - yy).abs
break
end
end
flag = true
n.times do |i|
if h[i] != [highest - (x[i] - xx).abs - (y[i] - yy).abs, 0].max
flag = false
break
end
end
if flag
puts "#{xx} #{yy} #{highest}"
exit
end
end
end
|
[
"call.add"
] | 1,027,735
| 1,027,736
|
u195257137
|
ruby
|
p03240
|
N = gets.to_i
A = []
B = []
N.times do
tmp = gets.split.map(&:to_i)
if tmp[2] > 0
A << tmp
else
B << tmp
end
end
for cy in 0..100
for cx in 0..100
tmp = A.map{|x, y, h| h + (x - cx).abs + (y - cy).abs}
if tmp.uniq.size == 1
ht = tmp[0]
if B.all?{|x, y , h0| ht < (x - cx).abs + (y - cy).abs}
puts "#{cx} #{cy} #{ht}"
break
end
end
end
end
|
N = gets.to_i
A = []
B = []
N.times do
tmp = gets.split.map(&:to_i)
if tmp[2] > 0
A << tmp
else
B << tmp
end
end
for cy in 0..100
for cx in 0..100
tmp = A.map{|x, y, h| h + (x - cx).abs + (y - cy).abs}
if tmp.uniq.size == 1
ht = tmp[0]
if B.all?{|x, y , h0| ht <= (x - cx).abs + (y - cy).abs}
puts "#{cx} #{cy} #{ht}"
exit
end
end
end
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"control_flow.break.remove",
"control_flow.exit.add"
] | 1,028,557
| 1,028,556
|
u004588855
|
ruby
|
p03241
|
require "prime"
n,m=gets.split.map(&:to_i)
# 参考:https://qiita.com/norioc/items/5c270ad6ff5d22d1efd0#comment-da13f6b749dba662ec63
def d(n)
n.prime_division.inject([1]) do |ary, (p, e)|
(0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
end.sort
end
d(m).reverse do |i|
if i<=m/n
puts i
exit
end
end
|
require "prime"
n,m=gets.split.map(&:to_i)
# 参考:https://qiita.com/norioc/items/5c270ad6ff5d22d1efd0#comment-da13f6b749dba662ec63
def d(n)
n.prime_division.inject([1]) do |ary, (p, e)|
(0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
end.sort
end
d(m).reverse.each do |i|
if i<=m/n
puts i
exit
end
end
|
[
"call.add"
] | 1,029,116
| 1,029,117
|
u744908753
|
ruby
|
p03241
|
require "prime"
n,m=gets.split.map(&:to_i)
# 参考:https://qiita.com/norioc/items/5c270ad6ff5d22d1efd0#comment-da13f6b749dba662ec63
def d(n)
n.prime_division.inject([1]) do |ary, (p, e)|
(0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
end.sort
end
d(n).reverse do |i|
if i<=m/n
puts i
exit
end
end
|
require "prime"
n,m=gets.split.map(&:to_i)
# 参考:https://qiita.com/norioc/items/5c270ad6ff5d22d1efd0#comment-da13f6b749dba662ec63
def d(n)
n.prime_division.inject([1]) do |ary, (p, e)|
(0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
end.sort
end
d(m).reverse.each do |i|
if i<=m/n
puts i
exit
end
end
|
[
"identifier.change",
"call.arguments.change",
"io.output.change",
"call.add"
] | 1,029,118
| 1,029,117
|
u744908753
|
ruby
|
p03241
|
def divisors(n)
b = Array.new
for i in 2..((n**0.5))
if n % i == 0
b.push(i)
end
end
len = b.length
len.times{|i|
if n/b[len-1-i] != b[len-1-i]
b.push(n/b[len-1-i])
end
}
b
end
n,m = gets.chomp.split(" ").map(&:to_i)
max = 1
divisors(m).each do |i|
if (m - i*n) >= 0 && (m - i*n) % i == 0
max = i if i > max
end
end
puts max
|
def divisors(n)
b = Array.new
for i in 1..((n**0.5))
if n % i == 0
b.push(i)
end
end
len = b.length
len.times{|i|
if n/b[len-1-i] != b[len-1-i]
b.push(n/b[len-1-i])
end
}
b
end
n,m = gets.chomp.split(" ").map(&:to_i)
max = 1
divisors(m).each do |i|
if (m - i*n) >= 0 && (m - i*n) % i == 0
max = i if i > max
end
end
puts max
|
[
"literal.number.integer.change"
] | 1,029,399
| 1,029,400
|
u265679940
|
ruby
|
p03241
|
def divisors(n)
b = Array.new
for i in 2..((n**0.5))
if n % i == 0
b.push(i)
end
end
len = b.length
len.times{|i|
if n/b[len-1-i] != b[len-1-i]
b.push(n/b[len-1-i])
end
}
b
end
n,m = gets.chomp.split(" ").map(&:to_i)
max = 0
divisors(m).each do |i|
if (m - i*n) >= 0 && (m - i*n) % i == 0
max = i if i > max
end
end
puts max
|
def divisors(n)
b = Array.new
for i in 1..((n**0.5))
if n % i == 0
b.push(i)
end
end
len = b.length
len.times{|i|
if n/b[len-1-i] != b[len-1-i]
b.push(n/b[len-1-i])
end
}
b
end
n,m = gets.chomp.split(" ").map(&:to_i)
max = 1
divisors(m).each do |i|
if (m - i*n) >= 0 && (m - i*n) % i == 0
max = i if i > max
end
end
puts max
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 1,029,401
| 1,029,400
|
u265679940
|
ruby
|
p03241
|
n, m = gets.split.map(&:to_i)
i = m / n
while i > 0
if m % i == 0
puts
exit
else
i-=1
end
end
|
n, m = gets.split.map(&:to_i)
i = m / n
while i > 0
if m % i == 0
puts i
exit
else
i -= 1
end
end
|
[
"call.arguments.change"
] | 1,029,882
| 1,029,883
|
u785521224
|
ruby
|
p03241
|
n,m = gets.split.map(&:to_i)
ans = 1
1.upto(10000){|i|
ans = i if m%i==0 && m/i>=n && ans < i
ans = m/i if m%i==0 && i>=n && ans < m/i
}
p ans
|
n,m = gets.split.map(&:to_i)
ans = 1
1.upto(100_000){|i|
ans = i if m%i==0 && m/i>=n && ans < i
ans = m/i if m%i==0 && i>=n && ans < m/i
}
p ans
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 1,029,907
| 1,029,908
|
u397763977
|
ruby
|
p03241
|
n,m=gets.split.map &:to_i
i=r=0
while i*i<=m
i+=1
next if m%i>0
r=[r,i].max if i<=m/n
r=[r,m/i].max if i<=m/n
end
p r
|
n,m=gets.split.map &:to_i
i=r=0
while i*i<=m
i+=1
next if m%i>0
r=[r,i].max if i<=m/n
r=[r,m/i].max if m/i<=m/n
end
p r
|
[] | 1,029,994
| 1,029,995
|
u280667879
|
ruby
|
p03241
|
N,M = gets.strip.split.map(&:to_i)
require 'prime'
class Integer
def my_divisor_list3
return [1] if self == 1
first, *rest = Prime.prime_division(self).map do |p, k|
(0..k).map{|i| p**i}
end
first.product(*rest).map do |a|
a.inject(&:*)
end.sort
end
end
i = 0
x = M.my_divisor_list3
cnt = M
if N == 1
else
while x[i] <= M
if x[i] > (M/N)
cnt = x[i - 1]
break
end
i += 1
end
end
|
N,M = gets.strip.split.map(&:to_i)
require 'prime'
class Integer
def my_divisor_list3
return [1] if self == 1
first, *rest = Prime.prime_division(self).map do |p, k|
(0..k).map{|i| p**i}
end
first.product(*rest).map do |a|
a.inject(&:*)
end.sort
end
end
i = 0
x = M.my_divisor_list3
cnt = M
if N == 1
else
while x[i] <= M
if x[i] > (M/N)
cnt = x[i - 1]
break
end
i += 1
end
end
puts cnt
|
[
"call.add"
] | 1,030,037
| 1,030,038
|
u166306121
|
ruby
|
p03242
|
n = gets.split(//).map(&:to_i)
num = 0
ans = []
n.each do |i|
if i == 9
ans[num] = 1
else
ans[num] = 9
end
num = num + 1
end
puts ans.join.to_s
|
n = gets.split(//).map(&:to_i)
num = 0
ans = []
n.each do |i|
if i == 9
ans[num] = 1
elsif i == 1
ans[num] = 9
end
num = num + 1
end
puts ans.join.to_s
|
[
"control_flow.branch.if.condition.change"
] | 1,030,828
| 1,030,829
|
u944733909
|
ruby
|
p03242
|
n = gets.split(//).map(&:to_i)
num = 0
ans = []
n.each do |i|
if i == 9
ans[num] = 1
else
ans[num] = 9
end
num = num + 1
end
puts ans.join.to_i
|
n = gets.split(//).map(&:to_i)
num = 0
ans = []
n.each do |i|
if i == 9
ans[num] = 1
elsif i == 1
ans[num] = 9
end
num = num + 1
end
puts ans.join.to_s
|
[
"control_flow.branch.if.condition.change",
"call.function.change",
"type_conversion.to_string.change"
] | 1,030,830
| 1,030,829
|
u944733909
|
ruby
|
p03242
|
n = gets.chomp
(0..n.length-1).each do |i|
if n[i] == '1'
n[i] = '9'
elsif n[i] == '9'
n[i] == '1'
end
end
puts n
|
n = gets.chomp
(0..n.length-1).each do |i|
if n[i] == '1'
n[i] = '9'
elsif n[i] == '9'
n[i] = '1'
end
end
puts n
|
[
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 1,030,856
| 1,030,857
|
u866325115
|
ruby
|
p03242
|
arr = gets.split("").map{ |a|
if a == "9"
a = "1"
elsif a == "1"
a = "9"
end
}
puts arr.jon
|
arr = gets.split("").map{ |a|
if a == "9"
a = "1"
elsif a == "1"
a = "9"
end
}
puts arr.join
|
[
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 1,030,859
| 1,030,860
|
u012110567
|
ruby
|
p03242
|
puts s.tr('1','t').tr('9','1').tr('t','9')
|
puts gets.tr('1','t').tr('9','1').tr('t','9')
|
[
"identifier.change",
"call.arguments.change"
] | 1,030,876
| 1,030,877
|
u408023666
|
ruby
|
p03242
|
s = gets.strip
s = s.to_s
for n in 0...s.length
if s[n] == "1" then
s[n] = "9"
elsif s[n] == "9" then
s[n] == "1"
end
end
print s
|
s = gets.strip
s = s.to_s
for n in 0...s.length
if s[n] == "1" then
s[n] = "9"
elsif s[n] == "9" then
s[n] = "1"
end
end
print s
|
[
"expression.operation.compare.replace.remove",
"assignment.replace.add",
"misc.typo"
] | 1,030,909
| 1,030,910
|
u460204279
|
ruby
|
p03242
|
a = ""
gets.chars do |c|
a += c=='1' ? '9' : '1'
end
puts a
|
a = ""
gets.chomp.chars do |c|
a += c=='1' ? '9' : '1'
end
puts a
|
[
"call.add"
] | 1,031,038
| 1,031,039
|
u502306384
|
ruby
|
p03242
|
puts gets.chars.map { |n|
n == '1' ? '9' : '1'
}.join
|
puts gets.chomp.chars.map { |n|
n == '1' ? '9' : '1'
}.join
|
[
"call.add"
] | 1,031,044
| 1,031,045
|
u326562452
|
ruby
|
p03242
|
p gets.gsub(/1|9/){|c| c=="1"?9:1}
|
puts gets.gsub(/1|9/){|c| c=="1"?9:1}
|
[
"call.function.change",
"io.output.change"
] | 1,031,122
| 1,031,123
|
u358554431
|
ruby
|
p03242
|
array=gets.split("").map(&:to_i)
brray=[]
s=0
while s<3
if array[s] == 1
brray.push(9)
else
brray.push(1)
end
s+=1
end
puts 100*brray[0]+10*brray[1]+brray[2]
p brray
|
array=gets.split("").map(&:to_i)
brray=[]
s=0
while s<3
if array[s] == 1
brray.push(9)
else
brray.push(1)
end
s+=1
end
puts 100*brray[0]+10*brray[1]+brray[2]
|
[
"call.remove"
] | 1,031,127
| 1,031,128
|
u987183622
|
ruby
|
p03242
|
n = gets
p n.gsub(/1|9/,'1'=>'9','9'=>'1')
|
n = gets
p n.gsub(/1|9/,'1'=>'9','9'=>'1').to_i
|
[
"call.add"
] | 1,031,233
| 1,031,234
|
u439687774
|
ruby
|
p03242
|
s = gets.chomp
s = s.gsub(/19/) do |n|
n == '1' ? '9' : '1'
end
puts s
|
s = gets.chomp
s = s.gsub(/1|9/) do |n|
n == '1' ? '9' : '1'
end
puts s
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 1,031,340
| 1,031,341
|
u307252896
|
ruby
|
p03242
|
gets.gsub(/[19]/){$&.to_i^8}
|
puts gets.gsub(/[19]/){$&.to_i^8}
|
[
"io.output.change",
"call.add"
] | 1,031,422
| 1,031,423
|
u335619873
|
ruby
|
p03242
|
n = gets.split("")
num = n.map { |n123| n123.to_i }
sum = ""
for i in num do
if i == 9 then
sum = sum + "1"
else
sum = sum + "9"
end
end
sum = sum.to_i
puts sum
|
n = gets.split("")
num = n.map { |n123| n123.to_i }
sum = ""
for i in num do
if i == 9 then
sum = sum + "1"
elsif i == 1 then
sum = sum + "9"
end
end
sum = sum.to_i
puts sum
|
[] | 1,031,492
| 1,031,493
|
u904735547
|
ruby
|
p03242
|
i = readlines[0]
p i.gsub(/1|9/, '9' => '1','1'=>'9')
|
i = readlines[0]
p i.gsub(/1|9/, '9' => '1','1'=>'9').to_i
|
[
"call.add"
] | 1,031,522
| 1,031,523
|
u053294083
|
ruby
|
p03243
|
n = gets.to_f
puts (n/111).ceil
|
n = gets.to_f
puts ((n/111).ceil)*111
|
[
"call.arguments.change"
] | 1,031,587
| 1,031,588
|
u313103408
|
ruby
|
p03240
|
_,*s,(i,j,k)=$<.map{|s|s.split.map &:to_i}.sort_by &:last
101.times{|x|101.times{|y|h=k+(i-x).abs+(j-y).abs
s.all?{|i,j,k|k==[h-(i-x).abs-(j-y).abs,0].max}&&($><<[x,y,h]*" ";exit)}}
|
gets
*s,(i,j,k)=$<.map{|s|s.split.map &:to_i}.sort_by &:last
101.times{|x|101.times{|y|h=k+(i-x).abs+(j-y).abs
s.all?{|i,j,k|k==[h-(i-x).abs-(j-y).abs,0].max}&&($><<[x,y,h]*" ";exit)}}
|
[] | 1,031,663
| 1,031,664
|
u019489252
|
ruby
|
p03240
|
def decide_h(cx,cy,ary_xyh)
h = ary_xyh[2]+(cx-ary_xyh[0]).abs+(cy-ary_xyh[1]).abs
return h
end
def histrue?(cx,cy,ary_xyh,h)
tmp_h = [(h-(ary_xyh[0]-x).abs-(ary_xyh[1]-y).abs),0].max
if tmp_h == ary_xyh[2]
true
else
false
end
# tmp_h = ary_xyh[2]+(cx-ary_xyh[0]).abs+(cy-ary_xyh[1]).abs
# if tmp_h == h
# return true
# else
# return false
# end
end
n = gets.chomp.to_i
ary = []
n.times do
xi,yi,hi = gets.chomp.split.map(&:to_i)
ary << [xi,yi,hi]
end
nukeru = false
for cx in 0..100
for cy in 0..100
flag = true
# hを定める
h = 0
ary.each do |point|
if point[2] != 0
h = decide_h(cx,cy,point)
break
end
end
# hが正しいか調べる
ary.each do |point|
if !histrue?(cx,cy,point,h)
flag = false
break
end
end
# hが正しかったらすべてのループを抜ける
if flag
nukeru = true
print("#{cx} #{cy} #{h}")
break
end
end
if nukeru
break
end
end
|
def decide_h(cx,cy,ary_xyh)
h = ary_xyh[2]+(cx-ary_xyh[0]).abs+(cy-ary_xyh[1]).abs
return h
end
def histrue?(cx,cy,ary_xyh,h)
tmp_h = [(h-(ary_xyh[0]-cx).abs-(ary_xyh[1]-cy).abs),0].max
if tmp_h == ary_xyh[2]
true
else
false
end
# tmp_h = ary_xyh[2]+(cx-ary_xyh[0]).abs+(cy-ary_xyh[1]).abs
# if tmp_h == h
# return true
# else
# return false
# end
end
n = gets.chomp.to_i
ary = []
n.times do
xi,yi,hi = gets.chomp.split.map(&:to_i)
ary << [xi,yi,hi]
end
nukeru = false
for cx in 0..100
for cy in 0..100
flag = true
# hを定める
h = 0
ary.each do |point|
if point[2] != 0
h = decide_h(cx,cy,point)
break
end
end
# hが正しいか調べる
ary.each do |point|
if !histrue?(cx,cy,point,h)
flag = false
break
end
end
# hが正しかったらすべてのループを抜ける
if flag
nukeru = true
print("#{cx} #{cy} #{h}")
break
end
end
if nukeru
break
end
end
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 1,031,796
| 1,031,797
|
u706730549
|
ruby
|
p03241
|
def main
n, m = gets.split.map(&:to_i)
# 割り切れるなら➾即決
if m % n == 0
puts m / n
return
end
(n-1).downto(2) do |d|
next if m % d != 0
# 割り切れるのでチャンスはあるが、
# 個数の問題をクリアできるか?
num = m / d
if n <= num
puts d
return
end
end
puts 1
end
if __FILE__ == $0
main
end
|
def main
n, m = gets.split.map(&:to_i)
# 割り切れるなら➾即決
if m % n == 0
puts m / n
return
end
(m/n).downto(2) do |d|
next if m % d != 0
# 割り切れるのでチャンスはあるが、
# 個数の問題をクリアできるか?
num = m / d
if n <= num
puts d
return
end
end
puts 1
end
if __FILE__ == $0
main
end
|
[
"expression.operation.binary.remove"
] | 1,031,942
| 1,031,943
|
u657749689
|
ruby
|
p03241
|
require 'prime'
def divisors(primes, k)
Enumerator.new do |y|
if primes.size == k
y << 1
else
p, e = primes[k]
divisors(primes, k + 1).each {|d|
(e + 1).times {|e1|
y << p ** e1 * d
}
}
end
end
end
n, m = gets.split.map(&:to_i)
puts divisors(Prime.prime_division(m), 0).select{ |k| k if k <= n }.max
|
require 'prime'
def divisors(primes, k)
Enumerator.new do |y|
if primes.size == k
y << 1
else
p, e = primes[k]
divisors(primes, k + 1).each {|d|
(e + 1).times {|e1|
y << p ** e1 * d
}
}
end
end
end
n, m = gets.split.map(&:to_i)
puts divisors(Prime.prime_division(m), 0).select{ |k| k if m >= n * k }.max
|
[
"control_flow.branch.if.condition.change"
] | 1,031,944
| 1,031,945
|
u331906013
|
ruby
|
p03243
|
n = gets.chomp.split("")
if (n.join).to_i <= (n[0]*3).to_i
p (n[0]*3).to_i
else
p (((n[1]).to_i+1).to_s*3).to_i
end
|
n = gets.chomp.split("")
if (n.join).to_i <= (n[0]*3).to_i
p (n[0]*3).to_i
else
p (((n[0]).to_i+1).to_s*3).to_i
end
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,032,085
| 1,032,086
|
u012110567
|
ruby
|
p03243
|
n = gets.to_i
puts (111..999).step(111).find{|it| it > n}
|
n = gets.to_i
puts (111..999).step(111).find{|it| it >= n}
|
[
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 1,032,364
| 1,032,365
|
u714769076
|
ruby
|
p03243
|
n = gets.to_i
cs = [111,222,333,444,555,666,777,888,999]
cs.each do |c|
if n < c
puts c
exit 0
end
end
|
n = gets.to_i
cs = [111,222,333,444,555,666,777,888,999]
cs.each do |c|
if n <= c
puts c
exit 0
end
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,032,736
| 1,032,737
|
u105001881
|
ruby
|
p03243
|
input = gets
ary = input.split('')
x = ary[0]
xx = x*3
if xx.to_i < (ary[0]+ary[1]+ary[2]).to_i
x = (x.to_i + 1).to_s
end
p x*3
|
input = gets
ary = input.split('')
x = ary[0]
xx = x*3
if xx.to_i < (ary[0]+ary[1]+ary[2]).to_i
x = (x.to_i + 1).to_s
end
puts x*3
|
[
"call.function.change",
"io.output.change"
] | 1,032,742
| 1,032,743
|
u647472020
|
ruby
|
p03243
|
def f(i)
s = i.to_s
s[0]==s[1]&&s[1]==s[2]
end
n = gets.chomp.to_i
(n...999).each do |i|
if f(i)
puts i
break
end
end
|
def f(i)
s = i.to_s
s[0]==s[1]&&s[1]==s[2]
end
n = gets.chomp.to_i
(n..999).each do |i|
if f(i)
puts i
break
end
end
|
[] | 1,032,893
| 1,032,894
|
u817142576
|
ruby
|
p03243
|
a=gets.chomp.split("").map(&:to_i)
if a[0]*111>a.join("").to_i
puts a[0]*111
else
puts (a[0]+1)*111
end
|
a=gets.chomp.split("").map(&:to_i)
if a[0]*111>=a.join("").to_i
puts a[0]*111
else
puts (a[0]+1)*111
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,032,954
| 1,032,955
|
u308416164
|
ruby
|
p03243
|
puts((gets.to_i/111+1)*111)
|
puts ((gets.to_i-1)/111+1)*111
|
[
"call.arguments.change"
] | 1,032,997
| 1,032,998
|
u712322283
|
ruby
|
p03243
|
n = gets.to_i
test = 0
array = [111, 222, 333, 444, 555, 666, 777, 888, 999]
array.each_with_index do |item, idx|
if array[idx] == n
test = n
break
end
if (array[idx] < n) && (array[idx+1] > n)
test = array[idx+1]
break
end
end
puts test
|
n = gets.to_i
test = 111
array = [111, 222, 333, 444, 555, 666, 777, 888, 999]
array.each_with_index do |item, idx|
if array[idx] == n
test = n
break
end
if (array[idx] < n) && (array[idx+1] > n)
test = array[idx+1]
break
end
end
puts test
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 1,033,053
| 1,033,054
|
u479293225
|
ruby
|
p03244
|
n = gets.to_i
v = gets.split.map(&:to_i)
p = Hash.new(0)
q = Hash.new(0)
n.times do |i|
p[v[i]] += 1 if i.even?
q[v[i]] += 1 if i.odd?
end
ps = Hash[p.sort_by{|k, v| -v}].keys
qs = Hash[q.sort_by{|k, v| -v}].keys
x, y, ans = 0, 0, 0
f = false
ps.size.times do |i|
x = ps[i]
qs.size.times do |j|
if x != qs[j]
y = qs[j]
f = true
break
end
end
break if f
end
ans = n - p[x] - q[y] if f
x, y = 0, 0
f = false
qs.size.times do |i|
x = qs[i]
ps.size.times do |j|
if x != ps[j]
y = ps[j]
f = true
break
end
end
break if f
end
ans = n - q[x] - p[y] if f && ans > n - q[x] - p[y]
puts ans
|
n = gets.to_i
v = gets.split.map(&:to_i)
p = Hash.new(0)
q = Hash.new(0)
n.times do |i|
p[v[i]] += 1 if i.even?
q[v[i]] += 1 if i.odd?
end
ps = Hash[p.sort_by{|k, v| -v}].keys
qs = Hash[q.sort_by{|k, v| -v}].keys
x, y, ans = 0, 0, n / 2
f = false
ps.size.times do |i|
x = ps[i]
qs.size.times do |j|
if x != qs[j]
y = qs[j]
f = true
break
end
end
break if f
end
ans = n - p[x] - q[y] if f
x, y = 0, 0
f = false
qs.size.times do |i|
x = qs[i]
ps.size.times do |j|
if x != ps[j]
y = ps[j]
f = true
break
end
end
break if f
end
ans = n - q[x] - p[y] if f && ans > n - q[x] - p[y]
puts ans
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 1,033,268
| 1,033,269
|
u979552932
|
ruby
|
p03244
|
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)
ary1_hash = Hash.new(0)
0.step(n - 1, 2) do |i|
ary1_hash[ary[i]] += 1
end
ary1 = ary1_hash.sort_by(&:last).reverse
ary2_hash = Hash.new(0)
1.step(n - 1, 2) do |i|
ary2_hash[ary[i]] += 1
end
ary2 = ary2_hash.sort_by(&:last).reverse
ans = if ary1[0][0] != ary2[0][0]
ary1[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i +
ary2[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i
else
ary1_sec = ary1[1][1] rescue 0
ary2_sec = ary2[1][1] rescue 0
if ary1_sec >= ary2_sec
ary1[0..-1].inject(0){|sum, attr| sum + attr.last} - ary1_sec * 2 +
ary2[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i
else
ary1[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i +
ary2[0..-1].inject(0){|sum, attr| sum + attr.last} - ary2_sec * 2
end
end
puts ans
|
n = gets.chomp.to_i
ary = gets.chomp.split.map(&:to_i)
ary1_hash = Hash.new(0)
0.step(n - 1, 2) do |i|
ary1_hash[ary[i]] += 1
end
ary1 = ary1_hash.sort_by(&:last).reverse
ary2_hash = Hash.new(0)
1.step(n - 1, 2) do |i|
ary2_hash[ary[i]] += 1
end
ary2 = ary2_hash.sort_by(&:last).reverse
ans = if ary1[0][0] != ary2[0][0]
ary1[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i +
ary2[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i
else
ary1_sec = ary1[1][1] rescue 0
ary2_sec = ary2[1][1] rescue 0
if ary1_sec >= ary2_sec
ary1[0..-1].inject(0){|sum, attr| sum + attr.last} - ary1_sec +
ary2[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i
else
ary1[1..-1].inject(0){|sum, attr| sum + attr.last}.to_i +
ary2[0..-1].inject(0){|sum, attr| sum + attr.last} - ary2_sec
end
end
puts ans
|
[
"expression.operation.binary.remove"
] | 1,033,433
| 1,033,434
|
u792512290
|
ruby
|
p03244
|
n = gets.to_i
v = gets.split.map(&:to_i)
odd = Hash.new(0).tap {|x| x[0] = 0}
even = Hash.new(0).tap {|x| x[0] = 0}
v.each_with_index do |vi, i|
odd[vi] += 1 if i.odd?
even[vi] += 1 if i.even?
end
odd = odd.sort{|a, b| b[1] <=> a[1]}
even = even.sort{|a, b| b[1] <=> a[1]}
ans = 0
if odd[0][0] != even[0][0]
ans = n - odd[0][1] - even[0][1]
else
ans = n - [odd[0][1] + even[1][1], odd[1][1] + even[0][1]].min
end
puts ans
|
n = gets.to_i
v = gets.split.map(&:to_i)
odd = Hash.new(0).tap {|x| x[0] = 0}
even = Hash.new(0).tap {|x| x[0] = 0}
v.each_with_index do |vi, i|
odd[vi] += 1 if i.odd?
even[vi] += 1 if i.even?
end
odd = odd.sort{|a, b| b[1] <=> a[1]}
even = even.sort{|a, b| b[1] <=> a[1]}
ans = 0
if odd[0][0] != even[0][0]
ans = n - odd[0][1] - even[0][1]
else
ans = n - [odd[0][1] + even[1][1], odd[1][1] + even[0][1]].max
end
puts ans
|
[
"misc.opposites",
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 1,034,059
| 1,034,060
|
u457499130
|
ruby
|
p03244
|
n = gets.to_i
v_array = gets.chomp.split(" ").map(&:to_i)
v_sliced = v_array.each_slice(2)
v_odd = v_sliced.map(&:first)
v_even = v_sliced.map(&:last)
v_odd_g = v_odd.group_by { |e| e }.sort { |e| e[1].length }
v_even_g = v_even.group_by { |e| e }.sort { |e| e[1].length }
if v_odd_g[0][0] != v_even_g[0][0]
puts n - v_odd_g[0][1].length - v_even_g[0][1].length
else
r1 = v_odd_g[0][1].length + (v_even_g[1] ? v_even_g[1][1].length : 0)
r2 = (v_odd_g[1] ? v_odd_g[1][1].length : 0) + v_even_g[0][1].length
puts n - [r1, r2].max
end
|
n = gets.to_i
v_array = gets.chomp.split(" ").map(&:to_i)
v_sliced = v_array.each_slice(2)
v_odd = v_sliced.map(&:first)
v_even = v_sliced.map(&:last)
v_odd_g = v_odd.group_by { |e| e }.sort_by { |e| - e[1].length }
v_even_g = v_even.group_by { |e| e }.sort_by { |e| - e[1].length }
if v_odd_g[0][0] != v_even_g[0][0]
puts n - v_odd_g[0][1].length - v_even_g[0][1].length
else
r1 = v_odd_g[0][1].length + (v_even_g[1] ? v_even_g[1][1].length : 0)
r2 = (v_odd_g[1] ? v_odd_g[1][1].length : 0) + v_even_g[0][1].length
puts n - [r1, r2].max
end
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.unary.add"
] | 1,034,112
| 1,034,113
|
u058568575
|
ruby
|
p03244
|
def counts(nums)
nums.each_with_object(Hash.new(0)) { |i, h| h[i] += 1 }.sort_by { |num, count| [count, num] }
end
N = gets.to_i
evens, odds = gets.split(" ").map(&:to_i).partition.with_index { |n, i| i % 2 == 0 }
even_counts = counts(evens)
odd_counts = counts(odds)
even_num, even_no_op_count = even_counts[0]
odd_num, odd_no_op_count = odd_counts[0]
ans = if even_num == odd_num
candidates = [
even_counts.fetch(1, [0]).last + odd_no_op_count,
even_no_op_count + odd_counts.fetch(1, [0]).last
]
N - candidates.max
else
N - (even_no_op_count + odd_no_op_count)
end
puts ans
|
def counts(nums)
nums.each_with_object(Hash.new(0)) { |i, h| h[i] += 1 }.sort_by { |num, count| [count, num] }.reverse
end
N = gets.to_i
evens, odds = gets.split(" ").map(&:to_i).partition.with_index { |n, i| i % 2 == 0 }
even_counts = counts(evens)
odd_counts = counts(odds)
even_num, even_no_op_count = even_counts[0]
odd_num, odd_no_op_count = odd_counts[0]
ans = if even_num == odd_num
candidates = [
even_counts.fetch(1, [0]).last + odd_no_op_count,
even_no_op_count + odd_counts.fetch(1, [0]).last
]
N - candidates.max
else
N - (even_no_op_count + odd_no_op_count)
end
puts ans
|
[
"call.add"
] | 1,034,696
| 1,034,697
|
u638443497
|
ruby
|
p03244
|
#!/usr/bin/env ruby
n = STDIN.readline.strip.to_i
v = STDIN.readline.strip.split(' ').map(&:to_i)
o = {}
e = {}
for i in 0..(n/2-1) do
e[v[i*2]] = e[v[i*2]].nil? ? 1 : e[v[i*2]]+1
o[v[i*2+1]] = o[v[i*2+1]].nil? ? 1 : o[v[i*2+1]]+1
end
e_s = e.sort_by{|k, _v| _v}
o_s = o.sort_by{|k, _v| _v}
def find_max(a, b)
max_a = a[0][1]
max_b = 0
i = 0
while i < a.length and a[i][1] == max_a do
max_i_b = a[i][0] != b[0][0] ? b[0][1] : b.length == 1 ? 0 : b[1][1]
max_b = max_i_b if max_b < max_i_b
i += 1
end
max_a + max_b
end
max_e = find_max(e_s, o_s)
max_o = find_max(o_s, e_s)
m = [max_e, max_o].max
puts n - m
|
#!/usr/bin/env ruby
n = STDIN.readline.strip.to_i
v = STDIN.readline.strip.split(' ').map(&:to_i)
o = {}
e = {}
for i in 0..(n/2-1) do
e[v[i*2]] = e[v[i*2]].nil? ? 1 : e[v[i*2]]+1
o[v[i*2+1]] = o[v[i*2+1]].nil? ? 1 : o[v[i*2+1]]+1
end
e_s = e.sort_by{|k, _v| _v}.reverse
o_s = o.sort_by{|k, _v| _v}.reverse
def find_max(a, b)
max_a = a[0][1]
max_b = 0
i = 0
while i < a.length and a[i][1] == max_a do
max_i_b = a[i][0] != b[0][0] ? b[0][1] : b.length == 1 ? 0 : b[1][1]
max_b = max_i_b if max_b < max_i_b
i += 1
end
max_a + max_b
end
# puts "e_s: [0]: #{e_s[0]}, [1]: #{e_s[1]}"
# puts "o_s: [0]: #{o_s[0]}, [1]: #{o_s[1]}"
max_e = find_max(e_s, o_s)
max_o = find_max(o_s, e_s)
m = [max_e, max_o].max
# puts "max_e:#{max_e}, max_o:#{max_o}, m: #{m}"
puts n - m
|
[
"call.add"
] | 1,034,912
| 1,034,913
|
u681517464
|
ruby
|
p03244
|
N = gets.to_i
Vs = gets.split.map(&:to_i)
as, bs = Hash.new(0), Hash.new(0)
Vs.each_slice(2) do |a, b|
as[a] += 1
bs[b] += 1
end
a1, a2 = as.sort_by(&:last).take(2).map(&:first)
b1, b2 = bs.sort_by(&:last).take(2).map(&:first)
puts a1 != b1 ? N - as[a1] - bs[b1] : [N - as[a1] - bs[b2], N - as[a2] - bs[b1]].min
|
N = gets.to_i
Vs = gets.split.map(&:to_i)
as, bs = Hash.new(0), Hash.new(0)
Vs.each_slice(2) do |a, b|
as[a] += 1
bs[b] += 1
end
a1, a2 = as.sort_by(&:last).reverse.take(2).map(&:first)
b1, b2 = bs.sort_by(&:last).reverse.take(2).map(&:first)
puts a1 != b1 ? N - as[a1] - bs[b1] : [N - as[a1] - bs[b2], N - as[a2] - bs[b1]].min
|
[
"call.add"
] | 1,034,916
| 1,034,917
|
u304198114
|
ruby
|
p03244
|
n=gets.to_i
v=gets.chomp.split.map(&:to_i)
v1=[]
v2=[]
h1 = Hash.new(0)
h2 = Hash.new(0)
v.each_with_index do |w, i|
if i%2==0
v1 << w
h1[w] += 1
else
v2 << w
h2[w] += 1
end
end
hh1 = h1.to_a.sort {|a,b| a[1] <=> b[1]}.reverse
hh2 = h2.to_a.sort {|a,b| a[1] <=> b[1]}.reverse
#p hh1
#p hh2
# 最頻値の数が同じ
if hh1[0][1] == hh2[0][1]
# 最頻値の値も同じ
if hh1[0][0] == hh2[0][0]
if hh1[0][0] == n/2
puts n/2
else
puts n - hh1[0][1] - [hh1[1][1], hh2[1][1]].max
end
else
if hh1[0][0] == n/2
puts 0
else
puts n - 2 * hh1[0][1]
end
end
else
puts n - hh1[0][1] - hh2[0][1]
end
|
n=gets.to_i
v=gets.chomp.split.map(&:to_i)
v1=[]
v2=[]
h1 = Hash.new(0)
h2 = Hash.new(0)
v.each_with_index do |w, i|
if i%2==0
v1 << w
h1[w] += 1
else
v2 << w
h2[w] += 1
end
end
hh1 = h1.to_a.sort {|a,b| a[1] <=> b[1]}.reverse
hh2 = h2.to_a.sort {|a,b| a[1] <=> b[1]}.reverse
#p hh1
#p hh2
# 最頻値の数が同じ
if hh1[0][1] == hh2[0][1]
# 最頻値の値も同じ
if hh1[0][0] == hh2[0][0]
if hh1[0][1] == n/2
puts n/2
else
puts n - hh1[0][1] - [hh1[1][1], hh2[1][1]].max
end
else
if hh1[0][1] == n/2
puts 0
else
puts n - 2 * hh1[0][1]
end
end
else
puts n - hh1[0][1] - hh2[0][1]
end
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 1,034,945
| 1,034,946
|
u868089307
|
ruby
|
p03246
|
N = gets.strip.to_i
s = gets.strip.split.map(&:to_i)
hs = Array.new(2) { Hash.new(0) }
hs[0][0] = 0
hs[1][0] = 0
s.each_with_index { |n, i| hs[i%2][n] += 1 }
# e = hs[0].to_a.sort_by { |a| -a[1] }
# o = hs[1].to_a.sort_by { |a| -a[1] }
# if e[0][1] != o[0][1]
# n = e[0][1] + o[0][1]
# else
# n = [e[0][1] + o[1][1], e[1][1] + o[0][1]].max
# end
# puts N - n
a1 = hs[0].to_a.sort_by{|a| -a[1]}
a2 = hhs[1].to_a.sort_by{|a| -a[1]}
if a1[0][0] != a2[0][0]
num = a1[0][1] + a2[0][1]
else
num = [a1[0][1] + a2[1][1], a1[1][1] + a2[0][1]].max
end
puts N - num
|
N = gets.strip.to_i
s = gets.strip.split.map(&:to_i)
hs = Array.new(2) { Hash.new(0) }
hs[0][0] = 0
hs[1][0] = 0
s.each_with_index { |n, i| hs[i%2][n] += 1 }
# e = hs[0].to_a.sort_by { |a| -a[1] }
# o = hs[1].to_a.sort_by { |a| -a[1] }
# if e[0][1] != o[0][1]
# n = e[0][1] + o[0][1]
# else
# n = [e[0][1] + o[1][1], e[1][1] + o[0][1]].max
# end
# puts N - n
a1 = hs[0].to_a.sort_by{|a| -a[1]}
a2 = hs[1].to_a.sort_by{|a| -a[1]}
if a1[0][0] != a2[0][0]
num = a1[0][1] + a2[0][1]
else
num = [a1[0][1] + a2[1][1], a1[1][1] + a2[0][1]].max
end
puts N - num
|
[
"assignment.value.change",
"identifier.change"
] | 1,035,504
| 1,035,505
|
u707614029
|
ruby
|
p03246
|
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
odd = v.select.with_index{|v, i| i.odd?}
even = v.select.with_index{|v, i| i.even?}
odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
if odd2[0]!=even2[0]
#最頻値が異なるなら素直に出力
p n/2-odd2[0][1].size + n/2-even2[0][1].size
else
#最頻値が同じなら二番目に多いやつに切り替え
ans1, ans2 = n/2, n/2
ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size if odd2[1]
ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size if even[1]
p [ans1,ans2].min
end
|
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
odd = v.select.with_index{|v, i| i.odd?}
even = v.select.with_index{|v, i| i.even?}
odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
if odd2[0]!=even2[0]
#最頻値が異なるなら素直に出力
p n/2-odd2[0][1].size + n/2-even2[0][1].size
else
#最頻値が同じなら二番目に多いやつに切り替え
ans1, ans2 = n/2, n/2
ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size if odd2[1]
ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size if even2[1]
p [ans1,ans2].min
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,035,584
| 1,035,585
|
u358554431
|
ruby
|
p03246
|
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
even = v.select.with_index{|v, i| i.even?}
odd = v.select.with_index{|v, i| i.odd?}
odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
#最頻値が異なるなら素直に出力
if odd2[0]!=even2[0]
n/2-odd2[0][1].size + n/2-even2[0][1].size
else
#最頻値が同じなら二番目に多いやつに切り替え
ans1, ans2 = n/2, n/2
if odd2[1]
ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size
end
if even2[1]
ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size
end
puts [ans1,ans2].min
end
|
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
even = v.select.with_index{|v, i| i.even?}
odd = v.select.with_index{|v, i| i.odd?}
odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
#最頻値が異なるなら素直に出力
if odd2[0]!=even2[0]
p n/2-odd2[0][1].size + n/2-even2[0][1].size
else
#最頻値が同じなら二番目に多いやつに切り替え
ans1, ans2 = n/2, n/2
if odd2[1]
ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size
end
if even2[1]
ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size
end
puts [ans1,ans2].min
end
|
[
"io.output.change",
"call.add"
] | 1,035,586
| 1,035,587
|
u358554431
|
ruby
|
p03246
|
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
even = v.select.with_index{|v, i| i.even?}
odd = v.select.with_index{|v, i| i.odd?}
odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
#最頻値が異なるなら素直に出力
if odd2[0]!=even2[0]
p n/2-odd2[0][1].size + n/2-even2[0][1].size
p "hoge"
else
#最頻値が同じなら二番目に多いやつに切り替え
ans1, ans2 = n/2, n/2
if odd2[1]
ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size
end
if even2[1]
ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size
end
puts [ans1,ans2].min
end
|
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split
even = v.select.with_index{|v, i| i.even?}
odd = v.select.with_index{|v, i| i.odd?}
odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
#最頻値が異なるなら素直に出力
if odd2[0]!=even2[0]
p n/2-odd2[0][1].size + n/2-even2[0][1].size
else
#最頻値が同じなら二番目に多いやつに切り替え
ans1, ans2 = n/2, n/2
if odd2[1]
ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size
end
if even2[1]
ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size
end
puts [ans1,ans2].min
end
|
[
"call.remove"
] | 1,035,588
| 1,035,587
|
u358554431
|
ruby
|
p03246
|
N,_=gets.chomp.split(' ').map{|n| n.to_i}
icnt = 0
hevn = {}
hodd = {}
gets.chomp.split(' ').map{|n| n.to_i}.each{|i|
case icnt%2
when 0
hevn[i].nil? ? hevn[i] = 1 : hevn[i]+=1
when 1
hodd[i].nil? ? hodd[i] = 1 : hodd[i]+=1
end
icnt+=1
}
evnsorted = hevn.sort{|a,b| b[1] <=> a[1]}
oddsorted = hodd.sort{|a,b| b[1] <=> a[1]}
# p evnsorted
# p oddsorted
evnmax = evnsorted[0]
oddmax = oddsorted[0]
evnmaxnum = evnmax[1]
oddmaxnum = evnmax[1]
evnmax2num = evnsorted[1].nil? ? evnsorted[1][1] : 0
oddmax2num = oddsorted[1].nil? ? oddsorted[1][1] : 0
if(evnmax[0] == oddmax[0])
case evnmax2num <=> oddmax2num
when -1
evnmaxnum = evnmax2num
when 1,0
oddmaxnum = oddmax2num
end
end
puts "#{N-evnmaxnum-oddmaxnum}"
|
N,_=gets.chomp.split(' ').map{|n| n.to_i}
icnt = 0
hevn = {}
hodd = {}
gets.chomp.split(' ').map{|n| n.to_i}.each{|i|
case icnt%2
when 0
hevn[i].nil? ? hevn[i] = 1 : hevn[i]+=1
when 1
hodd[i].nil? ? hodd[i] = 1 : hodd[i]+=1
end
icnt+=1
}
evnsorted = hevn.sort{|a,b| b[1] <=> a[1]}
oddsorted = hodd.sort{|a,b| b[1] <=> a[1]}
# p evnsorted
# p oddsorted
evnmax = evnsorted[0]
oddmax = oddsorted[0]
evnmaxnum = evnmax[1]
oddmaxnum = oddmax[1]
evnmax2num = !evnsorted[1].nil? ? evnsorted[1][1] : 0
oddmax2num = !oddsorted[1].nil? ? oddsorted[1][1] : 0
if(evnmax[0] == oddmax[0])
case evnmax2num <=> oddmax2num
when 1
evnmaxnum = evnmax2num
when -1,0
oddmaxnum = oddmax2num
end
end
puts "#{N-evnmaxnum-oddmaxnum}"
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.unary.add",
"control_flow.branch.if.condition.change",
"expression.operation.unary.arithmetic.remove"
] | 1,035,794
| 1,035,795
|
u415591191
|
ruby
|
p03246
|
n = gets.to_i
a = gets.split.map(&:to_i)
b = Hash.new(0)
c = Hash.new(0)
n.times{|i|
b[a[i]]+=1 if i%2==0
c[a[i]]+=1 if i%2==1
}
if a.uniq.size == 1
p n/2
else
b = b.sort{|a,b|a[1]<=>b[1]}
c = c.sort{|a,b|a[1]<=>b[1]}
p b
p c
if b[-1][0] == c[-1][0]
ans1 = n/2 - c[-2][1].to_i + n/2 - b[-1][1].to_i
ans2 = n/2 - b[-2][1].to_i + n/2 - c[-1][1].to_i
p [ans1, ans2].min
else
p (n/2 - b[-1][1]) + (n/2 - c[-1][1])
end
end
|
n = gets.to_i
a = gets.split.map(&:to_i)
b = Hash.new(0)
c = Hash.new(0)
n.times{|i|
b[a[i]]+=1 if i%2==0
c[a[i]]+=1 if i%2==1
}
if a.uniq.size == 1
p n/2
else
b = b.sort{|a,b|a[1]<=>b[1]}
c = c.sort{|a,b|a[1]<=>b[1]}
if b[-1][0] == c[-1][0]
ans1 = n/2 - c[-2][1].to_i + n/2 - b[-1][1].to_i
ans2 = n/2 - b[-2][1].to_i + n/2 - c[-1][1].to_i
p [ans1, ans2].min
else
p (n/2 - b[-1][1]) + (n/2 - c[-1][1])
end
end
|
[
"call.remove"
] | 1,035,818
| 1,035,819
|
u397763977
|
ruby
|
p03244
|
n=gets.chomp.to_i
v=gets.chomp.split(" ").map { |e| e.to_i }
even = []
odd = []
for i in 0..n-1 do
if i%2 == 0
even[i/2] = v[i]
else
odd[i/2] = v[i]
end
end
even = even.sort
odd = odd.sort
half = n/2
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd && string_even != odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd && string_even != odd[half-1]
max_odd = dp_odd
end
max_1 = max_even+max_odd
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd
string_odd = odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd
max_odd = dp_odd
string_odd = odd[half-1]
end
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even && string_odd != even[indx_even]
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even] && string_odd != even[half-1]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
max2 = max_even + max_odd
max = max2 > max1 ? max2 : max1
puts 2*half - max
|
n=gets.chomp.to_i
v=gets.chomp.split(" ").map { |e| e.to_i }
even = []
odd = []
for i in 0..n-1 do
if i%2 == 0
even[i/2] = v[i]
else
odd[i/2] = v[i]
end
end
even = even.sort
odd = odd.sort
half = n/2
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd && string_even != odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd && string_even != odd[half-1]
max_odd = dp_odd
end
max_1 = max_even+max_odd
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd
string_odd = odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd
max_odd = dp_odd
string_odd = odd[half-1]
end
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even && string_odd != even[indx_even]
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even] && string_odd != even[half-1]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
max2 = max_even + max_odd
max = max2 > max_1 ? max2 : max_1
puts 2*half - max
|
[
"assignment.value.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 1,036,148
| 1,036,149
|
u267552846
|
ruby
|
p03244
|
n=gets.chomp.to_i
v=gets.chomp.split(" ").map { |e| e.to_i }
even = []
odd = []
for i in 0..n-1 do
if i%2 == 0
even[i/2] = v[i]
else
odd[i/2] = v[i]
end
end
even = even.sort
odd = odd.sort
half = n/2
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd && string_even != odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd && string_even != odd[half-1]
max_odd = dp_odd
end
max_1 = max_even+max_odd
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd
string_odd = odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd
max_odd = dp_odd
string_odd = odd[half-1]
end
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even && string_odd != even[indx_even]
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even] && string_odd != even[half-1]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
max2 = maxeven + max_odd
max = max2 > max1 ? max2 : max1
puts 2*half - max
|
n=gets.chomp.to_i
v=gets.chomp.split(" ").map { |e| e.to_i }
even = []
odd = []
for i in 0..n-1 do
if i%2 == 0
even[i/2] = v[i]
else
odd[i/2] = v[i]
end
end
even = even.sort
odd = odd.sort
half = n/2
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd && string_even != odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd && string_even != odd[half-1]
max_odd = dp_odd
end
max_1 = max_even+max_odd
dp_even=0
dp_odd=0
max_even = 0
max_odd = 0
indx_even = 0
indx_odd = 0
string_even = even[0]
string_odd = odd[0]
for i in 0..half-1 do
if odd[i] != odd[indx_odd]
if dp_odd > max_odd
string_odd = odd[indx_odd]
max_odd = dp_odd
end
indx_odd = i
dp_odd = 0
end
if odd[i] == odd[indx_odd]
dp_odd += 1
end
end
if dp_odd > max_odd
max_odd = dp_odd
string_odd = odd[half-1]
end
for i in 0..half-1 do
if even[i] != even[indx_even]
if dp_even > max_even && string_odd != even[indx_even]
string_even = even[indx_even]
max_even = dp_even
end
indx_even = i
dp_even = 0
end
if even[i] == even[indx_even] && string_odd != even[half-1]
dp_even += 1
end
end
if dp_even > max_even
string_even = even[half-1]
max_even = dp_even
end
max2 = max_even + max_odd
max = max2 > max_1 ? max2 : max_1
puts 2*half - max
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change"
] | 1,036,150
| 1,036,149
|
u267552846
|
ruby
|
p03248
|
s=gets.chomp
if s !~ /^1.*0$/ || s[0..-2] != s[0..-2].reverse
p -1
end
puts "1 2"
ptr = 2
(1...s.size-1).each{|i|
puts "#{ptr} #{i+2}"
if s[i]==?1
ptr = i+2
end
}
|
s=gets.chomp
if s !~ /^1.*0$/ || s[0..-2] != s[0..-2].reverse
p -1
exit
end
puts "1 2"
ptr = 2
(1...s.size-1).each{|i|
puts "#{ptr} #{i+2}"
if s[i]==?1
ptr = i+2
end
}
|
[
"control_flow.exit.add"
] | 1,036,319
| 1,036,320
|
u019489252
|
ruby
|
p03248
|
s=gets.chomp
if s !~ /^1.*0$/ || s[0..-2] != s[0..-2].reverse
p -1
end
puts "1 2"
ptr = 2
(1...s.size/2).each{|i|
puts "#{ptr} #{i+2}"
if s[i]==?1
ptr = i+2
end
}
(s.size/2...s.size-1).each{|i|
puts "#{ptr} #{i+2}"
}
|
s=gets.chomp
if s !~ /^1.*0$/ || s[0..-2] != s[0..-2].reverse
p -1
exit
end
puts "1 2"
ptr = 2
(1...s.size/2).each{|i|
puts "#{ptr} #{i+2}"
if s[i]==?1
ptr = i+2
end
}
(s.size/2...s.size-1).each{|i|
puts "#{ptr} #{i+2}"
}
|
[
"control_flow.exit.add"
] | 1,036,321
| 1,036,322
|
u019489252
|
ruby
|
p03248
|
s = gets.chomp
def muri
p -1
exit
end
if s[0]==?0 || s[-1]==?1
muri
end
s = s[0..-2]
if !(s.size.times.map{|i| s[i]==s[-i-1]}.all?)
muri
end
pre = 1
1.upto(s.size-1){|i|
puts [pre,i+1]*" "
pre = i+1 if s[i-1]==?1
}
|
s = gets.chomp
def muri
p -1
exit
end
if s[0]==?0 || s[-1]==?1
muri
end
s = s[0..-2]
if !(s.size.times.map{|i| s[i]==s[-i-1]}.all?)
muri
end
pre = 1
1.upto(s.size){|i|
puts [pre,i+1]*" "
pre = i+1 if s[i-1]==?1
}
|
[
"expression.operation.binary.remove"
] | 1,036,335
| 1,036,336
|
u397763977
|
ruby
|
p03250
|
array = gets.chomp.split("").map(&:to_i).sort!
puts array.last * 10 + array[0] + array[1]
|
array = gets.chomp.split(" ").map(&:to_i).sort!
puts array.last * 10 + array[0] + array[1]
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 1,036,797
| 1,036,798
|
u333374716
|
ruby
|
p03250
|
ary = gets.split.map(&:to_i)
puts ary.inject(:+) - ary.min
|
ary = gets.split.map(&:to_i)
puts ary.inject(:+) + ary.max * 9
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"identifier.change",
"io.output.change"
] | 1,037,171
| 1,037,172
|
u622469330
|
ruby
|
p03250
|
arr = gets.chomp.split.map(&:to_i)
arr.sort!
puts arr[0]*10 + arr[1] + arr[2]
|
arr = gets.chomp.split.map(&:to_i)
arr.sort!.reverse!
puts arr[0]*10 + arr[1] + arr[2]
|
[
"call.add"
] | 1,037,343
| 1,037,344
|
u616320334
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.