# endlesscheng/codeforces-go architecture

> Architecture diagram of the GitHub repository endlesscheng/codeforces-go, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/endlesscheng/codeforces-go
- Repository: https://github.com/endlesscheng/codeforces-go

## Overview

This repository is a Go competitive-programming knowledge base: engineers study reusable algorithm templates, apply them while solving problems, and use contest-oriented starter templates. The README documents broad coverage across data structures, strings, mathematics, dynamic programming, graphs, and problem-solving techniques; the tree also contains a large LeetCode archive and smaller AtCoder/GCJ solutions. The sampled solutions are standalone programs, so the graph does not imply they call the reusable templates. Template-generator wiring and unsampled internals are not inferred.

Main entry points: [`copypasta/segment_tree.go`](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/segment_tree.go) (Data structures), [`copypasta/link_cut_tree.go`](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/link_cut_tree.go) (Tree structures), [`copypasta/graph.go`](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/graph.go) (Graph algorithms), [`copypasta/graph_tree.go`](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/graph_tree.go) (Tree and grid graphs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_algorithms["Algorithm library"]
  node_data_structures["Data structures<br/>[segment_tree.go]"]
  node_tree_structures["Tree structures<br/>[link_cut_tree.go]"]
  node_graph_algorithms["Graph algorithms<br/>[graph.go]"]
  node_tree_graphs["Tree and grid graphs<br/>[graph_tree.go]"]
  node_string_algorithms["String algorithms<br/>[strings.go]"]
  node_automata["String automata<br/>[acam.go]"]
  node_math_algorithms["Number theory<br/>[math.go]"]
  node_transforms["Math transforms<br/>[math_ntt.go]"]
  node_geometry["Computational geometry<br/>[geometry.go]"]
  node_dynamic_programming["Dynamic programming<br/>[dp.go]"]
  node_basic_algorithms["Basic techniques<br/>[common.go]"]
end

subgraph group_solutions["Problem archive"]
  node_leetcode_archive["LeetCode solutions<br/>[a.go]"]
  node_atcoder_archive["AtCoder solutions<br/>[main.go]"]
  node_gcj_archive["GCJ solutions<br/>[main.go]"]
end

subgraph group_contest["Contest templates"]
  node_base_template["General starter<br/>[main.go]"]
  node_platform_templates["Platform templates<br/>[generator.go]"]
  node_leetcode_templates["LeetCode templates<br/>[generator.go]"]
end

subgraph group_io["I/O and interaction"]
  node_interactive_template["Interactive starter<br/>[main.go]"]
  node_fast_io["Fast I/O template<br/>[io.go]"]
end

node_programmer(("Competitive programmer"))

node_programmer -->|"studies"| node_data_structures
node_programmer -->|"studies"| node_tree_structures
node_programmer -->|"studies"| node_graph_algorithms
node_programmer -->|"studies"| node_tree_graphs
node_programmer -->|"studies"| node_string_algorithms
node_programmer -->|"studies"| node_automata
node_programmer -->|"studies"| node_math_algorithms
node_programmer -->|"studies"| node_transforms
node_programmer -->|"studies"| node_geometry
node_programmer -->|"studies"| node_dynamic_programming
node_programmer -->|"studies"| node_basic_algorithms
node_programmer -->|"practices with"| node_leetcode_archive
node_programmer -->|"practices with"| node_atcoder_archive
node_programmer -->|"practices with"| node_gcj_archive
node_programmer -->|"starts from"| node_base_template
node_programmer -->|"uses"| node_platform_templates
node_programmer -->|"uses"| node_leetcode_templates
node_programmer -->|"starts from"| node_interactive_template
node_programmer -->|"references"| node_fast_io

click node_data_structures "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/segment_tree.go"
click node_tree_structures "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/link_cut_tree.go"
click node_graph_algorithms "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/graph.go"
click node_tree_graphs "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/graph_tree.go"
click node_string_algorithms "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/strings.go"
click node_automata "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/acam.go"
click node_math_algorithms "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/math.go"
click node_transforms "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/math_ntt.go"
click node_geometry "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/geometry.go"
click node_dynamic_programming "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/dp.go"
click node_basic_algorithms "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/common.go"
click node_leetcode_archive "https://github.com/endlesscheng/codeforces-go/blob/master/leetcode/biweekly/1/a/a.go"
click node_atcoder_archive "https://github.com/endlesscheng/codeforces-go/blob/master/misc/atcoder/abc163/e/main.go"
click node_gcj_archive "https://github.com/endlesscheng/codeforces-go/blob/master/misc/gcj/2020/1a/c/main.go"
click node_base_template "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/main.go"
click node_platform_templates "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/atcoder/generator.go"
click node_leetcode_templates "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/leetcode/generator.go"
click node_interactive_template "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/interactive_problem/main.go"
click node_fast_io "https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/io.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_data_structures,node_tree_structures,node_graph_algorithms,node_tree_graphs,node_string_algorithms,node_automata,node_math_algorithms,node_transforms,node_geometry,node_dynamic_programming,node_basic_algorithms toneBlue
class node_leetcode_archive,node_atcoder_archive,node_gcj_archive toneAmber
class node_base_template,node_platform_templates,node_leetcode_templates toneMint
class node_interactive_template,node_fast_io toneRose
class node_programmer toneIndigo
```

## Components

### Algorithm library

- [Data structures](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/segment_tree.go): `copypasta/segment_tree.go`
- [Tree structures](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/link_cut_tree.go): `copypasta/link_cut_tree.go`
- [Graph algorithms](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/graph.go): `copypasta/graph.go`
- [Tree and grid graphs](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/graph_tree.go): `copypasta/graph_tree.go`
- [String algorithms](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/strings.go): `copypasta/strings.go`
- [String automata](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/acam.go): `copypasta/acam.go`
- [Number theory](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/math.go): `copypasta/math.go`
- [Math transforms](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/math_ntt.go): `copypasta/math_ntt.go`
- [Computational geometry](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/geometry.go): `copypasta/geometry.go`
- [Dynamic programming](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/dp.go): `copypasta/dp.go`
- [Basic techniques](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/common.go): `copypasta/common.go`

### Problem archive

- [LeetCode solutions](https://github.com/endlesscheng/codeforces-go/blob/master/leetcode/biweekly/1/a/a.go): `leetcode/biweekly/1/a/a.go`
- [AtCoder solutions](https://github.com/endlesscheng/codeforces-go/blob/master/misc/atcoder/abc163/e/main.go): `misc/atcoder/abc163/e/main.go`
- [GCJ solutions](https://github.com/endlesscheng/codeforces-go/blob/master/misc/gcj/2020/1a/c/main.go): `misc/gcj/2020/1a/c/main.go`

### Contest templates

- [General starter](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/main.go): `copypasta/template/main.go`
- [Platform templates](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/atcoder/generator.go): `copypasta/template/atcoder/generator.go`
- [LeetCode templates](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/leetcode/generator.go): `copypasta/template/leetcode/generator.go`

### I/O and interaction

- [Interactive starter](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/template/interactive_problem/main.go): `copypasta/template/interactive_problem/main.go`
- [Fast I/O template](https://github.com/endlesscheng/codeforces-go/blob/master/copypasta/io.go): `copypasta/io.go`

### Other components

- **Competitive programmer**

## Connections

- Competitive programmer → Data structures: studies
- Competitive programmer → Tree structures: studies
- Competitive programmer → Graph algorithms: studies
- Competitive programmer → Tree and grid graphs: studies
- Competitive programmer → String algorithms: studies
- Competitive programmer → String automata: studies
- Competitive programmer → Number theory: studies
- Competitive programmer → Math transforms: studies
- Competitive programmer → Computational geometry: studies
- Competitive programmer → Dynamic programming: studies
- Competitive programmer → Basic techniques: studies
- Competitive programmer → LeetCode solutions: practices with
- Competitive programmer → AtCoder solutions: practices with
- Competitive programmer → GCJ solutions: practices with
- Competitive programmer → General starter: starts from
- Competitive programmer → Platform templates: uses
- Competitive programmer → LeetCode templates: uses
- Competitive programmer → Interactive starter: starts from
- Competitive programmer → Fast I/O template: references
