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 |
|---|---|---|---|---|---|---|---|
p03210
|
n = get.to_i
if [7, 5, 3].include?(n)
puts 'YES'
else
puts 'NO'
end
|
n = gets.to_i
if [7, 5, 3].include?(n)
puts 'YES'
else
puts 'NO'
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,004,701
| 1,004,702
|
u084335038
|
ruby
|
p03210
|
x = gets.strip.to_i
puts [7, 5, 3].include?(x) ? 'Yes' : 'No'
|
x = gets.strip.to_i
puts [7, 5, 3].include?(x) ? 'YES' : 'NO'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,723
| 1,004,724
|
u707614029
|
ruby
|
p03210
|
a = gets.strip.split.to_i
if a==7 || a==5 || a==3
puts "YES"
else
puts "NO"
end
|
a = gets.strip.to_i
if a==7 || a==5 || a==3
puts "YES"
else
puts "NO"
end
|
[
"call.remove"
] | 1,004,730
| 1,004,731
|
u061071198
|
ruby
|
p03210
|
a = gets.strip.split.map(&:to_i)
if a==7 || a==5 || a==3
puts "YES"
else
puts "NO"
end
|
a = gets.strip.to_i
if a==7 || a==5 || a==3
puts "YES"
else
puts "NO"
end
|
[
"assignment.value.change",
"identifier.change",
"call.remove"
] | 1,004,732
| 1,004,731
|
u061071198
|
ruby
|
p03210
|
a = gets.to_i
arr = [3,5,7]
puts arr.include?(a) ? "Yes" : "No"
|
a = gets.to_i
arr = [3,5,7]
puts arr.include?(a) ? "YES" : "NO"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,793
| 1,004,794
|
u422581886
|
ruby
|
p03210
|
puts ("357".index(gets)?"YES":"NO")
|
puts ("357".include?(gets.chomp)?"YES":"NO")
|
[
"identifier.change",
"control_flow.branch.if.condition.change",
"call.add"
] | 1,004,795
| 1,004,796
|
u168443921
|
ruby
|
p03210
|
X = gets.to_i
puts X == 7 || X == 5 || X == 3 ? 'Yes' : 'No'
|
X = gets.to_i
puts X == 7 || X == 5 || X == 3 ? 'YES' : 'NO'
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 1,004,814
| 1,004,815
|
u638516820
|
ruby
|
p03210
|
x=gets.to_i
puts 200[x]==1?"YES":"NO"
|
x=gets.to_i
puts 168[x]==1?"YES":"NO"
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 1,004,866
| 1,004,867
|
u459746049
|
ruby
|
p03210
|
x = gets.to_i
if x == 7 or 5 or 3
puts "YES"
else
puts "NO"
end
|
x = gets.to_i
if x == 7 or x == 5 or x == 3
puts "YES"
else
puts "NO"
end
|
[
"control_flow.branch.if.condition.change"
] | 1,004,951
| 1,004,952
|
u105001881
|
ruby
|
p03210
|
x = gets.to_i
if x == 7 or 5 or 3
puts "YES"
else
puts "NO"
end
|
x = gets.to_i
if x == 7 or x == 5 or x == 3
puts "YES"
else
puts "NO"
end
|
[
"control_flow.branch.if.condition.change"
] | 1,004,953
| 1,004,952
|
u105001881
|
ruby
|
p03210
|
year = gets.to_i
if year == 3 || year = 5 || year == 7
print("YES\n")
else
print("NO\n")
end
|
year = gets.to_i
if year == 3 || year == 5 || year == 7
print("YES\n")
else
print("NO\n")
end
|
[
"expression.operation.compare.replace.add",
"assignment.replace.remove",
"misc.typo"
] | 1,005,020
| 1,005,021
|
u452808393
|
ruby
|
p03210
|
x = gets
if x == 7 || x == 5 || x == 3
puts "YES"
else
puts "NO"
end
|
x = gets.to_i
if x == 7 || x == 5 || x == 3
puts "YES"
else
puts "NO"
end
|
[
"call.add"
] | 1,005,098
| 1,005,099
|
u873139556
|
ruby
|
p03210
|
N = gets.to_i
if (N == 3 || N == 5|| N == 7) then print "YES" end
|
N = gets.to_i
if (N == 3 || N == 5|| N == 7) then print "YES"
else print "NO" end
|
[] | 1,005,179
| 1,005,180
|
u617655036
|
ruby
|
p03211
|
B = gets.split('').map(&:to_i)
min = 1000
B.each_cons(3) do |i|
d = (753 - i.join('').to_i).abs
min = d if d < min
end
puts min
|
B = gets.chomp.split('').map(&:to_i)
min = 1000
B.each_cons(3) do |i|
d = (753 - i.join('').to_i).abs
min = d if d < min
end
puts min
|
[
"call.add"
] | 1,005,579
| 1,005,580
|
u039293076
|
ruby
|
p03211
|
s = gets.split('').map(&:to_i)
num = s[0,3]
n = s.size
i = 3
min = (753 - num.join('').to_i).abs
while i < n
num.shift
num << s[i]
min = (num.join('').to_i - 753).abs if min >= (num.join('').to_i - 753).abs
i += 1
end
puts min
|
s = gets.chomp.split('').map(&:to_i)
num = s[0,3]
n = s.size
i = 3
min = (753 - num.join('').to_i).abs
while i < n
num.shift
num << s[i]
min = (num.join('').to_i - 753).abs if min >= (num.join('').to_i - 753).abs
i += 1
end
puts min
|
[
"call.add"
] | 1,005,649
| 1,005,650
|
u437368899
|
ruby
|
p03210
|
a=gets.to_i
puts (a==7||a==5||a==3)?:Yes : :No
|
a=gets.to_i
puts (a==7||a==5||a==3)?:YES : :NO
|
[
"call.arguments.change"
] | 1,006,040
| 1,006,041
|
u752146271
|
ruby
|
p03211
|
s = gets.chomp
ans = 999
(s.length - 3).times do |i|
x = s[i, 3].to_i
diff = (x - 753).abs
ans = diff if diff <= ans
end
puts ans
|
s = gets.chomp
ans = 999
(s.length - 2).times do |i|
x = s[i, 3].to_i
diff = (x - 753).abs
ans = diff if diff <= ans
end
puts ans
|
[
"literal.number.integer.change",
"expression.operation.binary.change"
] | 1,006,102
| 1,006,103
|
u889326464
|
ruby
|
p03211
|
puts gets.chomp.chars.each_cons(3).min_by{|t| (t.join.to_i-753).abs}
|
puts gets.chomp.chars.each_cons(3).map{|t| (t.join.to_i-753).abs}.min
|
[
"identifier.change",
"call.arguments.change",
"io.output.change",
"call.add"
] | 1,006,146
| 1,006,147
|
u056944756
|
ruby
|
p03211
|
ary = gets.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem = "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (753 - tem.to_i).abs
if ans > temabs
ans = temabs
end
end
p ans
|
ary = gets.chomp.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
p ans
|
[
"call.add",
"expression.operation.binary.remove"
] | 1,006,159
| 1,006,160
|
u599631096
|
ruby
|
p03211
|
ary = gets.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
p ans
|
ary = gets.chomp.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
p ans
|
[
"call.add"
] | 1,006,161
| 1,006,160
|
u599631096
|
ruby
|
p03211
|
ary = gets.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
p tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
p ans
|
ary = gets.chomp.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
p ans
|
[
"call.add",
"io.output.change",
"call.remove"
] | 1,006,162
| 1,006,160
|
u599631096
|
ruby
|
p03211
|
ary = gets.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
puts ans
|
ary = gets.chomp.split("").map(&:to_i)
ans = 10000
(0..(ary.length-3)).each do |n|
tem= "#{ary[n]}#{ary[n+1]}#{ary[n+2]}"
temabs = (tem.to_i - 753).abs
if ans > temabs
ans = temabs
end
end
p ans
|
[
"call.add",
"identifier.change"
] | 1,006,163
| 1,006,160
|
u599631096
|
ruby
|
p03211
|
a=gets.chomp
m=(753-a[0..2].to_i).abs
for i in 3..(a.length-3)
m=(753-a[i..i+2].to_i).abs if m>(753-a[i..i+2].to_i).abs
end
puts m
|
a=gets.chomp
m=(753-a[0..2].to_i).abs
for i in 1..(a.length-3)
m=(753-a[i..i+2].to_i).abs if m>(753-a[i..i+2].to_i).abs
end
puts m
|
[
"literal.number.integer.change"
] | 1,006,271
| 1,006,272
|
u585819925
|
ruby
|
p03211
|
require 'pp'
s = gets.chars.map(&:to_i)
ans = nil
s.each_cons(3) do |arr|
n = arr.join.to_i
ans = (n-753).abs if ans.nil? || ans > (n - 753).abs
end
p ans
|
require 'pp'
s = gets.chomp.chars.map(&:to_i)
ans = nil
s.each_cons(3) do |arr|
n = arr.join.to_i
ans = (n-753).abs if ans.nil? || ans > (n - 753).abs
end
p ans
|
[
"call.add"
] | 1,006,340
| 1,006,341
|
u315597999
|
ruby
|
p03211
|
s = gets.chomp.split("").map(&:to_i)
length = s.length
sum = []
(0..length-3).each do |number|
sum.push(s.slice(number,3).join.to_i)
end
answer = (sum.first - 753).abs
p sum
sum.each do |min|
answer = (min - 753).abs if answer >= (min - 753).abs
end
puts answer
|
s = gets.chomp.split("").map(&:to_i)
length = s.length
sum = []
(0..length-3).each do |number|
sum.push(s.slice(number,3).join.to_i)
end
answer = (sum.first - 753).abs
sum.each do |min|
answer = (min - 753).abs if answer >= (min - 753).abs
end
puts answer
|
[
"call.remove"
] | 1,006,349
| 1,006,350
|
u333374716
|
ruby
|
p03211
|
S = gets().to_s
T = Array.new(S.length - 2)
U = Array.new(S.length - 2)
for i in 0 .. S.length - 4
T[i] = (S[i].to_i) * 100 + (S[i + 1].to_i) * 10 + (S[i + 2].to_i)
end
for i in 0 .. S.length - 4
U[i] = 753 - T[i]
if U[i] < 0
U[i] = -U[i]
end
end
p(U.min)
|
S = gets().to_s
T = Array.new(S.length - 3)
U = Array.new(S.length - 3)
for i in 0 .. S.length - 4
T[i] = (S[i].to_i) * 100 + (S[i + 1].to_i) * 10 + (S[i + 2].to_i)
end
for i in 0 .. S.length - 4
U[i] = 753 - T[i]
if U[i] < 0
U[i] = -U[i]
end
end
p(U.min)
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,006,780
| 1,006,781
|
u313403396
|
ruby
|
p03211
|
S = gets().to_s
T = Array.new(S.length - 2)
U = Array.new(S.length - 2)
for i in 0 .. S.length - 4
T[i] = (S[i].to_i) * 100 + (S[i + 1].to_i) * 10 + (S[i + 2].to_i)
end
for i in 0 .. S.length - 3
U[i] = 753 - T[i]
if U[i] < 0
U[i] = -U[i]
end
end
p(U.min)
|
S = gets().to_s
T = Array.new(S.length - 3)
U = Array.new(S.length - 3)
for i in 0 .. S.length - 4
T[i] = (S[i].to_i) * 100 + (S[i + 1].to_i) * 10 + (S[i + 2].to_i)
end
for i in 0 .. S.length - 4
U[i] = 753 - T[i]
if U[i] < 0
U[i] = -U[i]
end
end
p(U.min)
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,006,782
| 1,006,781
|
u313403396
|
ruby
|
p03211
|
S = gets().to_s
T = Array.new(S.length - 2)
U = Array.new(S.length - 2)
for i in 0 .. S.length - 3
T[i] = (S[i].to_i) * 100 + (S[i + 1].to_i) * 10 + (S[i + 2].to_i)
end
for i in 0 .. S.length - 3
U[i] = 753 - T[i]
if U[i] < 0
U[i] = -U[i]
end
end
p(U.min)
|
S = gets().to_s
T = Array.new(S.length - 3)
U = Array.new(S.length - 3)
for i in 0 .. S.length - 4
T[i] = (S[i].to_i) * 100 + (S[i + 1].to_i) * 10 + (S[i + 2].to_i)
end
for i in 0 .. S.length - 4
U[i] = 753 - T[i]
if U[i] < 0
U[i] = -U[i]
end
end
p(U.min)
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,006,783
| 1,006,781
|
u313403396
|
ruby
|
p03211
|
S = gets.chomp
min = 0
for i in 0..S.size-3 do
num = S[i..i+2].to_i
abs = (753-num).abs
min = abs < min ? abs : min
end
p min
|
S = gets.chomp
min = 753
for i in 0..S.size-3 do
num = S[i..i+2].to_i
abs = (753-num).abs
min = abs < min ? abs : min
end
p min
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 1,006,891
| 1,006,892
|
u460049292
|
ruby
|
p03211
|
s = gets.chomp
ans = 10000
(s.size - 2).times do |i|
ans = [ans, (753 - s[i..i+2].to_i).abs].min
puts ans
end
puts ans
|
s = gets.chomp
ans = 10000
(s.size - 2).times do |i|
ans = [ans, (753 - s[i..i+2].to_i).abs].min
end
puts ans
|
[
"call.remove"
] | 1,007,155
| 1,007,156
|
u124214522
|
ruby
|
p03212
|
n = gets.to_i
count = 0
(3..n.size).each do |i|
sets = ['7', '5', '3'].repeated_permutation(i).to_a
sets.each do |set|
if set.include?('7') && set.include?('5') && set.include?('3') && set.join.to_i <= n
count += 1
end
end
end
puts count
|
n = gets.to_i
count = 0
(3..n.to_s.size).each do |i|
sets = ['7', '5', '3'].repeated_permutation(i).to_a
sets.each do |set|
if set.include?('7') && set.include?('5') && set.include?('3') && set.join.to_i <= n
count += 1
end
end
end
puts count
|
[
"call.add"
] | 1,007,514
| 1,007,515
|
u866325115
|
ruby
|
p03211
|
#n, m = gets.chomp.split.map(&:to_i)
#ary = []; n.times { cakes << gets.chomp.split.map(&:to_i).to_a }
#def cb(i); i==1 ? 1 : -1;end
n = gets.chomp.to_i.to_s
min = 1000
0.step(l-3,1) {|i|
min = (753 - n[i,3].to_i).abs < min ? (753 - n[i,3].to_i).abs : min
}
p min
|
#n, m = gets.chomp.split.map(&:to_i)
#ary = []; n.times { cakes << gets.chomp.split.map(&:to_i).to_a }
#def cb(i); i==1 ? 1 : -1;end
n = gets.chomp.to_i.to_s
l = n.length
min = 1000
0.step(l-3,1) {|i|
min = (753 - n[i,3].to_i).abs < min ? (753 - n[i,3].to_i).abs : min
}
p min
|
[
"assignment.add"
] | 1,007,569
| 1,007,570
|
u987208743
|
ruby
|
p03212
|
n = gets.chomp
s = n.size
count = 0
st = 3
while true
if n.to_i >= 357
["3","5","7"].repeated_permutation (st) do |i|
if i.count("7") >= 1 && i.count("5") >= 1&& i.count("3") >= 1
ii = i.join("").to_i
if ii <= n.to_i
count += 1
end
end
end
else
count = 0
break
end
if st == s
break
end
st += 1
end
puts coun
|
n = gets.chomp
s = n.size
count = 0
st = 3
while true
if n.to_i >= 357
["3","5","7"].repeated_permutation (st) do |i|
if i.count("7") >= 1 && i.count("5") >= 1&& i.count("3") >= 1
ii = i.join("").to_i
if ii <= n.to_i
count += 1
end
end
end
else
count = 0
break
end
if st == s
break
end
st += 1
end
puts count
|
[
"identifier.change",
"call.arguments.change"
] | 1,007,731
| 1,007,732
|
u412789323
|
ruby
|
p03212
|
class Integer
@mod = nil
def self.set_mod(mod = 10**9 + 7)
@mod = mod
end
def combination(k = self) # 4C2 = 6
return 1 if k.zero?
if @mod.nil?
(self - k + 1..self).inject(:*) / k.factorial
else
(self - k + 1..self).inject{|i,m|i * m % @mod} * k.factorial.modinv % @mod
end
end
def permutation(k = self) # 4P2 = 12
return 1 if k.zero?
if @mod.nil?
(self - k + 1..self).inject(:*)
else
(self - k + 1..self).inject{|i,m|i * m % @mod}
end
end
def factorial(step = 1) # 4! = 24
return 1 if self.zero?
if @mod.nil?
(1..self).inject(:*)
else
(1..self).inject{|i,m|i * m % @mod}
end
end
def modinv # https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
a = self; b = @mod; u = 1; v = 0
while b > 0
t = a / b
a -= t * b
a, b = b, a
u -= t * v
u, v = v, u
end
u %= m
u += m if u < 0
u
end
# 繰り返し二乗法
def repeat_squaring(p, mod = (10**9 + 7))
return 1 if p == 0
if p % 2 == 0
t = repeat_squaring(p/2, mod)
return t*t % mod
end
self * repeat_squaring(p - 1, mod) % mod
end
alias :C :combination
alias :P :permutation
alias :! :factorial
end
require 'pp'
# 4 13 26484
n = gets.to_i
cnt = 0
sum = 0
M = 10
rs = []
cnts = (1..M).map do |m|
[3,5,7].repeated_permutation(m) do |arr|
cnt3 = arr.count(3)
cnt5 = arr.count(5)
cnt7 = arr.count(7)
next if cnt3 == 0 || cnt5 == 0 || cnt7 == 0
r = arr.size.! / (cnt3.! * cnt5.! * cnt7.!)
rs << arr.join.to_i
end
end
# pp rs
# p n
p rs.bsearch_index{|x|x >= n}
|
class Integer
@mod = nil
def self.set_mod(mod = 10**9 + 7)
@mod = mod
end
def combination(k = self) # 4C2 = 6
return 1 if k.zero?
if @mod.nil?
(self - k + 1..self).inject(:*) / k.factorial
else
(self - k + 1..self).inject{|i,m|i * m % @mod} * k.factorial.modinv % @mod
end
end
def permutation(k = self) # 4P2 = 12
return 1 if k.zero?
if @mod.nil?
(self - k + 1..self).inject(:*)
else
(self - k + 1..self).inject{|i,m|i * m % @mod}
end
end
def factorial(step = 1) # 4! = 24
return 1 if self.zero?
if @mod.nil?
(1..self).inject(:*)
else
(1..self).inject{|i,m|i * m % @mod}
end
end
def modinv # https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
a = self; b = @mod; u = 1; v = 0
while b > 0
t = a / b
a -= t * b
a, b = b, a
u -= t * v
u, v = v, u
end
u %= m
u += m if u < 0
u
end
# 繰り返し二乗法
def repeat_squaring(p, mod = (10**9 + 7))
return 1 if p == 0
if p % 2 == 0
t = repeat_squaring(p/2, mod)
return t*t % mod
end
self * repeat_squaring(p - 1, mod) % mod
end
alias :C :combination
alias :P :permutation
alias :! :factorial
end
require 'pp'
# 4 13 26484
n = gets.to_i
cnt = 0
sum = 0
M = 10
rs = []
cnts = (1..M).map do |m|
[3,5,7].repeated_permutation(m) do |arr|
cnt3 = arr.count(3)
cnt5 = arr.count(5)
cnt7 = arr.count(7)
next if cnt3 == 0 || cnt5 == 0 || cnt7 == 0
r = arr.size.! / (cnt3.! * cnt5.! * cnt7.!)
rs << arr.join.to_i
end
end
# pp rs
# p n
p rs.bsearch_index{|x|x > n}
|
[
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,007,902
| 1,007,903
|
u315597999
|
ruby
|
p03212
|
N = gets.to_i
ans = []
def func(s, ans, n)
ans.push(s.to_i) if s.to_i >= 357 && (s.chars & ['3', '5', '7']).length == 3
[3, 5, 7].each do |i|
v = s + i.to_s
return if v.to_i >= N
func(v, ans, n)
end
end
func('', ans, N)
p ans.length
|
N = gets.to_i
ans = []
def func(s, ans, n)
ans.push(s.to_i) if s.to_i >= 357 && (s.chars & ['3', '5', '7']).length == 3
[3, 5, 7].each do |i|
v = s + i.to_s
return if v.to_i > N
func(v, ans, n)
end
end
func('', ans, N)
p ans.length
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,008,137
| 1,008,138
|
u140351520
|
ruby
|
p03212
|
S = gets.strip
N = S.size
n = S.to_i
def dfs(s, n, a)
if s.size == N
a << s.to_i if s.split('').uniq.sort.eql?(['3', '5', '7'])
return
end
dfs(s + '3', n, a)
dfs(s + '5', n, a)
dfs(s + '7', n, a)
end
a = []
3.upto(N) { |i| dfs('', i, a) }
puts a.count { |d| d <= n }
|
S = gets.strip
N = S.size
n = S.to_i
def dfs(s, n, a)
if s.size == n
a << s.to_i if s.split('').uniq.sort.eql?(['3', '5', '7'])
return
end
dfs(s + '3', n, a)
dfs(s + '5', n, a)
dfs(s + '7', n, a)
end
a = []
3.upto(N) { |i| dfs('', i, a) }
puts a.count { |d| d <= n }
|
[
"control_flow.branch.if.condition.change"
] | 1,008,511
| 1,008,512
|
u707614029
|
ruby
|
p03212
|
n = gets.to_i
c = 0
for d in 3..(n.to_s.length) do
[7, 5, 3].repeated_permutation(d).to_a.uniq() do |num|
c += 1 if num.include?(3) && num.include?(5) && num.include?(7) && num.join.to_i < n
end
end
p c
|
n = gets.to_i
c = 0
for d in 3..(n.to_s.length) do
[7, 5, 3].repeated_permutation(d).to_a.uniq() do |num|
c += 1 if num.include?(3) && num.include?(5) && num.include?(7) && num.join.to_i <= n
end
end
p c
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,008,711
| 1,008,712
|
u105001881
|
ruby
|
p03213
|
require 'prime'
n = gets.chomp.to_i
def fact(n)
return 1 if n <= 1
n * fact(n-1)
end
def num_div(d, divs)
num_divs = []
begin
divs.each_index { |i| num_divs.push(d.select { |e| e >= divs[i] - 1 }.size - i) }
if divs == [5, 5, 3]
num_divs.reduce(1) { |mul, e| mul * e } / 2
else
num_divs.reduce(1) { |mul, e| mul * e }
end
rescue NoMethodError
0
end
end
f = fact(n)
count = 0
d = f.prime_division.map { |e| e.last }
[[75, 1], [25, 3], [15, 5], [5, 5, 3]].each do |divs|
n = num_div(d, divs)
count += n
end
puts count
|
require 'prime'
n = gets.chomp.to_i
def fact(n)
return 1 if n <= 1
n * fact(n-1)
end
def num_div(d, divs)
num_divs = []
begin
divs.each_index { |i| num_divs.push(d.select { |e| e >= divs[i] - 1 }.size - i) }
if divs == [5, 5, 3]
num_divs.reduce(1) { |mul, e| mul * e } / 2
else
num_divs.reduce(1) { |mul, e| mul * e }
end
rescue NoMethodError
0
end
end
f = fact(n)
count = 0
d = f.prime_division.map { |e| e.last }
[[75], [25, 3], [15, 5], [5, 5, 3]].each do |divs|
n = num_div(d, divs)
count += n
end
puts count
|
[] | 1,009,033
| 1,009,034
|
u434509016
|
ruby
|
p03213
|
pr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
u = [74, 24, 14, 4, 2]
n = gets.to_i
pr = pr.map do |x|
tm, res = n, 0
while tm > 0
tm /= x
res += tm
end
res
end
u = u.map{|x| m.count{|y| y >= x}}
p u[0] + u[1]*(u[4]-1) + u[2]*(u[3]-1) + u[3]*(u[3]-1)/2*(u[4]-2)
|
pr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
u = [74, 24, 14, 4, 2]
n = gets.to_i
pr = pr.map do |x|
tm, res = n, 0
while tm > 0
tm /= x
res += tm
end
res
end
u = u.map{|x| pr.count{|y| y >= x}}
p u[0] + u[1]*(u[4]-1) + u[2]*(u[3]-1) + u[3]*(u[3]-1)/2*(u[4]-2)
|
[
"assignment.value.change",
"identifier.change"
] | 1,009,037
| 1,009,038
|
u309985845
|
ruby
|
p03213
|
d=[0]*1e5;d[1]=p=1;n=2..gets.to_i;n.map{|i|p*=i+1};n.map{|i|c=0;(p/=i;c+=1)while p%i<1;75.downto(0){|k|c.times{|j|d[k.*j+2]+=d[k]}}};p d[75]
|
d=[0]*1e5;d[1]=p=1;n=2..gets.to_i;n.map{|i|p*=i};n.map{|i|c=0;(p/=i;c+=1)while p%i<1;75.downto(0){|k|c.times{|j|d[k.*j+2]+=d[k]}}};p d[75]
|
[
"expression.operation.binary.remove"
] | 1,009,078
| 1,009,079
|
u657913472
|
ruby
|
p03213
|
require 'prime'
DBG = true
def combi(n,k)
k=n-k if 2*k > n
return 1 if k == 0
((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end
n = gets.to_i
a = {}
for i in 2..n
ls = i.prime_division
for x in ls
pr = x[0]
ex = x[1]
if a.keys.include?(pr)
a[pr] += ex
else
a[pr] = ex
end
end
end
# now a : { 2:3, 3:1, ... }
b = []
for x in a.keys
b << [x, a[x]]
end
print b if DBG
puts ""
sum = 0
for x in b
psum = 0
if x[1] >= 74
psum += 1
end
sum += psum
if DBG && psum != 0
printf("%d - add %d", x[0], psum)
puts ""
end
end
b.combination(2) { |x,y|
psum = 0
if x[1] >= 24 && y[1] >= 2
psum += 1
end
if y[1] >= 24 && x[1] >= 2
psum += 1
end
if x[1] >= 14 && y[1] >= 4
psum += 1
end
if y[1] >= 14 && x[1] >= 4
psum += 1
end
sum += psum
if DBG && psum != 0
printf("%d %d - add %d", x[0], y[0], psum)
puts ""
end
}
b.combination(3) { |x,y,z|
if DBG && false
print x
puts "--x"
print y
puts "---y"
print z
puts "----z"
end
psum = 0
if x[1] >= 4 && y[1] >= 4 && z[1] >= 2
psum += 1
end
if x[1] >= 4 && z[1] >= 4 && y[1] >= 2
psum += 1
end
if z[1] >= 4 && y[1] >= 4 && x[1] >= 2
psum += 1
end
sum += psum
if DBG && psum != 0
printf("%d %d %d - add %d", x[0], y[0], z[0], psum)
puts ""
end
}
print sum
|
require 'prime'
DBG = !true
def combi(n,k)
k=n-k if 2*k > n
return 1 if k == 0
((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end
n = gets.to_i
a = {}
for i in 2..n
ls = i.prime_division
for x in ls
pr = x[0]
ex = x[1]
if a.keys.include?(pr)
a[pr] += ex
else
a[pr] = ex
end
end
end
# now a : { 2:3, 3:1, ... }
b = []
for x in a.keys
b << [x, a[x]]
end
print b if DBG
puts ""
sum = 0
for x in b
psum = 0
if x[1] >= 74
psum += 1
end
sum += psum
if DBG && psum != 0
printf("%d - add %d", x[0], psum)
puts ""
end
end
b.combination(2) { |x,y|
psum = 0
if x[1] >= 24 && y[1] >= 2
psum += 1
end
if y[1] >= 24 && x[1] >= 2
psum += 1
end
if x[1] >= 14 && y[1] >= 4
psum += 1
end
if y[1] >= 14 && x[1] >= 4
psum += 1
end
sum += psum
if DBG && psum != 0
printf("%d %d - add %d", x[0], y[0], psum)
puts ""
end
}
b.combination(3) { |x,y,z|
if DBG && false
print x
puts "--x"
print y
puts "---y"
print z
puts "----z"
end
psum = 0
if x[1] >= 4 && y[1] >= 4 && z[1] >= 2
psum += 1
end
if x[1] >= 4 && z[1] >= 4 && y[1] >= 2
psum += 1
end
if z[1] >= 4 && y[1] >= 4 && x[1] >= 2
psum += 1
end
sum += psum
if DBG && psum != 0
printf("%d %d %d - add %d", x[0], y[0], z[0], psum)
puts ""
end
}
print sum
|
[
"expression.operation.unary.add"
] | 1,009,248
| 1,009,249
|
u975329388
|
ruby
|
p03213
|
n = gets.to_i
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
exp = [0]*15
2.upto(n) do |v|
prime.each_with_index do |a,i|
while (v % a == 0)
exp[i] += 1
v /= a
end
end
end
v,w,x,y,z = 0,0,0,0,0
exp.each do |e|
if e >= 74
v += 1
end
if e >= 24
w += 1
elsif e >= 14
x += 1
elsif e >= 4
y += 1
elsif e == 2 || e == 3
z += 1
end
end
ans = 0
if v > 0
ans += v
end
if w > 0
ans += w * (x+y+z) + w * (w-1)
end
if x > 0
ans += (w+x) * y + (w+x) * ((w+x)-1)
end
y = w+x+y
if y >= 3
ans += y * (y-1) * (y-2) /2
end
if y >= 2 && z > 0
ans += y * (y-1) * z /2
end
p ans
|
n = gets.to_i
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
exp = [0]*15
2.upto(n) do |v|
prime.each_with_index do |a,i|
while (v % a == 0)
exp[i] += 1
v /= a
end
end
end
v,w,x,y,z = 0,0,0,0,0
exp.each do |e|
if e >= 74
v += 1
end
if e >= 24
w += 1
elsif e >= 14
x += 1
elsif e >= 4
y += 1
elsif e == 2 || e == 3
z += 1
end
end
ans = 0
if v > 0
ans += v
end
if w > 0
ans += w * (x+y+z) + w * (w-1)
end
if (w+x) > 0
ans += (w+x) * y + (w+x) * ((w+x)-1)
end
y = w+x+y
if y >= 3
ans += y * (y-1) * (y-2) /2
end
if y >= 2 && z > 0
ans += y * (y-1) * z /2
end
p ans
|
[
"control_flow.branch.if.condition.change"
] | 1,009,259
| 1,009,260
|
u123276241
|
ruby
|
p03214
|
def main(argv)
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
avg = a.reduce(:+).to_f / n.to_f
min_diff = 100.0
min_index = -1
n.times do |i|
diff = (a[i] - avg).abs
if min_diff < diff then
min_diff = diff
min_index = i
end
end
puts min_index.to_i
end
if self.to_s == 'main' then
main(ARGV)
end
|
def main(argv)
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
avg = a.reduce(:+).to_f / n.to_f
min_diff = 100.0
min_index = -1
n.times do |i|
diff = (a[i] - avg).abs
if min_diff > diff then
min_diff = diff
min_index = i
end
end
puts min_index.to_i
end
if self.to_s == 'main' then
main(ARGV)
end
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 1,009,364
| 1,009,365
|
u198355306
|
ruby
|
p03214
|
lines = readlines.map{|line| line.split(' ').map(&:to_i)}
a=[]
b=lines[1].inject(:+)/lines[1].length
for i in 0..lines[0][0]-1
a.push((b-lines[1][i]).abs)
end
puts a.index(a.min)
|
lines = readlines.map{|line| line.split(' ').map(&:to_f)}
a=[]
b=lines[1].inject(:+)/lines[1].length
for i in 0..lines[0][0]-1
a.push((b-lines[1][i]).abs)
end
puts a.index(a.min)
|
[
"assignment.value.change",
"call.arguments.change"
] | 1,009,490
| 1,009,491
|
u413184068
|
ruby
|
p03214
|
N = gets.to_i
a = gets.split.map(&:to_i)
b = a.map{|i| (a.inject(:+)/N-i).abs}
p b.index(b.min)
|
N = gets.to_i
a = gets.split.map(&:to_i)
b = a.map{|i| (a.inject(:+).to_f/N-i).abs}
p b.index(b.min)
|
[
"call.add"
] | 1,009,514
| 1,009,515
|
u091810847
|
ruby
|
p03214
|
n = gets.to_i
as = gets.split.map{|i|i.to_i}
ave = as.inject(:+) / as.length
min = 1000
min_index = 100
0.upto(n-1) do |i|
if min > (as[i] - ave).abs
min = (as[i] - ave).abs
min_index = i
end
end
puts min_index
|
n = gets.to_i
as = gets.split.map{|i|i.to_i}
ave = as.inject(:+) / as.length.to_f
min = 1000
min_index = 100
0.upto(n-1) do |i|
if min > (as[i] - ave).abs
min = (as[i] - ave).abs
min_index = i
end
end
puts min_index
|
[
"call.add"
] | 1,009,564
| 1,009,565
|
u103857220
|
ruby
|
p03214
|
n,*a=`dd`.split.map &:to_i
q=n*a.reduce(:+)
p (0...n).min_by{|i|(a[i]*n-q).abs}
|
n,*a=`dd`.split.map &:to_i
q=a.reduce(:+)
p (0...n).min_by{|i|(a[i]*n-q).abs}
|
[
"call.remove"
] | 1,009,685
| 1,009,686
|
u280667879
|
ruby
|
p03214
|
n,*a=`dd`.split.map &:to_i
q=n*a.reduce(:+)
p (0...n).min_by{|i|(a[i-1]*n-q).abs}
|
n,*a=`dd`.split.map &:to_i
q=a.reduce(:+)
p (0...n).min_by{|i|(a[i]*n-q).abs}
|
[
"call.remove",
"expression.operation.binary.remove"
] | 1,009,687
| 1,009,686
|
u280667879
|
ruby
|
p03214
|
n,*a=`dd`.split.map &:to_i
q=n*a.reduce(:+)
p (1..n).min_by{|i|(a[i-1]*n-q).abs}
|
n,*a=`dd`.split.map &:to_i
q=a.reduce(:+)
p (0...n).min_by{|i|(a[i]*n-q).abs}
|
[
"call.remove",
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.remove"
] | 1,009,688
| 1,009,686
|
u280667879
|
ruby
|
p03215
|
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
require 'pp'
def debug obj
# PP.pp obj, STDERR
end
debug [N,K]
debug A
sum = 0
sumA = A.map{|a| sum += a }
bt_list = []
(0..(N)).to_a.combination(2) do |l,r|
bt_list.push(((sumA[r] || 0) - sumA[l]).abs)
end
bt_list.sort!.reverse!
debug bt_list
r = 0
max = sumA.last
maxlog = Math.log2(max).to_i
maxlog.downto(1) do |i|
count = 0
ra = r + (1 << i)
bt_list.each_with_index do |bt, j|
if ra == ( ra & bt )
count += 1
if count >= K
r = ra
break
end
end
if (bt_list.size - j -1) < K - count
break
end
end
end
puts r
|
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
require 'pp'
def debug obj
# PP.pp obj, STDERR
end
debug [N,K]
debug A
sum = 0
sumA = A.map{|a| sum += a }
bt_list = []
(0..(N)).to_a.combination(2) do |l,r|
bt_list.push(((sumA[r] || 0) - sumA[l]).abs)
end
bt_list.sort!.reverse!
debug bt_list
r = 0
max = sumA.last
maxlog = Math.log2(max).to_i
maxlog.downto(0) do |i|
count = 0
ra = r + (1 << i)
bt_list.each_with_index do |bt, j|
if ra == ( ra & bt )
count += 1
if count >= K
r = ra
break
end
end
if (bt_list.size - j -1) < K - count
break
end
end
end
puts r
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 1,010,033
| 1,010,034
|
u299761130
|
ruby
|
p03215
|
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
require 'pp'
def debug obj
# PP.pp obj, STDERR
end
debug [N,K]
debug A
sum = 0
sumA = A.map{|a| sum += a }
bt_list = []
(0..(N)).to_a.combination(2) do |l,r|
bt_list.push(((sumA[r] || 0) - sumA[l]).abs)
end
bt_list.sort!.reverse!
debug bt_list
r = 0
max = sumA.last
maxlog = Math.log2(max).to_i
maxlog.downto(1) do |i|
count = 0
ra = r + (1 << i)
bt_list.each_with_index do |bt, j|
if ra == ( ra & bt )
count += 1
if count >= K
r = ra
break
end
end
# if (bt_list.size - j -1) < K - count
# break
# end
end
end
puts r
|
N, K = gets.split(' ').map(&:to_i)
A = gets.split(' ').map(&:to_i)
require 'pp'
def debug obj
# PP.pp obj, STDERR
end
debug [N,K]
debug A
sum = 0
sumA = A.map{|a| sum += a }
bt_list = []
(0..(N)).to_a.combination(2) do |l,r|
bt_list.push(((sumA[r] || 0) - sumA[l]).abs)
end
bt_list.sort!.reverse!
debug bt_list
r = 0
max = sumA.last
maxlog = Math.log2(max).to_i
maxlog.downto(0) do |i|
count = 0
ra = r + (1 << i)
bt_list.each_with_index do |bt, j|
if ra == ( ra & bt )
count += 1
if count >= K
r = ra
break
end
end
# if (bt_list.size - j -1) < K - count
# break
# end
end
end
puts r
|
[
"literal.number.integer.change",
"call.arguments.change"
] | 1,010,035
| 1,010,036
|
u299761130
|
ruby
|
p03214
|
N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);
sum = 0
a.each do |i|
sum += i
end
average = (sum.to_f) / N
puts average
thumbnail = a[0]
ans = 0
N.times do |i|
if (average - a[i]).abs < (average - thumbnail).abs
thumbnail = a[i]
ans = i
end
end
puts ans
|
N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);
sum = 0
a.each do |i|
sum += i
end
average = (sum.to_f) / N
thumbnail = a[0]
ans = 0
N.times do |i|
if (average - a[i]).abs < (average - thumbnail).abs
thumbnail = a[i]
ans = i
end
end
puts ans
|
[
"call.remove"
] | 1,010,783
| 1,010,784
|
u630733574
|
ruby
|
p03214
|
N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);
sum = 0
a.each do |i|
sum += i
end
average = sum / N
thumbnail = a[0]
ans = 0
N.times do |i|
if (average - a[i]).abs < (average - thumbnail).abs
thumbnail = a[i]
ans = i
end
end
puts ans
|
N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);
sum = 0
a.each do |i|
sum += i
end
average = (sum.to_f) / N
thumbnail = a[0]
ans = 0
N.times do |i|
if (average - a[i]).abs < (average - thumbnail).abs
thumbnail = a[i]
ans = i
end
end
puts ans
|
[] | 1,010,785
| 1,010,784
|
u630733574
|
ruby
|
p03219
|
a, b = gets.strip.split(' ').map(&:to_i)
puts a + (b * 2)
|
a, b = gets.strip.split(' ').map(&:to_i)
puts a + (b / 2)
|
[
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,011,429
| 1,011,430
|
u259578064
|
ruby
|
p03219
|
array = STDIN.read.chomp.split().map { |x|
x.to_i
}
p array[1] + array[1] / 2
|
array = STDIN.read.chomp.split().map { |x|
x.to_i
}
p array[0] + array[1] / 2
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,012,877
| 1,012,876
|
u231458241
|
ruby
|
p03220
|
n = gets.chomp.to_i
t, a = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
sa = 10 ** 8
ind = 0
arr.length.times do |i|
temp = (a - t - arr[i] * 0.006).abs
if sa > temp
sa = temp
ind = i
end
end
puts ind + 1
|
n = gets.chomp.to_i
t, a = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
sa = 10 ** 8
ind = 0
arr.length.times do |i|
temp = (a - (t - arr[i] * 0.006)).abs
if sa > temp
sa = temp
ind = i
end
end
puts ind + 1
|
[] | 1,013,361
| 1,013,362
|
u409390792
|
ruby
|
p03220
|
N = gets.to_i
T,A = gets.split.map(&:to_i)
higher = gets.split.map(&:to_i)
temp_near = higher.map{|x| ((T - x * 0.006).floor - A).abs}
point = temp_near.index(temp_near.min)
puts point + 1
|
N = gets.to_i
T,A = gets.split.map(&:to_i)
higher = gets.split.map(&:to_i)
temp_near = higher.map{|x| (T - x * 0.006 - A).abs}
point = temp_near.index(temp_near.min)
puts point + 1
|
[
"call.remove"
] | 1,013,371
| 1,013,372
|
u017368005
|
ruby
|
p03220
|
#!/usr/bin/env ruby
require 'set'
class Hash
def push(key, value)
self[key] = [] if self[key] == nil
self[key].push(value)
end
end
class Array
def lower_bound(value)
left = -1;
right = self.length;
while left + 1 < right
mid = left + (right - left) / 2;
if self[mid] >= value
right = mid
else
left = mid
end
end
right
end
def unique
res = [self.first]
each_cons(2) do |a, b|
if a != b
res.push(b)
end
end
res
end
end
def get_ints
gets.chomp.split.map(&:to_i)
end
def get_ints_minus_one
get_ints.map { |x| x - 1 }
end
def get_int
gets.chomp.to_i
end
require 'bigdecimal'
N = get_int
T, A = get_ints
H = get_ints
min = 10 ** 5 + 1
ans = -1
H.each.with_index do |h, i|
sa = A - (T - BigDecimal(h) * 0.006)
if sa < min
min = sa
ans = i
end
end
puts ans + 1
|
#!/usr/bin/env ruby
require 'set'
class Hash
def push(key, value)
self[key] = [] if self[key] == nil
self[key].push(value)
end
end
class Array
def lower_bound(value)
left = -1;
right = self.length;
while left + 1 < right
mid = left + (right - left) / 2;
if self[mid] >= value
right = mid
else
left = mid
end
end
right
end
def unique
res = [self.first]
each_cons(2) do |a, b|
if a != b
res.push(b)
end
end
res
end
end
def get_ints
gets.chomp.split.map(&:to_i)
end
def get_ints_minus_one
get_ints.map { |x| x - 1 }
end
def get_int
gets.chomp.to_i
end
require 'bigdecimal'
N = get_int
T, A = get_ints
H = get_ints
min = 10 ** 5 + 1
ans = -1
H.each.with_index do |h, i|
sa = (A - (T - BigDecimal(h) * 0.006)).abs
if sa < min
min = sa
ans = i
end
end
puts ans + 1
|
[
"call.add"
] | 1,013,545
| 1,013,546
|
u305883349
|
ruby
|
p03220
|
n = gets.to_i
t, a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
for i in 0..n-1
b[i] = (t * 1000 - b[i] * 6 - 1000 * a)
end
puts b.index(b.min) + 1
|
n = gets.to_i
t, a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
for i in 0..n-1
b[i] = (t * 1000 - b[i] * 6 - 1000 * a).abs
end
puts b.index(b.min) + 1
|
[
"call.add"
] | 1,013,986
| 1,013,987
|
u056083754
|
ruby
|
p03220
|
# https://atcoder.jp/contests/abc113/tasks/abc113_b
# Ruby 2nd Try
HOSEI = 0.006
n = gets.chomp.to_i
abss = Array.new(n,0.0)
t,a = gets.chomp.split(' ').map(&:to_f)
hi = gets.chomp.split(' ').map(&:to_f)
for j in 0..(n-1) do
abss[j]=((t-hi[j]*HOSEI)-a).abs
end
answer = 0
avemin = abss[0]
for j in 1..(n-1) do
if abss[j] < avemin
answer = j
end
end
answer = answer+1
puts(answer)
|
# https://atcoder.jp/contests/abc113/tasks/abc113_b
# Ruby 2nd Try
HOSEI = 0.006
n = gets.chomp.to_i
abss = Array.new(n,0.0)
t,a = gets.chomp.split(' ').map(&:to_f)
hi = gets.chomp.split(' ').map(&:to_f)
for j in 0..(n-1) do
abss[j]=((t-hi[j]*HOSEI)-a).abs
end
answer = 0
avemin = abss[0]
for j in 1..(n-1) do
if abss[j] < avemin
answer = j
avemin = abss[j]
end
end
answer = answer+1
puts(answer)
|
[
"assignment.add"
] | 1,014,197
| 1,014,198
|
u197300260
|
ruby
|
p03220
|
N = gets.to_i
T, A = gets.chomp.split.map(&:to_f)
H = gets.chomp.split.map(&:to_f)
sub = 0xffffffff
ans = -1
H.each.with_index(1) do |hi, i|
s = (A - T * hi * 0.006).abs
if s < sub
sub = s
ans = i
end
end
puts ans
|
N = gets.to_i
T, A = gets.chomp.split.map(&:to_f)
H = gets.chomp.split.map(&:to_f)
sub = 0xffffffff
ans = -1
H.each.with_index(1) do |hi, i|
s = (A - (T - hi * 0.006)).abs
if s < sub
sub = s
ans = i
end
end
puts ans
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,014,344
| 1,014,345
|
u164316941
|
ruby
|
p03220
|
n=gets.to_i
t,a=gets.split.map &:to_i
h=gets.split.map &:to_i
n.times do |i|
h[i] = (12 - h[i] * 0.006 - a).abs
end
p h.index(h.min)+1
|
n=gets.to_i
t,a=gets.split.map &:to_i
h=gets.split.map &:to_i
n.times do |i|
h[i] = (t - h[i] * 0.006 - a).abs
end
p h.index(h.min)+1
|
[
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.change"
] | 1,014,669
| 1,014,670
|
u744908753
|
ruby
|
p03220
|
N = gets.to_i
T,A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
min_d = 100000
min_di = 0
N.times do |i|
t = T-(H[i]*0.006)
puts t
if min_d > (A-t).abs
min_d = (A-t).abs
min_di = i
end
end
puts min_di+1
|
N = gets.to_i
T,A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
min_d = 100000
min_di = 0
N.times do |i|
t = T-(H[i]*0.006)
if min_d > (A-t).abs
min_d = (A-t).abs
min_di = i
end
end
puts min_di+1
|
[
"call.remove"
] | 1,014,743
| 1,014,744
|
u244087909
|
ruby
|
p03220
|
a=gets.chomp.to_i
b=gets.split.map(&:to_i)
c=gets.split.map(&:to_i)
for i in 0..(b.length-1)
c[i]=(b[1]-(b[0]-(c[i]*0.006))).abs
end
puts c.index(c.min)+1
|
a=gets.chomp.to_i
b=gets.split.map(&:to_i)
c=gets.split.map(&:to_i)
for i in 0..(c.length-1)
c[i]=(b[1]-(b[0]-(c[i]*0.006))).abs
end
puts c.index(c.min)+1
|
[
"identifier.change",
"expression.operation.binary.change"
] | 1,014,745
| 1,014,746
|
u585819925
|
ruby
|
p03220
|
n=gets.to_i
t,a = gets.split.map(&:to_i)
h=gets.split.map{|h| ((t - h.to_f*0.006).abs-a.abs).abs}
p h.find_index(h.min) + 1
|
n=gets.to_i
t,a = gets.split.map(&:to_i)
h=gets.split.map{|h| ((t - h.to_f*0.006)-a).abs}
p h.find_index(h.min) + 1
|
[
"call.remove"
] | 1,015,237
| 1,015,238
|
u358554431
|
ruby
|
p03220
|
n = gets.to_i
t, a = gets.split.map &:to_i
hs = gets.split.map &:to_i
min = 1000000
ans = 1
hs.each_with_index do |h,i|
diff = (h - (t - h * 0.006)).abs
if min > diff
min = diff
ans = i + 1
end
end
puts ans
|
n = gets.to_i
t, a = gets.split.map &:to_i
hs = gets.split.map &:to_i
min = 1000000
ans = 1
hs.each_with_index do |h,i|
diff = (a - (t - h * 0.006)).abs
if min > diff
min = diff
ans = i + 1
end
end
puts ans
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 1,015,643
| 1,015,644
|
u647522078
|
ruby
|
p03220
|
n = gets.to_i
t, a = gets.split.map(&:to_f)
h = gets.split.map(&:to_f)
puts (0...h.size).min_by{|x| (t - h[x] * 0.06 - a).abs} + 1
|
n = gets.to_i
t, a = gets.split.map(&:to_f)
h = gets.split.map(&:to_f)
puts (0...n).min_by{|x| (t - h[x] * 0.006 - a).abs} + 1
|
[
"call.arguments.change",
"expression.operation.binary.change",
"call.remove",
"literal.number.float.change"
] | 1,015,768
| 1,015,769
|
u794250528
|
ruby
|
p03220
|
n = gets.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
h = gets.chomp.split(' ').map(&:to_i)
ans = 0
tmpt = a + 10000000
i = 1
h.each do |hh|
avgt = t - hh * 0.6
if (avgt - a).abs < (tmpt - a).abs
ans = i
tmpt = avgt
end
i += 1
end
p ans
|
n = gets.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
h = gets.chomp.split(' ').map(&:to_i)
ans = 0
tmpt = a + 10000000
i = 1
h.each do |hh|
avgt = t - hh * 0.006
if (avgt - a).abs < (tmpt - a).abs
ans = i
tmpt = avgt
end
i += 1
end
p ans
|
[
"literal.number.float.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 1,015,915
| 1,015,913
|
u764011970
|
ruby
|
p03220
|
N = gets.to_i
T, A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
(1..N).min_by do |x|
(A - (T - H[x]*0.006)).abs
end
|
N = gets.to_i
T, A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
puts (1..N).min_by{|x| (A - (T - H[x-1]*0.006)).abs }
|
[
"io.output.change",
"call.add"
] | 1,016,003
| 1,016,004
|
u745385679
|
ruby
|
p03220
|
n = gets.chomp.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
h = gets.chomp.split(' ').map(&:to_i)
delta = ->(x) { a - (t - h[x] * 0.006) }
ans = (0...n).reduce(0) do |min, i|
delta[i] < delta[min] ? i : min
end
puts ans + 1
|
n = gets.chomp.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
h = gets.chomp.split(' ').map(&:to_i)
delta = ->(x) { (a - (t - h[x] * 0.006)).abs }
ans = (0...n).reduce(0) do |min, i|
delta[i] < delta[min] ? i : min
end
puts ans + 1
|
[
"call.add"
] | 1,016,013
| 1,016,014
|
u593938737
|
ruby
|
p03220
|
n=gets.chomp.to_i
t,a=gets.chomp.split.map(&:to_i)
h=gets.split.map(&:to_i)
tmp=[]
for x in 1..n
tmp[x-1]=(h[x-1]-x*0.006-a).abs
end
puts tmp.index(tmp.min)+1
|
n=gets.chomp.to_i
t,a=gets.chomp.split.map(&:to_i)
h=gets.split.map(&:to_i)
tmp=[]
for x in 1..n
tmp[x-1]=(t-h[x-1]*0.006-a).abs
end
puts tmp.index(tmp.min)+1
|
[
"expression.operation.binary.remove"
] | 1,016,237
| 1,016,238
|
u411903982
|
ruby
|
p03220
|
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ans = -1
dif = 10**9
n.times{|i|
tmp = t-h[i]*0.006
if (tmp-a).abs < dif
ans = tmp
dif = (tmp-a).abs
end
}
p ans+1
|
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ans = -1
dif = 10**9
n.times{|i|
tmp = t-h[i]*0.006
if (tmp-a).abs < dif
ans = i+1
dif = (tmp-a).abs
end
}
p ans
|
[
"assignment.value.change",
"expression.operation.binary.remove"
] | 1,016,477
| 1,016,478
|
u397763977
|
ruby
|
p03220
|
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ans = -1
dif = 10**9
n.times{|i|
tmp = t-h[i]*0.006
if (tmp-a).abs < dif
ans = tmp
dif = (tmp-a).abs
end
}
p ans
|
n = gets.to_i
t,a = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ans = -1
dif = 10**9
n.times{|i|
tmp = t-h[i]*0.006
if (tmp-a).abs < dif
ans = i+1
dif = (tmp-a).abs
end
}
p ans
|
[
"assignment.value.change"
] | 1,016,479
| 1,016,478
|
u397763977
|
ruby
|
p03220
|
N=gets.to_i
T,A=gets.split.map &:to_f
H=gets.split.map &:to_f
p H.each.with_index.map{|x,i|[(A-T-x*0.006).abs,i+1]}.min[1]
|
N=gets.to_i
T,A=gets.split.map &:to_f
H=gets.split.map &:to_f
p H.each.with_index.map{|x,i|[(A-(T-x*0.006)).abs,i+1]}.min[1]
|
[
"call.arguments.change"
] | 1,016,628
| 1,016,629
|
u647875062
|
ruby
|
p03221
|
n,m = gets.strip.split.map(&:to_i)
pref = Array.new(n){Array.new}
i = 1
while i <= m do
p,y = gets.strip.split.map(&:to_i)
pref[p-1] << [i,y].to_a #[市の番号,誕生年]
i += 1
end
#すべて入力完了
#全ての配列を年代順にソート
city = Array.new(m)
j = 0
while j < n do
unless pref[j] == nil
pref[j].sort! {|a, b| a[1] <=> b[1] }
print pref[j]
k = 0
while k < pref[j].size do
city[pref[j][k][0]-1] = ('%012d' % ((j+1)*(10**6)+(k+1)))
k += 1
end
end
j += 1
end
m.times do |d|
puts city[d]
end
|
n,m = gets.strip.split.map(&:to_i)
pref = Array.new(n){Array.new}
i = 1
while i <= m do
p,y = gets.strip.split.map(&:to_i)
pref[p-1] << [i,y].to_a #[市の番号,誕生年]
i += 1
end
#すべて入力完了
#全ての配列を年代順にソート
city = Array.new(m)
j = 0
while j < n do
unless pref[j] == nil
pref[j].sort! {|a, b| a[1] <=> b[1] }
k = 0
while k < pref[j].size do
city[pref[j][k][0]-1] = ('%012d' % ((j+1)*(10**6)+(k+1)))
k += 1
end
end
j += 1
end
m.times do |d|
puts city[d]
end
|
[
"call.remove"
] | 1,016,657
| 1,016,658
|
u313103408
|
ruby
|
p03221
|
N, M = gets.split(" ").map(&:to_i)
adress = []
prf = Array.new(N) {Array.new}
M.times do |i|
a, b = gets.chomp.split(" ")
prf[a.to_i - 1] << [i, b.to_i]
while a.length < 6 do
a = "0" + a
end
adress[i] = a
end
prf.each do |p|
next if p == []
p = p.sort{|a, b| a[1] <=> b[1]}
p.each_with_index do |a, i|
i += 1
i = i.to_s
while i.length < 6 do
i = "0" + i
end
adress[a[0]] += i
end
end
|
N, M = gets.split(" ").map(&:to_i)
adress = []
prf = Array.new(N) {Array.new}
M.times do |i|
a, b = gets.chomp.split(" ")
prf[a.to_i - 1] << [i, b.to_i]
while a.length < 6 do
a = "0" + a
end
adress[i] = a
end
prf.each do |p|
next if p == []
p = p.sort{|a, b| a[1] <=> b[1]}
p.each_with_index do |a, i|
i += 1
i = i.to_s
while i.length < 6 do
i = "0" + i
end
adress[a[0]] += i
end
end
puts adress
|
[
"call.add"
] | 1,016,969
| 1,016,970
|
u729911058
|
ruby
|
p03220
|
N, T, A, *H = gets(p).split.map &:to_i
p H.map.with_index(1){|h, i|[(A - (T - h*6/1000)).abs, i]}.min[1]
|
N, T, A, *H = gets(p).split.map &:to_i
p H.map.with_index(1){|h, i|[(A - (T - h*0.006)).abs, i]}.min[1]
|
[
"call.arguments.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 1,017,178
| 1,017,179
|
u711705317
|
ruby
|
p03220
|
N = gets.to_i
T, A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
Diff_C = H.map{ |h| (T - (T - h*0.006)).abs }
Min_diff = Diff_C.min
p Diff_C.index(Min_diff) + 1
|
N = gets.to_i
T, A = gets.split.map(&:to_i)
H = gets.split.map(&:to_i)
Diff_C = H.map{ |h| (A - (T - h*0.006)).abs }
Min_diff = Diff_C.min
p Diff_C.index(Min_diff) + 1
|
[
"assignment.value.change",
"expression.operation.binary.change"
] | 1,017,227
| 1,017,228
|
u716826907
|
ruby
|
p03221
|
N, M = gets.chomp.split(" ").map(&:to_i)
PYs = M.times.map do |_|
gets.chomp.split(" ").map(&:to_i)
end
prefs = PYs.inject({}) do |m, v|
m[v[0]] = [] unless m.key?(v[0])
m[v[0]].push(v)
m
end
prefs.each do |pref, v|
v.sort_by { |v| v[0] }.each.with_index do |v2, i|
v2.push("#{pref.to_s.rjust(6, "0")}#{(i + 1).to_s.rjust(6, "0")}")
end
end
PYs.each do |v|
puts v[2]
end
|
N, M = gets.chomp.split(" ").map(&:to_i)
PYs = M.times.map do |_|
gets.chomp.split(" ").map(&:to_i)
end
prefs = PYs.inject({}) do |m, v|
m[v[0]] = [] unless m.key?(v[0])
m[v[0]].push(v)
m
end
prefs.each do |pref, v|
v.sort_by { |v| v[1] }.each.with_index do |v2, i|
v2.push("#{pref.to_s.rjust(6, "0")}#{(i + 1).to_s.rjust(6, "0")}")
end
end
PYs.each do |v|
puts v[2]
end
|
[
"literal.number.integer.change",
"variable_access.subscript.index.change"
] | 1,017,757
| 1,017,758
|
u700923200
|
ruby
|
p03221
|
n,m = gets.split.map(&:to_i)
ary = []
rank = []
m.times do |i|
ary[i] = gets.split.map(&:to_i)
end
(1..n).each do |i|
rank[i] = []
end
m.times do |i|
p,y = ary[i]
rank[p].push([y,i])
end
(1..n).each do |p|
next if rank[p].nil?
rank[p].sort!
end
(1..n).each do |p|
next if rank[p].nil?
(rank[p].size).times do |r|
ary[rank[p][r][1]][2] = r+1
end
end
p rank
m.times do |i|
puts ary[i][0].to_s.rjust(6,"0") + ary[i][2].to_s.rjust(6,"0")
end
|
n,m = gets.split.map(&:to_i)
ary = []
rank = []
m.times do |i|
ary[i] = gets.split.map(&:to_i)
end
(1..n).each do |i|
rank[i] = []
end
m.times do |i|
p,y = ary[i]
rank[p].push([y,i])
end
(1..n).each do |p|
next if rank[p].nil?
rank[p].sort!
end
(1..n).each do |p|
next if rank[p].nil?
(rank[p].size).times do |r|
ary[rank[p][r][1]][2] = r+1
end
end
m.times do |i|
puts ary[i][0].to_s.rjust(6,"0") + ary[i][2].to_s.rjust(6,"0")
end
|
[
"call.remove"
] | 1,017,850
| 1,017,851
|
u622469330
|
ruby
|
p03221
|
n, m = gets.split.map(&:to_i)
ary = m.times.map { gets.split.map(&:to_i) }
years_by_pref = ary.group_by { |pref, year| pref }
year_index_by_pref = years_by_pref.map { |key,val| [key, val.sort.map.with_index.to_h] }.to_h
ary.each do |pref, year|
puts "%06d%06d" % [pref, year_index_by_pref[pref][year] + 1]
end
|
n, m = gets.split.map(&:to_i)
ary = m.times.map { gets.split.map(&:to_i) }
years_by_pref = ary.group_by { |pref, year| pref }
year_index_by_pref = years_by_pref.map { |key,val| [key, val.map(&:last).sort.map.with_index.to_h] }.to_h
ary.each do |pref, year|
puts "%06d%06d" % [pref, year_index_by_pref[pref][year] + 1]
end
|
[
"call.add"
] | 1,018,166
| 1,018,167
|
u321226359
|
ruby
|
p03221
|
class City
attr_accessor :prefec, :year, :spot, :rank
def initialize prefec,year,spot
self.prefec = prefec
self.year = year
# 自分が何番目に表示されるべきか
self.spot = spot
end
def getID
return "%06d%06d" % [self.prefec,self.rank]
end
end
datas = gets.split(" ").map{|nn|nn.to_i}
n = datas[0]
m = datas[1]
cities = []
m.times do|spot|
datas = gets.split(" ").map{|nn|nn.to_i}
cities << City.new(datas[0],datas[1],spot)
end
prefecs = {}
cities.each do|cit|
if prefecs[cit.prefec.to_s] != nil
prefecs[cit.prefec.to_s] << cit
else
prefecs[cit.prefec.to_s] = [cit]
end
end
prefecs.each do|cits|
cits[1].sort!{|a, b| a.year <=> b.year}
index = 1
cits[1].each do|cit|
cit.rank = index
index += 1
end
end
cities.sort!{|a, b| a.spot <=> b.spot}
p cities
cities.each do|cit|
puts cit.getID
end
|
class City
attr_accessor :prefec, :year, :spot, :rank
def initialize prefec,year,spot
self.prefec = prefec
self.year = year
# 自分が何番目に表示されるべきか
self.spot = spot
end
def getID
return "%06d%06d" % [self.prefec,self.rank]
end
end
datas = gets.split(" ").map{|nn|nn.to_i}
n = datas[0]
m = datas[1]
cities = []
m.times do|spot|
datas = gets.split(" ").map{|nn|nn.to_i}
cities << City.new(datas[0],datas[1],spot)
end
prefecs = {}
cities.each do|cit|
if prefecs[cit.prefec.to_s] != nil
prefecs[cit.prefec.to_s] << cit
else
prefecs[cit.prefec.to_s] = [cit]
end
end
prefecs.each do|cits|
cits[1].sort!{|a, b| a.year <=> b.year}
index = 1
cits[1].each do|cit|
cit.rank = index
index += 1
end
end
cities.sort!{|a, b| a.spot <=> b.spot}
cities.each do|cit|
puts cit.getID
end
|
[
"call.remove"
] | 1,018,266
| 1,018,267
|
u328174452
|
ruby
|
p03221
|
# https://abc113.contest.atcoder.jp/tasks/abc113_c
temp = gets.chomp.split(" ").map{|x| x.to_i}
prefecture_count = temp[0]
city_count = temp[1]
prefecture_city_array_database = Array.new().map{Array.new()}
#p prefecture_city_array_database
# 問題文の順番を保存
city_count.times do |i|
prefecture_city_array_database[i] = gets.chomp.split(" ").map{|x| x.to_i}
prefecture_city_array_database[i].push(i)
end
#p prefecture_city_array_database
prefecture_city_array_database.sort_by! {|x| [x[0],x[1]]}
#p prefecture_city_array_database
prefecture_number = 1
push_number = 1
# ソート時の順番を保存
city_count.times do |i|
if prefecture_number != prefecture_city_array_database[i][0]
push_number = 1
prefecture_number += 1
end
prefecture_city_array_database[i].push(push_number)
push_number += 1
end
prefecture_city_array_database.sort_by! {|x| x[2]}
#p prefecture_city_array_database
city_count.times do |i|
puts prefecture_city_array_database[i][0].to_s.rjust(6,"0") + prefecture_city_array_database[i][3].to_s.rjust(6,"0")
end
|
# https://abc113.contest.atcoder.jp/tasks/abc113_c
temp = gets.chomp.split(" ").map{|x| x.to_i}
prefecture_count = temp[0]
city_count = temp[1]
prefecture_city_array_database = Array.new().map{Array.new()}
#p prefecture_city_array_database
# 問題文の順番を保存
city_count.times do |i|
prefecture_city_array_database[i] = gets.chomp.split(" ").map{|x| x.to_i}
prefecture_city_array_database[i].push(i)
end
#p prefecture_city_array_database
prefecture_city_array_database.sort_by! {|x| [x[0],x[1]]}
#p prefecture_city_array_database
prefecture_number = 1
push_number = 1
# ソート時の順番を保存
city_count.times do |i|
loop do
if prefecture_number != prefecture_city_array_database[i][0]
push_number = 1
prefecture_number += 1
else
break
end
end
prefecture_city_array_database[i].push(push_number)
push_number += 1
end
prefecture_city_array_database.sort_by! {|x| x[2]}
#p prefecture_city_array_database
city_count.times do |i|
puts prefecture_city_array_database[i][0].to_s.rjust(6,"0") + prefecture_city_array_database[i][3].to_s.rjust(6,"0")
end
|
[
"call.add",
"control_flow.break.add"
] | 1,018,493
| 1,018,492
|
u565456867
|
ruby
|
p03221
|
n,m=gets.chomp.split(" ").map { |e| e.to_i }
py = []
m.times do |i|
p,y=gets.chomp.split(" ").map { |e| e.to_i }
py[i] = ("%06d" % p) + ("%06d" % y) + ("%06d" % i)
end
ans = Array.new(m)
hoge = "000001"
temp = 1
a = py.sort
for x in a do
if hoge != x[0..5]
hoge = x[0..5]
temp = 1
end
index = x[12..17].to_i
puts index
ans[index] = x[0..5] + ("%06d" % temp)
temp += 1
end
puts ans
|
n,m=gets.chomp.split(" ").map { |e| e.to_i }
py = []
m.times do |i|
p,y=gets.chomp.split(" ").map { |e| e.to_i }
py[i] = ("%06d" % p) + ("%010d" % y) + ("%06d" % i)
end
ans = Array.new(m)
hoge = "000001"
temp = 1
a = py.sort
for x in a do
if hoge != x[0..5]
hoge = x[0..5]
temp = 1
end
index = x[16..21].to_i
ans[index] = x[0..5] + ("%06d" % temp)
temp += 1
end
puts ans
|
[
"literal.string.change",
"assignment.value.change",
"expression.operation.binary.change",
"literal.number.integer.change",
"variable_access.subscript.index.change",
"call.remove"
] | 1,018,625
| 1,018,623
|
u267552846
|
ruby
|
p03221
|
def inputInts
gets.chomp.split(" ").map(&:to_i)
end
def getId(p, x)
format('%06d', p) + format('%06d', x)
end
@N, @M = inputInts
@pres = {}
@cities = {}
(1..@N).each do |i|
@pres[i] = []
end
(1..@M).each do |i|
p, y = inputInts
@pres[p] << i
@cities[i] = [p, y]
end
# sort cities by founded year
(1..@N).each do |i|
if @pres[i].length > 1
@pres[i].sort {|a, b| @cities[a][1] <=> @cities[b][1] }
end
end
# add indexes to cities
(1..@N).each do |i|
if @pres[i].length > 0
@pres[i].each_with_index do |city, i|
@cities[city] << i + 1
end
end
end
(1..@M).each do |i|
city = @cities[i]
puts getId(city[0], city[2])
end
|
def inputInts
gets.chomp.split(" ").map(&:to_i)
end
def getId(p, x)
format('%06d', p) + format('%06d', x)
end
@N, @M = inputInts
@pres = {}
@cities = {}
(1..@N).each do |i|
@pres[i] = []
end
(1..@M).each do |i|
p, y = inputInts
@pres[p] << i
@cities[i] = [p, y]
end
# sort cities by founded year
(1..@N).each do |i|
if @pres[i].length > 1
@pres[i].sort! {|a, b| @cities[a][1] <=> @cities[b][1] }
end
end
# add indexes to cities
(1..@N).each do |i|
if @pres[i].length > 0
@pres[i].each_with_index do |city, i|
@cities[city] << i + 1
end
end
end
(1..@M).each do |i|
city = @cities[i]
puts getId(city[0], city[2])
end
|
[
"call.suffix.change"
] | 1,018,668
| 1,018,669
|
u762955009
|
ruby
|
p03222
|
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
h,w,ki = gsmi #h<100, w<8, k<8
answer = Array.new(h+1){ Array.new(w){0} }
answer[0][0] = 1
mod = 1000000007
h.times do |i|
(2**(w-1)).times do |j|
flags = (w-1).times.map{|k| ((j>>k)%4)==3}.any?{|v| v==true}
perm = Array.new(w){|k| k }
(w-1).times {|k| (perm[k],perm[k+1] = perm[k+1], perm[k]) if (j>>k)&1==1}
w.times do |k|
answer[i+1][perm[k]] += answer[i][k]
answer[i+1][perm[k]] = answer[i+1][perm[k]] % mod
end
end
end
puts answer[h][ki-1]
|
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
h,w,ki = gsmi #h<100, w<8, k<8
answer = Array.new(h+1){ Array.new(w){0} }
answer[0][0] = 1
mod = 1000000007
h.times do |i|
(2**(w-1)).times do |j|
next if (w-1).times.map{|k| ((j>>k)%4)==3}.any?{|v| v==true}
perm = Array.new(w){|k| k }
(w-1).times {|k| (perm[k],perm[k+1] = perm[k+1], perm[k]) if (j>>k)&1==1}
w.times do |k|
answer[i+1][perm[k]] += answer[i][k]
answer[i+1][perm[k]] = answer[i+1][perm[k]] % mod
end
end
end
puts answer[h][ki-1]
|
[] | 1,018,797
| 1,018,798
|
u600153083
|
ruby
|
p03222
|
H, W, K = gets.split(' ').map(&:to_i)
MOD = 10 ** 9 + 7
dp = Array.new(H + 1){Array.new(W + 2, 0)}
dp[0][1] = 1
lines = []
if W == 1
puts 1
else
[0, 1].repeated_permutation(W - 1) do |line|
valid = true
0.upto(W - 2) do |i|
valid = false if line[i] == 1 && line[i + 1] == 1
end
lines.push([0] + line + [0]) if valid
end
1.upto(H) do |h|
lines.each do |line|
1.upto(W) do |j|
if line[j - 1] == 1
dp[h][j] += dp[h - 1][j - 1]
elsif line[j] == 1
dp[h][j] += dp[h - 1][j + 1]
else
dp[h][j] += dp[h - 1][j]
end
dp[h][j] %= MOD
end
end
end
end
puts dp[H][K]
|
H, W, K = gets.split(' ').map(&:to_i)
MOD = 10 ** 9 + 7
dp = Array.new(H + 1){Array.new(W + 2, 0)}
dp[0][1] = 1
lines = []
if W == 1
puts 1
else
[0, 1].repeated_permutation(W - 1) do |line|
valid = true
0.upto(W - 2) do |i|
valid = false if line[i] == 1 && line[i + 1] == 1
end
lines.push([0] + line + [0]) if valid
end
1.upto(H) do |h|
lines.each do |line|
1.upto(W) do |j|
if line[j - 1] == 1
dp[h][j] += dp[h - 1][j - 1]
elsif line[j] == 1
dp[h][j] += dp[h - 1][j + 1]
else
dp[h][j] += dp[h - 1][j]
end
dp[h][j] %= MOD
end
end
end
puts dp[H][K]
end
|
[] | 1,018,879
| 1,018,880
|
u548834738
|
ruby
|
p03212
|
n=gets.to_i
r=0
(3..8).each{|i|[3,5,7].repeated_permutation(i){|a|r+=1 if a.uniq.size==3&&a.join.to_i<=n}}
p r
|
n=gets.to_i
r=0
(3..9).each{|i|[3,5,7].repeated_permutation(i){|a|r+=1 if a.uniq.size==3&&a.join.to_i<=n}}
p r
|
[
"literal.number.integer.change"
] | 1,019,001
| 1,019,002
|
u280667879
|
ruby
|
p03212
|
n = gets.to_i
ary = []
ns = ['7','5','3']
(3..9).each do |i|
nums = ns.repeated_permutation(i).select{ |set| (ns - set).empty? }.map(&:join)
ary += nums
end
cnt = ary.select{|num| num <= n}
puts cnt.length
|
n = gets.to_i
ary = []
ns = ['7','5','3']
(3..9).each do |i|
nums = ns.repeated_permutation(i).select{ |set| (ns - set).empty? }.map(&:join)
ary += nums
end
cnt = ary.select{|num| num.to_i <= n}
puts cnt.length
|
[
"call.add"
] | 1,019,005
| 1,019,004
|
u236539492
|
ruby
|
p03212
|
n = gets.to_i
ary = []
ns = ['7','5','3']
(3..9).each do |i|
nums = ns.permutation(i).select{ |set| (ns - set).empty? }.map(&:join)
ary += nums
end
cnt = ary.select{|num| num <= n}
puts cnt.length
|
n = gets.to_i
ary = []
ns = ['7','5','3']
(3..9).each do |i|
nums = ns.repeated_permutation(i).select{ |set| (ns - set).empty? }.map(&:join)
ary += nums
end
cnt = ary.select{|num| num.to_i <= n}
puts cnt.length
|
[
"assignment.value.change",
"identifier.change",
"call.add"
] | 1,019,006
| 1,019,004
|
u236539492
|
ruby
|
p03221
|
n,m = gets.split.map(&:to_i)
a = []
ans = []
m.times do |i|
p,y = gets.split.map(&:to_i)
a << [p,y,i]
end
a = a.sort_by{|i,j,k|j}
b = Hash.new(0)
p a
a.each do |i,j,k|
b[i] += 1
ans << [("00000"+i.to_s)[-6..-1]+("00000"+b[i].to_s)[-6..-1],k]
end
ans.sort_by{|i,j|j}.each{|i,j|puts i}
|
n,m = gets.split.map(&:to_i)
a = []
ans = []
m.times do |i|
p,y = gets.split.map(&:to_i)
a << [p,y,i]
end
a = a.sort_by{|i,j,k|j}
b = Hash.new(0)
a.each do |i,j,k|
b[i] += 1
ans << [("00000"+i.to_s)[-6..-1]+("00000"+b[i].to_s)[-6..-1],k]
end
ans.sort_by{|i,j|j}.each{|i,j|puts i}
|
[
"call.remove"
] | 1,019,127
| 1,019,128
|
u506255180
|
ruby
|
p03221
|
# n 県数
# m 市数
n, m = gets.split.map(&:to_i)
ken = {}
data = m.times.map.with_index do |i|
p, y = gets.split.map(&:to_i)
ken[p] ||= []
ken[p] << [i, y]
[p, y]
end
# pp data
pp ken
ken.each do |p, value|
value
.sort_by {|(data_index, year)| year } # sort with year
.each.with_index(1) do |(data_index, year), order|
# pp [data_index, year, order]
# pp [p, data_index, order]
# pp ({ ken: p, data_index: data_index, order: order, year: data[data_index][1] })
data[data_index][2] = order
end
end
data.each do |(p, _y, o)|
puts "%06d%06d" % [p, o]
end
|
# n 県数
# m 市数
n, m = gets.split.map(&:to_i)
ken = {}
data = m.times.map.with_index do |i|
p, y = gets.split.map(&:to_i)
ken[p] ||= []
ken[p] << [i, y]
[p, y]
end
# pp data
# pp ken
ken.each do |p, value|
value
.sort_by {|(data_index, year)| year } # sort with year
.each.with_index(1) do |(data_index, year), order|
# pp ({ ken: p, data_index: data_index, order: order, year: data[data_index][1] })
data[data_index][2] = order
end
end
data.each do |(p, _y, o)|
puts "%06d%06d" % [p, o]
end
|
[
"call.remove"
] | 1,019,151
| 1,019,152
|
u614596051
|
ruby
|
p03221
|
n, m = gets.split.map(&:to_i)
cities = m.times.map{ gets.split.map(&:to_i) }.map.with_index{ |a, i| a.unshift(i) }
cities.sort!{ |a, b| (a[1] <=> b[1]).nonzero? || (a[2] <=> b[2]) }
p cities
ans = []
k = 1
pref = 1
cities.each do |i, p, y|
if pref != p
pref = p
k = 1
end
ans << [i, p.to_s.rjust(6, '0') + k.to_s.rjust(6, '0')]
k += 1
end
ans.sort_by{ |i, _| i }.each{ |_, s| puts s }
|
n, m = gets.split.map(&:to_i)
cities = m.times.map{ gets.split.map(&:to_i) }.map.with_index{ |a, i| a.unshift(i) }
cities.sort!{ |a, b| (a[1] <=> b[1]).nonzero? || (a[2] <=> b[2]) }
ans = []
k = 1
pref = 1
cities.each do |i, p, y|
if pref != p
pref = p
k = 1
end
ans << [i, p.to_s.rjust(6, '0') + k.to_s.rjust(6, '0')]
k += 1
end
ans.sort_by{ |i, _| i }.each{ |_, s| puts s }
|
[
"call.remove"
] | 1,019,401
| 1,019,402
|
u331906013
|
ruby
|
p03221
|
n, m = gets.split.map(&:to_i)
input = Array.new(m)
m.times do |i|
x, y = gets.split.map(&:to_i)
input[i] = [x, y, i + 1]
end
sorted = input.sort_by { |x| x[1] }
nums = Array.new(m + 1, 1)
ans = Array.new(m)
sorted.each do |x, y, i|
ans[i - 1] = "#{x}".rjust(6, "0") + "#{nums[x]}".rjust(6, "0")
nums[x] += 1
end
ans.each { |x| puts x }
|
n, m = gets.split.map(&:to_i)
input = Array.new(m)
m.times do |i|
x, y = gets.split.map(&:to_i)
input[i] = [x, y, i]
end
sorted = input.sort_by { |x| x[1] }
nums = Array.new(n + 1, 1)
ans = Array.new(m)
sorted.each do |x, y, i|
ans[i] = "#{x}".rjust(6, "0") + "#{nums[x]}".rjust(6, "0")
nums[x] += 1
end
ans.each { |x| puts x }
|
[
"expression.operation.binary.remove",
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 1,019,438
| 1,019,439
|
u300096598
|
ruby
|
p03221
|
_n, m = gets.chomp.split(' ').map(&:to_i)
list = []
hash = {}
m.times.each do
pi, yi = gets.chomp.split(' ').map(&:to_i)
if hash.key?(pi)
hash[pi] << yi
else
hash[pi] = [yi]
end
list << [pi, yi]
end
sorted = {}
list.each do |pi, yi|
unless sorted[pi]
hash[pi] = hash[pi].sort.map.with_index(1) do |x, i|
[x, i]
end.to_h
sorted[pi] = true
end
idx = hash[pi][yi]
puts "#{format('%06d', pi)}#{format('%06d', idx + 1)}"
end
|
_n, m = gets.chomp.split(' ').map(&:to_i)
list = []
hash = {}
m.times.each do
pi, yi = gets.chomp.split(' ').map(&:to_i)
if hash.key?(pi)
hash[pi] << yi
else
hash[pi] = [yi]
end
list << [pi, yi]
end
sorted = {}
list.each do |pi, yi|
unless sorted[pi]
hash[pi] = hash[pi].sort.map.with_index(1) do |x, i|
[x, i]
end.to_h
sorted[pi] = true
end
idx = hash[pi][yi]
puts "#{format('%06d', pi)}#{format('%06d', idx)}"
end
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 1,019,456
| 1,019,457
|
u823451365
|
ruby
|
p03227
|
S = gets.chpmp
if S.size == 2
puts S
else
puts S.reverse
end
|
S = gets.chomp
if S.size == 2
puts S
else
puts S.reverse
end
|
[
"assignment.value.change",
"identifier.change"
] | 1,019,897
| 1,019,898
|
u740836226
|
ruby
|
p03227
|
s = gets.split("\n")[0]
if s.size == 3
p s.reverse
else
p s
end
|
s = gets.split("\n")[0]
if s.size == 3
puts s.reverse
else
puts s
end
|
[
"call.function.change",
"io.output.change"
] | 1,019,928
| 1,019,929
|
u916219216
|
ruby
|
p03227
|
s=STDIN.gets.chomp
if s>2
puts s.reverse
else
puts s
end
|
s=STDIN.gets.chomp
if s.size > 2
puts s.reverse
else
puts s
end
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 1,019,940
| 1,019,941
|
u993842615
|
ruby
|
p03227
|
s=STDIN.gets
if s.size>2
puts s.reverse
else
puts s
end
|
s=STDIN.gets.chomp
if s.size > 2
puts s.reverse
else
puts s
end
|
[
"call.add"
] | 1,019,942
| 1,019,941
|
u993842615
|
ruby
|
p03227
|
S = gets
puts S.size == 2 ? S : S.reverse
|
S = gets.chomp
puts S.size == 2 ? S : S.reverse
|
[
"call.add"
] | 1,020,024
| 1,020,025
|
u503890246
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.