Language: C++

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>

namespace lib 
{
	template<std::uint64_t Mod>struct modnum;
	template<class T>constexpr T pow(T base, std::size_t p)
	{
		if (p == 0)
		{
			return T(1);
		}
		else if (p == 1)
		{
			return base;
		}
		else if (p == 2)
		{
			return base*base;
		}
		else if (p % 2 == 0)
		{
			return pow(pow(base, p / 2), 2);
		}
		else
		{
			return pow(pow(base, p / 2), 2)*base;
		}
	}
	template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&);

	template<std::uint64_t Mod>struct modnum
	{
		static constexpr auto mod = Mod;
		std::uint64_t val;
		modnum() = default;
		constexpr modnum(std::uint64_t v) :val(v)
		{

		}

		constexpr modnum& operator+=(modnum const& v)
		{
			val += v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator-=(modnum const& v)
		{
			val += mod - v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator*=(modnum const& v)
		{
			val *= v.val;
			val %= mod;
			return *this;
		}
		constexpr modnum& operator/=(modnum const& v)
		{
			return operator*=(inverse(v));
		}
	};
	template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs += rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs -= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs *= rhs;
	}
	template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
	{
		return lhs /= rhs;
	}

	template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base)
	{
		return pow(base, Mod - 2);
	}

	template<class T>constexpr auto clamp(T v)
	{
		return std::max(v, T());
	}
	template<class T>void sort(std::vector<T>& vec)
	{
		std::sort(vec.begin(), vec.end());
	}
}

void Main();
int main()	
{
	std::cin.sync_with_stdio(false);
	Main();
}

typedef lib::modnum<1000000007> mod_t;


void Main()
{
	std::int64_t N, L, T, X, W;
	std::cin >> N >> L >> T >> X >> W;
	std::vector<std::int64_t> result;
	int h{};
	if (W == 1)
	{
		result.emplace_back((X + T) % L);
	}
	else
	{
		auto v = X - T;
		if (v < 0)
		{
			v %= L;
			v = L - v;
		}
		result.emplace_back(v);
	}
	for (int i = 1; i < N; ++i)
	{
		int x, w;
		std::cin >> x >> w;
		if (w == 1)
		{
			result.emplace_back((x + T) % L);
		}
		else
		{
			auto v = x - T;
			if (v < 0)
			{
				v %= L;
				v = L - v;
			}
			result.emplace_back(v);
		}
		if (w != W)
		{
			if (W == 1)
			{
				auto p = (x - X) / 2;
				h += lib::clamp((T - p) / L);
			}
			else
			{
				auto p = L / 2 - (x - X) / 2;
				h += lib::clamp((T - p) / L);
			}
			h %= N;
		}
	}
	lib::sort(result);
	if (W == 1)
	{
		X += T;
		X %= L;
	}
	else
	{
		X += L - T%L;
		X %= L;
	}
	auto ite = std::lower_bound(result.begin(), result.end(), X);
	auto s = std::distance(result.begin(), ite);
	for (int i{}; i < N; ++i)
	{
		std::cout << result[(s + N - h) % ].val << std::endl;
	}
}

Compiler output:
a.cc:12:18: error: 'std::uint64_t' has not been declared
   12 |         template<std::uint64_t Mod>struct modnum;
      |                  ^~~
a.cc:36:18: error: 'std::uint64_t' has not been declared
   36 |         template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&);
      |                  ^~~
a.cc:36:66: error: 'Mod' was not declared in this scope
   36 |         template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&);
      |                                                                  ^~~
a.cc:36:69: error: template argument 1 is invalid
   36 |         template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&);
      |                                                                     ^
a.cc:38:18: error: 'std::uint64_t' has not been declared
   38 |         template<std::uint64_t Mod>struct modnum
      |                  ^~~
a.cc:71:18: error: 'std::uint64_t' has not been declared
   71 |         template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                  ^~~
a.cc:71:68: error: 'Mod' was not declared in this scope
   71 |         template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                    ^~~
a.cc:71:71: error: template argument 1 is invalid
   71 |         template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                       ^
a.cc:71:85: error: 'Mod' was not declared in this scope
   71 |         template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                     ^~~
a.cc:71:88: error: template argument 1 is invalid
   71 |         template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                        ^
a.cc:71:51: error: 'constexpr auto lib::operator+(int, const int&)' must have an argument of class or enumerated type
   71 |         template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                   ^~~~~~~~
