
Язык программирования Python для спортивного программирования
Изучите основы программирования с помощью практических упражнений и практических примеров.
Module 1: Introduction to Programming
Understanding what programming is and why we need it

Изучите основы программирования с помощью практических упражнений и практических примеров.
Understanding what programming is and why we need it
Write and understand your first program
Working with user input and program output
Making decisions in your programs
Numeric data types
Working with collections of data
part 2
Working with characters and collection of characters - strings
Learn how functions work in Python
Learn how to apply linear search for solving tasks. Brute-forcing
Finding elements by checking each one in sequence — implementation patterns, Python's built-in alternatives, and when to use it.
Solving problems by trying all possible candidates, with nine worked examples and a complexity guide for estimating feasibility.
part 1
part 2
- deque - set - dict - heapq
Python list as a stack, why lists fail as queues, and how collections.deque solves it with O(1) operations on both ends.
Fast O(1) membership and lookup using set and dict, plus defaultdict and Counter from collections, with common CP patterns.
Min-heap operations using Python's heapq module — push, pop, heapify, the negation trick for max-heap, and practical CP examples.
part 1
part 2
Basic Sorting Algorithms
Sorting algorithms are methods used to arrange data in a specific order. An overview of where sorting appears, Python's built-in sort, the O(N log N) lower bound, and why classical algorithms are worth studying.
Sorting by repeatedly swapping adjacent out-of-order elements, with an early exit optimization for nearly sorted data.
Sorting by repeatedly finding the minimum of the unsorted suffix and placing it in its correct position.
Sorting by maintaining a sorted prefix and inserting each new element into its correct position, with adaptive O(N) behavior on nearly sorted data.
Problems for practice
Learn special language tricks which is extremely usefull for solving tasks as well as writing normal scripts
Comprehensions are one of the most loved Python features — they let you build lists and dictionaries in a single concise line, replacing what would otherwise be a multi-line loop.
A generator expression looks almost identical to a list comprehension but computes values lazily — one at a time, only when needed.
Python's always-available functions most useful in competitive programming: enumerate, zip, map, filter, sorted, any, all, min, max, abs, pow, and sum.
The standard library modules most relevant to competitive programming: math, itertools, functools, and sys.
How to read and write data as fast as possible in Python — essential when problems have very large inputs or outputs.
Reading from and writing to files, redirecting stdin/stdout for file-based judges, and a local testing workflow.
Recursion
Recursion is when a function calls itself. Unlike a loop, recursive calls work inside each other — each waiting for the deeper call to finish before continuing.
Problems for practice