| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3408 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 153 |
| 2 | nik_exists | 151 |
| 3 | maroonrk | 150 |
| 4 | maspy | 149 |
| 5 | AmShZ | 146 |
| 6 | Um_nik | 143 |
| 7 | Errichto | 139 |
| 8 | adamant | 135 |
| 9 | BledDest | 134 |
| 10 | cry | 130 |
Hey Codeforces! (^_^)
I've been working on a Rust library that makes competitive programming in Rust much cleaner and less verbose. If you've ever tried Rust for CP, you know the pain of writing the same input parsing boilerplate over and over again.
Standard Rust CP code looks like this:
use std::{
io::{stdin, stdout, BufRead, BufReader, BufWriter, Read, Write},
iter::repeat,
};
fn solve<R: Read, W: Write>(input: R, output: W) {
let mut reader = BufReader::new(input);
let mut writer = BufWriter::new(output);
let mut buf = String::new();
reader.read_line(&mut buf).unwrap();
let n: usize = buf.trim().parse().unwrap();
buf.clear();
reader.read_line(&mut buf).unwrap();
let a: Vec<i64> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
// rest of the logic here
writeln!(writer, "{}", ans).unwrap();
}
fn main() {
let stdin = stdin();
let stdout = stdout();
solve(stdin.lock(), stdout.lock());
}
That's way too much boilerplate! (>_<#)
With this library, the same code becomes:
sol! {
fn solution(n: usize, arr: [i64]) -> i64 {
// Your actual solution logic here
arr.iter().sum()
}
}
That's it! Clean, readable, and focuses on the algorithm rather than I/O.
Simple Macros
Smart Input Parsing
sol! {
fn solution(
n: usize, // Single integer
arr: [i32], // Space-separated integers
matrix: [[i32]; n], // n lines of space-separated integers
s: [char], // String as char array
binary: [01], // Binary string as Vec<u8>
fixed: [i32; 5], // Exactly 5 integers
lines: [String]; n // n lines as strings
) -> String {
format!("Parsed {} elements", arr.len())
}
}
Flexible Output
// Automatic Yes/No for booleans
sol! {
fn solution(n: i32) -> bool {
n % 2 == 0 // Prints "Yes" or "No"
}
}
// Lists with custom separators
use cp_lib::{Words, Lines, words_of, lines_of};
sol! {
fn solution(arr: [i32]) -> Words<i32> {
words_of(arr) // Space-separated output
}
}
Debug Support
sol! {
fn solution(n: usize, arr: [i32]) -> i32 {
dbg_cp!("Processing array of size: {}", n); // Only prints in debug mode
arr.iter().max().unwrap_or(&0).clone()
}
}
Typical CF Problem
sol! {
fn solution(n: usize, a: [i32]) -> i32 {
let mut max_val = 0;
let mut current = 0;
for &x in &a {
current = (current + x).max(x);
max_val = max_val.max(current);
}
max_val
}
}
Multiple Test Cases
sol_n! {
fn solution(n: usize, s: [char]) -> bool {
let count_a = s.iter().filter(|&&c| c == 'a').count();
count_a > n - count_a
}
}
Grid Problems
sol! {
fn solution(n: usize, m: usize, grid: [[char]; n]) -> i32 {
let mut count = 0;
for i in 0..n {
for j in 0..m {
if grid[i][j] == '#' {
count += 1;
}
}
}
count
}
}
Performance
The library is designed for competitive programming:
How to Use
Source Code
The complete library is available as a single file that you can copy-paste into your solutions. It's designed to be self-contained and dependency-free (except for std).
Why Rust for CP?
The main barrier was always the verbose I/O, but this library solves that!
Feedback Welcome!
I'd love to hear your thoughts and suggestions! Have you tried Rust for competitive programming? What other features would make this library more useful? Let me know in the comments if you try it out!
Hello Codeforces community!
I'm excited to share a project I've been working on: CP-Assist, a desktop application designed to address the limitations of existing competitive programming tools.
Unlike many existing tools that either support too few languages or are tightly coupled with specific text editors, I wanted to create something more flexible. As a programmer who values versatility, I found most existing CP tools too restrictive, so I built CP-Assist to work across different environments and with various languages.
Editor Independence:
Works with any text editor or IDE of your choice
No lock-in to a specific development environment
Flexible workflow that adapts to your preferences
Extensive Language Support:
Wide range of programming languages supported
Customizable compiler flags and execution parameters
Pre-submission File Modification:
Unique Feature: Modify files before submission to include library files
Perfect for competitors who use personal algorithm libraries
Streamlines the process of preparing code for submission
Test Case Management:
Automatic import of problem statements and test cases via Competitive Companion
Organized interface for managing multiple test cases
Real-time verdict status for each test
Can add custom test cases
Code Execution:
Run solutions against test cases directly in the application
Track execution time and memory usage
Automatic comparison of expected vs. actual outputs
I built CP-Assist using:
Rust with Tauri for performance-critical backend operations
React with TypeScript for a responsive UI
Mantine and Tailwind CSS for styling
You can check out CP-Assist at: https://github.com/tsych0/cp-assist
Available for: - Linux (AppImage, .deb, .rpm) - Windows (Installer)
I'd appreciate hearing your thoughts on CP-Assist:
How does the flexibility compare to other tools you've used?
Which languages are you using with it?
Is the library inclusion feature helping with your workflow?
What other features would make this more useful for you?
I built this tool to address the limitations I experienced with other CP assistants, and I hope it can help improve your competitive programming experience as well!
GitHub: https://github.com/tsych0/cp-assist

| Name |
|---|


