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 |
|---|---|---|---|---|---|---|---|
p02421
|
#!/usr/bin/env ruby
turn = gets.to_i
line = []
taro_points = 0;hanako_points = 0
turn.times do
line = gets.split
if line[0] == line[1] then
taro_points += 1
hanako_points += 1
elsif line[0] > line[1] then
hanako_points += 3
elsif line[0] < line[1] then
taro_points += 3
end
end
puts "#{taro_points} #{hanako_points}"
|
#!/usr/bin/env ruby
turn = gets.to_i
line = []
taro_points = 0;hanako_points = 0
turn.times do
line = gets.split
if line[0] == line[1] then
taro_points += 1
hanako_points += 1
elsif line[0] > line[1] then
taro_points += 3
elsif line[0] < line[1] then
hanako_points += 3
end
end
puts "#{taro_points} #{hanako_points}"
|
[
"identifier.change"
] | 223,371
| 223,372
|
u948491783
|
ruby
|
p02421
|
n = gets.chomp.to_i
taro,hanako = 0,0
n.times do
c1,c2 = gets.chomp.split(" ")
if c1 < c2
taro += 3
elsif c1 > c2
hanako += 3
else
taro,hanako = taro + 1,hanako +1
end
end
puts "#{taro} #{hanako}"
|
n = gets.chomp.to_i
taro,hanako = 0,0
n.times do
c1,c2 = gets.chomp.split(" ")
if c1 > c2
taro += 3
elsif c1 < c2
hanako += 3
else
taro,hanako = taro + 1,hanako +1
end
end
puts "#{taro} #{hanako}"
|
[
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 223,381
| 223,382
|
u759791460
|
ruby
|
p02421
|
n = gets.to_i
taro = 0
hanaco = 0
n.times.each do
t,h = gets.split
taro += 3 if t > h
hanako += 3 if h < t
taro += 1 if h == t
hanako += 1 if h == t
end
puts [taro,hanako].join(" ")
|
n = gets.to_i
taro = 0
hanako = 0
n.times.each do
t,h = gets.split
taro += 3 if t > h
hanako += 3 if h > t
taro += 1 if h == t
hanako += 1 if h == t
end
puts [taro,hanako].join(" ")
|
[
"assignment.variable.change",
"identifier.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 223,386
| 223,387
|
u407138207
|
ruby
|
p02421
|
n = gets.to_i
taro = 0
hanaco = 0
n.times.each do
t,h = gets.split
taro += 3 if t > h
hanako += 3 if h > t
taro += 1 if h == t
hanako += 1 if h == t
end
puts [taro,hanako].join(" ")
|
n = gets.to_i
taro = 0
hanako = 0
n.times.each do
t,h = gets.split
taro += 3 if t > h
hanako += 3 if h > t
taro += 1 if h == t
hanako += 1 if h == t
end
puts [taro,hanako].join(" ")
|
[
"assignment.variable.change",
"identifier.change"
] | 223,388
| 223,387
|
u407138207
|
ruby
|
p02421
|
n = gets.to_i
taro = 0
hanaco = 0
n.times.each do
t,h = gets.split
taro += 3 if t > h
hanako += 3 if h > t
taro += 1 if h == t
hanako += 1 if h == t
end
puts [taro,hanako].join(" ")
|
n = gets.to_i
taro = 0
hanako = 0
n.times.each do
t,h = gets.split
taro += 3 if t > h
hanako += 3 if h > t
taro += 1 if h == t
hanako += 1 if h == t
end
puts [taro,hanako].join(" ")
|
[
"assignment.variable.change",
"identifier.change"
] | 223,390
| 223,387
|
u407138207
|
ruby
|
p02421
|
i = gets.to_i
tt = hh = 0
i.times { |j|
t, h = gets,chomp.split
if t < h
hh += 3
elsif t > h
tt += 3
else
tt += 1
hh += 1
end
}
puts "#{tt} #{hh}"
|
i = gets.to_i
tt = hh = 0
i.times { |j|
t, h = gets.chomp.split
if t < h
hh += 3
elsif t > h
tt += 3
else
tt += 1
hh += 1
end
}
puts "#{tt} #{hh}"
|
[
"assignment.value.change"
] | 223,399
| 223,400
|
u216813029
|
ruby
|
p02420
|
while(s=gets.chomp)!='-'
gets.to_i.times{p s+=s.slice!(0,gets.to_i)};puts s end
|
while(s=gets.chomp)!='-'
gets.to_i.times{s+=s.slice!(0,gets.to_i)};puts s end
|
[
"io.output.change",
"call.remove"
] | 223,521
| 223,522
|
u353994935
|
ruby
|
p02420
|
#!/usr/bin/env ruby
result = []
while true
cards = gets.chomp
if cards == "-" then
break
end
loopnumber = gets.to_i
loopnumber.times do
shufflenumber = gets.to_i
temp = cards * 2
cards = temp.slice(cards.length - shufflenumber,cards.length)
end
result << cards
end
puts result
|
#!/usr/bin/env ruby
result = []
while true
cards = gets.chomp
if cards == "-" then
break
end
loopnumber = gets.to_i
loopnumber.times do
shufflenumber = gets.to_i
temp = cards * 2
cards = temp.slice(shufflenumber,cards.length)
end
result << cards
end
puts result
|
[
"expression.operation.binary.remove"
] | 223,523
| 223,524
|
u948491783
|
ruby
|
p02420
|
while (a = gets) != "-"
a = a.chomp.chars
n = gets.to_i
for i in 1..n
s = gets.to_i
for j in 1..s
a.push(a.shift)
end
end
(0..a.size).each { |h|
print a[h]
}
puts
end
|
while (a = gets.chomp) != "-"
a = a.chars
n = gets.to_i
for i in 1..n
s = gets.to_i
for j in 1..s
a.push(a.shift)
end
end
(0..a.size).each { |h|
print a[h]
}
puts
end
|
[
"call.add",
"call.remove"
] | 223,539
| 223,540
|
u216813029
|
ruby
|
p02420
|
while (al_line = gets.chomp) != "-" do
h = gets.to_i
(0..(h-1)).each {|i|
# puts "#{i}回目"
back_str = ''
n = gets.to_i
front_str = al_line[0,n]
# puts "al_lineの削除する文字を出力"
al_line.slice!(0,n)
al_line = al_line + front_str
puts al_line
}
puts al_line
end
|
while (al_line = gets.chomp) != "-" do
h = gets.to_i
(0..(h-1)).each {|i|
back_str = ''
n = gets.to_i
front_str = al_line[0,n]
# puts "al_lineの削除する文字を出力"
al_line.slice!(0,n)
al_line = al_line + front_str
# puts al_line
}
puts al_line
end
|
[
"call.remove"
] | 223,541
| 223,542
|
u251341266
|
ruby
|
p02420
|
while (str = $stdin.gets(chomp:true)) != "-"
tms = $stdin.gets(chomp:true).to_i
shl_crd = []
tms.times do
shl_crd << file.gets(chomp:true).to_i
end
shl_crd.each do | num |
str << str.slice!(0...num)
end
puts str
end
|
while (str = $stdin.gets(chomp:true)) != "-"
tms = $stdin.gets(chomp:true).to_i
shl_crd = []
tms.times do
shl_crd << $stdin.gets(chomp:true).to_i
end
shl_crd.each do | num |
str << str.slice!(0...num)
end
puts str
end
|
[
"expression.operation.binary.change",
"call.add"
] | 223,546
| 223,547
|
u958508535
|
ruby
|
p02420
|
while (str = gets.chomp) != '-'
gets.to_i.times do
h = gets.to_i
str = str[h..-1] + str[0...h]
puts str
end
end
|
while (str = gets.chomp) != '-'
gets.to_i.times do
h = gets.to_i
str = str[h..-1] + str[0...h]
end
puts str
end
|
[] | 223,548
| 223,549
|
u517414491
|
ruby
|
p02422
|
str = gets.chomp
q = gets.chomp.to_i
q.times {
order = gets.chomp.split(" ")
if order[0] == "print"
print(str[order[1].to_i..order[2].to_i+1],"\n")
elsif order[0] == "reverse"
str[order[1].to_i..order[2].to_i] = str[order[1].to_i..order[2].to_i].reverse
elsif order[0] == "replace"
str[order[1].to_i..order[2].to_i] = order[3]
end
}
|
str = gets.chomp
q = gets.chomp.to_i
q.times {
order = gets.chomp.split(" ")
if order[0] == "print"
print(str[order[1].to_i..order[2].to_i],"\n")
elsif order[0] == "reverse"
str[order[1].to_i..order[2].to_i] = str[order[1].to_i..order[2].to_i].reverse
elsif order[0] == "replace"
str[order[1].to_i..order[2].to_i] = order[3]
end
}
|
[
"expression.operation.binary.remove"
] | 223,796
| 223,797
|
u843848664
|
ruby
|
p02422
|
str = gets.chomp
gets.to_i.times do
q = gets.chomp.split
a = n[1].to_i
b = n[2].to_i
case n[0]
when 'replace'
str[a..b] = n[3]
when 'reverse'
str[a..b] = str[a..b].reverse
when 'print'
puts str[a..b]
end
end
|
str = gets.chomp
gets.to_i.times do
l = gets.chomp.split
a = l[1].to_i
b = l[2].to_i
case l[0]
when 'replace'
str[a..b] = l[3]
when 'reverse'
str[a..b] = str[a..b].reverse
when 'print'
puts str[a..b]
end
end
|
[
"assignment.variable.change",
"identifier.change",
"assignment.value.change",
"io.output.change"
] | 223,800
| 223,801
|
u802537549
|
ruby
|
p02422
|
str = gets.chomp
gets.to_i.times do
l = gets.chomp.split
a = l[1].to_i
b = l[2].to_i
case n[0]
when 'replace'
str[a..b] = l[3]
when 'reverse'
str[a..b] = str[a..b].reverse
when 'print'
puts str[a..b]
end
end
|
str = gets.chomp
gets.to_i.times do
l = gets.chomp.split
a = l[1].to_i
b = l[2].to_i
case l[0]
when 'replace'
str[a..b] = l[3]
when 'reverse'
str[a..b] = str[a..b].reverse
when 'print'
puts str[a..b]
end
end
|
[
"identifier.change"
] | 223,802
| 223,801
|
u802537549
|
ruby
|
p02422
|
str = gets.to_s
q = gets.to_i
w = []
q.times do
x, a, b, q = gets.split.map(&:to_s)
a = a.to_i
b = b.to_i
case x
when "reverse" then
str[a..b] = str[a..b].reverse
when "replace"
str[a..b] = str[a..b].replace(q)
when "print" then
print str[a..b]
end
end
|
str = gets.to_s
q = gets.to_i
w = []
q.times do
x, a, b, q = gets.split.map(&:to_s)
a = a.to_i
b = b.to_i
case x
when "reverse" then
str[a..b] = str[a..b].reverse
when "replace"
str[a..b] = str[a..b].replace(q)
when "print" then
puts str[a..b]
end
end
|
[
"identifier.change",
"io.output.change"
] | 223,803
| 223,804
|
u489219392
|
ruby
|
p02422
|
s = gets.chomp
gets.to_i.times do
o, b, e, r = gets.split
b, e = b.to_i, e.to_i + 1
case o
when 'print' then puts s[b, e]
when 'reverse' then s[b, e] = s[b, e].reverse
when 'replace' then s[b, e] = r
end
end
|
s = gets.chomp
gets.to_i.times do
o, b, e, r = gets.split
b, e = b.to_i, e.to_i
case o
when 'print' then puts s[b..e]
when 'reverse' then s[b..e] = s[b..e].reverse
when 'replace' then s[b..e] = r
end
end
|
[
"expression.operation.binary.remove",
"variable_access.subscript.index.change",
"call.arguments.change",
"io.output.change",
"assignment.variable.change",
"assignment.value.change"
] | 223,808
| 223,809
|
u295404099
|
ruby
|
p02417
|
str = []
while tmp = gets.chomp do
break if tmp.size == 0
str << tmp.downcase.split("")
end
str.flatten!
("a".."z").each do |alp|
cnt = str.count{|char| char == alp}
puts "#{alp} : #{cnt}"
end
|
str = []
while tmp = gets do
break if tmp.size == 0
str << tmp.downcase.chomp.split("")
end
str.flatten!
("a".."z").each do |alp|
cnt = str.count{|char| char == alp}
puts "#{alp} : #{cnt}"
end
|
[
"call.remove",
"call.add"
] | 224,189
| 224,190
|
u374061464
|
ruby
|
p02417
|
text = gets(0).downcase
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
text = gets("").downcase
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
[
"assignment.value.change",
"call.arguments.change"
] | 224,200
| 224,199
|
u156659396
|
ruby
|
p02417
|
text = gets(0).downcase
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム
text = gets("").downcase #テキストに小文字をとる
for alphabet in "a".."z" #sをA から Zまで26回繰り返す
puts "#{alphabet} : #{text.count(alphabet)}" #まずAからZまで繰り返して テキストの中のアルファベットをカウントする
end
|
[
"assignment.value.change",
"call.arguments.change",
"identifier.change",
"literal.string.change"
] | 224,200
| 224,202
|
u156659396
|
ruby
|
p02417
|
#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム
text = gets("").downcase #テキストに小文字をとる
for alphabet in "a".."z" #sをA から Zまで26回繰り返す
puts "#{alphabet} : #{text*26.times*(alphabet)}" #まずAからZまで繰り返して テキストの中のアルファベットをカウントする
end
|
#入力した文書の中にアルファベット数字をいくつはいっているかをわかるプログラム
text = gets("").downcase #テキストに小文字をとる
for alphabet in "a".."z" #sをA から Zまで26回繰り返す
puts "#{alphabet} : #{text.count(alphabet)}" #まずAからZまで繰り返して テキストの中のアルファベットをカウントする
end
|
[
"literal.string.change",
"call.arguments.change"
] | 224,209
| 224,211
|
u156659396
|
ruby
|
p02417
|
h = {}
("a".."z").each { |char| h[char] = 0 }
while line = gets
line.chomp.chars do |char|
h[char] += 1 if /[a-z]/ === char
end
end
h.each {|key, value| puts "#{key} : #{value}"}
|
h = {}
("a".."z").each { |char| h[char] = 0 }
while line = gets
line.chomp.downcase.chars do |char|
h[char] += 1 if /[a-z]/ === char
end
end
h.each {|key, value| puts "#{key} : #{value}"}
|
[
"call.add"
] | 224,214
| 224,213
|
u742797815
|
ruby
|
p02417
|
text = gets.chomp
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
text = gets(nil).downcase
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
[
"call.arguments.add",
"assignment.value.change",
"identifier.change"
] | 224,219
| 224,220
|
u364560197
|
ruby
|
p02417
|
text = gets(nil)
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
text = gets(nil).downcase
for s in "a".."z"
puts "#{s} : #{text.count(s)}"
end
|
[
"call.add"
] | 224,222
| 224,220
|
u364560197
|
ruby
|
p02417
|
str = gets
('a'..'z').each do |alphabet|
puts "#{alphabet} : #{str.count(alphabet)}"
end
|
str = gets(nil).downcase
('a'..'z').each do |alphabet|
puts"#{alphabet} : #{str.count(alphabet)}"
end
|
[
"call.add"
] | 224,227
| 224,232
|
u873778695
|
ruby
|
p02417
|
lines = []
while true
line = STDIN.gets.chomp
if line.length == 0 then
break
end
lines << line
end
line = lines.join ("")
# puts line
element = line.downcase.chars.group_by{
|item| item.chr
}
# p element
for c in "a".."z" do
output = 0
if element[c] != nil then
output = element[c].length
end
puts "#{c} : #{output}"
end
|
lines = []
while true
line = STDIN.gets
if line == nil then
break
end
lines << line
end
line = lines.join ("")
# puts line
element = line.downcase.chars.group_by{
|item| item.chr
}
# p element
for c in "a".."z" do
output = 0
if element[c] != nil then
output = element[c].length
end
puts "#{c} : #{output}"
end
|
[
"call.remove",
"control_flow.branch.if.condition.change"
] | 224,233
| 224,234
|
u938745275
|
ruby
|
p02417
|
y = {}
(:a..:z).each do |i|
y[i] = 0
end
loop do
x = gets
if x == nil
break
end
x.gsub!(/[^a-zA-Z]/,"").downcase.split(//)
x.each do |i|
y[:"#{i}"] += 1
end
end
y.each do |k,v|
puts "#{k} : #{v}"
end
|
y = {}
(:a..:z).each do |i|
y[i] = 0
end
loop do
x = gets
if x == nil
break
end
z = x.gsub(/[^a-zA-Z]/,"").downcase.split(//)
z.each do |i|
y[:"#{i}"] += 1
end
end
y.each do |k,v|
puts "#{k} : #{v}"
end
|
[
"assignment.value.change",
"identifier.change"
] | 224,238
| 224,239
|
u960296069
|
ruby
|
p02417
|
str = "";
while s = gets do
str << s.chomp;
end
for c in 'a'..'z' do
puts c + " : " + str.count(c).to_s;
end
|
str = "";
while s = gets do
str << s.chomp;
end
str.downcase!;
for c in 'a'..'z' do
puts c + " : " + str.count(c).to_s;
end
|
[] | 224,248
| 224,249
|
u328069918
|
ruby
|
p02417
|
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_8-C
Character - Counting Characters
Time Limit : 1 sec, Memory Limit : 65536 KB
?????????????????????
?????????????????±??????????????????????????¢???????????????????????°?????°??????????????°????????????????????????????????? ??????????°?????????¨??§??????????????\???????????????
Input
?????°????????????????????????????????±???????????????????????????
Output
?????????????????±???????????????????????¢???????????????????????°?????\??????????????¢?????§????????????????????????
a : a????????°
b : b????????°
c : c????????°
.
.
z : z????????°
Constraints
??±???????????????????????° < 1200
Sample Input
This is a pen.
Sample Output
a : 1
b : 0
c : 0
d : 0
e : 1
f : 0
g : 0
h : 1
i : 2
j : 0
k : 0
l : 0
m : 0
n : 1
o : 0
p : 1
q : 0
r : 0
s : 2
t : 1
u : 0
v : 0
w : 0
x : 0
y : 0
z : 0
=end
fh=STDIN
#fh=open("IPT1_8_C.txt")
h = Hash.new
("a".."z").each {|c| h[c]=0}
while fh.gets
s=$_.chomp
puts s
str=s.downcase.split(//)
str.each {|c|
if not h.has_key?(c) then
h[c]=0
end
h[c] += 1
}
end
("a".."z").each {|c| puts c + " : " + h[c].to_s}
|
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_8-C
Character - Counting Characters
Time Limit : 1 sec, Memory Limit : 65536 KB
?????????????????????
?????????????????±??????????????????????????¢???????????????????????°?????°??????????????°????????????????????????????????? ??????????°?????????¨??§??????????????\???????????????
Input
?????°????????????????????????????????±???????????????????????????
Output
?????????????????±???????????????????????¢???????????????????????°?????\??????????????¢?????§????????????????????????
a : a????????°
b : b????????°
c : c????????°
.
.
z : z????????°
Constraints
??±???????????????????????° < 1200
Sample Input
This is a pen.
Sample Output
a : 1
b : 0
c : 0
d : 0
e : 1
f : 0
g : 0
h : 1
i : 2
j : 0
k : 0
l : 0
m : 0
n : 1
o : 0
p : 1
q : 0
r : 0
s : 2
t : 1
u : 0
v : 0
w : 0
x : 0
y : 0
z : 0
=end
fh=STDIN
#fh=open("IPT1_8_C.txt")
h = Hash.new
("a".."z").each {|c| h[c]=0}
while fh.gets
s=$_.chomp
str=s.downcase.split(//)
str.each {|c|
if not h.has_key?(c) then
h[c]=0
end
h[c] += 1
}
end
("a".."z").each {|c| puts c + " : " + h[c].to_s}
|
[
"call.remove"
] | 224,255
| 224,256
|
u032662562
|
ruby
|
p02417
|
str = $stdin.readlines.chomp.downcase
puts [*?a..?z].map{ |c| "#{c} : #{str.count(c)}" }
|
str = $stdin.read.chomp.downcase
puts [*?a..?z].map{ |c| "#{c} : #{str.count(c)}" }
|
[
"assignment.value.change",
"identifier.change"
] | 224,257
| 224,258
|
u365648092
|
ruby
|
p02417
|
lines = $stdin.read
array = lines.chomp.downcase.each_codepoint.to_a
sum_h = (96..122).to_a.map{ |c| [c, 0]}.to_h
array.each{|i| sum_h[i] += 1 unless sum_h[i].nil? }
sum_h.sort.select{|k,v| 96 < k && k < 123 }.map do |k,v|
puts "#{k.chr}: #{v}"
end
|
lines = $stdin.read
array = lines.chomp.downcase.each_codepoint.to_a
sum_h = (96..122).to_a.map{ |c| [c, 0]}.to_h
array.each{|i| sum_h[i] += 1 unless sum_h[i].nil? }
sum_h.sort.select{|k,v| 96 < k && k < 123 }.map do |k,v|
puts "#{k.chr} : #{v}"
end
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 224,266
| 224,264
|
u397596432
|
ruby
|
p02417
|
while str = gets
chars += str.downcase
end
('a'..'z').each do |letter|
# puts chars.count(letter)
puts "#{ letter } : #{ chars.count(letter) }"
end
|
chars = ""
while str = gets
chars += str.downcase
end
('a'..'z').each do |letter|
# puts chars.count(letter)
puts "#{ letter } : #{ chars.count(letter) }"
end
|
[
"assignment.add"
] | 224,272
| 224,273
|
u338661979
|
ruby
|
p02417
|
chrs = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
array = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while true do
str = gets.chomp.downcase
break if str.length == 0
chrs.each_with_index do |chr, index|
array[index] += str.count(chr)
end
end
chrs.each_with_index do |chr, index|
puts chr + " : " + array[index].to_s
end
|
chrs = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
array = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while str = gets do
str = str.chomp.downcase
break if str.length == 0
chrs.each_with_index do |chr, index|
array[index] += str.count(chr)
end
end
chrs.each_with_index do |chr, index|
puts chr + " : " + array[index].to_s
end
|
[
"assignment.add"
] | 224,278
| 224,279
|
u720435069
|
ruby
|
p02417
|
arr = Array.new(26, 0)
ch = [*('a'..'z')]
while true
s = gets
break if s == nil
length = s.chomp.length
for i in 1..length
al = s[i-1].downcase.ord - "a".ord
next if i < 0 || i > 25
arr[al] += 1
end
end
for i in 0..25
puts ch[i] + " : " + arr[i].to_s
end
|
arr = Array.new(26, 0)
ch = [*('a'..'z')]
while true
s = gets
break if s == nil
len = s.chomp.length
for i in 1..len
al = s[i-1].downcase.ord - "a".ord
next if al < 0 || al > 25
arr[al] += 1
end
end
for i in 0..25
puts ch[i] + " : " + arr[i].to_s
end
|
[
"assignment.variable.change",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 224,284
| 224,285
|
u087014397
|
ruby
|
p02417
|
dict = {
'a' => 0, 'b' => 0, 'c' => 0, 'd' => 0, 'e' => 0, 'f' => 0, 'g' => 0,
'h' => 0, 'i' => 0, 'j' => 0, 'k' => 0, 'l' => 0, 'm' => 0, 'n' => 0,
'o' => 0, 'p' => 0, 'q' => 0, 'r' => 0, 's' => 0, 't' => 0, 'u' => 0,
'v' => 0, 'w' => 0, 'x' => 0, 'y' => 0, 'z' => 0
}
while true
line = STDIN.gets
line.downcase.chars {|c|
dict[c] += 1 if c.match(/[a-z]/)
}
break if line.match(/^$/)
end
dict.each {|k,v|
puts k + ' : ' + v.to_s
}
|
dict = {
'a' => 0, 'b' => 0, 'c' => 0, 'd' => 0, 'e' => 0, 'f' => 0, 'g' => 0,
'h' => 0, 'i' => 0, 'j' => 0, 'k' => 0, 'l' => 0, 'm' => 0, 'n' => 0,
'o' => 0, 'p' => 0, 'q' => 0, 'r' => 0, 's' => 0, 't' => 0, 'u' => 0,
'v' => 0, 'w' => 0, 'x' => 0, 'y' => 0, 'z' => 0
}
while STDIN.eof == false
line = STDIN.gets
line.downcase.chars {|c|
dict[c] += 1 if c.match(/[a-z]/)
}
break if line.match(/^$/)
end
dict.each {|k,v|
puts k + ' : ' + v.to_s
}
|
[
"expression.operation.binary.add"
] | 224,292
| 224,293
|
u924816735
|
ruby
|
p02417
|
w=''
loop {w += gets.chomp.downcase}
[*'a'..'z'].each{|c|puts c+' : '+w.count(c).to_s}
|
w=''
loop do
begin
w += gets.chomp.downcase
rescue
break
end
end
[*'a'..'z'].each{|c|puts c+' : '+w.count(c).to_s}
|
[
"control_flow.break.add"
] | 224,294
| 224,295
|
u517414491
|
ruby
|
p02419
|
w = gets.chomp
t = $<.read
puts t.count(w)
|
w = gets.chomp
t = $<.read.downcase.split
puts t.count(w)
|
[
"call.add"
] | 224,636
| 224,637
|
u364253163
|
ruby
|
p02419
|
s=gets.chop
P=gets(nil).split
puts P.count s
|
s=gets.chop
puts gets(nil).downcase.split.count s
|
[
"call.add",
"call.remove"
] | 224,640
| 224,641
|
u556326323
|
ruby
|
p02419
|
target = gets.chomp.upcase
count = 0
until (s = gets) == "END_OF_TEXT" do
strs = s.chomp.split
0.upto(strs.size-1) do |i|
count += 1 if target == strs[i].upcase
end
end
p count
|
target = gets.chomp.upcase
count = 0
until (s = gets.chomp) == "END_OF_TEXT" do
strs = s.split
0.upto(strs.size-1) do |i|
count += 1 if target == strs[i].upcase
end
end
p count
|
[
"call.add",
"call.remove"
] | 224,648
| 224,649
|
u433116732
|
ruby
|
p02419
|
w = gets.chomp
res = 0
loop do
s = gets.chomp
break if s=='END_OF_TEXT'
res += s.split.count(w)
end
puts res
|
w = gets.chomp.downcase
res = 0
loop do
s = gets.chomp
break if s=='END_OF_TEXT'
res += s.downcase.split.count(w)
end
puts res
|
[
"call.add"
] | 224,650
| 224,651
|
u714639016
|
ruby
|
p02419
|
w = gets.chomp.lowercase
res = 0
loop do
s = gets.chomp
break if s=='END_OF_TEXT'
res += s.lowercase.split.count(w)
end
puts res
|
w = gets.chomp.downcase
res = 0
loop do
s = gets.chomp
break if s=='END_OF_TEXT'
res += s.downcase.split.count(w)
end
puts res
|
[
"assignment.value.change",
"identifier.change"
] | 224,652
| 224,651
|
u714639016
|
ruby
|
p02419
|
word = gets.chomp
result = 0
loop do
sentence = gets.chomp.split(" ").map do |s| s.to_s end
if sentence[0] == "END_OF_TEXT"
break
else
sentence.each do |n|
if n == word
result += 1
end
end
end
end
puts result
|
word = gets.chomp
result = 0
loop do
sentence = gets.chomp.split(" ").map do |s| s.to_s end
if sentence[0] == "END_OF_TEXT"
break
else
sentence.each do |n|
if n.downcase == word
result += 1
end
end
end
end
puts result
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 224,655
| 224,656
|
u359764315
|
ruby
|
p02419
|
target_word = gets.chomp.downcase
count = 0
while sentense = gets.chomp
break if sentense == "END_OF_TEXT"
words = sentense.split.downcase
count += words.count(target_word)
end
puts count
|
target_word = gets.chomp.downcase
count = 0
while sentense = gets.chomp
break if sentense == "END_OF_TEXT"
words = sentense.split.map(&:downcase)
count += words.count(target_word)
end
puts count
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.add"
] | 224,664
| 224,665
|
u338661979
|
ruby
|
p02419
|
word=gets.chomp
count=0
while true do
l=gets.chomp
if l=="END_OF_TEXT" then
break
end
line=l.split
for i in 0..line.length-1 do
if word==line[i] then
count=count+1
end
end
end
puts count
|
word=gets.chomp
count=0
while true do
l=gets.chomp
if l=="END_OF_TEXT" then
break
end
line=l.split
for i in 0..line.length-1 do
if word.downcase==line[i].downcase then
count=count+1
end
end
end
puts count
|
[
"control_flow.branch.if.condition.change",
"call.add"
] | 224,668
| 224,669
|
u284204984
|
ruby
|
p02419
|
s=gets.chomp
puts $<.read.downcase.split.count{|l|l[s]}
|
s=gets.chomp
puts $<.read.downcase.split.count{|l|l==s}
|
[
"call.arguments.change",
"io.output.change"
] | 224,687
| 224,684
|
u899067203
|
ruby
|
p02419
|
ptn = $stdin.gets(chomp:true)
str = $stdin.read.downcase
puts str.scan(/#{ptn}/).size
|
ptn = $stdin.gets(chomp:true)
str = $stdin.read.downcase
puts str.scan(/\b#{ptn}\b/).size
|
[
"call.arguments.change"
] | 224,688
| 224,689
|
u958508535
|
ruby
|
p02419
|
cnt = 0
word = gets.chomp
until (line = gets.chomp) == "END_OF_TEXT"
cnt += line.split.find_all{|it|
it == word
}.size
end
puts cnt
|
cnt = 0
word = gets.chomp.downcase
until (line = gets.chomp) == "END_OF_TEXT"
cnt += line.split.find_all{|it|
it.downcase == word
}.size
end
puts cnt
|
[
"call.add"
] | 224,692
| 224,693
|
u408475018
|
ruby
|
p02419
|
cnt = 0
word = gets.chomp.downcase
until (line = gets.chomp) == "END_OF_TEXT"
p line.split.find_all{|it|
it.downcase == word
}.size
end
puts cnt
|
cnt = 0
word = gets.chomp.downcase
until (line = gets.chomp) == "END_OF_TEXT"
cnt += line.split.find_all{|it|
it.downcase == word
}.size
end
puts cnt
|
[] | 224,695
| 224,693
|
u408475018
|
ruby
|
p02419
|
w = STDIN.gets.chomp
count = 0
while (line = STDIN.gets.chomp) != "END_OF_TEXT"
line.split(' ').each {|word|
count += 1 if word.casecomp(w) == 0
}
end
puts count
|
w = STDIN.gets.chomp
count = 0
while (line = STDIN.gets.chomp) != "END_OF_TEXT"
line.split(' ').each {|word|
count += 1 if word.casecmp(w) == 0
}
end
puts count
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 224,698
| 224,697
|
u924816735
|
ruby
|
p02467
|
n = gets.chomp
print n + ":"
n = n.to_i
k = Math::sqrt(n)
k = k.to_i
for i in 2..k
while n%i == 0
print " #{i}"
n = n/i
end
end
if n != 0
puts " #{n}"
else
puts ""
end
|
n = gets.chomp
print n + ":"
n = n.to_i
k = Math::sqrt(n)
k = k.to_i
for i in 2..k
while n%i == 0
print " #{i}"
n = n/i
end
end
if n != 1
puts " #{n}"
else
puts ""
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 225,209
| 225,211
|
u535246834
|
ruby
|
p02467
|
puts 'factor'
|
puts `factor`
|
[
"call.arguments.change"
] | 225,219
| 225,220
|
u822258792
|
ruby
|
p02467
|
n=gets.chomp.to_i
max_root=Math.sqrt(n).to_i
prime=Array.new
m=n
i=2
while i <= max_root
if n%i==0
prime << i
n=n/i
elsif i==2
i+=1
else
i+=2
end
end
if m==n
prime << n
end
print "#{m}: #{prime.join(" ")}\n"
|
n=gets.chomp.to_i
max_root=Math.sqrt(n).to_i
prime=Array.new
m=n
i=2
while i <= max_root
if n%i==0
prime << i
n=n/i
elsif i==2
i+=1
else
i+=2
end
end
if m==n || n!=1
prime << n
end
print "#{m}: #{prime.join(" ")}\n"
|
[
"control_flow.branch.if.condition.change"
] | 225,221
| 225,222
|
u534464795
|
ruby
|
p02467
|
n=gets.chomp.to_i
max_root=Math.sqrt(n).to_i
prime=Array.new
m=n
i=2
while i <= max_root
if n%i==0
prime << i
n=n/i
elsif i==2
i+=1
else
i+=2
end
end
puts n
if m==n || n!=1
prime << n
end
print "#{m}: #{prime.join(" ")}\n"
|
n=gets.chomp.to_i
max_root=Math.sqrt(n).to_i
prime=Array.new
m=n
i=2
while i <= max_root
if n%i==0
prime << i
n=n/i
elsif i==2
i+=1
else
i+=2
end
end
if m==n || n!=1
prime << n
end
print "#{m}: #{prime.join(" ")}\n"
|
[
"call.remove"
] | 225,223
| 225,222
|
u534464795
|
ruby
|
p02467
|
require 'Prime'
n = gets.to_i
puts "#{n}:" + Prime.prime_division(n).map{|d, e| " #{d}" * e}.join
|
require 'prime'
n = gets.to_i
puts "#{n}:" + Prime.prime_division(n).map{|d, e| " #{d}" * e}.join
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 225,229
| 225,230
|
u238839772
|
ruby
|
p02467
|
n = gets.to_i
puts "#{n}:" + Prime.prime_division(n).map{|d, e| " #{d}" * e}.join
|
require 'prime'
n = gets.to_i
puts "#{n}:" + Prime.prime_division(n).map{|d, e| " #{d}" * e}.join
|
[
"call.add"
] | 225,231
| 225,230
|
u238839772
|
ruby
|
p02468
|
m, n = gets.split.map &:to_i
$t = 1000000007
def pow(m, n)
m = m % $t
if n == 0
1
elsif n.even?
pow(m * m, n / 2)
else
pow(m * m, n / 2) * m
end
end
puts pow(m, n)
|
m, n = gets.split.map &:to_i
$t = 1000000007
def pow(m, n)
m = m % $t
if n == 0
1
elsif n.even?
pow(m * m, n / 2)
else
pow(m * m, n / 2) * m
end
end
puts pow(m, n) % $t
|
[
"expression.operation.binary.add"
] | 225,266
| 225,267
|
u352522848
|
ruby
|
p02479
|
r = gets.to_i
printf("%f %f\n", r ** 2 * Math::PI, r * 2 * Math::PI)
|
r = gets.to_f
printf("%f %f\n", r ** 2 * Math::PI, r * 2 * Math::PI)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,400
| 227,401
|
u361124931
|
ruby
|
p02479
|
r = gets.to_i
puts "#{(r * r * Math::PI).round(6)} #{(2 * r * Math::PI).round(6)}"
|
r = gets.to_f
puts "#{(r * r * Math::PI).round(6)} #{(2 * r * Math::PI).round(6)}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,404
| 227,405
|
u550083072
|
ruby
|
p02479
|
include Math
r = STDIN.gets.to_i
puts "%.5f %.5f" % [r ** 2 * PI, 2 * r * PI]
|
include Math
r = STDIN.gets.to_f
puts "%.5f %.5f" % [r ** 2 * PI, 2 * r * PI]
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,411
| 227,412
|
u238839772
|
ruby
|
p02479
|
r = gets.chomp.to_i
puts "#{r * r * Math::PI} #{2 * r * Math::PI}"
|
r = gets.chomp.to_f
puts "#{r * r * Math::PI} #{2.0 * r * Math::PI}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"literal.string.change",
"call.arguments.change"
] | 227,977
| 227,978
|
u442590759
|
ruby
|
p02479
|
#coding : utf-8
r = gets.to_i
pi = Math::PI
print r*r*pi," ",2*r*pi,"\n"
|
#coding : utf-8
r = gets.to_f
pi = Math::PI
print r*r*pi," ",2*r*pi,"\n"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,979
| 227,980
|
u420232230
|
ruby
|
p02479
|
r = gets.chomp.to_i
puts "#{sprintf("%.6f",r*r*Math::PI)} #{sprintf("%.6f",r*2*Math::PI)}"
|
r = gets.chomp.to_f
puts "#{sprintf("%.6f",r*r*Math::PI)} #{sprintf("%.6f",r*2*Math::PI)}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,981
| 227,982
|
u349293999
|
ruby
|
p02479
|
# coding: utf-8
r = gets.to_i
printf("%.5f %.5f\n", 2 * r * Math::PI, r * r * Math::PI)
|
# coding: utf-8
r = gets.to_f
printf("%.5f %.5f\n", r * r * Math::PI, 2 * r * Math::PI)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"call.arguments.change",
"call.arguments.add"
] | 227,990
| 227,991
|
u991779216
|
ruby
|
p02479
|
# coding: utf-8
r = gets.to_f
printf("%.5f %.5f\n", 2 * r * Math::PI, r * r * Math::PI)
|
# coding: utf-8
r = gets.to_f
printf("%.5f %.5f\n", r * r * Math::PI, 2 * r * Math::PI)
|
[
"call.arguments.change",
"call.arguments.add"
] | 227,992
| 227,991
|
u991779216
|
ruby
|
p02479
|
# coding: utf-8
r = gets.to_i
men = r * r * Math::PI
syu = 2 * r * Math::PI
puts sprintf("%f %f", men, syu)
|
# coding: utf-8
r = gets.to_f
men = r * r * Math::PI
syu = 2 * r * Math::PI
puts sprintf("%.6f %.6f", men, syu)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 227,996
| 227,997
|
u292263436
|
ruby
|
p02479
|
# coding: utf-8
r = gets.to_i
men = r * r * Math::PI
syu = 2 * r * Math::PI
puts sprintf("%.6f %.6f", men, syu)
|
# coding: utf-8
r = gets.to_f
men = r * r * Math::PI
syu = 2 * r * Math::PI
puts sprintf("%.6f %.6f", men, syu)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,998
| 227,997
|
u292263436
|
ruby
|
p02479
|
t=Math::PI*r=gets.to_i
puts [t*r,t*2]*" "
|
t=Math::PI*r=gets.to_f
puts [t*r,t*2]*" "
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 227,999
| 228,000
|
u198069342
|
ruby
|
p02479
|
r = gets.to_i
puts "#{Math::PI * r * r} #{2 * r * Math::PI}"
|
r = gets.to_f
puts "#{Math::PI * r * r} #{2 * r * Math::PI}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,001
| 228,002
|
u364560197
|
ruby
|
p02479
|
r = gets.to_f
printf("%.5f %.5f", r * r * 3.14, 2 * r * 3.14)
|
r = gets.to_f
printf("%.5f %.5f", r * r * Math::PI, 2 * r * Math::PI)
|
[
"call.arguments.change",
"expression.operation.binary.change"
] | 228,005
| 228,006
|
u286006929
|
ruby
|
p02479
|
r = gets.to_i
area = r*r*Math::PI
circumference = 2*r*Math::PI
puts "#{area.round(6)} #{circumference.round(6)}"
|
r = gets.to_f
area = r*r*Math::PI
circumference = 2*r*Math::PI
puts "#{area.round(6)} #{circumference.round(6)}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,007
| 228,008
|
u543212635
|
ruby
|
p02479
|
r=gets.to_i
pi=3.14159265358979323846
puts '%.10f %.10f'%[pi*r*r,pi*2*r]
|
r=gets.to_f
pi=3.14159265358979323846
puts '%.10f %.10f'%[pi*r*r, pi*2*r]
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,009
| 228,010
|
u714639016
|
ruby
|
p02479
|
r=gets.to_i
pi=3.14159265358979323846
puts '%.10f %.10f'%[pi*2*r, pi*r*r]
|
r=gets.to_f
pi=3.14159265358979323846
puts '%.10f %.10f'%[pi*r*r, pi*2*r]
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"literal.string.change",
"call.arguments.change"
] | 228,012
| 228,010
|
u714639016
|
ruby
|
p02479
|
r = gets.to_i
print r*r*Math::PI," ",r*2*Math::PI,"\n"
|
r = gets.to_f
print r*r*Math::PI," ",r*2*Math::PI,"\n"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,017
| 228,018
|
u600167541
|
ruby
|
p02479
|
r = gets.to_f
pi = 3.141592
puts "#{r*r*pi} #{r*2*pi}"
|
r = gets.to_f
pi = 3.141592653589793
puts "#{r*r*pi} #{r*2*pi}"
|
[
"literal.number.float.change",
"assignment.value.change"
] | 228,020
| 228,021
|
u765849500
|
ruby
|
p02479
|
r=gets.to_i
m=r*r*Math::PI
n=2*r*Math::PI
printf("%.6f %.6f\n",m,n)
|
r=gets.to_f
m=r*r*Math::PI
n=2*r*Math::PI
printf("%.6f %.6f\n",m,n)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,022
| 228,023
|
u600584317
|
ruby
|
p02479
|
#coding utf-8
r = gets.to_i
PI = Math::PI
puts "#{sprintf('%.5f',(r**2)*PI)} #{sprintf('%.5f',2*r*PI)}"
|
r = gets.to_f
PI = Math::PI
puts "#{sprintf('%.6f',(r**2)*PI)} #{sprintf('%.6f',2*r*PI)}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"literal.string.change",
"call.arguments.change"
] | 228,024
| 228,025
|
u500832615
|
ruby
|
p02479
|
#coding utf-8
r = gets.to_i
PI = Math::PI
puts "#{sprintf('%.6f',(r**2)*PI)} #{sprintf('%.6f',2*r*PI)}"
|
r = gets.to_f
PI = Math::PI
puts "#{sprintf('%.6f',(r**2)*PI)} #{sprintf('%.6f',2*r*PI)}"
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,026
| 228,025
|
u500832615
|
ruby
|
p02479
|
#coding utf-8
r = gets.to_i
pi = Math::PI
puts "#{sprintf('%.6f',(r**2)*pi)} #{sprintf('%.6f',2*r*pi)}"
|
r = gets.to_f
PI = Math::PI
puts "#{sprintf('%.6f',(r**2)*PI)} #{sprintf('%.6f',2*r*PI)}"
|
[
"literal.string.change",
"call.arguments.change"
] | 228,027
| 228,025
|
u500832615
|
ruby
|
p02479
|
r = gets.to_f
puts "#{f*f*Math::PI} #{f*2*Math::PI}"
|
r = gets.to_f
puts "#{r*r*Math::PI} #{r*2*Math::PI}"
|
[
"literal.string.change",
"call.arguments.change"
] | 228,036
| 228,037
|
u457499538
|
ruby
|
p02479
|
#!/usr/bin/ruby
r=gets.to_i
printf("%.9f %.9f\n",Math::PI*r**2,Math::PI*r*2)
|
#!/usr/bin/ruby
r=gets.to_f
printf("%.9f %.9f\n",Math::PI*r**2,Math::PI*r*2)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,040
| 228,041
|
u300645821
|
ruby
|
p02479
|
r=gets.to_i
printf("%.6f %.6f\n",Math::PI*r**2,2*Math::PI*r)
|
r=gets.to_f
printf("%.5f %.5f\n",Math::PI*r**2,2*Math::PI*r)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"literal.string.change",
"call.arguments.change"
] | 228,047
| 228,048
|
u621344171
|
ruby
|
p02479
|
#!/usr/local/bin/ruby
include Math
line=gets
r=line.to_i
s=r**2*PI
l=2*PI*r
printf("%.6f %.6f\n",s,l)
|
#!/usr/local/bin/ruby
include Math
line=gets
r=line.to_f
s=r**2*PI
l=2*PI*r
printf("%.6f %.6f\n",s,l)
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 228,050
| 228,051
|
u679425694
|
ruby
|
p02489
|
line_no = 0
while line = gets do
break if line.to_i == 0
printf "Case %d: %s", line_no, line
end
|
line_no = 0
while line = gets do
break if line.to_i == 0
printf "Case %d: %s", line_no += 1, line
end
|
[] | 234,163
| 234,164
|
u919623882
|
ruby
|
p02489
|
i = 1
while line = gets do
num = line.chomp
if num.to_i == 0
exit
else
puts 'Case' + i.to_s + ':' + num.to_s
i += 1
end
end
|
i = 1
while line = gets do
num = line.chomp
if num.to_i == 0
exit
else
puts 'Case ' + i.to_s + ': ' + num.to_s
i += 1
end
end
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 234,167
| 234,168
|
u214508393
|
ruby
|
p02489
|
i = 1
while line = gets do
num = line.chomp
if num.to_i == 0
exit
else
puts 'Case' + i.to_s + ': ' + num.to_s
i += 1
end
end
|
i = 1
while line = gets do
num = line.chomp
if num.to_i == 0
exit
else
puts 'Case ' + i.to_s + ': ' + num.to_s
i += 1
end
end
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 234,169
| 234,168
|
u214508393
|
ruby
|
p02489
|
i = 0
while (x = gets.chomp.to_i) != 0 do
puts "Case #{i}: #{x}"
i+=1;
end
|
i = 1
while (x = gets.to_i) != 0 do
puts "Case #{i}: #{x}"
i+=1;
end
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.remove"
] | 234,172
| 234,173
|
u873778695
|
ruby
|
p02489
|
i = 0
while (x = gets.to_i) != 0 do
puts "Case #{i}: #{x}"
i+=1;
end
|
i = 1
while (x = gets.to_i) != 0 do
puts "Case #{i}: #{x}"
i+=1;
end
|
[
"literal.number.integer.change",
"assignment.value.change"
] | 234,174
| 234,173
|
u873778695
|
ruby
|
p02489
|
STDIN.take_while{|e| e.to_i != 0}.each_with_index{|e, i| puts "case #{i + 1}: #{e}"}
|
STDIN.take_while{|e| e.to_i != 0}.each_with_index{|e, i| puts "Case #{i + 1}: #{e}"}
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 234,177
| 234,178
|
u799326664
|
ruby
|
p02489
|
c = 1
arr = []
while (n = gets.to_i) > 0
arr[c] = n
c += 1
end
for i in 1..c-1 do
puts "#{"case"} #{i}#{":"} #{arr[i]}"
end
|
c = 1
arr = []
while (n = gets.to_i) > 0
arr[c] = n
c += 1
end
for i in 1..c-1 do
puts "#{"Case"} #{i}#{":"} #{arr[i]}"
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 234,179
| 234,180
|
u765849500
|
ruby
|
p02489
|
caseNo = 1
while true
x = gets.to_i
break if x == 0
puts "Case:#{caseNo} #{x}"
caseNo += 1
end
|
caseNo = 1
while true
x = gets.to_i
break if x == 0
puts "Case #{caseNo}: #{x}"
caseNo += 1
end
|
[
"literal.string.change",
"call.arguments.change"
] | 234,185
| 234,186
|
u421119486
|
ruby
|
p02489
|
i = 1
while true do
n = gets.to_i
if n == 0 then
break
end
puts sprintf("Case %d:%d", i, n)
i += 1
end
|
i = 1
while true do
n = gets.to_i
if n == 0 then
break
end
puts sprintf("Case %d: %d", i, n)
i += 1
end
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 234,190
| 234,191
|
u881668270
|
ruby
|
p02489
|
input = []
while (line = gets).to_i != 0
input.push(line)
end
i = 0
while i < input.length
puts "Case " + i.to_s + ": " + input[i].to_s
i += 1
end
|
input = []
while (line = gets).to_i != 0
input.push(line)
end
i = 0
while i < input.length
puts "Case " + (i + 1).to_s + ": " + input[i].to_s
i += 1
end
|
[
"call.arguments.change"
] | 234,192
| 234,193
|
u471929490
|
ruby
|
p02489
|
i=0;while "0\n"!=x=gets do;puts"Case #{i+=1} #{x}"end
|
i=0;while "0\n"!=x=gets do;puts"Case #{i+=1}: #{x}"end
|
[
"literal.string.change",
"call.arguments.change"
] | 234,196
| 234,195
|
u310778860
|
ruby
|
p02489
|
i=0;while "0\n"!=x=gets do;puts"Case #{i+=1} #{x}"end
|
i=0;while "0\n"!=x=gets
puts"Case #{i+=1}: #{x}"end
|
[
"literal.string.change",
"call.arguments.change"
] | 234,196
| 234,197
|
u310778860
|
ruby
|
p02489
|
values = []
while line = gets
line.chomp!
break if line == "0"
values.push(line)
end
values.each_with_index{|x, i|
puts "Case" + (i+1).to_s + ": " + x
}
|
values = []
while line = gets
line.chomp!
break if line == "0"
values.push(line)
end
values.each_with_index{|x, i|
puts "Case " + (i+1).to_s + ": " + x
}
|
[
"literal.string.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 234,198
| 234,199
|
u518130073
|
ruby
|
p02489
|
cnt = 1
loop do
input = gets
break if input.to_i == 0
puts sprintf("Case %d: %d", cnt, input)
end
|
cnt = 1
loop do
input = gets
break if input.to_i == 0
puts sprintf("Case %d: %d", cnt, input)
cnt += 1
end
|
[] | 234,200
| 234,201
|
u361124931
|
ruby
|
p02489
|
num = 1
while input = gets.to_i
if input == 0
exit
else
puts "Case#{num}: #{input}"
num += 1
end
end
|
num = 1
while input = gets.to_i
if input == 0
exit
else
puts "Case #{num}: #{input}"
num += 1
end
end
|
[
"literal.string.change",
"call.arguments.change"
] | 234,202
| 234,203
|
u492566253
|
ruby
|
p02536
|
N,M = gets.split.map(&:to_i)
UF = [-1]*(N+1)
F = lambda{|a|
next UF[a]<0 ? a : UF[a]=F[UF[a]]
}
U = lambda{|ab|
a,b = ab.split.map(&:to_i).map(&F)
a,b = b,a unless UF[a]<UF[b]
UF[a] += UF[b]
UF[b] = a
}
$<.each(&U)
p UF.count{|g| g<0 }-2
|
N,M = gets.split.map(&:to_i)
UF = [-1]*(N+1)
F = lambda{|a|
next UF[a]<0 ? a : UF[a]=F[UF[a]]
}
U = lambda{|ab|
a,b = ab.split.map(&:to_i).map(&F)
next if a == b
a,b = b,a unless UF[a]<UF[b]
UF[a] += UF[b]
UF[b] = a
}
$<.each(&U)
p UF.count{|g| g<0 }-2
|
[] | 240,939
| 240,940
|
u977697682
|
ruby
|
p02536
|
n,m = gets.chomp.split(" ").map(&:to_i);
class UnionFind
def initialize(size)
@rank = Array.new(size, 0)
@parent = Array.new(size, &:itself)
#@開始はインスタンス変数:オブジェクトが存在する間有効
end
def unite(id_x, id_y)
x_parent = get_parent(id_x)
y_parent = get_parent(id_y)
return if x_parent == y_parent
if @rank[x_parent] > @rank[y_parent]
@parent[y_parent] = x_parent
else
@parent[x_parent] = y_parent
@rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
end
end
def get_parent(id_x)
@parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
# 3項演算子(xx ? yy : zz の意味は if xx then yy else zz end )
end
def same_parent?(id_x, id_y)
get_parent(id_x) == get_parent(id_y)
end
def count_parent
rtn = 0
@parent.each_with_index do |p, index|
rtn += 1 if p == index
end
rtn
end
end
union = UnionFind.new n
# クエリの回数だけ、入力受け取りを回す
m.times do
a, b = gets.split.map{|x| x.to_i}
union.unite(a, b)
end
puts union.count_parent - 1
|
n,m = gets.chomp.split(" ").map(&:to_i);
class UnionFind
def initialize(size)
@rank = Array.new(size, 0)
@parent = Array.new(size, &:itself)
end
def unite(id_x, id_y)
x_parent = get_parent(id_x)
y_parent = get_parent(id_y)
return if x_parent == y_parent
if @rank[x_parent] > @rank[y_parent]
@parent[y_parent] = x_parent
else
@parent[x_parent] = y_parent
@rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
end
end
def get_parent(id_x)
@parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
# 3項演算子(xx ? yy : zz の意味は if xx then yy else zz end )
end
def same_parent?(id_x, id_y)
get_parent(id_x) == get_parent(id_y)
end
def count_parent
rtn = 0
@parent.each_with_index do |p, index|
rtn += 1 if p == index
end
rtn
end
end
union = UnionFind.new n
# クエリの回数だけ、入力受け取りを回す
m.times do
a, b = gets.split.map{|x| x.to_i-1}
union.unite(a, b)
end
puts union.count_parent - 1
|
[
"assignment.change"
] | 241,231
| 241,232
|
u663882298
|
ruby
|
p02546
|
ans=gets.chomp.chars
ans << ans[-1]=="s"? "es" : "s"
puts ans.join
|
ans=gets.chomp.chars
ans << ((ans[-1]=="s")? "es" : "s")
puts ans.join
|
[
"control_flow.branch.if.condition.change"
] | 242,704
| 242,705
|
u977506075
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.