PROBLEM LINK:
Author:Dmytro Berezin
Tester:Sergey Kulik
Editorialist:Lalit Kundu
DIFFICULTY:
CAKEWALK
PREREQUISITES:
AD-HOC
PROBLEM:
Chef is at x=0.
1-jump: he will move from x -> x + 1
2-jump: he will move from x -> x + 2
3-jump: he will move from x -> x + 3
He will perform a lot of jumps in such a sequence: 1-jump, 2-jump, 3-jump, 1-jump, 2-jump, 3-jump, 1-jump, and so on.
Given an integer 0 ≤ a ≤ 1018, find will he ever arrive at a.
QUICK EXPLANATION:
In one sequence of 1-jump, 2-jump and 3-jump, he moves from x -> x + 6. So, if intermediate jumps are removed for a minute, x will always be a multiple of 6. Now, if we consider intermediate jumps, we will also consider points of form 6*k - 3, 6*k - 5.
Therefore,
a=input()
if a%6==0 || a%6==1 || a%6==3:
print "yes"
else:
print "no"
Complexity: O(1)