Language: C++

#include <bits/stdc++.h>
#define f first
#define s second
#define int long long
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 1e5+5;

pair<ii, int> A[MN];
ii pos[MN];
int ans[MN];

main() {
	if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0);

	int N, L, T; cin >> N >> L >> T;
	for (int i = 0; i < N; ++i) {
		cin >> A[i].f.f >> A[i].f.s;
		if (A[i].f.s == 2) A[i].f.s = -1;
		A[i].s = i;
	}
	
	for (int i = 0; i < N; ++i) pos[i] = ii((A[i].f.f+((ll)L+A[i].f.s)*T)%L, A[i].s);
	sort(A, A+N), sort(pos, pos+N);

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (A[i].f.s != A[0].f.s) {
			int d = (A[i].f.f*A[i].f.s-A[0].f.f*A[0].f.s+2*L)%L;
			cnt += max((2*T-d)/L+1, 0);
		}
	}

	int c = ((ll)(N+A[0].f.s)*cnt%N);
	int idx = find(pos, pos+N, ii((A[0].f.f+((ll)L+A[0].f.s)*T)%L, A[0].s))-pos;
	for (int i = 0; i < N; ++i) ans[A[(i+c)%N].s] = pos[(i+idx)%N].f;

	for (int i = 0; i < N; ++i) cout << ans[i] << '\n';
}


Compiler output:
a.cc:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:32:35: error: no matching function for call to 'max(long long int, int)'
   32 |                         cnt += max((2*T-d)/L+1, 0);
      |                                ~~~^~~~~~~~~~~~~~~~
In file included 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/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:32:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |                         cnt += max((2*T-d)/L+1, 0);
      |                                ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:32:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                         cnt += max((2*T-d)/L+1, 0);
      |                                ~~~^~~~~~~~~~~~~~~~