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 |
|---|---|---|---|---|---|---|---|
p02989
|
N = gets.to_i
d = gets.split.map(&:to_i)
half = N/2.to_f
if d[half-1] == d[half] then
puts 0
exit
end
min = d[half-1] + 1
max = d[half]
puts max - min + 1
|
N = gets.to_i
d = gets.split.map(&:to_i)
d.sort!
half = N/2.to_f
if d[half-1] == d[half] then
puts 0
exit
end
min = d[half-1] + 1
max = d[half]
puts max - min + 1
|
[
"call.add"
] | 796,532
| 796,533
|
u244257825
|
ruby
|
p02989
|
n = gets.to_i
d = gets.split.map(&:to_i)
arr = d.sort.each_slice(n/2)
puts arr[1].first - arr[0].last
|
n = gets.to_i
d = gets.split.map(&:to_i)
arr = d.sort.each_slice(n/2).to_a
puts arr[1].first - arr[0].last
|
[
"call.add"
] | 796,977
| 796,978
|
u679291177
|
ruby
|
p02989
|
N = gets.to_i
level = gets.split.map(&:to_i).sort
puts level
puts level[(level.size / 2)] - level[(level.size / 2) - 1]
|
N = gets.to_i
level = gets.split.map(&:to_i).sort
puts level[(level.size / 2)] - level[(level.size / 2) - 1]
|
[
"call.remove"
] | 797,044
| 797,045
|
u501265339
|
ruby
|
p02989
|
N = gets.to_i
level = gets.split.map(&:to_i).sort
#puts level
puts level[(level.size / 2) + 1] - level[(level.size / 2)]
|
N = gets.to_i
level = gets.split.map(&:to_i).sort
puts level[(level.size / 2)] - level[(level.size / 2) - 1]
|
[
"expression.operation.binary.remove"
] | 797,046
| 797,045
|
u501265339
|
ruby
|
p02990
|
N,B = gets.chomp.split(" ").map(&:to_i)
div = 10**9 + 7
R = N-B
op = R+1
puts op
(2..B).each do |i|
if i <= m+1 then
op *= R-(i-2)
op *= B-(i-1)
op /= i
op /= i-1
puts op % div
else
puts "0"
end
end
|
N,B = gets.chomp.split(" ").map(&:to_i)
div = 10**9 + 7
R = N-B
op = R+1
puts op
(2..B).each do |i|
if i <= R+1 then
op *= R-(i-2)
op *= B-(i-1)
op /= i
op /= i-1
puts op % div
else
puts "0"
end
end
|
[
"control_flow.branch.if.condition.change"
] | 797,537
| 797,538
|
u693378622
|
ruby
|
p02989
|
# coding: utf-8
# 入力1行目:4桁の整数(1文字列)
n = gets.to_i
p_list = gets.split.map(&:to_i)
p p_list.sort!
puts p_list[n/2] - p_list[n/2-1]
|
# coding: utf-8
# 入力1行目:4桁の整数(1文字列)
n = gets.to_i
p_list = gets.split.map(&:to_i)
p_list.sort!
puts p_list[n/2] - p_list[n/2-1]
|
[
"io.output.change",
"call.remove"
] | 797,784
| 797,785
|
u735540617
|
ruby
|
p02990
|
class Integer
def combination(k)
return 1 if k.zero?
(self - k + 1..self).inject(:*) / k.factorial
end
def factorial
return 1 if self.zero?
(1..self).inject(:*)
end
end
n,k = gets.split.map(&:to_i)
r = n-k
mod = 10**9 + 7
(1..k).each do |i|
if flag
puts 0
else
ans = (r+1).combination(i) * (k-1).combination(i-1) % mod
flag = 0 if ans==0
puts ans
end
end
|
class Integer
def combination(k)
return 1 if k.zero?
(self - k + 1..self).inject(:*) / k.factorial
end
def factorial
return 1 if self.zero?
(1..self).inject(:*)
end
end
n,k = gets.split.map(&:to_i)
r = n-k
mod = 10**9 + 7
flag = false
(1..k).each do |i|
if flag
puts 0
else
ans = (r+1).combination(i) * (k-1).combination(i-1) % mod
flag = 0 if ans==0
puts ans
end
end
|
[
"assignment.add"
] | 797,872
| 797,873
|
u600153083
|
ruby
|
p02987
|
a,b,c,d=gets.chars.sort
puts a==b&&c==d&&b!=c ? "Yes":"No"
|
a,b,c,d=gets.chomp.chars.sort
puts a==b&&c==d&&b!=c ? "Yes":"No"
|
[
"call.add"
] | 798,145
| 798,146
|
u966810027
|
ruby
|
p02987
|
puts gets.chop.chars.tally.values.all{_1==2}?:Yes: :No
|
puts gets.chop.chars.tally.values.all?{_1==2}?:Yes: :No
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 798,147
| 798,148
|
u657913472
|
ruby
|
p02990
|
class Integer
MOD = 1000000007
@@inverse = {}
def plus(other)
(self + other) % MOD
end
def minus(other)
(self - other) % MOD
end
def mult(other)
((self % MOD) * (other % MOD)) % MOD
end
def divi(other)
((self % MOD) * other.inverse) % MOD
end
def power(n)
res = 1
a = self
while (n > 0) do
res = res.mult(a) if n[0]==1
a = a.mult(a)
n = n >> 1
end
res
end
def inverse
@@inverse[self] ||= power(MOD-2)
end
end
def combi(n,k)
return 0 if n < k
k=n-k if 2*k > n
return 1 if k == 0
(((n-k+1)..n).reduce(&:mult)).divi ((1..k).reduce(&:mult))
end
N, K = gets.split(' ').map(&:to_i)
R = N - K
(1..K).each do |i|
puts combi(N-K+1, i)*combi(K-1, i-1)
end
|
class Integer
MOD = 1000000007
@@inverse = {}
def plus(other)
(self + other) % MOD
end
def minus(other)
(self - other) % MOD
end
def mult(other)
((self % MOD) * (other % MOD)) % MOD
end
def divi(other)
((self % MOD) * other.inverse) % MOD
end
def power(n)
res = 1
a = self
while (n > 0) do
res = res.mult(a) if n[0]==1
a = a.mult(a)
n = n >> 1
end
res
end
def inverse
@@inverse[self] ||= self.power(MOD-2)
end
end
def combi(n,k)
return 0 if n < k
k=n-k if 2*k > n
return 1 if k == 0
(((n-k+1)..n).reduce(&:mult)).divi ((1..k).reduce(&:mult))
end
N, K = gets.split(' ').map(&:to_i)
R = N - K
(1..K).each do |i|
puts combi(N-K+1, i).mult combi(K-1, i-1)
end
|
[
"call.add",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 798,401
| 798,402
|
u572745161
|
ruby
|
p02990
|
N, K = gets.split.map(&:to_i)
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
dec = 10**9+7
for i in 1..K do
puts combi(N-K+1,i) * combi(K-1,i-1) % dec
end
|
N, K = gets.split.map(&:to_i)
def combi(n,k)
return 0 if k > n
k=n-k if 2*k > n
return 1 if k == 0
((n-k+1)..n).reduce(&:*)/((1..k).reduce(&:*))
end
dec = 10**9+7
for i in 1..K do
puts combi(N-K+1,i) * combi(K-1,i-1) % dec
end
|
[] | 798,428
| 798,429
|
u947517859
|
ruby
|
p02990
|
MOD = 1000000007
def fact(n)
(1..n).inject(1){ |ans,x| ans*x % MOD }
end
def pow(n,k)
ans = 1
while k > 0
ans = ans*n % MOD if k.odd?
n = n*n % MOD
k >>= 1
end
ans
end
def comb(n,k)
fact(n) * pow(fact(n-k),MOD-2) % MOD * pow(fact(k),MOD-2) % MOD
end
n, k = gets.chomp.split.map(&:to_i)
l = n-k
(1..k).each do |i|
if l-i+1 < 0
puts(0)
else
ans = comb(k-1,i-1) * comb(l+1,i)
puts(ans)
end
end
|
MOD = 1000000007
def fact(n)
(1..n).inject(1){ |ans,x| ans*x % MOD }
end
def pow(n,k)
ans = 1
while k > 0
ans = ans*n % MOD if k.odd?
n = n*n % MOD
k >>= 1
end
ans
end
def comb(n,k)
fact(n) * pow(fact(n-k),MOD-2) % MOD * pow(fact(k),MOD-2) % MOD
end
n, k = gets.chomp.split.map(&:to_i)
l = n-k
(1..k).each do |i|
if l-i+1 < 0
puts(0)
else
ans = comb(k-1,i-1) * comb(l+1,i) % MOD
puts(ans)
end
end
|
[
"assignment.change"
] | 798,561
| 798,562
|
u913444337
|
ruby
|
p02990
|
def binom(n,k)
k = [k, n-k].min
if k==0
val = 1
else
val = binom(n-1,k-1)*n/k
end
return val
end
n,k = gets.chomp.split.map(&:to_i)
mod = (1e9+7).to_i
r = n - k
(1..k).each do |i|
break puts 0 if i-1 > r
cnt = 0
cnt += binom(k-1,i-1) % mod
cnt *= binom(r+1,r-i+1)
puts cnt % mod
end
|
def binom(n,k)
k = [k, n-k].min
if k==0
val = 1
else
val = binom(n-1,k-1)*n/k
end
return val
end
n,k = gets.chomp.split.map(&:to_i)
mod = (1e9+7).to_i
r = n - k
(1..k).each do |i|
next puts 0 if i-1 > r
cnt = 0
cnt += binom(k-1,i-1) % mod
cnt *= binom(r+1,r-i+1)
puts cnt % mod
end
|
[] | 798,889
| 798,890
|
u191196346
|
ruby
|
p02990
|
def binom(n,k)
k = [k, n-k].min
if k==0
val = 1
else
val = binom(n-1,k-1)*n/k
end
return val
end
n,k = gets.chomp.split.map(&:to_i)
mod = (1e9+7).to_i
r = n - k
(1..k).each do |i|
break if i-1 > r
cnt = 0
cnt += binom(k-1,i-1) % mod
cnt *= binom(r+1,r-i+1)
puts cnt % mod
end
|
def binom(n,k)
k = [k, n-k].min
if k==0
val = 1
else
val = binom(n-1,k-1)*n/k
end
return val
end
n,k = gets.chomp.split.map(&:to_i)
mod = (1e9+7).to_i
r = n - k
(1..k).each do |i|
next puts 0 if i-1 > r
cnt = 0
cnt += binom(k-1,i-1) % mod
cnt *= binom(r+1,r-i+1)
puts cnt % mod
end
|
[
"call.add"
] | 798,891
| 798,890
|
u191196346
|
ruby
|
p02993
|
s = gets.chomp.split("")
(1..3).each do |i|
if s[i] == s[i]
puts "Bad"
exit
end
end
puts "Good"
|
s = gets.chomp.split("")
(1..3).each do |i|
if s[i] == s[i-1]
puts "Bad"
exit
end
end
puts "Good"
|
[
"control_flow.branch.if.condition.change"
] | 799,741
| 799,742
|
u412789323
|
ruby
|
p02993
|
s = gets.chomp
# i = gets.to_i
4.times do |i|
if s[i] == s[i+1] # i と i+1 は同じでないのでスルーされる
puts "Bad"
end
end
puts "Good"
|
s = gets.chomp
# i = gets.to_i
4.times do |i|
if s[i] == s[i+1] # i と i+1 は同じでないのでスルーされる
puts "Bad"
exit
end
end
puts "Good"
|
[
"control_flow.exit.add"
] | 800,011
| 800,012
|
u552761221
|
ruby
|
p02993
|
a = gets.chomp.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
put ans
|
a = gets.chomp.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
puts ans
|
[
"misc.typo",
"identifier.change"
] | 800,221
| 800,222
|
u352238438
|
ruby
|
p02993
|
a = gets.chop.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
put ans
|
a = gets.chomp.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
puts ans
|
[
"assignment.value.change",
"identifier.change",
"misc.typo"
] | 800,223
| 800,222
|
u352238438
|
ruby
|
p02993
|
a = get.chomp.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
put ans
|
a = gets.chomp.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
puts ans
|
[
"assignment.value.change",
"identifier.change",
"misc.typo"
] | 800,224
| 800,222
|
u352238438
|
ruby
|
p02993
|
a = get.chop.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
put ans
|
a = gets.chomp.split("")
ans = "Good"
3.times do |i|
if a[i] == a[i+1]
ans = "Bad"
end
end
puts ans
|
[
"assignment.value.change",
"identifier.change",
"misc.typo"
] | 800,225
| 800,222
|
u352238438
|
ruby
|
p02993
|
code = gets.chars
puts(code.drop(1).zip(code).any?{|a, b| a == b} ? 'bad' : 'good')
|
code = gets.chars
puts(code.drop(1).zip(code).any?{|a, b| a == b} ? 'Bad' : 'Good')
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 800,321
| 800,322
|
u714769076
|
ruby
|
p02990
|
n, k = gets.chomp.split.map(&:to_i)
num = 1000000007
k_1 = k - 1
n_k_1 = n - k + 1
answer = n - k + 1
p answer
(2..k).each do |i|
if n_k_1 < i
p 0
else
answer = (answer * (k_1 - (i - 2)) / (i - 1) * (n_k_1 - (i - 1)) / i) % num
p answer
end
end
|
n, k = gets.chomp.split.map(&:to_i)
num = 1000000007
k_1 = k - 1
n_k_1 = n - k + 1
answer = n - k + 1
p answer
(2..k).each do |i|
if n_k_1 < i
p 0
else
answer = (answer * (k_1 - (i - 2)) / (i - 1) * (n_k_1 - (i - 1)) / i)
p answer % num
end
end
|
[
"call.add",
"call.remove"
] | 800,408
| 800,409
|
u975218092
|
ruby
|
p02993
|
s=gets;p s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[3]?"Good":"Bad"
|
s=gets;print s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[3]?"Good":"Bad"
|
[
"call.function.change",
"io.output.change"
] | 800,582
| 800,583
|
u803684095
|
ruby
|
p02993
|
s = gets.split(//).map(&:to_i)
last = 9999
result = "Good"
s.each do |n|
if n == last
result = "Bad"
end
last = n
end
puts result
|
s = gets.chomp
s = s.split(//).map(&:to_i)
last = 9999
result = "Good"
s.each do |n|
if n == last
result = "Bad"
end
last = n
end
puts result
|
[
"call.add"
] | 800,608
| 800,609
|
u944733909
|
ruby
|
p02993
|
s = gets.chomp.split("")
puts s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Good" : "Bad"
|
s = gets.chomp.split("")
puts s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ? "Bad" : "Good"
|
[
"literal.string.change",
"call.arguments.change"
] | 800,610
| 800,611
|
u692254521
|
ruby
|
p02993
|
s=gets
isb=false
1.upto(9){|i| isb=true if (s=~/#{i}+/)!=nil}
puts isb ? 'Bad':'Good'
|
s=gets
isb=false
0.upto(9){|i| isb=true if (s=~/#{i}{2}+/)!=nil}
puts isb ? 'Bad':'Good'
|
[
"literal.number.integer.change"
] | 800,754
| 800,755
|
u408023666
|
ruby
|
p02993
|
s=gets
isb=false
1.upto(9){|i| isb=true if (s=~/#{i}{2}/)!=nil}
puts isb ? 'Bad':'Good'
|
s=gets
isb=false
0.upto(9){|i| isb=true if (s=~/#{i}{2}+/)!=nil}
puts isb ? 'Bad':'Good'
|
[
"literal.number.integer.change"
] | 800,756
| 800,755
|
u408023666
|
ruby
|
p02993
|
S = gets.chomp
if S == S.squeeze
puts "Yes"
else
puts "No"
end
|
S = gets.chomp
if S == S.squeeze
puts "Good"
else
puts "Bad"
end
|
[
"literal.string.change",
"call.arguments.change"
] | 800,761
| 800,762
|
u106964380
|
ruby
|
p02993
|
S = gets.chomp.split("").map(&:to_i)
puts S
if S[0] == S[1] || S[1] == S[2] || S[2] == S[3]
puts "Bad"
else
puts "Good"
end
|
S = gets.chomp.split("").map(&:to_i)
if S[0] == S[1] || S[1] == S[2] || S[2] == S[3]
puts "Bad"
else
puts "Good"
end
|
[
"call.remove"
] | 800,825
| 800,826
|
u012110567
|
ruby
|
p02993
|
S = gets.to_i
cnt = 0
cnt += 1 if S[0] == S[1]
cnt += 1 if S[1] == S[2]
cnt += 1 if S[2] == S[3]
puts 'Bad' if cnt >= 1
puts 'Good' if cnt == 0
|
S = gets
cnt = 0
cnt += 1 if S[0] == S[1]
cnt += 1 if S[1] == S[2]
cnt += 1 if S[2] == S[3]
puts 'Bad' if cnt > 0
puts 'Good' if cnt == 0
|
[
"call.remove"
] | 800,850
| 800,851
|
u921706922
|
ruby
|
p02993
|
ary = gets.chomp.chars.map(&:to_i)
print = "Good"
ary.each_with_index do |v, k|
print = "Bad" if v == ary[k-1]
end
puts print
|
ary = gets.chomp.chars.map(&:to_i)
print = "Good"
ary.each_with_index do |v, k|
if k != 0
print = "Bad" if v == ary[k-1]
end
end
puts print
|
[] | 801,073
| 801,074
|
u126541218
|
ruby
|
p02993
|
gets.chomp.match(/([0-9])\1/) ? "Bad" : "Good"
|
puts gets.chomp.match(/([0-9])\1/) ? "Bad" : "Good"
|
[
"io.output.change",
"call.add"
] | 801,120
| 801,121
|
u700923200
|
ruby
|
p02993
|
S = gets
for i in 0..3 do
if S[i-1]<S[i]
a = 'Bad'
elsif a != 'Bad'
a='Good'
end
end
puts a
|
S = gets
for i in 0..3 do
if S[i-1] == S[i]
a = 'Bad'
elsif a != 'Bad'
a='Good'
end
end
puts a
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 801,243
| 801,244
|
u413815532
|
ruby
|
p02993
|
s = gets.chars.map(&:to_i)
judge = s.each_cons(2).inject(false) {|flag,(a,b)| a == b ? true : flag}
puts judge ? 'Bad' : 'Good'
|
s = gets.chomp.chars.map(&:to_i)
flag = s.each_cons(2).inject(false) {|flag,(a,b)| a == b ? true : flag}
puts flag ? 'Bad' : 'Good'
|
[
"call.add",
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 801,272
| 801,273
|
u396511998
|
ruby
|
p02993
|
s = gets.chars.map(&:to_i)
flag = s.each_cons(2).inject(false) {|flag,(a,b)| a == b ? true : flag}
puts flag ? 'Bad' : 'Good'
|
s = gets.chomp.chars.map(&:to_i)
flag = s.each_cons(2).inject(false) {|flag,(a,b)| a == b ? true : flag}
puts flag ? 'Bad' : 'Good'
|
[
"call.add"
] | 801,274
| 801,273
|
u396511998
|
ruby
|
p02993
|
# a,b,c = 3.times.map(gets.to_i)
r=gets.strip.split("").map(&:to_i)
puts r
#.inject(:+)
#cnt=0
#while as.all?(|x|x.even?) do
# cnt=cnt.succ
# end
# ans = (1..n)
# .map{|i|[i,j]}
# .select{|d|a <= d[1] && d[1]<= b}
# .inject(0){|sum,d|sum+d[0]}
cnt = 0
(0..2).each do |i|
cnt=1 if r[i]==r[i+1]
end
puts cnt==0 ? "Good" : "Bad"
|
# a,b,c = 3.times.map(gets.to_i)
r=gets.strip.split("").map(&:to_i)
#.inject(:+)
#cnt=0
#while as.all?(|x|x.even?) do
# cnt=cnt.succ
# end
# ans = (1..n)
# .map{|i|[i,j]}
# .select{|d|a <= d[1] && d[1]<= b}
# .inject(0){|sum,d|sum+d[0]}
cnt = 0
(0..2).each do |i|
cnt=1 if r[i]==r[i+1]
end
puts cnt==0 ? "Good" : "Bad"
|
[
"call.remove"
] | 801,557
| 801,558
|
u926099741
|
ruby
|
p02993
|
# frozen_string_literal: true
s = gets.chomp
if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4]
puts 'Bad'
else
puts 'Gooe'
end
|
# frozen_string_literal: true
s = gets.chomp
if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4]
puts 'Bad'
else
puts 'Good'
end
|
[
"literal.string.change",
"call.arguments.change"
] | 801,675
| 801,676
|
u434509016
|
ruby
|
p02993
|
s = gets.chomp.split("")
sss = ''
ssss = ''
s.each do |ss|
ssss = 'Bad' if ss == sss
sss = ss
end
if ssss == 'Bad'
p 'Bad'
else
p 'Good'
end
|
s = gets.chomp.split("")
sss = ''
ssss = ''
s.each do |ss|
ssss = 'Bad' if ss == sss
sss = ss
end
if ssss == 'Bad'
puts 'Bad'
else
puts 'Good'
end
|
[
"call.function.change",
"io.output.change"
] | 801,712
| 801,713
|
u634482428
|
ruby
|
p02993
|
s = gets.split.map(&:to_i)
flag = 1
for i in 0..2
if s[i] == s[i+1]
flag = 0
break
end
end
if flag == 1
puts "Good"
else
puts "Bad"
end
|
s = gets.split("").map(&:to_i)
flag = 1
for i in 0..2
if s[i] == s[i+1]
flag = 0
break
end
end
if flag == 1
puts "Good"
else
puts "Bad"
end
|
[
"call.arguments.add"
] | 801,912
| 801,913
|
u326891688
|
ruby
|
p02993
|
srray=gets.split.map(&:to_i)
if srray[0] == srray[1]
puts "Bad"
elsif srray[1] == srray[2]
puts "Bad"
elsif srray[2] == srray[3]
puts "Bad"
else
puts "Good"
end
|
srray=gets.split("").map(&:to_i)
if srray[0] == srray[1]
puts "Bad"
elsif srray[1] == srray[2]
puts "Bad"
elsif srray[2] == srray[3]
puts "Bad"
else
puts "Good"
end
|
[
"call.arguments.add"
] | 801,944
| 801,945
|
u987183622
|
ruby
|
p02993
|
S = gets
S << "a"
flg = 0
4.times do |i|
if S[i] == S[i + 1]
flg += 0
end
end
if flg == 0
puts "Good"
else
puts "Bad"
end
|
S = gets.chomp!
S << "a"
flg = 0
4.times do |i|
if S[i] == S[i + 1]
flg += 1
end
end
if flg == 0
puts "Good"
else
puts "Bad"
end
|
[
"call.add",
"literal.number.integer.change"
] | 801,967
| 801,968
|
u295334477
|
ruby
|
p02993
|
S = gets
S << "a"
flg = 0
4.times do |i|
if S[i] == S[i + 1]
flg += 0
end
end
if flg == 0
puts "Good"
else
puts "Bad"
end
|
S = gets
S << "a"
flg = 0
4.times do |i|
if S[i] == S[i + 1]
flg += 1
end
end
if flg == 0
puts "Good"
else
puts "Bad"
end
|
[
"literal.number.integer.change"
] | 801,967
| 801,969
|
u295334477
|
ruby
|
p02993
|
input = gets
i_1 = input.to_s[0]
i_2 = input.to_s[1]
i_3 = input.to_s[2]
i_4 = input.to_s[3]
output = "Good"
output = "Bad" if i_1 == i_2
output = "Bad" if i_2 == i_3
output = "Bad" if i_3 == i_4
p output
|
input = gets
i_1 = input.to_s[0]
i_2 = input.to_s[1]
i_3 = input.to_s[2]
i_4 = input.to_s[3]
output = "Good"
output = "Bad" if i_1 == i_2
output = "Bad" if i_2 == i_3
output = "Bad" if i_3 == i_4
puts output
|
[
"call.function.change",
"io.output.change"
] | 802,011
| 802,012
|
u802563409
|
ruby
|
p02993
|
input = ARGV[1]
i_1 = input.to_s[0]
i_2 = input.to_s[1]
i_3 = input.to_s[2]
i_4 = input.to_s[3]
output = "Good"
output = "Bad" if i_1 == i_2
output = "Bad" if i_2 == i_3
output = "Bad" if i_3 == i_4
p output
|
input = gets
i_1 = input.to_s[0]
i_2 = input.to_s[1]
i_3 = input.to_s[2]
i_4 = input.to_s[3]
output = "Good"
output = "Bad" if i_1 == i_2
output = "Bad" if i_2 == i_3
output = "Bad" if i_3 == i_4
puts output
|
[
"assignment.value.change",
"call.function.change",
"io.output.change"
] | 802,013
| 802,012
|
u802563409
|
ruby
|
p02993
|
s = gets.chomp.to_i
# n = gets.chomp.to_i
# ary = gets.chomp.split.map(&:to_i)
flag = false
for i in 1..3
if s[i] == s[i-1]
flag = true
end
end
if flag
puts "Bad"
else
puts "Good"
end
|
s = gets.chomp
# n = gets.chomp.to_i
# ary = gets.chomp.split.map(&:to_i)
flag = false
for i in 1..3
if s[i] == s[i-1]
flag = true
end
end
if flag
puts "Bad"
else
puts "Good"
end
|
[
"call.remove"
] | 802,178
| 802,179
|
u706730549
|
ruby
|
p02993
|
puts gets[/(\d)\1/] ? :Good : :Bad
|
puts gets[/(\d)\1/] ? :Bad : :Good
|
[] | 802,204
| 802,205
|
u711705317
|
ruby
|
p02993
|
S = gets.chomp.chars
s = S[0]
ans = "good"
1.upto(3) do |n|
if s == S[n]
ans = "bad"
break
end
s = S[n]
end
puts ans
|
S = gets.chomp.chars
s = S[0]
ans = "Good"
1.upto(3) do |n|
if s == S[n]
ans = "Bad"
break
end
s = S[n]
end
puts ans
|
[
"literal.string.change",
"literal.string.case.change",
"assignment.value.change"
] | 802,237
| 802,238
|
u541032448
|
ruby
|
p02994
|
#!/usr/bin/env ruby
# frozen_string_literal: true
n,l= gets.split.map(&:to_i)
sum = 0
arr = []
n.times do |i|
arr << l+i
sum += l+i
end
sa = sum if l < 0 && n-1+l >= 0
sa = sum - arr[-1] if l < 0 && n-1+l < 0
sa = sum -arr[0] if l > 0
puts sa
|
#!/usr/bin/env ruby
# frozen_string_literal: true
n,l= gets.split.map(&:to_i)
sum = 0
arr = []
n.times do |i|
arr << l+i
sum += l+i
end
sa = sum if l <= 0 && n-1+l > 0
sa = sum - arr[-1] if l < 0 && n-1+l <= 0
sa = sum -arr[0] if l >= 0
puts sa
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 802,721
| 802,722
|
u437368899
|
ruby
|
p02994
|
#!/usr/bin/env ruby
# frozen_string_literal: true
n,l= gets.split.map(&:to_i)
sum = 0
arr = []
n.times do |i|
arr << l+i
sum += l+i
end
sa = sum if l < 0 && n+l > 0
sa = sum - arr[-1] if l < 0 && n+l <= 0
sa = sum -arr[0] if l > 0
puts sa
|
#!/usr/bin/env ruby
# frozen_string_literal: true
n,l= gets.split.map(&:to_i)
sum = 0
arr = []
n.times do |i|
arr << l+i
sum += l+i
end
sa = sum if l <= 0 && n-1+l > 0
sa = sum - arr[-1] if l < 0 && n-1+l <= 0
sa = sum -arr[0] if l >= 0
puts sa
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 802,723
| 802,722
|
u437368899
|
ruby
|
p02994
|
inp = gets.split.map!(&:to_i)
apple = [] #美味しさの配列
apple_abs = [] #美味しさの絶対値の配列
inp[0].times do |i|
apple << inp[1]+(i+1)-1 #インデックスとりんごの番号は1ズレてる
end
apple_abs = apple.map(&:abs).sort! #これの0番目が食うやつ
ans = 0
apple.each do |v|
ans += v if v != apple_abs[0]
end
puts ans
|
inp = gets.split.map!(&:to_i)
apple = [] #美味しさの配列
apple_abs = [] #美味しさの絶対値の配列
inp[0].times do |i|
apple << inp[1]+(i+1)-1 #インデックスとりんごの番号は1ズレてる
end
apple_abs = apple.map(&:abs).sort! #これの0番目が食うやつ
#p apple #for debug
#p apple_abs[0] #for debug
ans = 0
apple.each do |v|
ans += v if v.abs != apple_abs[0]
end
puts ans
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 802,850
| 802,851
|
u318009838
|
ruby
|
p02994
|
N, L = gets.chomp.split.map(&:to_i)
sum = (L + N+L-1) * N / 2
if L >= 0
puts (sum - L)
elsif L < 0 && N+L-1 >= 0
puts sum
else
puts (sum - N+L-1)
end
|
N, L = gets.chomp.split.map(&:to_i)
sum = (L + N+L-1) * N / 2
if L >= 0
puts (sum - L)
elsif L < 0 && N+L-1 >= 0
puts sum
else
puts (sum - (N+L-1))
end
|
[
"call.arguments.change"
] | 802,954
| 802,955
|
u792512290
|
ruby
|
p02994
|
n, l = gets.split.map(&:to_i)
apple =
if (l..l + n).include?(0)
0
elsif l > 0
l
else
l + n - 1
end
puts n * l + (n - 1) * n / 2 - apple
|
n, l = gets.split.map(&:to_i)
apple =
if (l..l + n - 1).include?(0)
0
elsif l > 0
l
else
l + n - 1
end
puts n * l + (n - 1) * n / 2 - apple
|
[
"control_flow.branch.if.condition.change"
] | 803,028
| 803,029
|
u579668395
|
ruby
|
p02994
|
n,l = gets.chomp.split(" ").map(&:to_i)
sum = 0
if l >= 0
sum = n*(n-1)/2 + l*(n-1)
else
tn = l + n -1
if tn <= 0
sum = -n*(n-1)/2 + l*(n-1)
else
sum = -l*(l-1)/2 + tn*(tn+1)/2
end
end
puts sum
|
n,l = gets.chomp.split(" ").map(&:to_i)
sum = 0
if l >= 0
sum = n*(n-1)/2 + l*(n-1)
else
tn = l + n -1
if tn <= 0
sum = -n*(n-1)/2 + tn*(n-1)
else
sum = -l*(l-1)/2 + tn*(tn+1)/2
end
end
puts sum
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 803,366
| 803,367
|
u988912858
|
ruby
|
p02994
|
n, l = gets.split.map(&:to_i)
aji = []
(1..n).each{ |i| aji.push(l + i -1) }
p aji
foo = 10 ** 5
for var in aji do
foo = var if var.abs < foo.abs
end
aji.delete(foo)
puts aji.inject(:+)
|
n, l = gets.split.map(&:to_i)
aji = []
(1..n).each{ |i| aji.push(l + i -1) }
foo = 10 ** 5
for var in aji do
foo = var if var.abs < foo.abs
end
aji.delete(foo)
puts aji.inject(:+)
|
[
"call.remove"
] | 803,432
| 803,433
|
u561391668
|
ruby
|
p02994
|
n, l = gets.split.map(&:to_i)
flavors = []
n.times do |i|
flavors << l + i
end
res =
if l.negative?
n < l.abs ? flavors.inject(:+) + flavors.max.abs : flavors.inject(:+)
else
flavors[1..-1].inject(:+)
end
puts res
|
n, l = gets.split.map(&:to_i)
flavors = []
n.times do |i|
flavors << l + i
end
res =
if l.negative?
n <= l.abs ? flavors.inject(:+) + flavors.max.abs : flavors.inject(:+)
else
flavors[1..-1].inject(:+)
end
puts res
|
[
"expression.operator.compare.change",
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 803,485
| 803,486
|
u304013285
|
ruby
|
p02994
|
n, l = gets.map(&:to_i)
m = Array.new(n) { |i| n + i }.min_by(&:abs)
puts Array.new(n) { |i| n + i }.inject(:+) - m
|
n, l = gets.split.map(&:to_i)
m = Array.new(n) { |i| l + i }.min_by(&:abs)
puts Array.new(n) { |i| l + i }.inject(:+) - m
|
[
"call.add",
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change",
"call.arguments.change"
] | 803,548
| 803,549
|
u321226359
|
ruby
|
p02994
|
# A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
# MOD=1000000007
N,L=gets.split.map(&:to_i)
if L+N<0
puts (L...(L+N-1)).inject(&:+)
elsif L>0
puts ((L+1)...(L+N)).inject(&:+)
else
puts (L...(L+N)).inject(&:+)
end
|
N,L=gets.split.map(&:to_i)
if L+N-1<0
puts (L...(L+N-1)).inject(&:+)
elsif L>0
puts ((L+1)...(L+N)).inject(&:+)
else
puts (L...(L+N)).inject(&:+)
end
|
[
"control_flow.branch.if.condition.change"
] | 803,923
| 803,924
|
u364298541
|
ruby
|
p02994
|
N, L = STDIN.gets.chomp.split(' ').map(&:to_i)
ary = Array.new(N, 0)
ary.map!.with_index { |a, idx|
(L + idx)
}
minIdx = 0
if L > 0
minIdx = 0
elsif L < 0 && L.abs > N
minIdx = N - 1
else
minIdx = L.abs
end
puts ary.inject(:+) - ary[minIdx]
|
N, L = STDIN.gets.chomp.split(' ').map(&:to_i)
ary = Array.new(N, 0)
ary.map!.with_index { |a, idx|
(L + idx)
}
minIdx = 0
if L > 0
minIdx = 0
elsif L < 0 && L.abs >= N
minIdx = N - 1
else
minIdx = L.abs
end
puts ary.inject(:+) - ary[minIdx]
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 804,155
| 804,156
|
u231458241
|
ruby
|
p02995
|
a, b, c, d = gets.split.map(&:to_i)
ans = 0
if c == 1 || d == 1
elsif c == d
ans = b - (a - 1)
ans -= b / c - (a - 1) / c
else
ans = b - (a - 1)
ans -= b / c - (a - 1) / c
ans -= b / d - (a - 1) / d
ans += b / c.lcm(d) - a / c.lcm(d)
end
puts ans
|
a, b, c, d = gets.split.map(&:to_i)
ans = 0
if c == 1 || d == 1
elsif c == d
ans = b - (a - 1)
ans -= b / c - (a - 1) / c
else
ans = b - (a - 1)
ans -= b / c - (a - 1) / c
ans -= b / d - (a - 1) / d
ans += b / c.lcm(d) - (a - 1) / c.lcm(d)
end
puts ans
|
[] | 804,300
| 804,301
|
u979552932
|
ruby
|
p02995
|
a,b,c,d=gets.split.map &:to_i
e=c* d
kai1=b/c-(a-1)/c
kai2=b/d-(a-1)/d
kai3=b/e-(a-1)/e
puts (b-a+1)-(kai1+kai2-kai3)
|
a,b,c,d=gets.split.map &:to_i
e=c.lcm d
kai1=b/c-(a-1)/c
kai2=b/d-(a-1)/d
kai3=b/e-(a-1)/e
puts (b-a+1)-(kai1+kai2-kai3)
|
[
"assignment.value.change",
"expression.operation.binary.change",
"call.add"
] | 804,448
| 804,449
|
u977506075
|
ruby
|
p02995
|
A,B,C,D=$<.read.split.map(&:to_i)
a = A-1
x = B - B/C - B/D + B/C.lcm(D)
y = a - a/C - a/D + A/C.lcm(D)
puts x-y
|
A,B,C,D=$<.read.split.map(&:to_i)
a = A-1
x = B - B/C - B/D + B/C.lcm(D)
y = a - a/C - a/D + a/C.lcm(D)
puts x-y
|
[
"assignment.value.change",
"expression.operation.binary.change"
] | 804,601
| 804,602
|
u852974293
|
ruby
|
p02995
|
a, b, c, d = gets.strip.split.map(&:to_i)
lcm = c.lcm(d)
c_count = b/c-(a-1)/c
d_count = b/d-(a-1)/d
lcm_count = b/lcm-a/lcm
puts ((b-a + 1)-(c_count + d_count - lcm_count)).to_s
|
a, b, c, d = gets.strip.split.map(&:to_i)
lcm = c.lcm(d)
c_count = b/c-(a-1)/c
d_count = b/d-(a-1)/d
lcm_count = b/lcm-(a-1)/lcm
puts ((b-a + 1)-(c_count + d_count - lcm_count)).to_s
|
[] | 805,243
| 805,244
|
u913209852
|
ruby
|
p02995
|
# https://atcoder.jp/contests/abc131/tasks/abc131_c
a, b, c, d = gets.split.map(&:to_i)
am1 = a - 1
lcm = c.lcm(d)
puts b - a + 1 - ((b / c - am1 / c) + ( b / d - am1 / d) - (b / (c * d) - (am1 / lcm )) )
|
# https://atcoder.jp/contests/abc131/tasks/abc131_c
a, b, c, d = gets.split.map(&:to_i)
am1 = a - 1
lcm = c.lcm(d)
puts b - a + 1 - ((b / c - am1 / c) + ( b / d - am1 / d) - (b / lcm - (am1 / lcm )) )
|
[
"call.arguments.change",
"expression.operation.binary.change"
] | 805,251
| 805,252
|
u624505752
|
ruby
|
p02995
|
a,b,c,d = gets.split(" ").map{|item| item.to_i}
cdlcm = c.lcm(d)
c_div_count = b/c - (a-1)/c
d_div_count = b/d - (a-1)/d
cd_div_count = b/cdlcm - a/cdlcm
p b-a+1-c_div_count-d_div_count+cd_div_count
|
a,b,c,d = gets.split(" ").map{|item| item.to_i}
cdlcm = c.lcm(d)
c_div_count = b/c - (a-1)/c
d_div_count = b/d - (a-1)/d
cd_div_count = b/cdlcm - (a-1)/cdlcm
p b-a+1-c_div_count-d_div_count+cd_div_count
|
[] | 805,374
| 805,375
|
u131696044
|
ruby
|
p02995
|
a,b,c,d = gets.split.map(&:to_i)
l = c.lcm(d)
puts b - a + 1 +((b/c+b/d-b/l)-((a-1)/c+(a-1)/d-(a-1)/l))
|
a,b,c,d = gets.split.map(&:to_i)
l = c.lcm(d)
puts b - a + 1 - ((b/c+b/d-b/l)-((a-1)/c+(a-1)/d-(a-1)/l))
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 805,667
| 805,668
|
u032488805
|
ruby
|
p02995
|
a, b, c, d = gets.split.map(&:to_i)
x = b -a + 1
ya = (b / c) - (a / c)
ya += 1 if a % c == 0
yb = (b / d) - (a / d)
yb += 1 if a % d == 0
z = (b / c.lcm(d)) - (a / c.lcm(d))
z += 1 if a % c.lcm(b) == 0
puts x - (ya + yb - z)
|
a, b, c, d = gets.split.map(&:to_i)
x = b - a + 1
ya = (b / c) - (a / c)
ya += 1 if a % c == 0
yb = (b / d) - (a / d)
yb += 1 if a % d == 0
z = (b / c.lcm(d)) - (a / c.lcm(d))
z += 1 if a % c.lcm(d) == 0
puts x - (ya + yb - z)
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 806,144
| 806,145
|
u561391668
|
ruby
|
p02995
|
def count(l,r,d)
r / d - (l - 1) / d
end
A,B,C,D = gets.split.map(&:to_i)
if C == D
puts (B - A) - count(A,B,C)
else
puts (B - A + 1) - count(A,B,C) - count(A,B,D) + count(A,B, C.lcm(D))
end
|
def count(l,r,d)
r / d - (l - 1) / d
end
A,B,C,D = gets.split.map(&:to_i)
if C == D
puts (B - A + 1) - count(A,B,C)
else
puts (B - A + 1) - count(A,B,C) - count(A,B,D) + count(A,B, C.lcm(D))
end
|
[
"expression.operation.binary.add"
] | 806,343
| 806,344
|
u627981707
|
ruby
|
p02995
|
a, b, c, d = gets.split.map(&:to_i)
lcm = c.lcm(d)
n_c = lcm / c
n_d = lcm / d
n = n_c + n_d - 1
q_a = a / lcm
q_b = b / lcm
r_a = a % lcm
r_b = b % lcm
a_to_lcm = unless r_a == 0 then n - ((r_a-1)/c + (r_a-1)/d) else n end
lcm_to_b = r_b/c + r_b/d
division = a_to_lcm + (q_b - q_a - 1)*n + lcm_to_b
puts (b - a + 1) - division
|
a, b, c, d = gets.split.map(&:to_i)
lcm = c.lcm(d)
n_c = lcm / c
n_d = lcm / d
n = n_c + n_d - 1
q_a = a / lcm
q_b = b / lcm
r_a = a % lcm
r_b = b % lcm
a_to_lcm = unless r_a == 0 then n - ((r_a-1)/c + (r_a-1)/d) else n+1 end
lcm_to_b = r_b/c + r_b/d
division = a_to_lcm + (q_b - q_a - 1)*n + lcm_to_b
puts (b - a + 1) - division
|
[
"assignment.change"
] | 806,385
| 806,386
|
u145602296
|
ruby
|
p02996
|
abs = $stdin.read.lines.map(&:chomp).tap{|s| s.shift}.map{|l| l.split(" ").map(&:to_i)}
sorted = abs.sort_by {|a,b| b}
t = 0
sorted.each do |a,b|
t += a
if t > b
puts "No"
exit
end
end
puts "yes"
|
abs = $stdin.read.lines.map(&:chomp).tap{|s| s.shift}.map{|l| l.split(" ").map(&:to_i)}
sorted = abs.sort_by {|a,b| b}
t = 0
sorted.each do |a,b|
t += a
if t > b
puts "No"
exit
end
end
puts "Yes"
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 806,969
| 806,970
|
u381839731
|
ruby
|
p02996
|
n=gets.to_i
ab=(1..n).map{gets.split.to_i}.group_by{|x|x.last}
t=0
ab.keys.sort.each{|i|
d=ab[i].inject(0){|s,i|s+i[0]}
puts "No" or exit if d>i-t
t+=d
}
puts "Yes"
|
n=gets.to_i
ab=(1..n).map{gets.split.map(&:to_i)}.group_by{|x|x.last}
t=0
ab.keys.sort.each{|i|
d=ab[i].inject(0){|s,j|s+j[0]}
puts "No" or exit if d>i-t
t+=d
}
puts "Yes"
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.add",
"io.output.change",
"expression.operation.binary.change"
] | 807,300
| 807,301
|
u883824971
|
ruby
|
p02996
|
N = gets.to_i
works = Array.new
N.times do |i|
works.push!(gets.split(' ').map(&:to_i))
end
works = works.sort_by{|a| a[1]}
result = "Yes"
time = 0
N.times do |i|
time += works[i][0]
if time > works[i][1]
result = "No"
break
end
end
puts result
|
N = gets.to_i
works = Array.new
N.times do |i|
works.push(gets.split(' ').map(&:to_i))
end
works = works.sort_by{|a| a[1]}
result = "Yes"
time = 0
N.times do |i|
time += works[i][0]
if time > works[i][1]
result = "No"
break
end
end
puts result
|
[
"identifier.change"
] | 807,377
| 807,378
|
u548834738
|
ruby
|
p02996
|
n = gets.chomp.to_i
a_b = []
n.times do
a, b = gets.chomp.split.map(&:to_i)
a_b << [a,b]
end
# p a_b
a_b_s = a_b.sort do |x, y|
if x[0] == y[0] then
x[0] <=> y[0]
else
x[1] <=> y[1]
end
end
sum = 0
f = true
a_b_s.each do |x|
sum = sum + x[0]
if sum > x[1] then
f = false
end
end
if f then
puts 'Yes'
else
puts 'No'
end
|
n = gets.chomp.to_i
a_b = []
n.times do
a, b = gets.chomp.split.map(&:to_i)
a_b << [a,b]
end
# p a_b
a_b_s = a_b.sort do |x, y|
if x[1] == y[1] then
y[0] <=> x[0]
else
x[1] <=> y[1]
end
end
sum = 0
f = true
a_b_s.each do |x|
sum = sum + x[0]
if sum > x[1] then
f = false
end
end
if f then
puts 'Yes'
else
puts 'No'
end
|
[
"literal.number.integer.change",
"assignment.value.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"identifier.change",
"expression.operation.binary.change"
] | 807,948
| 807,949
|
u938270657
|
ruby
|
p02998
|
N = gets.to_i
ns = []
list_x = []
list_y = []
N.times{|i|
pos = gets.strip.split(/ /).collect(&:to_i)
ns << pos
x, y = pos
if l = list_x[x]
l << i
else
list_x[x] = [i]
end
if l = list_y[y]
l << i
else
list_y[y] = [i]
end
}
groups = N.times.to_a
def get_root(groups, g)
parent = groups[g]
if parent == g
return parent
else
return groups[g] = get_root(groups, parent)
end
end
def set_root(groups, g, root)
parent = groups[g]
groups[g] = root
if parent == g
return
else
get_root(groups, parent, root)
end
end
def combine(groups, g1, g2)
root = get_root(groups, g1)
set_root(groups, g2, root)
end
def combine_groups(groups, l)
if l
if l.length > 1
i1 = l[0]
(1...l.length).each{|i|
i2 = l[i]
combine(groups, i1, i2)
i1 = i2
}
end
end
end
list_x.each{|l|
combine_groups(groups, l)
}
list_y.each{|l|
combine_groups(groups, l)
}
table = {}
groups.each_with_index{|g, i|
g = get_root(groups, g)
if l = table[g]
l << i
else
table[g] = [i]
end
}
count = 0
table.values.each{|list|
x_table = {}
y_table = {}
list.each{|i|
x, y = ns[i]
x_table[x] = true
y_table[y] = true
}
x_count = x_table.length
y_count = y_table.length
if x_count >= 2 && y_count >= 2
count += (x_count * y_count - list.length)
end
}
puts count
|
N = gets.to_i
ns = []
list_x = []
list_y = []
N.times{|i|
pos = gets.strip.split(/ /).collect(&:to_i)
ns << pos
x, y = pos
if l = list_x[x]
l << i
else
list_x[x] = [i]
end
if l = list_y[y]
l << i
else
list_y[y] = [i]
end
}
groups = N.times.to_a
def get_root(groups, g)
parent = groups[g]
if parent == g
return parent
else
return groups[g] = get_root(groups, parent)
end
end
def set_root(groups, g, root)
parent = groups[g]
groups[g] = root
if parent == g
return
else
set_root(groups, parent, root)
end
end
def combine(groups, g1, g2)
root = get_root(groups, g1)
set_root(groups, g2, root)
end
def combine_groups(groups, l)
if l
if l.length > 1
i1 = l[0]
(1...l.length).each{|i|
i2 = l[i]
combine(groups, i1, i2)
i1 = i2
}
end
end
end
list_x.each{|l|
combine_groups(groups, l)
}
list_y.each{|l|
combine_groups(groups, l)
}
table = {}
groups.each_with_index{|g, i|
g = get_root(groups, g)
if l = table[g]
l << i
else
table[g] = [i]
end
}
count = 0
table.values.each{|list|
x_table = {}
y_table = {}
list.each{|i|
x, y = ns[i]
x_table[x] = true
y_table[y] = true
}
x_count = x_table.length
y_count = y_table.length
if x_count >= 2 && y_count >= 2
count += (x_count * y_count - list.length)
end
}
puts count
|
[
"identifier.change"
] | 809,169
| 809,170
|
u751724075
|
ruby
|
p02999
|
x, a = gets.chomp.split(' ').map(&:to_i).sort
puts x < a ? 0:10
|
x, a = gets.chomp.split(' ').map(&:to_i)
puts x < a ? 0:10
|
[
"call.remove"
] | 809,422
| 809,423
|
u175011963
|
ruby
|
p02999
|
x,a=gets.split.map(&:to_i)
p x%a*10
|
x,a=gets.split.map(&:to_i)
p x < a ? 0 : 10
|
[
"call.arguments.change",
"expression.operation.binary.change"
] | 809,539
| 809,540
|
u408023666
|
ruby
|
p02999
|
input = gets
array = input.split(' ').map! {|item| item.to_i}
X = array[0]
A = array[1]
if X <= A
p 0
else
p 10
end
|
input = gets
array = input.split(' ').map! {|item| item.to_i}
X = array[0]
A = array[1]
if X < A
p 0
else
p 10
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 809,558
| 809,559
|
u131696044
|
ruby
|
p02999
|
i,j = gets.strip.split('').map(&:to_i)
r = 0
r = 10 if i >= j
puts r
|
i,j = gets.strip.split(' ').map(&:to_i)
r = 0
r = 10 if i >= j
puts r
|
[
"literal.string.change",
"assignment.value.change",
"call.arguments.change"
] | 809,599
| 809,600
|
u259578064
|
ruby
|
p02999
|
eval"p %d<=%d?1:0"%gets.split
|
eval"p %d>=%d?10:0"%gets.split
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 809,648
| 809,649
|
u163052359
|
ruby
|
p02999
|
a=gets.split.map(&:to_i)
puts a[0] > a[1] ? 10 : 0
|
a=gets.split.map(&:to_i)
puts a[0] >= a[1] ? 10 : 0
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 809,730
| 809,731
|
u585819925
|
ruby
|
p02999
|
x, a = gets.chomp.split("").map(&:to_i)
if x < a
puts 0
else
puts 10
end
|
x, a = gets.chomp.split.map(&:to_i)
if x < a
puts 0
else
puts 10
end
|
[
"call.arguments.change"
] | 809,802
| 809,803
|
u303448696
|
ruby
|
p02999
|
x,a = gets.chomp.split("").map(&:to_i)
if x < a
puts 0
else
puts 10
end
|
x, a = gets.chomp.split.map(&:to_i)
if x < a
puts 0
else
puts 10
end
|
[
"call.arguments.change"
] | 809,804
| 809,803
|
u303448696
|
ruby
|
p02999
|
x,a=gets.splite(' ').map(&:to_i)
puts x >= a ? 10 : 0
|
x,a=gets.split(' ').map(&:to_i)
puts x >= a ? 10 : 0
|
[
"assignment.value.change",
"identifier.change"
] | 809,904
| 809,905
|
u024620623
|
ruby
|
p03000
|
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
ans=0
sum=0
i=0
if s.sum<x
sum=n+1
else
while ans<=x
sum+=1
ans+=s[i]
i+=1
end
end
puts sum
|
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
ans=0
sum=0
i=0
if s.sum<=x
sum=n+1
else
while ans<=x
sum+=1
ans+=s[i]
i+=1
end
end
puts sum
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 811,210
| 811,211
|
u977506075
|
ruby
|
p03000
|
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
ans=0
sum=0
i=0
if s.sum<x
sum=n
else
while ans<=x
sum+=1
ans+=s[i]
i+=1
end
end
puts sum
|
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
ans=0
sum=0
i=0
if s.sum<=x
sum=n+1
else
while ans<=x
sum+=1
ans+=s[i]
i+=1
end
end
puts sum
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 811,212
| 811,211
|
u977506075
|
ruby
|
p03000
|
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
ans=0
sum=0
i=0
if s.sum<x
else
while ans<=x
sum+=1
ans+=s[i]
i+=1
end
end
puts sum
|
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
ans=0
sum=0
i=0
if s.sum<=x
sum=n+1
else
while ans<=x
sum+=1
ans+=s[i]
i+=1
end
end
puts sum
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 811,213
| 811,211
|
u977506075
|
ruby
|
p03000
|
n, x = gets.chomp.split(' ').map(&:to_i)
l = gets.chomp.split(' ').map(&:to_i)
d = 0
c = 1
l.each do |i|
d += i
if d > x
print(c)
exit
end
c += 1
end
|
n, x = gets.chomp.split(' ').map(&:to_i)
l = gets.chomp.split(' ').map(&:to_i)
d = 0
c = 1
l.each do |i|
d += i
if d > x
print(c)
exit
end
c += 1
end
print(c)
|
[
"call.add"
] | 811,356
| 811,357
|
u882179152
|
ruby
|
p03000
|
n, x = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
sum = 0
cnt = 0
l.each do |num|
sum += num
break if sum > x
cnt += 1
end
puts cnt
|
n, x = gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
sum = 0
cnt = 1
l.each do |num|
sum += num
break if sum > x
cnt += 1
end
puts cnt
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 811,671
| 811,672
|
u876846619
|
ruby
|
p03000
|
n,x=gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
d=0
n.times do |i|
d += l[i]
if d > x
p i+1
break
end
end
|
n,x=gets.split.map(&:to_i)
l = gets.split.map(&:to_i)
d=0
n.times do |i|
d += l[i]
if d > x
p i+1
exit
end
end
p n+1
|
[
"control_flow.break.remove",
"control_flow.exit.add",
"call.add"
] | 811,990
| 811,991
|
u693378622
|
ruby
|
p03000
|
n,x=gets.split.map(&:to_i)
l=gets.split.map(&:to_i)
d=0
n.times do |i|
d+=l[i]
if x<d
puts i
exit
end
end
puts n
|
n,x=gets.split.map(&:to_i)
l=gets.split.map(&:to_i)
d=0
n.times do |i|
d+=l[i]
if x<d
puts i+1
exit
end
end
puts n+1
|
[
"expression.operation.binary.add"
] | 812,103
| 812,104
|
u926099741
|
ruby
|
p03000
|
# Your code here!
str = gets.split
array = gets.split
n, x = str[0].to_i, str[1].to_i
array = array.map{|n| n.to_i}
counter = 1
d = 0
i = 2
while i <= n + 1
d += array[i]
if d <= x
i += 1
counter += 1
else
print counter
break
end
end
print counter if d <= x
|
# Your code here!
str = gets.split
array = gets.split
n, x = str[0].to_i, str[1].to_i
array = array.map{|n| n.to_i}
counter = 1
d = 0
i = 0
while i <= n - 1
d += array[i]
if d <= x
i += 1
counter += 1
else
print counter
break
end
end
print counter if d <= x
|
[
"literal.number.integer.change",
"assignment.value.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 812,304
| 812,305
|
u460204279
|
ruby
|
p03000
|
str = gets.split
array = gets.split
n, x = str[0].to_i, str[1].to_i
array = array.map{|n| n.to_i}
counter = 1
d = 0
i = 0
while i <= n
d += array[i]
if d <= x
i += 1
counter += 1
else
print counter
break
end
end
print counter if d <= x
|
# Your code here!
str = gets.split
array = gets.split
n, x = str[0].to_i, str[1].to_i
array = array.map{|n| n.to_i}
counter = 1
d = 0
i = 0
while i <= n - 1
d += array[i]
if d <= x
i += 1
counter += 1
else
print counter
break
end
end
print counter if d <= x
|
[
"expression.operation.binary.add"
] | 812,307
| 812,305
|
u460204279
|
ruby
|
p03000
|
str = gets.split
array = gets.split
n, x = str[0].to_i, str[1].to_i
array = array.map{|n| n.to_i}
counter = 1
d = 0
i = 0
while i <= n
d += array[i]
if d <= x
i += 1
counter += 1
else
print counter
return
end
end
print counter if d <= x
|
# Your code here!
str = gets.split
array = gets.split
n, x = str[0].to_i, str[1].to_i
array = array.map{|n| n.to_i}
counter = 1
d = 0
i = 0
while i <= n - 1
d += array[i]
if d <= x
i += 1
counter += 1
else
print counter
break
end
end
print counter if d <= x
|
[
"control_flow.return.remove",
"control_flow.break.add"
] | 812,308
| 812,305
|
u460204279
|
ruby
|
p03000
|
n,x=gets.split.map &:to_i
l=gets.split.map &:to_i
d=0
n.times{|i|
d = d + l[i]
if d > x
p i+1
break
end
}
|
n,x=gets.split.map &:to_i
l=gets.split.map &:to_i
d=0
n.times{|i|
d = d + l[i]
if d > x
p i+1
exit
end
}
p n+1
|
[
"control_flow.break.remove",
"control_flow.exit.add",
"call.add"
] | 812,328
| 812,329
|
u752146271
|
ruby
|
p03000
|
n,x = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
res = 1
sum = 0
(nums).each do |i|
sum += nums[i]
res += 1 if x-sum >= 0
end
puts res
|
n, x = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
res = 1
sum = 0
(nums).each do |i|
sum += i
res += 1 if x-sum >= 0
end
puts res
|
[] | 812,353
| 812,354
|
u920525832
|
ruby
|
p03000
|
n,x = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
res = 1
sum = 0
(1..n).each do |i|
sum += nums[i]
res += 1 if x-sum >= 0
end
puts res
|
n, x = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
res = 1
sum = 0
(nums).each do |i|
sum += i
res += 1 if x-sum >= 0
end
puts res
|
[
"identifier.replace.add",
"literal.replace.remove"
] | 812,355
| 812,354
|
u920525832
|
ruby
|
p03000
|
N, X = gets.split.map(&:to_i)
L = gets.split.map(&:to_i)
count = 0
L.inject(0) do |sum, n|
count += 1 if sum <= X
sum + n
end
count += 1 if L.inject(:+) == X
puts count
|
N, X = gets.split.map(&:to_i)
L = gets.split.map(&:to_i)
count = 0
L.inject(0) do |sum, n|
count += 1 if sum <= X
sum + n
end
count += 1 if X >= L.inject(:+)
puts count
|
[
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 812,401
| 812,402
|
u326562452
|
ruby
|
p03000
|
N,X=gets.split.map &:to_i
r=0
x=0
gets.split.map(&:to_i).each do |l|
x+=l
r+=1
break unless x<=X
end
p r
|
N,X=gets.split.map &:to_i
r=1
x=0
gets.split.map(&:to_i).each do |l|
x+=l
r+=1 if x<=X
end
p r
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 812,746
| 812,747
|
u647875062
|
ruby
|
p03000
|
N,X=gets.split.map &:to_i
r=0
x=0
gets.split.map(&:to_i).each do |l|
x+=l
r+=1
break unless x<=X
end
p r
|
N,X=gets.split.map &:to_i
r=1
x=0
gets.split.map(&:to_i).each do |l|
x+=l
r+=1 if x<=X
end
p r
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 812,746
| 812,748
|
u647875062
|
ruby
|
p03000
|
n, x = gets.split.map(&:to_i)
ls = gets.split.map(&:to_i)
dest, cnt = 0, 0
while dest <= x
cnt += 1
dest += ls.shift
end
puts cnt
|
n, x = gets.split.map(&:to_i)
ls = gets.split.map(&:to_i)
dest, cnt = 0, 0
while dest <= x
cnt += 1
break if ls.empty?
dest += ls.shift
end
puts cnt
|
[] | 812,875
| 812,876
|
u366779547
|
ruby
|
p03000
|
N, X = gets.split.map!(&:to_i)
L = gets.split.to_a.map!(&:to_i)
ans = [0]
cnt = 1
N.times do |i|
tmp = ans.last + L[i]
if tmp <= X
cnt += 1
else
break
end
end
puts cnt
|
N, X = gets.split.map!(&:to_i)
L = gets.split.to_a.map!(&:to_i)
ans = [0]
cnt = 1
N.times do |i|
tmp = ans.last + L[i]
ans << tmp
if tmp <= X
cnt += 1
else
break
end
end
puts cnt
|
[
"expression.operation.binary.add"
] | 813,067
| 813,068
|
u295334477
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.