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 |
|---|---|---|---|---|---|---|---|
p00002
|
lines = gets(nil)
lines.each do |line|
a, b = line.split.map(&:to_i)
puts (a + b).to_s.size
end
|
lines = readlines
lines.each do |line|
a, b = line.split.map(&:to_i)
puts (a + b).to_s.size
end
|
[
"assignment.value.change",
"call.arguments.change"
] | 7,929
| 7,930
|
u365936947
|
ruby
|
p00002
|
while line = gets
num = line.split("\s")
sum = num[0].to_i + num[1].to_i
len = sum.to_s.rength
puts len.to_s
end
|
while line = gets
num = line.split("\s")
sum = num[0].to_i + num[1].to_i
len = sum.to_s.length
puts len.to_s
end
|
[
"identifier.change"
] | 7,933
| 7,934
|
u407138207
|
ruby
|
p00002
|
while s = gets
puts s.split(/\s/).map(&:to_i).inject(:+)
end
|
while s = gets
puts s.split(/\s/).map(&:to_i).inject(:+).to_s.size
end
|
[
"call.add"
] | 7,935
| 7,936
|
u708217907
|
ruby
|
p00002
|
class Array
def keta
map(&:to_i).reduce(:+).to_s.length
end
end
while i = $stdin.gets.chomp.split(' ').keta
puts I
end
|
class Array
def keta
map(&:to_i).reduce(:+).to_s.length
end
end
while i = $stdin.gets
puts i.chomp.split(' ').keta
end
|
[
"call.add",
"call.remove"
] | 7,939
| 7,940
|
u993379803
|
ruby
|
p00002
|
while str = gets
puts Math.log10(str.chomp.split(' ').map(&:to_i).inject(&:+)).to_i
end
|
while str = gets
puts Math.log10(str.chomp.split(' ').map(&:to_i).inject(&:+)).to_i + 1
end
|
[
"expression.operation.binary.add"
] | 7,941
| 7,942
|
u720435069
|
ruby
|
p00002
|
gets.split.map(&:to_i).inject(:+).to_s.length
|
while line = gets
puts line.split.map(&:to_i).inject(:+).to_s.length
end
|
[
"call.add"
] | 7,943
| 7,944
|
u689529213
|
ruby
|
p00002
|
puts gets.split.map(&:to_i).inject(:+).to_s.length
|
while line = gets
puts line.split.map(&:to_i).inject(:+).to_s.length
end
|
[
"call.add"
] | 7,945
| 7,944
|
u689529213
|
ruby
|
p00002
|
while l = gets do p l.split.map(:to_i).inject(:+).to_s.length end
|
while l = gets do p l.split.map(&:to_i).inject(:+).to_s.length end
|
[
"call.arguments.change"
] | 7,952
| 7,953
|
u300645821
|
ruby
|
p00002
|
while line = gets
line.split.map!(&:to_i)
puts (line[0] + line[1]).to_s.length
end
|
while line = gets
line = line.chomp.split.map(&:to_i)
puts (line[0] + line[1]).to_s.length
end
|
[
"assignment.value.change",
"identifier.change"
] | 7,956
| 7,955
|
u202852666
|
ruby
|
p00002
|
loop do
line = gets.strip
break if line.empty?
puts line.map(&:to_i).reduce(&:+).to_s.length
end
|
loop do
line = gets
break if line.nil?
puts line.split.map(&:to_i).reduce(&:+).to_s.length
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 7,959
| 7,960
|
u434245278
|
ruby
|
p00005
|
#!ruby -nal
p "#{$F.map(&:to_i).reduce(:lcm)} #{$F.map(&:to_i).reduce(:gcd)}"
|
#!ruby -nal
puts "#{$F.map(&:to_i).reduce(:gcd)} #{$F.map(&:to_i).reduce(:lcm)}"
|
[
"call.function.change",
"io.output.change",
"literal.string.change",
"call.arguments.change"
] | 8,602
| 8,603
|
u494858865
|
ruby
|
p00005
|
#!ruby -nal
puts "#{$F.map(&:to_i).reduce(:lcm)} #{$F.map(&:to_i).reduce(:gcd)}"
|
#!ruby -nal
puts "#{$F.map(&:to_i).reduce(:gcd)} #{$F.map(&:to_i).reduce(:lcm)}"
|
[
"literal.string.change",
"call.arguments.change"
] | 8,604
| 8,603
|
u494858865
|
ruby
|
p00005
|
# ?????§??¬?´???°?????????????????????????????????????????????
def gcd(x, y)
r = x % y
return y if r.zero?
gcd(y, r)
end
# ?????§??¬?????°
def lcm(x, y, gcd)
(x * y) / gcd
end
array = []
while line = gets
x, y = line.split.map(&:to_i)
gcd = gcd(x, y)
lcm = lcm(x, y, gcd)
p "#{gcd} #{lcm}"
end
|
# ?????§??¬?´???°?????????????????????????????????????????????
def gcd(x, y)
r = x % y
return y if r.zero?
gcd(y, r)
end
# ?????§??¬?????°
def lcm(x, y, gcd)
(x * y) / gcd
end
array = []
while line = gets
x, y = line.split.map(&:to_i)
gcd = gcd(x, y)
lcm = lcm(x, y, gcd)
puts "#{gcd} #{lcm}"
end
|
[
"call.function.change",
"io.output.change"
] | 8,610
| 8,611
|
u291317113
|
ruby
|
p00005
|
require 'English'
def gcd(a, b)
while (r = a % b) != 0
a = b
b = r
end
b
end
def lcm(n, m, g)
n * m / g
end
while gets
a, b = $LAST_READ_LINE.split(/\s/).map(&:to_i).sort
g = gcd(a, b)
l = lcm(a, b, g)
print "#{g} #{l}"
end
|
require 'English'
def gcd(a, b)
while (r = a % b) != 0
a = b
b = r
end
b
end
def lcm(n, m, g)
(n * m) / g
end
while gets
a, b = $LAST_READ_LINE.split(/\s/).map(&:to_i).sort
g = gcd(a, b)
l = lcm(a, b, g)
puts "#{g} #{l}"
end
|
[
"identifier.change"
] | 8,615
| 8,616
|
u708217907
|
ruby
|
p00005
|
class Array
def gcd
inject do |a, b|
a * b / lcm
end
end
def lcm
inject do |a, b|
a, b = b, a if a < b
return a if b.zero?
arr = b, a % b
arr.lcm
end
end
end
while str = gets
a = str.split(' ').map(&:to_i)
puts "#{a.gcd} #{a.lcm}"
end
|
class Array
def lcm
inject do |a, b|
a * b / gcd
end
end
def gcd
inject do |a, b|
a, b = b, a if a < b
return a if b.zero?
arr = b, a % b
arr.gcd
end
end
end
while str = gets
a = str.split(' ').map(&:to_i)
puts "#{a.gcd} #{a.lcm}"
end
|
[
"identifier.change",
"expression.operation.binary.change"
] | 8,617
| 8,618
|
u708217907
|
ruby
|
p00005
|
#! ruby -Ku
while data = gets.chomp
data = gets
break if data.nil?
x = 1
y = 1
z = 1
gcd = []
gcda = []
gcdb = []
lcma = []
lcmb = []
a, b = data.split(' ').map(&:to_i)
i = 2
while i <= a || i <= b
if (a % i).zero? && (b % i).zero?
# p "a=#{a} b=#{b} i=#{i} ab??????"
gcd << i
a /= i
b /= i
redo
elsif (a % i).zero?
# p "a=#{a} b=#{b} i=#{i} a??????"
gcda << i
a /= i
redo
elsif (b % i).zero?
# p "a=#{a} b=#{b} i=#{i} b??????"
gcdb << i
b /= i
redo
end
i += 1
# p "#{a} #{b}"
end
gcda.each do |i|
x *= i
end
gcdb.each do |i|
y *= i
end
gcd.each do |i|
z *= i
end
# puts "#{gcd} #{x} #{y} #{z} #{x*y*z}"
puts "#{z} #{x * y * z}"
end
|
while data = gets
break if data.nil?
x = 1
y = 1
z = 1
gcd = []
gcda = []
gcdb = []
lcma = []
lcmb = []
a, b = data.split(' ').map(&:to_i)
i = 2
while i <= a || i <= b
if (a % i).zero? && (b % i).zero?
# p "a=#{a} b=#{b} i=#{i} ab??????"
gcd << i
a /= i
b /= i
redo
elsif (a % i).zero?
# p "a=#{a} b=#{b} i=#{i} a??????"
gcda << i
a /= i
redo
elsif (b % i).zero?
# p "a=#{a} b=#{b} i=#{i} b??????"
gcdb << i
b /= i
redo
end
i += 1
# p "#{a} #{b}"
end
gcda.each do |i|
x *= i
end
gcdb.each do |i|
y *= i
end
gcd.each do |i|
z *= i
end
# puts "#{gcd} #{x} #{y} #{z} #{x*y*z}"
puts "#{z} #{x * y * z}"
end
|
[
"call.remove"
] | 8,621
| 8,620
|
u534464795
|
ruby
|
p00005
|
while line = gets
a, b = line.chomp.split.map(&:to_i)
gcd = a.gcd(b)
lcm = a * b / c
puts "#{gcd} #{lcm}"
end
|
while line = gets
a, b = line.chomp.split.map(&:to_i)
gcd = a.gcd(b)
lcm = a * b / gcd
puts "#{gcd} #{lcm}"
end
|
[
"identifier.change",
"expression.operation.binary.change"
] | 8,625
| 8,626
|
u802537549
|
ruby
|
p00005
|
#!/usr/local/bin/ruby
while line = gets
rec = gets.split(' ').map(&:to_i)
x = rec[0].to_i
y = rec[1].to_i
s = x * y
loop do
k = x % y
x = y
y = k
break if k.zero?
end
lcm = s / x
puts "#{x} #{lcm}"
end
|
#!/usr/local/bin/ruby
while line = gets
rec = line.split(' ').map(&:to_i)
x = rec[0].to_i
y = rec[1].to_i
s = x * y
loop do
k = x % y
x = y
y = k
break if k.zero?
end
lcm = s / x
puts "#{x} #{lcm}"
end
|
[
"identifier.change"
] | 8,631
| 8,632
|
u679425694
|
ruby
|
p00005
|
#!/usr/local/bin/ruby
while line = gets
rec = gets.split(' ').map(&:to_i)
x = rec[0]
y = rec[1]
s = x * y
loop do
k = x % y
x = y
y = k
break if k.zero?
end
lcm = s / x
puts "#{x} #{lcm}"
end
|
#!/usr/local/bin/ruby
while line = gets
rec = line.split(' ').map(&:to_i)
x = rec[0]
y = rec[1]
s = x * y
loop do
k = x % y
x = y
y = k
break if k.zero?
end
lcm = s / x
puts "#{x} #{lcm}"
end
|
[
"identifier.change"
] | 8,635
| 8,634
|
u679425694
|
ruby
|
p00005
|
class Array
def product(ary)
temp = clone
result = []
ary.each do |v|
result << temp.delete_at(temp.index(v)) if temp.include?(v)
end
result
end
end
# greatest common divisor(最大公約数)
def gcd(i)
gcd_div = prime_div2.product(i.prime_div2)
gcg_div.inject { |memo, item| memo * item }
end
# least common multiple(最小公倍数)
def lcm(i)
lcm_div = prime_div2 + i.prime_div2
lcm_div -= prime_div2.product(i.prime_div2)
lcm_div.inject { |memo, item| memo * item }
end
# エラトステネスの篩いによる素数列の生成
def eratosthenes(n)
list = Array.new(n - 1).map.with_index { |_i, k| k + 2 }
result = [1]
while list.last >= result.last**2
p = list.shift
result << p
list.delete_if { |v| (v % p).zero? }
end
result.shift
result += list
end
# 素因数分解して[2, 2, 2, 3]の様に返す。
def prime_div
k = self
c = 0
result = []
eratosthenes(n / 2).each do |i|
c = 0
next unless (k % i).zero?
while (k % i).zero?
k /= i
result << k
end
end
result
end
while line = gets
imput = line.chomp.split.map(&:to_i)
print imput[0].gcd(imput[1]), ' ', imput[0].lcm(imput[1])
end
|
class Array
def product(ary)
temp = clone
result = []
ary.each do |v|
result << temp.delete_at(temp.index(v)) if temp.include?(v)
end
result
end
end
# greatest common divisor(最大公約数)
def gcd(i)
gcd_div = prime_div2.product(i.prime_div2)
gcg_div.inject { |memo, item| memo * item }
end
# least common multiple(最小公倍数)
def lcm(i)
lcm_div = prime_div2 + i.prime_div2
lcm_div -= prime_div2.product(i.prime_div2)
lcm_div.inject { |memo, item| memo * item }
end
# エラトステネスの篩いによる素数列の生成
def eratosthenes(n)
list = Array.new(n - 1).map.with_index { |_i, k| k + 2 }
result = [1]
while list.last >= result.last**2
p = list.shift
result << p
list.delete_if { |v| (v % p).zero? }
end
result.shift
result += list
end
# 素因数分解して[2, 2, 2, 3]の様に返す。
def prime_div
k = self
c = 0
result = []
eratosthenes(n / 2).each do |i|
c = 0
next unless (k % i).zero?
while (k % i).zero?
k /= i
result << k
end
end
result
end
while line = gets
imput = line.chomp.split.map(&:to_i)
print imput[0].gcd(imput[1]), ' ', imput[0].lcm(imput[1]), "\n"
end
|
[
"call.arguments.add"
] | 8,636
| 8,637
|
u202852666
|
ruby
|
p00004
|
args = []
while line = gets
a, b, c, d, e, f = line.split.map(&:to_i)
y = (a * f - d * c) / (a * e - d * b)
x = (c - b * y) / a
puts "#{format('%.3f', x)} #{format('%.3f', y)}"
end
|
args = []
while line = gets
a, b, c, d, e, f = line.split.map(&:to_f)
y = (a * f - d * c) / (a * e - d * b)
x = (c - b * y) / a
puts "#{format('%.3f', x)} #{format('%.3f', y)}"
end
|
[
"call.arguments.change"
] | 9,010
| 9,011
|
u291317113
|
ruby
|
p00004
|
# a1x + b1y = c1
# a2x + b2y = c2
require 'English'
def solve(a1, b1, c1, a2, b2, c2)
x = (c1 * b2 - c2 * b1) / (a1 * b2 - a2 * b1)
x = 0.0 if x == -0.0
y = (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1)
y = 0.0 if y == -0.0
[x, y]
end
$DEFAULT_INPUT.each do |l|
a, b, c, d, e, f = l.split.map(&:to_f)
x, y = solve(a, b, c, d, e, f)
printf("%.4f %.4f\n", x, y)
end
|
# a1x + b1y = c1
# a2x + b2y = c2
require 'English'
def solve(a1, b1, c1, a2, b2, c2)
x = (c1 * b2 - c2 * b1) / (a1 * b2 - a2 * b1)
x = 0.0 if x == -0.0
y = (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1)
y = 0.0 if y == -0.0
[x, y]
end
$DEFAULT_INPUT.each do |l|
a, b, c, d, e, f = l.split.map(&:to_f)
x, y = solve(a, b, c, d, e, f)
printf("%.3f %.3f\n", x, y)
end
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 9,012
| 9,013
|
u543212635
|
ruby
|
p00004
|
#!/usr/bin/env ruby
while line = gets
a, b, c, d, e, f = line.split.map(&:to_i)
y = (a * f - c * d) / (a * e - b * d)
x = (c - b * ((a * f - c * d) / (a * e - b * d))) / a
puts format('%.3f %.3f', x, y)
end
|
#!/usr/bin/env ruby
while line = gets
a, b, c, d, e, f = line.split.map(&:to_f)
y = (a * f - c * d) / (a * e - b * d)
x = (c - b * ((a * f - c * d) / (a * e - b * d))) / a
puts format('%.3f %.3f', x, y)
end
|
[
"call.arguments.change"
] | 9,016
| 9,017
|
u695539149
|
ruby
|
p00004
|
#!/usr/bin/env ruby
while line = gets
a, b, c, d, e, f = line.split.map(&:to_i)
y = (a * f - c * d) / (a * e - b * d)
x = (c - b * ((a * f - c * d) / (a * e - b * d))) / a
puts format('%.3f %.3f', x, y)
end
|
while line = gets
a, b, c, d, e, f = line.split.map(&:to_f)
y = (a * f - c * d) / (a * e - b * d)
x = (c - b * ((a * f - c * d) / (a * e - b * d))) / a
puts format('%.3f %.3f', x, y)
end
|
[
"call.arguments.change"
] | 9,016
| 9,018
|
u695539149
|
ruby
|
p00004
|
$stdout.sync = true
num = []
while data = $stdin.gets
num = data.split.map!(&:to_i)
y = (num[2] * num[3] - num[0] * num[5]) / (num[1] * num[3] - num[0] * num[4])
x = (num[2] - num[1] * y) / num[0]
puts format("%.3f %.3f\n", x, y)
end
|
$stdout.sync = true
num = []
while data = $stdin.gets
num = data.split.map!(&:to_f)
y = (num[2] * num[3] - num[0] * num[5]) / (num[1] * num[3] - num[0] * num[4])
x = (num[2] - num[1] * y) / num[0]
puts format('%.3f %.3f', x, y)
end
|
[
"call.arguments.change"
] | 9,025
| 9,024
|
u493797593
|
ruby
|
p00004
|
$stdout.sync = true
num = []
while data = $stdin.gets
num = data.split.map!(&:to_i)
y = (num[2] * num[3] - num[0] * num[5]) / (num[1] * num[3] - num[0] * num[4])
x = (num[2] - num[1] * y) / num[0]
puts format('%.3f %.3f', x, y)
end
|
$stdout.sync = true
num = []
while data = $stdin.gets
num = data.split.map!(&:to_f)
y = (num[2] * num[3] - num[0] * num[5]) / (num[1] * num[3] - num[0] * num[4])
x = (num[2] - num[1] * y) / num[0]
puts format('%.3f %.3f', x, y)
end
|
[
"call.arguments.change"
] | 9,026
| 9,024
|
u493797593
|
ruby
|
p00004
|
$stdin.each_line do |line|
a, b, c, d, e, f = line.split.map(&:to_f)
x = (b * f - a * c) / (b * d - a * e)
y = (c - a * x) / b
puts format('%.03f %.03f', x + 0.0, y + 0.0)
end
|
$stdin.each_line do |line|
a, b, c, d, e, f = line.split.map(&:to_f)
x = (b * f - c * e) / (b * d - a * e)
y = (c - a * x) / b
puts format('%.3f %.3f', x + 0.0, y + 0.0)
# puts "#{sprintf("%.3f",x)} #{sprintf("%.3f",y)}"
end
|
[
"expression.operation.binary.remove",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 9,035
| 9,036
|
u461552210
|
ruby
|
p00004
|
$stdin.each_line do |line|
a, b, c, d, e, f = line.split.map(&:to_f)
x = (b * f - a * c) / (b * d - a * e)
y = (c - a * x) / b
puts format('%.03f %.03f', x + 0.0, y + 0.0)
end
|
$stdin.each_line do |line|
a, b, c, d, e, f = line.split.map(&:to_f)
x = (b * f - c * e) / (b * d - a * e)
y = (c - a * x) / b
puts format('%.3f %.3f', x + 0.0, y + 0.0)
end
|
[
"expression.operation.binary.remove",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 9,035
| 9,037
|
u461552210
|
ruby
|
p00004
|
while line = gets
a, b, c, d, e, f = line.split.map(&:to_f)
det = (a * e - b * d) / 1000.0
printf "%.3f %.3f\n", ((c * e - b * f) / det).round / 1000.0, ((a * f - c * d) / det).round / 1000
end
|
while line = gets
a, b, c, d, e, f = line.split.map(&:to_f)
det = (a * e - b * d) / 1000.0
printf "%.3f %.3f\n", ((c * e - b * f) / det).round / 1000.0, ((a * f - c * d) / det).round / 1000.0
end
|
[
"call.arguments.change",
"expression.operation.binary.change"
] | 9,042
| 9,043
|
u960312159
|
ruby
|
p00004
|
require 'English'
while $stdin.gets
a, b, c, d, e, f = $LAST_READ_LINE.split(' ').map(&:to_i)
//
ratio = d.to_i / a
aa = a * ratio
bb = b * ratio
cc = c * ratio
coe_y = bb - e
right = cc - f
y = right / coe_y
//
coe_x = a
right = c - b * y
x = right / coe_x
puts format('%.3f %.3f', x, y)
end
|
require 'English'
while $stdin.gets
a, b, c, d, e, f = $LAST_READ_LINE.split(' ').map(&:to_i)
//
ratio = d.to_f / a
aa = a * ratio
bb = b * ratio
cc = c * ratio
coe_y = bb - e
right = cc - f
y = right / coe_y
//
coe_x = a
right = c - b * y
x = right / coe_x
puts format('%.3f %.3f', x, y)
end
|
[
"call.function.change",
"type_conversion.to_float.change",
"type_conversion.to_number.change"
] | 9,046
| 9,047
|
u680906409
|
ruby
|
p00004
|
require 'matrix'
def solve(line)
a = Matrix[[line[0].to_f, line[1].to_f], [line[3].to_f, line[4].to_f]]
p a
b = Vector[line[2].to_f, line[5].to_f]
p b
s = a.inv * b
s.to_a
end
inputs = []
while (line = gets) != nil
inputs.push(line.split)
end
inputs.each do |i|
s = solve(i)
puts printf('%#0.3f %#0.3f', s[0], s[1])
end
|
require 'matrix'
def solve(line)
a = Matrix[[line[0].to_f, line[1].to_f], [line[3].to_f, line[4].to_f]]
b = Vector[line[2].to_f, line[5].to_f]
s = a.inv * b
s.to_a
end
inputs = []
while (line = gets) != nil
inputs.push(line.split)
end
inputs.each do |i|
s = solve(i)
puts printf('%#0.3f %#0.3f', s[0], s[1])
end
|
[
"call.remove"
] | 9,056
| 9,057
|
u471929490
|
ruby
|
p00004
|
while (line = gets)
a, b, c, d, e, f = line.split.map(&:to_f)
c /= a
b /= a
a /= a
f -= (c * d)
e -= (b * d)
d -= (a * d)
f /= e
d /= e
e /= e
c -= (f * b)
a -= (d * b)
b -= (e * b)
c = (c * (10**3)).round
c = (c * (10**-3)).round
f = (f * (10**3)).round
f = (f * (10**-3)).round
printf("%.3f %.3f\n", c + 0.0, f + 0.0)
end
|
while (line = gets)
a, b, c, d, e, f = line.split.map(&:to_f)
c /= a
b /= a
a /= a
f -= (c * d)
e -= (b * d)
d -= (a * d)
f /= e
d /= e
e /= e
c -= (f * b)
a -= (d * b)
b -= (e * b)
c = (c * (10**3)).round
c = (c * (10**-3))
f = (f * (10**3)).round
f = (f * (10**-3))
printf("%.3f %.3f\n", c + 0.0, f + 0.0)
end
|
[
"call.remove"
] | 9,060
| 9,061
|
u820929609
|
ruby
|
p00004
|
def f(line)
a, b, c, d, e, f = line.split(' ').map(&:to_i)
y = (a * f - d * c) / (a * e - d * b)
x = (c - b * y) / a
format('%.3f %.3f', x, y)
end
while line = gets
puts f(line)
end
|
def f(line)
a, b, c, d, e, f = line.split(' ').map(&:to_f)
y = (a * f - d * c) / (a * e - d * b)
x = (c - b * y) / a
format('%.3f %.3f', x, y)
end
while line = gets
puts f(line)
end
|
[
"call.arguments.change"
] | 9,064
| 9,065
|
u709642619
|
ruby
|
p00004
|
$stdin.each do |value|
a, b, c, d, e, f = value.split.map(&:to_i)
y = ((e * c - b * f) * 1.0 / (a * e - b * d) * 1000).round / 1000.0
x = ((a * f - d * c) * 1.0 / (a * e - b * d) * 1000).round / 1000.0
puts format('%.3f %.3f', x.to_f, y.to_f)
end
|
$stdin.each do |value|
a, b, c, d, e, f = value.split.map(&:to_i)
x = ((e * c - b * f) * 1.0 / (a * e - b * d) * 1000).round / 1000.0
y = ((a * f - d * c) * 1.0 / (a * e - b * d) * 1000).round / 1000.0
puts format('%.3f %.3f', x.to_f, y.to_f)
end
|
[
"assignment.variable.change",
"identifier.change"
] | 9,066
| 9,067
|
u389172382
|
ruby
|
p00004
|
while set = gets
break if set.nil? || (set == "\n") || (set == "\n\r")
a, b, c, d, e, f = set.split.map(&:to_f)
y = (d * c - a * f) / (d * b - a * e)
x = (c - b * y) / a
printf('%.3f %.3f', x, y)
end
|
while set = gets
break if set.nil? || (set == "\n") || (set == "\n\r")
a, b, c, d, e, f = set.split.map(&:to_f)
y = (d * c - a * f) / (d * b - a * e)
x = (c - b * y) / a
printf("%.3f %.3f\n", x, y)
end
|
[] | 9,068
| 9,069
|
u888227825
|
ruby
|
p00006
|
$stdin.gets.chomp.chars.inject([]) { |l, c| l.unshift(c) }.join
|
puts $stdin.gets.chomp.chars.inject([]) { |l, c| l.unshift(c) }.join
|
[
"io.output.change",
"call.add"
] | 11,025
| 11,026
|
u919623882
|
ruby
|
p00006
|
str = gets.chomp
p str.reverse
|
str = gets.chomp.to_s
puts str.reverse
|
[
"assignment.value.change",
"call.add",
"io.output.change"
] | 11,030
| 11,031
|
u828530311
|
ruby
|
p00006
|
str = gets.chomp.to_s
p str.reverse
|
str = gets.chomp.to_s
puts str.reverse
|
[
"call.function.change",
"io.output.change"
] | 11,032
| 11,031
|
u828530311
|
ruby
|
p00006
|
inputTxt = gets.chop
p inputTxt.reverse!
|
inputTxt = $stdin.gets.chomp
puts inputTxt.reverse!
|
[
"call.add"
] | 11,037
| 11,038
|
u789070388
|
ruby
|
p00006
|
inputTxt = $stdin.gets.chomp
p inputTxt.reverse!
|
inputTxt = $stdin.gets.chomp
puts inputTxt.reverse!
|
[
"call.function.change",
"io.output.change"
] | 11,040
| 11,038
|
u789070388
|
ruby
|
p00006
|
def ReverseChar(str)
str_arr = []
rev_str_arr = []
str.each_char do |char|
str_arr << char
end
rev_str_arr = str_arr.reverse
rev_str_arr.join
end
while str = gets.chomp
p ReverseChar(str)
end
|
def ReverseChar(str)
str_arr = []
rev_str_arr = []
str.each_char do |char|
str_arr << char
end
rev_str_arr = str_arr.reverse
rev_str_arr.join
end
str = gets.chomp
puts ReverseChar(str)
|
[
"call.function.change",
"io.output.change"
] | 11,046
| 11,047
|
u791170614
|
ruby
|
p00006
|
gets.chomp.split('').reverse.join
|
puts gets.chomp.split('').reverse.join
|
[
"io.output.change",
"call.add"
] | 11,079
| 11,080
|
u202852666
|
ruby
|
p00006
|
str = gets.split(//).reverse
print(str)
|
str = gets.chomp.reverse
puts(str)
|
[
"call.arguments.change",
"identifier.change"
] | 11,084
| 11,085
|
u753631841
|
ruby
|
p00007
|
n = gets.chomp.to_i
dt = 100_000
n.times do
dt *= 1.05
dt = dt.ceil(-3) if (money % 1000).positive?
end
puts dt
|
n = gets.chomp.to_i
dt = 100_000
n.times do
dt *= 1.05
dt = dt.ceil(-3) if (dt % 1000).positive?
end
puts dt
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 11,219
| 11,220
|
u601881164
|
ruby
|
p00007
|
m = 100_000
n = gets.to_i
n.times { m *= 1.05 }
cut = m % 10_000
m = m - cut + 10_000 if cut.positive?
puts m.to_i
|
m = 100_000
n = gets.to_i
n.times do
m *= 1.05
cut = m % 1000
m = m - cut + 1000 if cut.positive?
end
puts m.to_i
|
[
"literal.number.integer.change",
"expression.operation.binary.change"
] | 11,229
| 11,230
|
u526776155
|
ruby
|
p00007
|
n = gets.to_i
x = 100_000
i = 0
while i < n
x = x * 5 / 100
x = (x / 1000).ceil * 1000
i += 1
end
puts x
|
n = gets.to_i
x = 100_000
i = 0
while i < n
x *= 1.05
x = (x / 1000).ceil * 1000
i += 1
end
puts x
|
[
"expression.operation.binary.remove"
] | 11,231
| 11,232
|
u627848547
|
ruby
|
p00007
|
def week(n)
(n * 1.05 / 1000).ceil * 1000
end
n = gets.chomp.to_i
m = 100_000
n.times do
m = week(m)
puts m
end
puts m
|
def week(n)
(n * 1.05 / 1000).ceil * 1000
end
n = gets.chomp.to_i
m = 100_000
n.times do
m = week(m)
end
puts m
|
[
"call.remove"
] | 11,235
| 11,236
|
u013653135
|
ruby
|
p00007
|
week = gets
bet = 100_000
(1..week.to_i).each do |_i|
bet *= 1.05
bet = (bet * 0.001).ceil * 1000
puts bet
end
|
week = gets
bet = 100_000
(1..week.to_i).each do |_i|
bet *= 1.05
bet = (bet * 0.001).ceil * 1000
end
puts bet
|
[] | 11,237
| 11,238
|
u969530080
|
ruby
|
p00007
|
d = 1e5
gets.to_i.times do
d = (d + d / 20 + 999) / 1000 * 1000
end
p d
|
d = 10**5
gets.to_i.times do
d = (d + d / 20 + 999) / 1000 * 1000
end
p d
|
[
"assignment.value.change"
] | 11,243
| 11,244
|
u376883550
|
ruby
|
p00007
|
d = 1e5
gets.to_i.times do
d = (d + d / 20 + 999) / 1000 * 1000
end
p d
|
d = 10**5
gets.to_i.times { d = (d + d / 20 + 999) / 1000 * 1000 }
p d
|
[
"assignment.value.change"
] | 11,243
| 11,245
|
u376883550
|
ruby
|
p00007
|
n = gets.to_i
base = 100_000
n.times do
base *= 1.05
base = base.to_i
p base
c = base.to_s
loop do
if c.length <= 3
base = (base - c.to_i + 1000) if c.to_i != 0
break
end
c.slice!(0)
end
end
puts base
|
n = gets.to_i
base = 100_000
n.times do
base *= 1.05
base = base.to_i
c = base.to_s
loop do
if c.length <= 3
base = (base - c.to_i + 1000) if c.to_i != 0
break
end
c.slice!(0)
end
end
puts base
|
[
"call.remove"
] | 11,248
| 11,249
|
u861698758
|
ruby
|
p00007
|
n = gets.to_i
m = 100_000
n.times do
m = (m * 1.05).ceil
end
puts m
|
n = gets.to_i
m = 100_000
n.times do
m = (m * 1.05 / 1000).ceil * 1000
end
puts m
|
[
"assignment.change"
] | 11,256
| 11,257
|
u928503227
|
ruby
|
p00008
|
while line = gets
number = line.chomp.to_i
puts 0 if number > 36
counter = 0
(0..9).each do |a|
(0..9).each do |b|
(0..9).each do |c|
(0..9).each do |d|
counter += 1 if (a + b + c + d) == number
end
end
end
end
puts counter
end
|
while line = gets
number = line.chomp.to_i
if number > 36
puts 0
else
counter = 0
(0..9).each do |a|
(0..9).each do |b|
(0..9).each do |c|
(0..9).each do |d|
counter += 1 if (a + b + c + d) == number
end
end
end
end
puts counter
end
end
|
[
"call.remove",
"call.add"
] | 11,481
| 11,482
|
u291317113
|
ruby
|
p00008
|
n = gets.chomp.to_i
ans = 0
i = 0
while i <= 9
j = 0
while j <= 9
k = 0
while k <= 9
l = 0
while l <= 9
ans += 1 if i + j + k + l == n
l += 1
end
k += 1
end
j += 1
end
i += 1
end
puts ans
|
while n = gets
n = n.chomp.to_i
ans = 0
i = 0
while i <= 9
j = 0
while j <= 9
k = 0
while k <= 9
l = 0
while l <= 9
ans += 1 if i + j + k + l == n
l += 1
end
k += 1
end
j += 1
end
i += 1
end
puts ans
end
|
[
"assignment.add"
] | 11,487
| 11,488
|
u910106747
|
ruby
|
p00008
|
cnt = 0
while line = gets
n = line.to_i
if n > 36
puts 0
else
(0..9).each do |a|
(0..9).each do |b|
(0..9).each do |c|
(0..9).each do |d|
cnt += 1 if a + b + c + d == n
end
end
end
end
puts cnt
end
end
|
while line = gets
n = line.to_i
cnt = 0
if n > 36
puts 0
else
(0..9).each do |a|
(0..9).each do |b|
(0..9).each do |c|
(0..9).each do |d|
cnt += 1 if a + b + c + d == n
end
end
end
end
puts cnt
end
end
|
[
"assignment.remove",
"assignment.add"
] | 11,493
| 11,494
|
u141917820
|
ruby
|
p00008
|
$stdin.gets.split("\n").map(&:chomp).map(&:to_i).each do |n|
count = 0
10.times do |a|
10.times do |b|
10.times do |c|
10.times do |d|
count += 1 if a + b + c + d == n
end
end
end
end
puts count
end
|
$stdin.read.split("\n").map(&:chomp).map(&:to_i).each do |n|
count = 0
10.times do |a|
10.times do |b|
10.times do |c|
10.times do |d|
count += 1 if a + b + c + d == n
end
end
end
end
puts count
end
|
[
"identifier.change"
] | 11,495
| 11,496
|
u919623882
|
ruby
|
p00008
|
#!/usr/local/bin/ruby
n = gets.to_i
m = 0
(0..9).to_a.repeated_permutation(4) do |a, b, c, d|
m += 1 if a + b + c + d == n
end
puts m.to_s
|
#!/usr/local/bin/ruby
while line = gets
n = line.to_i
m = 0
(0..9).to_a.repeated_permutation(4) do |a, b, c, d|
m += 1 if a + b + c + d == n
end
puts m.to_s
end
|
[
"assignment.add"
] | 11,505
| 11,506
|
u679425694
|
ruby
|
p00008
|
def fact(n)
if n.zero?
1
else
n * fact(n - 1)
end
end
def c(n, r)
fact(n) / (fact(n - r) * fact(r))
end
def calcCombine(n)
n = 36 - n
if (n >= 0) && (n <= 9)
c(n + 3, 3)
elsif (n >= 10) && (n <= 18)
c(n + 3, 3) - 4 * c(n - 7, 3)
else
0
end
end
input = []
while (line = gets) != nil
input.push(line.to_i)
end
input.each do |i|
puts calcCombine(i)
end
|
def fact(n)
if n.zero?
1
else
n * fact(n - 1)
end
end
def c(n, r)
fact(n) / (fact(n - r) * fact(r))
end
def calcCombine(n)
n = n > 18 ? 36 - n : n
if (n >= 0) && (n <= 9)
c(n + 3, 3)
elsif (n >= 10) && (n <= 18)
c(n + 3, 3) - 4 * c(n - 7, 3)
else
0
end
end
input = []
while (line = gets) != nil
input.push(line.to_i)
end
input.each do |i|
puts calcCombine(i)
end
|
[] | 11,515
| 11,516
|
u471929490
|
ruby
|
p00008
|
count = []
(0..36).each do |num|
count[num] = 0
(0..9).each do |a|
(0..9).each do |b|
(0..9).each do |c|
(0..9).each do |d|
count[num] += 1 if a + b + c + d == n
end
end
end
end
end
def answer(n)
if n.negative? || (n > 36)
0
else
count[n]
end
end
while n = gets
puts answer(n.to_i)
end
|
$count = []
(0..36).each do |num|
$count[num] = 0
(0..9).each do |a|
(0..9).each do |b|
(0..9).each do |c|
(0..9).each do |d|
$count[num] += 1 if a + b + c + d == num
end
end
end
end
end
def answer(n)
if n.negative? || (n > 36)
0
else
$count[n]
end
end
while n = gets
puts answer(n.to_i)
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 11,519
| 11,520
|
u358499277
|
ruby
|
p00010
|
include Math
gets.to_i.times do
x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_i)
a1 = 2 * (x2 - x1)
b1 = 2 * (y2 - y1)
c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2
a2 = 2 * (x3 - x1)
b2 = 2 * (y3 - y1)
c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3
a = sqrt((x2 - x3)**2 + (y2 - y3)**2)
b = sqrt((x3 - x1)**2 + (y3 - y1)**2)
c = sqrt((x1 - x2)**2 + (y1 - y2)**2)
px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
r = (a * b * c) / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c))
printf("%.3f %.3f %.3f\n", px, py, r)
end
|
include Math
gets.to_i.times do
x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
a1 = 2 * (x2 - x1)
b1 = 2 * (y2 - y1)
c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2
a2 = 2 * (x3 - x1)
b2 = 2 * (y3 - y1)
c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3
a = sqrt((x2 - x3)**2 + (y2 - y3)**2)
b = sqrt((x3 - x1)**2 + (y3 - y1)**2)
c = sqrt((x1 - x2)**2 + (y1 - y2)**2)
px = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
py = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
r = (a * b * c) / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c))
printf("%.3f %.3f %.3f\n", px, py, r)
end
|
[
"assignment.value.change",
"call.arguments.change",
"io.output.change"
] | 13,274
| 13,275
|
u196124614
|
ruby
|
p00010
|
def get_long(a, b)
Math.sqrt(a**2 + b**2)
end
def get_rad(a, b, c)
Math.acos((b**2 + c**2 - a**2) / (2 * b * c))
end
gets.to_i.times do
x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
puts a = get_long(x2 - x3, y2 - y3)
puts b = get_long(x3 - x1, y3 - y1)
puts c = get_long(x1 - x2, y1 - y2)
ar = get_rad(a, b, c)
br = get_rad(b, a, c)
cr = get_rad(c, a, b)
puts sin2a = Math.sin(2 * ar)
puts sin2b = Math.sin(2 * br)
puts sin2c = Math.sin(2 * cr)
r = a / (2 * Math.sin(ar))
px = (x1 * sin2a + x2 * sin2b + x3 * sin2c) / (sin2a + sin2b + sin2c)
py = (y1 * sin2a + y2 * sin2b + y3 * sin2c) / (sin2a + sin2b + sin2c)
printf("%.3f %.3f %.3f\n", px, py, r)
end
|
def get_long(a, b)
Math.sqrt(a**2 + b**2)
end
def get_rad(a, b, c)
Math.acos((b**2 + c**2 - a**2) / (2 * b * c))
end
gets.to_i.times do
x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
a = get_long(x2 - x3, y2 - y3)
b = get_long(x3 - x1, y3 - y1)
c = get_long(x1 - x2, y1 - y2)
ar = get_rad(a, b, c)
br = get_rad(b, a, c)
cr = get_rad(c, a, b)
sin2a = Math.sin(2 * ar)
sin2b = Math.sin(2 * br)
sin2c = Math.sin(2 * cr)
r = a / (2 * Math.sin(ar))
px = (x1 * sin2a + x2 * sin2b + x3 * sin2c) / (sin2a + sin2b + sin2c)
py = (y1 * sin2a + y2 * sin2b + y3 * sin2c) / (sin2a + sin2b + sin2c)
printf("%.3f %.3f %.3f\n", px, py, r)
end
|
[
"io.output.change",
"call.remove"
] | 13,280
| 13,281
|
u600321313
|
ruby
|
p00010
|
#!/usr/bin/ruby
gets.to_i.times do
x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
a1 = 2 * x2 - 2 * x1
b1 = 2 * y2 - 2 * y1
c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2
a2 = 2 * x3 - 2 * x1
b2 = 2 * y3 - 2 * y1
c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3
x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
puts format('%.3f %.3f %.3f', x, y, math.hypot(x1 - x, y1 - y))
end
|
#!/usr/bin/ruby
gets.to_i.times do
x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
a1 = 2 * x2 - 2 * x1
b1 = 2 * y2 - 2 * y1
c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2
a2 = 2 * x3 - 2 * x1
b2 = 2 * y3 - 2 * y1
c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3
x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
puts format('%.3f %.3f %.3f', x, y, Math.hypot(x1 - x, y1 - y))
end
|
[
"call.arguments.change"
] | 13,286
| 13,287
|
u300645821
|
ruby
|
p00011
|
class DrawingLots
def initialize(width, switch_ary)
@results = (1..width).to_a
switch_ary.each do |data|
tmp = @results[data[1] - 1]
@results[data[1] - 1] = @results[data[0] - 1]
@results[data[0] - 1] = tmp
end
end
attr_accessor :results
def all_result
@results
end
end
width = gets.to_i
switch_ary = []
gets.to_i.times do
switch_ary << gets.split(',').map(&:to_i)
end
puts DrawingLots.new(width, switch_ary).all_result.join(' ')
|
class DrawingLots
def initialize(width, switch_ary)
@results = (1..width).to_a
switch_ary.each do |data|
tmp = @results[data[1] - 1]
@results[data[1] - 1] = @results[data[0] - 1]
@results[data[0] - 1] = tmp
end
end
attr_accessor :results
def all_result
@results
end
end
width = gets.to_i
switch_ary = []
gets.to_i.times do
switch_ary << gets.split(',').map(&:to_i)
end
puts DrawingLots.new(width, switch_ary).all_result.join("\n")
|
[] | 13,508
| 13,509
|
u543244905
|
ruby
|
p00011
|
w = gets.chomp.to_i
n = gets.chomp.to_i
array = []
a = []
b = []
(1..w).each do |j|
array[j] = j
end
(1..n).each do |_i|
a, b = gets.chomp.split
a = a.to_i
b = b.to_i
(1..w).each do |k|
next unless a == k
x = array[b]
array[b] = array[k]
array[k] = x
end
end
(1..w).each do |s|
puts array[s]
end
|
w = gets.chomp.to_i
n = gets.chomp.to_i
array = []
a = []
b = []
(1..w).each do |j|
array[j] = j
end
(1..n).each do |_i|
a, b = gets.chomp.split(',')
a = a.to_i
b = b.to_i
(1..w).each do |k|
next unless a == k
x = array[b]
array[b] = array[k]
array[k] = x
end
end
(1..w).each do |s|
puts array[s]
end
|
[
"call.arguments.add"
] | 13,511
| 13,512
|
u797339489
|
ruby
|
p00011
|
w = gets.to_i
n = gets.to_i
n_list = []
n.times.each do
st = gets.split(/\s/)
n_list << [st[0].to_i, st[1].to_i]
end
answers = []
1.upto(w).each do |i|
current_w = i
n_list.each do |n_line|
if current_w == n_line[0]
current_w = n_line[1]
elsif current_w == n_line[1]
current_w = n_line[0]
end
end
answers[current_w - 1] = i
end
puts answers
|
w = gets.to_i
n = gets.to_i
n_list = []
n.times.each do
st = gets.split(/,/)
n_list << [st[0].to_i, st[1].to_i]
end
answers = []
1.upto(w).each do |i|
current_w = i
n_list.each do |n_line|
if current_w == n_line[0]
current_w = n_line[1]
elsif current_w == n_line[1]
current_w = n_line[0]
end
end
answers[current_w - 1] = i
end
puts answers
|
[
"assignment.value.change",
"call.arguments.change"
] | 13,513
| 13,514
|
u708217907
|
ruby
|
p00011
|
w = gets.to_i
arr = w.times.map { |i| i + 1 }
gets.to_i.times do
a, b = str.split(',').map(&:to_i)
arr[a - 1], arr[b - 1] = arr[b - 1], arr[a - 1]
end
puts arr
|
w = gets.to_i
arr = w.times.map { |i| i + 1 }
gets.to_i.times do
a, b = gets.split(',').map(&:to_i)
arr[a - 1], arr[b - 1] = arr[b - 1], arr[a - 1]
end
puts arr
|
[
"assignment.value.change",
"identifier.change"
] | 13,515
| 13,516
|
u708217907
|
ruby
|
p00013
|
car = []
while input = gets
input = input.to_i
if input.zero? then puts(car.shift)
else
car.push input
end
end
|
car = []
while input = gets
input = input.to_i
if input.zero? then puts(car.pop)
else
car.push input
end
end
|
[
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 13,873
| 13,874
|
u421423781
|
ruby
|
p00014
|
while data = gets
d = data.to_i
s = 0
loop_num = 1
while loop_num * d >= 600
s += ((loop_num * d)**2) * d
loop_num += 1
end
puts s
end
|
while data = gets
d = data.to_i
s = 0
loop_num = 1
until loop_num * d >= 600
s += ((loop_num * d)**2) * d
loop_num += 1
end
puts s
end
|
[
"control_flow.loop.while.condition.change"
] | 14,077
| 14,078
|
u543244905
|
ruby
|
p00014
|
d = gets.to_i
d_sum = 0
sum = 0
while d_sum < 600
sum += (d_sum**2) * d
d_sum += d
end
puts sum
|
while a = gets
d = a.to_i
d_sum = 0
sum = 0
while d_sum < 600
sum += (d_sum**2) * d
d_sum += d
end
puts sum
end
|
[
"assignment.add"
] | 14,079
| 14,080
|
u215707914
|
ruby
|
p00014
|
while line = gets
width = line.to_i
sum = 0
(600 / width).times do |i|
x = i * d
sum += x**2 * d
end
puts sum
end
|
while line = gets
width = line.to_i
sum = 0
(600 / width).times do |i|
x = i * width
sum += x**2 * width
end
puts sum
end
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change",
"call.arguments.change"
] | 14,085
| 14,086
|
u648595404
|
ruby
|
p00012
|
def vector(x, y)
[y[0] * x[0], y[1] * x[1]]
end
def direction(x, y)
(x[0] * y[1] - x[1] * y[0]).positive? ? :+ : :-
end
$stdin.read.split("\n").each do |input|
a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a
result = [[a, b], [b, c], [c, a]].map do |s, e|
direction(vector(s, e), vector(s, d))
end
puts result.uniq.size == 1 ? 'YES' : 'NO'
end
|
def vector(x, y)
[y[0] - x[0], y[1] - x[1]]
end
def direction(x, y)
(x[0] * y[1] - x[1] * y[0]).positive? ? :+ : :-
end
$stdin.read.split("\n").each do |input|
a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a
result = [[a, b], [b, c], [c, a]].map do |s, e|
direction(vector(s, e), vector(e, d))
end
puts result.uniq.size == 1 ? 'YES' : 'NO'
end
|
[
"expression.operator.arithmetic.change",
"expression.operation.binary.change",
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 14,145
| 14,146
|
u919623882
|
ruby
|
p00012
|
def vector(x, y)
[y[0] * x[0], y[1] * x[1]]
end
def direction(x, y)
(x[0] * y[1] - x[1] * y[0]).positive? ? :+ : :-
end
$stdin.read.split("\n").each do |input|
a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a
result = [[a, b], [b, c], [c, a]].map do |s, e|
direction(vector(s, e), vector(s, d))
end
puts result.uniq.size == 1 ? 'YES' : 'NO'
end
|
def vector(x, y)
[y[0] - x[0], y[1] - x[1]]
end
def direction(x, y)
(x[0] * y[1] - x[1] * y[0]).positive? ? :+ : :-
end
$stdin.read.split("\n").each do |input|
a, b, c, d = input.split(' ').map { |f| f.chomp.to_f }.each_slice(2).to_a
result = [[a, b], [b, c], [c, a]].map do |s, e|
direction(vector(s, e), vector(e, d))
end
puts result.uniq.size == 1 ? 'YES' : 'NO'
end
|
[
"expression.operator.arithmetic.change",
"expression.operation.binary.change",
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 14,147
| 14,146
|
u919623882
|
ruby
|
p00012
|
readlines.each do |l|
x1, y1, x2, y2, x3, y3, xp, yp = l.split.map(&:to_f)
v1x = x2 - x1
v1y = y2 - y1
v2x = x3 - x1
v2y = y3 - y1
vpx = xp - x1
vpy = yp - y1
# (vpx, vpy) = t(v1x, v1y) + u(v2x, v2y)
t = (vpx * v2y - vpy * v2x) / (v1x * v2y - v1y * v2x)
u = (vpx * v1y - vpy * vpx) / (v1y * v2x - v2y * v1x)
if t.positive? && u.positive? && t + u < 1
puts 'YES'
else
puts 'NO'
end
end
|
readlines.each do |l|
x1, y1, x2, y2, x3, y3, xp, yp = l.split.map(&:to_f)
v1x = x2 - x1
v1y = y2 - y1
v2x = x3 - x1
v2y = y3 - y1
vpx = xp - x1
vpy = yp - y1
# (vpx, vpy) = t(v1x, v1y) + u(v2x, v2y)
t = (vpx * v2y - vpy * v2x) / (v1x * v2y - v1y * v2x)
u = (vpx * v1y - vpy * v1x) / (v1y * v2x - v2y * v1x)
if t.positive? && u.positive? && t + u < 1
puts 'YES'
else
puts 'NO'
end
end
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 14,153
| 14,154
|
u662700808
|
ruby
|
p00014
|
#!/usr/local/bin/ruby
def f(x)
x * x
end
while line = gets
d = line.to_i
(0..(600 - 2 * d) / d).each do |_i|
a += d
sum += f(a)
end
ans = sum * d
puts ans.to_s
a = 0
ans = 0
sum = 0
end
|
#!/usr/local/bin/ruby
a = 0
sum = 0
def f(x)
x * x
end
while line = gets
d = line.to_i
(0..(600 - 2 * d) / d).each do |_i|
a += d
sum += f(a)
end
ans = sum * d
puts ans.to_s
a = 0
ans = 0
sum = 0
end
|
[
"assignment.add"
] | 14,291
| 14,292
|
u679425694
|
ruby
|
p00014
|
def square(n)
n * n
end
# main
arr = []
while n = gets
arr << n.to_i
end
p arr
arr.each do |d|
sum = 0
0.upto(600 / d - 1) do |i|
sum += square(i * d) * d
end
puts sum
end
|
def square(n)
n * n
end
# main
arr = []
while n = gets
arr << n.to_i
end
arr.each do |d|
sum = 0
0.upto(600 / d - 1) do |i|
sum += square(i * d) * d
end
puts sum
end
|
[
"call.remove"
] | 14,293
| 14,294
|
u388785927
|
ruby
|
p00009
|
require 'English'
MAX = 1000
prime = Array.new(1_000_001, true)
prime[0] = false
prime[1] = false
(2..MAX).each do |i|
j = i * i
while j < 1_000_000
prime[j] = false
j += i
end
end
while gets
n = $LAST_READ_LINE.to_i
ans = 0
n.times do |i|
ans += 1 if prime[i]
end
puts ans
end
|
require 'English'
MAX = 1000
prime = Array.new(1_000_001, true)
prime[0] = false
prime[1] = false
(2..MAX).each do |i|
j = i * i
while j < 1_000_000
prime[j] = false
j += i
end
end
while gets
n = $LAST_READ_LINE.to_i
ans = 0
(2..n).each do |i|
ans += 1 if prime[i]
end
puts ans
end
|
[
"call.add"
] | 14,434
| 14,435
|
u373127758
|
ruby
|
p00009
|
require 'prime'
primes = Prime.each(999_999)
while (l = gets)
puts primes.count { |p| p < l.to_i }
end
|
require 'prime'
primes = Prime.each(999_999).to_a
while (l = gets)
puts primes.count { |p| p <= l.to_i }
end
|
[
"call.add",
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 14,436
| 14,437
|
u348111249
|
ruby
|
p00009
|
require 'prime'
primes = Prime.each(999_999).to_a
while (l = gets)
puts primes.count { |p| p < l.to_i }
end
|
require 'prime'
primes = Prime.each(999_999).to_a
while (l = gets)
puts primes.count { |p| p <= l.to_i }
end
|
[
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 14,438
| 14,437
|
u348111249
|
ruby
|
p00009
|
require 'Prime'
while s = gets
puts Prime.each(s.to_i).to_a.size
end
|
require 'prime'
while s = gets
puts Prime.each(s.to_i).count
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"identifier.change",
"call.remove"
] | 14,443
| 14,444
|
u362869314
|
ruby
|
p00009
|
require 'Prime'
while s = gets
puts Prime.each(s.to_i).count
end
|
require 'prime'
while s = gets
puts Prime.each(s.to_i).count
end
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change"
] | 14,445
| 14,444
|
u362869314
|
ruby
|
p00009
|
$stdin.read.split("\n").map { |i| i.chomp.to_i }.each do |max|
table = Array.new(max + 1, true)
prime_list = []
(2..max).each do |num|
prime_list << num if table[num] == true
k = num * num
while k <= max
table[k] = false
k += num
end
end
prime_list.count
end
|
$stdin.read.split("\n").map { |i| i.chomp.to_i }.each do |max|
table = Array.new(max + 1, true)
prime_list = []
(2..max).each do |num|
prime_list << num if table[num] == true
k = num * num
while k <= max
table[k] = false
k += num
end
end
puts prime_list.count
end
|
[
"io.output.change",
"call.add"
] | 14,446
| 14,447
|
u919623882
|
ruby
|
p00009
|
require 'English'
def get_prime_list(n)
sn = (n**0.5).to_i
is_prime = [false, false] + [true] * (n - 1)
(2..sn).each do |i|
next unless is_prime[i]
(i * i).step(n, i) do |j|
is_prime[j] = false
end
end
(2..n).to_a.select { |i| is_prime[i] }
end
list = get_prime_list(999_999)
while gets
max = $LAST_READ_LINE.to_i
puts list.select { |nu| nu < max }.count
end
|
require 'English'
def get_prime_list(n)
sn = (n**0.5).to_i
is_prime = [false, false] + [true] * (n - 1)
(2..sn).each do |i|
next unless is_prime[i]
(i * i).step(n, i) do |j|
is_prime[j] = false
end
end
(2..n).to_a.select { |i| is_prime[i] }
end
list = get_prime_list(999_999)
while gets
max = $LAST_READ_LINE.to_i
puts list.select { |nu| nu <= max }.count
end
|
[
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 14,454
| 14,453
|
u708217907
|
ruby
|
p00009
|
require 'prime'
gets.split.map(&:to_i).each do |i|
puts Prime.each(i).to_a.size
end
|
require 'prime'
while l = gets
l.split.map(&:to_i).each do |i|
puts Prime.each(i).to_a.size
end
end
|
[
"call.add"
] | 14,461
| 14,462
|
u401720175
|
ruby
|
p00015
|
n = gets.to_i
n.times do
a = gets.to_i
b = gets.to_i
c = a + b
c = c.to_s
if c.length >= 80
puts 'overflow'
else
puts c
end
end
|
n = gets.to_i
n.times do
a = gets.to_i
b = gets.to_i
c = a + b
c = c.to_s
if c.length > 80
puts 'overflow'
else
puts c
end
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 15,142
| 15,143
|
u819979588
|
ruby
|
p00015
|
gets.to_i.times do
a = gets.chomp.split(//).reverse
b = gets.chomp.split(//).reverse
if (a.length > 80) || (b.length > 80)
p 'overflow'
else
a.push(*Array.new(80 - a.length, 0))
b.push(*Array.new(80 - b.length, 0))
result = []
temp = 0
80.times do |i|
result.unshift((a[i].to_i + b[i].to_i + temp) % 10)
temp = ((a[i].to_i + b[i].to_i + temp) / 10)
end
if temp.zero?
p result.join.to_i
else
p 'overflow'
end
end
end
|
gets.to_i.times do
a = gets.chomp.split(//).reverse
b = gets.chomp.split(//).reverse
if (a.length > 80) || (b.length > 80)
puts 'overflow'
else
a.push(*Array.new(80 - a.length, 0))
b.push(*Array.new(80 - b.length, 0))
result = []
temp = 0
80.times do |i|
result.unshift((a[i].to_i + b[i].to_i + temp) % 10)
temp = ((a[i].to_i + b[i].to_i + temp) / 10)
end
if temp.zero?
puts result.join.to_i
else
puts 'overflow'
end
end
end
|
[
"call.function.change",
"io.output.change"
] | 15,144
| 15,145
|
u514597327
|
ruby
|
p00015
|
def writeSum
number1 = gets.to_i
number2 = gets.to_i
sum = number1 + number2
if sum >= 10 ** 81
puts "overflow"
else
puts sum
end
end
dataSet = gets.to_i
1.upto(dataSet) do |i|
writeSum()
end
|
def writeSum
number1 = gets.to_i
number2 = gets.to_i
sum = number1 + number2
if sum >= 10 ** 80
puts "overflow"
else
puts sum
end
end
dataSet = gets.to_i
1.upto(dataSet) do |i|
writeSum()
end
|
[
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 15,152
| 15,153
|
u414533604
|
ruby
|
p00015
|
n = gets.to_i
n.times do
s = (gets.to_i + gets.to_i).to_s
puts s.length >= 80 ? 'overflow' : s
end
|
n=gets.to_i
n.times{
s=(gets.to_i+gets.to_i).to_s
puts s.length>80 ? "overflow":s
}
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 15,160
| 15,161
|
u861698758
|
ruby
|
p00015
|
n=gets.to_i
n.times{
s=(gets.to_i+gets.to_i)
puts s>10**80 ? "overflow":s
}
|
n = gets.to_i
n.times do
s = (gets.to_i + gets.to_i)
puts s >= 10**80 ? 'overflow' : s
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 15,162
| 15,163
|
u861698758
|
ruby
|
p00015
|
gets.chomp.to_i.times do
a = gets.to_i
b = gets.to_i
if (sum = a + b) > 10**80
puts 'overflow'
else
puts sum
end
end
|
gets.chomp.to_i.times do
a = gets.to_i
b = gets.to_i
if (sum = a + b) >= 10**80
puts 'overflow'
else
puts sum
end
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 15,164
| 15,165
|
u919623882
|
ruby
|
p00015
|
n = gets.to_i
(0...n).each do |_x|
a = gets.to_i
b = gets.to_i
c = a + b
ans = c.to_s.length > 80 ? 'overflow' : c
p ans
end
|
n = gets.to_i
(0...n).each do |x|
a = gets.to_i
b = gets.to_i
c = a+b
ans = (c.to_s.length > 80) ? "overflow" : c
puts ans
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change",
"literal.string.change",
"assignment.value.change",
"call.function.change",
"io.output.change"
] | 15,170
| 15,171
|
u577850777
|
ruby
|
p00015
|
(n=gets.to_i).times{puts((a=gets.to_i+gets.to_i)>=10**80?"overfllow":a)}
|
(n=gets.to_i).times{puts((a=gets.to_i+gets.to_i)>=10**80?"overflow":a)}
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 15,173
| 15,174
|
u183179710
|
ruby
|
p00015
|
n = gets.to_i
n.times do
sum = gets.to_i + gets.to_i
puts sum.size >= 80 ? 'overflow' : sum
end
|
n = gets.to_i
n.times do
sum = gets.to_i + gets.to_i
puts sum.to_s.length >= 81 ? 'overflow' : sum
end
|
[
"identifier.change",
"control_flow.branch.if.condition.change",
"call.add",
"literal.number.integer.change"
] | 15,177
| 15,178
|
u708217907
|
ruby
|
p00015
|
n = gets.to_i
1.upto(n) do |i|
sum = gets.to_i + gets.to_i
puts sum.size > 80 ? 'overflow' : sum
end
# ruby <3
|
n = gets.to_i
1.upto(n) do |_i|
sum = gets.to_i + gets.to_i
puts sum.to_s.size > 80 ? 'overflow' : sum
end
# ruby <3
|
[
"identifier.change",
"control_flow.branch.if.condition.change",
"call.add"
] | 15,182
| 15,183
|
u585414111
|
ruby
|
p00015
|
num = gets.to_i
while num > 0
num1 = gets.to_i
num2 = gets.to_i
ans = num2+num1
if ans >= 10e80 then
puts "overflow"
else
puts ans
end
num = num - 1
end
|
num = gets.to_i
while num > 0
num1 = gets.to_i
num2 = gets.to_i
ans = num2+num1
if ans >= 100000000000000000000000000000000000000000000000000000000000000000000000000000000 then
puts "overflow"
else
puts ans
end
num = num - 1
end
|
[
"control_flow.branch.if.condition.change"
] | 15,184
| 15,185
|
u398354652
|
ruby
|
p00015
|
num = gets.to_i
while num > 0
num1 = gets.to_i
num2 = gets.to_i
ans = num2+num1
if ans >= 10e80 then
puts "overflow"
else
puts ans
end
num = num - 1
end
|
num = gets.to_i
while num > 0
num1 = gets.to_i
num2 = gets.to_i
ans = num2+num1
if ans >= 10**80 then
puts "overflow"
else
puts ans
end
num = num - 1
end
|
[
"control_flow.branch.if.condition.change"
] | 15,184
| 15,186
|
u398354652
|
ruby
|
p00015
|
gets.to_i.times do
sum = gets.to_i + gets.to_i
puts 10**80 < sum ? 'overflow' : sum
end
|
gets.to_i.times do
sum = gets.to_i + gets.to_i
puts 10**80 <= sum ? 'overflow' : sum
end
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 15,188
| 15,189
|
u517414491
|
ruby
|
p00016
|
class TreasureHunter
def initialize
@x = 0
@y = 0
@deg = 0
end
def to_rad(deg)
return Math::PI * deg / 180.0
end
def walk(distance)
@x += Math.sin(to_rad(@deg)) * distance
@y += Math.cos(to_rad(@deg)) * distance
end
def turn(direction)
@deg += direction
end
def dumpXY
return [@x.floor, @y.floor]
end
end
t = TreasureHunter.new
$<.each_line do |line|
distance, direction = line.split(/,/).map(&:to_i)
t.walk(distance)
t.turn(direction)
end
puts t.dumpXY
|
class TreasureHunter
def initialize
@x = 0
@y = 0
@deg = 0
end
def to_rad(deg)
return Math::PI * deg / 180.0
end
def walk(distance)
@x += Math.sin(to_rad(@deg)) * distance
@y += Math.cos(to_rad(@deg)) * distance
end
def turn(direction)
@deg += direction
end
def dumpXY
return [@x.to_i, @y.to_i]
end
end
t = TreasureHunter.new
$<.each_line do |line|
distance, direction = line.split(/,/).map(&:to_i)
t.walk(distance)
t.turn(direction)
end
puts t.dumpXY
|
[
"identifier.change",
"call.arguments.change",
"function.return_value.change"
] | 15,387
| 15,388
|
u347010700
|
ruby
|
p00016
|
class Sambonmatsu
def initialize
@x = 0
@y = 0
@direct = 90
end
def calc
while(input = $stdin.gets) do
direct, rotate = input.chomp.split(',').map(&:to_i)
if direct == 0 && rotate == 0
break
end
step(direct)
@direct -= rotate
end
puts @x.round
puts @y.round
end
def step(direct)
thita = (@direct/360.0)*2*Math::PI
@x += direct*Math.cos(thita)
@y += direct*Math.sin(thita)
end
end
s = Sambonmatsu.new
s.calc
|
class Sambonmatsu
def initialize
@x = 0
@y = 0
@direct = 90
end
def calc
while(input = $stdin.gets) do
direct, rotate = input.chomp.split(',').map(&:to_i)
if direct == 0 && rotate == 0
break
end
step(direct)
@direct -= rotate
end
puts @x.truncate
puts @y.truncate
end
def step(direct)
thita = (@direct/360.0)*2*Math::PI
@x += direct*Math.cos(thita)
@y += direct*Math.sin(thita)
end
end
s = Sambonmatsu.new
s.calc
|
[
"identifier.change",
"call.arguments.change",
"io.output.change"
] | 15,389
| 15,390
|
u470949294
|
ruby
|
p00016
|
include "Math"
x, y = 0, 0
s = 90
while true
d, si = gets.chomp.split(",").map(&:to_i)
break if d == 0 && si == 0
x += d * cos(2 * PI * s / 360)
y += d * sin(2 * PI * s / 360)
s += si
end
puts x.truncate
puts y.truncate
|
include Math
x, y = 0, 0
s = 90
while true
d, si = gets.chomp.split(",").map(&:to_f)
break if d == 0 && si == 0
x += d * cos(2 * PI * s / 360)
y += d * sin(2 * PI * s / 360)
s -= si
end
puts x.truncate
puts y.truncate
|
[
"call.arguments.change",
"assignment.value.change",
"expression.operator.change"
] | 15,391
| 15,392
|
u202852666
|
ruby
|
p00016
|
include Math
x, y = 0, 0
s = 90
while true
d, si = gets.chomp.split(",").map(&:to_i)
break if d == 0 && si == 0
x += d * cos(2 * PI * s / 360)
y += d * sin(2 * PI * s / 360)
s += si
end
puts x.truncate
puts y.truncate
|
include Math
x, y = 0, 0
s = 90
while true
d, si = gets.chomp.split(",").map(&:to_f)
break if d == 0 && si == 0
x += d * cos(2 * PI * s / 360)
y += d * sin(2 * PI * s / 360)
s -= si
end
puts x.truncate
puts y.truncate
|
[
"assignment.value.change",
"call.arguments.change",
"expression.operator.change"
] | 15,393
| 15,392
|
u202852666
|
ruby
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.