Language: C++

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

i64 n,l,t;

i64 calc_count(i64 a,i64 b){
    i64 d;
    if(a<b) d=b-a;
    else d=l-a+b;
    if(2*t<d) return 0;
    return 1+(2*t-(d+d%2))/l;
}

void solve(){
    cin >> n >> l >> t;
    vector<i64> x(n),w(n);
    rep(i,0,n) cin >> x[i] >> w[i];
    i64 num=0;
    rep(i,1,n){
        if(w[i]==w[0]) continue;
        i64 a=x[0],b=x[i];
        if(w[i]==1) swap(a,b);
        num=((num+calc_count(a,b)*(w[0]==1?1:-1)%n)%n+n)%n;
    }
    vector<pair<i64,int>> y(n);
    rep(i,0,n) y[i]=make_pair(((x[i]+t*(w[i]==1?1:-1))%l+l)%l,w[i]);
    auto tmp=make_pair(y[0],w[0]);
    sort(y.begin(),y.end());
    int j=find(y.begin(),y.end(),tmp)-y.begin();
    vector<i64> ans(n);
    rep(i,0,n) ans[(num+i)%n]=y[(i+j)%n].first;
    rep(i,0,n) cout << ans[i] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equals_val<_Value>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long int, int>*, std::vector<std::pair<long int, int> > >; _Value = const std::pair<std::pair<long int, int>, long int>]':
/usr/include/c++/14/bits/stl_algobase.h:2107:14:   required from '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long int, int>*, vector<pair<long int, int> > >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const pair<pair<long int, int>, long int> >]'
 2107 |           if (__pred(__first))
      |               ~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:2152:23:   required from '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = __gnu_cxx::__normal_iterator<pair<long int, int>*, vector<pair<long int, int> > >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const pair<pair<long int, int>, long int> >]'
 2152 |       return __find_if(__first, __last, __pred,
      |              ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
 2153 |                        std::__iterator_category(__first));
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3850:28:   required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<pair<long int, int>*, vector<pair<long int, int> > >; _Tp = pair<pair<long int, int>, long int>]'
 3850 |       return std::__find_if(__first, __last,
      |              ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
 3851 |                             __gnu_cxx::__ops::__iter_equals_val(__val));
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:54:15:   required from here
   54 |     int j=find(y.begin(),y.end(),tmp)-y.begin();
      |           ~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:270:24: error: no match for 'operator==' (operand types are 'std::pair<long int, int>' and 'const std::pair<std::pair<long int, int>, long int>')
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:1208:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1208 |     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1208:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1216:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1216 |     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1216:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1103 |     operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1199 |     operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1274 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1366 |     operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'const std::pair<std::pair<long int, int>, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1441 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1534 |     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'const std::pair<std::pair<long int, int>, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1613 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
 2186 |     operator==(const match_results<_Bi_iter, _Alloc>& __m1,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   'std::pair<long int, int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:270:24: note:   deduced conflicting types for parameter '_T1' ('long int' and 'std::pair<long int, int>')
  270 |         { return *__it == _M_value; }
      |                  ~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl