Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p00000
def cal (1..9).each do |x| (1..9).each do |y| puts "#{x}*#{y}=#{x * y}" end end end cal
def cal (1..9).each do |x| (1..9).each do |y| puts "#{x}x#{y}=#{x * y}" end end end cal
null
4,622
4,623
u776760522
ruby
p00000
1.upto(9) do |i| 1.upto(9) do |j| puts "#{i}*#{j}=#{i * j}" end end
1.upto(9) do |i| 1.upto(9) do |j| puts "#{i}x#{j}=#{i * j}" end end
null
4,651
4,652
u398011154
ruby
p00003
gets.to_i.times do a, b, c = gets.split.map(&:to_i).sort puts a * a + b * b == c * c ? 'OK' : 'NG' end
gets.to_i.times do a, b, c = gets.split.map(&:to_i).sort puts a * a + b * b == c * c ? 'YES' : 'NO' end
null
6,907
6,908
u843977395
ruby
p00003
finish = gets.chomp i = 0 answer = [] while i < finish.to_i array = gets.split array[0], array[1] = array[1], array[0] if array[0].to_i > array[1].to_i array[1], array[2] = array[2], array[1] if array[1].to_i > array[2].to_i array[0], array[1] = array[1], array[0] if array[0].to_i > array[1].to_i answer[i] = if array[2].to_i**2 == array[0].to_i**2 + array[1].to_i**2 'Yes' else 'No' end i += 1 end puts answer
finish = gets.chomp i = 0 answer = [] while i < finish.to_i array = gets.split array[0], array[1] = array[1], array[0] if array[0].to_i > array[1].to_i array[1], array[2] = array[2], array[1] if array[1].to_i > array[2].to_i array[0], array[1] = array[1], array[0] if array[0].to_i > array[1].to_i answer[i] = if array[2].to_i**2 == array[0].to_i**2 + array[1].to_i**2 'YES' else 'NO' end i += 1 end puts answer
null
6,864
6,865
u949338836
ruby
p00004
while line = gets a, b, c, d, e, f = line.split.map(&:to_f) x = Relatinal(b * f - c * e, b * d - a * e) y = Relatinal(a * f - d * c, a * e - b * d) printf "%.3f %.3f\n", x, y end
while line = gets a, b, c, d, e, f = line.split.map(&:to_f) x = Rational(b * f - c * e, b * d - a * e) y = Rational(a * f - d * c, a * e - b * d) printf "%.3f %.3f\n", x, y end
null
9,008
9,009
u334460795
ruby
p00004
while line = gets puts line a, b, c, d, e, f = line.split.map(&:to_f) x = (c * e - b * f) / (a * e - b * d) y = (a * f - c * d) / (a * e - b * d) puts "#{format('%.3f', x.round(3) + 0)} #{format('%.3f', y.round(3) + 0)}" end
while line = gets a, b, c, d, e, f = line.split.map(&:to_f) x = (c * e - b * f) / (a * e - b * d) y = (a * f - c * d) / (a * e - b * d) puts "#{format('%.3f', x.round(3) + 0)} #{format('%.3f', y.round(3) + 0)}" end
null
9,038
9,039
u670581076
ruby
p00006
puts gets.chop
puts gets.chop.reverse
null
10,987
10,985
u188882971
ruby
p00007
money = 100_000 weeks = gets.to_i 1.upto(weeks) do |_i| money = (money * 1.05).to_i money = (money / 1000).ceil * 1000 end puts money
money = 100_000 weeks = gets.to_i 1.upto(weeks) do |_i| money = (money * 1.05) money = (money / 1000).ceil * 1000 end puts money
null
11,223
11,224
u414533604
ruby
p00010
def get_circle_equation(x, y) [x, y, 1, x**2 + y**2] end def get_invers_matrix(m) det = m[0][0] * m[1][1] * m[2][2] + m[0][1] * m[1][2] * m[2][0] + m[1][0] * m[2][1] * m[0][2] det -= m[0][2] * m[1][1] * m[2][0] + m[0][1] * m[1][0] * m[2][2] + m[1][2] * m[2][1] * m[0][0] v1 = [m[1][1] * m[2][2] - m[1][2] * m[2][1], m[0][2] * m[2][1] - m[0][1] * m[2][2], m[0][1] * m[1][2] - m[0][2] * m[1][1]] v2 = [m[1][2] * m[1][0] - m[1][0] * m[2][2], m[0][0] * m[2][2] - m[0][2] * m[2][0], m[0][2] * m[1][0] - m[0][0] * m[1][2]] v3 = [m[1][0] * m[2][1] - m[1][1] * m[2][0], m[0][1] * m[2][0] - m[0][0] * m[2][1], m[0][0] * m[1][1] - m[0][1] * m[1][0]] v1 = v1.map { |i| i / det } v2 = v2.map { |i| i / det } v3 = v3.map { |i| i / det } [v1, v2, v3] end def mluti(m1, m2) v1 = m1[0][0] * m2[0] + m1[0][1] * m2[1] + m1[0][2] * m2[2] v2 = m1[1][0] * m2[0] + m1[1][1] * m2[1] + m1[1][2] * m2[2] v3 = m1[2][0] * m2[0] + m1[2][1] * m2[1] + m1[2][2] * m2[2] [v1, v2, v3] end n = gets.to_i n.times do x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f) e1 = get_circle_equation(x1, y1) e2 = get_circle_equation(x2, y2) e3 = get_circle_equation(x3, y3) matrix = [e1[0..2], e2[0..2], e3[0..2]] invers_matrix = get_invers_matrix(matrix) vec = mluti(invers_matrix, [e1[3], e2[3], e3[3]]) center = [vec[0] / 2, vec[1] / 2] r = Math.sqrt((x1 - center[0])**2 + (y1 - center[1])**2) puts format('%.3f %.3f %.3f', center[0].round(3), center[1].round(3), r.round(3)) # puts "#{center[0].round(3)} #{center[0].round(3)} #{r.round(3)}" end
def get_circle_equation(x, y) [x, y, 1, x**2 + y**2] end def get_invers_matrix(m) det = m[0][0] * m[1][1] * m[2][2] + m[0][1] * m[1][2] * m[2][0] + m[1][0] * m[2][1] * m[0][2] det -= m[0][2] * m[1][1] * m[2][0] + m[0][1] * m[1][0] * m[2][2] + m[1][2] * m[2][1] * m[0][0] v1 = [m[1][1] * m[2][2] - m[1][2] * m[2][1], m[0][2] * m[2][1] - m[0][1] * m[2][2], m[0][1] * m[1][2] - m[0][2] * m[1][1]] v2 = [m[1][2] * m[2][0] - m[1][0] * m[2][2], m[0][0] * m[2][2] - m[0][2] * m[2][0], m[0][2] * m[1][0] - m[0][0] * m[1][2]] v3 = [m[1][0] * m[2][1] - m[1][1] * m[2][0], m[0][1] * m[2][0] - m[0][0] * m[2][1], m[0][0] * m[1][1] - m[0][1] * m[1][0]] v1 = v1.map { |i| i / det } v2 = v2.map { |i| i / det } v3 = v3.map { |i| i / det } [v1, v2, v3] end def mluti(m1, m2) v1 = m1[0][0] * m2[0] + m1[0][1] * m2[1] + m1[0][2] * m2[2] v2 = m1[1][0] * m2[0] + m1[1][1] * m2[1] + m1[1][2] * m2[2] v3 = m1[2][0] * m2[0] + m1[2][1] * m2[1] + m1[2][2] * m2[2] [v1, v2, v3] end n = gets.to_i n.times do x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f) e1 = get_circle_equation(x1, y1) e2 = get_circle_equation(x2, y2) e3 = get_circle_equation(x3, y3) matrix = [e1[0..2], e2[0..2], e3[0..2]] invers_matrix = get_invers_matrix(matrix) vec = mluti(invers_matrix, [e1[3], e2[3], e3[3]]) center = [vec[0] / 2, vec[1] / 2] r = Math.sqrt((x1 - center[0])**2 + (y1 - center[1])**2) puts format('%.3f %.3f %.3f', center[0].round(3), center[1].round(3), r.round(3)) end
null
13,276
13,277
u750346935
ruby
p00012
# coding:utf-8 EPS = 1e-3 class Point def initialize(args) @x = args[0] @y = args[1] end attr_reader :x, :y end until $stdin.eof? str = gets.chomp.split(' ').map(&:to_f) # p str a = Point.new(str[0, 2]) b = Point.new(str[2, 2]) c = Point.new(str[4, 2]) p = Point.new(str[6, 2]) ab = Point.new([b.x - a.x, b.y - a.y]) bc = Point.new([c.x - b.x, c.y - b.y]) ca = Point.new([a.x - c.x, a.y - c.y]) ap = Point.new([p.x - a.x, p.y - a.y]) bp = Point.new([p.x - b.x, p.y - b.y]) cp = Point.new([p.x - c.x, p.y - c.y]) # 外積を求める puts abap = ab.x * ap.y - ab.y * ap.x puts bcbp = bc.x * bp.y - bc.y * bp.x puts cacp = ca.x * cp.y - ca.y * cp.x if abap.zero? || bcbp.zero? || cacp.zero? then puts 'NO' elsif (abap * bcbp).negative? || (abap * cacp).negative? || (bcbp * cacp).negative? then puts 'NO' else puts 'YES' end puts end
# coding:utf-8 EPS = 1e-3 class Point def initialize(args) @x = args[0] @y = args[1] end attr_reader :x, :y end until $stdin.eof? str = gets.chomp.split(' ').map(&:to_f) # p str a = Point.new(str[0, 2]) b = Point.new(str[2, 2]) c = Point.new(str[4, 2]) p = Point.new(str[6, 2]) ab = Point.new([b.x - a.x, b.y - a.y]) bc = Point.new([c.x - b.x, c.y - b.y]) ca = Point.new([a.x - c.x, a.y - c.y]) ap = Point.new([p.x - a.x, p.y - a.y]) bp = Point.new([p.x - b.x, p.y - b.y]) cp = Point.new([p.x - c.x, p.y - c.y]) # 外積を求める abap = ab.x * ap.y - ab.y * ap.x bcbp = bc.x * bp.y - bc.y * bp.x cacp = ca.x * cp.y - ca.y * cp.x if abap.zero? || bcbp.zero? || cacp.zero? then puts 'NO' elsif (abap * bcbp).negative? || (abap * cacp).negative? || (bcbp * cacp).negative? then puts 'NO' else puts 'YES' end end
null
14,141
14,142
u659663128
ruby
p00015
gets.chomp.to_i.times do a = gets.chomp.to_i; b = gets.chomp.to_i sum = a + b if sum.to_s.length >= 80 puts "overflow" else puts sum end end
gets.chomp.to_i.times do a = gets.chomp.to_i; b = gets.chomp.to_i sum = a + b if sum.to_s.length > 80 puts "overflow" else puts sum end end
null
15,158
15,159
u261074410
ruby
p00015
n=gets().to_i n.times(){|i| a=gets().to_i b=gets().to_i if a+b>=10**81 puts'overfrow' else puts a+b end }
n=gets().to_i n.times(){|i| a=gets().to_i b=gets().to_i if a+b>=10**80 puts'overflow' else puts a+b end }
null
15,166
15,167
u646183247
ruby
p00030
def count(limit, max, n, queue, black_list) if queue.size == limit if queue.inject(:+) == max return 1 else return 0 end end result = 0 (0..9).step do |i| next if queue.include?(i) queue << i if black_list.include?(queue.sort) queue.pop next end black_list << queue.sort result += count(limit, max, result, queue, black_list) queue.pop end result end def bfs while gets limit, max = $_.split.map(&:to_i) break if limit == 0 && max == 0 puts count(limit, max, 0, [], []) end end
def count(limit, max, n, queue, black_list) if queue.size == limit if queue.inject(:+) == max return 1 else return 0 end end result = 0 (0..9).step do |i| next if queue.include?(i) queue << i if black_list.include?(queue.sort) queue.pop next end black_list << queue.sort result += count(limit, max, result, queue, black_list) queue.pop end result end def bfs while gets limit, max = $_.split.map(&:to_i) break if limit == 0 && max == 0 puts count(limit, max, 0, [], []) end end bfs
null
22,311
22,312
u919623882
ruby
p00044
$primes = [2,3] def is_prime?(n) i = 0 while $primes[i] <= Math.sqrt(n).to_i return false if n % $primes[i] == 0 i += 1 end return true end def next_prime(n) n += 1 if n % 2 == 0 loop do return n if is_prime?(n) n += 2 end end def make_prime(n) while $primes[-1] <= n $primes << next_prime($primes[-1]+1) end end def print_prime(n) if is_prime?(n) i = $primes.index(n) puts "#{$primes[i-1]} #{$primes[i+1]}" else i = 0 i += 1 while $primes[i] < n print "#{$primes[i-1]} #{$primes[i]}" end puts "" end while gets n = $_.to_i if n < 3 || 50000 < n puts "n must be in the range (3..50000)" next end make_prime(n) if $primes[-2] < n print_prime(n) end
$primes = [2,3] def is_prime?(n) i = 0 while $primes[i] <= Math.sqrt(n).to_i return false if n % $primes[i] == 0 i += 1 end return true end def next_prime(n) n += 1 if n % 2 == 0 loop do return n if is_prime?(n) n += 2 end end def make_prime(n) while $primes[-1] <= n $primes << next_prime($primes[-1]+1) end end def print_prime(n) if is_prime?(n) i = $primes.index(n) puts "#{$primes[i-1]} #{$primes[i+1]}" else i = 0 i += 1 while $primes[i] < n puts "#{$primes[i-1]} #{$primes[i]}" end end while gets n = $_.to_i if n < 3 || 50000 < n puts "n must be in the range (3..50000)" next end make_prime(n) if $primes[-2] < n print_prime(n) end
null
24,485
24,486
u881491942
ruby
p00044
$primes = [2,3] def is_prime?(n) i = 0 while $primes[i] <= Math.sqrt(n).to_i return false if n % $primes[i] == 0 i += 1 end return true end def next_prime(n) n += 1 if n % 2 == 0 loop do return n if is_prime?(n) n += 2 end end def make_prime(n) while $primes[-1] <= n $primes << next_prime($primes[-1]+1) end end def print_prime(n) if is_prime?(n) i = $primes.index(n) puts "#{$primes[i-1]} #{$primes[i+1]}" else i = 0 i += 1 while $primes[i] < n puts "#{$primes[i-1]} #{$primes[i]}" end puts "" end while gets n = $_.to_i if n < 3 || 50000 < n puts "n must be in the range (3..50000)" next end make_prime(n) if $primes[-2] < n print_prime(n) end
$primes = [2,3] def is_prime?(n) i = 0 while $primes[i] <= Math.sqrt(n).to_i return false if n % $primes[i] == 0 i += 1 end return true end def next_prime(n) n += 1 if n % 2 == 0 loop do return n if is_prime?(n) n += 2 end end def make_prime(n) while $primes[-1] <= n $primes << next_prime($primes[-1]+1) end end def print_prime(n) if is_prime?(n) i = $primes.index(n) puts "#{$primes[i-1]} #{$primes[i+1]}" else i = 0 i += 1 while $primes[i] < n puts "#{$primes[i-1]} #{$primes[i]}" end end while gets n = $_.to_i if n < 3 || 50000 < n puts "n must be in the range (3..50000)" next end make_prime(n) if $primes[-2] < n print_prime(n) end
null
24,487
24,486
u881491942
ruby
p00075
readlines.each do |l| (n,w,h)=s.split(/,/).map(&:to_f) puts n.to_i if w/(h**2) >= 25 end
readlines.each do |s| (n,w,h)=s.split(/,/).map(&:to_f) puts n.to_i if w/(h**2) >= 25 end
null
29,509
29,510
u854447110
ruby
p00227
loop do n, m = gets.split.map(&:to_i) break if n == 0 && m == 0 p = gets.split.map(&:to_i) ans = 0 p.each_slice(m) do |a| ans += a.inject(:+) ans -= a.pop if a.size == m end puts ans end
loop do n, m = gets.split.map(&:to_i) break if n == 0 && m == 0 p = gets.split.map(&:to_i).sort.reverse ans = 0 p.each_slice(m) do |a| ans += a.inject(:+) ans -= a.pop if a.size == m end puts ans end
null
43,274
43,275
u672005134
ruby
p00272
data = Array.new(4) i = 0 #p data =begin File.open("test/0277","r") do |input| while data[i] = input.gets do #p data[i] i += 1 end end =end while data[i] = input.gets do #p data[i] i += 1 end for i in data if i == nil break end a,b = (i.chomp).split(" ").map(&:to_i) case a when 1 a = 6000 when 2 a = 4000 when 3 a = 3000 when 4 a = 2000 end p a*b end
data = Array.new(4) i = 0 #p data =begin File.open("test/0277","r") do |input| while data[i] = input.gets do #p data[i] i += 1 end end =end while data[i] = gets do #p data[i] i += 1 end for i in data if i == nil break end a,b = (i.chomp).split(" ").map(&:to_i) case a when 1 a = 6000 when 2 a = 4000 when 3 a = 3000 when 4 a = 2000 end p a*b end
null
45,416
45,417
u222957942
ruby
p00424
table = Hash::new n = gets.to_i() while(n!=0) str="" n.times do a = gets.split(" ") table[a[0].strip] = a[1].strip end m = gets.to_i() m.times do c = gets.chomp.strip if(table[c]!=nil) c = table[c] end str.concat(c) end puts str n = gets.to_i() end
table = Hash::new n = gets.to_i() while(n!=0) str="" table.clear n.times do a = gets.split(" ") table[a[0].strip] = a[1].strip end m = gets.to_i() m.times do c = gets.chomp.strip if(table[c]!=nil) c = table[c] end str.concat(c) end puts str n = gets.to_i() end
null
50,118
50,119
u574548096
ruby
p02388
input = gets.chomp puts input ** 3
input = gets.chomp.to_i puts input ** 3
null
142,740
142,741
u092148725
ruby
p02389
n1,n2 = gets.split(" ").map(&:to_i) p "#{n1*n2} #{(n1+n2)*2}"
n1,n2 = gets.split(" ").map(&:to_i) puts "#{n1*n2} #{(n1+n2)*2}"
null
147,898
147,899
u818068308
ruby
p02389
a, b = *gets.split(/ /).map(&:to_i) print a*a, " ", a*2+b+2, "\n"
a, b = *gets.split(/ /).map(&:to_i) print a*b, " ", a*2+b*2, "\n"
null
148,962
148,961
u277379271
ruby
p02389
a, b = *gets.split(/ /).map(&:to_i) print a*a, " ", a*2+b*2, "\n"
a, b = *gets.split(/ /).map(&:to_i) print a*b, " ", a*2+b*2, "\n"
null
148,963
148,961
u277379271
ruby
p02389
a, b = gets.chomp.split.map(&:to_i) puts "#{a*b} #{a**2+b**2}"
a, b = gets.chomp.split.map(&:to_i) puts "#{a*b} #{a*2+b*2}"
null
148,964
148,965
u216813029
ruby
p02389
x = gets.split a = x[0].to_i b = x[0].to_i m = a * b n = (a + b) * 2 puts "#{m} #{n}"
x = gets.split a = x[0].to_i b = x[1].to_i m = a * b n = (a + b) * 2 puts "#{m} #{n}"
null
149,011
149,012
u070534809
ruby
p02390
t = gets.to_i h = t / 3600 m = (t - h * 3600) / 60 s = t - (h * 3600 + m * 60) puts("#{h}:#{m}:#{t}")
t = gets.to_i h = t / 3600 m = (t - h * 3600) / 60 s = t - (h * 3600 + m * 60) puts("#{h}:#{m}:#{s}")
null
152,498
152,499
u750346935
ruby
p02390
a = gets().to_i h = a.div(3600) a = a.modulo(3600) m = a.div(60) a = a.modulo(60) s = a print("#{h};#{m};#{s}\n")
a = gets().to_i h = a.div(3600) a = a.modulo(3600) m = a.div(60) a = a.modulo(60) s = a print("#{h}:#{m}:#{s}\n")
null
152,515
152,516
u641479950
ruby
p02390
S = gets.to_i h = s / 3600 m = (s - h *3600) / 60 s = s - h * 3600 - m * 60 puts "%d:%d:%d" % [h,m,s]
S = gets.to_i h = S / 3600 m = (S - h *3600) / 60 s = S - h * 3600 - m * 60 puts "%d:%d:%d" %[h,m,s]
null
152,546
152,547
u407138207
ruby
p02390
S = gets.to_i h = s / 3600 m = (s - h *3600) / 60 s = s - h * 3600 - m * 60 puts "%d:%d:%d" % [h,m,s]
S = gets.to_i h = S / 3600 m = (S - h *3600) / 60 s = S - h *3600 - m * 60 puts "%d:%d:%d" % [h,m,s]
null
152,546
152,548
u407138207
ruby
p02390
n=gets.to_i puts [n/t=60/t,n/t%t,n%t]*":"
n=gets.to_i puts [n/60/t=60,n/t%t,n%t]*":"
null
152,559
152,560
u279605379
ruby
p02390
a=gets.to_i puts"#{a/60/t=60}:#{a%t/t}:#{a%t}"
a=gets.to_i puts"#{a/t=3600}:#{a%t/60}:#{a%60}"
null
152,561
152,562
u279605379
ruby
p02379
class Point def initialize(x, y) @x = x @y = y end attr_reader :x, :y def distance(p) (((@x - p.x) ** 2.0 + (@y - p.y) ** 2.0) ** 0.5) end end a,b,c,d=gets.split.map &:to_i p1=Point.new(a,b) p2=Point.new(c,d) puts p1.distance(p2)
class Point def initialize(x, y) @x = x @y = y end attr_reader :x, :y def distance(p) (((@x - p.x) ** 2.0 + (@y - p.y) ** 2.0) ** 0.5) end end a,b,c,d=gets.split.map &:to_f p1=Point.new(a,b) p2=Point.new(c,d) puts p1.distance(p2)
null
134,788
134,789
u550290469
ruby
p02392
begin input_line = [] while line = $stdin.gets.chomp break if line == "" input_line.push(line.split(" ")) end rescue end i = input_line.first.map{|i| i.to_i } if i[0] < i[1] && i[1] && i[2] puts "Yes" else puts "No" end
begin input_line = [] while line = $stdin.gets.chomp break if line == "" input_line.push(line.split(" ")) end rescue end i = input_line.first.map{|i| i.to_i } if i[0] < i[1] && i[1] < i[2] puts "Yes" else puts "No" end
null
164,008
164,009
u626163867
ruby
p02267
dammy = gets list1 = gets.split.map(&:to_i) dammy = gets list2 = gets.split.map(&:to_i) ans = 0 list2.each do |obj| ans += list1.count(obj) end puts ans
dammy = gets list1 = gets.split.map(&:to_i) dammy = gets list2 = gets.split.map(&:to_i) ans = 0 list2.each do |obj| ans += list1.include?(obj) ? 1 : 0 end puts ans
null
111,404
111,405
u742926680
ruby
p02269
gets d={} while gets o,w=$_.split w=w.to_sym o[0]==?i?d[w]=0:puts(d[w]?"no":"yes") end
gets d={} while gets o,w=$_.split w=w.to_sym o[0]==?i?d[w]=0:puts(d[w]?"yes":"no") end
null
114,236
114,237
u550290469
ruby
p02279
$a=Array.new() class Tree attr_accessor :id,:parent,:depth,:children,:type def initialize(id,children) @id=id @parent=-1 @children=children @type=(children==[] ? 'leaf' : 'internal node') end def print puts "node #{id}: parent=#{parent}, depth=#{depth}, #{type}, #{children}" end def setDepth children.each do |c| $a[c].depth = depth + 1 $a[c].setDepth end end end n=gets.to_i n.times do id,d,*children=gets.split.map(&:to_i) $a << Tree.new(id,children) end $a.sort_by! {|e| e.id} $a.each {|ele| ele.children.each {|e| $a[e].parent=ele.id } } $a.each do |e| if e.parent==-1 e.type='root' e.depth=0 e.setDepth end end $a.each {|e| e.print}
$a=Array.new() class Tree attr_accessor :id,:parent,:depth,:children,:type def initialize(id,children) @id=id @parent=-1 @children=children @type=(children==[] ? 'leaf' : 'internal node') end def print puts "node #{id}: parent = #{parent}, depth = #{depth}, #{type}, #{children}" end def setDepth children.each do |c| $a[c].depth = depth + 1 $a[c].setDepth end end end n=gets.to_i n.times do id,d,*children=gets.split.map(&:to_i) $a << Tree.new(id,children) end $a.sort_by! {|e| e.id} $a.each {|ele| ele.children.each {|e| $a[e].parent=ele.id } } $a.each do |e| if e.parent==-1 e.type='root' e.depth=0 e.setDepth end end $a.each {|e| e.print}
null
122,465
122,466
u083853290
ruby
p02258
n = STDIN.gets.to_i unless (2 <= n and n <= 200000) p ("erro: 0 <= n <= 200000") exit end xs = (0...n.to_i).map {|x| STDIN.gets.to_i } min = nil diff_max = -1000000001 xs.each {|x, i| if (i == 0) min = x else diff = x - min if (diff > diff_max) diff_max = diff end if (x < min) min = x end end } puts diff_max
n = STDIN.gets.to_i unless (2 <= n and n <= 200000) p ("erro: 0 <= n <= 200000") exit end xs = (0...n.to_i).map {|x| STDIN.gets.to_i } min = nil diff_max = -1000000001 xs.each_with_index {|x, i| if (i == 0) min = x else diff = x - min if (diff > diff_max) diff_max = diff end if (x < min) min = x end end } puts diff_max
null
104,247
104,248
u382730661
ruby
p02391
input = gets.split() c,d = input[0].to_i,input[1].to_i if c > d puts "a > b" elsif c < d puts "a < b" elsif c == d puts "a = b" end
input = gets.split() c,d = input[0].to_i,input[1].to_i if c > d puts "a > b" elsif c < d puts "a < b" elsif c == d puts "a == b" end
null
159,137
159,138
u691944762
ruby
p02391
a=gets.chomp.split(" ").map{|str| str.to_i} str = (a[0] < a[1]) ? "a < b\n" : (a[0] > a[1]) ? "a > b\n" : "a==b\n" print str
a=gets.chomp.split(" ").map{|str| str.to_i} str = (a[0] < a[1]) ? "a < b\n" : (a[0] > a[1]) ? "a > b\n" : "a == b\n" print str
null
159,221
159,222
u279605379
ruby
p02391
a=gets.chomp.split(" ").map{|str| str.to_i} str = (a[0] < a[1]) ? "a < b\n" : (a[0] > a[1]) ? "a > b\n" : "a==b\n" print str
a=gets.chomp.split(" ").map{|str| str.to_i} print (a[0] < a[1]) ? "a < b\n" : (a[0] > a[1]) ? "a > b\n" : "a == b\n"
null
159,221
159,223
u279605379
ruby
p02391
a=gets.chomp.split(" ").map{|str| str.to_i} puts (a[0] < a[1]) ? "a < b" : (a[0] > a[1]) ? "a > b" : "a==b"
a=gets.chomp.split(" ").map{|str| str.to_i} puts (a[0] < a[1]) ? "a < b" : (a[0] > a[1]) ? "a > b" : "a == b"
null
159,224
159,225
u279605379
ruby
p02393
nums = AGRF.gets.split.map(&:to_i).sort puts nums.join(" ")
nums = ARGF.gets.split.map(&:to_i).sort puts nums.join(" ")
null
166,640
166,641
u102042957
ruby
p02400
include Math input = STDIN.gets r = input.to_f l = 2*PI*r s = PI*r*r print format("%.6f", l) + " " + format("%.6f", s) + "\n"
include Math input = STDIN.gets r = input.to_f l = 2*PI*r s = PI*r*r print format("%.6f", s) + " " + format("%.6f", l) + "\n"
null
190,784
190,785
u099156261
ruby
p02402
x = gets a = x.split.map(&:to_i) puts [a.min, a.max, a.inject(:+)].join " "
x = gets a = gets.split.map(&:to_i) puts [a.min, a.max, a.inject(:+)].join " "
null
195,389
195,390
u587994751
ruby
p02402
n=gets.split(" ").map(&:to_i) puts "#{n.min} #{n.max} #{n.inject(&:+)}"
gets n=gets.split(" ").map(&:to_i) puts "#{n.min} #{n.max} #{n.inject(&:+)}"
null
195,398
195,399
u420100559
ruby
p02406
n = gets.to_i n.times { |i| x = i+1 if (x%3==0) print " #{x}" next end while(x>0) if (x%10 == 3) print " #{x}" x=0 end x/=10 end }
n = gets.to_i n.times { |i| x = i+1 if (x%3==0) print " #{x}" next end while(x>0) if (x%10 == 3) print " #{i+1}" x=0 end x/=10 end } puts ""
null
208,432
208,433
u983614091
ruby
p02406
n = gets.to_i n.times { |i| x = i+1 if (x%3==0) print " #{x}" next end while(x>0) if (x%10 == 3) print " #{x}" x=0 end x/=10 end } puts ""
n = gets.to_i n.times { |i| x = i+1 if (x%3==0) print " #{x}" next end while(x>0) if (x%10 == 3) print " #{i+1}" x=0 end x/=10 end } puts ""
null
208,434
208,433
u983614091
ruby
p02406
def include3?(x) if x % 10 == 3 true elsif x != 0 include3?(x / 10) else false end end n = gets.chomp.to_i (1...n).each do |i| if i % 3 == 0 || include3?(i) print " #{i}" end end puts
def include3?(x) if x % 10 == 3 true elsif x != 0 include3?(x / 10) else false end end n = gets.chomp.to_i (1..n).each do |i| if i % 3 == 0 || include3?(i) print " #{i}" end end puts
null
208,435
208,436
u765748067
ruby
p02406
def call(n) i=1 i.upto(n){ x=i if x%3==0 print(' ' + i.to_s) next end while x>0 if x%10==3 print(' ' + i.to_s) break end x/=10 end } end call(gets.to_i)
def call(n) ii=1 ii.upto(n){|i| x=i if x%3==0 print(' ' + i.to_s) next end while x>0 if x%10==3 print(' '+i.to_s) break end x/=10 end } puts end call(gets.to_i)
null
208,456
208,457
u861698758
ruby
p02406
n = gets.to_i for i in 1..n x = i if x % 3 == 0 print " #{i}" else while x > 0 if x % 10 == 3 print " #{i}" end x /= 10 end end end puts
n = gets.to_i for i in 1..n x = i if x % 3 == 0 print " #{i}" else while x > 0 if x % 10 == 3 print " #{i}" break end x /= 10 end end end puts
null
208,498
208,499
u216813029
ruby
p02396
ary = [] ARGF.each_line do |line| x = line.to_i break if x != 0 ary << x.to_i end ary.each.with_index(1) do |num, i| puts "Case #{i}: #{num}" end
ary = [] ARGF.each_line do |line| x = line.to_i break if x == 0 ary << x end ary.each.with_index(1) do |num, i| puts "Case #{i}: #{num}" end
null
174,904
174,905
u330842660
ruby
p02396
def toi(a) b = [] a.each do |n| b << n.to_i end b end a=gets().to_i i = 1 while a !=0 do print("case #{i}: #{a}\n") i +=1 a=gets().to_i end
def toi(a) b = [] a.each do |n| b << n.to_i end b end a=gets().to_i i = 1 while a !=0 do print("Case #{i}: #{a}\n") i +=1 a=gets().to_i end
null
174,983
174,984
u641479950
ruby
p02396
data = Array.new arr = 0 while true data[arr] = gets break if data[arr] == "0" data[arr].slice!("\n") arr += 1 end for i in 0..data.size - 1 puts "Case #{i + 1}: #{data[i]}" end
data = Array.new arr = 0 while true data[arr] = gets break if data[arr] == "0\n" data[arr].slice!("\n") arr += 1 end for i in 0..data.size - 2 puts "Case #{i + 1}: #{data[i]}" end
null
174,987
174,988
u229669351
ruby
p02396
data = Array.new arr = 0 while true data[arr] = gets break if data[arr] == "0" data[arr].slice!("\n") arr += 1 end for i in 0..data.size - 2 puts "Case #{i + 1}: #{data[i]}" end
data = Array.new arr = 0 while true data[arr] = gets break if data[arr] == "0\n" data[arr].slice!("\n") arr += 1 end for i in 0..data.size - 2 puts "Case #{i + 1}: #{data[i]}" end
null
174,989
174,988
u229669351
ruby
p02396
i = 1 while true do a=gets.to_i if a==0 then break end puts("Case #{i}:#{a}\n") i=i+1 end
i = 1 while true do a=gets.to_i if a==0 then break end puts("Case #{i}: #{a}\n") i=i+1 end
null
175,062
175,063
u988213374
ruby
p02396
i = 0 while true do x = gets.to_i if x.zero? break else i += 1 puts "Case #{i}:#{x}" end end
i = 0 while true do x = gets.to_i if x.zero? break else i += 1 puts "Case #{i}: #{x}" end end
null
175,064
175,065
u676488304
ruby
p02398
a, b, c = gets.chomp.split.map(&:to_i) (a..b).count {|n| c % n == 0 }
a, b, c = gets.chomp.split.map(&:to_i) puts (a..b).count {|n| c % n == 0 }
null
181,936
181,937
u981139449
ruby
p02398
count = 0 a,b,c = gets.split.map(&:to_i) for x in 1..c do if c%x == 0 count = count + 1 end end puts count
count = 0 a,b,c = gets.split.map(&:to_i) for x in a..b do if c%x == 0 count += 1 end end puts count
null
181,938
181,939
u565781955
ruby
p02407
n = gets.to_i num = gets.split(" ").map(&:to_i) a = [num] puts a.reverse.join(" ")
n = gets.to_i num = gets.split(" ").map(&:to_i) puts num.reverse.join(" ")
null
207,404
207,405
u232170203
ruby
p02407
puts gets.split.map(&:to_i).reverse.join(" ")
gets puts gets.split.map(&:to_i).reverse.join(" ")
null
207,423
207,424
u067629267
ruby
p02409
n = gets.chomp.to_i bldg1 = Array.new(3){Array.new(10){0}} bldg2 = Array.new(3){Array.new(10){0}} bldg3 = Array.new(3){Array.new(10){0}} bldg4 = Array.new(3){Array.new(10){0}} while line = gets b, f, r, v = line.chomp.split(' ').map(&:to_i) case b when 1 bldg1[f-1][r-1] = v when 2 bldg2[f-1][r-1] = v when 3 bldg3[f-1][r-1] = v when 4 bldg4[f-1][r-1] = v end end bldg1.each do |f| print ' ', f.join(' '), "\n" end puts '#'*20 bldg2.each do |f| print ' ', f.join(' '), "\n" end puts '#'*20 bldg3.each do |f| print ' ', f.join(' '), "\n" end puts '#'*20 bldg4.each do |f| print ' ', f.join(' '), "\n" end
n = gets.chomp.to_i bldg1 = Array.new(3){Array.new(10){0}} bldg2 = Array.new(3){Array.new(10){0}} bldg3 = Array.new(3){Array.new(10){0}} bldg4 = Array.new(3){Array.new(10){0}} while line = gets b, f, r, v = line.chomp.split(' ').map(&:to_i) case b when 1 bldg1[f-1][r-1] += v when 2 bldg2[f-1][r-1] += v when 3 bldg3[f-1][r-1] += v when 4 bldg4[f-1][r-1] += v end end bldg1.each do |f| print ' ', f.join(' '), "\n" end puts '#'*20 bldg2.each do |f| print ' ', f.join(' '), "\n" end puts '#'*20 bldg3.each do |f| print ' ', f.join(' '), "\n" end puts '#'*20 bldg4.each do |f| print ' ', f.join(' '), "\n" end
null
209,742
209,743
u247976584
ruby
p02409
rooms = Array.new(4).map! do |n| n = Array.new(3).map! do |m| m = Array.new(10, 0) end end gets.to_i.times do b, f, r, v = gets.split.map(&:to_i) rooms[b - 1][f - 1][r - 1] += v end rooms.each_with_index do |i, index| i.each do |j| puts index," " + j.join(" ") end puts "####################" if index != 3 end
rooms = Array.new(4).map! do |n| n = Array.new(3).map! do |m| m = Array.new(10, 0) end end gets.to_i.times do b, f, r, v = gets.split.map(&:to_i) rooms[b - 1][f - 1][r - 1] += v end rooms.each_with_index do |i, index| i.each do |j| puts " " + j.join(" ") end puts "####################" if index != 3 end
null
209,748
209,749
u818936038
ruby
p02409
ooms = Array.new(4).map! do |n| n = Array.new(3).map! do |m| m = Array.new(10, 0) end end gets.to_i.times do b, f, r, v = gets.split.map(&:to_i) rooms[b - 1][f - 1][r - 1] += v end rooms.each_with_index do |i, index| i.each do |j| puts " " + j.join(" ") end puts "####################" if index != 3 end
rooms = Array.new(4).map! do |n| n = Array.new(3).map! do |m| m = Array.new(10, 0) end end gets.to_i.times do b, f, r, v = gets.split.map(&:to_i) rooms[b - 1][f - 1][r - 1] += v end rooms.each_with_index do |i, index| i.each do |j| puts " " + j.join(" ") end puts "####################" if index != 3 end
null
209,750
209,749
u818936038
ruby
p02409
def update(house, f, r, v) house[10 * (f - 1) + (r - 1)] = v end def print_house(house) house.each_slice(10) do |v| puts " %d %d %d %d %d %d %d %d %d %d" % v end end house1 = Array.new(30, 0) house2 = Array.new(30, 0) house3 = Array.new(30, 0) house4 = Array.new(30, 0) n = gets.chomp.to_i n.times do b, f, r, v = gets.chomp.split.map(&:to_i) case b when 1 then update(house1, f, r, v) when 2 then update(house2, f, r, v) when 3 then update(house3, f, r, v) when 4 then update(house4, f, r, v) end end print_house house1 puts '#' * 20 print_house house2 puts '#' * 20 print_house house3 puts '#' * 20 print_house house4
def update(house, f, r, v) house[10 * (f - 1) + (r - 1)] += v end def print_house(house) house.each_slice(10) do |v| puts " %d %d %d %d %d %d %d %d %d %d" % v end end house1 = Array.new(30, 0) house2 = Array.new(30, 0) house3 = Array.new(30, 0) house4 = Array.new(30, 0) n = gets.chomp.to_i n.times do b, f, r, v = gets.chomp.split.map(&:to_i) case b when 1 then update(house1, f, r, v) when 2 then update(house2, f, r, v) when 3 then update(house3, f, r, v) when 4 then update(house4, f, r, v) end end print_house house1 puts '#' * 20 print_house house2 puts '#' * 20 print_house house3 puts '#' * 20 print_house house4
null
209,753
209,754
u765748067
ruby
p02409
n = gets.chomp.to_i room = [] 4.times do |b| room[b] = [] 3.times do |f| room[b][f] = [] 10.times do |r| room [b][f][r] = 0 end end end n.times do b, f, r, v = gets.split.map(&:to_i) room[b-1][f-1][r-1] += v end 4.times do |b| 3.times do |f| 10.times do |r| print " #{room[b][f][r]}" end puts end puts '####################' end
n = gets.chomp.to_i room = [] 4.times do |b| room[b] = [] 3.times do |f| room[b][f] = [] 10.times do |r| room [b][f][r] = 0 end end end n.times do b, f, r, v = gets.split.map(&:to_i) room[b-1][f-1][r-1] += v end 4.times do |b| 3.times do |f| 10.times do |r| print " #{room[b][f][r]}" end puts end puts '####################' if b < 4-1 end
null
209,766
209,767
u873778695
ruby
p02409
m=gets.to_i bb=[] ff=[] rr=[] vv=[] 1.upto(m){|n| b,f,r,v=gets.split(" ").map{|v|v=v.to_i} bb.push(b) ff.push(f) rr.push(r) vv.push(v) } b1,b2,b3=[] BOR=[] 1.upto(20){|a| BOR.push("#") } 1.upto(4){|n| 1.upto(3){|s| de=[] 1.upto(10){|b| de.push(0.to_i) } 0.upto(m-1){|t| de[rr[t]-1]=vv[t] if bb[t]==n&&ff[t]==s } print (" ") puts de.join(" ") } puts BOR.join if n<4 }
m=gets.to_i bb=[] ff=[] rr=[] vv=[] 1.upto(m){|n| b,f,r,v=gets.split(" ").map{|v|v=v.to_i} bb.push(b) ff.push(f) rr.push(r) vv.push(v) } b1,b2,b3=[] BOR=[] 1.upto(20){|a| BOR.push("#") } 1.upto(4){|n| 1.upto(3){|s| de=[] 1.upto(10){|b| de.push(0.to_i) } 0.upto(m-1){|t| de[rr[t]-1]+=vv[t] if bb[t]==n&&ff[t]==s } print (" ") puts de.join(" ") } puts BOR.join if n<4 }
null
209,773
209,774
u140655940
ruby
p02409
xs = Array.new(4) { Array.new(3) { Array.new(10) { 0 } } } gets.to_i.times do b,f,r,v = gets.split(" ").map(&:to_i) xs[b - 1][f - 1][r - 1] += v end puts xs.map {|building| building.map {|floor| floor.join(" ") }.join("\n") }.join("\n" + "#" * 19 + "\n")
xs = Array.new(4) { Array.new(3) { Array.new(10) { 0 } } } gets.to_i.times do b,f,r,v = gets.split(" ").map(&:to_i) xs[b - 1][f - 1][r - 1] += v end puts xs.map {|building| building.map {|floor| " " + floor.join(" ") }.join("\n") }.join("\n" + "#" * 20 + "\n")
null
209,786
209,787
u709642619
ruby
p02410
n, m = gets.split.map(&:to_i) mat = [] vec = [] n.times do mat << gets.split.map(&:to_i) end m.times do vec << gets.to_i end p mat p vec mat.each do | line | puts line.zip( vec ).map{ | i, j | i * j }.inject(:+) end
n, m = gets.split.map(&:to_i) mat = [] vec = [] n.times do mat << gets.split.map(&:to_i) end m.times do vec << gets.to_i end mat.each do | line | puts line.zip( vec ).map{ | i, j | i * j }.inject(:+) end
null
210,572
210,573
u216457386
ruby
p02410
n,m = gets.chomp.split(" ").map { |e| e.to_i } a = Array.new(n){Array.new(m,0)} b = Array.new(m) c = Array.new(n,0) k = 0 while k <= n-1 a[k] = gets.chomp.split.map { |e| e.to_i } k += 1 end t = 0 while t <= m-1 b[t] = gets.to_i t += 1 end p a p b for i in 0..(n-1) for e in 0..(m-1) c[i] += a[i][e] * b[e] end end for i in 0..(n-1) puts c[i] end
n,m = gets.chomp.split(" ").map { |e| e.to_i } a = Array.new(n){Array.new(m,0)} b = Array.new(m) c = Array.new(n,0) k = 0 while k <= n-1 a[k] = gets.chomp.split.map { |e| e.to_i } k += 1 end t = 0 while t <= m-1 b[t] = gets.to_i t += 1 end for i in 0..(n-1) for e in 0..(m-1) c[i] += a[i][e] * b[e] end end for i in 0..(n-1) puts c[i] end
null
210,579
210,580
u501176275
ruby
p02411
while line=gets (m,f,r)=line.split().map(&:to_i) break if m==-1&&f==-1&&r==-1 if m==-1 || m==-1 || (m+f < 30) puts "F" elsif m+f >= 80 puts "A" elsif m+f >= 65 && m+f < 80 puts "B" elsif m+f >= 50 && m+f < 65 puts "C" elsif m+f >= 30 && m+f < 50 puts r >= 50 ? "C" : "D" else puts "ERROR" end end
while line=gets (m,f,r)=line.split().map(&:to_i) break if m==-1&&f==-1&&r==-1 if m==-1 || f==-1 || (m+f < 30) puts "F" elsif m+f >= 80 puts "A" elsif m+f >= 65 && m+f < 80 puts "B" elsif m+f >= 50 && m+f < 65 puts "C" elsif m+f >= 30 && m+f < 50 puts r >= 50 ? "C" : "D" else puts "ERROR" end end
null
212,457
212,458
u565102293
ruby
p02411
while line = gets data = line.split().map{|e|e.to_i} break if data[0] == -1 && data[1] == -1 && data[2] == -1 sum = data[0] + data[1] if sum < 30 || data[0] == -1 || data[1] puts "F" elsif sum >= 80 puts "A" elsif sum >= 65 puts "B" elsif sum >= 50 puts "C" else if data[2] >= 50 puts "C" else puts "D" end end end
while line = gets data = line.split().map{|e|e.to_i} break if data[0] == -1 && data[1] == -1 && data[2] == -1 sum = data[0] + data[1] if sum < 30 || data[0] == -1 || data[1] == -1 puts "F" elsif sum >= 80 puts "A" elsif sum >= 65 puts "B" elsif sum >= 50 puts "C" else if data[2] >= 50 puts "C" else puts "D" end end end
null
212,465
212,466
u728700495
ruby
p02411
loop do m,f,r=gets.split.map(&:to_i) break if m == -1 && f == -1 && r == -1 sum = m + f a = if m == -1 || f == -1 'F' elsif sum >= 80 'A' elsif sum >= 65 'B' elsif sum >= 50 'C' elsif sum >= 30 r >= 50 ? 'C' : 'D' else 'D' end puts a end
loop do m,f,r=gets.split.map(&:to_i) break if m == -1 && f == -1 && r == -1 sum = m + f a = if m == -1 || f == -1 'F' elsif sum >= 80 'A' elsif sum >= 65 'B' elsif sum >= 50 'C' elsif sum >= 30 r >= 50 ? 'C' : 'D' else 'F' end puts a end
null
212,467
212,468
u739433776
ruby
p02411
loop do m, f, r = gets.chomp.split.map(&:to_i) if m == -1 && f == -1 break end total = m + f if m == -1 || f == -1 puts "F" elsif total >= 80 puts "A" elsif total >= 65 puts "B" elsif total >= 50 puts "C" elsif total < 30 puts "F" end if r >= 50 && total >= 30 puts "C" elsif r < 50 && total >=30 puts "D" end end
loop do m, f, r = gets.chomp.split.map(&:to_i) if m == -1 && f == -1 break end total = m + f if m == -1 || f == -1 puts "F" elsif total >= 80 puts "A" elsif total >= 65 puts "B" elsif total >= 50 puts "C" elsif total < 30 puts "F" elsif r >= 50 && total >= 30 puts "C" elsif r < 50 && total >=30 puts "D" end end
null
212,472
212,473
u960296069
ruby
p02411
while true m,f,r = gets.chomp.split(" ").map &:to_i break if m == -1 and f == -1 and r == -1 puts "A" if 80 <= m+f and 1 < m*f puts "B" if 65 <= m+f and m+f < 80 and 1 < m*f puts "C" if 50 <= m+f and m+f < 65 and 1 < m*f puts "C" if 30 <= m+f and m+f < 50 and 50 <= r and 1 < m*f puts "D" if 30 <= m+f and m+f < 50 and r < 50 and 1 < m*f puts "F" if m+f < 30 or m == -1 or f == -1 end
while true m,f,r = gets.chomp.split(" ").map &:to_i break if m == -1 and f == -1 and r == -1 puts "A" if 80 <= m+f and -1 < m*f puts "B" if 65 <= m+f and m+f < 80 and -1 < m*f puts "C" if 50 <= m+f and m+f < 65 and -1 < m*f puts "C" if 30 <= m+f and m+f < 50 and 50 <= r and -1 < m*f puts "D" if 30 <= m+f and m+f < 50 and r < 50 and -1 < m*f puts "F" if m+f < 30 or m == -1 or f == -1 end
null
212,481
212,482
u281257618
ruby
p02411
while true do m,f,r = gets.split.map!(& :to_i) break m < 0 && f < 0 && r < 0 sum = m + f if (m < 0 || f < 0 || sum < 30) then puts "F" next elsif (sum >= 80) then puts "A" next elsif (sum >= 65 && sum < 80) then puts "B" next elsif (sum >= 50 && sum < 65 || r >= 50) then puts "C" next else puts "D" end end
while true do m,f,r = gets.split.map!(& :to_i) break if m < 0 && f < 0 && r < 0 sum = m + f if (m < 0 || f < 0 || sum < 30) then puts "F" next elsif (sum >= 80) then puts "A" next elsif (sum >= 65 && sum < 80) then puts "B" next elsif (sum >= 50 && sum < 65 || r >= 50) then puts "C" next else puts "D" end end
null
212,491
212,492
u166301467
ruby
p02411
loop do m,f,r = gets.split.map(&:to_i) if m == -1 && f == -1 && r == -1 then exit else if m == -1 || f == -1 then puts "F" else d = m+f if d >= 80 then puts "A" else if d >= 65 then puts "B" else if d >= 50 then puts "C" else if d >= 30 then if r >= 50 then puts "C" else puts "D" end end end end end end end end
loop do m,f,r = gets.split.map(&:to_i) if m == -1 && f == -1 && r == -1 then exit else if m == -1 || f == -1 then puts "F" else d = m+f if d >= 80 then puts "A" else if d >= 65 then puts "B" else if d >= 50 then puts "C" else if d >= 30 then if r >= 50 then puts "C" else puts "D" end else puts "F" end end end end end end end
null
212,506
212,507
u350127362
ruby
p02411
while allscore = STDIN.gets.split(" ") m = allscore[0].to_i f = allscore[1].to_i r = allscore[2].to_i if m == -1 && f == -1 && r == -1 break elsif m == -1 && f == -1 puts "F" elsif m + f >= 80 puts "A" elsif m + f >= 65 && m + f < 80 puts "B" elsif m + f >= 50 && m + f < 65 || m + f >= 30 && m + f < 55 && r >= 50 puts "C" elsif m + f >= 30 && m + f < 55 puts "D" elsif m + f < 30 puts "F" end end
while allscore = STDIN.gets.split(" ") m = allscore[0].to_i f = allscore[1].to_i r = allscore[2].to_i if m == -1 && f == -1 && r == -1 break elsif m == -1 || f == -1 puts "F" elsif m + f >= 80 puts "A" elsif m + f >= 65 && m + f < 80 puts "B" elsif m + f >= 50 && m + f < 65 || m + f >= 30 && m + f < 55 && r >= 50 puts "C" elsif m + f >= 30 && m + f < 55 puts "D" elsif m + f < 30 puts "F" end end
null
212,508
212,509
u236620240
ruby
p02412
# (1..n) # a + b + c = x || a != b, b != c, c != a ARGF.each do |line| n, x = line.split.map(&:to_i) break if n == 0 && x == 0 ary = [*1..n] i = 0 ary.combination(3) do |a, b, c| if (a + b + c) == x i += 1 end puts i end end
# (1..n) # a + b + c = x || a != b, b != c, c != a ARGF.each do |line| n, x = line.split.map(&:to_i) break if n == 0 && x == 0 ary = [*1..n] i = 0 ary.combination(3) do |a, b, c| if (a + b + c) == x i += 1 end end puts i end
null
219,144
219,145
u102042957
ruby
p02412
loop do n,s = gets.split.map(&:to_i) break if n==0 puts (1..n).permutation(3).count{|x,y,z| x+y+z==s} end
loop do n,s = gets.split.map(&:to_i) break if n==0 puts [*1..n].combination(3).count{|x,y,z| x+y+z==s} end
null
219,155
219,156
u714639016
ruby
p02412
loop do n,s = gets.split.map(&:to_i) break if n==0 puts [*1..n].permutation(3).count{|x,y,z| x+y+z==s} end
loop do n,s = gets.split.map(&:to_i) break if n==0 puts [*1..n].combination(3).count{|x,y,z| x+y+z==s} end
null
219,157
219,156
u714639016
ruby
p02412
def ans (num, total, amax) if(total<=0) 0 elsif(num==1) if(total<=amax) 1 else 0 end else sum=0 for i in 1..amax do sum+=ans(num-1,total-i,i) end sum end end while(true) a,b=gets.split(" ").map(&:to_i) if(a==0&&b==0) then break end d=ans(3,b,a) puts(d) end
def ans (num, total, amax) if(total<=0) 0 elsif(num==1) if(total<=amax) 1 else 0 end else sum=0 for i in 1..amax do sum+=ans(num-1,total-i,i-1) end sum end end while(true) a,b=gets.split(" ").map(&:to_i) if(a==0&&b==0) then break end d=ans(3,b,a) puts(d) end
null
219,158
219,159
u186082958
ruby
p02412
loop do n, x = gets.chomp.split(' ').map(&:to_i) break if [n, x] == [0, 0] cnt = 0 # n + n + 1 + n + 2 = x for i in 1 .. x / 3 - 1 #i + n + n + 1 = x for j in i + 1 .. (x - i - 1) / 2 k = x - i - j if j < k cnt += 1 end end end puts cnt end
loop do n, x = gets.chomp.split(' ').map(&:to_i) break if [n, x] == [0, 0] cnt = 0 # n + n + 1 + n + 2 = x for i in 1 .. x / 3 - 1 #i + n + n + 1 = x for j in i + 1 .. (x - i - 1) / 2 k = x - i - j if j < k && k <= n cnt += 1 end end end puts cnt end
null
219,164
219,165
u802537549
ruby
p02418
line = gets.chomp line2 = gets.chomp if a.include?(line2) puts "Yes" else puts "No" end
line = gets.chomp line2 = gets.chomp a = line * 2 if a.include?(line2) puts "Yes" else puts "No" end
null
222,094
222,095
u818936038
ruby
p02418
s = gets.chomp p = gets.chomp if (s*2).index(p) puts "YES" else puts "NO" end
s = gets.chomp p = gets.chomp if (s*2).index(p) puts "Yes" else puts "No" end
null
222,097
222,098
u728700495
ruby
p02418
ary = [] ARGF.each do |line| ary << line.chomp end str = ary[0] str += str if str.include?(ary[1]) puts "YES" else puts "NO" end
ary = [] ARGF.each do |line| ary << line.chomp end str = ary[0] str += str if str.include?(ary[1]) puts "Yes" else puts "No" end
null
222,099
222,100
u330842660
ruby
p02418
arr = gets.chomp.split("") s = gets str = (arr + arr).join("") if str.scan(s) == nil puts "No" else puts "Yes" end
arr = gets.chomp.split("") s = gets.chomp str = (arr + arr).join("") if str.scan(s).size == 0 puts "No" else puts "Yes" end
null
222,112
222,113
u229669351
ruby
p02418
s = gets*2 p = gets check = s.include?(p) if check puts "Yes" else puts "No" end
s = gets.chomp*2 p = gets.chomp check = s.include?(p) if check puts "Yes" else puts "No" end
null
222,117
222,118
u216813029
ruby
p02418
s_line = gets.chomp p_line = gets.chomp check = 0 (s_line.length).times do if s_line.include?(p_line) check = 1 break else tmp = s_line.slice(0) s_line << tmp end end if check == 1 puts "Yes" else puts "No" end
s_line = gets.chomp p_line = gets.chomp check = 0 (s_line.length).times do if s_line.include?(p_line) check = 1 break else tmp = s_line.slice!(0) s_line << tmp # puts s_line tmp = '' end end if check == 1 puts "Yes" else puts "No" end
null
222,121
222,122
u251341266
ruby
p02418
s = gets.chomp p = gets.chomp puts s.include?(p) ? "Yes" : "No"
s = gets.chomp * 2 p = gets.chomp puts s.include?(p) ? "Yes" : "No"
null
222,125
222,126
u087014397
ruby
p02418
s = gets.chomp.split * 2 p = gets.chomp puts s.include?(p) ? "Yes" : "No"
s = gets.chomp * 2 p = gets.chomp puts s.include?(p) ? "Yes" : "No"
null
222,127
222,126
u087014397
ruby
p02418
s = gets.chomp.split * 2 p = gets.chomp.split puts s.include?(p) ? "Yes" : "No"
s = gets.chomp * 2 p = gets.chomp puts s.include?(p) ? "Yes" : "No"
null
222,128
222,126
u087014397
ruby
p02419
#!/usr/bin/env ruby require "pp" search_word = gets.chomp.lowcase strings = [] while strings[-1] != "END_OF_TEXT" do strings.concat(gets.split(/\W/)) end count = 0 strings.each do |word| if word.lowcase == search_word then count += 1 end end puts count
#!/usr/bin/env ruby search_word = gets.chomp.downcase strings = [] while strings[-1] != "END_OF_TEXT" do strings.concat(gets.split(/\W/)) end count = 0 strings.each do |word| if word.downcase == search_word then count += 1 end end puts count
null
222,156
222,157
u948491783
ruby
p02419
w = gets.chomp res = 0 while line = gets break if line.chomp == 'END_OF_TEXT' line.chomp.split(' ').each do |ww| ww.sub!(/\./, '') if ww == w res += 1 end end end puts res
w = gets.chomp.downcase res = 0 while line = gets break if line.chomp == 'END_OF_TEXT' line.chomp.split(' ').each do |ww| ww.sub!(/\./, '') ww.downcase! if ww == w res += 1 end end end puts res
null
222,158
222,159
u247976584
ruby
p02419
count = 0 word = gets.chomp word.downcase! loop do l = readline line = l.split line.each{|str| count += 1 if str.downcase == word } break if l == "END_OF_TEXT" end puts count
count = 0 word = gets.chomp word.downcase! while l = gets line = l.chomp.split line.each{|str| count += 1 if str.downcase == word } break if l == "END_OF_TEXT" end puts count
null
224,673
224,674
u401720175
ruby
p02419
count = 0 word = gets.chomp word.downcase! while l = readline line = l.split line.each{|str| count += 1 if str.downcase == word } break if l == "END_OF_TEXT" end puts count
count = 0 word = gets.chomp word.downcase! while l = gets line = l.chomp.split line.each{|str| count += 1 if str.downcase == word } break if l == "END_OF_TEXT" end puts count
null
224,675
224,674
u401720175
ruby
p02419
count = 0 key = gets.chomp loop do line = gets.split line.each{|str| if str == key then count += 1 end } if line[0] == "END_OF_TEXT" then break end end puts count
count = 0 key = gets.chomp.downcase loop do line = gets.split line.each{|str| if str.downcase == key then count += 1 end } if line[0] == "END_OF_TEXT" then break end end puts count
null
224,676
224,677
u350127362
ruby
p02419
word = gets.chomp.downcase cnt = 0 while true t = gets.chomp.downcase break if t == "ENT_OF_TEXT" cnt += t.split(" ").count(word) end puts cnt
word = gets.chomp.downcase cnt = 0 while true t = gets.chomp break if t == "END_OF_TEXT" cnt += t.downcase.split(" ").count(word) end puts cnt
null
224,678
224,679
u236620240
ruby
p02419
word = gets.chomp.downcase cnt = 0 while true t = gets.chomp break if t == "ENT_OF_TEXT" cnt += t.downcase.split(" ").count(word) end puts cnt
word = gets.chomp.downcase cnt = 0 while true t = gets.chomp break if t == "END_OF_TEXT" cnt += t.downcase.split(" ").count(word) end puts cnt
null
224,680
224,679
u236620240
ruby
p02420
while line = gets break if '-' == line.chomp! cards = line m = gets.to_i m.times { h = gets.to_i shuffle = cards[ 0 ... h ] cards.slice!( 0 ... h ) cards <<shuffle } end puts( cards )
while line = gets break if '-' == line.chomp! cards = line m = gets.to_i m.times { h = gets.to_i shuffle = cards[ 0 ... h ] cards.slice!( 0 ... h ) cards <<shuffle } puts( cards ) end
null
223,525
223,526
u604774382
ruby
p02420
while input = gets.chomp break if input.to_s == "-" card = input.to_s n = gets.chomp.to_i n.times do i = gets.chomp.to_i bottom = card.slice!(0..i-1) card << bottom end p card end
while input = gets.chomp break if input.to_s == "-" card = input.to_s n = gets.chomp.to_i n.times do i = gets.chomp.to_i bottom = card.slice!(0..i-1) card << bottom end puts card end
null
223,533
223,534
u759791460
ruby