class Main def start a = input.split.map { |s| s.to_i + 100 } puts main(a) ? "Yes" : "No" return nil end private def main(a) result = false return result if a.sum % 3 != 0 target = a.sum / 3 for i in 0...100 a = a.map { |x| x % 100 } if i >= 10 a = sub(a, i % 3, a[0] == target) if a.min == a.max result = true break end end result end def sub(a, i, flg) target = a.sum / 3 j = 1 + i x = [a[j % 3] + (i != 2 || flg ? 0 : j) - target, 0].max / j * j a[i] += x a[j % 3] -= x #puts [j, target, x, a].flatten.join(", ") return a end def input = gets end Main.new.start