Since I don't have something recent to share, I am going to tell about something old. I was trying to solve Timus 1378 Artificial Intelligence and realized that the code I was writing was too spaghetti, and I thought if I could make it simpler. So I came upon a solution which is simple, fast and correct. You can try to discover it, in case you don't want to, it's under spoiler in the first comment.
BTW: you can you pictures from dropbox here, just share it in dropbox interface and replace www.dropbox with dl.dropboxusercontent in URL
SPOILER.