Language: C++

#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;

inline int read()
{
	int x=0; bool f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=0;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	if(f) return x;
	return -x;
}

const int N = 1e5;
struct Element
{
	int id,dir; llong x,endpos;
} a[N+3];
vector<llong> endpos;
int n; llong m,l;

llong divup(llong x,llong y) {return (x+y-1)/y;}

signed main()
{
	scanf("%d%lld%lld",&n,&l,&m);
	for(int i=0; i<n; i++)
	{
		scanf("%lld%d",&a[i].x,&a[i].dir); a[i].id = i;
		if(a[i].dir==1) {a[i].endpos = (a[i].x+m)%l; endpos.push_back(a[i].endpos);}
		else {a[i].endpos = ((a[i].x-m)%l+l)%l; endpos.push_back(a[i].endpos);}
	}
	sort(endpos.begin(),endpos.end());
	if(a[0].dir==1)
	{
		int k; for(k=endpos.size()-1; k>=0; k--) {if(endpos[k]==a[0].endpos) break;}
		llong tot = 0ll;
		for(int i=1; i<n; i++)
		{
			if(a[i].dir==2)
			{
				llong dist = a[i].x-a[0].x;
				llong cnt = (2ll*m-dist)/l+1;
				tot += cnt;
			}
		}
//		printf("tot=%lld k=%d\n",tot,k);
		int sid = ((k-tot)%n+n)%n;
		for(int j=sid; j<sid+n; j++)
		{
			printf("%lld\n",endpos[j%n]);
		}
	}
	else if(a[0].dir==2)
	{
		int k; for(k=0; k<endpos.size(); k++) {if(endpos[k]==a[0].endpos) break;}
		llong tot = 0ll;
		for(int i=1; i<n; i++)
		{
			if(a[i].dir==1)
			{
				llong dist = a[0].x-a[i].x+l;
				llong cnt = (2ll*m-dist)/l+1;
				tot += cnt;
			}
		}
//		printf("tot=%lld k=%d\n",tot,k);
		int sid = ((k+tot)%n+n)%n;
		for(int j=sid; j<sid+n; j++)
		{
			printf("%lld\n",endpos[j%n]);
		}
	}
	return 0;
}
/*
5 20 17
3 1
4 1
5 1
18 2
19 1
*/
/*
5 20 5
5 2
6 1
7 1
18 2
19 1
*/

Compiler output:
a.cc:22:21: error: 'llong' does not name a type; did you mean 'ulong'?
   22 |         int id,dir; llong x,endpos;
      |                     ^~~~~
      |                     ulong
a.cc:24:8: error: 'llong' was not declared in this scope; did you mean 'ulong'?
   24 | vector<llong> endpos;
      |        ^~~~~
      |        ulong
a.cc:24:13: error: template argument 1 is invalid
   24 | vector<llong> endpos;
      |             ^
a.cc:24:13: error: template argument 2 is invalid
a.cc:25:8: error: 'llong' does not name a type; did you mean 'ulong'?
   25 | int n; llong m,l;
      |        ^~~~~
      |        ulong
a.cc:27:1: error: 'llong' does not name a type; did you mean 'ulong'?
   27 | llong divup(llong x,llong y) {return (x+y-1)/y;}
      | ^~~~~
      | ulong
a.cc: In function 'int main()':
a.cc:31:32: error: 'l' was not declared in this scope
   31 |         scanf("%d%lld%lld",&n,&l,&m);
      |                                ^
a.cc:31:35: error: 'm' was not declared in this scope; did you mean 'tm'?
   31 |         scanf("%d%lld%lld",&n,&l,&m);
      |                                   ^
      |                                   tm
a.cc:34:38: error: 'struct Element' has no member named 'x'
   34 |                 scanf("%lld%d",&a[i].x,&a[i].dir); a[i].id = i;
      |                                      ^
a.cc:35:39: error: 'struct Element' has no member named 'endpos'
   35 |                 if(a[i].dir==1) {a[i].endpos = (a[i].x+m)%l; endpos.push_back(a[i].endpos);}
      |                                       ^~~~~~
a.cc:35:54: error: 'struct Element' has no member named 'x'
   35 |                 if(a[i].dir==1) {a[i].endpos = (a[i].x+m)%l; endpos.push_back(a[i].endpos);}
      |                                                      ^
a.cc:35:69: error: request for member 'push_back' in 'endpos', which is of non-class type 'int'
   35 |                 if(a[i].dir==1) {a[i].endpos = (a[i].x+m)%l; endpos.push_back(a[i].endpos);}
      |                                                                     ^~~~~~~~~
a.cc:35:84: error: 'struct Element' has no member named 'endpos'
   35 |                 if(a[i].dir==1) {a[i].endpos = (a[i].x+m)%l; endpos.push_back(a[i].endpos);}
      |                                                                                    ^~~~~~
