Language: C++

#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;

int n, l[MAXN], r[MAXN], id_l[MAXN], l_now = 1, id_r[MAXN], r_now = 1, ans;

inline bool cmp_l(register int a, register int b) {
    return l[a] > l[b];
}

inline bool cmp_r(register int a, register int b) {
    return r[a] < r[b];
}

inline int max(register int a, register int b) {
    return a > b ? a : b;
}

inline int abs(register int a) {
    return a > 0 ? a : -a;
}

int main() {
    scanf("%d", &n);
    for (register int i = 1; i <= n; ++i) {
        scanf("%d%d", &l[i], &r[i]);
        id_l[i] = id_r[i] = i;
    }
    sort(id_l + 1, id_l + 1 + n, cmp_l);
    sort(id_r + 1, id_r + 1 + n, cmp_r);''
    register int pos, ll = abs(l[id_l[1]]), rr = abs(r[id_r[1]]);
    register bool flag;
    if (ll >= rr) {
        ++l_now;
        pos = l[id_l[1]];
        ans += ll;
        flag = 1;
    }
    else {
        ++r_now;
        pos = r[id_r[1]];
        ans += rr;
        flag = 0;
    }
    for (register int i = 2; i <= n; ++i)
        if (flag) {
            if (l[id_r[r_now]] <= pos && r[id_r[r_now]] >= pos) {
                ++r_now;
                flag = 1;
                continue;
            }
            ans += abs(r[id_r[r_now]] - pos);
            pos = r[id_r[r_now++]];
            flag = 0;
        }
        else {
            if (l[id_l[l_now]] <= pos && r[id_l[l_now]] >= pos) {
                ++l_now;
                flag = 1;
                continue;
            }
            ans += abs(l[id_l[l_now]] - pos);
            pos = l[id_l[l_now++]];
            flag = 1;
        }
    ans += abs(pos);
    printf("%d", ans);
    return 0;
}


Compiler output:
a.cc:30:41: error: empty character constant
   30 |     sort(id_r + 1, id_r + 1 + n, cmp_r);''
      |                                         ^~
a.cc:7:32: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    7 | inline bool cmp_l(register int a, register int b) {
      |                                ^
a.cc:7:48: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    7 | inline bool cmp_l(register int a, register int b) {
      |                                                ^
a.cc:11:32: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 | inline bool cmp_r(register int a, register int b) {
      |                                ^
a.cc:11:48: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 | inline bool cmp_r(register int a, register int b) {
      |                                                ^
a.cc:15:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 | inline int max(register int a, register int b) {
      |                             ^
a.cc:15:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   15 | inline int max(register int a, register int b) {
      |                                             ^
a.cc:19:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   19 | inline int abs(register int a) {
      |                             ^
a.cc: In function 'int main()':
a.cc:25:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |     for (register int i = 1; i <= n; ++i) {
      |                       ^
a.cc:30:43: error: expected ';' before 'register'
   30 |     sort(id_r + 1, id_r + 1 + n, cmp_r);''
      |                                           ^
      |                                           ;
   31 |     register int pos, ll = abs(l[id_l[1]]), rr = abs(r[id_r[1]]);
      |     ~~~~~~~~                               
a.cc:32:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |     register bool flag;
      |                   ^~~~
a.cc:33:9: error: 'll' was not declared in this scope; did you mean 'l'?
   33 |     if (ll >= rr) {
      |         ^~
      |         l
a.cc:33:15: error: 'rr' was not declared in this scope; did you mean 'r'?
   33 |     if (ll >= rr) {
      |               ^~
      |               r
a.cc:35:9: error: 'pos' was not declared in this scope; did you mean 'pow'?
   35 |         pos = l[id_l[1]];
      |         ^~~
      |         pow
a.cc:41:9: error: 'pos' was not declared in this scope; did you mean 'pow'?
   41 |         pos = r[id_r[1]];
      |         ^~~
      |         pow
a.cc:45:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |     for (register int i = 2; i <= n; ++i)
      |                       ^
a.cc:47:35: error: 'pos' was not declared in this scope; did you mean 'pow'?
   47 |             if (l[id_r[r_now]] <= pos && r[id_r[r_now]] >= pos) {
      |                                   ^~~
      |                                   pow
a.cc:52:41: error: 'pos' was not declared in this scope; did you mean 'pow'?
   52 |             ans += abs(r[id_r[r_now]] - pos);
      |                                         ^~~
      |                                         pow
a.cc:57:35: error: 'pos' was not declared in this scope; did you mean 'pow'?
   57 |             if (l[id_l[l_now]] <= pos && r[id_l[l_now]] >= pos) {
      |                                   ^~~
      |                                   pow
a.cc:62:41: error: 'pos' was not declared in this scope; did you mean 'pow'?
   62 |             ans += abs(l[id_l[l_now]] - pos);
      |                                         ^~~
      |                                         pow
a.cc:66:16: error: 'pos' was not declared in this scope; did you mean 'pow'?
   66 |     ans += abs(pos);
      |                ^~~
      |                pow