Tutorials

Concise tutorials on algorithms, data structures, and competitive-programming techniques.

To use Python in competitive programming, you will have to know how to take input from stdin.

Read more →

If you are given a number N, you have to determine how many integers between 1 and N have a GCD of 1 with N.

Read more →

Finding a number in a sorted array using binary search.

A beginner's number theory tutorial on Sieve of Eratosthenes.

Default I/O is sometimes too slow for large data. Use buffered reads/writes or fast parsers to avoid timeouts.

Sign up. Get Toph news and updates.