Um_nik's blog

By Um_nik, history, 12 months ago, In English

Complete shitpost, don't take it seriously. We were discussing #define int long long and I suggested defining it to one letter if you want to save on typing so desperately. jeroenodb said that those are reserved for variables, which prompted me to think, "Is there a letter I don't standardly use for some particular purpose?" Then I compiled the following list, and then I thought, "Well, I already wrote it, let's put it on cf", so here we are.

a - array, but also all sorts of stuff
b - second array
c - third array / count
d - delta / divisor
e - event / edge
f - flag
g - graph / second flag
h - third iterator / third flag / height
i - iterator
j - second iterator
k - third input size / some parameter (i know, those are all parameters, but for some reason k is parameter)
l - left
m - number of edges / second input size
n - input size
o - ???
p - permutation / position
q - number of queries / query / second permutation / second position
r - right
s - string
t - tests / time / temp
u - second vertex
v - vertex
w - weight / value (because v is vertex???)
x - variable in math sense / x coordinate
y - y coordinate
z - use when need some letter that won't be used / z coordinate
  • Vote: I like it
  • +766
  • Vote: I do not like it

| Write comment?
»
12 months ago, hide # |
 
Vote: I like it +139 Vote: I do not like it

o — ???

I have at times used o/z to keep track of the number of ones/zeroes in an array (often later realizing that I could simply have used cnt[2]). Note that this is a particularly cursed used of o as it looks like a 0 but is being used to indicate ones here, and I have indeed made mistakes because of this.

»
12 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I have used o a handful of times for a random variable name I confirm o += 1 is awful 3/10

»
12 months ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

I use o for the order of a certain array, when you want to do some sort without messing with the original array. For example when doing MO i might do an implementation like that:

vector<pii> queries(q);

for(auto&[l,r] : queries)
    cin >> l >> r, r--;
    
vector<int> o(q);
iota(all(o),0);

sort(all(o),[&](int a, int b){
    const int ba = queries[a].ff/LEN, bb = queries[b].ff/LEN;

    if(ba == bb)
        return (ba&1) ? queries[a].ss > queries[b].ss : 
            queries[a].ss < queries[b].ss;
    return ba < bb;
});
»
12 months ago, hide # |
← Rev. 2  
Vote: I like it +70 Vote: I do not like it

The real unused character is _

  • »
    »
    12 months ago, hide # ^ |
    ← Rev. 4  
    Vote: I like it 0 Vote: I do not like it

    It's not that it will never be used. I have previously used this variable name for the following purposes, to avoid occupying other variable names:

    int _ = 1, ......;
    void solve();
    signed main() {
        cin >> _; // Comment out this line when the problem is not multi-test.
        while(_--) solve();
        return 0;
    }
    
  • »
    »
    12 months ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    It is very used for me when a variable is only modified in one place and accessed in one place. Examples are for (const auto &_: g[u]) { int v=_.first,w=_.second; ... }, int _;cin>>_;while (_--) { ... }, etc.

  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    no its $

  • »
    »
    12 months ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    .

  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it +24 Vote: I do not like it

    I do use it sometimes as blank placeholders, when I want to input 2 lists and then pair them up at the same time.

    vector<pair<int,int>> v(n);
    for (auto &[x, _]: v) cin >> x;
    for (auto &[_, y]: v) cin >> y;
    
  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Nah, you use that to #define _ << ' ' <<

  • »
    »
    12 months ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    In many languages _ means a discarded return value. iirc in C++23 _ also means a discarded value/placeholder in structured binding.

  • »
    »
    12 months ago, hide # ^ |
    ← Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    I use it a lot for foreach loops with vectors of pairs, when I am only interested in one element on that loop, helps me keep track of what I am doing or something, don't know why I started, but now I always do it

    for example

    vector<pair<int, int>> coords
    for(auto &[x, _]: coords){
        // some process in which I am only interested in the x coordinate
    }
    

    And I also sometimes use it as a loop iterator when the iterator variable only needs to loop but doesn't need to be accessed inside the loop

    for(int _ = 0; _ < n; _++) {
       // code that doesn't require the iterator
    }
    
»
12 months ago, hide # |
 
Vote: I like it +32 Vote: I do not like it

For me, f and d are sometimes for dp, and g,h for the second and the third dp array.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

You could use o for 1 to trick people into hacking your solutions thinking you have an off by 1 bug but it might violate code obfuscation rules and also requires hacking to be common in contests.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I use const modint<998244353> o=0;

»
12 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

I tend to use o to mean offset.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

'o' for ones in zero and one array + odd even tracking also sometimes.

»
12 months ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

o: odd

then I find out my code is failing because I wrote cnt = o instead of cnt = 0

»
12 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

If you really want to save as much time as possible on typing, you should be naming all of the variables 30+ symbols, so you train your typing speed while solving problems.

And after 10 years of CP you switch to 1 letter variables only to achieve maximum speed!

»
12 months ago, hide # |
 
