Skip to content

When algo is not enough

algo is meant to cover common contest code well, not every possible C++ trick. When you need lower-level control, the boundary is explicit.

Anything inside a cpp: block is copied into the generated output.

Top-level example:

cpp:
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")

Inside a function:

fn process(a: [int]) -> int:
cpp:
if (__builtin_popcount(mask) > 20) return -1;
0

Use this when you need something the language does not model directly.

Unknown methods on values are emitted as C++ method calls:

a.reserve(n)
a.shrink_to_fit()
s.find(sub)

This is useful for the long tail of STL operations that do not need first-class syntax.

#!int64

Use this when the problem is naturally 64-bit and you want int in source code to map to 64-bit integers in generated C++.

#!mod 998244353

This changes the value used by modular helpers such as MOD, +%, -%, *%, **%, and modinv.

Good reasons:

  • GCC pragmas
  • STL features without direct syntax
  • intrinsics or compiler builtins
  • temporary debugging code in generated C++

Bad reason:

  • working around language syntax you have not checked in the docs yet

If the task is common and repetitive, look at the guides and reference first. The language probably already has a surface form for it.