Datasets:

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
p03077
n = gets.to_i a = gets.to_i b = gets.to_i c = gets.to_i d = gets.to_i e = gets.to_i ary = [a,b,c,d,e] min = ary.min t = n / min + 5 p t
n = gets.to_i a = gets.to_i b = gets.to_i c = gets.to_i d = gets.to_i e = gets.to_i ary = [a,b,c,d,e] min = ary.min t = (n-1) / min + 5 p t
[]
894,571
894,570
u164522933
ruby
p03077
def ascan; gets.split.map(&:to_i); end n = gets.to_i neck = 5.times.map{gets.to_i}.min p 5+(n/neck)
def ascan; gets.split.map(&:to_i); end n = gets.to_i neck = 5.times.map{gets.to_i}.min p 5+((n-1)/neck)
[ "call.arguments.change" ]
894,602
894,603
u079330987
ruby
p03078
x,y,z,k=gets.split(' ').map(&:to_i) #h=gets.split(' ').map(&:to_i) #tajigen = Array.new(4) { Array.new(2,0) } a=gets.split(' ').map(&:to_i) b=gets.split(' ').map(&:to_i) c=gets.split(' ').map(&:to_i) xy = Array.new k_count = 0 for i in 0..x-1 for j in 0..y-1 xy.push(a[i]+b[j]) #break if k_count >=k end end xy.sort!.reverse! xy_new = Array.new =begin while k_count<k && xy[k_count] xy_new[k_count]=xy[k_count] k_count+=1 end =end u = [k,x*y].min xy_new = xy[0..u] puts xy_new #puts xy #c.sort!.reverse! =begin count =0 xy_count = 0 z_count = 0 while count<k if z_count >=z z_count=0 xy_count+=1 end ans = (xy[xy_count])+(c[z_count]) z_count+=1 count += 1 puts ans end =end abc = Array.new for i in 0..(xy_new.length-1) for j in 0..z-1 abc.push(xy_new[i]+c[j]) end end abc.sort!.reverse! =begin if k<x*y*z k=x*y*z end =end for i in 0..k-1 puts abc[i] end
x,y,z,k=gets.split(' ').map(&:to_i) #h=gets.split(' ').map(&:to_i) #tajigen = Array.new(4) { Array.new(2,0) } a=gets.split(' ').map(&:to_i) b=gets.split(' ').map(&:to_i) c=gets.split(' ').map(&:to_i) xy = Array.new k_count = 0 for i in 0..x-1 for j in 0..y-1 xy.push(a[i]+b[j]) #break if k_count >=k end end xy.sort!.reverse! xy_new = Array.new =begin while k_count<k && xy[k_count] xy_new[k_count]=xy[k_count] k_count+=1 end =end u = [k,x*y].min xy_new = xy[0..u] #puts xy_new #puts xy #c.sort!.reverse! =begin count =0 xy_count = 0 z_count = 0 while count<k if z_count >=z z_count=0 xy_count+=1 end ans = (xy[xy_count])+(c[z_count]) z_count+=1 count += 1 puts ans end =end abc = Array.new for i in 0..(xy_new.length-1) for j in 0..z-1 abc.push(xy_new[i]+c[j]) end end abc.sort!.reverse! =begin if k<x*y*z k=x*y*z end =end for i in 0..k-1 puts abc[i] end
[ "call.remove" ]
894,702
894,703
u387173453
ruby
p03079
a,b,c=gets.split.map(&:to_i) putd a==b && b==c ? "Yes" : "No"
a,b,c=gets.split.map(&:to_i) puts a==b && b==c ? "Yes" : "No"
[ "identifier.change" ]
894,945
894,946
u926099741
ruby
p03079
a,b,c=gets.split.map(&:to_i) if a==b and b==c puts "Yes" else puts "NO" end
a,b,c=gets.split.map(&:to_i) if a==b and b==c puts "Yes" else puts "No" end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
894,998
894,999
u921168761
ruby
p03079
def is_equilateral_triangle_present(numbers) if numbers.uniq.size == 1 puts true else puts false end end numbers = gets() numbers_list = numbers.split(" ").map(&:to_i) is_equilateral_triangle_present(numbers_list)
def is_equilateral_triangle_present(numbers) if numbers.uniq.size == 1 puts "Yes" else puts "No" end end numbers = gets() numbers_list = numbers.split(" ").map(&:to_i) is_equilateral_triangle_present(numbers_list)
[ "call.arguments.change" ]
895,169
895,170
u305781333
ruby
p03079
A,B,C = gets.split.map(&:to_i) if A == B && A == C && B == C puts "YES" else puts "NO" end
A,B,C = gets.split.map(&:to_i) if A == B && A == C && B == C puts "Yes" else puts "No" end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
895,229
895,230
u470178885
ruby
p03079
A, B, C = gets.chomp.split.map(&:to_i) if A == B && B == C puts 'YES' else puts 'NO' end
A, B, C = gets.chomp.split.map(&:to_i) if A == B && B == C puts 'Yes' else puts 'No' end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
895,252
895,253
u176990977
ruby
p03079
a,b,c = gets.chomp.map(&:to_i) if a==b && b==c puts "Yes" else puts "No" end
a,b,c = gets.chomp.split.map(&:to_i) if a==b && b==c puts "Yes" else puts "No" end
[ "call.add" ]
895,291
895,292
u462560753
ruby
p03079
puts gets.split.uniq! ? "Yes" : "No"
puts gets.split.uniq.size==1 ? "Yes" : "No"
[ "identifier.change", "control_flow.branch.if.condition.change" ]
895,303
895,304
u019489252
ruby
p03079
a,b,c = gets.chomp.split(" ").map(&:to_i) if a == b and b == c puts "yes" else puts "no" end
a,b,c = gets.chomp.split(" ").map(&:to_i) if a == b and b == c puts "Yes" else puts "No" end
[ "literal.string.change", "literal.string.case.change", "call.arguments.change" ]
895,415
895,416
u130878340
ruby
p03079
A = gets.chomp! list = A.split(" ") if list[0] == list[1] && list[0] == list[2] then output = "Yes" else output = "No" end p output
A = gets.chomp! list = A.split(" ") if list[0] == list[1] && list[0] == list[2] then output = "Yes" else output = "No" end puts output
[ "call.function.change", "io.output.change" ]
895,650
895,651
u917409046
ruby
p03079
A = gets.chomp! list = A.split(" ") if list[0] == list[1] && list[0] == list[2] then output = "yes" else output = "no" end p output
A = gets.chomp! list = A.split(" ") if list[0] == list[1] && list[0] == list[2] then output = "Yes" else output = "No" end puts output
[ "literal.string.change", "literal.string.case.change", "assignment.value.change", "call.function.change", "io.output.change" ]
895,652
895,651
u917409046
ruby
p03079
a,b,c=gets.split.map(&:to_i).sort puts a==b && a+b>c ? "Yes" : "No"
a,b,c=gets.split.map(&:to_i).sort puts a==b && b==c ? "Yes" : "No"
[ "expression.operation.binary.remove", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
895,700
895,701
u726630158
ruby
p03080
n = gets.to_i array = gets.split("").map(&:to_s) array.delete("R") if (array.length)*2 < n puts "Yes " else puts "No " end
n = gets.to_i array = gets.split("").map(&:to_s) array.delete("R") if (array.length)*2-2 < n puts "Yes " else puts "No " end
[ "control_flow.branch.if.condition.change" ]
896,024
896,025
u987183622
ruby
p03080
n = gets.to_i array = gets.split("").map(&:to_s) array.delete("R") if (array.length)*2 < n puts "Yes" else puts "No" end
n = gets.to_i array = gets.split("").map(&:to_s) array.delete("R") if (array.length)*2-2 < n puts "Yes " else puts "No " end
[ "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change" ]
896,027
896,025
u987183622
ruby
p03080
n = gets.to_i array = gets.split("").map(&:to_s) array.delete("R") if (array.length)*2 < n puts "Yes" else puts"No" end
n = gets.to_i array = gets.split("").map(&:to_s) array.delete("R") if (array.length)*2-2 < n puts "Yes " else puts "No " end
[ "control_flow.branch.if.condition.change", "literal.string.change", "call.arguments.change" ]
896,028
896,025
u987183622
ruby
p03080
timen = gets str = gets.chomp.split("") r = b = 0 for i in 0...timen if str[i] == "R" r += 1 else b += 1 end end if r > b puts "Yes" else puts "No" end
timen = gets.to_i str = gets.chomp.split("") r = b = 0 for i in 0...timen if str[i] == "R" r += 1 else b += 1 end end if r > b puts "Yes" else puts "No" end
[ "call.add" ]
896,243
896,244
u538351278
ruby
p03080
S = gets.chomp puts S.count(?R) > S.count(?B) ? "Yes" : "No"
N, S = gets, gets.chomp puts S.count(?R) > S.count(?B) ? "Yes" : "No"
[]
896,256
896,257
u064100484
ruby
p03078
x,y,z,k = gets.split(" ").map(&:to_i) a = gets.split(" ").map(&:to_i).sort.reverse b = gets.split(" ").map(&:to_i).sort.reverse c = gets.split(" ").map(&:to_i).sort.reverse ary = [] x.times do |i| y.times do |j| break if (i + 1) * (j + 1) > k z.times do |t| break if (i + 1) * (j + 1) * (t + 1) > k ary << a[i] + b[j] + c[t] end end end ary.sort.reverse k.times{|i| puts ary[i] }
x,y,z,k = gets.split(" ").map(&:to_i) a = gets.split(" ").map(&:to_i).sort.reverse b = gets.split(" ").map(&:to_i).sort.reverse c = gets.split(" ").map(&:to_i).sort.reverse ary = [] x.times do |i| y.times do |j| break if (i + 1) * (j + 1) > k z.times do |t| break if (i + 1) * (j + 1) * (t + 1) > k ary << a[i] + b[j] + c[t] end end end ary.sort!.reverse! k.times{|i| puts ary[i] }
[ "call.suffix.change" ]
896,379
896,380
u351482714
ruby
p03078
n = [] n = gets.split.map(&:to_i) a = [] a = gets.split.map(&:to_i) b = [] b = gets.split.map(&:to_i) c = [] c = gets.split.map(&:to_i) #a.sort #b.sort #c.sort k=[] for i in 0..n[0]-1 for j in 0..n[1]-1 k.push(a[i]+b[j]) end end k.sort! #p k l=[] for i in 0..[n[-1]-1,k.length-1].min for j in 0..n[2]-1 l.push(k[i]+c[j]) end end #p l l.sort! #p l for i in 0..n[-1]-1 puts l[l.length-1-i] end
n = [] n = gets.split.map(&:to_i) a = [] a = gets.split.map(&:to_i) b = [] b = gets.split.map(&:to_i) c = [] c = gets.split.map(&:to_i) #a.sort #b.sort #c.sort k=[] for i in 0..n[0]-1 for j in 0..n[1]-1 k.push(a[i]+b[j]) end end k.sort! #p k l=[] for i in 0..[n[-1]-1,k.length-1].min for j in 0..n[2]-1 l.push(k[k.length-1-i]+c[j]) end end #p l l.sort! #p l for i in 0..n[-1]-1 puts l[l.length-1-i] end
[ "expression.operation.binary.add" ]
896,777
896,778
u614043796
ruby
p03085
s=gets.chomp s=='T'?'A':s=='A'?'T':s=='G'?'C':'G'
s=gets.chomp puts s=='T'?'A':s=='A'?'T':s=='G'?'C':'G'
[ "io.output.change", "call.add" ]
897,324
897,325
u966810027
ruby
p03085
a=%w(A C G T) b=%w(A T C G ) n=gets.chomp for i in 0..3 if n==a[i] puts b[i] end end
a=%w(A C G T) b=%w(T G C A) n=gets.chomp for i in 0..3 if n==a[i] puts b[i] end end
[]
897,349
897,350
u977506075
ruby
p03085
a = gets.strip r = 'A' r = 'C' if a == 'A' r = 'A' if a == 'C' r = 'T' if a == 'G' r = 'G' if a == 'T' puts r
a = gets.strip r = 'A' r = 'T' if a == 'A' r = 'A' if a == 'T' r = 'C' if a == 'G' r = 'G' if a == 'C' puts r
[ "literal.string.change", "assignment.value.change", "control_flow.branch.if.condition.change" ]
897,379
897,380
u259578064
ruby
p03085
b = gets.to_s if 'AT'.include?(b) puts 'AT'.delete(b) else puts 'CG'.delete(b) end
b = gets.chomp.to_s if 'AT'.include?(b) puts 'AT'.delete(b) else puts 'CG'.delete(b) end
[ "call.add" ]
897,474
897,475
u175011963
ruby
p03085
## https://qiita.com/naotospace/items/8edea2f89566d0f687ec # ハッシュを使う b = gets.chomp.to_s hash = {A: "T", T: "A", C: "G", G: "C"} puts hash[b]
## https://qiita.com/naotospace/items/8edea2f89566d0f687ec # ハッシュを使う b = gets.chomp.to_sym # to_sym にしないとダメ hash = {A: "T", T: "A", C: "G", G: "C"} puts hash[b]
[ "assignment.value.change", "identifier.change" ]
897,508
897,509
u552761221
ruby
p03085
result = {'A' => 'T','T' => 'A','G' => 'C','C' => 'G'}[gets.strip] puts reuslt
result = {'A' => 'T','T' => 'A','G' => 'C','C' => 'G'}[gets.strip] puts result
[ "identifier.change", "call.arguments.change" ]
897,697
897,698
u021358975
ruby
p03085
b = gets.chomp if b =='A' puts 'A' elsif b == 'G' puts 'C' elsif b == 'C' puts 'T' elsif b == 'T' puts 'G' end
b = gets.chomp if b =='A' puts 'T' elsif b == 'G' puts 'C' elsif b == 'C' puts 'G' elsif b == 'T' puts 'A' end
[ "literal.string.change", "call.arguments.change" ]
897,770
897,771
u932417742
ruby
p03085
A = %w(A T C G) puts A[A.index(gets)^1]
B = gets.chomp A = %w(A T C G) puts A[A.index(B)^1]
[ "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
897,776
897,777
u106964380
ruby
p03085
X = gets.chomp A = %w(A C G T) puts A[A.index(X)^1]
B = gets.chomp A = %w(A T C G) puts A[A.index(B)^1]
[ "assignment.variable.change", "variable_access.subscript.index.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
897,779
897,777
u106964380
ruby
p03085
puts gets.tr('ACGT','TGAC')
puts gets.tr'ACGT','TGCA'
[ "call.arguments.change", "literal.string.change", "io.output.change" ]
897,784
897,785
u408023666
ruby
p03085
puts gets.tr('ACGT','TGAC')
puts gets.tr('ACGT','TGCA')
[ "literal.string.change", "call.arguments.change", "io.output.change" ]
897,784
897,786
u408023666
ruby
p03085
case gets when 'A' puts 'T' when 'T' puts 'A' when 'C' puts 'G' when 'G' puts 'C' end
case gets.chomp when 'A' puts 'T' when 'T' puts 'A' when 'C' puts 'G' when 'G' puts 'C' end
[ "call.add" ]
897,826
897,827
u326562452
ruby
p03085
b = gets.chomp E = { A: 'T', T: 'A', G: 'C', C: 'C'} puts E[b.to_sym]
b = gets.chomp E = { A: 'T', T: 'A', G: 'C', C: 'G'} puts E[b.to_sym]
[ "literal.string.change", "assignment.value.change" ]
897,846
897,847
u303448696
ruby
p03085
b = gets.to_s if b == "A" puts "T" elsif b == "T" puts "A" elsif b == "C" puts "G" elsif b == "G" puts "C" end
b = gets.chomp if b == "A" puts "T" elsif b == "T" puts "A" elsif b == "C" puts "G" elsif b == "G" puts "C" end
[ "assignment.value.change", "identifier.change" ]
897,917
897,918
u512524057
ruby
p03085
pairs = {"A":"T","T":"A","C":"G","G":"C"} base =gets.chomp p_base ="" base.each{|c| p_base << pairs[:"#{c}"] } puts p_base
pairs = {"A":"T","T":"A","C":"G","G":"C"} base =gets.chomp p_base ="" base.size.times{|c| p_base << pairs[:"#{base[c]}"] } puts p_base
[ "identifier.change", "call.add", "literal.string.change", "variable_access.subscript.index.change", "expression.operation.binary.change" ]
897,992
897,993
u606976120
ruby
p03085
E = {A: 'T', T: 'A', C: 'G', G: 'C'} b = gets puts E[b.to_sym]
E = {A: 'T', T: 'A', C: 'G', G: 'C'} b = gets.chomp puts E[b.to_sym]
[ "call.add" ]
897,999
898,000
u670006196
ruby
p03085
b = gets.chomp if b == "A" puts "T" elsif b == "T" puts "A" elsif b == "C" puts "G" els puts "C" end
b = gets.chomp if b == "A" puts "T" elsif b == "T" puts "A" elsif b == "C" puts "G" else puts "C" end
[]
898,002
898,003
u210338356
ruby
p03085
b = gets.chomp if b = "A" puts "T" elsif b = "T" puts "A" elsif b = "C" puts "G" els puts "C" end
b = gets.chomp if b == "A" puts "T" elsif b == "T" puts "A" elsif b == "C" puts "G" else puts "C" end
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
898,004
898,003
u210338356
ruby
p03085
b = gets.chomp list = { 'A'=> 'T', 'B'=> 'T', 'C'=> 'G', 'G'=> 'C' } puts list[b]
b = gets.chomp list = { 'A'=> 'T', 'T'=> 'A', 'C'=> 'G', 'G'=> 'C' } puts list[b]
[ "literal.string.change", "assignment.value.change" ]
898,068
898,069
u124214522
ruby
p03085
b = gets.split[0] case b when 'A' o = 'T' when 'C' o = 'G' when 'G' o = 'T' else o = 'A' end puts o
b = gets.split[0] case b when 'A' o = 'T' when 'C' o = 'G' when 'G' o = 'C' else o = 'A' end puts o
[ "literal.string.change", "assignment.value.change" ]
898,072
898,073
u080348635
ruby
p03085
base = { "A":"C", "C":"A", "G":"T", "T":"G" } puts base.key(gets.chomp)
base = { "A":"T", "C":"G", "G":"C", "T":"A" } puts base.key(gets.chomp)
[ "literal.string.change", "assignment.value.change" ]
898,097
898,098
u446713108
ruby
p03085
s = gets.to_s if s == "A" puts "T" elsif s == "T" puts "A" elsif s == "C" puts "G" else puts "C" end
s = gets.chomp.to_s if s == "A" puts "T" elsif s == "T" puts "A" elsif s == "C" puts "G" else puts "C" end
[ "call.add" ]
898,169
898,170
u422581886
ruby
p03085
b = gets case b when "A" then puts "T" when "T" then puts "A" when "C" then puts "G" when "G" then puts "C" end
b = gets.chomp case b when "A" then puts "T" when "T" then puts "A" when "C" then puts "G" when "G" then puts "C" end
[ "call.add" ]
898,276
898,277
u080112718
ruby
p03085
b = gets DoubleHelix = {"A" => "T", "T" => "A", "G" => "C", "C" => "G"} puts DoubleHelix[b]
b = gets.chomp DoubleHelix = {"A" => "T", "T" => "A", "G" => "C", "C" => "G"} puts DoubleHelix[b]
[ "call.add" ]
898,317
898,318
u552893255
ruby
p03085
class DoubleHelixAnswer def self.double_helix(data) case data when 'A' 'T' when 'T' 'A' when 'C' 'G' when 'G' 'C' end end end data = STDIN.read.strip DoubleHelixAnswer.double_helix(data)
class DoubleHelixAnswer def self.double_helix(data) case data when 'A' 'T' when 'T' 'A' when 'C' 'G' when 'G' 'C' end end end data = STDIN.read.strip puts DoubleHelixAnswer.double_helix(data)
[ "io.output.change", "call.add" ]
898,351
898,352
u168202142
ruby
p03085
fline = STDIN.gets.to_sym star = {A: "T", T: "A", C: "G", G: "C"} puts star[fline]
fline = $stdin.gets.chomp.to_sym star = {A: "T", T: "A", C: "G", G: "C"} puts star[fline]
[ "assignment.value.change", "call.add" ]
898,457
898,458
u021166294
ruby
p03085
fline = ARGV[0].to_sym star = {A: "T", T: "A", C: "G", G: "C"} puts star[fline]
fline = $stdin.gets.chomp.to_sym star = {A: "T", T: "A", C: "G", G: "C"} puts star[fline]
[ "call.add" ]
898,459
898,458
u021166294
ruby
p03085
{"A" => "T", "G" => "C", "C" => "G", "T" => "A"}[gets.chomp]
puts({"A" => "T", "G" => "C", "C" => "G", "T" => "A"}[gets.chomp])
[ "call.add", "call.arguments.change" ]
898,462
898,461
u895515293
ruby
p03085
{"A" => "T", "G" => "C", "C" => "G", "T" => "A"}[gets]
puts({"A" => "T", "G" => "C", "C" => "G", "T" => "A"}[gets.chomp])
[ "call.add", "call.arguments.change" ]
898,463
898,461
u895515293
ruby
p03085
lines = STDIN.gets if(lines == 'A') print 'T' elsif(lines == 'T') print 'A' elsif(lines == 'C') print 'G' else print 'C' end
lines = STDIN.gets.chomp if(lines == 'A') print 'T' elsif(lines == 'T') print 'A' elsif(lines == 'C') print 'G' else print 'C' end
[ "call.add" ]
898,494
898,495
u119099532
ruby
p03085
b = STDIN.gets() case b when "A" then puts "T" when "T" then puts "A" when "C" then puts "G" when "G" then puts "C" end
b = STDIN.gets().chomp case b when "A" puts "T" when "T" puts "A" when "C" puts "G" when "G" puts "C" end
[ "call.add" ]
898,513
898,514
u155570707
ruby
p03085
b = gets.to_s case b when 'A' print 'T' when 'C' print 'G' when 'G' print 'C' when 'T' print 'A' else 'No Match' end
b = gets.chomp case b when 'A' print 'T' when 'C' print 'G' when 'G' print 'C' when 'T' print 'A' else print 'No Match' end
[ "assignment.value.change", "identifier.change", "io.output.change", "call.add" ]
898,518
898,519
u641906413
ruby
p03085
array = ["A", "C", "G", "T"] input = gets.gsub("\n", "") if input == "A" p "T" elsif input == "T" p "A" elsif input == "C" p "G" elsif input == "G" p "C" end
array = ["A", "C", "G", "T"] input = gets.gsub("\n", "") if input == "A" puts "T" elsif input == "T" puts "A" elsif input == "C" puts "G" elsif input == "G" puts "C" end
[ "call.function.change", "io.output.change" ]
898,547
898,548
u942230032
ruby
p03085
b = gets.chomp if b = "A" puts("T") elsif b = "C" puts("G") elsif b = "G" puts("C") elsif b = "T" puts("A") end
b = gets.chomp if b == "A" puts("T") elsif b == "C" puts("G") elsif b == "G" puts("C") elsif b == "T" puts("A") end
[ "expression.operation.compare.replace.add", "assignment.replace.remove", "misc.typo" ]
898,560
898,561
u241469130
ruby
p03085
b = gets if b == 'A' puts 'T' elsif b == 'T' puts 'A' elsif b == 'C' puts 'G' else puts 'C' end
b = gets.chomp if b == 'A' puts 'T' elsif b == 'T' puts 'A' elsif b == 'C' puts 'G' else puts 'C' end
[ "call.add" ]
898,802
898,803
u027126134
ruby
p03085
def trans(s) s.split('').map { |c| case c when 'A' then 'T' when 'T' then 'A' when 'G' then 'C' when 'C' then 'G' else 'X' end }.join end b = readline puts trans(b)
def trans(s) s.split('').map { |c| case c when 'A' then 'T' when 'T' then 'A' when 'G' then 'C' when 'C' then 'G' else 'X' end }.join end b = readline.chop puts trans(b)
[ "call.add" ]
898,829
898,830
u101112282
ruby
p03085
i = gets if i == "A" then print 'T' elsif i == "C" then print 'G' elsif i == "G" then print 'C' else print 'A' end
i = gets if i == "A\n" then print 'T' elsif i == "C\n" then print 'G' elsif i == "G\n" then print 'C' else print 'A' end
[ "literal.string.change", "control_flow.branch.if.condition.change" ]
898,859
898,860
u312004378
ruby
p03086
s = gets.chomp str = s.scan(/([ACGT]+)/) if str == nil puts 0 exit end #p str str = str.map{|ss| ss[0].length} #p str puts str.max
s = gets.chomp str = s.scan(/([ACGT]+)/) if str.length == 0 puts 0 exit end #p str str = str.map{|ss| ss[0].length} #p str puts str.max
[ "control_flow.branch.if.condition.change", "call.add" ]
899,182
899,183
u409390792
ruby
p03086
s = gets.chomp ans = [] tmp = 0 s.each_char do |c| if c =~ /(A|C|G|T)/ tmp += 1 else ans << tmp tmp = 0 end end puts ans.max
s = gets.chomp ans = [0] tmp = 0 s.each_char do |c| if c =~ /(A|C|G|T)/ tmp += 1 else ans << tmp tmp = 0 end end ans << tmp puts ans.max
[ "expression.operation.binary.add" ]
899,308
899,309
u733814820
ruby
p03086
s = gets.chomp n = s.size ans = 0 (n-1).times do |i| (i+1).upto(n) do |j| if s[i...j] =~ /^[ACGT]+$/ then ans = [j-i, ans].max end end end puts ans
s = gets.chomp n = s.size ans = 0 n.times do |i| (i+1).upto(n) do |j| if s[i...j] =~ /^[ACGT]+$/ then ans = [j-i, ans].max end end end puts ans
[]
899,604
899,605
u466332671
ruby
p03086
s = gets.to_s.chomp ATGC = %w( A T G C ) ans = 0 cnt = 0 s.each_char do |c| if ATGC.include?(c) cnt += 1 ans = [ans, cnt] else cnt = 0 end end puts ans
s = gets.to_s.chomp ATGC = %w( A T G C ) ans = 0 cnt = 0 s.each_char do |c| if ATGC.include?(c) cnt += 1 ans = [ans, cnt].max else cnt = 0 end end puts ans
[ "call.add" ]
899,627
899,628
u693378622
ruby
p03086
puts gets.scan(/[ACGT]+/).map(&:size).max
puts gets.scan(/[ACGT]+/).map(&:size).max || 0
[ "expression.operation.binary.add" ]
899,629
899,630
u693378622
ruby
p03086
S=gets.chomp N=S.size ans=0 0.upto(N-2) do |i| (i+1).upto(N-1) do |j| if S[i..j].split("").all?{|e|e=="A" || e=="C" || e=="G" || e=="T"} jd=j-i+1 ans=ans<jd ? jd : ans end end end puts ans
S=gets.chomp N=S.size ans=0 0.upto(N-1) do |i| (i).upto(N-1) do |j| if S[i..j].split("").all?{|e|e=="A" || e=="C" || e=="G" || e=="T"} jd=j-i+1 ans=ans<jd ? jd : ans end end end puts ans
[ "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
900,059
900,060
u926099741
ruby
p03086
S=gets.chomp N=S.size ans=0 0.upto(N-2) do |i| (i+1).upto(N-1) do |j| if S[i..j].split("").all?{|e|e=="A" || e=="C" || e=="G" || e=="T"} jd=j-i+1 ans=ans<jd ? jd : ans end end end pust ans
S=gets.chomp N=S.size ans=0 0.upto(N-1) do |i| (i).upto(N-1) do |j| if S[i..j].split("").all?{|e|e=="A" || e=="C" || e=="G" || e=="T"} jd=j-i+1 ans=ans<jd ? jd : ans end end end puts ans
[ "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change", "expression.operation.binary.remove", "identifier.change" ]
900,061
900,060
u926099741
ruby
p03086
a = gets.strip.split('') r = %w[A C G T] l = 0 c = 0 a.each_with_index do |char, i| if r.include? char c += 1 elsif !r.include? char || (i == a.size - 1) l = c if c > l c = 0 end end puts l
a = gets.strip.split('') r = %w[A C G T] l = 0 c = 0 a.each_with_index do |char, i| if r.include? char c += 1 end if (!r.include?(char)) || (i == a.size - 1) l = c if c > l c = 0 end end puts l
[ "control_flow.branch.if.condition.change" ]
900,408
900,409
u259578064
ruby
p03086
s = gets.chomp max_s = s.scan(/[ATGC]+/).max{ |a, b| a.size <=> b.size } puts max_s == nil ? 0 : max_s
s = gets.chomp max_s = s.scan(/[ATGC]+/).max{ |a, b| a.size <=> b.size } puts max_s == nil ? 0 : max_s.size
[ "call.add" ]
900,817
900,818
u874414087
ruby
p03086
p gets.split(/[^ACGT]/).map{ |t| t.size }.max
p gets.split(/[^ACGT]/).map{ |t| t.size }.max || 0
[ "expression.operation.binary.add" ]
901,015
901,016
u360187321
ruby
p03086
S = gets.chomp ans = 0 S.size.times do |i| i.upto(S.size) do |j| if S[i..j].split('').all?{|s| ['A', 'C', 'G', 'T'].include?(s)} ans = [ans, j-i+1].max end end end puts ans
S = gets.chomp ans = 0 S.size.times do |i| i.upto(S.size - 1) do |j| if S[i..j].split('').all?{|s| ['A', 'C', 'G', 'T'].include?(s)} ans = [ans, j-i+1].max end end end puts ans
[ "expression.operation.binary.add" ]
901,044
901,045
u548834738
ruby
p03086
s = gets.chomp ans = s.scan(/[ACGT]+/).map { |m| m.size }.max puts ans
s = gets.chomp ans = s.scan(/[ACGT]+/).map { |m| m.size }.max || 0 puts ans
[ "assignment.change" ]
901,151
901,152
u721689253
ruby
p03086
a = gets.chomp max_length, current_length = 0 acgt = 'ACGT' a.each_char do |c| acgt.include?(c) ? current_length += 1 : current_length = 0 max_length = current_length if current_length > max_length end puts max_length
a = gets.chomp max_length, current_length = 0, 0 acgt = 'ACGT' a.each_char do |c| acgt.include?(c) ? current_length += 1 : current_length = 0 max_length = current_length if current_length > max_length end puts max_length
[]
901,211
901,212
u610761300
ruby
p03086
puts gets.chomp.scan(/[ACGT]+/).map(&:size).max
puts gets.chomp.scan(/[ACGT]+/).map(&:size).max || 0
[ "expression.operation.binary.add" ]
901,495
901,496
u064100484
ruby
p03086
a = gets.chomp if a.scan(/[ACGT]+/).empty? puts 0 else puts a.scan(/[ACGT]+/).max {|a, b| a.size <=> b.size} end
a = gets.chomp if a.scan(/[ACGT]+/).empty? puts 0 else s = a.scan(/[ACGT]+/).max {|a, b| a.size <=> b.size} puts s.size end
[ "assignment.variable.change", "call.add" ]
901,553
901,554
u841951314
ruby
p03086
puts gets.chomp.scan(/[ATCG]+/).map(&:length).max
p gets.scan(/[ATGC]*/).map(&:size).max
[ "identifier.change", "call.remove", "literal.string.change", "call.arguments.change", "expression.operator.arithmetic.change" ]
901,572
901,573
u358554431
ruby
p03086
puts gets.chomp.scan(/[ATCG]+/).map(&:length).max
puts (gets.chomp.scan(/[ATCG]+/).map(&:length)+[0]).max
[ "call.arguments.change" ]
901,572
901,574
u358554431
ruby
p03086
S = gets.chomp().split("") acgt = ["A", "C", "G", "T"] count = 0 max_count = 0 S.each do |s| if acgt.include?(s) count += 1 elsif count > max_count max_count = count count = 0 else count = 0 end end puts max_count
S = gets.chomp().split("") acgt = ["A", "C", "G", "T"] count = 0 max_count = 0 S.each do |s| if acgt.include?(s) count += 1 elsif count > max_count max_count = count count = 0 else count = 0 end end puts [max_count, count].max
[ "call.arguments.change", "call.add" ]
901,585
901,586
u867005447
ruby
p03086
s = gets.chomp acgt = "ACGT".chars max = 0 (0..(s.length-1)).to_a.combination(2) do |a,b| c = s[a..b] if (c.chars - acgt) == [] max = [max, c.length].max end end puts max
s = gets.chomp acgt = "ACGT".chars max = 0 (0..(s.length-1)).to_a.repeated_combination(2) do |a,b| c = s[a..b] if (c.chars - acgt) == [] max = [max, c.length].max end end puts max
[ "identifier.change" ]
901,680
901,681
u158131514
ruby
p03086
S = gets.chomp ans = 0 max = 0 S.chars.each do |s| if s == 'A' ans += 1 elsif s == 'T' ans += 1 elsif s == 'C' ans += 1 elsif s == 'G' ans += 1 else if ans > max max = ans end ans = 0 end end puts max
S = gets.chomp ans = 0 max = 0 S.chars.each do |s| if s == 'A' ans += 1 elsif s == 'T' ans += 1 elsif s == 'C' ans += 1 elsif s == 'G' ans += 1 else if ans > max max = ans end ans = 0 end end puts [ans, max].max
[ "call.add" ]
901,718
901,719
u237620737
ruby
p03086
def test ss = gets.chomp keys = %w(A C G T) cnt = 0 ans = 0 ss.each_char do |s| if keys.include?(s) cnt += 1 else ans = cnt if cnt > ans cnt = 0 end end ans end puts test
def test ss = gets.chomp keys = %w(A C G T) cnt = 0 ans = 0 ss.each_char do |s| if keys.include?(s) cnt += 1 else ans = cnt if cnt > ans cnt = 0 end end [ans, cnt].max end puts test
[ "call.add" ]
901,836
901,837
u884879015
ruby
p03086
a = gets.chomp.to_s cnt = 0 flg = 0 res = 0 a.each_char do |s| case s when 'A','C','G','T' flg = 1 cnt += 1 res = cnt else if flg == 1 if res <= cnt res = cnt end flg = 0 end cnt = 0 end end puts res
a = gets.chomp.to_s cnt = 0 flg = 0 res = 0 a.each_char do |s| case s when 'A','C','G','T' flg = 1 cnt += 1 if res <= cnt res = cnt end else if flg == 1 if res <= cnt res = cnt end flg = 0 end cnt = 0 end end puts res
[]
901,890
901,891
u135201316
ruby
p03087
def get_i() #空白区切の入力を数値(整数)の配列で返す return gets.chomp.split(" ").map(&:to_i) end def get_f() #空白区切の入力を数値(実数)の配列で返す return gets.chomp.split(" ").map(&:to_f) end def get() #空白区切の入力を文字列の配列で返す return gets.chomp.split(" ") end def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す return gets.chomp.split("") end def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する return bool ? y : n end def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す if n==1 return Array.new(size){init} else return Array.new(n).map{Array.new(size){init}} end end n,q=get_i s=get_nsp table=array(n+1,1,0) flag=false n.times do|i| val=0 if s[i]=="A" flag=true elsif s[i]=="C" val=1 flag=false else flag=false end table[i+1]=table[i]+val end q.times do l,r=get_i #l-=1 #r-=1 puts table[r]-table[l] end
def get_i() #空白区切の入力を数値(整数)の配列で返す return gets.chomp.split(" ").map(&:to_i) end def get_f() #空白区切の入力を数値(実数)の配列で返す return gets.chomp.split(" ").map(&:to_f) end def get() #空白区切の入力を文字列の配列で返す return gets.chomp.split(" ") end def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す return gets.chomp.split("") end def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する return bool ? y : n end def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す if n==1 return Array.new(size){init} else return Array.new(n).map{Array.new(size){init}} end end n,q=get_i s=get_nsp table=array(n+1,1,0) flag=false n.times do|i| val=0 if s[i]=="A" flag=true elsif flag and s[i]=="C" val=1 flag=false else flag=false end table[i+1]=table[i]+val end q.times do l,r=get_i #l-=1 #r-=1 puts table[r]-table[l] end
[ "control_flow.branch.if.condition.change" ]
902,492
902,493
u415400221
ruby
p03087
def get_i() #空白区切の入力を数値(整数)の配列で返す return gets.chomp.split(" ").map(&:to_i) end def get_f() #空白区切の入力を数値(実数)の配列で返す return gets.chomp.split(" ").map(&:to_f) end def get() #空白区切の入力を文字列の配列で返す return gets.chomp.split(" ") end def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す return gets.chomp.split("") end def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する return bool ? y : n end def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す if n==1 return Array.new(size){init} else return Array.new(n).map{Array.new(size){init}} end end n,q=get_i s=get_nsp table=array(n+1,1,0) flag=true n.times do|i| val=0 if s[i]=="A" flag=true elsif s[i]=="C" val=1 flag=false else flag=false end table[i+1]=table[i]+val end q.times do l,r=get_i #l-=1 #r-=1 puts table[r]-table[l] end
def get_i() #空白区切の入力を数値(整数)の配列で返す return gets.chomp.split(" ").map(&:to_i) end def get_f() #空白区切の入力を数値(実数)の配列で返す return gets.chomp.split(" ").map(&:to_f) end def get() #空白区切の入力を文字列の配列で返す return gets.chomp.split(" ") end def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す return gets.chomp.split("") end def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する return bool ? y : n end def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す if n==1 return Array.new(size){init} else return Array.new(n).map{Array.new(size){init}} end end n,q=get_i s=get_nsp table=array(n+1,1,0) flag=false n.times do|i| val=0 if s[i]=="A" flag=true elsif flag and s[i]=="C" val=1 flag=false else flag=false end table[i+1]=table[i]+val end q.times do l,r=get_i #l-=1 #r-=1 puts table[r]-table[l] end
[ "misc.opposites", "assignment.value.change", "control_flow.branch.if.condition.change" ]
902,494
902,493
u415400221
ruby
p03087
idx=Array.new(100100,0) n,q=gets.split.map(&:to_i) s=gets.chomp cnt=0 for i in 1..s.length-1 do if s[i-1]=="a" && s[i]=="c" cnt+=1 end idx[i]=cnt end for i in 1..q do a,b=gets.split.map(&:to_i) p idx[b-1]-idx[a-1] end
idx=Array.new(100100,0) n,q=gets.split.map(&:to_i) s=gets.chomp cnt=0 for i in 1..s.length-1 do if s[i-1]=="A" && s[i]=="C" cnt+=1 end idx[i]=cnt end for i in 1..q do a,b=gets.split.map(&:to_i) p idx[b-1]-idx[a-1] end
[ "literal.string.change", "literal.string.case.change", "control_flow.branch.if.condition.change", "misc.typo" ]
902,561
902,562
u803684095
ruby
p03086
p gets.split(/[^ACGT]/).map(&:size).max
p gets.split(/[^ACGT]/).map(&:size).max||0
[ "expression.operation.binary.add" ]
902,826
902,827
u207056619
ruby
p03086
data = gets data = data.chomp datas = data.chars answer = 0 tmp_answer = 0 datas.each do|elm| p elm if ((elm == "A") || (elm == "G") || (elm == "C") || (elm == "T")) tmp_answer += 1 p "COUTNTED" else if tmp_answer > answer answer = tmp_answer end tmp_answer = 0 end end if tmp_answer > answer answer = tmp_answer end puts answer.to_s
data = gets data = data.chomp datas = data.chars answer = 0 tmp_answer = 0 datas.each do|elm| if ((elm == "A") || (elm == "G") || (elm == "C") || (elm == "T")) tmp_answer += 1 else if tmp_answer > answer answer = tmp_answer end tmp_answer = 0 end end if tmp_answer > answer answer = tmp_answer end puts answer.to_s
[ "call.remove" ]
902,846
902,847
u328174452
ruby
p03087
n, q = gets.chomp.split.map(&:to_i) s = gets.chomp l = [] r = [] q.times do |i| l[i], r[i] = gets.chomp.split.map(&:to_i) end memo = [] (n-1).times do |i| if s[i..i+1] == 'AC' memo.push(i) end end q.times do |i| le = l[i] - 1 ri = r[i] - 2 le_ind = memo.bsearch_index { |x| x >= le } ri_ind = memo.bsearch_index { |x| x > ri } || memo.size p ri_ind - le_ind end
n, q = gets.chomp.split.map(&:to_i) s = gets.chomp l = [] r = [] q.times do |i| l[i], r[i] = gets.chomp.split.map(&:to_i) end memo = [] (n-1).times do |i| if s[i..i+1] == 'AC' memo.push(i) end end q.times do |i| le = l[i] - 1 ri = r[i] - 2 le_ind = memo.bsearch_index { |x| x >= le } || memo.size ri_ind = memo.bsearch_index { |x| x > ri } || memo.size p ri_ind - le_ind end
[ "assignment.change" ]
902,890
902,891
u195257137
ruby
p03087
n, q = gets.split.map(&:to_i) s = gets.chomp t = Array.new(n, 0) ans = [] n.times do |i| t[i] = t[i-1] + (s[i-1, 2] == 'AC' ? 1 : 0) puts t[i] end q.times do |i| l, r = gets.split.map(&:to_i) ans[i] = t[r-1] - t[l-1] end puts ans
n, q = gets.split.map(&:to_i) s = gets.chomp t = Array.new(n, 0) ans = [] n.times do |i| t[i] = t[i-1] + (s[i-1, 2] == 'AC' ? 1 : 0) end q.times do |i| l, r = gets.split.map(&:to_i) ans[i] = t[r-1] - t[l-1] end puts ans
[ "call.remove" ]
903,126
903,127
u721689253
ruby
p03087
n, q = gets.split.map(&:to_i) s = gets.chomp lrs = [0,0] (0..n-2).each{|i| lrs << lrs.last + (s[i,2] == 'AC' ? 1 : 0) } q.times do l, r = gets.split.map(&:to_i) puts lrs[r-1] - lrs[l-1] end
n, q = gets.split.map(&:to_i) s = gets.chomp lrs = [0] (0..n-2).each{|i| lrs << lrs.last + (s[i,2] == 'AC' ? 1 : 0) } q.times do l, r = gets.split.map(&:to_i) puts lrs[r-1] - lrs[l-1] end
[]
903,183
903,184
u069429049
ruby
p03087
n,q = gets.split(' ').map &:to_i s = gets.chop.split('') pre = '' arr = [] point = 0 s.each_with_index do |t, i| point += 1 if pre == 'A' && t == 'C' arr[i] = point pre = t end p arr q.times { l,r = gets.split(' ').map &:to_i p arr[r-1] - arr[l-1] }
n,q = gets.split(' ').map &:to_i s = gets.chop.split('') pre = '' arr = [] point = 0 s.each_with_index do |t, i| point += 1 if pre == 'A' && t == 'C' arr[i] = point pre = t end q.times { l,r = gets.split(' ').map &:to_i p arr[r-1] - arr[l-1] }
[ "call.remove" ]
903,226
903,227
u360187321
ruby
p03087
io = STDIN n,q=io.gets.split.map(&:to_i) str=io.gets.chomp +" " ar=Array.new(n,0) cnt=0 n.times do |i| cnt+=1 if str[i..i+1]=='AC' ar[i]=cnt end ar.unshift(0) p ar q.times.each do l,r=io.gets.split.map(&:to_i) p ar[r-1]-ar[l-1] end
io = STDIN n,q=io.gets.split.map(&:to_i) str=io.gets.chomp +" " ar=Array.new(n,0) cnt=0 n.times do |i| cnt+=1 if str[i..i+1]=='AC' ar[i]=cnt end ar.unshift(0) q.times.each do l,r=io.gets.split.map(&:to_i) p ar[r-1]-ar[l-1] end
[ "call.remove" ]
903,243
903,244
u132360211
ruby
p03087
N,Q = gets.chomp.split(" ").map(&:to_i) S = gets.chomp.split("").map(&:to_s) ac_count = [] count = 0 S.each_with_index do |str,i| if i == 0 ac_count << 0 else if S[i-1]+S[i] == "AC" count += 1 ac_count << count else ac_count << count end end end p ac_count Q.times do |i| begin_i,end_i = gets.chomp.split(" ").map(&:to_i) puts ac_count[end_i-1] - ac_count[begin_i-1] end
N,Q = gets.chomp.split(" ").map(&:to_i) S = gets.chomp.split("").map(&:to_s) ac_count = [] count = 0 S.each_with_index do |str,i| if i == 0 ac_count << 0 else if S[i-1]+S[i] == "AC" count += 1 ac_count << count else ac_count << count end end end # p ac_count Q.times do |i| begin_i,end_i = gets.chomp.split(" ").map(&:to_i) puts ac_count[end_i-1] - ac_count[begin_i-1] end
[ "call.remove" ]
903,275
903,276
u966695319
ruby
p03088
#!/usr/bin/env ruby require 'set' class Hash def push(key, value) self[key] = [] if self[key] == nil self[key].push(value) end end class Array def each_cons_with_ends(num) array = [] each_cons(num).with_index do |*x, i| prev = i > 0 ? self[0..i-1] : [] following = self[(i+num)..] yield(*x, prev, following) if block_given? array << [*x, prev, following] end array.to_enum end def lower_bound(value) left = -1; right = self.length; while left + 1 < right mid = left + (right - left) / 2; if self[mid] >= value right = mid else left = mid end end right end def unique res = [self.first] each_cons(2) do |a, b| if a != b res.push(b) end end res end end def get_ints gets.chomp.split.map(&:to_i) end def get_ints_minus_one get_ints.map { |x| x - 1 } end def get_int gets.chomp.to_i end def exponential_with_mod(n, k, mod) return 1 if k == 0 return n if k == 1 if k % 2 == 1 (n * (exponential_with_mod(n, k/2, mod) ** 2 % mod)) % mod else (exponential_with_mod(n, k/2, mod) ** 2) % mod end end # mod m での aの逆元 # mが素数のときのみ有効 def modinv(a, m) b = m; u = 1; v = 0 while b != 0 t = a / b a -= t * b c = a; a = b; b = c u -= t * v c = u; u = v; v = c end u %= m u += m if u < 0 u end def nCk(n, k, mod) ue = 1 shita = 1 k.times do |a| ue = ue * (n - a) % mod shita = shita * (k - a) % mod end ue * modinv(shita, mod) % mod end N = get_int MOD = 10 ** 9 + 7 @memo = Array.new(N+1) { {} } def ok(last4) 4.times do |i| return false if last4.include?('ACG') chars = last4.split('') return false if chars.each_cons_with_ends(2).any? do |a, b, prev, fol| (prev + [b, a] + fol).join.include?('ACG') end end return true end def dfs(cur, last3) return @memo[cur][last3] if @memo[cur][last3] return 1 if cur == N ret = 0 %w[A C G T].each do |s| ret = (ret + dfs(cur+1, last3[1..] + s)) % MOD if ok(last3 + s) end @memo[cur][last3] = ret ret end puts dfs(0, 'TTT')
#!/usr/bin/env ruby require 'set' class Hash def push(key, value) self[key] = [] if self[key] == nil self[key].push(value) end end class Array def each_cons_with_ends(num) array = [] each_cons(num).with_index do |*x, i| prev = i > 0 ? self[0..i-1] : [] following = self[(i+num)..] yield(*x, prev, following) if block_given? array << [*x, prev, following] end array.to_enum end def lower_bound(value) left = -1; right = self.length; while left + 1 < right mid = left + (right - left) / 2; if self[mid] >= value right = mid else left = mid end end right end def unique res = [self.first] each_cons(2) do |a, b| if a != b res.push(b) end end res end end def get_ints gets.chomp.split.map(&:to_i) end def get_ints_minus_one get_ints.map { |x| x - 1 } end def get_int gets.chomp.to_i end def exponential_with_mod(n, k, mod) return 1 if k == 0 return n if k == 1 if k % 2 == 1 (n * (exponential_with_mod(n, k/2, mod) ** 2 % mod)) % mod else (exponential_with_mod(n, k/2, mod) ** 2) % mod end end # mod m での aの逆元 # mが素数のときのみ有効 def modinv(a, m) b = m; u = 1; v = 0 while b != 0 t = a / b a -= t * b c = a; a = b; b = c u -= t * v c = u; u = v; v = c end u %= m u += m if u < 0 u end def nCk(n, k, mod) ue = 1 shita = 1 k.times do |a| ue = ue * (n - a) % mod shita = shita * (k - a) % mod end ue * modinv(shita, mod) % mod end N = get_int MOD = 10 ** 9 + 7 @memo = Array.new(N+1) { {} } def ok(last4) 4.times do |i| return false if last4.include?('ACG') chars = last4.split('') return false if chars.each_cons_with_ends(2).any? do |(a, b), prev, fol| (prev + [b, a] + fol).join.include?('ACG') end end return true end def dfs(cur, last3) return @memo[cur][last3] if @memo[cur][last3] return 1 if cur == N ret = 0 %w[A C G T].each do |s| ret = (ret + dfs(cur+1, last3[1..] + s)) % MOD if ok(last3 + s) end @memo[cur][last3] = ret ret end puts dfs(0, 'TTT')
[ "control_flow.branch.if.condition.change" ]
903,693
903,694
u305883349
ruby
p03088
n = gets.strip.to_i MOD = 10**9+7 dp = {'' => 1} n.times do next_hash = Hash.new(0) dp.each do |k, v| 'AGCT'.chars.each do |c| s = (k+c) s = s[1..-1] if s.length > 3 next if s.match(/AGC|GAC|ACG|AG.C|A.GC/) next_hash[s] += v next_hash[s] %= MOD end end dp = next_hash end #p dp p dp.values.inject(:+) % MOD
n = gets.strip.to_i MOD = 10**9+7 dp = {'' => 1} n.times do next_hash = Hash.new(0) dp.each do |k, v| 'AGCT'.chars.each do |c| # s = (k+c)[1..-1] s = (k+c) s = s[1..-1] if s.length == 5 next if s.match(/AGC|GAC|ACG|AG.C|A.GC/) next_hash[s] += v next_hash[s] %= MOD end end # p dp # p '-' dp = next_hash end # p dp p dp.values.inject(:+) % MOD
[]
903,794
903,795
u021358975
ruby
p03087
n,q = gets.split().map(&:to_i) s = gets.chomp lr = q.times.map{gets.split().map(&:to_i)} count = [] count[0] = 0 (1..n-1).each do |i| if s[i-1..i] == "AC" then count[i] = count[i-1] + 1 else count[i] = count[i-1] end end p count lr.each do |l,r| p count[r-1] - count[l-1] end
n,q = gets.split().map(&:to_i) s = gets.chomp lr = q.times.map{gets.split().map(&:to_i)} count = [] count[0] = 0 (1..n-1).each do |i| if s[i-1..i] == "AC" then count[i] = count[i-1] + 1 else count[i] = count[i-1] end end lr.each do |l,r| p count[r-1] - count[l-1] end
[ "call.remove" ]
903,955
903,956
u070036461
ruby
p03088
input = gets.to_i dp=Array.new(101).map{Array.new(4,0).map{Array.new(4,0).map{Array.new(4,0)}}} #dp[101][4][4][4] = kazu dp[0][3][3][3] = 1 mod = 10 ** 9 + 7 input.times{|kazu| 4.times{|c1| 4.times{|c2| 4.times{|c3| 4.times{|a| #ダメな5つの条件をカットする if (a == 2 && c1 == 1 && c2 == 0) then next end if (a == 2 && c1 == 0 && c2 == 1) then next end if (a == 1 && c1 == 2 && c2 == 0) then next end if (a == 2 && c1 == 1 && c3 == 0) then next end if (a == 2 && c2 == 1 && c3 == 0) then next end dp[input + 1][a][c1][c2] += dp[input][c1][c2][c3] dp[input + 1][a][c1][c2] %= mod } } } } } ans = 0 4.times{|c1| 4.times{|c2| 4.times{|c3| ans += dp[input][c1][c2][c3]; ans %= mod; } } } print ans
input = gets.to_i dp=Array.new(101).map{Array.new(4,0).map{Array.new(4,0).map{Array.new(4,0)}}} #dp[101][4][4][4] = kazu dp[0][3][3][3] = 1 mod = 10 ** 9 + 7 input.times{|kazu| 4.times{|c1| 4.times{|c2| 4.times{|c3| 4.times{|a| #ダメな5つの条件をカットする if (a == 2 && c1 == 1 && c2 == 0) then next end if (a == 2 && c1 == 0 && c2 == 1) then next end if (a == 1 && c1 == 2 && c2 == 0) then next end if (a == 2 && c1 == 1 && c3 == 0) then next end if (a == 2 && c2 == 1 && c3 == 0) then next end dp[kazu + 1][a][c1][c2] += dp[kazu][c1][c2][c3] dp[kazu + 1][a][c1][c2] %= mod } } } } } ans = 0 4.times{|c1| 4.times{|c2| 4.times{|c3| ans += dp[input][c1][c2][c3]; ans %= mod; } } } print ans
[ "identifier.change", "variable_access.subscript.index.change" ]
904,011
904,012
u312004378
ruby
p03089
N = gets.to_i b = gets.split.map(&:to_i) res = [] until b.empty? do (1..b.length).reverse_each do |i| if b[i-1] == i res << i b.delete_at(i-1) break end if i == b.length puts -1 exit end end end puts res.reverse
N = gets.to_i b = gets.split.map(&:to_i) res = [] until b.empty? do (1..b.length).reverse_each do |i| if b[i-1] == i res << i b.delete_at(i-1) break end if i == 1 puts -1 exit end end end puts res.reverse
[ "identifier.replace.remove", "literal.replace.add", "control_flow.branch.if.condition.change", "call.remove" ]
904,245
904,246
u291278680
ruby
p03090
n = gets.to_i x = n/2*2 a = [] 1.upto(x-1){|i|a << [i].product((i+1..x).to_a - [x+1-i]).map{|e| e*" "}} a << Array.new(x-1){|i| [i+1,n]*" "} if n.odd? puts a.size, a
n = gets.to_i x = n/2*2 a = [] 1.upto(x-1){|i| a += [i].product((i+1..x).to_a - [x+1-i]).map{|e| e*" "}} a += Array.new(x){|i| [i+1,n]*" "} if n.odd? puts a.size, a
[ "expression.operation.binary.change", "expression.operation.binary.remove" ]
904,437
904,438
u692254521
ruby
p03090
n = gets.chomp.to_i ary = [] for i in 1..n for j in i..n if i < j ary << [i,j] end end end if n % 2 == 1 for i in 1..(n-1) if i < n-i ary.delete([i, n-i]) else ary.delete([n-i, i]) end end else for i in 1..(n-1) if i < n-i+1 ary.delete([i, n-i+1]) else ary.delete([n-i+1, i]) end end end ary.each do |i| print(i[0].to_s+" "+i[1].to_s+"\n") end
n = gets.chomp.to_i ary = [] for i in 1..n for j in i..n if i < j ary << [i,j] end end end if n % 2 == 1 for i in 1..(n-1) if i < n-i ary.delete([i, n-i]) else ary.delete([n-i, i]) end end else for i in 1..(n-1) if i < n-i+1 ary.delete([i, n-i+1]) else ary.delete([n-i+1, i]) end end end puts ary.length ary.each do |i| print(i[0].to_s+" "+i[1].to_s+"\n") end
[ "call.add" ]
904,681
904,682
u706730549
ruby
p03095
DIVISOR = 10**9+7 gets gets.chomp.each_char.reduce({}){ |z, v| z[v] = (z[v] || 0) + 1; z }.reduce(1){ |res, kv| (res*(kv[1]+1)) % DIVISOR }
DIVISOR = 10**9+7 gets puts gets.chomp.each_char.reduce({}){ |z, v| z[v] = (z[v] || 0) + 1; z }.reduce(1){ |res, kv| (res*(kv[1]+1)) % DIVISOR } - 1
[ "io.output.change", "call.add" ]
905,822
905,823
u895515293
ruby
p03096
n = gets.to_i c = n.times.map{gets.to_i-1} mod = 10**9+7 dp = Array.new(n+1,0) dp[0] = 1 a = Array.new(n,-1) n.times do |i| dp[i+1] = dp[i] if a[c[i]] > -1 && c[i-1] != c[i] dp[i+1] += dp[a[c[i]]+1] dp[i+1] %= mod end a[c[i]] = i end puts dp[n]
n = gets.to_i c = n.times.map{gets.to_i-1} mod = 10**9+7 dp = Array.new(n+1,0) dp[0] = 1 a = Hash.new(-1) n.times do |i| dp[i+1] = dp[i] if a[c[i]] > -1 && c[i-1] != c[i] dp[i+1] += dp[a[c[i]]+1] dp[i+1] %= mod end a[c[i]] = i end puts dp[n]
[ "assignment.value.change", "call.arguments.change" ]
907,297
907,298
u506255180
ruby