Vote: I like it +196 Vote: I do not like it

Am I the only one who always preferred using u as the first vertex and v as the second vertex?

It makes more sense to me since u comes before v in the alphabet and the edge is u -> v.

Example: DFS
»
12 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I use some of these, but everyone seems to have their own preferred variable and macro style. and i think That’s totally fine — as long as the code remains readable to you (and your teammates).

»
12 months ago, hide # |
 
Vote: I like it +101 Vote: I do not like it

I usually use k as a third iterator.

»
12 months ago, hide # |
 
Vote: I like it +30 Vote: I do not like it

My most controversial one-letter variable naming's got to be using z for the third vertex (specifically, lca(u, v)). Come at me.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I use o — operator

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I use o for "order", when ord is already taken

»
12 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

sometimes i define m as for mod purpose like m=1e9+7

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

If common small ones get used up, use their capital form.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

o : ok

»
12 months ago, hide # |
 
Vote: I like it -16 Vote: I do not like it

d — disrance and depth also s — sum t — temporary trash variable For me, in addition to above. In rest it all pretty much matches my usage of the letters haha

»
12 months ago, hide # |
← Rev. 2  
Vote: I like it +8 Vote: I do not like it
  • r — row
  • c — column
  • l — lca
  • f — first
  • s — second, start
  • e — end
  • q — queue
  • d — distance
»
12 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

v — vector

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

o — answer, output

»
12 months ago, hide # |
 
Vote: I like it +76 Vote: I do not like it

There is something worse than #define int long long

constexpr int oo = 1e9;
constexpr ll OO = 1e18;
»
12 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

f also flow

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

l for list

»
12 months ago, hide # |
← Rev. 4  
Vote: I like it 0 Vote: I do not like it

For me:

d - depth (in tree problem)
f - father (in tree problem)
h - hash
m - map
p - mod (especially prime)
s - size (in tree problem) / set / stack
»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Well I think use s for sum is quite suitable

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I usually use o for a iterator which is necessary but barely appears in any calculating of at least two variables lol

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

'o' can be count of odds, meanwhile i use 'q' for priority_queue

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I also sometimes use o and e for even and odd counts.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What about one uppercase letter names? C for binomial, I and J for iterators, X for random intermediate value, A and B when the answer is A-B

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

v for value, w for walue

i for index, j for jndex XD

sometimes i use o for original, like ov — original value, nv — new value, but hardly use a single o as a name

»
12 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I have always been advised against using single-letter variables.

»
12 months ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

I remember that I've recently posted similar comment. But turned out it was 10 years ago...

Here it is

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I often use $$$t$$$ for second string, and $$$f$$$ for dp table.

»
12 months ago, hide # |
← Rev. 2  
Vote: I like it -10 Vote: I do not like it

you all cheaters should learn from this blog

hint for those who don't get the joke
»
12 months ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

Maybe in some data structures when we need to maintain two operations, 1 for ... and 2 for ..., we may use

int o;
cin >> o;
if(o == 1) { // first operation
} else { // second operation
}
»
12 months ago, hide # |
← Rev. 5  
Vote: I like it 0 Vote: I do not like it

Do you really think people who use #define int long long do so because long long is too long to type? We'd use #define ll long long then

  • »
    »
    12 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I agree with you, that was just some context for how I have come to write this list.

  • »
    »
    11 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I think starters normally use int, then not used to changing to long long so they use #define int long long.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

f can be function, then g could be second function, and h third function.

»
12 months ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

I use d for

Spoiler
»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

random name for me(in 2024.12~2025.7)(in order)(includes delta height ...) h y l z x now the same,except a,b,c,d added

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

so "z" is just useless -_-

and the funny thing is that I use "z" the most)

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Great blog that helps me understand more about code habits. Here are some additional meanings (completely coming from my own style.)

p[] and s[] can also be used for prefixs and suffixes.

Sometimes, I use s[] to represent the size of a certain array or something similar to that.

z[] is sometimes used in the ex-kmp algorithm.

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

this is so accurate lmao

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I sometime use p as prefix, s as sum and k as the third iterator

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

$$$\texttt{Variable 'o' stands for "Oh no, where did my bug go?"}$$$

»
11 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

I use the letter “o” to represent the abbreviation of “ok”, or simply because in some places using it looks round and cute.

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

This post reminded me of the exact same conversation i had years ago. Editoral for a problem used a variable named not o, not oo, but ooo. We were flabbergasted to say the least

»
11 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Don't know about others ,but I find capital variable naming like A,M,N,O,I,J,CC,TT,MM,NN much handy xD , A, B -vectors
M,N — input size O- odd even counts I,J ->auto iterators CC ,TT — count . etc

»
10 months ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

Helpfull

»
8 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

Not one letter variables but I almost always use set<int> ste; and map<int,int> mpa;

»
8 months ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

I have used o a handful of times for a random variable name "ones" to count the number of ones in the string or array :)