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 |
|---|---|---|---|---|---|---|---|
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"
] | 121,609 | 121,608 | u888846141 | ruby |
p02279 | n = gets.to_i
# クラスってかこの程度なら構造体で充分なんだがな!!!!!!!!!!!!!!!!!!!!!!!!!!!
class Tree
attr_accessor :id, :parent, :depth, :tree_type, :childs
def initialize
@childs = []
@parent = -1
@depth = 0
end
end
trees = {}
# 数がわかっているので初期化
n.times do |i|
tree = Tree.new()
tree.id = i
trees[i] = tree
end
# 単にdept... | n = gets.to_i
# クラスってかこの程度なら構造体で充分なんだがな!!!!!!!!!!!!!!!!!!!!!!!!!!!
class Tree
attr_accessor :id, :parent, :depth, :tree_type, :childs
def initialize
@childs = []
@parent = -1
@depth = 0
end
end
trees = {}
# 数がわかっているので初期化
n.times do |i|
tree = Tree.new()
tree.id = i
trees[i] = tree
end
# 単にdept... | [
"expression.operation.unary.add",
"control_flow.branch.if.condition.change"
] | 122,459 | 122,460 | u677096240 | ruby |
p02279 | # ALDS1_7_A: Rooted Trees
class Node
attr_accessor :id, :parent, :left_child, :r_sib
def initialize()
@id = -1
end
def depth
@parent.nil? ? 0 : 1 + @parent.depth
end
def parent_id
@parent.nil? ? -1 : @parent.id
end
def child_ids
child_ids = []
child = @left_child
until c... | # ALDS1_7_A: Rooted Trees
class Node
attr_accessor :id, :parent, :left_child, :r_sib
def initialize()
@id = -1
end
def depth
@parent.nil? ? 0 : 1 + @parent.depth
end
def parent_id
@parent.nil? ? -1 : @parent.id
end
def child_ids
child_ids = []
child = @left_child
until c... | [
"assignment.value.change",
"identifier.change"
] | 122,461 | 122,462 | u559743044 | ruby |
p02279 | lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
Node = Struct.new(:parent, :left, :right)
nodes = Array.new(N) { Node.new }
def get_depth(id, nodes)
d = 0
while ! nodes[id].parent.nil? do
id = nodes[id].parent
d += 1
end
d
end
def get_children(id, nodes)
children = []
c = nodes[i... | lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
Node = Struct.new(:parent, :left, :right)
nodes = Array.new(N) { Node.new }
def get_depth(id, nodes)
d = 0
while ! nodes[id].parent.nil? do
id = nodes[id].parent
d += 1
end
d
end
def get_children(id, nodes)
children = []
c = nodes[i... | [
"expression.operation.binary.remove"
] | 122,467 | 122,468 | u397596432 | ruby |
p02279 | lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
Node = Struct.new(:parent, :left, :right)
nodes = Array.new(N) { Node.new }
def get_depth(id, nodes)
d = 0
while ! nodes[id].parent.nil? do
id = nodes[id].parent
d += 1
end
d
end
def get_children(id, nodes)
children = []
c = nodes[i... | lines = $stdin.read
array = lines.split("\n")
N = array[0].to_i
Node = Struct.new(:parent, :left, :right)
nodes = Array.new(N) { Node.new }
def get_depth(id, nodes)
d = 0
while ! nodes[id].parent.nil? do
id = nodes[id].parent
d += 1
end
d
end
def get_children(id, nodes)
children = []
c = nodes[i... | [
"call.remove"
] | 122,469 | 122,468 | u397596432 | ruby |
p02280 | q=Array.new n=gets.to_i,M=-1
s=*q
g=$<.map{|l|i,*c=l.split.map &:to_i
c.reject!{|v|v<0}
c.map{|j|q[j]=i}
c[1]&&(a,b=c
s[a],s[b]=b,a)
[i,c]}.sort
d=->f,i,x{g[i][2]=x
g[i][3]=(g[i][1].map{|j|f[f,j,x+1]}.max||M)+1}
d[d,q.index(M),0]
g.map{|v|i,c,d,h=v
[i,p=q[i],s[i],c.size,d,h,p<0?:root:c[0]?"internal node": :leaf]}.map{|... | q=Array.new n=gets.to_i,M=-1
s=*q
g=$<.map{|l|i,*c=l.split.map &:to_i
!i&&next
c.reject!{|v|v<0}
c.map{|j|q[j]=i}
c[1]&&(a,b=c
s[a],s[b]=b,a)
[i,c]}.compact.sort
d=->f,i,x{g[i][2]=x
g[i][3]=(g[i][1].map{|j|f[f,j,x+1]}.max||M)+1}
d[d,q.index(M),0]
g.map{|v|i,c,d,h=v
[i,p=q[i],s[i],c.size,d,h,p<0?:root:c[0]?"internal nod... | [
"call.add"
] | 122,806 | 122,807 | u890794282 | ruby |
p02280 | #binary_tree
class Node
attr_accessor :myname,:parent,:left,:right,:depth,:height
def initialize(n)
@myname = n
@parent = nil
@left = nil
@right = nil
@depth = 0
end
def add_left(child)
self.left = child
child.parent = self
end
def add_right(child)
self.right ... | #binary_tree
class Node
attr_accessor :myname,:parent,:left,:right,:depth,:height
def initialize(n)
@myname = n
@parent = nil
@left = nil
@right = nil
@depth = 0
end
def add_left(child)
self.left = child
child.parent = self
end
def add_right(child)
self.right ... | [
"identifier.change",
"control_flow.branch.if.condition.change",
"expression.operation.unary.remove",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 122,812 | 122,813 | u708993917 | ruby |
p02280 | #binary_tree
class Node
attr_accessor :myname,:parent,:left,:right,:depth,:height
def initialize(n)
@myname = n
@parent = nil
@left = nil
@right = nil
@depth = 0
end
def add_left(child)
self.left = child
child.parent = self
end
def add_right(child)
self.right ... | #binary_tree
class Node
attr_accessor :myname,:parent,:left,:right,:depth,:height
def initialize(n)
@myname = n
@parent = nil
@left = nil
@right = nil
@depth = 0
end
def add_left(child)
self.left = child
child.parent = self
end
def add_right(child)
self.right ... | [
"identifier.change",
"control_flow.branch.if.condition.change",
"expression.operation.unary.remove",
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove"
] | 122,814 | 122,813 | u708993917 | ruby |
p02280 | #binary_tree
class Node
attr_accessor :myname,:parent,:left,:right,:depth,:height
def initialize(n)
@myname = n
@parent = nil
@left = nil
@right = nil
@depth = 0
end
def add_left(child)
self.left = child
child.parent = self
end
def add_right(child)
self.right ... | #binary_tree
class Node
attr_accessor :myname,:parent,:left,:right,:depth,:height
def initialize(n)
@myname = n
@parent = nil
@left = nil
@right = nil
@depth = 0
end
def add_left(child)
self.left = child
child.parent = self
end
def add_right(child)
self.right ... | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 122,815 | 122,813 | u708993917 | ruby |
p02280 | $arr=Array.new()
class BinaryTree
attr_accessor :id,:parent,:sibling,:degree,:depth,:height,:type,:children
def initialize(id,children,degree)
@id=id
@parent=-1
@sibling=-1
@degree=degree
@height=0
@children=children
@type=(children==[-1,-1] ? 'leaf' :'internal node')
end
def print
... | $arr=Array.new()
class BinaryTree
attr_accessor :id,:parent,:sibling,:degree,:depth,:height,:type,:children
def initialize(id,children,degree)
@id=id
@parent=-1
@sibling=-1
@degree=degree
@height=0
@children=children
@type=(children==[-1,-1] ? 'leaf' :'internal node')
end
def print
... | [
"literal.string.change",
"call.arguments.change",
"identifier.change",
"expression.operation.binary.change"
] | 122,816 | 122,817 | u083853290 | ruby |
p02280 | $arr=Array.new()
class BinaryTree
attr_accessor :id,:parent,:sibling,:degree,:depth,:height,:type,:children
def initialize(id,children,degree)
@id=id
@parent=-1
@sibling=-1
@degree=degree
@height=0
@children=children
@type=(children==[-1,-1] ? 'leaf' :'internal node')
end
def print
... | $arr=Array.new()
class BinaryTree
attr_accessor :id,:parent,:sibling,:degree,:depth,:height,:type,:children
def initialize(id,children,degree)
@id=id
@parent=-1
@sibling=-1
@degree=degree
@height=0
@children=children
@type=(children==[-1,-1] ? 'leaf' :'internal node')
end
def print
... | [
"literal.string.change",
"call.arguments.change"
] | 122,818 | 122,817 | u083853290 | ruby |
p02277 | def part(a, q, r)
x = a[r][1]
i = q - 1
for j in 0...r - q
if a[q + j][1] <= x
i += 1
a[i], a[q + j] = a[q + j], a[i]
end
end
a[i + 1], a[r] = a[r], a[i + 1]
return i + 1
end
def qsort(a, q = nil, r = nil)
q, r = 0, a.length - 1 if !q
if q < r
x = part(a, q, r)
qsort(a, q, x ... | def part(a, q, r)
x = a[r][1]
i = q - 1
for j in 0...r - q
if a[q + j][1] <= x
i += 1
a[i], a[q + j] = a[q + j], a[i]
end
end
a[i + 1], a[r] = a[r], a[i + 1]
return i + 1
end
def qsort(a, q = nil, r = nil)
q, r = 0, a.length - 1 if !q
if q < r
x = part(a, q, r)
qsort(a, q, x ... | [
"call.suffix.change"
] | 122,837 | 122,838 | u514597327 | ruby |
p02277 | def q a,l,r
l<r&&(
i=0
(a.size-1).times{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b | def q a,l,r
l<r&&(
i=l
(l..r-1).map{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b | [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.change",
"identifier.change"
] | 122,839 | 122,840 | u198069342 | ruby |
p02277 | def q a,l,r
l<r&&(
i=0
(l..r-1).map{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b | def q a,l,r
l<r&&(
i=l
(l..r-1).map{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b | [
"assignment.value.change",
"identifier.replace.add",
"literal.replace.remove",
"expression.operation.binary.change"
] | 122,841 | 122,840 | u198069342 | ruby |
p02277 | def q a,l,r
p [l,r]
l<r&&(
i=l
(l..r-1).map{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b | def q a,l,r
l<r&&(
i=l
(l..r-1).map{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b | [
"call.remove"
] | 122,842 | 122,840 | u198069342 | ruby |
p02277 | def partition(a, p, r)
unused, x = a[r].split(' ')
i = p - 1
p.upto(r-1) do |j|
unused, aj = a[j].split(' ')
if aj.to_i <= x.to_i
i = i + 1
a[i], a[j] = a[j], a[i]
end
end
a[i+1], a[r] = a[r], a[i+1]
return i + 1
end
def quickSort(a, p, r)
if p < r
q = partition(a, p, r)
q... | def partition(a, p, r)
unused, x = a[r].split(' ')
i = p - 1
p.upto(r-1) do |j|
unused, aj = a[j].split(' ')
if aj.to_i <= x.to_i
i = i + 1
a[i], a[j] = a[j], a[i]
end
end
a[i+1], a[r] = a[r], a[i+1]
return i + 1
end
def quickSort(a, p, r)
if p < r
q = partition(a, p, r)
q... | [
"expression.operation.binary.remove"
] | 122,845 | 122,846 | u878851603 | ruby |
p02277 | def partition(a, p ,r)
x = a[r][1]
i = p-1
(p...r).each do |j|
if a[j][1] <= x
i += 1
a[i], a[j] = a[j], a[i]
end
end
a[i+1], a[r] = a[r], a[i+1]
return i+1
end
def quick_sort(a, p, r)
if p < r
q = partition(a, p, r)
quick_sort(a, p, q-1)
quick_sort(a, q+1, r)
end
end
n... | def partition(a, p ,r)
x = a[r][1]
i = p-1
(p...r).each do |j|
if a[j][1] <= x
i += 1
a[i], a[j] = a[j], a[i]
end
end
a[i+1], a[r] = a[r], a[i+1]
return i+1
end
def quick_sort(a, p, r)
if p < r
q = partition(a, p, r)
quick_sort(a, p, q-1)
quick_sort(a, q+1, r)
end
end
n... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 122,847 | 122,848 | u920530014 | ruby |
p02277 |
def solve(n, cards)
a = []
b = []
p cards
for j in 0..(n-1)
m = cards[j][0]
i = cards[j][1].to_i
a.push([m, i])
b.push([m, i])
end
qsort(a, 0, n-1)
stable = true
(0..n-2).each do |i|
if (a[i][1] == a[i+1][1])
if b.index(a[i]) > b.index(a[i+1])
... |
def solve(n, cards)
a = []
b = []
for j in 0..(n-1)
m = cards[j][0]
i = cards[j][1].to_i
a.push([m, i])
b.push([m, i])
end
qsort(a, 0, n-1)
stable = true
(0..n-2).each do |i|
if (a[i][1] == a[i+1][1])
if b.index(a[i]) > b.index(a[i+1])
sta... | [
"call.remove"
] | 122,851 | 122,852 | u723368439 | ruby |
p02277 | class Card
def initialize(mark, number)
@mark = mark
@number = number.to_i
end
def to_s
"#{mark} #{number}"
end
attr_accessor :number, :mark
end
def partition(array, p, r)
x = array[r].number
i = p - 1
p.upto(r - 1) do |index|
if array[index].number <= x
i += 1
array[i], a... | class Card
def initialize(mark, number)
@mark = mark
@number = number.to_i
end
def to_s
"#{mark} #{number}"
end
attr_accessor :number, :mark
end
def partition(array, p, r)
x = array[r].number
i = p - 1
p.upto(r - 1) do |index|
if array[index].number <= x
i += 1
array[i], a... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 122,853 | 122,854 | u731989230 | ruby |
p02281 | class Node
attr_accessor :parent, :left, :right
def initialize(p, l, r)
@parent = p
@left = l
@right = r
end
end
def make_tree n
tree = {}
[*0...n].each do |i|
tree[i] = Node.new(-1, nil ,nil)
end
n.times do
k, l, r = gets.chomp.split.map(&:to_i)
... | class Node
attr_accessor :parent, :left, :right
def initialize(p, l, r)
@parent = p
@left = l
@right = r
end
end
def make_tree n
tree = {}
[*0...n].each do |i|
tree[i] = Node.new(-1, nil ,nil)
end
n.times do
k, l, r = gets.chomp.split.map(&:to_i)
... | [
"call.remove"
] | 123,293 | 123,294 | u573990433 | ruby |
p02284 | class Tree
attr_accessor :id,:parent,:children
def initialize(id)
@id=id
@parent=-1
@children=[nil,nil]
end
def preorder
print " #{id}"
children[0].preorder if children[0]
children[1].preorder if children[1]
end
def inorder
children[0].inorder if children[0]
print " #{id}"
... | class Tree
attr_accessor :id,:parent,:children
def initialize(id)
@id=id
@parent=-1
@children=[nil,nil]
end
def preorder
print " #{id}"
children[0].preorder if children[0]
children[1].preorder if children[1]
end
def inorder
children[0].inorder if children[0]
print " #{id}"
... | [
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 124,476 | 124,477 | u083853290 | ruby |
p02285 |
CMD=0
VAL=1
class Node
attr_accessor :value,:left,:right,:parent
def initialize (value,parent)
@value = value
@parent = parent
@left = nil
@right = nil
end
def insert (value)
if value < @value
if @left.nil?
@left = Node.new(value,self)
else
@left.insert(value)
... | CMD=0
VAL=1
class Node
attr_accessor :value,:left,:right,:parent
def initialize (value,parent)
@value = value
@parent = parent
@left = nil
@right = nil
end
def insert (value)
if value < @value
if @left.nil?
@left = Node.new(value,self)
else
@left.insert(value)
... | [
"call.add"
] | 124,863 | 124,864 | u054278963 | ruby |
p02287 | class Node
def initialize(i, key)
@index = i
@key = key
@parent_key = nil
@left_key = nil
@right_key = nil
end
def to_s
str = "node #{index}: key = #{key}, "
str += "parent_key = #{@parent_key.key}, " unless @parent_key.nil?
str += "left_key = #{@left_key.key}, " unless @left_key.... | class Node
def initialize(i, key)
@index = i
@key = key
@parent_key = nil
@left_key = nil
@right_key = nil
end
def to_s
str = "node #{index}: key = #{key}, "
str += "parent key = #{@parent_key.key}, " unless @parent_key.nil?
str += "left key = #{@left_key.key}, " unless @left_key.... | [
"literal.string.change"
] | 125,414 | 125,415 | u731989230 | ruby |
p02287 | class Node
attr_accessor :id, :key, :parent, :left, :right
def initialize(id, key)
@id = id
@key = key
@parent = nil
@left = nil
@right = nil
end
def to_s
parent_s =
if @parent != nil
"parent key = #{@parent.key}, "
else
""
end
left_s =
if @... | class Node
attr_accessor :id, :key, :parent, :left, :right
def initialize(id, key)
@id = id
@key = key
@parent = nil
@left = nil
@right = nil
end
def to_s
parent_s =
if @parent != nil
"parent key = #{@parent.key}, "
else
""
end
left_s =
if @... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 125,418 | 125,419 | u382730661 | ruby |
p02287 | def parent(i)
return i/2
end
def left(i)
return i*2
end
def right(i)
return i*2+1
end
n=gets.to_i
arr=gets.split.map(&:to_i)
arr.unshift(nil)
(1..n).each do |i|
print "node #{i}, key = #{arr[i]}, "
if parent(i)>=1
print "parent key = #{arr[parent(i)]}, "
end
if left(i)<=n
print "left key = #{arr[l... | def parent(i)
return i/2
end
def left(i)
return i*2
end
def right(i)
return i*2+1
end
n=gets.to_i
arr=gets.split.map(&:to_i)
arr.unshift(nil)
(1..n).each do |i|
print "node #{i}: key = #{arr[i]}, "
if parent(i)>=1
print "parent key = #{arr[parent(i)]}, "
end
if left(i)<=n
print "left key = #{arr[l... | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 125,427 | 125,428 | u083853290 | ruby |
p02287 | n = gets.to_i
heep = gets.split.map(&:to_i)
heep.each_with_index{|val, j|
i = j + 1
str = "node #{j}: key = #{val}, "
str << "parent key = #{heep[i/2-1]}, " if j > 0
str << "left key = #{heep[2*i-1]}, " if 2 * i - 1 < n
str << "right key = #{heep[2*i]}, " if 2 * i < n
puts str
} | n = gets.to_i
heep = gets.split.map(&:to_i)
heep.each_with_index{|val, j|
i = j + 1
str = "node #{i}: key = #{val}, "
str << "parent key = #{heep[i/2-1]}, " if j > 0
str << "left key = #{heep[2*i-1]}, " if 2 * i - 1 < n
str << "right key = #{heep[2*i]}, " if 2 * i < n
puts str
} | [
"literal.string.change",
"assignment.value.change"
] | 125,435 | 125,436 | u960312159 | ruby |
p02283 |
CMD=0
VAL=1
class Node
attr_accessor :value,:left,:right
def initialize (value)
@value = value
@left = nil
@right = nil
end
def insert (value)
if value < @value
if @left.nil?
@left = Node.new(value)
else
@left.insert(value)
end
else
if @right.nil?
... |
CMD=0
VAL=1
class Node
attr_accessor :value,:left,:right
def initialize (value)
@value = value
@left = nil
@right = nil
end
def insert (value)
if value < @value
if @left.nil?
@left = Node.new(value)
else
@left.insert(value)
end
else
if @right.nil?
... | [
"literal.string.change",
"call.arguments.change",
"identifier.change"
] | 125,920 | 125,921 | u054278963 | ruby |
p02288 | class Node
include Comparable
def initialize(id, key)
@id = id
@key = key
end
def <=>(other)
@key <=> other.key
end
DUMMY = Node.new(-1, -1)
attr_accessor :id, :key
end
def maxHeapify(array, i)
left = (i*2 < array.size) ? array[i*2] : Node::DUMMY
right = (i*2+1 < array.size) ? array[i... | class Node
include Comparable
def initialize(id, key)
@id = id
@key = key
end
def <=>(other)
@key <=> other.key
end
DUMMY = Node.new(-1, -2_000_000_001)
attr_accessor :id, :key
end
def maxHeapify(array, i)
left = (i*2 < array.size) ? array[i*2] : Node::DUMMY
right = (i*2+1 < array.siz... | [
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change"
] | 126,371 | 126,372 | u148091382 | ruby |
p02288 | def maxHeapify(x)
l = 2*x
r = 2*x+1
if l <= $n && $heap[l] > $heap[x]
largest = l
else
largest = x
end
if r <= $n && $heap[r] > $heap[largest]
largest = r
end
if largest != x
$heap[x], $heap[largest] = $heap[largest], $heap[x]
maxHeapify(largest)
end
end
def buildMaxHeap
($n/2).d... | def maxHeapify(x)
l = 2*x
r = 2*x+1
if l <= $n && $heap[l] > $heap[x]
largest = l
else
largest = x
end
if r <= $n && $heap[r] > $heap[largest]
largest = r
end
if largest != x
$heap[x], $heap[largest] = $heap[largest], $heap[x]
maxHeapify(largest)
end
end
def buildMaxHeap
($n/2).d... | [
"identifier.change"
] | 126,376 | 126,377 | u811434779 | ruby |
p02290 | require 'matrix'
p1x, p1y, p2x, p2y = gets.split.map &:to_i
p1 = Vector[ p1x, p1y ]
p1p2 = Vector[ p2x - p1x, p2y - p1y ]
q = gets.to_i
q.times do
px, py = gets.split.map &:to_i
p1p = Vector[ px - p1x, py - p1y ]
p1t_norm = p1p.innter_product(p1p2) / p1p2.norm
t = p1 + p1p2 * ( p1t_norm / p1p2.norm )
puts "%.... | require 'matrix'
p1x, p1y, p2x, p2y = gets.split.map &:to_i
p1 = Vector[ p1x, p1y ]
p1p2 = Vector[ p2x - p1x, p2y - p1y ]
q = gets.to_i
q.times do
px, py = gets.split.map &:to_i
p1p = Vector[ px - p1x, py - p1y ]
p1t_norm = p1p.inner_product(p1p2) / p1p2.norm
t = p1 + p1p2 * ( p1t_norm / p1p2.norm )
puts "%.8... | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change",
"io.output.change"
] | 127,736 | 127,737 | u352522848 | ruby |
p02293 | require 'matrix'
q = gets.to_i
x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i
s1 = Vector[ x1 - x0, y1 - y0, 0 ]
s2 = Vector[ x3 - x2, y3 - y2, 0 ]
if s1.inner_product(s1) == 0
puts 1
elsif s1.cross_product(s2).norm == 0
puts 2
else
puts 0
end | require 'matrix'
q = gets.to_i
q.times do
x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i
s1 = Vector[ x1 - x0, y1 - y0, 0 ]
s2 = Vector[ x3 - x2, y3 - y2, 0 ]
if s1.inner_product(s2) == 0
puts 1
elsif s1.cross_product(s2).norm == 0
puts 2
else
puts 0
end
end | [
"call.add",
"identifier.change",
"control_flow.branch.if.condition.change"
] | 128,010 | 128,011 | u352522848 | ruby |
p02293 | require 'matrix'
q = gets.to_i
q.times do
x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i
s1 = Vector[ x1 - x0, y1 - y0, 0 ]
s2 = Vector[ x3 - x2, y3 - y2, 0 ]
if s1.inner_product(s1) == 0
puts 1
elsif s1.cross_product(s2).norm == 0
puts 2
else
puts 0
end
end | require 'matrix'
q = gets.to_i
q.times do
x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map &:to_i
s1 = Vector[ x1 - x0, y1 - y0, 0 ]
s2 = Vector[ x3 - x2, y3 - y2, 0 ]
if s1.inner_product(s2) == 0
puts 1
elsif s1.cross_product(s2).norm == 0
puts 2
else
puts 0
end
end | [
"identifier.change",
"control_flow.branch.if.condition.change"
] | 128,012 | 128,011 | u352522848 | ruby |
p02289 | #!/usr/bin/ruby
def heappush(heap, item)
heap.push(item)
_siftdown(heap, 0, heap.size-1)
end
def heappop(heap)
lastelt = heap.pop
if !heap.empty?
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else
returnitem = lastelt
end
returnitem
end
def heappushpop(heap, item)
if !heap.empty? && (heap[0]... | #!/usr/bin/ruby
def heappush(heap, item)
heap.push(item)
_siftdown(heap, 0, heap.size-1)
end
def heappop(heap)
lastelt = heap.pop
if !heap.empty?
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else
returnitem = lastelt
end
returnitem
end
def heappushpop(heap, item)
if !heap.empty? && (heap[0]... | [
"expression.operation.unary.add",
"call.arguments.change"
] | 128,061 | 128,062 | u300645821 | ruby |
p02289 | #!/usr/bin/ruby
def heappush(heap, item)
heap.push(item)
_siftdown(heap, 0, heap.size-1)
end
def heappop(heap)
lastelt = heap.pop
if !heap.empty?
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else
returnitem = lastelt
end
returnitem
end
def heappushpop(heap, item)
if !heap.empty? && (heap[0]... | #!/usr/bin/ruby
def heappush(heap, item)
heap.push(item)
_siftdown(heap, 0, heap.size-1)
end
def heappop(heap)
lastelt = heap.pop
if !heap.empty?
returnitem = heap[0]
heap[0] = lastelt
_siftup(heap, 0)
else
returnitem = lastelt
end
returnitem
end
def heappushpop(heap, item)
if !heap.empty? && (heap[0]... | [
"expression.operation.unary.add",
"call.arguments.change",
"expression.operation.unary.arithmetic.remove"
] | 128,063 | 128,062 | u300645821 | ruby |
p02294 | require 'matrix'
q = gets.to_i
def cross(p1, p2)
return p1[0] * p2[1] - p1[1] * p2[0]
end
q.times do
p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y = gets.split.map &:to_i
p0 = Vector[ p0x, p0y ]
p1 = Vector[ p1x, p1y ]
p2 = Vector[ p2x, p2y ]
p3 = Vector[ p3x, p3y ]
if cross(p1-p0, p2-p0) * cross(p1-p0, p3-p0... | require 'matrix'
q = gets.to_i
def cross(p1, p2)
return p1[0] * p2[1] - p1[1] * p2[0]
end
q.times do
p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y = gets.split.map &:to_i
p0 = Vector[ p0x, p0y ]
p1 = Vector[ p1x, p1y ]
p2 = Vector[ p2x, p2y ]
p3 = Vector[ p3x, p3y ]
if cross(p1-p0, p2-p0) * cross(p1-p0, p3-p0... | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 128,119 | 128,120 | u352522848 | ruby |
p02314 |
def solution(n, m, coins)
dp = [0] + [Float::INFINITY] * n
for coin in coins
for amount in 0..n
if amount >= coin
dp[amount] = [dp[amount], dp[amount - coin] + 1].min
else
dp[amount] = dp[amount]
end
end
p dp
end
dp[n]
end
first_line = gets.split.map(&:to_i)
coin... | def solution(n, m, coins)
dp = [0] + [Float::INFINITY] * n
for coin in coins
for amount in 0..n
if amount >= coin
dp[amount] = [dp[amount], dp[amount - coin] + 1].min
else
dp[amount] = dp[amount]
end
end
end
dp[n]
end
first_line = gets.split.map(&:to_i)
coins = gets.s... | [
"call.remove"
] | 128,767 | 128,768 | u854817684 | ruby |
p02315 | def solve_knapsack(w, v, q)
n = w.length
inf = 1e9.to_i
ans = [-inf] * (q + 1)
ans[0] = 0
(w.zip(v)).each do |wi, vi|
(0..(q-wi)).each do |kkk|
k = (q-wi) - kkk
ans[k+wi] = [ans[k+wi], ans[k] + vi].max
end
end
ans[q]
end
if __FILE__ == $0
n, q = gets().split().map(&:to_i)
v, w = [], []
n.tim... | def solve_knapsack(w, v, q)
n = w.length
inf = 1e9.to_i
ans = [-inf] * (q + 1)
ans[0] = 0
(w.zip(v)).each do |wi, vi|
(0..(q-wi)).each do |kkk|
k = (q-wi) - kkk
ans[k+wi] = [ans[k+wi], ans[k] + vi].max
end
end
ans.max
end
if __FILE__ == $0
n, q = gets().split().map(&:to_i)
v, w = [], []
n.t... | [] | 129,185 | 129,186 | u890256830 | ruby |
p02317 | n = gets.to_i
a = []
n.times{ a << gets.to_i }
dp = Array.new
dp << -1
n.times do |i|
if dp.last < a[i]
dp << a[i]
else
left = 0
right = dp.size
mid = 0
while left <= right
mid = (left + right)/2
if a[i] >= dp[mid]
left = mid + 1
else
right = mid - 1
end
... | n = gets.to_i
a = []
n.times{ a << gets.to_i }
dp = Array.new
dp << -1
n.times do |i|
if dp.last < a[i]
dp << a[i]
else
left = 0
right = dp.size - 1
mid = 0
while left <= right
mid = (left + right)/2
if a[i] >= dp[mid]
left = mid + 1
else
right = mid - 1
... | [
"assignment.change"
] | 130,558 | 130,559 | u811434779 | ruby |
p02317 | n = gets.to_i
a = []
n.times{ a << gets.to_i }
dp = Array.new
dp << -1
n.times do |i|
if dp.last < a[i]
dp << a[i]
else
left = 0
right = dp.size
mid = 0
while left <= right
mid = (left + right)/2
if a[i] >= dp[mid]
left = mid + 1
else
right = mid - 1
end
... | n = gets.to_i
a = []
n.times{ a << gets.to_i }
dp = Array.new
dp << -1
n.times do |i|
if dp.last < a[i]
dp << a[i]
else
left = 0
right = dp.size - 1
mid = 0
while left <= right
mid = (left + right)/2
if a[i] >= dp[mid]
left = mid + 1
else
right = mid - 1
... | [
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 130,558 | 130,560 | u811434779 | ruby |
p02318 | str1 = gets.chomp
str2 = gets.chomp
lenStr1 = str1.length
lenStr2 = str2.length
matrix = Array.new()
(lenStr2+1).times{|i| matrix.push(Array.new(lenStr1,0))}
for i in 1..lenStr1 do
matrix[0][i] = i
end
for i in 1..lenStr2 do
matrix[i][0] = i
end
for i in 1..lenStr1 do
for j in 1..lenStr2 do
x = (str1[j-1] == str2[... | str1 = gets.chomp
str2 = gets.chomp
lenStr1 = str1.length
lenStr2 = str2.length
matrix = Array.new()
(lenStr2+1).times{|i| matrix.push(Array.new(lenStr1,0))}
for i in 1..lenStr1 do
matrix[0][i] = i
end
for i in 1..lenStr2 do
matrix[i][0] = i
end
for i in 1..lenStr1 do
for j in 1..lenStr2 do
x = (str1[i-1] == str2[... | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 130,747 | 130,748 | u199171255 | ruby |
p02318 | str1 = gets.chomp
str2 = gets.chomp
lenStr1 = str1.length
lenStr2 = str2.length
matrix = Array.new()
(lenStr2+1).times{|i| matrix.push(Array.new(lenStr1,0))}
for i in 1..lenStr1 do
matrix[0][i] = i
end
for i in 1..lenStr2 do
matrix[i][0] = i
end
for i in 1..lenStr1 do
for j in 1..lenStr2 do
x = (str1[j-1] == str2[... | str1 = gets.chomp
str2 = gets.chomp
lenStr1 = str1.length
lenStr2 = str2.length
matrix = Array.new
(lenStr2+1).times{|i| matrix.push(Array.new(lenStr1,0))}
for i in 1..lenStr1 do
matrix[0][i] = i
end
for i in 1..lenStr2 do
matrix[i][0] = i
end
for i in 1..lenStr1 do
for j in 1..lenStr2 do
x = (str1[i-1] == str2[j-... | [
"call.arguments.change",
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 130,747 | 130,749 | u199171255 | ruby |
p02318 | s1 = gets.chomp
s2 = gets.chomp
# s1???????????°???[0..s1.size]?????£?????´???
# s2???????????°???[0..s2.size]?????£?????´???
# ??¨???????????????
res = Array.new(s1.size.succ).map{Array.new(s2.size.succ, 0)}
# ????????????????????????0???????????¨????????¢?????????????????????
for i in (0..s1.size) do
res[i][0] = i... | s1 = gets.chomp
s2 = gets.chomp
# s1???????????°???[0..s1.size]?????£?????´???
# s2???????????°???[0..s2.size]?????£?????´???
# ??¨???????????????
res = Array.new(s1.size.succ).map{Array.new(s2.size.succ, 0)}
# ????????????????????????0???????????¨????????¢?????????????????????
for i in (0..s1.size) do
res[i][0] = i... | [
"control_flow.branch.if.condition.change"
] | 130,750 | 130,751 | u645879095 | ruby |
p02346 | # range_sum_query
#
#
s=STDIN.gets.split
n = s[0].to_i
q = s[1].to_i
ar = Array.new(100001,0)
ar2 = Array.new(1001 ,0)
1.upto(q) {
s=STDIN.gets.split
com = s[0].to_i
x = s[1].to_i
y = s[2].to_i
#printf(":%d %d %d\n",com,x,y)
if(com==0)
x1=x/100
diff = y - ar[x]
ar[x]=y
ar2[x1] += diff
elsif (com==1)
... | # range_sum_query
#
#
s=STDIN.gets.split
n = s[0].to_i
q = s[1].to_i
ar = Array.new(100001,0)
ar2 = Array.new(1001 ,0)
1.upto(q) {
s=STDIN.gets.split
com = s[0].to_i
x = s[1].to_i
y = s[2].to_i
#printf(":%d %d %d\n",com,x,y)
if(com==0)
x1=x/100
diff = y - ar[x]
ar[x] += y
ar2[x1] += y
elsif (com==1)
... | [
"assignment.value.change",
"identifier.change"
] | 131,330 | 131,331 | u708993917 | ruby |
p02346 | def add(a, b, k, l, r, node)
return 0 if r <= a || b <= l
return node[k] if a <= l && r <= b
m = (l+r)/2
vl = add(a, b, 2*k+1, l, m, node)
vr = add(a, b, 2*k+2, m, r, node)
return vl + vr
end
n, q = gets.split.map(&:to_i)
m = 1
while m < n
m *= 2
end
node = Array.new(2*m-1){0}
q.times{
com, x, y = ge... | def add(a, b, k, l, r, node)
return 0 if r <= a || b <= l
return node[k] if a <= l && r <= b
m = (l+r)/2
vl = add(a, b, 2*k+1, l, m, node)
vr = add(a, b, 2*k+2, m, r, node)
return vl + vr
end
n, q = gets.split.map(&:to_i)
m = 1
while m < n
m *= 2
end
node = Array.new(2*m-1){0}
q.times{
com, x, y = ge... | [
"expression.operation.binary.remove"
] | 131,334 | 131,335 | u960312159 | ruby |
p02345 | class SegmentTree
def initialize
@N=2**17
@INF=2**32-1
@seg=Array.new(2*@N-1){@INF}
end
def update(i, x)
i+=@N-1 #??°??????i??????????????????????????¨????????????????????????
@seg[i]=x
while i.nonzero?
i=(i-1)/2 #????????????????????????????????¨????????????
@seg[i]=[@seg[2... | class SegmentTree
def initialize
@N=2**17
@INF=2**31-1
@seg=Array.new(2*@N-1){@INF}
end
def update(i, x)
i+=@N-1 #??°??????i??????????????????????????¨????????????????????????
@seg[i]=x
while i.nonzero?
i=(i-1)/2 #????????????????????????????????¨????????????
@seg[i]=[@seg[2... | [
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 131,338 | 131,339 | u677070142 | ruby |
p02379 | x1,y1,x2,y2 = gets.chomp.split.map(&:to_i)
d = Math.sqrt((x2-x1)**2 + (y2-y1)**2)
puts d | x1,y1,x2,y2 = gets.chomp.split.map(&:to_f)
d = Math.sqrt((x2-x1)**2 + (y2-y1)**2)
puts d | [
"assignment.value.change",
"call.arguments.change"
] | 134,794 | 134,795 | u742797815 | ruby |
p02379 | x1,y1,x2,y2 = gets.chomp.split.map(&:to_i)
d = Math.sqrt((x2-x1)**2 + (y2-y1)**2)
puts d | x1,y1,x2,y2 = gets.chomp.split.map(&:to_r)
d = Math.sqrt((x2-x1)**2 + (y2-y1)**2)
puts d | [
"assignment.value.change",
"call.arguments.change"
] | 134,794 | 134,796 | u742797815 | ruby |
p02379 | x1, y1, x2, y2 = gets.split(" ").map{|x| x.to_i}
puts Math::sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) | x1, y1, x2, y2 = gets.split(" ").map{|x| x.to_f}
puts Math::sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) | [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 134,797 | 134,798 | u364560197 | ruby |
p02379 | (x1,y1,x2,y2)=gets.split.map(&:to_i)
x=x2-x1
y=y2-y1
puts Math.sqrt(x**2+y**2) | (x1,y1,x2,y2)=gets.split.map(&:to_f)
x=x2-x1
y=y2-y1
puts Math.sqrt(x**2+y**2) | [
"assignment.value.change",
"call.arguments.change"
] | 134,799 | 134,800 | u565102293 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
puts sprintf("%.5f\n", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts sprintf("%f", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | [
"assignment.value.change",
"call.arguments.change",
"literal.string.change",
"io.output.change",
"io.output.newline.remove"
] | 134,804 | 134,805 | u873778695 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
puts sprintf("%.5f\n", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts sprintf("%f", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | [
"assignment.value.change",
"call.arguments.change",
"literal.string.change",
"io.output.change",
"io.output.newline.remove"
] | 134,806 | 134,805 | u873778695 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
puts sprintf("%.5f", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts sprintf("%f", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | [
"assignment.value.change",
"call.arguments.change",
"literal.string.change",
"io.output.change"
] | 134,807 | 134,805 | u873778695 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
puts sprintf("%f", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts sprintf("%f", ((x2-x1)**2 + (y2-y1)**2)**(1/2.0)) | [
"assignment.value.change",
"call.arguments.change"
] | 134,808 | 134,805 | u873778695 | ruby |
p02379 | x1, y1, x2, y2 = gets.split( " " ).map { |val| val.to_i }
puts( Math.sqrt( ( x1 - x2 )**2 + ( y1 - y2 )**2 ) ) | x1, y1, x2, y2 = gets.split( " " ).map { |val| val.to_f }
puts( Math.sqrt( ( x1 - x2 )**2 + ( y1 - y2 )**2 ) ) | [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 134,809 | 134,810 | u604774382 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
puts Math.sqrt((x1 - x2)**2 + (y1 -y2)**2) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts Math.sqrt((x1 - x2)**2 + (y1 -y2)**2) | [
"assignment.value.change",
"call.arguments.change"
] | 134,811 | 134,812 | u209022771 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts Math.sqrt(a + b) | x1, y1, x2, y2 = gets.split.map(&:to_f)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts Math.sqrt(a + b) | [
"assignment.value.change",
"call.arguments.change"
] | 134,813 | 134,814 | u330842660 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_f)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts a
puts Math.sqrt(a + b) | x1, y1, x2, y2 = gets.split.map(&:to_f)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts Math.sqrt(a + b) | [
"call.remove"
] | 134,815 | 134,814 | u330842660 | ruby |
p02379 | x1,y1,x2,y2=gets.split.map(&:to_i)
d=((x2-x1)**2+(y2-y1)**2)**(1/2.0)
puts "%05f" % d | x1,y1,x2,y2=gets.split.map(&:to_f)
d=((x2-x1)**2+(y2-y1)**2)**(1/2.0)
puts "%05f" % d | [
"assignment.value.change",
"call.arguments.change"
] | 134,816 | 134,817 | u352522848 | ruby |
p02379 | include Math
x1,y1,x2,y2= gets.split.map(&:to_i)
dx = x1 - x2
dy = y1 - y2
puts sqrt(dx * dx + dy * dy) | include Math
x1,y1,x2,y2= gets.split.map(&:to_f)
dx = x1 - x2
dy = y1 - y2
puts sqrt(dx * dx + dy * dy) | [
"assignment.value.change",
"call.arguments.change"
] | 134,818 | 134,819 | u043406421 | ruby |
p02379 | x1, y1, x2, y2 = gets.chomp.split.map(&:to_i)
x_long = x2 - x1
y_long = y2 - y1
long = Math.hypot(x_long, y_long)
puts "#{sprintf("%.9f", long)}" | x1, y1, x2, y2 = gets.chomp.split.map(&:to_f)
x_long = x2 - x1
y_long = y2 - y1
long = Math.hypot(x_long, y_long)
puts "#{sprintf("%.9f", long)}" | [
"assignment.value.change",
"call.arguments.change"
] | 134,820 | 134,821 | u960296069 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_i)
puts sprintf("%.5f", Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts sprintf("%.5f", Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)) | [
"assignment.value.change",
"call.arguments.change"
] | 134,824 | 134,823 | u750346935 | ruby |
p02379 | x1,y1,x2,y2 = gets.split.map(&:to_i)
printf "%.8f\n", Math.hypot(x1 - x2, y1 - y2) | x1,y1,x2,y2 = gets.split.map(&:to_f)
printf "%.8f\n", Math.hypot(x1 - x2, y1 - y2) | [
"assignment.value.change",
"call.arguments.change"
] | 134,825 | 134,826 | u709642619 | ruby |
p02379 | x1, y1, x2, y2 = STDIN.gets.split(" ").map(&:to_i)
puts "%.8f" % [((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5] | x1, y1, x2, y2 = STDIN.gets.split(" ").map(&:to_f)
puts "%.8f" % [((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5] | [
"assignment.value.change",
"call.arguments.change"
] | 134,827 | 134,828 | u854587684 | ruby |
p02379 | a = gets.split(" ").map(&:to_i);
x = a[2] - a[0];
y = a[3] - a[1];
puts ((x**2 + y**2)**0.5).to_s; | a = gets.split(" ").map(&:to_f);
x = a[2] - a[0];
y = a[3] - a[1];
puts ((x**2 + y**2)**0.5).to_s; | [
"assignment.value.change",
"call.arguments.change"
] | 134,829 | 134,830 | u328069918 | ruby |
p02379 | x1,x2,y1,y2 = gets.split.map(&:to_f)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts Math.sqrt(a+b) | x1,y1,x2,y2 = gets.split.map(&:to_f)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts Math.sqrt(a+b) | [] | 134,838 | 134,839 | u407138207 | ruby |
p02379 | x1,x2,y1,y2 = gets.split.map(&:to_f)
a = (x2 - x1)**2
b = (y2 - y1)**2
puts Math.sqrt(a+b) | x1,y1,x2,y2 = gets.split.map(&:to_f)
a = (x2 - x1) **2
b = (y2 - y1) **2
puts Math.sqrt(a+b) | [] | 134,838 | 134,840 | u407138207 | ruby |
p02379 | x1,y1,x2,y2 = gets.split.map(&:to_f)
a = (x2 - x1) **2
b = (y2 - y1) **2
puts Math.sprt(a+b) | x1,y1,x2,y2 = gets.split.map(&:to_f)
a = (x2 - x1) **2
b = (y2 - y1) **2
puts Math.sqrt(a+b) | [
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 134,841 | 134,840 | u407138207 | ruby |
p02379 | def calc_distance(x, y) #x, y???????´???°2??????1?¬??????????
require 'bigdecimal'
distance = ((y[0] - x[0])**2 + (y[1] - x[1])**2) ** 0.5
distance_approximately = BigDecimal(distance.to_s).floor(8).to_f
return distance_approximately #P1??¨P2????????¢
end
input_values = gets.chomp.split.map(&:to_i)
x = [input_... | def calc_distance(x, y) #x, y???????´???°2??????1?¬??????????
require 'bigdecimal'
distance = ((y[0] - x[0])**2 + (y[1] - x[1])**2) ** 0.5
distance_approximately = BigDecimal(distance.to_s).floor(8).to_f
return distance_approximately #P1??¨P2????????¢
end
input_values = gets.chomp.split.map(&:to_f)
x = [input_... | [
"assignment.value.change",
"call.arguments.change"
] | 134,842 | 134,843 | u723368439 | ruby |
p02379 | x1,y1,x2,y2 = gets.split(" ").map(&:to_i)
distance = (x2-x1)**2 + (y2-y1)**2
puts Math.sqrt(distance) | x1,y1,x2,y2 = gets.split(" ").map(&:to_f)
distance = (x2-x1)**2 + (y2-y1)**2
puts Math.sqrt(distance) | [
"assignment.value.change",
"call.arguments.change"
] | 134,844 | 134,845 | u501176275 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts Math.sqrt((x2 - x1) ** 2 + (y1 + y2) ** 2) | x1, y1, x2, y2 = gets.split.map(&:to_f)
puts Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) | [
"expression.operation.binary.remove",
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 134,846 | 134,847 | u802537549 | ruby |
p02379 | x1, y1, x2, y2 = gets.split(" ").map(&:to_i)
a = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
puts "%f"%a | x1, y1, x2, y2 = gets.split(" ").map(&:to_f)
a = Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
puts "%f"%a | [
"assignment.value.change",
"call.arguments.change"
] | 134,850 | 134,851 | u906710658 | ruby |
p02379 | x1, y1, x2, y2 = gets.split(" ").map(&:to_i)
printf "%f\n", Math.sqrt((x2-x1)**2 + (y2-y1)**2) | x1, y1, x2, y2 = gets.split(" ").map(&:to_f)
printf "%f\n", Math.sqrt((x2-x1)**2 + (y2-y1)**2) | [
"assignment.value.change",
"call.arguments.change"
] | 134,852 | 134,853 | u960312159 | ruby |
p02379 | a, b, c, d = gets.split.map(&:to_i)
p Math.hypot(c - a, d - b) | a, b, c, d = gets.split.map(&:to_f)
p Math.hypot(c - a, d - b) | [
"assignment.value.change",
"call.arguments.change"
] | 134,854 | 134,855 | u295404099 | ruby |
p02379 | #!/usr/bin/env ruby
x1, y1, x2, y2 = gets.chomp.split.map(&:to_i)
puts Math.sqrt((x1 - x2)**2 + (y1 - y2)**2) | #!/usr/bin/env ruby
x1, y1, x2, y2 = gets.chomp.split.map(&:to_f)
puts Math.sqrt((x1 - x2)**2 + (y1 - y2)**2) | [
"assignment.value.change",
"call.arguments.change"
] | 134,856 | 134,857 | u717782380 | ruby |
p02379 | # Your code here!
x1, y1, x2, y2 = gets.split.map(&:to_i)
p ((x2 - x1)**2 + (y2 - y1)**2) **(1/2.0)
| # Your code here!
x1, y1, x2, y2 = gets.split.map(&:to_f)
puts ((x2 - x1)**2 + (y2 - y1)**2)**(1/2.0)
| [
"assignment.value.change",
"call.arguments.change",
"call.function.change",
"io.output.change"
] | 134,858 | 134,859 | u401720175 | ruby |
p02379 | x1,y1,x2,y2 = gets.chomp.split(" ").map{|x| x.to_i}
printf("%f\n",((x2-x1)**2+(y2-y1)**2)**0.5)
| x1,y1,x2,y2 = gets.chomp.split(" ").map{|x| x.to_f}
printf("%f\n",((x2-x1)**2+(y2-y1)**2)**0.5)
| [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 134,860 | 134,861 | u241079749 | ruby |
p02379 | x1, y1, x2, y2 = gets.split.to_f
printf "%.4f", Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
| x1, y1, x2, y2 = gets.split.map(&:to_f)
printf "%.4f", Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
| [
"assignment.value.change",
"identifier.change",
"call.arguments.add"
] | 134,864 | 134,865 | u864617427 | ruby |
p02379 | x1, y1, x2, y2 = io.gets.split.map(&:to_f)
printf "%.4f", Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
| x1, y1, x2, y2 = gets.split.map(&:to_f)
printf "%.4f", Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
| [
"call.remove"
] | 134,866 | 134,865 | u864617427 | ruby |
p02379 | a,b,c,d=gets.split.map(&:to_i)
puts Math.sqrt((c-a)**2+(d-b)**2) | a,b,c,d=gets.split.map(&:to_f)
puts Math.sqrt((c-a)**2+(d-b)**2) | [
"assignment.value.change",
"call.arguments.change"
] | 134,867 | 134,868 | u517414491 | ruby |
p02381 | while (n=gets.to_i)!=0
s=gets.split.map &:to_i
p (s.inject(0){|a,i|a+(i-(eval s*?+)/n)**2}/n)**0.5
end
| while (n=gets.to_i)!=0
s=gets.split.map &:to_f
p (s.inject(0){|a,i|a+(i-(eval s*?+)/n)**2}/n)**0.5
end
| [
"assignment.value.change",
"call.arguments.change"
] | 136,269 | 136,270 | u550290469 | ruby |
p02381 | loop do
sigma = 0
n = gets.to_i
exit 0 if n == 0
s = gets.split(" ").map{|x| x.to_i}
for i in 0..(s.length - 1)
sigma += (s[i] - (s.inject(:+) / s.length)) ** 2
end
puts Math::sqrt(sigma / n)
end | loop do
sigma = 0
n = gets.to_i
exit 0 if n == 0
s = gets.split(" ").map{|x| x.to_i}
for i in 0..(s.length - 1)
sigma += (s[i] - (s.inject(:+).to_f / s.length)) ** 2
end
puts Math::sqrt(sigma / n)
end | [
"call.add"
] | 136,273 | 136,274 | u364560197 | ruby |
p02381 | def getAverage(points)
sum = 0
points.each {|x|
sum += x
}
return (sum / points.length).to_f
end
while true
n = STDIN.gets.to_i
if n == 0 then break end
str = STDIN.gets.split(" ")
point = Array.new(n) { |i| i = str[i].to_i}
average = getAverage(point)
s = 0.0
for i in 0..point.length - 1 d... | def getAverage(points)
sum = 0
points.each {|x|
sum += x
}
return (sum / points.length).to_f
end
while true
n = STDIN.gets.to_i
if n == 0 then break end
str = STDIN.gets.split(" ")
point = Array.new(n) { |i| i = str[i].to_f}
average = getAverage(point)
s = 0.0
for i in 0..point.length - 1 d... | [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 136,275 | 136,276 | u938745275 | ruby |
p02381 | loop do
n = gets.chomp.to_i
if n == 0
break
end
s = gets.split
i = 0
s.each do |j|
i += j.to_i
end
m = i / n
k = 0
s.each do |l|
k += (l.to_i - m) ** 2
end
a = k / n
puts "#{sprintf("%.9f", Math.sqrt(a))}"
end | loop do
n = gets.chomp.to_i
if n == 0
break
end
s = gets.split
i = 0
s.each do |j|
i += j.to_f
end
m = i / n
k = 0
s.each do |l|
k += (l.to_i - m) ** 2
end
a = k / n
puts "#{sprintf("%.9f", Math.sqrt(a))}"
end | [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 136,280 | 136,281 | u960296069 | ruby |
p02381 | until (n = gets.chomp.to_i) == 0
arr = gets.split.map(&:to_i)
sum = 0
n.times do |i|
sum = sum + arr[i]
end
ave = sum / n
alpha = 0
n.times do |i|
alpha = alpha + ((arr[i] - ave)**2)
end
puts (alpha / n) ** 0.5
end | until (n = gets.chomp.to_i) == 0
arr = gets.split.map(&:to_i)
sum = 0
n.times do |i|
sum = sum + arr[i]
end
ave = sum.to_f / n
alpha = 0
n.times do |i|
alpha = alpha + ((arr[i] - ave)**2)
end
puts (alpha / n) ** 0.5
end | [
"call.add"
] | 136,284 | 136,285 | u261074410 | ruby |
p02381 | while n = gets.to_i
break if n.zero?
students = gets.split.map(&:to_i)
average = students.inject(&:+) / n
dispersion = students.inject(0) { |sum, num| sum + (num - average)**2 } / n
puts Math.sqrt(dispersion)
end | while n = gets.to_i
break if n.zero?
students = gets.split.map(&:to_i)
average = students.inject(&:+) / n.to_f
dispersion = students.inject(0) { |sum, num| sum + (num - average)**2 } / n
puts Math.sqrt(dispersion)
end | [
"call.add"
] | 136,286 | 136,287 | u139670451 | ruby |
p02381 | while gets != "0\n"
ss = gets.split.map(&:to_i)
ave = ss.inject(:+) / ss.size
puts Math.sqrt(ss.map{|s|(s-ave)**2}.inject(:+)/ss.size)
end | while gets != "0\n"
ss = gets.split.map(&:to_f)
ave = ss.inject(:+) / ss.size
puts Math.sqrt(ss.map{|s|(s-ave)**2}.inject(:+)/ss.size)
end | [
"assignment.value.change",
"call.arguments.change"
] | 136,288 | 136,289 | u422350156 | ruby |
p02381 | until ((n = gets.chomp.to_i) == 0)
numbers = gets.chomp.split.map(&:to_f)
squares = numbers.map{|n| n ** 2}
sum = numbers.inject(:+) / n
ss = squares.inject(:+)
sd = Math.sqrt(ss / n - mean ** 2)
printf("%.5f\n", sd)
end | until ((n = gets.chomp.to_i) == 0)
numbers = gets.chomp.split.map(&:to_f)
squares = numbers.map{|n| n ** 2}
mean = numbers.inject(:+) / n
ss = squares.inject(:+)
sd = Math.sqrt(ss / n - mean ** 2)
printf("%.5f\n", sd)
end | [
"assignment.variable.change",
"identifier.change"
] | 136,290 | 136,291 | u247371045 | ruby |
p02381 | until ((n = gets.chomp.to_i) == 0)
numbers = gets.chomp.split.map(&:to_i)
mean = numbers.inject(:+) / n.to_f
squares = numbers.map{|n| n ** 2}
ss = squares.inject(:+)
sd = Math.sqrt(ss / n - mean ** 2)
printf("%.5f\n", sd)
end | until ((n = gets.chomp.to_i) == 0)
numbers = gets.chomp.split.map(&:to_i)
mean = numbers.inject(:+) / n.to_f
squares = numbers.map{|n| n ** 2}
ss = squares.inject(:+)
sd = Math.sqrt(ss / n.to_f - mean ** 2)
printf("%.5f\n", sd)
end | [
"call.add"
] | 136,292 | 136,293 | u247371045 | ruby |
p02381 | while n = gets.chomp.to_i
if n==0
break
end
s = gets.chomp.split(" ").map{|item| item.to_i}
ave=0
n.times{ |idx|
ave += s[idx]
}
ave/=n
a=0
n.times{ |idx|
a+=(s[idx]-ave)**2
}
a/=n
a=Math::sqrt(a)
puts a
end | while n = gets.chomp.to_i
if n==0
break
end
s = gets.chomp.split(" ").map{|item| item.to_i}
ave=0.0
n.times{ |idx|
ave += s[idx]
}
ave/=n
a=0.0
n.times{ |idx|
a+=(s[idx]-ave)**2
}
a/=n
a=Math::sqrt(a)
puts a
end | [
"assignment.value.change"
] | 136,294 | 136,295 | u843848664 | ruby |
p02381 | while true do
count = gets.to_i;
if count == 0 then
break;
end
sum = 0.to_f;
average = 0.to_f;
aryStudentPoint = gets.split(' ').map(&:to_f);
for sumIndex in 0..aryStudentPoint.length - 1 do
sum = sum + aryStudentPoint[sumIndex];
end
average = sum / average;
sum = 0.to_f;
for index... | while true do
count = gets.to_i;
if count == 0 then
break;
end
sum = 0.to_f;
average = 0.to_f;
aryStudentPoint = gets.split(' ').map(&:to_f);
for sumIndex in 0..aryStudentPoint.length - 1 do
sum = sum + aryStudentPoint[sumIndex];
end
average = sum / count;
sum = 0.to_f;
for index in 0.... | [
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 136,296 | 136,297 | u606593727 | ruby |
p02381 | while (times = gets.to_i) != 0
date = gets.split(" ").map(&:to_i)
ave = date.inject(:+) / times
sum = 0
for i in 0...times
sum += (date[i]-ave)**2
end
s = Math.sqrt(sum/times)
puts s
end | while (times = gets.to_f) != 0
date = gets.split(" ").map(&:to_f)
ave = date.inject(:+) / times
sum = 0
for i in 0...times
sum += (date[i]-ave)**2
end
s = Math.sqrt(sum/times)
puts s
end | [
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change",
"assignment.value.change",
"call.arguments.change"
] | 136,298 | 136,299 | u501176275 | ruby |
p02381 | while n = gets.to_i do
break if n == 0
s = gets.split(" ").map(&:to_i)
m = s.inject(:+)/n
s2 = 0
s.each{|si|
s2 += (si - m)**2
}
printf "%f\n", Math.sqrt(s2 / n)
end | while n = gets.to_i do
break if n == 0
s = gets.split(" ").map(&:to_i)
m = s.inject(:+)/n.to_f
s2 = 0
s.each{|si|
s2 += (si - m)**2
}
printf "%f\n", Math.sqrt(s2 / n)
end | [
"call.add"
] | 136,300 | 136,301 | u960312159 | ruby |
p02380 | include Math
def f(a, b, c)
return (0.5 * a * b * sin(g(c))), (a ** 2 + b ** 2 - 2 * a * b * cos(g(c))) ** 0.5 * a + b, b * sin(g(c))
end
def g(c)
return c * PI / 180
end
puts f(*gets.split(" ").map(&:to_i)) | include Math
def f(a, b, c)
return (0.5 * a * b * sin(g(c))), (a ** 2 + b ** 2 - 2 * a * b * cos(g(c))) ** 0.5 + a + b, b * sin(g(c))
end
def g(c)
return c * PI / 180
end
puts f(*gets.split(" ").map(&:to_i))
#f(*gets.split(" ").map(&:to_i)).each{|i|puts sprintf("%.4f", i)} | [
"expression.operator.arithmetic.change",
"call.arguments.change",
"function.return_value.change",
"expression.operation.binary.change"
] | 136,304 | 136,305 | u514597327 | ruby |
p02380 | a, b, c = gets.split.map(&:to_f)
s = 0.5 * (a * b) * (Math.sin(c * (Math::PI / 180)))
l = a + b + Math.sqrt(a**2 + b**2 + (2 * a * b * Math.cos(c * (Math::PI / 180))))
h = b * Math.sin(c * (Math::PI / 180.0))
puts s
puts l
puts h | a, b, c = gets.split.map(&:to_f)
s = 0.5 * (a * b) * (Math.sin(c * (Math::PI / 180)))
l = a + b + Math.sqrt(a**2 + b**2 - (2 * a * b * Math.cos(c * (Math::PI / 180))))
h = b * Math.sin(c * (Math::PI / 180))
puts s
puts l
puts h | [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 136,306 | 136,307 | u330842660 | ruby |
p02380 | a,b,c=gets.split.map(&:to_f)
h=b*Math.sin(Math::PI*c/180)
puts a*h*1/2
puts a+b+(h**2+(a-b*Math.cos(Math::PI*c/180))**2)**(1/2.0) | a,b,c=gets.split.map(&:to_f)
h=b*Math.sin(Math::PI*c/180)
puts a*h*1/2
puts a+b+(h**2+(a-b*Math.cos(Math::PI*c/180))**2)**(1/2.0)
puts h | [
"call.add"
] | 136,308 | 136,309 | u352522848 | ruby |
p02380 | a, b, c = gets.split.map(&:to_f)
h = sin(c *= PI / 180) * b
puts a / 2 * h
puts a + b + sqrt(a * a + b * b - 2 * a * b * cos(c))
puts h | include Math
a, b, c = gets.split.map(&:to_f)
h = sin(c *= PI / 180) * b
puts a / 2 * h
puts a + b + sqrt(a * a + b * b - 2 * a * b * cos(c))
puts h | [
"call.add"
] | 136,310 | 136,311 | u364253163 | ruby |
p02380 | a, b, theta = gets.chomp.split.map(&:to_f)
rad = theta / 180 * Math::PI
h = b * Math.sin(rad)
S = a * h / 2
c = Math.sqrt(a ** 2 + b **2 - a * b * Math.cos(rad))
L = a + b + c
printf("%.5f\n", S)
printf("%.5f\n", L)
printf("%.5f\n", h) | a, b, theta = gets.chomp.split.map(&:to_f)
rad = theta / 180 * Math::PI
h = b * Math.sin(rad)
S = a * h / 2
c = Math.sqrt(a ** 2 + b **2 - 2 * a * b * Math.cos(rad))
L = a + b + c
printf("%.5f\n", S)
printf("%.5f\n", L)
printf("%.5f\n", h) | [
"assignment.change"
] | 136,314 | 136,315 | u247371045 | ruby |
p02380 | #!/usr/bin/env ruby
a, b, c = gets.chomp.split.map(&:to_f)
c_rad = c * Math::PI / 180
l = Math.sqrt(a**2 + b**2 + a * b * Math.cos(c_rad)) + a + b
h = b * Math.sin(c_rad)
s = a * h / 2
puts s, l, h | #!/usr/bin/env ruby
a, b, c = gets.chomp.split.map(&:to_f)
c_rad = c * Math::PI / 180
l = Math.sqrt(a**2 + b**2 - 2 * a * b * Math.cos(c_rad)) + a + b
h = b * Math.sin(c_rad)
s = a * h / 2
puts s, l, h | [
"misc.opposites",
"expression.operator.arithmetic.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 136,325 | 136,326 | u717782380 | ruby |
p02380 | #!/usr/bin/env ruby
a, b, c = gets.chomp.split.map(&:to_f)
c_rad = c * Math::PI / 180
l = Math.sqrt(a**2 + b**2 - a * b * Math.cos(c_rad)) + a + b
h = b * Math.sin(c_rad)
s = a * h / 2
puts s, l, h | #!/usr/bin/env ruby
a, b, c = gets.chomp.split.map(&:to_f)
c_rad = c * Math::PI / 180
l = Math.sqrt(a**2 + b**2 - 2 * a * b * Math.cos(c_rad)) + a + b
h = b * Math.sin(c_rad)
s = a * h / 2
puts s, l, h | [
"assignment.change"
] | 136,327 | 136,326 | u717782380 | ruby |
p02380 | a, b, c_theta = gets.split.map(&:to_i)
# surface
s = a * b * Math.sin(c_theta / 180.0 * Math::PI) / 2.0
puts s
# length in the circle
c = (a ** 2 + b ** 2 - 2 * a * b * Math.cos(c_theta / 180.0 * Math::PI)) ** (1/2.0)
puts a + b + c
# height h
h = b / Math.sin(c_theta / 180.0 * Math::PI)
puts h
| a, b, c_theta = gets.split.map(&:to_i)
# surface
s = a * b * Math.sin(c_theta / 180.0 * Math::PI) / 2.0
puts s
# length in the circle
c = (a ** 2 + b ** 2 - 2 * a * b * Math.cos(c_theta / 180.0 * Math::PI)) ** (1/2.0)
puts a + b + c
# height h
h = b * Math.sin(c_theta / 180.0 * Math::PI)
puts h
| [
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 136,328 | 136,329 | u401720175 | ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.