Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, L, T;
  cin >> N >> L >> T;
  vector<tuple<int, int, int>>an(N);
  for (int i = 0; i < N; i ++) {
    int x, w;
    cin >> x >> w;
    an[i] = make_tuple(x, w, i);
  }
  int num = 0;
  for (int i = 1; i < N; i ++) {
    if (get<1>an[i] == get<1>an[0]) continue;
    int t = get<0>an[i] - get<0>an[0];
    if (!(get<1>an[0] % 2)) {
      t = L - t;
    }
    int ti = T * 2 - t;
    if (ti < 0) continue;
    ti /= L;
    num += ti + 1;
    num %= N;
  }
  vector<int>ans(N);
  int kj = num;
  if (get<1>an[0] == 2) kj = (N - num) % 2;
  int tim = T % L;
  ans[num] = (get<0>an[0] + tim) % L;
  if (get<1>an[0] == 2) ans[num] = (L - tim + get<0>an[0]) % L;
  vector<int>as(N);
  for (int i = 0; i < N; i ++) {
    as[i] = (get<0>an[i] + tim) % L;
    if (get<1>an[i] == 2) as[i] = (L - tim + get<0>an[i]) % L;
  }
  sort(as.begin(), as.end());
  int al = 0;
  while (as[al] != ans[num]) al ++;
  for (int i = 1; i < N; i ++) {
    int j = i + al;
    j %= N;
    int k = i + num;
    k %= N;
    ans[k] = as[j];
  }
  for (int i = 0; i < N; i ++) {
    cout << ans[i] << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: expected ')' before 'an'
   14 |     if (get<1>an[i] == get<1>an[0]) continue;
      |        ~      ^~
      |               )
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant: In instantiation of 'struct std::variant_alternative<1, std::variant<> >':
/usr/include/c++/14/variant:106:11:   required by substitution of 'template<long unsigned int _Np, class _Variant> using std::variant_alternative_t = typename std::variant_alternative::type [with long unsigned int _Np = 1; _Variant = std::variant<>]'
  106 |     using variant_alternative_t =
      |           ^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/variant:1748:5:   required from here
 1748 |     get(const variant<_Types...>&& __v)
      |     ^~~
/usr/include/c++/14/variant:100:25: error: static assertion failed
  100 |       static_assert(_Np < sizeof...(_Types));
      |                     ~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/variant:100:25: note: the comparison reduces to '(1 < 0)'
In file included from /usr/include/c++/14/bits/stl_pair.h:62,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/utility.h: In instantiation of 'struct std::_Nth_type<1>':
/usr/include/c++/14/variant:102:13:   required from 'struct std::variant_alternative<1, std::variant<> >'
  102 |       using type = typename _Nth_type<_Np, _Types...>::type;
      |             ^~~~
/usr/include/c++/14/variant:106:11:   required by substitution of 'template<long unsigned int _Np, class _Variant> using std::variant_alternative_t = typename std::variant_alternative::type [with long unsigned int _Np = 1; _Variant = std::variant<>]'
  106 |     using variant_alternative_t =
      |           ^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/variant:1748:5:   required from here
 1748 |     get(const variant<_Types...>&& __v)
      |     ^~~
/usr/include/c++/14/bits/utility.h:237:13: error: '__type_pack_element' index is out of range
  237 |     { using type = __type_pack_element<_Np, _Types...>; };
      |             ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/tuple: In instantiation of 'struct std::tuple_element<1, std::tuple<> >':
/usr/include/c++/14/bits/utility.h:84:11:   required by substitution of 'template<long unsigned int __i, class _Tp> using std::__tuple_element_t = typename std::tuple_element::type [with long unsigned int __i = 1; _Tp = std::tuple<>]'
   84 |     using __tuple_element_t = typename tuple_element<__i, _Tp>::type;
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2466:5:   required from here
 2466 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/14/tuple:2422:25: error: static assertion failed: tuple index must be in range
 2422 |       static_assert(__i < sizeof...(_Types), "tuple index must be in range");
      |                     ~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/tuple:2422:25: note: the comparison reduces to '(1 < 0)'
