Language: C++

#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define N 200005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, L, T, t, cnt, now;
int x[N], pos[N], d[N], ans[N];

int Next(int x) { return x == n ? 1 : x + 1; }
int Pre(int x) { return x > 1 ? x - 1 : n; }

signed main() {
	read(n, L, T);
	t = T / L, T %= L;
	for (int i = 1; i <= n; ++i) read(x[i], d[i]), d[i] = d[i] == 2 ? -1 : 1;
	for (int i = 1; i <= n; ++i) pos[i] = ((x[i] + T * d[i]) % L + L) % L;
	for (int i = 2; i <= n; ++i) cnt += d[i] == -d[1];

	now = 1ll * cnt * t % n + 1;
	for (int i = 2; i <= n; ++i)
		if (d[i] == -d[1]) {
			if (d[1] == 1) {
				if (x[i] - x[1] < T << 1) now = Next(now);
				if (x[i] - x[1] < T * 2 - L) now = Next(now);
			} else {
				if (L - x[i] + x[1] <= T << 1) now = Pre(now);
				if (L - x[i] + x[1] <= T * 2 - L) now = Pre(now);
			}
		}

	ans[now] = pos[1];
	sort(pos + 1, pos + n + 1);
	int i = now % n + 1, j = (lower_bound(pos + 1, pos + n + 1, ans[now]) - pos) % n + 1;
	for (; i ^ now; i = i % n + 1, j = j % n + 1) ans[i] = pos[j];
	for (i = 1; i <= n; ++i) printf("%d\n", ans[i]);
	return 0;
}


Compiler output:
a.cc:37:16: error: '<unnamed struct>::operator long long int()' cannot be overloaded with '<unnamed struct>::operator long long int()'
   37 |         inline operator long long () { return input<long long>(); }
      |                ^~~~~~~~
a.cc:36:16: note: previous declaration '<unnamed struct>::operator long long int()'
   36 |         inline operator int () { return input<int>(); }
      |                ^~~~~~~~
a.cc:41:3: error: '<unnamed struct> read' redeclared as different kind of entity
   41 | } read;
      |   ^~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:371:16: note: previous declaration 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
a.cc: In function 'int main()':
a.cc:50:17: error: invalid conversion from 'long long int' to 'void*' [-fpermissive]
   50 |         read(n, L, T);
      |                 ^
      |                 |
      |                 long long int
/usr/include/unistd.h:371:38: note:   initializing argument 2 of 'ssize_t read(int, void*, size_t)'
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                                ~~~~~~^~~~~
a.cc:52:52: error: invalid conversion from 'long long int' to 'void*' [-fpermissive]
   52 |         for (int i = 1; i <= n; ++i) read(x[i], d[i]), d[i] = d[i] == 2 ? -1 : 1;
      |                                                 ~~~^
      |                                                    |
      |                                                    long long int
a.cc:52:42: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
   52 |         for (int i = 1; i <= n; ++i) read(x[i], d[i]), d[i] = d[i] == 2 ? -1 : 1;
      |                                      ~~~~^~~~~~~~~~~~
/usr/include/unistd.h:371:16: note: declared here
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~