Language: C++

using namespace std;

int N, L, T;
//a 時計回り
//b 逆時計回り
int main() {
    cin >> N >> L >> T;
    vector<int> a(N), b(N);
    int ac = 0;
    int bc = 0;
    int ai0 = 0;
    int av0 = 0;
    int ab0 = 0;

    for (int i = 0; i < N; i ++){
        int ci, wi;
        cin >> ci >> wi;
        if (wi == 1) {
            if (ac == 0){
                ai0 = i;
                av0 = ci;
                ab0 = bc;
            }
            a[ac] = ci;
            ac++;
        }else{
            b[bc] = ci;
            bc++;
        }
    }

    int dt =  T % L;
    //例外処理
    if (bc == 0) {
        for(int i = 0; i < N; i++){
            int p = (a.at(i) + dt) % L;
            cout << p << endl;
        }
        return 0;
    }
    if (ac == 0) {
        for(int i = 0; i < N; i++){
            int p = (L + b.at(i) - dt) % L;
            cout << p << endl;
        }
        return 0;
    }

    // (T % L)秒で何個の反時計周り出会うかの計算
    int count = ai0 + (T / L) * bc * 2;
    int dt2 = dt * 2 ;
    if (dt2 >= L){
        count += bc;
        dt2 -= L;
    }
    int pb;
    if ((av0 + dt2) > L){
        auto iter = lower_bound(b.begin(), b.begin() + bc, av0 + dt2 - L);
        pb = distance(b.begin(), iter);
        count += bc + pb - ab0;
    }
    else{
        auto iter = lower_bound(b.begin(), b.begin() + bc, av0 + dt2);
        pb = distance(b.begin(), iter);
        count += pb - ab0;
    }

    pb = pb % bc;
    int av = (a.at(0) + dt) % L;
    int bv = (L + b.at(pb) - dt) % L;
    int pa = 0;
    int base = av;
    if (bv < base)
        bv += L;
    int acount = 0;
    int bcount = 0;
    count = count % N;
    bool flag = count == 0;
    queue<int> que;
    while(acount < ac && bcount < bc){
        if (av <= bv){
            if(flag)
                cout << av % L << endl;
            else
                que.push(av % L);
            pa++;
            if (pa == ac){
                pa = 0;
            }
            av = (a.at(pa) + dt) % L;
            if (av < base)
                av += L;
            acount++;
        }
        else{
            if(flag)
                cout << bv % L << endl;
            else
                que.push(bv % L);
            pb++;
            if (pb == bc){
                pb = 0;
            }
            bv = (L + b.at(pb) - dt) % L;
            if (bv < base)
                bv += L;
            bcount++;
        }
        count++;
        if (count == N)
            flag = true;
    }
    av %= L;
    for(int i = acount; i < ac; i++){
        if(flag)
            cout << av % L << endl;
        else
            que.push(av);
        pa++;
        if (pa == ac){
            pa = 0;
        }
        av =  (a.at(pa) + dt) % L;
        count++;
        if (count == N)
            flag = true;
    }
    bv %=  L;
    for(int i = bcount; i < bc; i++){
        if (flag)
            cout << bv << endl;
        else
            que.push(bv);
        pb++;
        if (pb == bc){
            pb = 0;
        }
        bv =  (L + b.at(pb) - dt) % L;
        count++;
        if (count == N)
            flag = true;
    }
    while(!que.empty()) {
        cout << que.front() << endl;
        que.pop();
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> N >> L >> T;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:8:5: error: 'vector' was not declared in this scope
    8 |     vector<int> a(N), b(N);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:8:12: error: expected primary-expression before 'int'
    8 |     vector<int> a(N), b(N);
      |            ^~~
a.cc:24:13: error: 'a' was not declared in this scope
   24 |             a[ac] = ci;
      |             ^
a.cc:27:13: error: 'b' was not declared in this scope
   27 |             b[bc] = ci;
      |             ^
a.cc:36:22: error: 'a' was not declared in this scope
   36 |             int p = (a.at(i) + dt) % L;
      |                      ^
a.cc:37:13: error: 'cout' was not declared in this scope
   37 |             cout << p << endl;
      |             ^~~~
a.cc:37:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:37:26: error: 'endl' was not declared in this scope
   37 |             cout << p << endl;
      |                          ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:43:26: error: 'b' was not declared in this scope
   43 |             int p = (L + b.at(i) - dt) % L;
      |                          ^
a.cc:44:13: error: 'cout' was not declared in this scope
   44 |             cout << p << endl;
      |             ^~~~
a.cc:44:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:44:26: error: 'endl' was not declared in this scope
   44 |             cout << p << endl;
      |                          ^~~~
a.cc:44:26: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:58:33: error: 'b' was not declared in this scope; did you mean 'pb'?
   58 |         auto iter = lower_bound(b.begin(), b.begin() + bc, av0 + dt2 - L);
      |                                 ^
      |                                 pb
a.cc:58:21: error: 'lower_bound' was not declared in this scope
   58 |         auto iter = lower_bound(b.begin(), b.begin() + bc, av0 + dt2 - L);
      |                     ^~~~~~~~~~~
a.cc:59:14: error: 'distance' was not declared in this scope
   59 |         pb = distance(b.begin(), iter);
      |              ^~~~~~~~
a.cc:1:1: note: 'std::distance' is defined in header '<iterator>'; this is probably fixable by adding '#include <iterator>'
  +++ |+#include <iterator>
    1 | using namespace std;
a.cc:63:33: error: 'b' was not declared in this scope; did you mean 'pb'?
   63 |         auto iter = lower_bound(b.begin(), b.begin() + bc, av0 + dt2);
      |                                 ^
      |                                 pb
a.cc:63:21: error: 'lower_bound' was not declared in this scope
   63 |         auto iter = lower_bound(b.begin(), b.begin() + bc, av0 + dt2);
      |                     ^~~~~~~~~~~
a.cc:64:14: error: 'distance' was not declared in this scope
   64 |         pb = distance(b.begin(), iter);
      |              ^~~~~~~~
a.cc:64:14: note: 'std::distance' is defined in header '<iterator>'; this is probably fixable by adding '#include <iterator>'
a.cc:69:15: error: 'a' was not declared in this scope; did you mean 'av'?
   69 |     int av = (a.at(0) + dt) % L;
      |               ^
      |               av
a.cc:70:19: error: 'b' was not declared in this scope; did you mean 'bv'?
   70 |     int bv = (L + b.at(pb) - dt) % L;
      |                   ^
      |                   bv
a.cc:79:5: error: 'queue' was not declared in this scope
   79 |     queue<int> que;
      |     ^~~~~
a.cc:1:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
  +++ |+#include <queue>
    1 | using namespace std;
a.cc:79:11: error: expected primary-expression before 'int'
   79 |     queue<int> que;
      |           ^~~
a.cc:83:17: error: 'cout' was not declared in this scope
   83 |                 cout << av % L << endl;
      |                 ^~~~
a.cc:83:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:83:35: error: 'endl' was not declared in this scope
   83 |                 cout << av % L << endl;
      |                                   ^~~~
a.cc:83:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:85:17: error: 'que' was not declared in this scope
   85 |                 que.push(av % L);
      |                 ^~~
a.cc:97:17: error: 'cout' was not declared in this scope
   97 |                 cout << bv % L << endl;
      |                 ^~~~
a.cc:97:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:97:35: error: 'endl' was not declared in this scope
   97 |                 cout << bv % L << endl;
      |                                   ^~~~
a.cc:97:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:99:17: error: 'que' was not declared in this scope
   99 |                 que.push(bv % L);
      |                 ^~~
a.cc:116:13: error: 'cout' was not declared in this scope
  116 |             cout << av % L << endl;
      |             ^~~~
a.cc:116:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:116:31: error: 'endl' was not declared in this scope
  116 |             cout << av % L << endl;
      |                               ^~~~
a.cc:116:31: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:118:13: error: 'que' was not declared in this scope
  118 |             que.push(av);
      |             ^~~
a.cc:131:13: error: 'cout' was not declared in this scope
  131 |             cout << bv << endl;
      |             ^~~~
a.cc:131:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:131:27: error: 'endl' was not declared in this scope
  131 |             cout << bv << endl;
      |                           ^~~~
a.cc:131:27: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:133:13: error: 'que' was not declared in this scope
  133 |             que.push(bv);
      |             ^~~
a.cc:143:12: error: 'que' was not declared in this scope
  143 |     while(!que.empty()) {
      |            ^~~
a.cc:144:9: error: 'cout' was not declared in this scope
  144 |         cout << que.front() << endl;
      |         ^~~~
a.cc:144:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:144:32: error: 'endl' was not declared in this scope
  144 |         cout << que.front() << endl;
      |                                ^~~~
a.cc:144:32: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'