a.cc:75:18: error: 'std::uint64_t' has not been declared
   75 |         template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                  ^~~
a.cc:75:68: error: 'Mod' was not declared in this scope
   75 |         template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                    ^~~
a.cc:75:71: error: template argument 1 is invalid
   75 |         template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                       ^
a.cc:75:85: error: 'Mod' was not declared in this scope
   75 |         template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                     ^~~
a.cc:75:88: error: template argument 1 is invalid
   75 |         template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                        ^
a.cc:75:51: error: 'constexpr auto lib::operator-(int, const int&)' must have an argument of class or enumerated type
   75 |         template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                   ^~~~~~~~
a.cc:79:18: error: 'std::uint64_t' has not been declared
   79 |         template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                  ^~~
a.cc:79:68: error: 'Mod' was not declared in this scope
   79 |         template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                    ^~~
a.cc:79:71: error: template argument 1 is invalid
   79 |         template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                       ^
a.cc:79:85: error: 'Mod' was not declared in this scope
   79 |         template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                     ^~~
a.cc:79:88: error: template argument 1 is invalid
   79 |         template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                        ^
a.cc:79:51: error: 'constexpr auto lib::operator*(int, const int&)' must have an argument of class or enumerated type
   79 |         template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                   ^~~~~~~~
a.cc:83:18: error: 'std::uint64_t' has not been declared
   83 |         template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                  ^~~
a.cc:83:68: error: 'Mod' was not declared in this scope
   83 |         template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                    ^~~
a.cc:83:71: error: template argument 1 is invalid
   83 |         template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                       ^
a.cc:83:85: error: 'Mod' was not declared in this scope
   83 |         template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                     ^~~
a.cc:83:88: error: template argument 1 is invalid
   83 |         template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                                                        ^
a.cc:83:51: error: 'constexpr auto lib::operator/(int, const int&)' must have an argument of class or enumerated type
   83 |         template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs)
      |                                                   ^~~~~~~~
a.cc:88:18: error: 'std::uint64_t' has not been declared
   88 |         template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base)
      |                  ^~~
a.cc:88:66: error: 'Mod' was not declared in this scope
   88 |         template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base)
      |                                                                  ^~~
a.cc:88:69: error: template argument 1 is invalid
   88 |         template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base)
      |                                                                     ^
a.cc: In function 'constexpr auto lib::inverse(const int&)':
a.cc:90:34: error: 'Mod' was not declared in this scope
   90 |                 return pow(base, Mod - 2);
      |                                  ^~~
a.cc: In function 'void Main()':
a.cc:115:14: error: 'int64_t' is not a member of 'std'; did you mean 'int64_t'?
  115 |         std::int64_t N, L, T, X, W;
      |              ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155,
                 from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here
   27 | typedef __int64_t int64_t;
      |                   ^~~~~~~
a.cc:116:21: error: 'N' was not declared in this scope
  116 |         std::cin >> N >> L >> T >> X >> W;
      |                     ^
a.cc:116:26: error: 'L' was not declared in this scope
  116 |         std::cin >> N >> L >> T >> X >> W;
      |                          ^
a.cc:116:31: error: 'T' was not declared in this scope
  116 |         std::cin >> N >> L >> T >> X >> W;
      |                               ^
a.cc:116:36: error: 'X' was not declared in this scope
  116 |         std::cin >> N >> L >> T >> X >> W;
      |                                    ^
a.cc:116:41: error: 'W' was not declared in this scope
  116 |         std::cin >> N >> L >> T >> X >> W;
      |                                         ^
a.cc:117:26: error: 'int64_t' is not a member of 'std'; did you mean 'int64_t'?
  117 |         std::vector<std::int64_t> result;
      |                          ^~~~~~~
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here
   27 | typedef __int64_t int64_t;
      |                   ^~~~~~~
a.cc:117:33: error: template argument 1 is invalid
  117 |         std::vector<std::int64_t> result;
      |                                 ^
a.cc:117:33: error: template argument 2 is invalid
a.cc:121:24: error: request for member 'emplace_back' in 'result', which is of non-class type 'int'
  121 |                 result.emplace_back((X + T) % L);
      |                        ^~~~~~~~~~~~
a.cc:131:24: error: request for member 'emplace_back' in 'result', which is of non-class type 'int'
  131 |