package yukicoder import java.util.Scanner object q240 { case class Position(x: Int, y: Int) { def move(position: Position): Position = { Position(x + position.x, y + position.y) } } def makeMoveList(): List[Position] = { List( Position(1, 2), Position(1, -2), Position(-1, 2), Position(-1, -2), Position(2, 1), Position(2, -1), Position(-2, 1), Position(-2, -1) ) } def makeMoveSet(position: Position, count: Int): Set[Position] = { if (count <= 0) { Set() } else { makeMoveList().map(position.move).foldLeft[Set[Position]](Set())((set, position) => set + position ++ makeMoveSet(position, count - 1)) } } def main(args: Array[String]) { val sc = new Scanner(System.in) val goal = Position(sc.nextInt(), sc.nextInt()) val set = makeMoveSet(Position(0, 0), 3) if (set(goal)) { println("YES") } else { println("NO") } } }