class Start def main a = input.split.map { |s| s.to_i + 100 } echo func(a) ? "Yes" : "No" return nil end private def func(a) result = false #return result if a.sum % 3 != 0 #echo "j, target, x ,a" for i in 0...4 k = [0, a.min - 3].max a = a.map { |x| x - k } a = sub(a, i % 3) end result = true if a.sum % 9 == 0 result end def sub(a, i) target = a.sum / 3 j = 1 + i x = [a[j % 3] - target, 0].max / j * j a[i] += x a[j % 3] -= x #echo [j, target, x, a] return a end def echo(*x) print(*x) puts end def input = $gets.pop.chomp end Start.new.main