a.cc:36:28: error: 'struct Element' has no member named 'endpos'
   36 |                 else {a[i].endpos = ((a[i].x-m)%l+l)%l; endpos.push_back(a[i].endpos);}
      |                            ^~~~~~
a.cc:36:44: error: 'struct Element' has no member named 'x'
   36 |                 else {a[i].endpos = ((a[i].x-m)%l+l)%l; endpos.push_back(a[i].endpos);}
      |                                            ^
a.cc:36:64: error: request for member 'push_back' in 'endpos', which is of non-class type 'int'
   36 |                 else {a[i].endpos = ((a[i].x-m)%l+l)%l; endpos.push_back(a[i].endpos);}
      |                                                                ^~~~~~~~~
a.cc:36:79: error: 'struct Element' has no member named 'endpos'
   36 |                 else {a[i].endpos = ((a[i].x-m)%l+l)%l; endpos.push_back(a[i].endpos);}
      |                                                                               ^~~~~~
a.cc:38:21: error: request for member 'begin' in 'endpos', which is of non-class type 'int'
   38 |         sort(endpos.begin(),endpos.end());
      |                     ^~~~~
a.cc:38:36: error: request for member 'end' in 'endpos', which is of non-class type 'int'
   38 |         sort(endpos.begin(),endpos.end());
      |                                    ^~~
a.cc:41:37: error: request for member 'size' in 'endpos', which is of non-class type 'int'
   41 |                 int k; for(k=endpos.size()-1; k>=0; k--) {if(endpos[k]==a[0].endpos) break;}
      |                                     ^~~~
a.cc:41:68: error: invalid types 'int[long long int]' for array subscript
   41 |                 int k; for(k=endpos.size()-1; k>=0; k--) {if(endpos[k]==a[0].endpos) break;}
      |                                                                    ^
a.cc:41:78: error: 'struct Element' has no member named 'endpos'
   41 |                 int k; for(k=endpos.size()-1; k>=0; k--) {if(endpos[k]==a[0].endpos) break;}
      |                                                                              ^~~~~~
a.cc:42:17: error: 'llong' was not declared in this scope; did you mean 'ulong'?
   42 |                 llong tot = 0ll;
      |                 ^~~~~
      |                 ulong
a.cc:47:38: error: expected ';' before 'dist'
   47 |                                 llong dist = a[i].x-a[0].x;
      |                                      ^~~~~
      |                                      ;
a.cc:48:38: error: expected ';' before 'cnt'
   48 |                                 llong cnt = (2ll*m-dist)/l+1;
      |                                      ^~~~
      |                                      ;
a.cc:49:33: error: 'tot' was not declared in this scope
   49 |                                 tot += cnt;
      |                                 ^~~
a.cc:49:40: error: 'cnt' was not declared in this scope; did you mean 'int'?
   49 |                                 tot += cnt;
      |                                        ^~~
      |                                        int
a.cc:53:31: error: 'tot' was not declared in this scope
   53 |                 int sid = ((k-tot)%n+n)%n;
      |                               ^~~
a.cc:56:47: error: invalid types 'int[long long int]' for array subscript
   56 |                         printf("%lld\n",endpos[j%n]);
      |                                               ^
a.cc:61:42: error: request for member 'size' in 'endpos', which is of non-class type 'int'
   61 |                 int k; for(k=0; k<endpos.size(); k++) {if(endpos[k]==a[0].endpos) break;}
      |                                          ^~~~
a.cc:61:65: error: invalid types 'int[long long int]' for array subscript
   61 |                 int k; for(k=0; k<endpos.size(); k++) {if(endpos[k]==a[0].endpos) break;}
      |                                                                 ^
a.cc:61:75: error: 'struct Element' has no member named 'endpos'
   61 |                 int k; for(k=0; k<endpos.size(); k++) {if(endpos[k]==a[0].endpos) break;}
      |                                                                           ^~~~~~
a.cc:62:17: error: 'llong' was not declared in this scope; did you mean 'ulong'?
   62 |                 llong tot = 0ll;
      |                 ^~~~~
      |                 ulong
a.cc:67:38: error: expected ';' before 'dist'
   67 |                                 llong dist = a[0].x-a[i].x+l;
      |                                      ^~~~~
      |                                      ;
a.cc:68:38: error: expected ';' before 'cnt'
   68 |                                 llong cnt = (2ll*m-dist)/l+1;
      |                                      ^~~~
      |                                      ;
a.cc:69:33: error: 'tot' was not declared in this scope
   69 |                                 tot += cnt;
      |                                 ^~~
a.cc:69:40: error: 'cnt' was not declared in this scope; did you mean 'int'?
   69 |                                 tot += cnt;
      |                                        ^~~
      |                                        int
a.cc:73:31: error: 'tot' was not declared in this scope
   73 |                 int sid = ((k+tot)%n+n)%n;
      |                               ^~~
a.cc:76:47: error: invalid types 'int[long long int]' for array subscript
   76 |                         printf("%lld\n",endpos[j%n]);
      |                                               ^