View agc026-a.rb
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
prev = a[0]
ans = 0
l = 1
(n - 1).times do |i|
if a[i + 1] == prev
l += 1
else
ans += (l / 2)
View agc025-a.rb
n = gets.chomp.to_i
if n % 10 == 0 then
puts 10
else
puts n.to_s.split("").map(&:to_i).inject(:+)
end
View agc023-a.rb
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
s = [0]
n.times do |i|
s[i+1] = s[i] + a[i]
end
h = Hash.new(0)
s.each do |i|
h[i] += 1
end
View abc102-c.rb
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = (1..n).map{|i| a[i-1] - i}.sort
x = b[n/2]
puts b.map{|e| (e - x).abs}.inject(:+)
View abc097-b.rb
x = gets.chomp.to_i
y = Math.sqrt(x).to_i + 1
if x == 1 then
puts 1
exit
end
ans = 1
2.upto(y) do |i|
a = i
View abc097-a.rb
a, b, c, d = gets.chomp.split(" ").map(&:to_i)
if (a - c).abs <= d then
puts "Yes"
elsif (a - b).abs <= d && (b - c).abs <= d then
puts "Yes"
else
puts "No"
end
View r-cairo_pdf-or-CairoPDF.Rmd
library(ggplot2)
library(Cairo)
gp <- ggplot(cars, aes(x=speed, y=dist)) + 
  geom_point()
gp
View colopl2018-qual-b.rb
n, x = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
tt = []
n.times do
tt << gets.chomp.to_i
end
ans = 0
n.times do |i|
if s[i] == '0' then
ans += tt[i]
View code-thanks-fes-2017-para-b.rb
s = gets.chomp
ss = s.reverse
ans = ss.length
ss.length.times do |i|
sss = s + ss[i..-1]
if sss == sss.reverse then
ans = ss.length - i
end
end
View agc004-a.rb
a, b, c = gets.chomp.split(" ").map(&:to_i)
total = a * b * c
r1 = (a / 2) * b * c
b1 = total - r1
r2 = a * (b / 2) * c
b2 = total - r2
r3 = a * b * (c / 2)