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 |
|---|---|---|---|---|---|---|---|
p02881
|
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() 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
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )スヤァ… ###########
n=gi
require 'prime'
ar=[]
np=n.prime_division
# np.each do |a,b|
# temp=[1]
# b.times do |i|
# temp<<a*(i+1)
# end
# ar<<temp
# end
def div(pr,k=0)
Enumerator.new do |en|
if pr.size == k
en << 1
else
p,e = pr[k]
div(pr,k+1).each do |d|
(e+1).times do |e1|
en << (p**e1) * d
end
end
end
end
end
divs=div(np).to_a
#puts divs.to_s
sq=Math.sqrt(n).to_i
res=1
divs.each do |d|
if d<=sq
res=d
else
break
end
end
puts res+(n/res)-2
|
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() 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
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )スヤァ… ###########
n=gi
require 'prime'
ar=[]
np=n.prime_division
# np.each do |a,b|
# temp=[1]
# b.times do |i|
# temp<<a*(i+1)
# end
# ar<<temp
# end
def div(pr,k=0)
Enumerator.new do |en|
if pr.size == k
en << 1
else
p,e = pr[k]
div(pr,k+1).each do |d|
(e+1).times do |e1|
en << (p**e1) * d
end
end
end
end
end
divs=div(np).to_a.sort
#puts divs.to_s
sq=Math.sqrt(n).to_i
res=1
divs.each do |d|
if d<=sq
res=d
else
break
end
end
puts res+(n/res)-2
|
[
"call.add"
] | 681,471
| 681,472
|
u385631112
|
ruby
|
p02881
|
require 'prime'
a = gets.to_i
class Integer
def my_divisor_list2
return [1] if self == 1
Prime.prime_division(self).map do |e|
Array.new(e[1]+1).map.with_index do |element, i|
e[0]**i
end
end.inject{|p,q| p.product(q)}.map do |a|
[a].flatten.inject(&:*)
end.sort
end
end
b = a.my_divisor_list2
c = b.count / 2
x = b[c]
y = b[c - 1]
unless b.count % 2 == 0
puts x + x - 2
end
if x == 1 && y == 1
puts x + y - 1
exit
else
puts x + y - 2
end
|
require 'prime'
a = gets.to_i
class Integer
def my_divisor_list2
return [1] if self == 1
Prime.prime_division(self).map do |e|
Array.new(e[1]+1).map.with_index do |element, i|
e[0]**i
end
end.inject{|p,q| p.product(q)}.map do |a|
[a].flatten.inject(&:*)
end.sort
end
end
b = a.my_divisor_list2
c = b.count / 2
x = b[c]
y = b[c - 1]
unless b.count % 2 == 0
puts x + x - 2
exit
end
if x == 1 && y == 1
puts x + y - 1
exit
else
puts x + y - 2
end
|
[
"control_flow.exit.add"
] | 681,567
| 681,568
|
u973744316
|
ruby
|
p02881
|
n = gets.chomp.to_i
mn = Math.sqrt(n)
i=1
arr=[]
while i<mn do
if n%i==0 then
arr<<i
end
i+=1
end
puts ((arr[arr.length-1]-1) + ( n / arr[arr.length-1] )-1)
|
n = gets.chomp.to_i
mn = Math.sqrt(n)
i=1
arr=[]
while i<=mn do
if n%i==0 then
arr<<i
end
i+=1
end
puts ((arr[arr.length-1]-1) + ( n / arr[arr.length-1] )-1)
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 681,805
| 681,806
|
u281662621
|
ruby
|
p02881
|
N = gets.chomp.to_i
n = Math.sqrt(N)
i = 2
max = 1
while i < n
if N % i == 0
max = i
end
i += 1
end
answer = (N/max) + max - 2
puts answer
|
N = gets.chomp.to_i
n = Math.sqrt(N)
i = 2
max = 1
while i <= n
if N % i == 0
max = i
end
i += 1
end
answer = (N/max) + max - 2
puts answer
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 682,029
| 682,030
|
u349832549
|
ruby
|
p02882
|
a, b, x = gets.chomp.split(" ").map(&:to_f)
theta = 0.0
capacity = a * a * b
if (capacity / 2.0) < x then
theta = Math.atan(2.0 * (capacity - x / a**3))
else
theta = Math.atan((a * b * b) / (2.0 * x))
end
puts theta * 180.0 / Math::PI
|
a, b, x = gets.chomp.split(" ").map(&:to_f)
theta = 0.0
capacity = a * a * b
if (capacity / 2.0) < x then
theta = Math.atan(2.0 * (capacity - x) / a**3)
else
theta = Math.atan((a * b * b) / (2.0 * x))
end
puts theta * 180.0 / Math::PI
|
[
"call.arguments.change"
] | 682,164
| 682,165
|
u466332671
|
ruby
|
p02881
|
n = gets.to_i
a = Math.sqrt(n).to_i
while n % a == 0
a -= 1
end
b = n / a
puts a + b - 2
|
n = gets.to_i
a = Math.sqrt(n).to_i
while n % a != 0
a -= 1
end
b = n / a
puts a + b - 2
|
[
"misc.opposites",
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 682,694
| 682,695
|
u634482428
|
ruby
|
p02882
|
a, b, x = gets.split.map!(&:to_i)
ans_rad = if x >= a * a * b / 2.0
Math.atan(2.0 * (a * a * b - x) / (a * a * a))
else
Math.atan(a * b * b / 2.0 * x)
end
puts ans_rad * (180 / Math::PI)
|
a, b, x = gets.split.map!(&:to_i)
ans_rad = if x > a * a * b / 2.0
Math.atan(2.0 * (a * a * b - x) / (a * a * a))
else
Math.atan(a * b * b / (2.0 * x))
end
puts ans_rad * 180 / Math::PI
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 682,912
| 682,913
|
u638516820
|
ruby
|
p02882
|
input = gets.chomp.split.map(&:to_i)
a, b, x = input
s = x / a
if (a * b / 2) <= s
h = 2 * (a * b - s) / a
re = Math.atan2(h, a)
else
m = 2 * s / b
re = Math.atan2(b, m)
end
de = re / (2 * Math::PI) * 360
puts de
|
input = gets.chomp.split.map(&:to_f)
a, b, x = input
s = x / a
if (a * b / 2) <= s
h = 2 * (a * b - s) / a
re = Math.atan2(h, a)
else
m = 2 * s / b
re = Math.atan2(b, m)
end
de = re / (2 * Math::PI) * 360
puts de
|
[
"assignment.value.change",
"call.arguments.change"
] | 682,924
| 682,925
|
u447059782
|
ruby
|
p02882
|
a,b,x = gets.split.map(&:to_f)
y = x/a/a
if b/2 < y
t = Math.atan y/a
else
z = 2*a*y/b
t = Math.atan b/z
end
p t/Math::PI*180
|
a,b,x = gets.split.map(&:to_f)
y = x/a/a
if b/2 < y
t = Math.atan (b-y)*2/a
else
z = 2*a*y/b
t = Math.atan b/z
end
p t/Math::PI*180
|
[
"assignment.change"
] | 683,003
| 683,004
|
u353917577
|
ruby
|
p02882
|
a, b, x = gets.chomp.split.map(&:to_f)
z = (a**2)*b # 容器の体積
if z / 2.0 <= x # x が半分以上
n = z - x
t = (2.0 * n)/(a**2)
p (Math.atan(t/a) * 180 / Math::PI)
exit
else
t = (2.0 * x)/(a * b)
p (Math.atan(a/t) * 180 / Math::PI)
end
|
a, b, x = gets.chomp.split.map(&:to_i)
z = (a**2)*b # 容器の体積
if z / 2.0 <= x # x が半分以上
n = z - x
t = (2.0 * n)/(a**2)
p (Math.atan(t/a) * 180 / Math::PI)
exit
else
t = (2.0 * x)/(a * b)
p (Math.atan(b/t) * 180 / Math::PI)
end
|
[
"assignment.value.change",
"call.arguments.change",
"identifier.change",
"expression.operation.binary.change"
] | 683,437
| 683,438
|
u195257137
|
ruby
|
p02882
|
str = gets.split
A,B,X = str[0].to_i, str[1].to_i, str[2].to_i
V = A*A*B
V2 = V/2.0
if X > V2
c = (V-X)/(A*A*0.5)
d = Math.atan(c/A)
answer = d / Math::PI * 180
else
c = X/(A*B*0.5)
d = Math.atan(c/B)
answer = 90 - (d / Math::PI * 180)
end
puts c,d,answer
|
str = gets.split
A,B,X = str[0].to_i, str[1].to_i, str[2].to_i
V = A*A*B
V2 = V/2.0
if X > V2
c = (V-X)/(A*A*0.5)
d = Math.atan(c/A)
answer = d / Math::PI * 180
else
c = X/(A*B*0.5)
d = Math.atan(c/B)
answer = 90 - (d / Math::PI * 180)
end
puts answer
|
[
"call.arguments.change"
] | 683,485
| 683,486
|
u349832549
|
ruby
|
p02882
|
a,b,x = gets.split(' ').map(&:to_i)
if b-2*x.to_f/(a*a) <= 0
puts Math.atan2((b-x.to_f/(a*a))*2, a) * 180 / Math::PI
else
puts Math.atan2(b, x.to_f/(a*b)) * 180 / Math::PI
end
|
a,b,x = gets.split(' ').map(&:to_i)
if b-2*x.to_f/(a*a) <= 0
puts Math.atan2((b-x.to_f/(a*a))*2, a) * 180 / Math::PI
else
puts Math.atan2(b, 2*x.to_f/(a*b)) * 180 / Math::PI
end
|
[
"expression.operation.binary.add"
] | 683,549
| 683,550
|
u634482428
|
ruby
|
p02882
|
include Math
a, b, x = gets.chomp.split(" ").map(&:to_f)
h = x / a**2.to_f # d: 水の深さ
s = a * b.to_f # s: 水筒の横1面の面積
sw = a * h.to_f # sw: 横から見た際の面積
c = 0.0 # 傾けた水が作る直角三角形の不明な高さ
if sw == s / 2 then
puts atan( a / b ) * 180 / PI
elsif sw < s / 2 then
c = 2 * sw / b
puts atan( b / c ) * 180 / PI
else
c = 2 * sw / a
puts atan( c / a ) * 180 / PI
end
|
include Math
a, b, x = gets.chomp.split(" ").map(&:to_f)
h = x / a**2.to_f # d: 水の深さ
s = a * b.to_f # s: 水筒の横1面の面積
sw = a * h.to_f # sw: 横から見た際の面積
c = 0.0 # 傾けた水が作る直角三角形の不明な高さ
if sw == s / 2 then
puts atan( a / b ) * 180 / PI
elsif sw < s / 2 then
c = 2 * sw / b
puts atan( b / c ) * 180 / PI
else
sw = s - sw
c = 2 * sw / a
puts atan( c / a ) * 180 / PI
end
|
[
"assignment.add"
] | 683,638
| 683,639
|
u226855113
|
ruby
|
p02882
|
a,b,x = gets.chomp.split(" ").map{|i|i = i.to_i}
#double radian = Math.atan2(y2 - y,x2 - x);
#return radian;
#double degree = arcLineMargineRadian * 180 / Math.PI;
# 台形になるとき
if ( x > ((a.to_f)*b)/2 )
xx =((x.to_f)*2)/a
z=(xx/a-b)
puts (Math.atan2((b-z),a) * 180.to_f)/ Math::PI
# 三角形となるとき
else
xx =( (x.to_f)*2)/a
z=xx/b
puts (Math.atan2(b,z) * 180.to_f)/ Math::PI
end
|
a,b,x = gets.chomp.split(" ").map{|i|i = i.to_i}
#double radian = Math.atan2(y2 - y,x2 - x);
#return radian;
#double degree = arcLineMargineRadian * 180 / Math.PI;
# 台形になるとき
if ( x > ((a.to_f * a)*b)/2 )
xx =((x.to_f)*2)/a
z=(xx/a-b)
puts (Math.atan2((b-z),a) * 180.to_f)/ Math::PI
# 三角形となるとき
else
xx =( (x.to_f)*2)/a
z=xx/b
puts (Math.atan2(b,z) * 180.to_f)/ Math::PI
end
|
[
"control_flow.branch.if.condition.change"
] | 683,766
| 683,767
|
u281662621
|
ruby
|
p02883
|
#input of int(split by space)
def get_i()
return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
return bool ? y : n
end
#create of array
def array(size1,init=nil,size2=-1)
if size2==-1
return Array.new(size1){init}
else
return Array.new(size2){Array.new(size1){init}}
end
end
def max(a,b)
return a>b ? a : b
end
def min(a,b)
return a>b ? b : a
end
INF=Float::INFINITY
N,K=get_i
A=get_i.sort{|x,y| y<=>x}
F=get_i.sort
def fulfil?(x)
res=0
N.times do|i|
res+=A[i]-x/F[i]
end
return res<=K
end
head=-1
tail=A[0]*F[-1]+1
while tail-head>1
mid=head+(tail-head)/2
if fulfil?(mid)
tail=mid
else
head=mid
end
end
puts tail
|
#input of int(split by space)
def get_i()
return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
return bool ? y : n
end
#create of array
def array(size1,init=nil,size2=-1)
if size2==-1
return Array.new(size1){init}
else
return Array.new(size2){Array.new(size1){init}}
end
end
def max(a,b)
return a>b ? a : b
end
def min(a,b)
return a>b ? b : a
end
INF=Float::INFINITY
N,K=get_i
A=get_i.sort{|x,y| y<=>x}
F=get_i.sort
def fulfil?(x)
res=0
N.times do|i|
res+=max(A[i]-x/F[i],0)
end
return res<=K
end
head=-1
tail=A[0]*F[-1]+1
while tail-head>1
mid=head+(tail-head)/2
if fulfil?(mid)
tail=mid
else
head=mid
end
end
puts tail
|
[
"call.add",
"call.arguments.add"
] | 684,133
| 684,134
|
u415400221
|
ruby
|
p02883
|
N,K= gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
F = gets.split.map(&:to_i).sort.reverse
max_time = A.map.with_index{|a,i| a * F[i]}.max
puts (0...max_time).bsearch{|x|
k = K
N.times do |i|
next if A[i] * F[i] <= x
k -= A[i] - (x / F[i])
break if k < 0
end
k >= 0
}
|
N,K= gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
F = gets.split.map(&:to_i).sort.reverse
max_time = A.map.with_index{|a,i| a * F[i]}.max
puts (0...(max_time+1)).bsearch{|x|
k = K
N.times do |i|
next if A[i] * F[i] <= x
k -= A[i] - (x / F[i])
break if k < 0
end
k >= 0
}
|
[
"call.arguments.change"
] | 684,312
| 684,313
|
u299761130
|
ruby
|
p02883
|
N,K= gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
F = gets.split.map(&:to_i).sort.reverse
max_time = A.map.with_index{|a,i| a * F[i]}.max
puts (0...max_time).bsearch{|x|
k = K
N.times do |i|
next if A[i] * F[i] <= x
k -= A[i] - (x / F[i])
break if k < 0
end
k >= 0
}
|
N,K= gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
F = gets.split.map(&:to_i).sort.reverse
max_time = A.map.with_index{|a,i| a * F[i]}.max
puts (0...(max_time+100)).bsearch{|x|
k = K
N.times do |i|
next if A[i] * F[i] <= x
k -= A[i] - (x / F[i])
break if k < 0
end
k >= 0
}
|
[
"call.arguments.change"
] | 684,312
| 684,314
|
u299761130
|
ruby
|
p02885
|
a, b = gets.chomp.split.map(&:to_i)
ans = a - 2*b
if ans < 0
puts "0"
end
puts ans
|
a, b = gets.chomp.split.map(&:to_i)
ans = a - 2*b
if ans < 0
puts "0"
else
puts ans
end
|
[] | 685,327
| 685,328
|
u552761221
|
ruby
|
p02885
|
a, b = gets.split.map(&:to_i)
puts a - (b * 2)
|
a, b = gets.split.map(&:to_i)
puts [a - (b * 2), 0].max
|
[
"call.arguments.change",
"call.add"
] | 685,357
| 685,358
|
u641383521
|
ruby
|
p02885
|
a,b = gets.chomp.split.map(&:to_i)
puts (a- 2*b) < 0 ? a - 2 * b : 0
|
a,b = gets.chomp.split.map(&:to_i)
puts (a- 2*b) > 0 ? a - 2 * b : 0
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 685,717
| 685,718
|
u191196346
|
ruby
|
p02885
|
p gets.split.inject{|a,b|a.to_i-2*b.to_i}
|
p gets.split.inject{|a,b|[a.to_i-2*b.to_i,0].max}
|
[
"call.arguments.change",
"call.add"
] | 685,719
| 685,720
|
u353917577
|
ruby
|
p02885
|
a,b=gets.chomp.to_i
puts a-b*2 <= 0 ? 0 : a-b*2
|
a,b=gets.chomp.split.map(&:to_i)
puts a-b*2 <= 0 ? 0 : a-b*2
|
[
"assignment.value.change",
"identifier.change",
"call.add"
] | 685,897
| 685,898
|
u585819925
|
ruby
|
p02885
|
a,b=gets.split.map(&:to_i)
puts [a,a-2*b].min
|
a,b=gets.split.map(&:to_i)
puts [0,a-2*b].max
|
[
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change",
"io.output.change",
"misc.opposites",
"identifier.change"
] | 686,060
| 686,061
|
u926099741
|
ruby
|
p02885
|
a,b = gets.splti(" ").map(&:to_i)
puts ((a < (b << 1)) ? 0 : a - (b << 1))
|
a,b = gets.split(" ").map(&:to_i)
puts ((a < (b << 1)) ? 0 : a - (b << 1))
|
[
"assignment.value.change",
"identifier.change"
] | 686,233
| 686,234
|
u538351278
|
ruby
|
p02886
|
n = gets.to_i
d = gets.split.map(&:to_i)
sum = 0
d.combinaton(2) do |x, y|
sum += x * y
end
puts sum
|
n = gets.to_i
d = gets.split.map(&:to_i)
sum = 0
d.combination(2) do |x, y|
sum += x * y
end
puts sum
|
[
"identifier.change"
] | 686,459
| 686,460
|
u920244601
|
ruby
|
p02886
|
n = gets.to_i
d = gets.chomp.split.map(&:to_i)
sum = 0
d.combinaton(2) do |x, y|
sum += x * y
end
puts sum
|
n = gets.to_i
d = gets.split.map(&:to_i)
sum = 0
d.combination(2) do |x, y|
sum += x * y
end
puts sum
|
[
"call.remove",
"identifier.change"
] | 686,461
| 686,460
|
u920244601
|
ruby
|
p02886
|
n = gets.chomp.to_i
d = gets.chomp.split.map(&:to_i)
combination = d.combination(2).to_a
combination_sum = (0...(n * (n - 1)/ 2)).map do |i|
combination[i].inject(:+)
end
puts combination_sum.inject(:+)
|
n = gets.chomp.to_i
d = gets.chomp.split.map(&:to_i)
combination = d.combination(2).to_a
combination_sum = (0...(n * (n - 1)/ 2)).map do |i|
combination[i].inject(:*)
end
puts combination_sum.inject(:+)
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"call.arguments.change"
] | 686,863
| 686,864
|
u895926909
|
ruby
|
p02886
|
n,*d=$<.read.split.map(&:to_i)
a=0
p d
for i in 0...n
for j in 0...n
a+=d[i]*d[j] if i!=j
end
end
p a/2
|
n,*d=$<.read.split.map(&:to_i)
a=0
for i in 0...n
for j in 0...n
a+=d[i]*d[j] if i!=j
end
end
p a/2
|
[
"call.remove"
] | 687,011
| 687,012
|
u408023666
|
ruby
|
p02886
|
N = gets.to_i
takoyaki = gets.split(' ').map(&:to_i)
oishisa_total = 0
oishisa = 0
a = 0
while a < N do
b = a + 1
while b < N do
oishisa = oishisa + takoyaki[a] * takoyaki[b]
b = b + 1
end
oishisa_total = oishisa_total + oishisa
oishisa = 0
a = a + 1
puts oishisa_total
end
puts oishisa_total
|
N = gets.to_i
takoyaki = gets.split(' ').map(&:to_i)
oishisa_total = 0
oishisa = 0
a = 0
while a < N do
b = a + 1
while b < N do
oishisa = oishisa + takoyaki[a] * takoyaki[b]
b = b + 1
end
oishisa_total = oishisa_total + oishisa
oishisa = 0
a = a + 1
end
puts oishisa_total
|
[
"call.remove"
] | 687,661
| 687,662
|
u729372946
|
ruby
|
p02887
|
n = gets.chomp.to_i
s = gets.chomp.to_i
ans = 1
s.each do |i|
if s[0] != i
ans += 1
s[0] = i
end
end
puts ans
|
n = gets.chomp.to_i
s = gets.chomp.split("")
ans = 1
s.each do |i|
if s[0] != i
ans += 1
s[0] = i
end
end
puts ans
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.add"
] | 687,774
| 687,775
|
u895926909
|
ruby
|
p02887
|
one = gets
two = gets.split("")
res = [two.shift]
two.each do |s|
res.last != s ? res.push(s) : next
end
puts res.count.to_s
|
one = gets
two = gets.chomp.split("")
res = [two.shift]
two.each do |s|
res.last != s ? res.push(s) : next
end
puts res.count
|
[
"call.add",
"call.remove"
] | 687,901
| 687,902
|
u403537991
|
ruby
|
p02887
|
one = gets
two = gets.split("")
res = [two.shift]
two.each do |s|
res.last != s ? res.push(s) : next
end
puts res.count
|
one = gets
two = gets.chomp.split("")
res = [two.shift]
two.each do |s|
res.last != s ? res.push(s) : next
end
puts res.count
|
[
"call.add"
] | 687,903
| 687,902
|
u403537991
|
ruby
|
p02887
|
gets
puts gets.squeeze.length
|
gets
puts gets.chomp.squeeze.length
|
[
"call.add"
] | 687,974
| 687,975
|
u802371628
|
ruby
|
p02887
|
n=gets.chomp.to_i
s=gets.chomp
puts s.squeeze.lenth
|
n=gets.chomp.to_i
s=gets.chomp
puts s.squeeze.length
|
[
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 688,004
| 688,005
|
u585819925
|
ruby
|
p02887
|
gets
p gets.gsub(/(.)(?=\1)/,"").size
|
gets
p gets.chomp.gsub(/(.)(?=\1)/,"").size
|
[
"call.add"
] | 688,068
| 688,069
|
u353917577
|
ruby
|
p02887
|
n = gets.to_i
s = gets.chomp.to_s
puts s.sqeeze
|
n = gets.to_i
s = gets.chomp.to_s
puts s.squeeze.length
|
[
"identifier.change",
"call.arguments.change",
"io.output.change",
"call.add"
] | 688,089
| 688,090
|
u932417742
|
ruby
|
p02887
|
n=gets.to_i
s=gets.chomp
i=0
l=0
while i<n
j=i
j+=1 while s[i]==s[j+1]
l+=1
i=j+1
end
|
n=gets.to_i
s=gets.chomp
i=0
l=0
while i<n
j=i
j+=1 while s[i]==s[j+1]
l+=1
i=j+1
end
puts l
|
[
"call.add"
] | 688,097
| 688,098
|
u883824971
|
ruby
|
p02887
|
N = gets.to_i
S = gets.strip
puts S.split('').chunk(&:itself).size
|
N = gets.to_i
S = gets.strip
puts S.split('').chunk(&:itself).count
|
[
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 688,199
| 688,200
|
u304198114
|
ruby
|
p02887
|
n=gets.to_i
s=gets
print s.squeeze.length
|
n=gets.to_i
s=gets.chomp
print s.squeeze.size
|
[
"call.add",
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 688,217
| 688,218
|
u882389182
|
ruby
|
p02887
|
s = gets.chomp
d=p
ans=0
s.chars.each do |c|
ans += 1 if d!=c
d = c
end
p ans
|
gets
s = gets.chomp
d=p
ans=0
s.chars.each do |c|
ans += 1 if d!=c
d = c
end
p ans
|
[] | 688,282
| 688,283
|
u976045235
|
ruby
|
p02887
|
a = gets.to_i
slime = gets.squeeze.length
p slime
|
a = gets.to_i
slime = gets.chomp.squeeze.length
p slime
|
[
"call.add"
] | 688,302
| 688,303
|
u945412921
|
ruby
|
p02887
|
a = gets.to_i
slime =gets
result = slime.squeeze.length
p result
|
a = gets.to_i
slime = gets.chomp.squeeze.length
p slime
|
[
"identifier.change",
"call.arguments.change"
] | 688,304
| 688,303
|
u945412921
|
ruby
|
p02887
|
gets
s = gets.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
p res
|
gets
s = gets.chomp.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
puts res
|
[
"call.add",
"call.function.change",
"io.output.change"
] | 688,339
| 688,340
|
u631543593
|
ruby
|
p02887
|
gets
s = gets.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
puts res
|
gets
s = gets.chomp.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
puts res
|
[
"call.add"
] | 688,341
| 688,340
|
u631543593
|
ruby
|
p02887
|
gets
s = gets.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
p res
|
gets
s = gets.chomp.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
puts res
|
[
"call.add",
"call.function.change",
"io.output.change"
] | 688,342
| 688,340
|
u631543593
|
ruby
|
p02887
|
gets
s = gets.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
print res
|
gets
s = gets.chomp.chars
res = 0
before = nil
s.each() do |a|
res += 1 if a != before
before = a
end
puts res
|
[
"call.add",
"identifier.change"
] | 688,343
| 688,340
|
u631543593
|
ruby
|
p02887
|
_N = gets.chomp.to_i
string = gets
ans = 0
be = ''
string.chars do |c|
next if c == be
ans += 1
be = c
end
p ans
|
_N = gets.chomp.to_i
string = gets.chomp
ans = 0
be = ''
string.chars do |c|
next if c == be
ans += 1
be = c
end
puts ans
|
[
"call.add",
"call.function.change",
"io.output.change"
] | 688,458
| 688,459
|
u987208743
|
ruby
|
p02888
|
N = gets.to_i
L = gets.chomp.split(" ").map(&:to_i).sort.reverse
count = 0
(N - 2).times do |i|
j = i + 1
k = n - 1
while j < k do
if L[i] < L[j] + L[k]
count += k - j
j += 1
else
k -= 1
end
end
end
puts count
|
N = gets.to_i
L = gets.chomp.split(" ").map(&:to_i).sort.reverse
count = 0
(N - 2).times do |i|
j = i + 1
k = N - 1
while j < k do
if L[i] < L[j] + L[k]
count += k - j
j += 1
else
k -= 1
end
end
end
puts count
|
[
"assignment.value.change",
"expression.operation.binary.change"
] | 688,735
| 688,736
|
u729911058
|
ruby
|
p02888
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
c_over_index = candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort.reverse
# puts sticks.inspect
# puts ""
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a - b
# puts "--------"
# puts c_candidates.inspect
# puts "a: #{a}, b: #{b}, a - b: #{t}"
c_over_index = c_candidates.bsearch_index { |c| c <= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
[
"call.add",
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change",
"identifier.change",
"expression.operator.compare.change"
] | 688,868
| 688,869
|
u094532861
|
ruby
|
p02888
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
c_over_index = candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
# 1622 ms, 2040 KB
# https://atcoder.jp/contests/abc143/submissions/12694269
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
# puts sticks.inspect
# puts ""
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
# puts "--------"
# puts c_candidates.inspect
# puts "a: #{a}, b: #{b}, a + b: #{t}"
c_over_index = c_candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
[
"assignment.value.change",
"identifier.change"
] | 688,868
| 688,870
|
u094532861
|
ruby
|
p02888
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
c_over_index = candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
# puts sticks.inspect
# puts ""
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
# puts "--------"
# puts c_candidates.inspect
# puts "a: #{a}, b: #{b}, a + b: #{t}"
c_over_index = c_candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
[
"assignment.value.change",
"identifier.change"
] | 688,868
| 688,872
|
u094532861
|
ruby
|
p02888
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
c_over_index = candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d
n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort
count = 0
0.upto(n - 3) do |i|
a = l[i]
(i + 1).upto(n - 2) do |j|
b = l[j]
c_candidates = l[(j + 1)..(n - 1)]
t = a + b
c_over_index = c_candidates.bsearch_index { |c| c >= t }
if c_over_index.nil?
count += (n - 1) - j
else
count += c_over_index
end
end
end
puts count
|
[
"assignment.value.change",
"identifier.change"
] | 688,868
| 688,874
|
u094532861
|
ruby
|
p02888
|
n = gets.to_i
l = gets.split.map(&:to_i).sort
p l
ans = 0
(n-2).times do |i|
k = i + 2
(i+1).upto(n-2) do |j|
k += 1 while k < n && l[k] < l[i] + l[j]
ans += k - 1 - j
#p [ans,i,j,k]
end
end
puts ans
|
n = gets.to_i
l = gets.split.map(&:to_i).sort
#p l
ans = 0
(n-2).times do |i|
k = i + 2
(i+1).upto(n-2) do |j|
k += 1 while k < n && l[k] < l[i] + l[j]
ans += k - 1 - j
#p [ans,i,j,k]
end
end
puts ans
|
[
"call.remove"
] | 688,988
| 688,989
|
u692254521
|
ruby
|
p02888
|
ticks_length = gets.chomp.to_i
sticks = gets.chomp.split.map(&:to_i)
sticks_asc = sticks.sort_by{ |stick| stick }
result = 0
(sticks_length - 1).downto(2) do |i|
(i - 1).downto(1) do |j|
# 2辺が固定されたのであと1本の必要な長さがわかる
min_length = sticks_asc[i] - sticks_asc[j]
# 短すぎる枝の数
small_stick_num = sticks_asc.index {|stick| min_length < stick }
result += [j - small_stick_num, 0].max
end
end
puts result
|
sticks_length = gets.chomp.to_i
sticks = gets.chomp.split.map(&:to_i)
sticks_asc = sticks.sort_by{ |stick| stick }
result = 0
(sticks_length - 1).downto(2) do |i|
(i - 1).downto(1) do |j|
# 2辺が固定されたのであと1本の必要な長さがわかる
min_length = sticks_asc[i] - sticks_asc[j]
# 短すぎる枝の数
small_stick_num = sticks_asc.bsearch_index {|stick| min_length < stick }
result += [j - small_stick_num, 0].max
end
end
puts result
|
[
"assignment.variable.change",
"identifier.change",
"assignment.value.change"
] | 689,186
| 689,185
|
u302654038
|
ruby
|
p02888
|
def bisect_left(a, x)
lo = 0
hi = a.size
while lo < hi do
mid = (lo + hi) / 2
if a[mid] < x then
lo = mid + 1
else
hi = mid
end
end
return lo
end
N = gets.to_i
L = gets.strip.split.map(&:to_i)
L.sort()
result = 0
(0..N - 3).each do |i|
(i + 1..N - 2).each do |j|
result += bisect_left(a, L[i] + L[j]) - j - 1
end
end
puts result
|
def bisect_left(a, x)
lo = 0
hi = a.size
while lo < hi do
mid = (lo + hi) / 2
if a[mid] < x then
lo = mid + 1
else
hi = mid
end
end
return lo
end
N = gets.to_i
L = gets.strip.split.map(&:to_i)
L.sort!
result = 0
(0..N - 3).each do |i|
(i + 1..N - 2).each do |j|
result += bisect_left(L, L[i] + L[j]) - j - 1
end
end
puts result
|
[
"call.suffix.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 689,375
| 689,376
|
u347640436
|
ruby
|
p02888
|
N=gets.chomp.to_i
l=gets.chomp.split(' ').map(&:to_i)
cnt=0
l2=l.sort
l2.each_with_index { |a,i|
((i+1)...N).each { |j|
ab=a+l2[j]
cnt += (l2.bsearch_index{|m| m >= ab } || N)-1-j
}
}
|
N=gets.chomp.to_i
l=gets.chomp.split(' ').map(&:to_i)
cnt=0
l2=l.sort
l2.each_with_index { |a,i|
((i+1)...N).each { |j|
ab=a+l2[j]
cnt += (l2.bsearch_index{|m| m >= ab } || N)-1-j
}
}
puts cnt
|
[
"call.add"
] | 690,249
| 690,250
|
u977982581
|
ruby
|
p02891
|
s = gets.chomp
k = gets.to_i
if s.split('').count(s[0]) == s.size
puts s.size*k/2
exit
end
ans = 0
cnt = 1
(s.size-1).times do |i|
if s[i] == s[i+1]
cnt += 1
else
ans += cnt / 2
cnt = 1
end
end
ans += cnt / 2
ans *= k
if s[0] == s[-1]
i = 0
while true
if s[i] != s[i+1]
break
end
i += 1
end
j = -1
while true
if s[j] != s[j-1]
break
end
j -= 1
end
i += 1
j *= -1
ans -= ((i/2)+(j/2)-(a+b)/2)*(k-1)
end
puts ans
|
s = gets.chomp
k = gets.to_i
if s.split('').count(s[0]) == s.size
puts s.size*k/2
exit
end
ans = 0
cnt = 1
(s.size-1).times do |i|
if s[i] == s[i+1]
cnt += 1
else
ans += cnt / 2
cnt = 1
end
end
ans += cnt / 2
ans *= k
if s[0] == s[-1]
i = 0
while true
if s[i] != s[i+1]
break
end
i += 1
end
j = -1
while true
if s[j] != s[j-1]
break
end
j -= 1
end
i += 1
j *= -1
ans -= ((i/2)+(j/2)-(i+j)/2)*(k-1)
end
puts ans
|
[
"identifier.change",
"expression.operation.binary.change"
] | 690,771
| 690,772
|
u238956837
|
ruby
|
p02891
|
S=gets.chomp
K=gets.to_i
if S.chars.uniq.length == 1
puts S.length*K/2
exit 0
end
a = S.chars.chunk_while {|c1,c2| c1 == c2 }.map(&:count)
ret = a.inject(0) {|sum,cnt| sum += cnt/2 * K }
ret -= K-1 if S[0] == S[-1] && a[0].odd? && a[-1].odd?
puts ret
|
S=gets.chomp
K=gets.to_i
if S.chars.uniq.length == 1
puts S.length*K/2
exit 0
end
a = S.chars.chunk_while {|c1,c2| c1 == c2 }.map(&:count)
ret = a.inject(0) {|sum,cnt| sum += cnt/2 * K }
ret += K-1 if S[0] == S[-1] && a[0].odd? && a[-1].odd?
puts ret
|
[
"expression.operator.change"
] | 691,014
| 691,015
|
u852974293
|
ruby
|
p02891
|
# encoding: UTF-8
s = gets.chomp.to_s
k = gets.chomp.to_i
def count str, opts={}
first = opts[:first] || 0
last = opts[:last] || -1
replaced = str.gsub(/([a-z])(\1)/, '\1A')
return 0 unless replaced
replaced[first..last].count('A')
end
if s.match(/^([a-z])\1*$/)
puts ((s.length * k) / 2).to_i
exit
end
if k == 1
puts count(s)
exit
end
if s[0] != s[-1]
puts count(s) * k
exit
end
first = s.match(/^([a-z])\1*/)[0]
last = s.match(/([a-z])\1*$/)[0]
first_count = count(s + first, last: (- first.length - 1))
last_count = count(last + s, first: last.length)
if k == 2
puts first_count + last_count
exit
end
puts first_count + last_count +
(count(last + s + first, first: last.length, last: ((- first.length - 1) * (k - 2))))
|
# encoding: UTF-8
s = gets.chomp.to_s
k = gets.chomp.to_i
def count str, opts={}
first = opts[:first] || 0
last = opts[:last] || -1
replaced = str.gsub(/([a-z])(\1)/, '\1A')
return 0 unless replaced
replaced[first..last].count('A')
end
if s.match(/^([a-z])\1*$/)
puts ((s.length * k) / 2).to_i
exit
end
if k == 1
puts count(s)
exit
end
if s[0] != s[-1]
puts count(s) * k
exit
end
first = s.match(/^([a-z])\1*/)[0]
last = s.match(/([a-z])\1*$/)[0]
first_count = count(s + first, last: (- first.length - 1))
last_count = count(last + s, first: last.length)
if k == 2
puts first_count + last_count
exit
end
puts first_count + last_count +
(count(
last + s + first,
first: last.length,
last: (- first.length - 1)
) * (k-2))
|
[
"call.arguments.change"
] | 691,111
| 691,112
|
u299761130
|
ruby
|
p02891
|
S = gets.chomp
K = gets.to_i
# 2,3 -> 1
# 3,4 -> 2
r = [1]
combo = false
S.split("").each_with_index do |c, i|
next if i == 0
if S[i] == S[i-1]
r[-1] += 1
else
r.push(1)
end
end
if r.length == 1
puts r[0]*K/2
exit
end
ret = r.map {|e| e /2 }.inject(:+)
ret *= K
if S[0] == S[-1] && r[0].odd? && r[1].odd?
ret += (K-1)
end
puts ret
|
S = gets.chomp
K = gets.to_i
r = [1]
combo = false
S.split("").each_with_index do |c, i|
next if i == 0
if S[i] == S[i-1]
r[-1] += 1
else
r.push(1)
end
end
if r.length == 1
puts r[0]*K/2
exit
end
ret = r.map {|e| e /2 }.inject(:+)
ret *= K
if S[0] == S[-1] && r[0].odd? && r[-1].odd?
ret += (K-1)
end
puts ret
|
[
"expression.operation.unary.add",
"control_flow.branch.if.condition.change"
] | 691,980
| 691,981
|
u058568575
|
ruby
|
p02897
|
n=gets.to_i
p (n+1)/2.0/n
|
n=gets.to_i
p (n+1)/2/n.to_f
|
[
"call.arguments.change",
"expression.operation.binary.change",
"call.add"
] | 692,668
| 692,669
|
u657913472
|
ruby
|
p02897
|
n=gets.to_i
cnt=0
(0...n).each do |i|
if i%2==1
cnt=cnt.succ
end
end
p cnt/n.to_f
|
n=gets.to_i
cnt=0
(1..n).each do |i|
if i%2==1
cnt=cnt.succ
end
end
p cnt/n.to_f
|
[
"literal.number.integer.change"
] | 692,911
| 692,912
|
u781354194
|
ruby
|
p02897
|
n = gets.to_f
x = (n + 1) / 2
puts printf("%.10f", x / n)
|
n = gets.to_f
x = ((n + 1) / 2.0).floor
puts printf("%.10f", x / n)
|
[
"assignment.value.change",
"expression.operation.binary.change",
"call.add"
] | 692,954
| 692,955
|
u467800529
|
ruby
|
p02897
|
# n = gets.chomp.split.map(&:to_i)
# a = gets.to_f
# ans = 2 * n / a
# puts ans
# https://qiita.com/nasuka/items/21d7cd9acee9187c961e
n = gets.to_i
a = 0
count = 0
(1..n).each do a # each do で数を取り出す
if a.odd? # が奇数の時trueを返す→カウントを足す
count += 1
end
end
puts count / n.to_f
# to_f で小数点以下を表示
|
n = gets.to_i
a = 0
count = 0
(1..n).each do |a| # each do で数を取り出す
if a.odd? # が奇数の時trueを返す→カウントを足す
count += 1
end
end
puts count / n.to_f
# to_f で小数点以下を表示
|
[] | 693,107
| 693,108
|
u552761221
|
ruby
|
p02897
|
# n = gets.chomp.split.map(&:to_i)
# a = gets.to_f
# ans = 2 * n / a
# puts ans
# https://qiita.com/nasuka/items/21d7cd9acee9187c961e
n = gets.to_f
a = 0
count = 0
(1..n).each do a # each do で数を取り出す
if a.odd? # が奇数の時trueを返す→カウントを足す
count += 1
end
end
puts count / n.to_f
# to_f で小数点以下を表示
|
n = gets.to_i
a = 0
count = 0
(1..n).each do |a| # each do で数を取り出す
if a.odd? # が奇数の時trueを返す→カウントを足す
count += 1
end
end
puts count / n.to_f
# to_f で小数点以下を表示
|
[
"call.function.change",
"type_conversion.to_integer.change",
"type_conversion.to_number.change"
] | 693,109
| 693,108
|
u552761221
|
ruby
|
p02897
|
n = gets.to_i
if n % 2 == 0
puts "0.5"
else
puts ((n-1)/n.to_f)
end
|
n = gets.to_i
if n % 2 == 0
puts "0.5"
else
puts (n/2 + 1)/ n.to_f
end
|
[
"call.arguments.change",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 693,460
| 693,461
|
u333374716
|
ruby
|
p02897
|
n = gets.to_i
s = 0
(1..n).each{|i| s+=i if i.odd?}
puts s / n.to_f
|
n = gets.to_i
s = 0
(1..n).each{|i| s+=1 if i.odd?}
puts s / n.to_f
|
[
"identifier.replace.remove",
"literal.replace.add"
] | 693,555
| 693,556
|
u036108511
|
ruby
|
p02897
|
a = gets.to_i
puts (a / (a / 2).floor) / a.to_f
|
a = gets.to_i
puts (a - (a / 2).floor) / a.to_f
|
[
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 693,661
| 693,662
|
u610761300
|
ruby
|
p02897
|
incr=0
gets.chomp.to_i.times {|n| incr += 1 if n.next.odd?}
puts incr.to_f/n.to_f
|
incr=0
n=gets.chomp.to_i;n.times {|n| incr += 1 if n.next.odd?};puts incr.to_f/n.to_f
|
[
"assignment.add"
] | 693,967
| 693,968
|
u977982581
|
ruby
|
p02897
|
N = gets.chomp_to_f
puts (N - (N/2).floor)/N
|
N = gets.chomp.to_f
puts (N - (N/2).floor)/N
|
[
"assignment.value.change",
"identifier.change",
"call.add"
] | 694,000
| 694,001
|
u179299890
|
ruby
|
p02897
|
N = gets.chomp_to_i
puts (N - (N/2).floor)/N.to_f
|
N = gets.chomp.to_f
puts (N - (N/2).floor)/N
|
[
"assignment.value.change",
"identifier.change",
"call.add",
"call.remove"
] | 694,002
| 694,001
|
u179299890
|
ruby
|
p02897
|
n = gets.to_i
puts ((n/2).to_f)/(n.to_f)
|
n = gets.to_i
puts (((n+1)/2).to_f)/(n.to_f)
|
[
"call.arguments.change"
] | 694,265
| 694,266
|
u606976120
|
ruby
|
p02897
|
n = gets.to_i
puts n
i = 1
evennum = []
n.times do
if i.odd?
evennum.push(n)
end
i += 1
end
puts evennum.length/n.to_f
|
n = gets.to_i
i = 1
evennum = []
n.times do
if i.odd?
evennum.push(n)
end
i += 1
end
puts evennum.length/n.to_f
|
[
"call.remove"
] | 694,409
| 694,410
|
u562082015
|
ruby
|
p02897
|
n = gets.to_i
m = 0
if n % 2 == 0
m = n/2
else
m =(n-1)/2
end
puts m.fdiv(n)
|
n = gets.to_i
m = 0
if n % 2 == 0
m = n/2
else
m =(n+1)/2
end
puts m.fdiv(n)
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 694,602
| 694,603
|
u911373146
|
ruby
|
p02897
|
n=gets.to_i
puts (n.even?)? 0.5 : (n/2)*1.0/2
|
n=gets.to_i
puts (n.even?) ? 0.5 : (n/2+1)*1.0/n
|
[
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change",
"expression.operation.binary.change"
] | 694,852
| 694,853
|
u883824971
|
ruby
|
p02898
|
n,k=gets.split(" ").map(&:to_i)
h=gets.split(" ").map(&:to_i)
m=0
i=0
while i<n do
if h[i]>k
m+=1
end
i+=1
end
puts m
|
n,k=gets.split(" ").map(&:to_i)
h=gets.split(" ").map(&:to_i)
m=0
i=0
while i<n do
if h[i]>k-1
m+=1
end
i+=1
end
puts m
|
[
"control_flow.branch.if.condition.change"
] | 695,745
| 695,746
|
u560481052
|
ruby
|
p02898
|
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
sorted_h = h.sort
index = sorted_h.bsearch_index { |height| height >= k }
puts n - (index || 1)
|
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
sorted_h = h.sort
index = sorted_h.bsearch_index { |height| height >= k }
puts n - (index || n)
|
[
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change",
"expression.operation.binary.change"
] | 696,060
| 696,061
|
u623402808
|
ruby
|
p02898
|
n.k=gets.spit.map(&:to_i)
puts gets.spit.map(&:to_i).select{|i|i>=k}.size
|
n,k=gets.split.map(&:to_i)
puts gets.split.map(&:to_i).select{|i|i>=k}.size
|
[
"misc.typo",
"assignment.variable.change",
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 696,302
| 696,303
|
u883824971
|
ruby
|
p02899
|
n = gets.to_i
list = gets.split(" ").map(&:to_i)
list_new = []
list.each_with_index do |l, idx|
list_new[l] = idx+1
end
list_new.delete_at(0)
p list_new.join(" ")
|
_n = gets.to_i
list = gets.split(" ").map(&:to_i)
list_new = []
list.each_with_index do |l, idx|
list_new[l] = idx+1
end
list_new.delete_at(0)
print list_new.join(" ")
|
[
"assignment.variable.change",
"identifier.change",
"call.function.change",
"io.output.change"
] | 696,903
| 696,904
|
u806252545
|
ruby
|
p02899
|
student = gets.to_i
attend = gets.split(' ').map(&:to_i)
order = Array.new(student - 1)
print attend
range = 1..student
range.each do |num|
order[attend[num - 1] - 1] = num
end
print order.join(' ')
|
student = gets.to_i
attend = gets.split(' ').map(&:to_i)
order = Array.new(student - 1)
range = 1..student
range.each do |num|
order[attend[num - 1] - 1] = num
end
print order.join(' ')
|
[
"call.remove"
] | 697,130
| 697,131
|
u729372946
|
ruby
|
p02899
|
n = gets.to_i
keys = (1..n).to_a
vals = gets.split.map!{|i| i.to_i}
hash = Hash[keys.zip vals]
p hash.sort_by{|k, v| v}.to_h.keys.join(" ")
|
n = gets.to_i
keys = (1..n).to_a
vals = gets.split.map!{|i| i.to_i}
hash = Hash[keys.zip vals]
puts hash.sort_by{|k, v| v}.to_h.keys.join(" ")
|
[
"call.function.change",
"io.output.change"
] | 697,278
| 697,279
|
u751934765
|
ruby
|
p02899
|
gets
$><<gets.split.map.with_index.sort_by{|a,b|b.to_i}.map{|a,b|a}*" "
|
gets
$><<gets.split.map.with_index.sort_by{|a,b|a.to_i}.map{|a,b|b+1}*" "
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 697,476
| 697,477
|
u019489252
|
ruby
|
p02899
|
N = gets.chomp.to_i
a = Array.new(10**5)
gets.chomp.split(" ").map(&:to_i).each.with_index do |v, idx|
a[v - 1] = idx + 1
end
out = ""
a.each do |v|
out += v.to_s + " "
end
puts out.chomp
|
N = gets.chomp.to_i
a = Array.new(10**5)
gets.chomp.split(" ").map(&:to_i).each.with_index do |v, idx|
a[v - 1] = idx + 1
end
out = ""
a.each do |v|
out << v.to_s
out << " "
end
puts out.chomp
|
[
"expression.operation.binary.change"
] | 697,513
| 697,514
|
u778692431
|
ruby
|
p02900
|
require 'prime'
A,B = gets.split(" ").map(&:to_i)
puts A.gcd(B).prime_division.transpose[0].count + 1
|
require 'prime'
A,B = gets.split(" ").map(&:to_i)
puts A.gcd(B).prime_division.size + 1
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"call.remove"
] | 697,817
| 697,818
|
u307452818
|
ruby
|
p02900
|
require 'prime'
a, b = gets.chop.split.map(&:to_i)
puts a.gcd(b).prime_divition.length + 1
|
require 'prime'
a, b = gets.chop.split.map(&:to_i)
puts a.gcd(b).prime_division.length + 1
|
[
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 698,298
| 698,299
|
u604352408
|
ruby
|
p02900
|
A, B = gets.chomp.split.map(&:to_i)
require "prime"
puts (A.prime_division.map(&:first) & B.prime_division.map(&:first)) + 1
|
A, B = gets.chomp.split.map(&:to_i)
require "prime"
intsec = A.prime_division.map(&:first) & B.prime_division.map(&:first)
puts intsec.size + 1
|
[
"call.arguments.change",
"expression.operation.binary.change",
"call.add"
] | 698,504
| 698,505
|
u695135066
|
ruby
|
p02900
|
a,b=gets.split.map(&:to_i)
m=a.gcd b
require 'prime'
puts m.prime_division.size
|
a,b=gets.split.map(&:to_i)
m=a.gcd b
require 'prime'
puts m.prime_division.size + 1
|
[
"expression.operation.binary.add"
] | 698,703
| 698,704
|
u987208743
|
ruby
|
p02900
|
def gcd(a, b)
b == 0 ? a: gcd(b, a % b)
end
def pd(n)
results = []
i = 2
while i * i < n
if n % i == 0 then
n = n.div(i)
results.push(i)
else
i = i + 1
end
end
if n != 1 then
results.push(n)
end
return results
end
a, b = gets.chomp.split(" ").map(&:to_i)
d = gcd(a, b)
results = pd(d)
p results.uniq.length + 1
|
def gcd(a, b)
b == 0 ? a: gcd(b, a % b)
end
def pd(n)
results = []
i = 2
while i * i <= n
if n % i == 0 then
n = n.div(i)
results.push(i)
else
i = i + 1
end
end
if n != 1 then
results.push(n)
end
return results
end
a, b = gets.chomp.split(" ").map(&:to_i)
d = gcd(a, b)
results = pd(d)
p results.uniq.length + 1
|
[
"expression.operator.compare.change",
"expression.operation.binary.change"
] | 699,936
| 699,937
|
u081906479
|
ruby
|
p02900
|
require 'prime'
a, b = gets.chomp.split.map(&:to_i)
a, b = b, a if a > b
until a == 0
a, b = b%a, a
end
# bが最大公約数
k = []
def my_divisor_list(a)
return [1] if self == 1
Prime.prime_division(a).map do |e|
Array.new(e[1]+1).map.with_index do |element, i|
e[0]**i
end
end.inject{|p,q| p.product(q)}.map do |a|
[a].flatten.inject(&:*)
end.sort
end
k = my_divisor_list(b)
def prime_or_1?(n)
return true if n == 1
return true if n == 2 or n == 3
return false if (n % 2).zero?
3.step(Math.sqrt(n).to_i, 2) {|i| return false if (n % i).zero?}
true
end
p k.select{ |i| prime_or_1?(i) }.size
|
require 'prime'
a, b = gets.chomp.split.map(&:to_i)
a, b = b, a if a > b
until a == 0
a, b = b%a, a
end
# bが最大公約数
k = []
def my_divisor_list(a)
return [1] if a == 1
Prime.prime_division(a).map do |e|
Array.new(e[1]+1).map.with_index do |element, i|
e[0]**i
end
end.inject{|p,q| p.product(q)}.map do |a|
[a].flatten.inject(&:*)
end.sort
end
k = my_divisor_list(b)
def prime_or_1?(n)
return true if n == 1
return true if n == 2 or n == 3
return false if (n % 2).zero?
3.step(Math.sqrt(n).to_i, 2) {|i| return false if (n % i).zero?}
true
end
p k.select{ |i| prime_or_1?(i) }.size
|
[
"control_flow.branch.if.condition.change"
] | 700,151
| 700,152
|
u195257137
|
ruby
|
p02901
|
N,M = gets.split.map(&:to_i)
keys = Array.new(M)
i = 0
while i < M
a,_ = gets.split.map(&:to_i)
n = 0
gets.split.each do |c|
n |= 1 << c.to_i-1
end
keys[i] = [a,n]
i += 1
end
dp = Array.new(5000, 1e9)
dp[0] = 0
keys.each do |price,now|
bits = 0
while bits < (1<<N)
n = dp[bits] + price
if n < dp[bits|now]
dp[bits|now] = n
end
bits += 1
end
end
if dp[(1<<N)-1].nil?
p -1
else
p dp[(1<<N)-1]
end
|
N,M = gets.split.map(&:to_i)
keys = Array.new(M)
i = 0
while i < M
a,_ = gets.split.map(&:to_i)
n = 0
gets.split.each do |c|
n |= 1 << c.to_i-1
end
keys[i] = [a,n]
i += 1
end
dp = Array.new(5000, 1e9)
dp[0] = 0
keys.each do |price,now|
bits = 0
while bits < (1<<N)
n = dp[bits] + price
if n < dp[bits|now]
dp[bits|now] = n
end
bits += 1
end
end
if dp[(1<<N)-1] == 1e9
p -1
else
p dp[(1<<N)-1]
end
|
[] | 700,925
| 700,926
|
u852974293
|
ruby
|
p02903
|
h, w, a, b = gets.split.map(&:to_i)
ans = Array.new(h) { Array.new(w) }
for i in 0..h-1
for j in 0..w-1
ans[i][j] = (i <= b ? 1 : 0) ^ (j <= a ? 1 : 0)
end
end
puts ans.map(&:join).join("\n")
|
h, w, a, b = gets.split.map(&:to_i)
ans = Array.new(h) { Array.new(w) }
for i in 0..h-1
for j in 0..w-1
ans[i][j] = (i < b ? 1 : 0) ^ (j < a ? 1 : 0)
end
end
puts ans.map(&:join).join("\n")
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 701,253
| 701,254
|
u655122274
|
ruby
|
p02903
|
h,w,a,b = gets.split.map(&:to_i)
(h-b).times { puts ([0] * (w-a) + [1] * a).join }
h.times { puts ([1] * (w-a) + [0] * a).join }
|
h,w,a,b = gets.split.map(&:to_i)
(h-b).times { puts ([0] * (w-a) + [1] * a).join }
b.times { puts ([1] * (w-a) + [0] * a).join }
|
[
"identifier.change"
] | 702,667
| 702,668
|
u634482428
|
ruby
|
p02909
|
Weather = gets
if (Weather == "Sunny")
print "Cloudy"
elsif (Weather == "Cloudy")
print "Rainy"
else
print "Sunny"
end
|
Weather = gets.chomp
if (Weather == "Sunny")
print "Cloudy"
elsif (Weather == "Cloudy")
print "Rainy"
else
print "Sunny"
end
|
[
"call.add"
] | 703,012
| 703,013
|
u390383520
|
ruby
|
p02909
|
Weather = gets
if Weather == "Sunny" then
print "Cloudy"
elsif Weather == "Cloudy" then
print "Rainy"
else
print "Sunny"
end
|
Weather = gets.chomp
if (Weather == "Sunny")
print "Cloudy"
elsif (Weather == "Cloudy")
print "Rainy"
else
print "Sunny"
end
|
[
"call.add",
"control_flow.branch.if.condition.change"
] | 703,014
| 703,013
|
u390383520
|
ruby
|
p02909
|
s = gets.chomp
if s == "sunny"
puts "cloud"
elsif s == "cloud"
puts "rain"
else
puts "sunny"
end
|
s = gets.chomp
if s == "Sunny"
puts "Cloudy"
elsif s == "Cloudy"
puts "Rainy"
else
puts "Sunny"
end
|
[
"literal.string.change",
"literal.string.case.change",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 703,024
| 703,025
|
u561507564
|
ruby
|
p02909
|
A = ['Sunny', 'Cloudy', 'Rainy']
n = A.index(gets.chomp)
puts A[n.next / 3]
|
A = ['Sunny', 'Cloudy', 'Rainy']
n = A.index(gets.chomp)
puts A[n.next % 3]
|
[
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 703,539
| 703,540
|
u765478029
|
ruby
|
p02909
|
A = ['Sunny', 'Cloudy', 'Rainy']
n = A.index?(gets.chomp)
puts A[n.next / 3]
|
A = ['Sunny', 'Cloudy', 'Rainy']
n = A.index(gets.chomp)
puts A[n.next % 3]
|
[
"assignment.value.change",
"identifier.change",
"expression.operator.arithmetic.change",
"variable_access.subscript.index.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 703,541
| 703,540
|
u765478029
|
ruby
|
p02909
|
weather = %w(Sunny Cloudy Rainy Sunny)
s = gets.chomp
puts weather[index(s)+1]
|
weather = %w(Sunny Cloudy Rainy Sunny)
s = gets.chomp
puts weather[weather.index(s)+1]
|
[
"call.add"
] | 703,591
| 703,592
|
u446160635
|
ruby
|
p02909
|
h = {
'Sunny' => 'Cloudy',
'Cloudy' => 'Rainy',
'Rainy' => 'Sunny'
}
s = gets
puts h[s]
|
h = {
'Sunny' => 'Cloudy',
'Cloudy' => 'Rainy',
'Rainy' => 'Sunny'
}
s = gets
puts h[s.strip]
|
[
"call.add"
] | 703,610
| 703,611
|
u285929684
|
ruby
|
p02909
|
a = gets.to_s
if a === "Sunny" then
print("Cloudy")
elsif a === "Cloudy" then
print("Rainy")
else
print("Sunny")
end
|
a = gets.strip
if a === "Sunny" then
print("Cloudy")
elsif a === "Cloudy" then
print("Rainy")
else
print("Sunny")
end
|
[
"assignment.value.change",
"identifier.change"
] | 703,664
| 703,665
|
u291303244
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.