a.cc:14:35: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   14 |     if (get<1>an[i] == get<1>an[0]) continue;
      |                                   ^
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:14:9: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   14 |     if (get<1>an[i] == get<1>an[0]) continue;
      |         ^~~~~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:14:9: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   14 |     if (get<1>an[i] == get<1>an[0]) continue;
      |         ^~~~~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:15:13: error: cannot resolve overloaded function 'get' based on conversion to type 'int'
   15 |     int t = get<0>an[i] - get<0>an[0];
      |             ^~~~~~
a.cc:16:17: error: expected ')' before 'an'
   16 |     if (!(get<1>an[0] % 2)) {
      |          ~      ^~
      |                 )
a.cc:18:5: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   18 |     }
      |     ^
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:18:5: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   18 |     }
      |     ^
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:18:6: error: expected ')' before 'int'
   18 |     }
      |      ^
      |      )
   19 |     int ti = T * 2 - t;
      |     ~~~
a.cc:16:8: note: to match this '('
   16 |     if (!(get<1>an[0] % 2)) {
      |        ^
a.cc:20:9: error: 'ti' was not declared in this scope; did you mean 't'?
   20 |     if (ti < 0) continue;
      |         ^~
      |         t
a.cc:21:5: error: 'ti' was not declared in this scope; did you mean 't'?
   21 |     ti /= L;
      |     ^~
      |     t
a.cc:27:13: error: expected ')' before 'an'
   27 |   if (get<1>an[0] == 2) kj = (N - num) % 2;
      |      ~      ^~
      |             )
a.cc:27:23: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   27 |   if (get<1>an[0] == 2) kj = (N - num) % 2;
      |                       ^
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:27:7: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   27 |   if (get<1>an[0] == 2) kj = (N - num) % 2;
      |       ^~~~~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:27:7: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   27 |   if (get<1>an[0] == 2) kj = (N - num) % 2;
      |       ^~~~~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:29:21: error: expected ')' before 'an'
   29 |   ans[num] = (get<0>an[0] + tim) % L;
      |              ~      ^~
      |                     )
a.cc:29:36: error: cannot resolve overloaded function 'get' based on conversion to type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   29 |   ans[num] = (get<0>an[0] + tim) % L;
      |                                    ^
a.cc:30:13: error: expected ')' before 'an'
   30 |   if (get<1>an[0] == 2) ans[num] = (L - tim + get<0>an[0]) % L;
      |      ~      ^~
      |             )
a.cc:30:23: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   30 |   if (get<1>an[0] == 2) ans[num] = (L - tim + get<0>an[0]) % L;
      |                       ^
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:30:7: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   30 |   if (get<1>an[0] == 2) ans[num] = (L - tim + get<0>an[0]) % L;
      |       ^~~~~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
a.cc:30:7: error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&) [with long unsigned int __i = 1; _Elements = {}; __enable_if_t<(__i >= sizeof... (_Types))> = void]'
   30 |   if (get<1>an[0] == 2) ans[num] = (L - tim + get<0>an[0]) % L;
      |       ^~~~~~
/usr/include/c++/14/tuple:2476:5: note: declared here
 2476 |     get(const tuple<_Elements...>&) = delete;
      |     ^~~
/usr/include/c++/14/variant: In instantiation of 'struct std::variant_alternative<0, std::variant<> >':
/usr/include/c++/14/variant:106:11:   required by substitution of 'template<long unsigned int _Np, class _Variant> using std::variant_alternative_t = typename std::variant_alternative::type [with long unsigned int _Np = 0; _Variant = std::variant<>]'
  106 |     using variant_alternative_t =
      |           ^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/variant:1748:5:   required f