You can use several words in query to find by all of them at the same time. In addition, if you are lucky search understands word forms and some synonyms. It supports search by title and author. Examples:

  • 305 — search for 305, most probably it will find blogs about the Round 305
  • andrew stankevich contests — search for words "andrew", "stankevich" and "contests" at the same time
  • user:mikemirzayanov title:testlib — search containing "testlib" in title by MikeMirzayanov
  • "vk cup" — use quotes to find phrase as is
  • title:educational — search in title

Results

1.

eval

Last visit:  3 years ago
Registered:  12 years ago
2.
By tourist, history, 9 years ago, translation, In English
Hello 2018 -- Tutorial Here is the tutorial of Hello 2018. Enjoy! <spoiler summary="Modular Exponentiation"> Problem writer: [user:tourist,2018-01-08] [tutorial:913A] <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf("%d %d", &n, &m); printf("%d\n", n >= 31 ? m : m % (1 << n)); return 0; } ~~~~~ </spoiler> </spoiler> <spoiler summary="Christmas Spruce"> Problem writer: [user:BudAlNik,2018-01-08] [tutorial:913B] <spoiler summary="C++ solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> p(n), deg(n); for (int i = 1; i < n; i++) { cin >> p[i]; p[i]--; deg[p[i]]++; } vector<int> sons_leaves(n); for (int i = 0; i < n; i++) { if (deg[i] == 0) { sons_leaves[p[i]]++; } } for (int i = 0; i < n; i++) { if (deg[i] > 0 && sons_leaves[i] < 3) { puts("No"); return 0; } } puts...
- 1; i >= 0; i--) { sub(a[i][0], eval(a[i], point[i])); for (int j = i - 1; j >= i, b; } int eval(poly a, int x) { int res = 0; for (int i = (int) a.size() - 1; i >= 0; i, ) { sub(a[i], a[i - cnt]); } a[i] = integrate(a[i]); sum[i] = eval(a, ; } int eval(poly a, int x) { int res = 0; for (int i = (int) a.size() - 1; i >= 0; i--) { res, int eval(poly a, int x) { int res = 0; for (int i = (int) a.size() - 1; i >= 0; i

Full text and comments »

Tutorial of Hello 2018
  • Vote: I like it
  • +463
  • Vote: I do not like it

3.
By ekzhang, history, 6 years ago, In English
[Tutorial] Kinetic Tournament (Used in FBHC Round 2) Background ------------------ During Facebook Hacker Cup Round 2 today, Problem D caught my attention. It reminded me of a particular data structure called a **kinetic tournament**, which is not very well known in this community. However, it offers an extremely clean and slick solution to the problem, in my opinion. I first learned about this data structure from [user:dragonslayerintraining,2020-08-30], who described a variant of it in this [Codeforces blog comment](https://codeforces.me/blog/entry/68534#comment-530381). Since the data structure is so interesting, I feel like it deserves a longer explanation, some template code, and more examples. That's why I am writing this blog post. Kinetic Tournaments ------------------ Briefly, the functionality of the data structure is a mix between a line container, i.e., "convex hull trick", and a segment tree. Suppose that you have an array containing pairs of nonnegative integers, $A[i]$ and $B[i]$. You also have a global...
INF; if (s <= lo && hi <= e) return eval(st[node], temp); size_t mid = (lo + hi) / 2; return, delta = eval(line2, temp) - eval(line1, temp); T delta_slope = line1.first - line2.first; assert, inline T eval(const line& ln, T t) { return ln.first * t + ln.second; }, inline bool cmp(const line& line1, const line& line2) { auto x = eval(line1, temp); auto y

Full text and comments »

  • Vote: I like it
  • +242
  • Vote: I do not like it

4.
By sammyuri, 4 months ago, In English
Spectral::Cup 2026 Round 2 (Codeforces Round 1100, Div. 1 + Div. 2) Editorial Thank you for participating in our round! We hope you enjoyed the problems as much as we enjoyed preparing them. <spoiler summary="Rate the contest!"> <spoiler summary="Quality"> - Absolute Cinema contest - Excellent contest - Good contest - Average contest - Bad contest - Horrible contest </spoiler> <spoiler summary="Difficulty"> - Trivial contest - Easy contest - Average contest - Hard contest - Impossible contest </spoiler> </spoiler> [problem:2229A] Idea by: [user:Intellegent,2026-05-23] Prepared by: [user:Intellegent,2026-05-23] Editorial by: [user:reirugan,2026-05-23] <spoiler summary="Hint 1"> Let $y$ denote the final position of all of the slimes. Then it is optimal to choose $x = y$ for every operation. </spoiler> <spoiler summary="Hint 2"> Let $\mathrm{mn}$ denote the minimum value in $a$, a...
; } bool operator<(ll x) const { return p < x; } ll eval(ll x) { return k * x + m; } };, ; } ll eval(ll x) { return k * x + m; } }; struct LineContainer : multiset

Full text and comments »

  • Vote: I like it
  • +304
  • Vote: I do not like it

5.
By meooow, 8 years ago, In English
[Tutorial] Convex Hull Trick — Geometry being useful ### The problem Let us consider the problem where we need to quickly calculate the following over some set $S$ of $j$ for some value $x$. $$\max_{j \in S} \{m_j \cdot x + c_j\}$$ Additionally, insertion of new $j$ into $S$ must also be efficient. This will most likely be encountered with DP problems. For example, the recent problem [problem:1083E] from Round #526 has the following DP formulation after sorting the rectangles by $x$. $$f(i) = x_i \cdot y_i - a_i + \max_{1 \le j < i}\{-x_j \cdot y_i + f(j)\}$$ The problem requires quick calculation of the above define maximum for each index $i$. How can this be done? ### The idea Notice the special form of $m_j \cdot x + c_j$. This is identical to the equation of a straight line with slope $m_j$ and Y-intercept $c_j$. So the problem is equivalent to being given a set of lines and asked for the maximum $y$ value any of those lines can give at a particular $x$. If you draw a bunch of straight lines on a plane, you'll...
long m, c; long long eval(long long x) { return m * x + c; } long double intersectX(line l, ); long long f = dq[idx].eval(rects[i].q) + rects[i].p * 1LL * rects[i].q - rects[i].a, ++) { while (dq.size() >= 2 && dq.back().eval(rects[i].q) <= dq[dq.size() - 2]. eval(rects[i].q, ; long long eval(long long x) { return m * x + c; } long double intersectX(line l) { return

Full text and comments »

  • Vote: I like it
  • +274
  • Vote: I do not like it

6.
By zscoder, history, 5 years ago, In English
April Fools Day Contest 2021 — ZS Edition Hi everyone, April Fools is near and as usual we have an [April Fools Day Contest](https://codeforces.me/blog/entry/88840) on Codeforces this year. In addition to that, I usually try to host some form of mini April Fools Contest for my friends every year (or almost every year). This year, I am trying to host a bigger April Fools Day contest than usual and I invite everyone to participate! In view of the April Fools contest on Codeforces, the round will begin at [31 March 10pm (GMT+8)](https://www.timeanddate.com/worldclock/fixedtime.html?msg=April+Fools+Day+Contest+2021+%28ZS%29&iso=20210331T22&p1=122) and lasts for exactly $24$ hours (and thus it will end ~35 minutes before the CF April Fools round). The contest will consist of several unusual tasks, and I hope that everyone will at least find something interesting. The problems will not be sorted by increasing order of difficulty (if the word difficulty is even applicable), so it is **highly advisable** to read (and try!)...
Figure out what each function is. Use Python eval. [Code, Python eval. [Code](https://ideone.com/812DxQ) There are

Full text and comments »

  • Vote: I like it
  • +247
  • Vote: I do not like it

7.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 82 Editorial [problem:1303A] Idea: [user:Roms,2020-02-13] <spoiler summary="Tutorial"> [tutorial:1303A] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ for t in range(int(input())): print(input().strip('0').count('0')) ~~~~~ </spoiler> [problem:1303B] Idea: [user:adedalic,2020-02-13] <spoiler summary="Tutorial"> [tutorial:1303B] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ fun main() { val t = readLine()!!.toInt() for (tc in 1..t) { val (n, g, b) = readLine()!!.split(' ').map { it.toLong() } val needG = (n + 1) / 2 var totalG = needG / g * (b + g) totalG += if (needG % g == 0L) -b else needG % g println(maxOf(n, totalG)) } } ~~~~~ </spoiler> [problem:1303C] Idea: [user:Roms,2020-02-13] <spoiler summary="Tutorial"> [tutorial:1303C] </spoiler> <spoiler summary="Solution (Ne0n25)"> ~~~~~ #include <bits/stdc++.h> using namespace std; #define s...
* 2 + 1, l, m); clear(v * 2 + 2, m, r); } } long long eval(func f, int x, need_swap = eval(f, m) > eval(T[v], m); if(need_swap) swap(T[v], f); if(l == r, ) / 2; clear(v * 2 + 1, l, m); clear(v * 2 + 2, m, r); } } long long eval, long long eval(func f, int x) { return f.first * x + f.second; }, long long get(int v, int l, int r, int x) { long long ans = eval(T[v], x); if(l < r - 1

Full text and comments »

  • Vote: I like it
  • +89
  • Vote: I do not like it

8.
By awoo, history, 7 years ago, translation, In English
Educational Codeforces Round 81 Editorial [problem:1295A] Idea: [user:adedalic,2020-01-30] <spoiler summary="Tutorial"> [tutorial:1295A] </spoiler> <spoiler summary="Solution (BledDest)"> ~~~~~ t = int(input()) for i in range(t): n = int(input()) if(n % 2 == 1): print(7, end='') n -= 3 while(n > 0): print(1, end='') n -= 2 print() ~~~~~ </spoiler> [problem:1295B] Idea: [user:Roms,2020-01-30] <spoiler summary="Tutorial"> [tutorial:1295B] </spoiler> <spoiler summary="Solution (adedalic)"> ~~~~~ #include<bits/stdc++.h> using namespace std; typedef long long li; int n, x; string s; inline bool read() { if(!(cin >> n >> x >> s)) return false; return true; } inline void solve() { int ans = 0; bool infAns = false; int cntZeros = (int)count(s.begin(), s.end(), '0'); int total = cntZeros - (n - cntZeros); int bal = 0; for(int i = 0; i < n; i++) { if(total == 0) { if(bal == x) infAns = tru...
++) { cur = add(cur, eval(a, x[i])); y.push_back(cur); } return, [i][0]; cur = cur * poly({add(0, -x[i]), 1}); } return res; } int eval(const, ]; cur = cur * poly({add(0, -x[i]), 1}); } return res; } int eval(const poly& a, int x, int eval(const poly& a, int x) { int res = 0; for(int i = int(a.size()) - 1; i >= 0; i, int sumOverSegment(const poly& a, int L, int R) { return eval(sumFromL(a, L, a.size()), R - 1); }

Full text and comments »

  • Vote: I like it
  • +106
  • Vote: I do not like it

9.
By Elegia, history, 21 month(s) ago, In English
More on D-Finite Functions I: Theories Hello everyone. Several years ago [user:jqdai0815,2025-01-03] released a [blog](https://codeforces.me/blog/entry/76447) on the topic of D-Finite functions. In this blog, I will introduce some more theories, and show the relation between some CP problems. Also, I found out that what I show is like opening Pandora's box: it provides some new ways to solve problems, but they also somehow prevent us from really understanding them. Therefore, I'll also talk about some of my personal critiques on this topic. Since this blog is quite long, I'll divide it into several parts. This is the first part. ## Appetizer We start with this toy problem. **$n$-King Problem.** Given $n$, count the number of permutations $\sigma$ of $[n]$ such that for any $i$, $|\sigma(i) - \sigma(i+1)| \neq 1$. Of course, this sequence has already been studied before, it is the [A002464](https://oeis.org/A002464) in OEIS. You can find its recurrence relation $$ a_n = (n+1)a_{n-1} - (n-2)a_{n-2} - (n-5...
; a.erase(a.begin()); return a; } Z eval(const P &a, const Z &z) { Z v = 0; for (int i, Eval(const PRec &prec) : prec(prec) {}, PRec prec = DFinite_genPRec(tot); cerr << prec << '\n'; Eval eval(prec); cerr, Z eval(const P &a, const Z &z) { Z v = 0; for (int i = a.deg(); i >= 0; --i) v = v * z, ] += init[i - j] * eval(prec[j], i); init[i] = init[i] * -nvs[i - start]; } return init; } };, int pre(int n) { coeff.resize(n + 1); for (int i = 0; i <= n; ++i) coeff[i] = eval(prec[0, struct Eval { PRec prec; vector coeff;

Full text and comments »

  • Vote: I like it
  • +123
  • Vote: I do not like it

10.
By cry, 3 years ago, In English
CodeTON Round 8 Editorial Thank you for participating! We put a lot of effort into this contest. Special thanks to [user:TheScrasse,2024-03-10] for contributing to these problems. <spoiler summary="Rating Predictions"> | Person | A | B | C1 | C2 | D | E | F | G | H | |--------------------------------------------|------|------|------|------|------|------|------|------|------| | [user:oursaco,2024-03-30] | 800 | 1200 | 1500 | 1800 | 2200 | 2400 | 2800 | 2700 | 3400 | | [user:priyanshu.p,2024-03-30] | 800 | 1200 | 1300 | 1600 | 2200 | | | | | | [user:thescrasse,2024-03-30] | 800 | 1200 | 1400 | 1700 | 2100 | 2300 | 2900 | 2900 | 3500 | | [user:cry,2024-03-30] | 800 | 1000 | 1300 | 1700 | 2100 | 2200 | 2800 | 2900 | 3500 | | [user:buffering,2024-03-30] | 800 | 1000 | 1500 | 1900 | 2100 | 2200 | 2700 | 2800 | 3500 | | [user:jaggubandar,2024...
v0 = eval(x, 0), v1 = eval(x, 1), v2 = eval(x, 2); deg1[par[x]].erase(max((ll)0, v1, v0 = eval(x, 0), v1 = eval(x, 1), v2 = eval(x, 2); deg1[par[x]].insert(max((ll)0, v1, ; rebuild(x); pull(x); add(x); cout << (min({eval(1, ][2][2] = b[x] + c[x] + sum2[x]; } ll eval(int x, int ind){ return min({cum, ll eval(int x, int ind){ return min({cum[rt[x]][ind][0], cum[rt[x]][ind][1], cum[rt[x

Full text and comments »

  • Vote: I like it
  • +143
  • Vote: I do not like it

11.
By BledDest, 10 months ago, In English
About ER185, problem D Judging by the comments in the ER announcement, people seriously disliked problem D (to say the least). I want to explain why it exists. But first, I have to admit that I made two serious mistakes when setting the problem. My first mistake is actually putting it into a 2-hour solo round; in its current state, it is much more suitable for a longer contest with a team of three people, where you can actually get some help in debugging the code or verifying your solution logic. The second mistake will be explained a bit later, but I want to say that I understand why people think this is a terrible problem. I am sorry if this problem made the contest much worse for you. However, I am also asking that you consider my point of view. You don't have to agree with it, but I don't want anyone to view me as some insane author who's setting a problem just to watch everyone get furious while implementing it. This is definitely an implementation-heavy problem. But I think that implementation...
+= eval(s); for(int i = 0; i < q; i++) { int a, b, c; cin >> a >> b >> c, cost(char c) { if(c == 'I') return 1; return 5; } int eval(string s) { int n, int eval(string s) { int n = s.size(); int ans = 0; for(int i = 0; i < n; i

Full text and comments »

  • Vote: I like it
  • +181
  • Vote: I do not like it

12.
By awoo, history, 4 years ago, In English
Codeforces Round #839 (Div. 3) Editorial [problem:1772A] Idea: [user:BledDest,2022-12-19] <spoiler summary="Tutorial"> [tutorial:1772A] </spoiler> <spoiler summary="Solution (BledDest)"> ~~~~~ t = int(input()) for i in range(t): print(eval(input())) ~~~~~ </spoiler> [problem:1772B] Idea: [user:BledDest,2022-12-19] <spoiler summary="Tutorial"> [tutorial:1772B] </spoiler> <spoiler summary="Solution (BledDest)"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for(int _ = 0; _ < t; _++) { vector<int> a(4); for(int i = 0; i < 4; i++) cin >> a[i]; int maxpos = max_element(a.begin(), a.end()) - a.begin(); int minpos = min_element(a.begin(), a.end()) - a.begin(); if(maxpos + minpos == 3) puts("YES"); else puts("NO"); } } ~~~~~ </spoiler> [problem:1772C] Idea: [user:BledDest,2022-12-19] <spoiler summary="Tutorial"> [tutori...
(t): print(eval(input())) ~~~~~ [problem:1772B] Idea: [user:BledDest,2022, ): print(eval(input())) ~~~~~ [problem:1772B] Идея: [user:BledDest,2022-12, ~~~~~ t = int(input()) for i in range(t): print(eval(input())) ~~~~~

Full text and comments »

  • Vote: I like it
  • +50
  • Vote: I do not like it

13.
By 36champ, 4 months ago, In English
Codeforces Round 1101 (Div. 2) — Editorial [Problem A &mdash; Convergence](https://codeforces.me/contest/2232/problem/A) Problem Idea: [user:36champ,2026-05-30] <br> Solution Idea: [user:36champ,2026-05-30] <spoiler summary="Hint 1"> What if the meeting location is fixed? </spoiler> <spoiler summary="Solution"> If the meeting location is fixed, the answer is max(the number of people to the left of that position, the number of people to the right of that position. This can be solved in $O(n^2)$ by iterating through all position that has at least one person on it. This problem can also be solved in $O(n\log n)$ by sorting and setting the meeting position to the median of all positions. </spoiler> <spoiler summary="Code"> ```cpp #include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vll; typedef vector<vll> vvll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int main() { ios_ba...
cout << eval(S, l) << "\n"; } } ``` , int x = eval(S, m), y = eval(S, m + 1);, ll ans = 0; for(int i=l; i<=r; i++) ans = max(ans, eval(S, i));, ll eval(string &S, int m) { ll T = 0, ans = 0;

Full text and comments »

  • Vote: I like it
  • +97
  • Vote: I do not like it

14.
By tibinyte2006, 2 years ago, In English
[Tutorial] Li Chao Tree Extended 2 Hello, Codeforces! <font color='white'>new round dropping soon btw</font> There are ways to modify [Li Chao Tree](https://cp-algorithms.com/geometry/convex_hull_trick.html) to support more powerful types of operations, some of which are already described [here](https://codeforces.me/blog/entry/86731). This tutorial will focus on extending the aforementioned data structure to solve the following problem: - Operation 1: Add a new line - Operation 2: For a given point, find the line that yields the $k$-th minimum value at that point We will assume, without loss of generality, that $k$ does not change during the queries. Our goal is to perform those operations in $O(k \cdot log C)$ each. Note that a simple Li Chao Tree solves our problem for $k=1$. <hr> #### The Idea Since a normal Li Chao Tree stores the best line in each node, it is natural to think that all we need to do is to keep the best $k$ lines. ( where the _best_ line is defined as the line that gives the mini...
~~~~~ struct line { int a, b; int eval(int x

Full text and comments »

  • Vote: I like it
  • +210
  • Vote: I do not like it

15.
By awang11, history, 7 months ago, In English
Codeforces Round 1085 (Div. 1 + Div. 2) Editorial <center> <table class="tex-tabular bordertable" style="border-left: none; border-right: none; border-top: 1px solid; border-bottom: 1px solid; border-collapse: collapse;"> <tbody> <tr> <td class="tex-tabular-text-align-center" style="border-left: none; border-right: none; border-top: none; border-bottom: none;"> <span class="tex-font-size-small"> <span class="tex-font-style-it"> <a href="https://www.youtube.com/watch?v=HCYKLnT0UNU">Trophy Presentations — Asuka Ota, Ryo Nagamatsu, Mario Kart Wii</a> </span> </span> </td> </tr> </tbody> </table> </center> **UPD 1:** added hints, problem credits, more specific acknowledgements and some remarks. Implementations are on the way, sorry for making y'all wait! **UPD 2:** Implementations are finally here. [problem:2207A] Author: [user:awang11,2026-03-09] Preparers: [user:awang11,2026-03-09], [user:IceSerpent,2026-03-09] Anal...
+= ")"; return ret; } return "error"; } int eval(const vector, ) { cout << M->eval(Q) << endl; cout.flush(); } else break; } } return 0, ; } return "error"; } int eval(const vector& x) { ++evals

Full text and comments »

  • Vote: I like it
  • +146
  • Vote: I do not like it

16.
By shishyando, 4 years ago, In English
Codeforces Round #781 (Div. 2) Editorial Again, I hope that you liked all the problems. Share your ideas and solutions in the comments, because there are always different ones! So, the editorial: <spoiler summary="A: GCD vs LCM"> [problem:1665A] <spoiler summary="Editorial"> In this problem it is enough to print $n - 3$, $1$, $1$, $1$. It is easy to see that this answer is correct for any $n \ge 4$. </spoiler> <spoiler summary="Implementation (C++, shishyando)"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T --> 0) { int n; cin >> n; cout << n - 3 << ' ' << 1 << ' ' << 1 << ' ' << 1 << '\n'; } return 0; } ~~~~~ </spoiler> </spoiler> <spoiler summary="B: Array Cloning Technique"> [problem:1665B] <spoiler summary="Editorial"> We will use a greedy technique. Let's find the most common element in the array. Let it be $x$ and let it occur $k$ times in the array. Then let's make a copy where all elements...
() { ios::sync_with_stdio(0); cin.tie(0); /* #if !ONLINE_JUDGE && !EVAL ifstream, ); /* #if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout("output.txt, /* #if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout

Full text and comments »

  • Vote: I like it
  • +143
  • Vote: I do not like it

17.
By awoo, history, 10 months ago, translation, In English
Educational Codeforces Round 185 Editorial [problem:2170A] Idea: [user:BledDest,2025-11-29] <spoiler summary="Tutorial"> [tutorial:2170A] </spoiler> <spoiler summary="Solution 1 (Neon)"> ~~~~~ #include <bits/stdc++.h> using namespace std; int dx[] = {-1, 0, 1, 0}; int dy[] = {0, -1, 0, 1}; int main() { int t; cin >> t; while (t--) { int n; cin >> n; auto get = [&](int x, int y) { if (x >= 0 && x < n && y >= 0 && y < n) return x * n + y + 1; return 0; }; int ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { int cur = get(i, j); for (int d = 0; d < 4; ++d) cur += get(i + dx[d], j + dy[d]); ans = max(ans, cur); } } cout << ans << '\n'; } } ~~~~~ </spoiler> <spoiler summary="Solution 2 (Neon)"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin...
+= eval(s); for(int i = 0; i < q; i++) { int a, b, c; cin >> a >> b >> c, c) { if(c == 'I') return 1; return 5; } int eval(string s) { int n = s.size, ; int cost(char c) { if(c == 'I') return 1; return 5; } int eval(string s) { int, int eval(string s) { int n = s.size(); int ans = 0; for(int i = 0; i < n; i

Full text and comments »

  • Vote: I like it
  • +34
  • Vote: I do not like it

18.
By awoo, history, 3 years ago, In English
Educational Codeforces Round 154 Editorial [problem:1861A] Idea: [user:BledDest,2023-09-01] <spoiler summary="Tutorial"> [tutorial:1861A] </spoiler> <spoiler summary="Solution (BledDest)"> ~~~~~ #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for(int i = 0; i < t; i++) { string s; cin >> s; if(s.find("1") < s.find("3")) cout << 13; else cout << 31; cout << endl; } } ~~~~~ </spoiler> [problem:1861B] Idea: [user:Roms,2023-09-01] <spoiler summary="Tutorial"> [tutorial:1861B] </spoiler> <spoiler summary="Solution (Roms)"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (int tc = 0; tc < t; ++tc) { string a, b; cin >> a >> b; bool ok = false; for (int i = 0; i + 1 < a.size(); ++i) { if (a[i] == b[i] && a[i] == '0' && a[i + 1] == b[i + 1] && a[i + 1] == '1') { ok = true; } } ...
and evaluate them add_to_cut[mask] = eval(pref_sums(aux)); }, corresponding points vector eval(const vector>& a) { int n, vector eval(const vector>& a) { int n = a.size(); vector

Full text and comments »

  • Vote: I like it
  • +119
  • Vote: I do not like it

19.
By MarcosK, 4 years ago, In English
2022-2023 ICPC Latin American Regional Programming Contest — Unofficial editorial Hi everyone! The [2022-2023 ICPC Latin America Regional Programming Contest](https://codeforces.me/gym/104252) was held last weekend. Given that (as far as I know) there is no official editorial for the problems, I decided to create one. Please notice that, given that these are not the official solutions, there can be typos/mistakes in the explanations. Feedback is always appreciated :) I would like to thank [user:lsantire,2023-03-22] for reviewing the editorial and providing valuable feedback. Don't hesitate to reach out to me if you have any questions/suggestions. Thank you! [problem:104252A] <spoiler summary="Hint"> Think in which case a person loses money. Remember we can choose the order in which events happen. </spoiler> <spoiler summary="Solution"> Let's fix a person $p$ and call $a$ and $b$ to the people $p$ will ask for money. It's easy to see that $p$ loses money if $a$, $b$ and $p$ are asked for money before $p$ requests $a$ or $b$ to pay. This ...
){ if(val.snd >= -st[k].eval(val.fst)) return -1; if(s+1==e) return s; int m=(s+e)/2; int, ll ans=(d-b)/(a-c)-1; while(eval(x,ans) <= eval(y,ans)) ans++;, ll eval(ii a, ll x){ return x*a.fst+a.snd; }, tc eval(tc x){ while(pos>0&&fbin(x,pos-1))pos--; while(pos, { int l=0,r=n-1; while(l<=r){ int m=(l+r)/2; if(eval(v[id[m]],x.fst.fst

Full text and comments »

  • Vote: I like it
  • +120
  • Vote: I do not like it

20.
By Chilli, history, 3 years ago, In English
A Manual Evaluation of AlphaCode2 through stalking AlphaCode2 accounts See https://twitter.com/cHHillee/status/1732868066558792189 for the original tweet. Contents mimicked below. TL;DR: I found AlphaCode2 accounts, and through stalking their submission history, I manually performed the AlphaCode2 Codeforces evals, and found the model to perform at about a ~1650 rating. ![ ](https://pbs.twimg.com/media/GAt599aacAAb9Jm?format=png&name=medium) I am somewhat concerned about data leakage, see https://twitter.com/cHHillee/status/1732636161204760863. This is an AlphaCode2 contributor's response https://twitter.com/RemiLeblond/status/1732677521290789235 However, for the purposes of this analysis I'll take the results at face value. Methodology ================== Disclaimer: I'm trying to reverse-engineer info from their public submissions, so apologies in advance for any errors. There is a fixed set of 12 contests that they submit to. When they kick off a "run" they submit to these contests from several accounts at a time. ![ ](https://pbs.tw...
and november, and they repeatedly eval on the same set of contests. Identifying their accounts is, evaluation between the middle of october and november, and they repeatedly eval on the same set of, And here's my [datasheet where I tracked my manual eval of AlphaCode2](https://docs.google.com, One concern I had about this eval is whether this "run" actually represented their performance, or, To find a full "eval" run, I found a particular time that they started submitting. For example

Full text and comments »

  • Vote: I like it
  • +127
  • Vote: I do not like it

21.
By rui_er, 2 years ago, In English
Codeforces Round 942 (Div. 1, Div. 2) Editorial [problem:1972A] <spoiler summary="Hint 1"> Only add problems when they are needed. </spoiler> <spoiler summary="Tutorial"> [tutorial:1972A] </spoiler> <spoiler summary="Solution"> ```cpp //By: OIer rui_er #include <bits/stdc++.h> #define rep(x, y, z) for(int x = (y); x <= (z); ++x) #define per(x, y, z) for(int x = (y); x >= (z); --x) #define endl '\n' using namespace std; typedef long long ll; const int N = 105; int T, n, a[N], b[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); for(cin >> T; T; --T) { cin >> n; rep(i, 1, n) cin >> a[i]; rep(i, 1, n) cin >> b[i]; int diff = 0, ans = 0; rep(i, 1, n) { if(a[i - diff] > b[i]) { ++ans; ++diff; } } cout << ans << endl; } return 0; } ``` </spoiler> [problem:1972B] <spoiler summary="Hint 1"> Is there anything that _never...
#if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout("output.txt, ); #if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout("output.txt

Full text and comments »

  • Vote: I like it
  • +113
  • Vote: I do not like it

22.
By DanTheMan., 16 months ago, In English
mBIT 2025 Editorial Thank you to everyone who competed in mBIT 2025! It was a record breaking year for us with 84 in-person participants and 135 online participants. We hoped you guys enjoyed it as much as we did. We tried hard to make the problems fun and interesting for as wide of a skill gap as possible. In fact, this year's competition had an in-person team of middle schoolers that was unfamiliar with for loops, and an online team with all three participants in the top 15 in the world in codeforces. We are glad to contribute to all niches of the computer science community: beginner and advanced, local and global. Thank you all for your enthusiasm. Congratulations to the winners: **Online Advanced:** - 1st place &mdash; HoMaMaOvo &mdash; Masaki Nishimoto, Riku Kawasaki, Yui Hosaka - 2nd place &mdash; mathforcesbox &mdash; Brian Xue, Bing-Dong Liu, Alex Chen - 3rd place &mdash; bluepuppygreenturtle &mdash; Rain Jiang, Kai Jiang **Online Intermediate:** - 1st place &mdash; NULP Lega...
){ for(int i=al; i<=ar; i++) ans = max(ans, eval(i, bl)); return; }, // shortest path if break is at l1 and l2 functioneval = [&](int l1, int l2, int am = (al+ar)/2; pair best = make_pair(eval(am, bl), bl); for(int i=bl; i

Full text and comments »

  • Vote: I like it
  • +77
  • Vote: I do not like it

23.
By Nickolas, 10 years ago, In English
April Fools Day Contest 2016: editorial I'm happy to see that this year there were 3 people who managed to solve all 7 problems! Unfortunately, only 1097 participants solved at least one problem, which is less than in 2014. #### [problem:656A] This problem asked to figure out an integer sequence from two samples and problem title. It turned out to be surprisingly hard, a lot harder than I anticipated. A quick search through OEIS shows that while there are a lot of sequences which have these two numbers in them, only one is related to Leonardo da Vinci (and if you're looking for da Vinci, there are only two sequences overall). http://oeis.org/A221180 is an erroneous series of powers of 2, written down by da Vinci in his diaries and available as part of "Codex Madrid I". #### [problem:656B] Just one word: [typoglycemia](https://en.wikipedia.org/wiki/Typoglycemia). [cut] The urban legend (unsupported by any known research) claims that people can easily read text even if letters in each word are scrambled, as lo...
each forbidden keyword (/*..*/ in C++ or @ in Python with eval) * Use built-in functions like map, in the middle of each forbidden keyword (/*..*/ in C++ or @ in Python with eval ) * Use built-in, выполнить ее при помощи eval в Python). * Использовать встроенные функции итерирования map, each и, помощи eval в Python). * Использовать встроенные функции итерирования map, each и т.д. * Я подозреваю

Full text and comments »

  • Vote: I like it
  • +121
  • Vote: I do not like it

24.
By rahulgoel, history, 4 years ago, In English
Editorial for CodeCraft-22 and Codeforces Round #795 (Div. 2) [problem:1691A] ================== **[Video Editorial](https://youtu.be/CwsYQXjIwDg)** **Idea:** [user:amul_agrawal,2022-05-26] **Problem Setting:** [user:menavlikar.rutvij,2022-05-26] [user:JadeReaper,2022-05-26] [user:rahulgoel,2022-05-26] [user:amul_agrawal,2022-05-26] **Editorial**: [user:menavlikar.rutvij,2022-05-26] [user:rahulgoel,2022-05-26] **Video Editorial**: [user:rahulgoel,2022-05-26] <spoiler summary="Hint 1"> Sum of two odd numbers is even and sum of two even numbers is also even. </spoiler> <spoiler summary="Hint 2"> If all consecutive pairs have even sum, can we generalize something about the sequence using the above hint? </spoiler> <spoiler summary="Solution"> [tutorial:1691A] </spoiler> <spoiler summary="C++ Code"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int num...
#if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout("output.txt, ; } } } int main() { ios::sync_with_stdio(0); cin.tie(0); #if !ONLINE_JUDGE && ! EVAL

Full text and comments »

  • Vote: I like it
  • +141
  • Vote: I do not like it

25.
By jay_jayjay, history, 13 months ago, In English
Teamscode Summer 2025 Contest Official Editorial Thanks for participating in TeamsCode, and I hope you enjoyed the problems! All problems were written and prepared by [user:hyforces,2025-08-20], [user:Yam,2025-08-20], [user:culver0412,2025-08-20], [user:alexlikemath007,2025-08-20], [user:Jasonwei08,2025-08-20], [user:n685,2025-08-20], [user:HaccerKat,2025-08-20], [user:jay_jayjay,2025-08-20], [user:feining_for_gm,2025-08-20], [user:Mustela_Erminea,2025-08-20], [user:eysbutno,2025-08-20], [user:furyna,2025-08-20], [user:iframe_,2025-08-20], [user:Nyctivoe,2025-08-20], [user:TheYashB,2025-08-20], [user:gggg0,2025-08-20], [user:training4usaco,2025-08-20], [user:ThatRowletOwlet,2025-08-20], and [user:superhelen,2025-08-20]. Also thanks to our testers for valuable feedback, and the Teamscode web and logistics teams for making this contest possible! Also thanks to [user:omeganot,2025-08-24] for writing an unofficial editorial [here](https://codeforces.me/blog/entry/145620). [Novice A/](https://codeforces.me/gym/106042/proble...
void mergeSort(vector&bufLeft,vector&bufRight,Func&&eval,vector, using Func=int(*)(int); static const Func eval[8]={ [](int i)->int{return arr[i]-0-0

Full text and comments »

  • Vote: I like it
  • +27
  • Vote: I do not like it

26.
By VladProg, 8 years ago, translation, In English
Codeforces Round #499 — editorial [problem:1011A] Author: Mike Mirzayanov ([user:MikeMirzayanov,2018-07-26]). <spoiler summary="Tutorial"> [tutorial:1011A] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; int main() { int n,k; cin>>n>>k; string s; cin>>s; sort(s.begin(),s.end()); char last='a'-2; int ans=0; int len=0; for(int i=0;i<n;i++) if(s[i]>=last+2) { last=s[i]; ans+=s[i]-'a'+1; len++; if(len>=k) cout<<ans,exit(0); } cout<<-1; } ~~~~~ </spoiler> [problem:1011B] Author: Mike Mirzayanov ([user:MikeMirzayanov,2018-07-26]). <spoiler summary="Tutorial"> [tutorial:1011B] </spoiler> <spoiler summary="Solution"> ~~~~~ #include <bits/stdc++.h> using namespace std; const int N = 100; int main() { int n, m; cin >> n >> m; vector<int> c(N + 1); for (int i = 0; i < m; i++) ...
> eval(const vector > &a) { if (a.size() == 1) { auto ret = a[0, solve = eval(polys[who[0]]).first; auto big_binoms = binom(x, n); for (int i = 0; i <= n, ], r[v]); } auto go = eval(polys[who[r[v]]]).first; go.insert, pair , vector > eval(const vector > &a) { if (a.size() == 1

Full text and comments »

  • Vote: I like it
  • +109
  • Vote: I do not like it

27.
By Crysfly, history, 7 weeks ago, In English
UOJ Prime Round 2026 & UOJ Challenge #1 [UOJ Prime Round 2026](https://uoj.ac/contest/112) will be held at [10:00 AM on Saturday, August 8 (UTC +8)](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20260808T1000&p1=33)! The contest will last for 672 hours (28 days). [UOJ Challenge #1](https://uoj.ac/contest/113) will be held at [10:00 AM on Sunday, August 9 (UTC +8)](https://www.timeanddate.com/worldclock/fixedtime.html?iso=20260809T1000&p1=33)! The contest will also last for 672 hours (28 days). UOJ Prime Round has already been mentioned in a [previous blog post](https://gezhiyuan.blog.uoj.ac/blog/9779). It will bring together problems from on-site contests over the past year that were solved by almost nobody during the contests and have received relatively few post-contest submissions. As for UOJ Challenge, [user:Gellyfish,2026-08-08] happened to have an interesting problem that did not seem to fit particularly well anywhere else, so we thought we might as well release it alongside UOJ Prime Round for eve...
automatically generated full-contest PDF statements and samples, as well as a CCF-style `selfeval, well as a CCF-style `self eval` testing program

Full text and comments »

  • Vote: I like it
  • +22
  • Vote: I do not like it

28.
By NahC0el, 17 months ago, In English
Codeforces Round 1023 (Div 2) Editorial Hope you enjoyed the round! [problem:2107A] <spoiler summary = "Solution"> When all the elements of the array are equal, the solution is trivially impossible since the $\gcd$ of any subset will always be equal to $a_1$. That is infact the only $\texttt{No}$ case. We show a construction otherwise. Let $\operatorname{mx} = \max(a)$. Put all the elements equal to $\operatorname{mx}$ in one set, and all the other elements in the other set. Then, the $\gcd$ of the first set is $\operatorname{mx}$ while the other set will have a strictly smaller $\gcd$ (because $\gcd(a, b) \le \min(a, b)$) Time complexity is $O(n)$. </spoiler> <spoiler summary = "Code"> ```cpp #include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while (t--){ int n; cin >> n; vector <int> a(n); for (int i = 0; i < n; i++){ cin >> a[i]; } int mn = *min_element(a.begin(), a.end()); int mx = *max_el...
= false; } int eval(int x) const { return m * x + b; } bool parallel(const line &l, ; iter it = --hull.lower_bound(q); return - it -> eval(x); } };, int eval(int x) const { return m * x + b; } bool parallel(const line &l) const { return m == l.m

Full text and comments »

  • Vote: I like it
  • +157
  • Vote: I do not like it

29.
By chromate00, 4 years ago, In English
I will be using Ruby along with two other languages on today's Round (UPD: with results!) For the few weeks so far, I have been practicing ruby on multiple platforms (Atcoder and BOJ, solved about ~150 in total?). Now I feel that I am fluent enough with the language, so I will be using Ruby, along with Python 3 and C++, on todays Round (the Div.3). After that, I would like to share my honest thoughts about using Ruby in CP with others as well. I am eager to see how well Ruby can perform on Codeforces today! P.S. Yes, I am writing this blog also for the ignorant people who might argue about this saying that I am cheating again, why can't they understand that one person can understand more than 2~3 languages? (Yes, I could've used Ruby, Java, C++, Python, and JS all in the same contest. I simply don't because there's no merit for that.) **UPD: The round has concluded. I solved 4 tasks in total, 3 with Ruby and 1 with Python, and then tried 2 more tasks with C++. (Could not come up with the idea on E, could not come up with the edge cases on G. This is not to argue with ...
```ruby gets.to_i.times do puts eval gets end ```, solution. ```ruby gets.to_i.times do puts eval gets

Full text and comments »

  • Vote: I like it
  • +12
  • Vote: I do not like it

30.
By hly1204, history, 5 years ago, In English
A simple way to understand the transposed algo of multi-eval # A simple way to understand the transposed algo of multi-eval A simple way to understand the transposed algorithm of multi-point evaluation of polynomials in [Tellegen’s Principle into Practice](https://specfun.inria.fr/bostan/publications/BoLeSc03.pdf). I learned this from Bernstein's paper [Scaled Remainder Trees](http://cr.yp.to/arith/scaledmod-20040820.pdf). If there are any mistakes, please tell me, thanks! (Sorry for my poor English) Let $\mathbb{R}((x))$ denote the ring of formal Laurent series, $\mathbb{R}\lbrack x\rbrack$ denote the ring of polynomial. $f(x)\bmod 1:=f_{-1}x^{-1}+f_{-2}x^{-2}+\cdots$. Bernstein showed that division in $\mathbb{R}\lbrack x\rbrack$ is division in $\mathbb{R}((x^{-1}))$. Here is a concrete example. Let $A(x):=1+x+4x^2+5x^3+x^4+4x^5\in\mathbb{R}\lbrack x\rbrack$ and $B(x):=1+9x+8x^2+x^3\in\mathbb{R}\lbrack x\rbrack$, we want to compute $Q(x),R(x)\in\mathbb{R}\lbrack x\rbrack$ such that $A(x)=B(x)Q(x)+R(x)$ and $\deg R(x)\lt \deg B(x)$ ...
A simple way to understand the transposed algo of multi-eval

Full text and comments »

  • Vote: I like it
  • +60
  • Vote: I do not like it

31.
By tridipta2806, history, 6 months ago, In English
Insomnia'26 Editorial ####[Problem A : Ancient Trees](https://codeforces.me/gym/680528/problem/A) Problem Idea: [user:shorya1835,2026-03-23], Problem Preparation: [user:aastik231205,2026-03-23] <spoiler summary="Hint 1"> You are allowed to use intermediate vertices in your sequence. Does it ever actually help? For any three vertices $a$, $b$, $c$, what is the relationship between $c(a,b) + c(b,c)$ and $c(a,c)$? Recall that for non-negative integers, $x + y \geq x \oplus y$. </spoiler> <spoiler summary="Answer for Hint 1"> Since, $c(a,b) + c(b,c) \geq c(a,b) \oplus c(b,c)$, Splitting the path doesn't minimize the distance at all. Hence $d(u,v) = c(u,v)$ always. </spoiler> <spoiler summary="Hint 2"> Since $d(u,v) = c(u,v)$ always, we can maintain a running mask $M$ (XOR of all Type 1 updates so far). A path with $\ell$ edges has its XOR-distance changed only if $\ell$ is odd, flipping their XOR-distance by $M$, depending only on the running XOR of Type 1 queries so far. Can you precomput...
){ cur = conv(cur, {1, mod-modpow( a1[l], mod - 2)}); ans[l]=eval, ; } ll eval(const vl& a, ll x){ ll x1=1,ans=0; for(auto &i:a){ ans=(ans+i*x1, ll eval(const vl& a, ll x){ ll x1=1,ans=0; for(auto &i:a){ ans=(ans+i*x1)%mod

Full text and comments »

Tutorial of Insomnia-26
  • Vote: I like it
  • +113
  • Vote: I do not like it

32.
By willy108, history, 2 years ago, In English
Teamscode Spring 2024 Contest Official Editorial Sorry for the long wait. These problems were brought to you by [user:esomer,2024-04-05], [user:danx,2024-04-05], [user:dutin,2024-04-05], [user:jay_jayjay,2024-04-05], [user:oursaco,2024-04-05], [user:superhelen,2024-04-05], [user:thehunterjames,2024-04-05], [user:willy108,2024-04-05], and [user:yash_9a3b,2024-04-05]. Also, massive thanks to [user:omeganot,2024-04-05] for his [unofficial editorial](https://codeforces.me/blog/omeganot) (which was posted a lot sooner than ours). [Novice A/](https://codeforces.me/gym/105066/problem/A)[Advanced A: It's Time to Submit](https://codeforces.me/gym/105067/problem/A) ================== <spoiler summary="Solution"> Both "YES" and "NO" are consistent answer (as long as exactly one of them is the answer). If you print "YES" and get AC, you are getting AC by printing the sample output. If you print "NO" and get AC, you are getting AC by not printing the sample output. Never assume just because the carrot is big ... the sample out...
){ for(auto x : a) cerr << x << " "; cerr << "\n"; } info eval(string s){ ll d = 0; int c = 0, info eval(string s){ ll d = 0; int c = 0; int m3 = 0; info ret = {0ll, 0ll, 0ll}; cerr, void solve(){ string l = (string) in; string r = (string) in; auto sl = eval (l); auto sr

Full text and comments »

  • Vote: I like it
  • +42
  • Vote: I do not like it

33.
By Mindeveloped, history, 23 months ago, In English
I made (Not Yet Another) problem filter script I made my own script to filter problems in CF problemset. If such script with same function already exists you can ignore my post or downvote it. This is a python 3 script that fetches all problems from CF problemset and allows custom filtering. It supports custom filter criteria in python expression format. After you input the filter function, it filters the problems and choose a random one. More details can be found in spoilers below. <spoiler summary="Filter Expression"> In your filter expression, you are given variables `problem` and `contest`, and it's supposed to returns `1` if the problem matches your search, `0` otherwise. Example: `problem.rating == 2400 and "geometry" not in problem.tags and contest.divison == "Div. 1"` The variable `problem` contains such properties: ``` id - The ID of the problem, in the format e.g. 1234H, 2024A. rating - The CF rating tag. Can be absent. contest - The contest id of this problem. Equals to contest.id. index - The problem...
("Enter filter expression ") for problem in problems: try: if eval (schema,None,{'problem, : try: if eval(schema,None,{'problem':problem,'contest':contests[problem.contest

Full text and comments »

  • Vote: I like it
  • +15
  • Vote: I do not like it

34.
By cjchirag7, 6 years ago, In English
Editorial of Virtual Farewell IIT (ISM) Dhanbad Here, we present you the Editorial for the [Virtual Farewell IIT (ISM)](https://codeforces.me/contestInvitation/a52c365430f69a8f04d28eafb2cad804d392072c). I hope you enjoyed the contest !! [A. Farewell or Best Wishes](https://codeforces.me/gym/102625/problem/A) ----------------- **Author :** [user:chefpr7,2020-06-21] <spoiler summary="Tutorial"> Firstly, if the office is located anywhere in the path of the auto, then their plan will always fail, i.e if $X=1$ or $Y=M$ then best wishes are on the way. Otherwise, the auto can meet the agents only in the cells ($1$, $Y$) or ($X$, $M$). The time needed to reach these cells can be obtained in $O$($1$). Agent A initially headed North reaches the cell ($1$, $Y$) at time $t$ = $Y$-$1$ and after that it comes back at intervals of $2*(N-1)$. So all we need to do is check whether the time taken by the auto to reach any of the two cells is a term in the arithmetic progression of time taken by an agent to reach that cell. If we ch...
-x.b)/(double)(x.m-y.m); } vector st; vector points; int eval(int x,line y, int eval(int x,line y) { return x*y.m+y.b; }, int findbest(int x) { int ind=lower_bound(all(points),x)-points.begin(); return eval(x,st[ind]); }

Full text and comments »

  • Vote: I like it
  • +48
  • Vote: I do not like it

35.
By jlahcejlot, history, 4 weeks ago, In English
Mindrift is looking for competitive programmers — get paid to break AI-generated code ### Mindrift is looking for competitive programmers — get paid to break AI-generated code **Who we are:** Mindrift connects specialists with project-based opportunities for leading tech companies, focused on testing, evaluating, and improving AI systems. We're not a product company — we build the training and evaluation data that makes AI models actually good at their job. Right now, we're looking for competitive programmers to help with coding models specifically. We're looking for competitive programmers to help build problems and graders used to train AI coding models. If you enjoy problem-setting, hacking weak solutions, and writing brutal test cases — this might be for you. **What you'd actually do:** - Write original algorithmic problems (statement, constraints, intended solution) - Write correct solutions in C++ and Python - Write realistic wrong solutions — the kind of bugs real contestants actually submit - Build generators, edge cases, stress tests, and testlib...
LLM code benchmarks/eval datasets. **Format:** project-based, freelance. ~10-20 hrs/week during, judges), testlib experience, or prior work on LLM code benchmarks/eval datasets.

Full text and comments »

  • Vote: I like it
  • -19
  • Vote: I do not like it

36.
By KEPuzOfficial, 23 months ago, translation, In English
One Liner Contest ![ ](https://cpython.s3.amazonaws.com/media/images/contest-preview/410.jpg) I invite everyone to the [contest](https://kep.uz/competitions/contests/contest/410), which will take place on **November 3, 2024 at 16:00UTC**. **Contest Rules:** - In this contest, you need to write one-line solutions for problems. - The solution is scored by the length of the code (Code Golf). No penalties. **Only Python** **Contest info:** - Number of problems: **8** - Duration: **2 hours** **Prizes:** - First place – **20$ (USDT)** - Second place – **15$** - Third place – **10$** Link to the platform: https://kep.uz/competitions/contests/ One Liner #10: https://kep.uz/competitions/contests/contest/386 P.S. Registration on the platform only via Gmail/Github. **UPD** Thank you for participating **Results** 1. [user:Haksell,2024-11-03] &mdash; 611 2. marcocheng &mdash; 519 3. [user:Timosh,2024-11-03] &mdash; 465 4. [user:shogo314,2024-11-03] &m...
~~~~~ print(int(input())/eval(input())**2) ~~~~~

Full text and comments »

  • Vote: I like it
  • +39
  • Vote: I do not like it

37.
By pashka, history, 6 years ago, In English
Bonus Lecture 2. Link-Eval Hey CodeForces! So, the [first bonus lecture](https://youtu.be/ahz0HvV_QYU) worked out pretty well, let's have another one! [Tomorrow at 17:00 MSK](https://www.timeanddate.com/worldclock/fixedtime.html?msg=lecture&iso=20210115T1700&p1=352&ah=1) we will discuss Link-Eval data structure, part of [this work by R. E. Tarjan](https://www.cs.princeton.edu/courses/archive/fall03/cs528/handouts/applications%20of%20path%20compression.pdf). See you!
Bonus Lecture 2. Link-Eval, /fixedtime.html?msg=lecture&iso=20210115T1700&p1=352&ah=1) we will discuss Link- Eval data structure, part, =20210115T1700&p1=352&ah=1) we will discuss Link-Eval data structure, part of [this work by R. E. Tarjan

Full text and comments »

  • Vote: I like it
  • +60
  • Vote: I do not like it

38.
By Nickolas, 9 years ago, translation, In English
April Fools Day Contest 2017: editorial Incredibly, 34 people managed to solve all problems! 1032 participants solved at least one problem, and it wasn't always A :-) #### [problem:784A] Traditionally the first problem of April Fools Day contest asks to recognize a sequence of integers by problem title and (this time) a single data point. OEIS search for just the given number isn't going to give a result &mdash; or rather is going to give too many to be useful. However, if you look for the problem title, the first result for "numbers joke" query will give you https://oeis.org/A006753 "Smith (or joke) numbers", which has 27 as its 3rd element. #### [problem:784B] This problem is a variation on a [kid's riddle](http://codeforces.me/predownloaded/31/a2/31a26647d3b860e3a6e9cb82acf532d1059b1da0.jpg) in which you have to count closed loops in digits of the number &mdash; one in 4, 6, 9 and 0 and two in 8. [cut] Since we're programmers here, we had to count loops in digits in hexadecimal notation of the number (writi...
expression in a normal language (preferably Python with its eval) and generate a program which would, its eval) and generate a program which would print each digit of the answer.

Full text and comments »

  • Vote: I like it
  • +87
  • Vote: I do not like it

39.
By teplohod, history, 4 years ago, In Russian
Фишки в Python которые возможно вы не знали. Использование символа подчеркивания для получения последнего значения Вы можете использовать символ подчеркивания (_) в качестве переменной, чтобы получить последнее вычисленное значение в интерпретаторе Python. Это может быть полезно, когда вам нужно быстро получить результат предыдущей операции. Использование цепочки операторов сравнения В Python вы можете использовать цепочку операторов сравнения, чтобы проверить, находится ли значение в диапазоне. Например, "1 < x < 10" означает, что "x" должно быть больше 1 и меньше 10. Использование функции locals () для получения локальных переменных Функция locals() позволяет получить доступ ко всем локальным переменным в текущей области видимости. Это может быть полезно для отладки или для получения списка всех переменных, определенных в текущей функции. Использование синтаксиса распаковки для разделения кортежей и списков Вы можете использовать синтаксис распаковки, чтобы разделить кортежи и списки на ...
eval() для выполнения строки кода Функция eval() позволяет выполнять строку кода в качестве, Использование функции eval() для выполнения строки кода Функция eval() позволяет выполнять

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

40.
By alessandrosolbiati, 8 years ago, In English
elegant Python solutions TEMPLATE FUNCTIONS: ~~~~ stdin = lambda type_ = "int", sep = " ": list(map(eval(type_), raw_input().split(sep))) """ >>> stdin() 1 2 3 4 >>>[1, 2, 3, 4] """ joint = lambda sep = " ", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args) """ >>> joint(" ", [1, 2]) '1 2' >>> joint(" ", [1, 2], [2, 3]) '1 2 2 3' """ def iters(): return map(int(raw_input())) ~~~~ PROBLEMS: ================== [http://codeforces.me/contest/988/problem/B](http://codeforces.me/contest/988/problem/B) ~~~~~ n = int(input()) a = sorted((input() for _ in range(n)), key=lambda x: len(x)) v = all(a[i] in a[i+1] for i in range(n-1)) print('YES\n'+"\n".join(a) if v else 'NO') ~~~~~ ================== [http://codeforces.me/contest/994/problem/A](http://codeforces.me/contest/994/problem/A) ~~~~ R = lambda: (int, input().split()) n, a, b = R(), R(), R() print(' '.join(map(str, (x for x in a if x in b)))) ~~~~ ================== [h...
TEMPLATE FUNCTIONS: ~~~~ stdin = lambda type_ = "int", sep = " ": list(map(eval (type_, ~~~~ stdin = lambda type_ = "int", sep = " ": list(map(eval(type_), raw_input().split(sep

Full text and comments »

41.
By bholagabbar, 11 years ago, In English
BitMasking & Subset Listing for Absolute Beginners I happened to write an answer on Quora yesterday for **'How to list all the subsets of a set where elements need not be necessarily unique'**. http://qr.ae/fwOCc Though several tutorials already exist, here is my 'simplified' version solving the above problem using bitmasking because personally, I was really confused when i learnt this first. Also, this is my first attempt at writing something. Please feel free to comment/criticize and please upvote if you liked the explanation :) More than often, problems where you feel the answer can be found after brute forcing through all the subsets, have smarter and more efficient solutions using Dynamic Programming. Have a look at an Introduction to the Knapsack Problem and Dynamic Programming: http://www.cs.rit.edu/~zjb/courses/800/lec7.pdf That aside, if n is reasonably small, you CAN use BruteForce and list down all the subsets in the process. As mentioned, we will use the technique of BitMasking. Alright, so lets start by trying ...
**. Code: ~~~~~ n=eval(input("Enter n: ")) # keep sub 20-ish max for i in range(0,(2**n)):# loop from, ~~~~~ n=eval(input("Enter n: ")) # keep sub 20-ish max for i in range(0,(2**n)):# loop from 0 to

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

42.
By pank.dm, 13 years ago, In Russian
ICFPC 2013 — Мини-отчет Кто-нибудь еще участвовал в прошедшем ICFPC? Предлагаю здесь пообсуждать решения, впечатления и набранное количество очков. Вкратце опишу наш подход. ### Simple problems Для задач без оператора `fold` мы придумали решение, которое работало лучше чем полный перебор: 1. Сначала делаем прекальк. 2. Выбираем случайным образом `X` &mdash; вектор длины 5-10 из случайных 64 битных чисел. 3. Динамикой вычисляем какие могут быть вектора значений функций сложности не больше `N`, на этом наборе `X`. Число `N` определялось таким образом, чтобы общее количество вариантов не превосходило `10^6`. 4. Теперь делаем запрос `eval` на сервер c этим вектором `X`. 5. По полученному `Y` начинаем раскручивать динамику назад и восстанавливать какие функции могут принимать такие значения. 6. Каждую подходящую функцию пытаемся отправить на сервер в качестве ответа. 7. Если она не подходит, то сервер нам выдает `(x, y)` -- ограничение на функцию вида `f(x) = y`. Продолжаем раскручивать динам...
`10^6`. 4. Теперь делаем запрос `eval` на сервер c этим вектором `X`. 5. По полученному `Y, вариантов не превосходило `10^6`. 4. Теперь делаем запрос `eval` на сервер c этим вектором `X`. 5. По

Full text and comments »

  • Vote: I like it
  • +47
  • Vote: I do not like it

43.
By dush1729, history, 6 years ago, In English
An alternate approach using eval for Google Kickstart 2020 Round B problem Robot Path Decoding Problem: [https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc8/00000000002d83dc](https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc8/00000000002d83dc) We can solve above problem using stack. But we can use eval from python 2 library also to solve this question. Thanks to [user:sonu628,2020-04-20] for this idea. But unfortunately this solution gives Runtime Error(RE) for second test and Accepted for first test. Can we fix this? Solution: [https://ideone.com/dDwtoM](https://ideone.com/dDwtoM)
An alternate approach using eval for Google Kickstart 2020 Round B problem Robot Path Decoding, We can solve above problem using stack. But we can use eval from python 2 library also to solve

Full text and comments »

  • Vote: I like it
  • -21
  • Vote: I do not like it

44.
By hello____world, history, 6 years ago, In English
Doubts on Ternary Search I have two doubts regarding Ternary Search, I hope someone can help. ### 1. Complexity: In every blog, I find complexty of ternary search as O(log3(N)). I know how we get this complexity but if we do something like this: ```cpp int i=0, j=MAX; while(i<=j){ int m=(i+j)/2; if(eval(m)<eval(m+1)){ j=m-1; }else{ i=m+1; } } cout<<j+1; ``` Wouldn’t complexity be O(log(2))? What are the limitations of this kind of implementation? I believe we can modify this implementation to work with decimal values as well. ### 2. Type of Function? Can we use this algorithm work with non-strict decrease-increase function? If I have a function with values: `{5,5,4,3,3,3,2,3,4,4,5}` i.e: `f(0)=5`, `f(2)=4` and so on. How should I implement ternary search on this function? To be specific, what should I do if f(m1)==f(m2)? If you have any blog which can help me with these doubts, please share.
(eval(m)<eval(m+1)){ j=m-1; }else{ i=m+1; } } cout<, ```cpp int i=0, j=MAX; while(i<=j){ int m=(i+j)/2; if(eval(m)<eval(m+1)){ j=m

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

45.
By MrMoon, 2 months ago, In English
PSUT JCPC Qualification 2026 Tutorial Hints are mostly related, so you have to think and get some observations before understanding the next, make sure to understand the code before you submit it as well, "Most problems in life are due two reasons: act without thinking, think without acting" ~the,2026-08-02 poet,2026-08-01 Big thank you to the testers for improving this problem set beyond what it was, [user:the_seal,2026-08-02] , [user:Rayo,2026-08-02], [user:samsoom,2026-08-02], [user:lazlooz,2026-08-02] The contest exist in the group so make sure to join https://codeforces.me/group/ppRciMeJFg Some of these problems were inspired from other problems across the internet, "If I have seen further, it is by standing on the shoulders of giants." ~the,2026-08-02 poet [Problem A: MrMoon creates Lucky Number Seven Command](https://codeforces.me/group/ppRciMeJFg/contest/707652/problem/A) ================== ### 7 [Problem B: Moon creates seal backflips](https://codeforces.me/group/ppRciMeJFg/contest/707652/probl...
inf = 2e18; struct Node { ll st, ln, w; }; struct Line { ll m, c; ll eval(ll x) { return m, ; }; struct Line { ll m, c; ll eval(ll x) { return m * x + c; } }; struct node { Line

Full text and comments »

  • Vote: I like it
  • +21
  • Vote: I do not like it

46.
By MciprianM, 16 years ago, In English
uwi wrecked the eval!!! Today, 6th of&nbsp; July at 4:21:58 AM <a href="http://codeforces.me/profile/uwi">uwi</a> sent a solution in Java to Codeforces Beta Round #22's problem E-Scheme.<br><a href="http://codeforces.me/contest/22/status">See wreckage</a>.<br>HAHA!!!
uwi wrecked the eval!!!

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it