Language: C++

#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 n;
    i64 L, T;
    std::cin >> n >> L >> T;

    vec<i64> ans(n);
    i64 cnt = 0;
    for (i64 i=0; i<n; i++) {
        i64 x, w;
        std::cin >> x >> w;

        i64 r = w==1 ? (x + T) % L : ((x - T) % L + L) % L;
        i64 q = w==1 ? (x + T) / L : -((T - x + L - 1) / L);
        ans.at(i) = r;
        cnt += q;
    }a#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 n;
    i64 L, T;
    std::cin >> n >> L >> T;

    vec<i64> ans(n);
    i64 cnt = 0;
    for (i64 i=0; i<n; i++) {
        i64 x, w;
        std::cin >> x >> w;

        i64 y = x + (w==1 ? T : -T);
        i64 r = (y % L + L) % L;
        i64 q = (y - r) / L;
        ans.at(i) = r;
        cnt += q;
    }
    cnt = (cnt % n + n) % n;
    std::sort(ALL(ans));
    std::rotate(ans.begin(), ans.begin() + cnt, ans.end());

    for (i64 x: ans) {
        std::cout << x <<'\n';
    }
}

    cnt = (cnt % n + n) % n;
    std::sort(ALL(ans));
    std::rotate(ans.begin(), ans.begin() + cnt, ans.end());

    for (i64 x: ans) {
        std::cout << x <<'\n';
    }
}


Compiler output:
a.cc:45:7: error: stray '#' in program
   45 |     }a#define ENABLE_DEBUG 1
      |       ^
a.cc: In function 'int main()':
a.cc:45:6: error: 'a' was not declared in this scope
   45 |     }a#define ENABLE_DEBUG 1
      |      ^
a.cc:57:1: error: a template declaration cannot appear at block scope
   57 | template <class T, class U> using pair = std::pair<U, T>;
      | ^~~~~~~~
a.cc:59:1: error: a template declaration cannot appear at block scope
   59 | template <class... Args> using tuple = std::tuple<Args...>;
      | ^~~~~~~~
a.cc:61:1: error: a template declaration cannot appear at block scope
   61 | template <class T> using numr = std::numeric_limits<T>;
      | ^~~~~~~~