import algorithm import math import strutils const WindowSize = 3 proc countIncreases(): uint = var line = "" window: array[WindowSize + 1, uint] while readLine(stdin, line): if line.len() > 0: window.rotateLeft(1) window[^1] = parseUint(line) if window[0] > 0 and sum(window[1 .. ^1]) > sum(window[0 .. ^2]): result.inc() proc main(): int = try: echo countIncreases() except ValueError: result = -1 when isMainModule: quit(main())