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 9
values |
|---|---|---|---|---|---|---|---|
p02257 | n = gets.to_i
m = []
p_num = 0
n.times{
m += [gets.to_i]
}
for x in m
flag = 0
for y in 2..(x**0.5)+1
if x % y == 0
flag = 1
break
end
end
if flag == 0
p_num += 1
end
end
puts p_num | n = gets.to_i
m = []
p_num = 0
n.times{
m += [gets.to_i]
}
for x in m
flag = 0
for y in 2..(x**0.5)
if x % y == 0
flag = 1
break
end
end
if flag == 0
p_num += 1
end
end
puts p_num | [
"expression.operation.binary.remove"
] | 100,951 | 100,952 | u547057305 | ruby |
p02259 | class Array
def swap!(a, b)
self[a], self[b] = self[b], self[a]
self
end
end
def bubble_sort(array)
isSorted = false
count = 0
index = 0
until isSorted do
swaped = false
(array.length - 1).downto(index) do |comp_index|
break if comp_index.zero?
if array[comp_index] < array[comp_... | class Array
def swap!(a, b)
self[a], self[b] = self[b], self[a]
self
end
end
def bubble_sort(array)
isSorted = false
count = 0
index = 0
until isSorted do
swaped = false
(array.length - 1).downto(index) do |comp_index|
break if comp_index.zero?
if array[comp_index] < array[comp_... | [
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 103,510 | 103,511 | u731989230 | ruby |
p02260 | $swap = 0
def Swap(a, b)
$swap += 1
return b,a
end
gets
d = gets.chomp.split(" ").map &:to_i
d.length.times { |i|
min = i
(i..d.length).each_with_index { |j|
min = j if d[min] > d[j]
}
d[i],d[min] = Swap(d[i],d[min])
}
d.length.times { |i|
print " " unless i == 0
print "#{d[i]}"
}
print "\n#{$swap}\n" | $swap = 0
def Swap(a, b)
$swap += 1
return b,a
end
gets
d = gets.chomp.split(" ").map &:to_i
d.length.times { |i|
min = i
(i...d.length).each_with_index { |j|
min = j if d[min] > d[j]
}
d[i],d[min] = Swap(d[i],d[min]) if i != min
}
d.length.times { |i|
print " " unless i == 0
print "#{d[i]}"
}
print "\n#{... | [] | 104,143 | 104,144 | u281257618 | ruby |
p02260 | $swap = 0
def Swap(a, b)
$swap += 1
return b,a
end
gets
d = gets.chomp.split(" ").map &:to_i
d.length.times { |i|
min = i
(i...d.length).each_with_index { |j|
min = j if d[min] > d[j]
}
d[i],d[min] = Swap(d[i],d[min])
}
d.length.times { |i|
print " " unless i == 0
print "#{d[i]}"
}
print "\n#{$swap}\n" | $swap = 0
def Swap(a, b)
$swap += 1
return b,a
end
gets
d = gets.chomp.split(" ").map &:to_i
d.length.times { |i|
min = i
(i...d.length).each_with_index { |j|
min = j if d[min] > d[j]
}
d[i],d[min] = Swap(d[i],d[min]) if i != min
}
d.length.times { |i|
print " " unless i == 0
print "#{d[i]}"
}
print "\n#{... | [] | 104,145 | 104,144 | u281257618 | ruby |
p02260 | input = []
while (n = gets.to_i) != 0 do
input = gets.split.map(&:to_i)
end
n = input.size
count = 0
for i in 0..n-1 do
min_j = i
for j in i..n-1 do
min_j = j if input[j] < input[min_j]
end
break if input[min_j] == input[i]
tmp = input[min_j]
input[min_j] = input[i]
input[i] = tmp
count += 1
end... | # 選択ソート(最小のものを先頭に追加していくイメージ。)
input = []
while (n = gets.to_i) != 0 do
input = gets.split.map(&:to_i)
end
n = input.size
count = 0
for i in 0..n-1 do
min_j = i
for j in i..n-1 do
min_j = j if input[j] < input[min_j]
end
if input[min_j] != input[i]
tmp = input[min_j]
input[min_j] = input[i]
i... | [
"control_flow.break.remove",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 104,150 | 104,151 | u854817684 | ruby |
p02258 | n = gets(chomp:true).to_i
# 最大利益を負の無限大に設定!!!
maxv = -Float::INFINITY
# 最小値を読み込み
minv = gets(chomp:true).to_i
(1..n).each do |price_idx|
# 比較する価格を読み込み
price = gets(chomp:true).to_i
# 最大利益が価格-最小値より小さい場合。最大利益を更新
maxv < price - minv && maxv = price - minv
# 最小値が価格より大きい場合、最小値を更新
minv > price && minv = pric... | n = gets(chomp:true).to_i
# 最大利益を負の無限大に設定!!!
maxv = -Float::INFINITY
# 最小値を読み込み
minv = gets(chomp:true).to_i
(1...n).each do
# 比較する価格を読み込み
price = gets(chomp:true).to_i
# 最大利益が価格-最小値より小さい場合。最大利益を更新
maxv < price - minv && maxv = price - minv
# 最小値が価格より大きい場合、最小値を更新
minv > price && minv = price
end
put... | [] | 104,221 | 104,222 | u958508535 | ruby |
p02258 | n = gets.chomp.to_i
a = []
n.times do
a.push(gets.chomp.to_i)
end
max_gap = 0
low = a[0]
for i in 1..a.size-1
if a[i] - low > max_gap
max_gap = a[i] - low
elsif a[i] < low
low = a[i]
end
end
puts max_gap | n = gets.chomp.to_i
a = []
n.times do
a.push(gets.chomp.to_i)
end
max_gap = -Float::INFINITY
low = a[0]
for i in 1..a.size-1
if a[i] - low > max_gap
max_gap = a[i] - low
end
if a[i] < low
low = a[i]
end
end
puts max_gap | [
"assignment.value.change"
] | 104,225 | 104,226 | u742797815 | ruby |
p02258 | n = gets.chomp.to_i
a = []
n.times do
a.push(gets.chomp.to_i)
end
max_gap = -Float::INFINITY
low = a[0]
for i in 1..a.size-1
if a[i] - low > max_gap
max_gap = a[i] - low
elsif a[i] < low
low = a[i]
end
end
puts max_gap | n = gets.chomp.to_i
a = []
n.times do
a.push(gets.chomp.to_i)
end
max_gap = -Float::INFINITY
low = a[0]
for i in 1..a.size-1
if a[i] - low > max_gap
max_gap = a[i] - low
end
if a[i] < low
low = a[i]
end
end
puts max_gap | [] | 104,227 | 104,226 | u742797815 | ruby |
p02258 | _,m,*a=$<.map &:to_i
p a.map{|i|m=i if 0<s=i-m
s}.max | _,m,*a=$<.map &:to_i
p a.map{|i|m=i if 0>s=i-m
s}.max | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 104,228 | 104,229 | u890794282 | ruby |
p02258 | gets
n=2e9
m=0
$<.map{|c|i=c.to_i;m<i-n&&m=i-n;n>i&&n=i}
p m | gets
n=2e9
m=-n
$<.map{|c|i=c.to_i;m<i-n&&m=i-n;n>i&&n=i}
p m | [
"assignment.value.change",
"expression.operation.unary.add"
] | 104,232 | 104,233 | u198069342 | ruby |
p02258 | n = gets.to_i
ret = -1000000000
j = gets.to_i
min = j
max = j
for i in 2..n
j = gets.to_i
if min > j
ret = j - min if ret < j - min
min = j
max = j
end
if max < j
max = j
ret = max - min if ret < max - min
end
end
puts ret | n = gets.to_i
ret = -1000000000
j = gets.to_i
min = j
max = j
for i in 2..n
j = gets.to_i
if min >= j
ret = j - min if ret < j - min
min = j
max = j
end
if max < j
max = j
ret = max - min if ret < max - min
end
end
puts ret | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 104,237 | 104,238 | u324171823 | ruby |
p02258 | n = STDIN.gets.to_i
n1 = STDIN.gets.to_i
n2 = STDIN.gets.to_i
max = n1
min = n1
if n1 > n2 then
min = n2
diff = n2 - n1
max = n2
else
max = n2
diff = n2 - n1
end
(3..n).each { |i|
x = STDIN.gets.to_i
max = x if max.nil?
min = -x if min.nil?
if x > max then
diff = x - min if x - min > diff
... | n = STDIN.gets.to_i
n1 = STDIN.gets.to_i
n2 = STDIN.gets.to_i
max = n1
min = n1
if n1 > n2 then
min = n2
diff = n2 - n1
max = n2
else
max = n2
diff = n2 - n1
end
(3..n).each { |i|
x = STDIN.gets.to_i
max = x if max.nil?
min = -x if min.nil?
if x > max then
diff = x - min if x - min > diff
... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 104,244 | 104,245 | u382730661 | ruby |
p02258 | n = STDIN.gets.to_i
p n
max = -2000000000
min = STDIN.gets.to_i
(2..n).each { |i|
x = STDIN.gets.to_i
max = if max > x - min then max else x - min end
min = if x < min then x else min end
}
puts max | n = STDIN.gets.to_i
max = -2000000000
min = STDIN.gets.to_i
(2..n).each { |i|
x = STDIN.gets.to_i
max = if max > x - min then max else x - min end
min = if x < min then x else min end
}
puts max | [
"call.remove"
] | 104,251 | 104,252 | u677710583 | ruby |
p02258 | n = gets.to_i
rs = readlines.take(n).map(&:to_i)
_, max_profit = rs.drop(0).reduce([rs[0], -(10 ** n)]) do |(min_r, max_profit), r|
max_profit = [max_profit, r - min_r].max
min_r = r if r < min_r
[min_r, max_profit]
end
puts max_profit | n = gets.to_i
rs = readlines.take(n).map(&:to_i)
_, max_profit = rs.drop(1).reduce([rs[0], -(10 ** 9)]) do |(min_r, max_profit), r|
max_profit = [max_profit, r - min_r].max
min_r = r if r < min_r
[min_r, max_profit]
end
puts max_profit | [
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"identifier.replace.remove",
"literal.replace.add",
"expression.operation.binary.change"
] | 104,262 | 104,263 | u694668170 | ruby |
p02258 | n = gets.to_i
r = Array.new
r0 = gets.to_i
r1 = gets.to_i
max_r = - r0
min_v = r0 < r1 ? r0 : r1
(n-2).times do
r = gets.to_i
current = r - min_v
max_r = current if current > max_r
min_v = r if r < min_v
end
puts max_r | n = gets.to_i
r = Array.new
r0 = gets.to_i
r1 = gets.to_i
max_r = r1 - r0
min_v = r0 < r1 ? r0 : r1
(n-2).times do
r = gets.to_i
current = r - min_v
max_r = current if current > max_r
min_v = r if r < min_v
end
puts max_r | [] | 104,268 | 104,269 | u107950945 | ruby |
p02258 | n = gets.to_i
min = last = gets.to_i
profits = []
(n-2).times{
current = gets.to_i
profits<<(current-min) if (profits.bsearch{|i| i >= 0} == nil) || (current > last)
min = current if (current < min)
last = current
}
puts profits.max | n = gets.to_i
min = last = gets.to_i
profits = []
(n-1).times{
current = gets.to_i
profits<<(current-min) if (profits.bsearch{|i| i >= 0} == nil) || (current > last)
min = current if (current < min)
last = current
}
puts profits.max | [
"literal.number.integer.change",
"expression.operation.binary.change"
] | 104,274 | 104,275 | u213421924 | ruby |
p02258 |
n = gets.to_i
a = gets.to_i
b = gets.to_i
can = b-a
if n==2 then
puts can
else
if a>b then
left = b
end
m = n-2
m.times{
right = gets.to_i
d = right - left
if d>can then
can = d
end
if right< left then
left = right
end
}
puts can
end
|
n = gets.to_i
a = gets.to_i
b = gets.to_i
can = b-a
if n==2 then
puts can
else
if a>b then
left = b
else
left = a
end
m = n-2
m.times{
right = gets.to_i
d = right - left
if d>can then
can = d
end
if right < left then
left = right
end
}
puts can
end
| [
"assignment.add"
] | 104,290 | 104,291 | u350127362 | ruby |
p02258 |
n = gets.to_i
a = gets.to_i
b = gets.to_i
can = b-a
if n==2 then
puts can
else
if a>b then
left = b
end
m = n-2
m.times{
right = gets.to_i
d = right - left
if d>can then
can = d
end
if right < left then
left = right
end
}
puts can
end
|
n = gets.to_i
a = gets.to_i
b = gets.to_i
can = b-a
if n==2 then
puts can
else
if a>b then
left = b
else
left = a
end
m = n-2
m.times{
right = gets.to_i
d = right - left
if d>can then
can = d
end
if right < left then
left = right
end
}
puts can
end
| [
"assignment.add"
] | 104,292 | 104,291 | u350127362 | ruby |
p02258 | arr = []
n = gets.to_i
n.times do
input = gets.to_i
arr << input
end
max = -2000000000000000
minv = arr[0]
arr.length.times do |i|
i += 1
max = arr[i] - minv if(arr[i] - minv > max)
minv = arr[i] if(arr[i] < minv)
end
p max
| arr = []
n = gets.to_i
n.times do
input = gets.to_i
arr << input
end
max = -2000000000000000
minv = arr[0]
(arr.length - 1).times do |i|
i += 1
max = arr[i] - minv if(arr[i] - minv > max)
minv = arr[i] if(arr[i] < minv)
end
p max
| [] | 104,293 | 104,294 | u352940122 | ruby |
p02258 | arr = []
n = gets.to_i
n.times do
input = gets.to_i
arr << input
end
max = -2000000000000000
minv = arr[0]
(arr.length - 1).times do |i|
i += 1
max = arr[i] - minv if(arr[0] - minv > max)
minv = arr[i] if(arr[i] < minv)
end
p max
| arr = []
n = gets.to_i
n.times do
input = gets.to_i
arr << input
end
max = -2000000000000000
minv = arr[0]
(arr.length - 1).times do |i|
i += 1
max = arr[i] - minv if(arr[i] - minv > max)
minv = arr[i] if(arr[i] < minv)
end
p max
| [
"identifier.replace.add",
"literal.replace.remove",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 104,295 | 104,294 | u352940122 | ruby |
p02263 | while ary = gets
ary.chomp
stack = []
ary = str.split(" ")
while ary.size>0
a = ary.shift
if a == "+"
x = stack.shift.to_i + stack.shift.to_i
elsif a == "-"
x = -stack.shift.to_i + stack.shift.to_i
elsif a == "*"
x = stack.shift.to_i * stack.shift.to_i
else
x = a
... | while ary = gets
ary.chomp
stack = []
ary = ary.split(" ")
while ary.size>0
a = ary.shift
if a == "+"
x = stack.shift.to_i + stack.shift.to_i
elsif a == "-"
x = -stack.shift.to_i + stack.shift.to_i
elsif a == "*"
x = stack.shift.to_i * stack.shift.to_i
else
x = a
... | [
"assignment.value.change",
"identifier.change"
] | 107,557 | 107,558 | u535246834 | ruby |
p02263 | MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new
if(defined? MODE)
line = STDIN.read.split("\n")
else
tmp = '1 2 +'.split("\n")
tmp.each{|s|
line << s.strip
}
end
arr = line[0].split(" ")
stack = []
arr.each do |i|
case i
when "+"
stack.push(stack.pop+stack.pop)
when "-"
sta... | MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new
if(defined? MODE)
line = STDIN.read.split("\n")
else
tmp = '1 1 +'.split("\n")
tmp.each{|s|
line << s.strip
}
end
arr = line[0].split(" ")
stack = []
arr.each do |i|
case i
when "+"
stack.push(stack.pop+stack.pop)
when "-"
stac... | [
"literal.string.change",
"assignment.value.change",
"expression.operation.unary.add",
"call.arguments.change",
"misc.opposites",
"expression.operator.arithmetic.change",
"expression.operation.binary.change"
] | 107,563 | 107,564 | u876514616 | ruby |
p02261 | def bubble_sort(a)
arr = a.dup
n = arr.length
for i in 0..n - 1
j = n - 1
while j > i
if arr[j-1][1] > arr[j][1]
arr[j-1],arr[j] = arr[j],arr[j-1]
end
j -= 1
end
end
arr
end
def selection_sort(arr)
a = arr.dup
for i in 0..(a.length - 1)
min = i
for j in i ..(... | def bubble_sort(a)
arr = a.dup
n = arr.length
for i in 0..n - 1
j = n - 1
while j > i
if arr[j-1][1] > arr[j][1]
arr[j-1],arr[j] = arr[j],arr[j-1]
end
j -= 1
end
end
arr
end
def selection_sort(arr)
a = arr.dup
for i in 0..(a.length - 1)
min = i
for j in i ..(... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 107,997 | 107,998 | u739433776 | ruby |
p02261 | # ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
a = c.dup
(0..n-1).each do |i|
(n-1).downto(i) do |j|
if a[j][1].to_i < a[j-1][1].to_i
a[j], a[j-1] = a[j-1], a[j]
end
end
end
return a
end
def selectionSort(c, n)
a = c.dup
(0..n-1).each ... | # ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
a = c.dup
(0..n-1).each do |i|
(n-1).downto(i+1) do |j|
if a[j][1].to_i < a[j-1][1].to_i
a[j], a[j-1] = a[j-1], a[j]
end
end
end
return a
end
def selectionSort(c, n)
a = c.dup
(0..n-1).eac... | [
"literal.string.change",
"call.arguments.change"
] | 107,999 | 108,000 | u247976584 | ruby |
p02261 | # ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
a = c.dup
(0..n-1).each do |i|
(n-1).downto(i) do |j|
if a[j][1].to_i < a[j-1][1].to_i
a[j], a[j-1] = a[j-1], a[j]
end
end
end
return a
end
def selectionSort(c, n)
a = c.dup
(0..n-1).each ... | # ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
a = c.dup
(0..n-1).each do |i|
(n-1).downto(i+1) do |j|
if a[j][1].to_i < a[j-1][1].to_i
a[j], a[j-1] = a[j-1], a[j]
end
end
end
return a
end
def selectionSort(c, n)
a = c.dup
(0..n-1).eac... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 108,001 | 108,000 | u247976584 | ruby |
p02261 | # ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
a = c.dup
(0..n-1).each do |i|
(n-1).downto(i) do |j|
if a[j][1].to_i < a[j-1][1].to_i
a[j], a[j-1] = a[j-1], a[j]
end
end
end
return a
end
def selectionSort(c, n)
a = c.dup
(0..n-1).each ... | # ALDS1_2_C Stable Sort
n = gets.chomp.to_i
a = gets.chomp.split(" ")
def bubbleSort(c, n)
a = c.dup
(0..n-1).each do |i|
(n-1).downto(i+1) do |j|
if a[j][1].to_i < a[j-1][1].to_i
a[j], a[j-1] = a[j-1], a[j]
end
end
end
return a
end
def selectionSort(c, n)
a = c.dup
(0..n-1).eac... | [
"expression.operation.binary.add"
] | 108,002 | 108,000 | u247976584 | ruby |
p02261 | size = STDIN.gets.to_i
c = STDIN.gets.split
b = c.dup
size.times do |i|
(size-1).downto(i) do |j|
if b[j][1] < b[j-1][1]
b[j], b[j-1] = b[j-1], b[j]
end
end
end
puts b.join(' ')
def stable?(a1, a2)
h1 = Hash.new{|h, k| h[k] = []}
h2 = Hash.new{|h, k| h[k] = []}
a1.each... | size = STDIN.gets.to_i
c = STDIN.gets.split
b = c.dup
size.times do |i|
(size-1).downto(i+1) do |j|
if b[j][1] < b[j-1][1]
b[j], b[j-1] = b[j-1], b[j]
end
end
end
puts b.join(' ')
def stable?(a1, a2)
h1 = Hash.new{|h, k| h[k] = []}
h2 = Hash.new{|h, k| h[k] = []}
a1.ea... | [
"expression.operation.binary.add"
] | 108,003 | 108,004 | u854587684 | ruby |
p02261 | class Card
attr_accessor :suit, :value
def initialize(str)
@suit = str[0]
@value = str[1].to_i
end
def to_s
"#@suit#@value"
end
def self.bubble_sort(c)
c = c.dup
n = c.size
0.upto(n-1){|i|
(n-1).downto(i){|j|
if c[j].value < c[j-1].value
c[j], c[j-1] = c[j-1], c[j]
end
}
}
c... | class Card
attr_accessor :suit, :value
def initialize(str)
@suit = str[0]
@value = str[1].to_i
end
def to_s
"#@suit#@value"
end
def self.bubble_sort(c)
c = c.dup
n = c.size
0.upto(n-1){|i|
(n-1).downto(i+1){|j|
if c[j].value < c[j-1].value
c[j], c[j-1] = c[j-1], c[j]
end
}
}
... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 108,005 | 108,006 | u422350156 | ruby |
p02261 | class Card
attr_accessor :suit, :value
def initialize(str)
@suit = str[0]
@value = str[1].to_i
end
def to_s
"#@suit#@value"
end
def self.bubble_sort(c)
c = c.dup
n = c.size
0.upto(n-1){|i|
(n-1).downto(i){|j|
if c[j].value < c[j-1].value
c[j], c[j-1] = c[j-1], c[j]
end
}
}
c... | class Card
attr_accessor :suit, :value
def initialize(str)
@suit = str[0]
@value = str[1].to_i
end
def to_s
"#@suit#@value"
end
def self.bubble_sort(c)
c = c.dup
n = c.size
0.upto(n-1){|i|
(n-1).downto(i+1){|j|
if c[j].value < c[j-1].value
c[j], c[j-1] = c[j-1], c[j]
end
}
}
... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 108,007 | 108,006 | u422350156 | ruby |
p02261 | class Card
attr_accessor :suit, :value
def initialize(str)
@suit = str[0]
@value = str[1].to_i
end
def to_s
"#@suit#@value"
end
def self.bubble_sort(c)
c = c.dup
n = c.size
0.upto(n-1){|i|
(n-1).downto(i){|j|
if c[j].value < c[j-1].value
c[j], c[j-1] = c[j-1], c[j]
end
}
}
c... | class Card
attr_accessor :suit, :value
def initialize(str)
@suit = str[0]
@value = str[1].to_i
end
def to_s
"#@suit#@value"
end
def self.bubble_sort(c)
c = c.dup
n = c.size
0.upto(n-1){|i|
(n-1).downto(i+1){|j|
if c[j].value < c[j-1].value
c[j], c[j-1] = c[j-1], c[j]
end
}
}
... | [
"expression.operation.binary.add",
"assignment.remove"
] | 108,008 | 108,006 | u422350156 | ruby |
p02261 | def bubbleSort c, n
for i in 0...n
for j in (i...n).to_a.reverse
if c[j][1] < c[j - 1][1]
temp = c[j]
c[j] = c[j - 1]
c[j - 1] = temp
end
end
end
end
def selectionSort c, n
for i in 0...n
minj = i
for j ... | def bubbleSort c, n
for i in 1...n
for j in (i...n).to_a.reverse
if c[j][1] < c[j - 1][1]
temp = c[j]
c[j] = c[j - 1]
c[j - 1] = temp
end
end
end
end
def selectionSort c, n
for i in 0...n
minj = i
for j... | [
"literal.number.integer.change"
] | 108,013 | 108,014 | u247371045 | ruby |
p02261 | def b_sort(ca)
c = ca.dup
s = 0
c.sort_by{|i| [i[1], s += 1]}
end
def s_sort(ca)
c = ca.dup
c.size.times do |i|
m = i
i.upto(c.size - 1) do |j|
if c[j][1] < c[m][1]
m = j
end
end
c[m], c[i] = c[m], c[i]
end
c
end
gets
a = gets.split.map! do |e|
e =~ /(\w)(\d+)/
[$... | def b_sort(ca)
c = ca.dup
s = 0
c.sort_by{|i| [i[1], s += 1]}
end
def s_sort(ca)
c = ca.dup
c.size.times do |i|
m = i
i.upto(c.size - 1) do |j|
if c[j][1] < c[m][1]
m = j
end
end
c[m], c[i] = c[i], c[m]
end
c
end
gets
a = gets.split.map! do |e|
e =~ /(\w)(\d+)/
[$... | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 108,018 | 108,019 | u295404099 | ruby |
p02261 | def b_sort(ca)
c = ca.dup
s = 0
c.sort_by{|i| [i[1], s += 1]}
end
def s_sort(ca)
c = ca.dup
c.size.times do |i|
m = i
i.upto(c.size - 1) do |j|
if c[j][1] < c[m][1]
m = j
end
end
c[m], c[i] = c[i], c[m]
end
c
end
gets
a = gets.split.map do |e|
e =~ /(\w)(\d+)/
[$1... | def b_sort(ca)
c = ca.dup
s = 0
c.sort_by{|i| [i[1], s += 1]}
end
def s_sort(ca)
c = ca.dup
c.size.times do |i|
m = i
i.upto(c.size - 1) do |j|
if c[j][1] < c[m][1]
m = j
end
end
c[m], c[i] = c[i], c[m]
end
c
end
gets
a = gets.split.map do |e|
e =~ /(\w)(\d+)/
[$1... | [
"literal.string.change",
"call.arguments.change"
] | 108,020 | 108,021 | u295404099 | ruby |
p02261 | def b_sort(ca)
c = ca.dup
s = 0
c.sort_by{|i| [i[1], s += 1]}
end
def s_sort(ca)
c = ca.dup
c.size.times do |i|
m = i
i.upto(c.size - 1) do |j|
if c[j][1] < c[m][1]
m = j
end
end
c[m], c[i] = c[m], c[i]
end
c
end
gets
a = gets.split.map! do |e|
e =~ /(\w)(\d+)/
[$... | def b_sort(ca)
c = ca.dup
s = 0
c.sort_by{|i| [i[1], s += 1]}
end
def s_sort(ca)
c = ca.dup
c.size.times do |i|
m = i
i.upto(c.size - 1) do |j|
if c[j][1] < c[m][1]
m = j
end
end
c[m], c[i] = c[i], c[m]
end
c
end
gets
a = gets.split.map do |e|
e =~ /(\w)(\d+)/
[$1... | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 108,018 | 108,022 | u295404099 | ruby |
p02261 | n = gets.chomp.to_i
arr1 = gets.chomp.split(' ')
arr2 = []
(0...n).each do |i|
arr1[i] = arr1[i].split('')
arr1[i][1] = arr1[i][1].to_i
arr2[i] = arr1[i]
end
def is_same?(arr1, arr2, n)
(0...n).each do |i|
if arr1[i] != arr2[i]
return false
end
end
return true
end
def bubble_sort(arr, n)
... | n = gets.chomp.to_i
arr1 = gets.chomp.split(' ')
arr2 = []
(0...n).each do |i|
arr1[i] = arr1[i].split('')
arr1[i][1] = arr1[i][1].to_i
arr2[i] = arr1[i]
end
def is_same?(arr1, arr2, n)
(0...n).each do |i|
if arr1[i] != arr2[i]
return false
end
end
return true
end
def bubble_sort(arr, n)
... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 108,023 | 108,024 | u799048341 | ruby |
p02261 | n = gets
arr = gets.chomp.split
arro = arr.clone
arr0 = arr.clone
arr1 = arr.clone
def bubble_sort(arr)
count = 0
arr.length.times do |i|
j = arr.length - 1
while j >= i+1
if(arr[j-1][1] > arr[j][1])
tmp = arr[j-1]
arr[j-1] = arr[j]
arr[j] = tmp
end
j -= 1
end
... | n = gets
arr = gets.chomp.split
arro = arr.clone
arr0 = arr.clone
arr1 = arr.clone
def bubble_sort(arr)
count = 0
arr.length.times do |i|
j = arr.length - 1
while j >= i+1
if(arr[j-1][1] > arr[j][1])
tmp = arr[j-1]
arr[j-1] = arr[j]
arr[j] = tmp
end
j -= 1
end
... | [
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 108,025 | 108,026 | u352940122 | ruby |
p02261 | def bubble_sort(array, n)
n.times do |i|
(n - 1).downto(i + 1) do |j|
if array[j].num < array[j - 1].num
array[j], array[j - 1] = array[j - 1], array[j]
end
end
end
array
end
def selection_sort(array, n)
n.times do |i|
minj = i
i.upto(n - 1) do |j|
minj = j if array[j]... | def bubble_sort(array, n)
n.times do |i|
(n - 1).downto(i + 1) do |j|
if array[j].num < array[j - 1].num
array[j], array[j - 1] = array[j - 1], array[j]
end
end
end
array
end
def selection_sort(array, n)
n.times do |i|
minj = i
i.upto(n - 1) do |j|
minj = j if array[j]... | [
"identifier.change",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"control_flow.return.remove"
] | 108,027 | 108,028 | u731989230 | ruby |
p02262 | # get input
n=gets.to_i
target=[]
n.times do
target << gets.to_i
end
# insertion sort method
def insertion_sort a, n, g
cnt = 0
(g..n-1).each do |i|
v = a[i]
j = i - g
while j >= 0 && a[j] > v
a[j+g] = a[j]
j = j - g
cnt+=1
end
a[j+g] = v
end
return cnt
end
# main
## g ... | # get input
n=gets.to_i
target=[]
n.times do
target << gets.to_i
end
# insertion sort method
def insertion_sort a, n, g
cnt = 0
(g..n-1).each do |i|
v = a[i]
j = i - g
while j >= 0 && a[j] > v
a[j+g] = a[j]
j = j - g
cnt+=1
end
a[j+g] = v
end
return cnt
end
# main
g = ... | [
"assignment.value.change"
] | 109,198 | 109,199 | u352522848 | ruby |
p02262 | n=gets.chomp.to_i
ary=Array.new
for i in 0..n-1
ary=ary.push(gets.chomp.to_i)
end
def insertion(ary,n,g)
for i in g..n-1
v=ary[i]
j=i-g
while j>=0 && ary[j]>v
ary[j+g]=ary[j]
j-=g
@count+=1
end
ary[j+g]=v
end
end
g=1
while 3*g+1<=n
g=3*g+1
end
@count=0
k=Array.new
while g>=1
insertion(ary... | n=gets.chomp.to_i
ary=Array.new
for i in 0..n-1
ary=ary.push(gets.chomp.to_i)
end
def insertion(ary,n,g)
for i in g..n-1
v=ary[i]
j=i-g
while j>=0 && ary[j]>v
ary[j+g]=ary[j]
j-=g
@count+=1
end
ary[j+g]=v
end
end
g=1
while 3*g+1<=n
g=3*g+1
end
@count=0
k=Array.new
while g>=1
insertion(ary... | [
"call.add"
] | 109,202 | 109,203 | u534464795 | ruby |
p02262 | def insertion_sort(array, n, g)
cnt = 0
g.upto n - 1 do |i|
v = array[i]
j = i - g
while j >= 0 && array[j] > v
array[j + g] = array[j]
j -= g
cnt += 1
end
array[j + g] = v
end
cnt
end
def shell_sort(array, n)
cnt = 0
g = [1]
g << 3 * g[-1] + 1 until 3 * g[-1] + 1 > ... | def insertion_sort(array, n, g)
cnt = 0
g.upto n - 1 do |i|
v = array[i]
j = i - g
while j >= 0 && array[j] > v
array[j + g] = array[j]
j -= g
cnt += 1
end
array[j + g] = v
end
cnt
end
def shell_sort(array, n)
cnt = 0
g = [1]
g << 3 * g[-1] + 1 until 3 * g[-1] + 1 > ... | [
"call.add"
] | 109,210 | 109,211 | u731989230 | ruby |
p02262 | #!/usr/bin/ruby
def insertionSort(a, n, g)
for i in g..n-1
v = a[i]
j = i - g
while j >= 0 && a[j] > v
a[j+g] = a[j]
j = j - g
$cnt+=1
a[j+g] = v
end
end
end
def shellSort(a, n)
$cnt = 0
g = []
h = 1
while h*2 <= n
g << h
h = 3*h+1
end
g.reverse!
m = g.size
p m
puts g*' '
for i in 0... | #!/usr/bin/ruby
def insertionSort(a, n, g)
for i in g..n-1
v = a[i]
j = i - g
while j >= 0 && a[j] > v
a[j+g] = a[j]
j = j - g
$cnt+=1
a[j+g] = v
end
end
end
def shellSort(a, n)
$cnt = 0
g = []
h = 1
while h <= n
... | [] | 109,213 | 109,214 | u300645821 | ruby |
p02262 | #!/usr/bin/ruby
def insertionSort(a,g)
for i in g..a.size-1
v = a[i]
j = i - g
while j >= 0 && a[j] > v
a[j+g] = a[j]
j = j - g
$cnt+=1
a[j+g] = v
end
end
end
def shellSort(a)
$cnt = 0
g = []
h = 1
while h <= a.size
g << h
h = 3*h+1
end
g.reverse!
m = g.size
p m
puts g*' '
for i in ... | #!/usr/bin/ruby
def insertionSort(a,g)
for i in g..a.size-1
v = a[i]
j = i - g
while j >= 0 && a[j] > v
a[j+g] = a[j]
j = j - g
$cnt+=1
a[j+g] = v
end
end
end
def shellSort(a)
$cnt = 0
g = []
h = 1
while h <= a.size
g << h
h = 3*h+1
end
g.reverse!
m = g.size
p m
puts g*' '
for i in ... | [
"call.arguments.change"
] | 109,215 | 109,216 | u300645821 | ruby |
p02264 | def roundRobin(q, process, time)
currentTime = 0
loop do
break if process.empty?
p = process.shift
t = time.shift
if t <= q
currentTime += t
puts p + " " + currentTime.to_s
else
t -= q
process.push p
time.push t
currentTime += q
end
end
end
if __FILE__... | def roundRobin(q, process, time)
currentTime = 0
loop do
break if process.empty?
p = process.shift
t = time.shift
if t <= q
currentTime += t
puts p + " " + currentTime.to_s
else
t -= q
process.push p
time.push t
currentTime += q
end
end
end
if __FILE__... | [
"call.remove"
] | 109,677 | 109,678 | u881491942 | ruby |
p02264 | class Task
def initialize(name, qms)
@name = name
if !qms.is_a? Integer
qms = qms.to_i
end
@qms = qms
end
def consume(time)
@qms -= time
end
def to_s
"#{@name}"
end
end
n, consume_time = STDIN.gets.split.map(&:to_i)
queue = []
n.times do
pname, ptime = STDIN.gets.split
queue.push(Task.new(p... | class Task
def initialize(name, qms)
@name = name
if !qms.is_a? Integer
qms = qms.to_i
end
@qms = qms
end
def consume(time)
@qms -= time
end
def to_s
"#{@name}"
end
end
n, consume_time = STDIN.gets.split.map(&:to_i)
queue = []
n.times do
pname, ptime = STDIN.gets.split
queue.push(Task.new(p... | [
"identifier.replace.add",
"literal.replace.remove"
] | 109,679 | 109,680 | u977801694 | ruby |
p02264 | n_process, quantum = gets.chomp.split.map(&:to_i)
queue = []
n_process.times{
name, sec = gets.chomp.split
queue.push [name, sec.to_i]
}
time = 0
until queue.empty?
process = queue.shift
p process
if process[1] <= quantum
# p "?¶???????"
time += process[1]
puts "#{process[0]... | n_process, quantum = gets.chomp.split.map(&:to_i)
queue = []
n_process.times{
name, sec = gets.chomp.split
queue.push [name, sec.to_i]
}
time = 0
until queue.empty?
process = queue.shift
# p process
if process[1] <= quantum
# p "?¶???????"
time += process[1]
puts "#{process[... | [
"call.remove"
] | 109,689 | 109,690 | u677710583 | ruby |
p02264 | n_process, quantum = gets.chomp.split.map(&:to_i)
queue = []
n_process.times{
name, sec = gets.chomp.split
queue.push [name, sec.to_i]
}
time = 0
until queue.empty?
process = queue.shift
p process
if process[1] <= quantum
# p "?¶???????"
time += process[1]
puts "#{process[0]... | n, quantum = gets.chomp.split.map(&:to_i)
queue = []
n.times{
name, sec = gets.chomp.split
queue.push [name, sec.to_i]
}
time = 0
until queue.empty?
process = queue.shift
# p process
if process[1] <= quantum
# p "?¶???????"
time += process[1]
puts "#{process[0]} #{time}"
... | [
"assignment.variable.change",
"identifier.change",
"call.remove"
] | 109,689 | 109,691 | u677710583 | ruby |
p02264 | line1 = STDIN.gets.chomp.split(" ")
n = line1[0].to_i
q = line1[1].to_i
queue = Array.new(n)
n.times do |i|
line = STDIN.gets.chomp.split(" ")
process = [line[0], line[1].to_i]
queue[i] = process
end
time = 0
processes_ended = Array.new
while queue.empty? == false
process = queue.shift
if process[1] > q
... | line1 = STDIN.gets.chomp.split(" ")
n = line1[0].to_i
q = line1[1].to_i
queue = Array.new(n)
n.times do |i|
line = STDIN.gets.chomp.split(" ")
process = [line[0], line[1].to_i]
queue[i] = process
end
time = 0
processes_ended = Array.new
while queue.empty? == false
process = queue.shift
if process[1] > q
... | [] | 109,694 | 109,695 | u818475907 | ruby |
p02264 | n,q = gets.split.map(&:to_i)
queue = []
n.times{
queue << gets.split
}
# n,q=5,100
# queue = [["p1",150],["p2",80],["p3",200],["p4",350],["p5",20]]
# time = 0
def aqueue(n,q,queue,time)
ans = []
while queue.size != 0
v = queue.shift
if v[1].to_i <= q
time += v[1].to_i
ans.push("#{v[0]} #{time}... | n,q = gets.split.map(&:to_i)
queue = []
n.times{
queue << gets.split
}
# n,q=5,100
# queue = [["p1",150],["p2",80],["p3",200],["p4",350],["p5",20]]
time = 0
def aqueue(n,q,queue,time)
ans = []
while queue.size != 0
v = queue.shift
if v[1].to_i <= q
time += v[1].to_i
ans.push("#{v[0]} #{time}")... | [
"assignment.add"
] | 109,698 | 109,699 | u151409041 | ruby |
p02264 | n, q = gets.chomp.split(' ').map(&:to_i)
arr = []
(0...n).each do |i|
arr[i]= gets.chomp.split(' ')
end
class Queue
attr_accessor :head, :tail, :queue
def initialize(size)
@head = 0
@tail = 0
@queue = Array.new(size)
end
def enqueue(x)
@queue[@tail] = x
if @tail + 1 == @queue.size
... | n, q = gets.chomp.split(' ').map(&:to_i)
arr = []
(0...n).each do |i|
arr[i]= gets.chomp.split(' ')
end
class Queue
attr_accessor :head, :tail, :queue
def initialize(size)
@head = 0
@tail = 0
@queue = Array.new(size)
end
def enqueue(x)
@queue[@tail] = x
if @tail + 1 == @queue.size
... | [
"identifier.replace.add",
"literal.replace.remove"
] | 109,700 | 109,701 | u799048341 | ruby |
p02264 | class Proces
def initialize(name,time)
@name = name
@time = time.to_i
end
def act limit
if @time > limit
@time -= limit
true
end
false
end
attr_reader :name,:time
end
queue = Array.new()
time = 0
temp = gets.split(" ").map{|x| x.to_i}
q = temp.pop
num = temp.pop
num.times do
... | class Proces
def initialize(name,time)
@name = name
@time = time.to_i
end
def act limit
if @time > limit
@time -= limit
true
end
end
attr_reader :name,:time
end
queue = Array.new()
time = 0
temp = gets.split(" ").map{|x| x.to_i}
q = temp.pop
num = temp.pop
num.times do
temp = ge... | [] | 109,704 | 109,705 | u588130269 | ruby |
p02263 | ary=gets.chomp.split(" ")
stack=[]
c=[]
ary.each {|x|
if x =~ /\d+/
x=x.to_i
stack.unshift(x)
p stack
c=nil
elsif x== "+" || x=="-" || x=="*" || x=="/"
b=stack.shift
a=stack.shift
case x
when "+"
stack=stack.unshift(a+b)
when "-"
stack=stack.unshift(a-b)
when "*"
stack=stack.unsh... | ary=gets.chomp.split(" ")
stack=[]
c=[]
ary.each {|x|
if x =~ /\d+/
x=x.to_i
stack.unshift(x)
c=nil
elsif x== "+" || x=="-" || x=="*" || x=="/"
b=stack.shift
a=stack.shift
case x
when "+"
stack=stack.unshift(a+b)
when "-"
stack=stack.unshift(a-b)
when "*"
stack=stack.unshift(a*b)
... | [
"call.remove"
] | 109,803 | 109,804 | u534464795 | ruby |
p02263 | input_str = STDIN.gets
input_list = input_str.split(" ")
stack = []
input_list.each do |value|
case value
when '+'
a = stack.pop
b = stack.pop
c = a + b
stack.push c
when '-'
a = stack.pop
b = stack.pop
c = a - b
stack.push c
when '*'
a = stack.pop
b = stack.pop
c = ... | input_str = STDIN.gets
input_list = input_str.split(" ")
stack = []
input_list.each do |value|
case value
when '+'
b = stack.pop
a = stack.pop
c = a + b
stack.push c
when '-'
b = stack.pop
a = stack.pop
c = a - b
stack.push c
when '*'
b = stack.pop
a = stack.pop
c = ... | [
"assignment.variable.change",
"identifier.change"
] | 109,807 | 109,808 | u188708842 | ruby |
p02263 | #一つの数式が一行に与えられます
#連続するシンボルは一つの空白で区切られて与えられます
#計算結果を一行に出力してください
require "pp"
input = gets.chomp.split(" ")
stack = %w[]
input.each do |str|
if str =~ /^[0-9]/
stack.push str
else
if str == "+"
second = stack.pop.to_i
first = stack.pop.to_i
stack.push(first-second)
elsif str == "-"
... | #一つの数式が一行に与えられます
#連続するシンボルは一つの空白で区切られて与えられます
#計算結果を一行に出力してください
require "pp"
input = gets.chomp.split(" ")
stack = %w[]
input.each do |str|
if str =~ /^[0-9]/
stack.push str
else
if str == "+"
second = stack.pop.to_i
first = stack.pop.to_i
stack.push(first+second)
elsif str == "-"
... | [
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 109,810 | 109,811 | u483082413 | ruby |
p02265 | # 双方向連結リスト | アルゴリズムとデータ構造 | Aizu Online Judge http://is.gd/5CIlit
n = gets.chomp.to_i
doubleLinkedList = Array.new
n.times do
command = gets.chomp
if command == "deleteFirst" then
doubleLinkedList.shift
elsif command == "deleteLast" then
doubleLinkedList.pop
else
command, x = command.split
x = x... | # 双方向連結リスト | アルゴリズムとデータ構造 | Aizu Online Judge http://is.gd/5CIlit
n = gets.chomp.to_i
doubleLinkedList = Array.new
n.times do
command = gets.chomp
if command == "deleteFirst" then
doubleLinkedList.shift
elsif command == "deleteLast" then
doubleLinkedList.pop
else
command, x = command.split
x = x... | [] | 110,169 | 110,170 | u247976584 | ruby |
p02265 | class List
def initialize
@head = Node.new
@tail = Node.new(@head)
@head.nxt = @tail
end
def insert(val)
nxt_old = @head.nxt
node = Node.new(@head, nxt_old, val)
@head.nxt = node
nxt_old.prv = node
end
def delete(val)
node = @head.nxt
while node.val
if node.val == v... | class List
def initialize
@head = Node.new
@tail = Node.new(@head)
@head.nxt = @tail
end
def insert(val)
nxt_old = @head.nxt
node = Node.new(@head, nxt_old, val)
@head.nxt = node
nxt_old.prv = node
end
def delete(val)
node = @head.nxt
while node.val
if node.val == v... | [
"call.add"
] | 110,171 | 110,172 | u631235380 | ruby |
p02265 | n = gets.to_i
command_list = []
n.times do
command_list << gets.chomp.split
end
list = []
while command_list.length > 0
command = command_list.shift
if command[0] == "insert"
list << command[1].to_i
elsif command[0] == "delete"
x = list.rindex(command[1].to_i)
list.delete_at(x)
elsif command[0] =... | n = gets.to_i
command_list = []
n.times do
command_list << gets.chomp.split
end
list = []
while command_list.length > 0
command = command_list.shift
if command[0] == "insert"
list << command[1].to_i
elsif command[0] == "delete"
x = list.rindex(command[1].to_i)
if x
list.delete_at(x)
end
... | [] | 110,178 | 110,179 | u536840698 | ruby |
p02265 | #!/usr/bin/env ruby
n = gets.chomp.to_i
list = []
n.times do
action, num = gets.chomp.split
case action
when 'insert'
list.unshift(num.to_i)
when 'delete'
i = list.index(num.to_i)
list.delete_at(i) if i
when 'deleteFirst'
list.shift
when 'deleteLast'
list.pop
end
end
puts list.reve... | #!/usr/bin/env ruby
n = gets.chomp.to_i
list = []
n.times do
action, num = gets.chomp.split
case action
when 'insert'
list.unshift(num.to_i)
when 'delete'
i = list.index(num.to_i)
list.delete_at(i) if i
when 'deleteFirst'
list.shift
when 'deleteLast'
list.pop
end
end
puts list * ' ... | [
"call.remove"
] | 110,184 | 110,185 | u717782380 | ruby |
p02265 | n = gets.chomp.to_i
arr = Array.new
n.times do
order = gets.split(" ")
case order[0]
when "insert"
arr.unshift(order[1].to_i)
when "delete"
arr.index(order[1].to_i) == nil ? (next): (queue.delete_at(queue.index(order[1].to_i)))
when "deleteFirst"
arr.shift
when "deleteLast"
arr.... | n = gets.chomp.to_i
arr = Array.new
n.times do
order = gets.split(" ")
case order[0]
when "insert"
arr.unshift(order[1].to_i)
when "delete"
arr.index(order[1].to_i) == nil ? (next): (arr.delete_at(arr.index(order[1].to_i)))
when "deleteFirst"
arr.shift
when "deleteLast"
arr.pop
... | [
"identifier.change",
"call.arguments.change"
] | 110,186 | 110,187 | u481175672 | ruby |
p02265 | array = Array.new
gets.to_i.times do
command = gets.chomp.split
case command[0]
when 'insert'
array.unshift(command[1].to_i)
when 'delete'
array.delete_at(array.index(command[1].to_i))
when 'deleteFirst'
array.shift
when 'deleteLast'
array.pop
end
end
puts array*' ' | array = Array.new
gets.to_i.times do
command = gets.chomp.split
case command[0]
when 'insert'
array.unshift(command[1].to_i)
when 'delete'
begin
array.delete_at(array.index(command[1].to_i))
rescue
end
when 'deleteFirst'
array.shift
when 'deleteLast'
array.pop
end
end
puts a... | [] | 110,195 | 110,196 | u879497299 | ruby |
p02265 | l = []
gets.to_i.times do
com, n = gets.split
case com
when 'insert'
l.unshift(n)
when 'delete'
i = l.index(n)
l.delete_at(i)
when 'deleteFirst'
l.shift
when 'deleteLast'
l.pop
end
end
puts l * ' ' | l = []
gets.to_i.times do
com, n = gets.split
case com
when 'insert'
l.unshift(n)
when 'delete'
i = l.index(n)
l.delete_at(i) unless i.nil?
when 'deleteFirst'
l.shift
when 'deleteLast'
l.pop
end
end
puts l * ' ' | [] | 110,197 | 110,198 | u517414491 | ruby |
p02266 | def solve(diagram)
area = 0
froms = []
layers = []
(0...diagram.size).each do |x|
c = diagram[x]
case c
when '\\' then
froms.push x
when '/' then
next if froms.empty?
from = froms.pop
area += 1
area += x - from - 1
layers << [from, x]
end
end
return ar... | def solve(diagram)
area = 0
froms = []
layers = []
(0...diagram.size).each do |x|
c = diagram[x]
case c
when '\\' then
froms.push x
when '/' then
next if froms.empty?
from = froms.pop
area += 1
area += x - from - 1
layers << [from, x]
end
end
return ar... | [
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 110,515 | 110,516 | u723368439 | ruby |
p02267 | n = STDIN.gets.to_i
s = STDIN.gets.split[0...n].map(&:to_i)
q = STDIN.gets.to_i
t = STDIN.gets.split[0...q].map(&:to_i)
count = 0
t.each do |te|
s[q] = te # 番兵を利用, rubyでは多分意味ない
i = 0
i += 1 until a[i] == te
count += 1 unless i == q
end
p count | n = STDIN.gets.to_i
s = STDIN.gets.split[0...n].map(&:to_i)
q = STDIN.gets.to_i
t = STDIN.gets.split[0...q].map(&:to_i)
count = 0
t.each do |te|
s[n] = te # 番兵を利用, rubyでは多分意味ない
i = 0
i += 1 until s[i] == te
count += 1 unless i == n
end
p count | [
"assignment.variable.change",
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 111,374 | 111,375 | u977801694 | ruby |
p02267 | int_s = gets.to_i
s_arr = gets.split(" ").map(&:to_i)
int_t = gets.to_i
t_arr = gets.split(" ").map(&:to_i)
count1 = s_arr.count
count2 = (s_arr - t_arr).count
ans = count1 - count2
puts ans | int_s = gets.to_i
s_arr = gets.split(" ").map(&:to_i)
int_t = gets.to_i
t_arr = gets.split(" ").map(&:to_i)
count1 = s_arr.uniq.count
count2 = (s_arr.uniq - t_arr.uniq).count
ans = count1 - count2
puts ans | [
"call.add"
] | 111,376 | 111,377 | u046695668 | ruby |
p02267 | def linearSearch(as, bs)
n = 0
for i in as
for j in bs
if i == j
n = n + 1
end
end
end
puts n
end
a_size = STDIN.gets.to_i
as = STDIN.gets.split(' ')
b_size = STDIN.gets.to_i
bs = STDIN.gets.split(' ')
linearSearch(as, bs) | def linearSearch(as, bs)
n = 0
for i in bs
for j in as
if i == j
n = n + 1
break;
end
end
end
puts n
end
a_size = STDIN.gets.to_i
as = STDIN.gets.split(' ')
b_size = STDIN.gets.to_i
bs = STDIN.gets.split(' ')
linearSearch(as, bs) | [
"identifier.change"
] | 111,380 | 111,381 | u382730661 | ruby |
p02267 | n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i)
c = 0
t.each { |i|
s.each{ |j|
if i == j
c+=1
end
}
}
puts c | n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split(" ").map(&:to_i)
c = 0
t.each { |i|
s.each{ |j|
if i == j
c+=1
break
end
}
}
puts c | [
"control_flow.break.add"
] | 111,382 | 111,383 | u843848664 | ruby |
p02267 | s = gets.split
t = gets.sprit
puts (s&t).size | gets
s=gets.split
gets
t=gets.split
puts (s&t).size | [
"assignment.value.change",
"identifier.change"
] | 111,388 | 111,389 | u753751512 | ruby |
p02267 | s = gets.split
t = gets.sprit
puts (s&t).size | gets
s=gets.split
gets
t=gets.split
puts (s&t).size | [
"assignment.value.change",
"identifier.change"
] | 111,390 | 111,389 | u753751512 | ruby |
p02267 | gets
s =gets.split
gets
t =gets.sprit
puts (s&t).size | gets
s=gets.split
gets
t=gets.split
puts (s&t).size | [
"assignment.value.change",
"identifier.change"
] | 111,392 | 111,389 | u753751512 | ruby |
p02267 | gets
s=gets.split
gets
t=gets.sprit
puts (s&t).size | gets
s=gets.split
gets
t=gets.split
puts (s&t).size | [
"assignment.value.change",
"identifier.change"
] | 111,393 | 111,389 | u753751512 | ruby |
p02267 | gets
s=gets.split
gets
t=gets.sprit
puts (s & t).size | gets
s=gets.split
gets
t=gets.split
puts (s&t).size | [
"assignment.value.change",
"identifier.change"
] | 111,394 | 111,389 | u753751512 | ruby |
p02267 | n=gets.to_i
s=gets.split.map(&:to_i)
q=gets.to_i
t=gets.split.map(&:to_i)
cnt=0
s.each do |i|
t.each do |j|
if i==j
cnt+=1
end
end
end
puts cnt | n=gets.to_i
s=gets.split.map(&:to_i)
q=gets.to_i
t=gets.split.map(&:to_i)
cnt=0
t.each do |i|
s.each do |j|
if i==j
cnt+=1
break
end
end
end
puts cnt | [
"identifier.change",
"control_flow.break.add"
] | 111,401 | 111,402 | u083853290 | ruby |
p02267 | def linear_search(array, value)
length = array.length
for i in 0..(length-1)
if array[i] == value
return true
end
end
end
n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)
if n == 10000
puts "100"
break
else
sum_count = 0
for i in 0..(... | def linear_search(array, value)
length = array.length
for i in 0..(length-1)
if array[i] == value
return true
end
end
end
n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)
if n == 10000
puts "100"
else
sum_count = 0
for i in 0..(n-1)
... | [
"control_flow.break.remove"
] | 111,406 | 111,407 | u723368439 | ruby |
p02267 | n = gets.to_i
a = gets.split(' ').map(&:to_i)
m = gets.to_i
b = gets.split(' ').map(&:to_i)
cnt = 0
a.each do |i|
b.each do |ii|
cnt += 1 if i == ii
end
end
puts cnt | n = gets.to_i
a = gets.split(' ').map(&:to_i)
m = gets.to_i
b = gets.split(' ').map(&:to_i)
cnt = 0
a.uniq.each do |i|
b.uniq.each do |ii|
cnt += 1 if i == ii
end
end
puts cnt | [
"call.add"
] | 111,412 | 111,413 | u151409041 | ruby |
p02269 | n = gets.to_i
moji = {}
n.times do |i|
command, arr = gets.split(" ")
if "insert" == command then
moji[arr] = arr
elsif "find" == command then
puts moji ? 'yes' : 'no'
end
end
| n = gets.to_i
moji = { }
n.times do |i|
command, arr = gets.split(" ")
if "insert" == command then
moji[arr] = true
elsif "find" == command then
puts moji[arr] ? 'yes' : 'no'
end
end
| [
"assignment.value.change",
"control_flow.branch.if.condition.change"
] | 114,241 | 114,242 | u565781955 | ruby |
p02269 | n = gets.to_i
moji = { }
n.times do |i|
command, arr = gets.split(" ")
if "insert" == command then
moji[arr] = true
elsif "find" == command then
puts moji ? 'yes' : 'no'
end
end
| n = gets.to_i
moji = { }
n.times do |i|
command, arr = gets.split(" ")
if "insert" == command then
moji[arr] = true
elsif "find" == command then
puts moji[arr] ? 'yes' : 'no'
end
end
| [
"control_flow.branch.if.condition.change"
] | 114,243 | 114,242 | u565781955 | ruby |
p02269 | n = gets.to_i
dic = []
(0..n-1).each do |i|
order, word = gets.chomp.split(" ")
if(order=="insert") then
dic[word] = true
end
if(order=="find")
if (dic[word] == true) then
puts "yes"
else
puts "no"
end
end
end | n = gets.to_i
dic = {}
(0..n-1).each do |i|
order, word = gets.chomp.split(" ")
if(order=="insert") then
dic[word] = true
end
if(order=="find")
if (dic[word] == true) then
puts "yes"
else
puts "no"
end
end
end | [] | 114,246 | 114,247 | u677710583 | ruby |
p02268 | gets
s = gets.split.map(&:to_i)
gets
t = gets.split.map(&:to_i)
puts (s && t).size | gets
s = gets.split.map(&:to_i)
gets
t = gets.split.map(&:to_i)
puts (s & t).size | [
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 114,286 | 114,287 | u281180011 | ruby |
p02268 | #MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new
if(defined? MODE)
line = STDIN.read.split("\n")
else
tmp = '500
0 933 743 262 529 700 508 752 256 256 119 711 351 843 705 108 393 330 366 169 932 917 847 972 868 980 223 549 592 164 169 551 427 190 624 635 920 944 310 862 484 363 301 710 236 876 43... | MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new
if(defined? MODE)
line = STDIN.read.split("\n")
else
tmp = '500
0 933 743 262 529 700 508 752 256 256 119 711 351 843 705 108 393 330 366 169 932 917 847 972 868 980 223 549 592 164 169 551 427 190 624 635 920 944 310 862 484 363 301 710 236 876 431... | [
"assignment.add"
] | 114,288 | 114,289 | u876514616 | ruby |
p02268 |
gets
array_1 = gets.chomp.split(" ").map(&:to_i).sort
gets
array_2 = gets.chomp.split(" ").map(&:to_i).sort
def binary_search(val, array)
left = 0
right = array.length
while left < right do
mid = (left+right) / 2
if array[mid] == val
return true
elsif val < array[mid]
right = mid
el... |
gets
array_1 = gets.chomp.split(" ").map(&:to_i).sort.uniq
gets
array_2 = gets.chomp.split(" ").map(&:to_i).sort.uniq
def binary_search(val, array)
left = 0
right = array.length
while left < right do
mid = (left+right) / 2
if array[mid] == val
return true
elsif val < array[mid]
right = ... | [
"call.add"
] | 114,290 | 114,291 | u049151861 | ruby |
p02270 |
def check c, n, k, list
i = 0
0.upto k-1 do
s = 0
while s + list[i] <= c
s += list[i]
i += 1
return n if i == n
end
end
return i
end
def solve n, k, list
left = 0
right = 100000 * 100000
while right - left > 1
mid = (left + right)/2
v = check mid n, k ,list
if v >= n
right = mid
else
... |
def check c, n, k, list
i = 0
0.upto k-1 do
s = 0
while s + list[i] <= c
s += list[i]
i += 1
return n if i == n
end
end
return i
end
def solve n, k, list
left = 0
right = 100000 * 100000
while right - left > 1
mid = (left + right)/2
v = check mid, n, k, list
if v >= n
right = mid
else... | [
"call.arguments.change",
"assignment.value.change",
"identifier.change",
"identifier.replace.add",
"literal.replace.remove"
] | 114,961 | 114,962 | u742926680 | ruby |
p02270 | def available?(ary, p, k)
sum = 0
tracks = 1
ary.each{ |w|
if sum + w <= p
sum += w
else
sum = w
tracks += 1
end
}
tracks <= k
end
def binary(ary, l, r, k)
if l == r
return l
else
c = ((r - l)/2).to_i + 1 + l
if available?(ary, c, k)
binary(ary, l, c-1, k)
... | def available?(ary, p, k)
sum = 0
tracks = 1
ary.each{ |w|
if sum + w <= p
sum += w
else
sum = w
tracks += 1
end
}
tracks <= k
end
def binary(ary, l, r, k)
if l == r
return l
else
c = ((r - l)/2).to_i + 1 + l
if available?(ary, c, k)
binary(ary, l, c-1, k)
... | [
"expression.operation.binary.remove"
] | 114,964 | 114,965 | u635053632 | ruby |
p02271 | can = [0]
gets
a = gets.split.map(&:to_i)
n = gets.to_i
m = gets.split.map(&:to_i)
a.each_with_index {|e,i|
if i == 0
can << e
else
can = Marshal.load(Marshal.dump(can + can.map {|ele| ele + e}))
end
can.uniq!
}
n.times{|i|
if can.include?can[i]
puts 'yes'
else
puts 'no'
end
} | can = [0]
gets
a = gets.split.map(&:to_i)
n = gets.to_i
m = gets.split.map(&:to_i)
a.each_with_index {|e,i|
if i == 0
can << e
else
can = Marshal.load(Marshal.dump(can + can.map {|ele| ele + e}))
end
can.uniq!
}
n.times{|i|
if can.include?m[i]
puts 'yes'
else
puts 'no'
end
} | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 116,487 | 116,488 | u556326323 | ruby |
p02271 | # sum??????????????????
module Main
extend self
@@memo = {}
def can_assemble?(elements, index, sum, raw_elements_length)
unless @@memo[index].nil?
return @@memo[index][sum] unless @@memo[index][sum].nil?
else
@@memo[index] = []
end
if sum == 0
true
elsif index >= raw_elemen... | module Main
extend self
@@memo = {}
def can_assemble?(elements, index, sum, raw_elements_length)
unless @@memo[index].nil?
return @@memo[index][sum] unless @@memo[index][sum].nil?
else
@@memo[index] = {}
end
if sum == 0
true
elsif index >= raw_elements_length
false
... | [] | 116,489 | 116,490 | u761061259 | ruby |
p02271 | module Main
extend self
@@memo = {}
def can_assemble?(elements, index, sum, raw_elements_length)
unless @@memo[index].nil?
return @@memo[index][sum] unless @@memo[index][sum].nil?
else
@@memo[index] = []
end
if sum == 0
true
elsif index >= raw_elements_length
false
... | module Main
extend self
@@memo = {}
def can_assemble?(elements, index, sum, raw_elements_length)
unless @@memo[index].nil?
return @@memo[index][sum] unless @@memo[index][sum].nil?
else
@@memo[index] = {}
end
if sum == 0
true
elsif index >= raw_elements_length
false
... | [] | 116,491 | 116,490 | u761061259 | ruby |
p02271 | gets.to_i
a = gets.split.map(&:to_i)
gets.to_i
m = gets.split.map(&:to_i)
arr = [0]
a.each{|i|
arr += arr.clone.map{|j| j+i}
p arr
}
m.each{|num|
if arr.index(num) == nil then
puts "no"
else
puts "yes"
end
} | gets.to_i
a = gets.split.map(&:to_i)
gets.to_i
m = gets.split.map(&:to_i)
arr = [0]
a.each{|i|
arr += arr.clone.map{|j| j+i}
# p arr
}
m.each{|num|
if arr.index(num) == nil then
puts "no"
else
puts "yes"
end
} | [
"call.remove"
] | 116,496 | 116,497 | u960312159 | ruby |
p02271 | gets.to_i
a = gets.split.map(&:to_i)
gets.to_i
m = gets.split.map(&:to_i)
arr = [0]
a.each{|i|
arr += arr.clone.map{|j| j+i}
p arr
}
m.each{|num|
if arr.index(num) == nil then
puts "no"
else
puts "yes"
end
} | gets.to_i
a = gets.split.map(&:to_i)
gets.to_i
m = gets.split.map(&:to_i)
arr = [0]
a.each{|i|
arr += arr.clone.map{|j| j+i}
arr.uniq!
}
m.each{|num|
if arr.index(num) == nil then
puts "no"
else
puts "yes"
end
} | [
"io.output.change",
"call.remove",
"call.add"
] | 116,496 | 116,498 | u960312159 | ruby |
p02274 | def merge(a, left, mid, right)
n1 = mid - left
n2 = right - mid
_L = a[left..mid-1]
_R = a[mid..right-1]
_L[n1] = _R[n2] = 1.0 / 0.0
i = j = 0
cnt = 0
left.upto(right-1){|k|
if _L[i] <= _R[j] then
a[k] = _L[i]
i += 1
else
a[k] = _R[j]
j += 1
cnt += 1
end
}
r... | def merge(a, left, mid, right)
n1 = mid - left
n2 = right - mid
_L = a[left..mid-1]
_R = a[mid..right-1]
_L[n1] = _R[n2] = 1.0 / 0.0
i = j = 0
cnt = 0
left.upto(right-1){|k|
if _L[i] <= _R[j] then
a[k] = _L[i]
i += 1
else
a[k] = _R[j]
j += 1
cnt += n1 - i
end
... | [
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.remove"
] | 118,827 | 118,828 | u960312159 | ruby |
p02273 | def third_points(points)
point_one = {x: (points[1][:x] + 2.0 * points[0][:x]) / 3.0, y: (points[1][:y] + 2.0 * points[0][:y]) / 3.0}
point_two = {x: (points[0][:x] + 2.0 * points[1][:x]) / 3.0, y: (points[0][:y] + 2.0 * points[1][:y]) / 3.0}
[point_one, point_two]
end
def triangle(points)
x = points[0][:x] + ... | def third_points(points)
point_one = {x: (points[1][:x] + 2.0 * points[0][:x]) / 3.0, y: (points[1][:y] + 2.0 * points[0][:y]) / 3.0}
point_two = {x: (points[0][:x] + 2.0 * points[1][:x]) / 3.0, y: (points[0][:y] + 2.0 * points[1][:y]) / 3.0}
[point_one, point_two]
end
def triangle(points)
x = points[0][:x] + ... | [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 118,985 | 118,986 | u285272839 | ruby |
p02273 | n = gets.to_i
rot = ->(v, θ) {
t = θ / 180.0 * PI
Matrix[[cos(t), -sin(t)], [sin(t), cos(t)]] * v
}
result = []
koch_curve = ->(p1, p2, level) {
if level == n
result << p1
result << p2
else
l1 = (p2 - p1) / 3
l2 = rot.(l1, 60)
koch_curve.(p1, p3 = p1 + l1, level + 1)
koch_curve.(p3, p4 ... | require 'matrix'
include Math
n = gets.to_i
rot = ->(v, θ) {
t = θ / 180.0 * PI
Matrix[[cos(t), -sin(t)], [sin(t), cos(t)]] * v
}
result = []
koch_curve = ->(p1, p2, level) {
if level == n
result << p1
result << p2
else
l1 = (p2 - p1) / 3
l2 = rot.(l1, 60)
koch_curve.(p1, p3 = p1 + l1, lev... | [
"call.add"
] | 118,987 | 118,988 | u864617427 | ruby |
p02273 | n = gets.to_i
rot = ->(v, θ) {
t = θ / 180.0 * PI
Matrix[[cos(t), -sin(t)], [sin(t), cos(t)]] * v
}
result = []
koch_curve = ->(p1, p2, level) {
if level == n
result << p1
result << p2
else
l1 = (p2 - p1) / 3
l2 = rot.(l1, 60)
koch_curve.(p1, p3 = p1 + l1, level + 1)
koch_curve.(p3, p4 ... | require 'matrix'
include Math
n = gets.to_i
rot = ->(v, θ) {
t = θ / 180.0 * PI
Matrix[[cos(t), -sin(t)], [sin(t), cos(t)]] * v
}
result = []
koch_curve = ->(p1, p2, level) {
if level == n
result << p1
result << p2
else
l1 = (p2 - p1) / 3
l2 = rot.(l1, 60)
koch_curve.(p1, p3 = p1 + l1, lev... | [
"call.add"
] | 118,990 | 118,988 | u864617427 | ruby |
p02273 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
#整数nを入力し、深さnの再帰呼び出しによって作成されるコッホ曲線の頂点の座標を出力するプログラムを作成してください
# 入力 一つの整数nが与えられます
# 1など
# 出力 コッホ曲線の各頂点の座標(x,y)を出力してください
# 一行に一点の座標を出力してください
# 端点の一つ
def koch(n,a,b)
if n == 0
return
end
s = [(2*a[0]+1*b[0])/3.to_f,(2*a[1]+1*b[1])/3.to_f... | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
#整数nを入力し、深さnの再帰呼び出しによって作成されるコッホ曲線の頂点の座標を出力するプログラムを作成してください
# 入力 一つの整数nが与えられます
# 1など
# 出力 コッホ曲線の各頂点の座標(x,y)を出力してください
# 一行に一点の座標を出力してください
# 端点の一つ
def koch(n,a,b)
if n == 0
return
end
s = [(2*a[0]+1*b[0])/3.to_f,(2*a[1]+1*b[1])/3.to_f... | [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 118,991 | 118,992 | u483082413 | ruby |
p02273 | include Math
class Point
def initialize(x, y)
@x = x.to_f
@y = y.to_f
end
def distance(p)
dx = @x - p.x
dy = @y - p.y
sqrt(dx * dx + dy * dy).to_f
end
def getX()
@x
end
def getY()
@y
end
def internally_dividing_point(p,m,n)
Point.new(((n*@x+m*p.x)/(m+n)).to_f,((n*@y+m*p... | include Math
class Point
def initialize(x, y)
@x = x.to_f
@y = y.to_f
end
def distance(p)
dx = @x - p.x
dy = @y - p.y
sqrt(dx * dx + dy * dy).to_f
end
def getX()
@x
end
def getY()
@y
end
def internally_dividing_point(p,m,n)
Point.new(((n*@x+m*p.x)/(m+n)).to_f,((n*@y+m*p... | [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 118,993 | 118,994 | u588130269 | ruby |
p02275 | gets
gets.split.map(&:to_i).sort*" " | gets
puts gets.split.map(&:to_i).sort*" " | [
"io.output.change",
"call.add"
] | 120,614 | 120,615 | u890794282 | ruby |
p02275 | def counting_sort(a, k)
n = a.length
b = Array.new(n)
c = Array.new(k+1,0)
n.times do |i|
c[a[i]]+=1
end
1.upto(k) do |i|
c[i]+=c[i-1]
end
(n-1).downto(1) do |i|
b[c[a[i]]]=a[i]
c[a[i]]-=1
end
return b.compact
end
n = STDIN.gets
a = STDIN.gets.split(' ').map{ |i| i.to_i }
print ... |
def counting_sort(a, k)
n = a.length
b = Array.new(n)
c = Array.new(k+1,0)
n.times do |i|
c[a[i]]+=1
end
1.upto(k) do |i|
c[i]+=c[i-1]
end
(n-1).downto(0) do |i|
b[c[a[i]]]=a[i]
c[a[i]]-=1
end
return b.compact
end
n = STDIN.gets
a = STDIN.gets.split(' ').map{ |i| i.to_i }
print... | [
"literal.number.integer.change",
"call.arguments.change"
] | 120,618 | 120,619 | u054278963 | ruby |
p02275 | def sort(array)
a = array
b = []
c = []
k = a.max
##all elements of array c equal to 0
for i in 0..k
c[i] = 0
end
##insert +1 to c[element of array a]
a.each do |el|
c[el] = c[el] + 1
end
#array c now contains the number of elements of array a
##add the number of previous element starting from c[1]
... | def sort(array)
a = array
b = []
c = []
k = a.max
##all elements of array c equal to 0
for i in 0..k
c[i] = 0
end
##insert +1 to c[element of array a]
a.each do |el|
c[el] = c[el] + 1
end
#array c now contains the number of elements of array a
##add the number of previous element starting from c[1]
... | [
"function.return_value.change",
"io.output.change",
"call.remove"
] | 120,622 | 120,623 | u959436166 | ruby |
p02275 | def counting_sort(array)
count = Array.new(array.length, 0)
count_sum = Array.new(array.length, 0)
sorted = Array.new(array.length, 0)
array.each do |value|
count[value] += 1
end
count.each_with_index do |value, index|
if index.zero?
count_sum[index] = value
end
count_sum[index] = cou... | def counting_sort(array)
count = Array.new(10000, 0)
count_sum = Array.new(10000, 0)
sorted = Array.new(array.length, 0)
array.each do |value|
count[value] += 1
end
count.each_with_index do |value, index|
if index.zero?
count_sum[index] = value
end
count_sum[index] = count_sum[index -... | [
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add",
"call.arguments.change",
"call.remove"
] | 120,636 | 120,637 | u731989230 | ruby |
p02276 | def partition(arr, p, r)
x = arr[r]
i = p - 1
for j in p...r
if arr[j] <= x
i += 1
arr[i], arr[j] = arr[j], arr[i]
end
end
arr[i + 1], arr[r] = arr[r], arr[i + 1]
return i + 1
end
n = gets.to_i
arr = gets.split.map(&:to_i)
index = partition(arr, 0, n - 1)
for i in 0...index
print arr[... | def partition(arr, p, r)
x = arr[r]
i = p - 1
for j in p...r
if arr[j] <= x
i += 1
arr[i], arr[j] = arr[j], arr[i]
end
end
arr[i + 1], arr[r] = arr[r], arr[i + 1]
return i + 1
end
n = gets.to_i
arr = gets.split.map(&:to_i)
index = partition(arr, 0, n - 1)
for i in 0...index
print arr[... | [
"call.add"
] | 121,288 | 121,289 | u966015027 | ruby |
p02276 | def partition(a, p, r)
x = a[r]
i = p - 1
for j in p..r
if a[j] <= x
i += 1
a[j],a[i] = a[i],a[j]
end
a[r],a[i+1] = a[i+1],a[r]
end
return i + 1
end
n = gets.to_i
a = gets.split(" ").map(&:to_i)
i = partition(a,0,n-1)
puts a[0,i-1].join(" ") + " [" + a[i].to_s + "] " + a[i+1,n-i-1].join(" ") | def partition(a, p, r)
x = a[r]
i = p - 1
for j in p..r-1
if a[j] <= x
i += 1
a[j],a[i] = a[i],a[j]
end
end
a[r],a[i+1] = a[i+1],a[r]
return i+1
end
n = gets.to_i
a = gets.split(" ").map(&:to_i)
i = partition(a,0,n-1)
puts a[0,i].join(" ") + " [" + a[i].to_s + "] " + a[i+1,n-i-1].join(" ") | [
"expression.operation.binary.remove"
] | 121,294 | 121,295 | u843848664 | ruby |
p02276 | def partition(a)
x = a.last
r = a.size
i = 0
i.upto(r - 1) do |j|
if a[j] <= x
a[i], a[j] = a[j], a[i]
i += 1
end
p a
end
a[0..i-2].join(' ') + " [#{a[i-1]}] " + a[i..-1].join(' ')
end
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
puts partition(a) | def partition(a)
x = a.last
r = a.size
i = 0
i.upto(r - 1) do |j|
if a[j] <= x
a[i], a[j] = a[j], a[i]
i += 1
end
end
a[0..i-2].join(' ') + " [#{a[i-1]}] " + a[i..-1].join(' ')
end
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
puts partition(a) | [
"call.remove"
] | 121,296 | 121,297 | u881491942 | ruby |
p02278 | n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
t = []
n.times do |i|
t << arr.shift
end
# swap????????????
def swap(list, idx1, idx2)
list[idx1], list[idx2] = list[idx2], list[idx1]
return list
end
def minCostPath(list)
sorted = list.sort
total = 0
# list?????????
list.size.times do |i|
#... | n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
t = []
n.times do |i|
t << arr.shift
end
# swap????????????
def swap(list, idx1, idx2)
list[idx1], list[idx2] = list[idx2], list[idx1]
return list
end
def minCostPath(list)
sorted = list.sort
total = 0
# list?????????
list.size.times do |i|
#... | [
"identifier.change",
"variable_access.subscript.index.change"
] | 121,607 | 121,608 | u888846141 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.