require 'date' class Yukicoder def initialize n = gets.to_i - 2014 list = Hash.new(0) wday = Date.new(2014, 7, 23).wday count = 0 1.upto(400) do |i| if wday == Date.new(2014+i, 7, 23).wday count += 1 end list[i] = count end if n <= 400 puts list[n] else puts count * (n/400) + list[n%400] end end end Yukicoder.new