stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;



const int N = 100005;

ll n, C, x[N], v[N], pre[N], ans, p, q, ans1, ans2;

ll a[N], b[N], L[N], R[N];



int main() {

    scanf("%lld%lld", &n, &C);

    // 1

    for (int i = 1; i <= n; i++) {

        scanf("%lld%lld", &x[i], &v[i]);

        pre[i] = pre[i - 1] + v[i];

    }

    for (int i = 1; i <= n; i++) {

        ll tmp = pre[i] - x[i];

        a[i] = tmp;

        ans1 = max(ans1, tmp);

    }

    ans = max(ans, ans1);



    // 2

    for (int i = 1; i <= n; i++) pre[i] = v[i];

    for (int i = n; i >= 1; i--) pre[i] += pre[i + 1];

    for (int i = n; i >= 1; i--) {

        ll tmp = pre[i] - (C - x[i]);

        b[i] = tmp;

        ans2 = max(ans2, tmp);

    }

    ans = max(ans, ans2);



    // 3

    for (int i = 1; i <= n; i++) {

        L[i] = max(L[i - 1], a[i] - x[i]);

    }

    for (int i = n; i >= 1; i--) {

        R[i] = max(R[i + 1], b[i]);

    }

    for (int i = 1; i <= n; i++)

        ans = max(ans, L[i] + R[i + 1]);



    // 4

    memset(L, 0, sizeof(L));

    memset(R, 0, sizeof(R));

    for (int i = 1; i <= n; i++) {

        L[i] = max(L[i - 1], a[i]);

    }

    for (int i = n; i >= 1; i--) {

        R[i] = max(R[i + 1], b[i] - (C - x[i]));

    }

    for (int i = 1; i <= n; i++)

        ans = max(ans, L[i] + R[i + 1]);





    printf("%lld\n", ans);

    return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h> //Ithea Myse Valgulious

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return pc(48);

  if (x<0) x=-x,pc('-');

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

const int yuzu=1e5;

typedef ll fuko[yuzu|10];

int n=read();ll c;

fuko x,v,a,b,d,e;

int main(){

int i;

read(c);

for (i=1;i<=n;++i){

  read(x[i]),read(v[i]);

  } 

for (i=1;i<=n;++i){

  a[i]=a[i-1]+x[i-1]-x[i]+v[i];

  }

x[n+1]=c;

for (i=n;i;--i){

  b[i]=b[i+1]-x[i+1]+x[i]+v[i];

  }

for (i=2;i<=n;++i) a[i]=max(a[i],a[i-1]);

for (i=n-1;i;--i) b[i]=max(b[i],b[i+1]);

ll ans=0;

for (i=1;i<=n;++i){

  ans=max(ans,max(a[i],max(b[i],max(a[i]-x[i]+b[i+1],b[i]-c+x[i]+a[i-1]))));

  }

write(ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <set>

#include <map>

#include <vector>

#include <algorithm>

#include <iomanip>

#include <climits>

#include <numeric>

#include <cmath>

#include <queue>

#include <sstream>



using namespace std;

typedef long long ll;



int main() {

  ll N, C;

  cin >> N >> C;

  vector<ll> x(N + 2), v(N + 2);

  for (ll i = 1; i <= N; i++) {

    cin >> x[i] >> v[i];

  }

  x[0] = 0;

  x[N + 1] = C;

  

  vector<vector<ll>> dp(2, vector<ll>(100010, 0));

  ll cal = 0;

  for (ll i = 1; i <= N; i++) {

    cal -= x[i] - x[i - 1];

    cal += v[i];

    dp[0][i] = max(dp[0][i - 1], cal);

  }

  cal = 0;

  for (ll i = N; i >= 1; i--) {

    cal -= x[i + 1] - x[i];

    cal += v[i];

    dp[1][i] = max(dp[1][i + 1], cal);

  }

  

  ll maxcal = 0;

  for (int i = 0; i <= N; i++) {

    cal = dp[0][i] + dp[1][i + 1] - x[i];

    maxcal = max(maxcal, cal);

    

    cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];

    maxcal = max(maxcal, cal);

  }

  cout << maxcal << endl;

  return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>



using namespace std;

typedef long long ll;



const ll INF = 1e9;

const ll MOD = 1e9 + 7;



int main() {

  int N;

  ll C;

  cin >> N >> C;



  vector<ll> x(N + 1, 0), v(N + 1, 0), rwv(N + 1, 0);

  for (int i = 1; i <= N; i++) {

    cin >> x[i] >> v[i];

  }



  // 累積和

  for (int i = 0; i < N; i++) {

    rwv[i + 1] = rwv[i] + v[i + 1];

  }



  vector<ll> r(N + 1, 0);

  for (int i = 0; i < N; i++) {

    r[i + 1] = max(r[i], rwv[i + 1] - x[i + 1]);

  }



  vector<ll> l(N + 1, 0);

  l[1] = rwv[N] - rwv[N - 1] - (C - x[N]);

  for (int i = 1; i < N; i++) {

    l[i + 1] = max(l[i], rwv[N] - rwv[N - (i + 1)] - (C - x[N - i]));

  }



  // for (int i = 0; i <= N; i++) {

  //   cout << l[i] << " ";

  // }

  // cout << endl;

  // for (int i = 0; i <= N; i++) {

  //   cout << r[i] << " ";

  // }

  // cout << endl;





  ll ans = 0;

  for (int i = 1; i <= N; i++) {

    ans = max(ans, rwv[i] - x[i]);

    if (i < N) {

      ans = max(ans, rwv[i] - 2 * x[i] + l[N - i]);

    }

  }



  for (int i = N - 1; i >= 0; i--) {

    ans = max(ans, rwv[N] - rwv[i] - (C - x[i + 1]));

    if (i > 0) {

      ans = max(ans, rwv[N] - rwv[i] - 2 * (C - x[i + 1]) + r[i]);

    }

  }

  cout << ans << endl;



  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

#include <string>

#include <algorithm>

#include <set>

#include <vector>

#include <map>

#include <list>

#include <stack>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <queue>

#define mkp(a, b) make_pair(a, b)

#define pb(t) push_back(t)

#define ft first

#define sc second

#define pt(num) cout << num << "\n"

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

#define max(a, b) ((a)>(b) ? (a):(b))

#define min(a, b) ((a)<(b) ? (a):(b))

#define chmax(a, b) (a<b ? a=b : 0)

#define chmin(a, b) (a>b ? a=b : 0)

#define INF 1000000000000000000

#define MOD 1000000007LL

#define MAX 101010

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef map<ll, ll> Map;









int main(void) {

    ll N, C;

    cin >> N >> C;

    ll x[MAX], v[MAX];

    ll s[MAX]={};

    ll r[MAX]={};

    ll si[MAX]={};

    ll ssi[MAX]={};

    ll i;

    

    x[0]=0; v[0]=0;

    for(i=1; i<=N; i++) cin >> x[i] >> v[i];

    x[N+1]=C; v[N+1]=0;

    

    for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];

    for(i=N; i>=1; i--) r[i]=r[i+1]+v[i];

    

    ll mx=0, mi=0;

    for(i=1; i<=N; i++) {

        if(s[i]-x[i]>mx) {

            mx=s[i]-x[i];

            mi=i;

        }

        si[i]=mi;

    }

    

    mx=0; mi=0;

    for(i=1; i<=N; i++) {

        if(s[i]-x[i]*2>mx) {

            mx=s[i]-x[i]*2;

            mi=i;

        }

        ssi[i]=mi;

    }

    

    ll ans=0;

    for(ll b=1; b<=N+1; b++) {

        chmax(ans, s[ssi[b-1]]-x[ssi[b-1]]*2+r[b]-(C-x[b]));

        chmax(ans, s[si[b-1]]-x[si[b-1]]+r[b]-(C-x[b])*2);

    }

    pt(ans);

}








// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#include <string>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> PL;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

 for(i=0; i<N; i++)

   cin >> a[i];

*/







int main(void) {

  ll i, j, k;

  

  ll N, C;

  cin >> N >> C;

  ll x[MAX], v[MAX];

  ll s[MAX]={}, t[MAX]={};

  

  x[0]=0; v[0]=0;

  x[N+1]=C; v[N+1]=0;

  for(i=1; i<=N; i++) cin >> x[i] >> v[i];

  for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];

  for(i=N; i>=1; i--) t[i]=t[i+1]+v[i];

  

  ll ans=0;

  ll m=-INF, mm=-INF;

  for(i=0; i<=N; i++) {

    chmax(m, s[i]-x[i]);

    chmax(mm, s[i]-x[i]*2);

    

    chmax(ans, m+t[i+1]-(C-x[i+1])*2); //OA+OB*2

    chmax(ans, mm+t[i+1]-(C-x[i+1])); //OA*2+OB

  }

  

  pt(ans);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

#include <string>

#include <algorithm>

#include <set>

#include <vector>

#include <map>

#include <list>

#include <stack>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <queue>

#define mkp(a, b) make_pair(a, b)

#define pb(t) push_back(t)

#define ft first

#define sc second

#define pt(num) cout << num << "\n"

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

#define max(a, b) ((a)>(b) ? (a):(b))

#define min(a, b) ((a)<(b) ? (a):(b))

#define chmax(a, b) (a<b ? a=b : 0)

#define chmin(a, b) (a>b ? a=b : 0)

#define INF 1000000000000000000

#define MOD 1000000007LL

#define MAX 101010

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef map<ll, ll> Map;









int main(void) {

    ll N, C;

    cin >> N >> C;

    ll x[MAX], v[MAX];

    ll s[MAX]={};   //先頭からのカロリーの累積和

    ll r[MAX]={};   //後ろからのカロリーの累積和

    ll si[MAX]={};  //si[i]:i番目まででs[k]-x[k]が最大となるような位置k (k<=i)

    ll ssi[MAX]={}; //ssi[i]:i番目まででs[k]-x[k]*2が最大となるような位置k (k<=i)

    ll i;

    

    x[0]=0; v[0]=0;

    for(i=1; i<=N; i++) cin >> x[i] >> v[i];

    x[N+1]=C; v[N+1]=0;

    

    for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];

    for(i=N; i>=1; i--) r[i]=r[i+1]+v[i];

    

    ll mx=0, mi=0;

    for(i=1; i<=N; i++) {       //si[i]を求める

        if(s[i]-x[i]>mx) {

            mx=s[i]-x[i];

            mi=i;

        }

        si[i]=mi;

    }

    

    mx=0; mi=0;

    for(i=1; i<=N; i++) {       //ssi[i]を求める

        if(s[i]-x[i]*2>mx) {

            mx=s[i]-x[i]*2;

            mi=i;

        }

        ssi[i]=mi;

    }

    

    ll ans=0;

    for(ll b=1; b<=N+1; b++) {

        chmax(ans, s[si[b-1]]-x[si[b-1]]+r[b]-(C-x[b])*2);  //OA+2OBの場合

        chmax(ans, s[ssi[b-1]]-x[ssi[b-1]]*2+r[b]-(C-x[b]));//2OA+OBの場合

    }

    pt(ans);

}








// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#include <string>

#define pt(sth) cout << sth << "\n"

#define chmax(a, b) {if(a<b) a=b;}

#define chmin(a, b) {if(a>b) a=b;}

#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD

using namespace std;

typedef long long ll;

typedef pair<ll, ll> PL;

static const ll INF=1e18;

static const ll MAX=101010;

static const ll MOD=1e9+7;



/*

 for(i=0; i<N; i++)

   cin >> a[i];

*/







int main(void) {

  ll i, j, k;

  

  ll N, C;

  cin >> N >> C;

  ll x[MAX], v[MAX];

  ll s[MAX]={}, t[MAX]={};

  

  x[0]=0; v[0]=0;

  x[N+1]=C; v[N+1]=0;

  for(i=1; i<=N; i++) cin >> x[i] >> v[i];

  for(i=1; i<=N; i++) s[i]=s[i-1]+v[i];

  for(i=N; i>=1; i--) t[i]=t[i+1]+v[i];

  

  ll ans=0;

  ll m=-INF, mm=-INF;

  for(i=0; i<=N; i++) {

    chmax(m, s[i]-x[i]);

    chmax(mm, s[i]-x[i]*2);

    

    chmax(ans, m+t[i+1]-(C-x[i+1])*2); //OA+OB*2

    chmax(ans, mm+t[i+1]-(C-x[i+1])); //OA*2+OB

  }

  

  pt(ans);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#define MAXN (101010)

#define LL long long

using namespace std;

int n; 

struct Node{

	LL p,v;

	bool operator < (const Node &a)const{

		return p<a.p;

	}

	void Read(){

		scanf("%lld %lld",&p,&v);

	}

}T[MAXN];

LL C,A1[MAXN],A2[MAXN],B1[MAXN],B2[MAXN],p[MAXN],v[MAXN];

LL Max(LL a,LL b){

	if (a>b) return a;

	return b;

}

int main(){

	scanf("%d %lld",&n,&C);

	int i;

	LL ans=0;

	for (i=1;i<=n;i++) 

		T[i].Read();

	sort(T+1,T+n+1);

	for (i=1;i<=n;i++) p[i]=T[i].p,v[i]=T[i].v;

	p[n+1]=C;

	for (i=1;i<=n;i++){

		A1[i]=A1[i-1]+v[i]-(p[i]-p[i-1]);

		ans=Max(A1[i],ans);

		B1[i]=A1[i]-p[i];

		if (i>1) B1[i]=Max(B1[i],B1[i-1]);

	}

	for (i=n;i>=1;i--){

		A2[i]=A2[i+1]+v[i]-(p[i+1]-p[i]);

		ans=Max(ans,A2[i]);

		B2[i]=A2[i]-(C-p[i]);

		if (i<n) B2[i]=Max(B2[i],B2[i+1]);

	}

	for (i=1;i<n;i++) ans=Max(ans,A1[i]+B2[i+1]);

	for (i=2;i<=n;i++) ans=Max(ans,A2[i]+B1[i-1]);

	cout<<ans;

	

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define MAXN 100010

#define ll long long

#define max(a,b) (a>b?a:b)

#define INF 0x3f3f3f3f3f3f3f3f

using namespace std;



int n;

ll c,x[MAXN],v[MAXN];

ll k[5][MAXN],ma[5][MAXN];



int main()

{

	scanf("%d%lld",&n,&c);

	for(register int i=1;i<=n;i++)

		scanf("%lld%lld",&x[i],&v[i]);

	x[n+1]=c;  x[0]=0LL;

	long long sum=0LL,ans=-1e18;

	for(register int i=1;i<=n;i++)

	{

		sum=sum-(x[i]-x[i-1])+v[i];

		ans=max(ans,sum);

	}

	sum=0LL;

	for(register int i=n;i>=1;i--)

	{

		sum=sum-(x[i+1]-x[i])+v[i];

		ans=max(ans,sum);

	}

	for(register int i=1;i<=n;i++)

	{

		k[1][i]=k[1][i-1]+v[i]+2*x[i-1]-2*x[i];

		k[2][i]=k[2][i-1]+v[i]+x[i-1]-x[i];

	}

	for(register int i=n;i>=1;i--)

	{

		k[3][i]=k[3][i+1]+v[i]+2*(c-x[i+1])-2*(c-x[i]);

		k[4][i]=k[4][i+1]+v[i]+(c-x[i+1])-(c-x[i]);

	}

	//  1: 顺 - 先到i    v[1]+v[2]+...+v[i] - 2x[i] 

	//  2: 顺 - 后到i    v[1]+v[2]+...+v[i] - x[i]

	//  3: 逆 - 先到i    v[n]+v[n-1]+...+v[i] - 2(c-x[i])

	//  4: 逆 - 后到i    v[n]+v[n-1]+...+v[i] - (c-x[i])

	

	//  1: 逆 - 后到 i~n 的最大值

	//  2: 逆 - 先到 i~n 的最大值

	//  3: 顺 - 后到 1~i 的最大值

	//  4: 顺 - 先到 1~i 的最大值

	for(register int i=n;i>=1;i--)

	{

		ma[1][i]=max(ma[1][i+1],k[4][i]);

		ma[2][i]=max(ma[2][i+1],k[3][i]);

	}

	for(register int i=1;i<=n;i++)

	{

		ma[3][i]=max(ma[3][i-1],k[2][i]);

		ma[4][i]=max(ma[4][i-1],k[1][i]);

	}

	for(register int i=1;i<=n;i++)

	{

		sum=k[1][i]+ma[1][i+1];//先顺到 i 再逆到 j  (i<j)

		ans=max(sum,ans);

		sum=k[3][i]+ma[3][i-1];//先逆到 i 再顺到 j  (i>j)

		ans=max(sum,ans);

		sum=k[2][i]+ma[2][i+1];//后顺到 i 先逆到 j  (i<j)

		ans=max(sum,ans);

		sum=k[4][i]+ma[4][i-1];//后逆到 i 先顺到 j  (i>j)

		ans=max(sum,ans);

	}

	if(ans<0LL)  puts("0");

	else  printf("%lld",ans);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <iostream>

#include <cmath>

#include <cstring>

using namespace std;



int arr[2000100], c[100001], ans[2000100];



int main()

{

    int i, n;

    scanf("%d", &n);



        memset(c, 0, sizeof(c));



        for(i = 1; i <= n; ++i)

        {

            scanf("%d", &arr[i]);

            ++c[arr[i]];

        }



        for(i = 1; i < 100001; ++i)

            c[i] = c[i] + c[i - 1];



        for(i = n; i > 0; --i)

        {

            ans[c[arr[i]]] = arr[i];

            --c[arr[i]];

        }



        for(i = 1; i < n; ++i)

            printf("%d ", ans[i]);

            printf("%d\n", ans[n]);



    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



int a[2000007];



int main()

{

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

        cin>>a[i];



    sort(a,a+n);

    for(int i=0;i<n;i++)

        (i)?printf(" %d",a[i]):

            printf("%d",a[i]);

    printf("\n");





}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int arr[10001];

int main()

{

    int cs=0;



    {

        int n;

       scanf("%d",&n);





    memset(arr,0,sizeof(arr));



        for(int i=0;i<n;i++)

        {

            int a;

            scanf("%d",&a);

        arr[a]++;



        }

        }



    int i=0;

        for( i=0;i<10001;i++)

        {

            if(arr[i]>0){



           printf("%d",i);

           arr[i]--;



           break;

            }







        }

 for(int j=0;j<10001;j++)

        {

            if(arr[j]>0){

                    for(int k=1;k<=arr[j];k++)

           printf(" %d",j);

            }







        }





printf("\n");









    }

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



int ara[20000];

int main()

{

    int n ;

    cin >> n;

    for(int i = 0; i<n; i++)

    {

        int a;

        cin >> a;

        ara[a]++;

    }

    int f = 0;

    for(int i = 0; i<10007; i++)

        while(ara[i]--){

            if(f) printf(" ");

            cout << i ;

            f = 1;

        }

    cout << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



int main()

{



int ns[10001];



for(int i=0;i<10001;i++)

{

    ns[i]=0;

}



int n;

scanf("%d",&n);



int d;

for(int i=0;i<n;i++)

{

    scanf("%d",&d);

    ns[d]++;

}



int frst=1;



for(int i=0;i<10001;i++)

{

    if(ns[i]!=0)

    {

        for(int j=0;j<ns[i];j++)

        {

            if(!frst){printf(" ");}

            else{frst=0;}

            printf("%d",i);

        }

    }

}



printf("\n");



return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;

int arra[10001];

int main()



{

    int n,temp,j,mini;

    scanf("%d",&n);

    int ara[n];

    for(int i=0;i<n;i++)

    {

        scanf("%d",&ara[i]);

        arra[ara[i]]++;

    }

    int frst=1;

    for(int i=0;i<10001;i++)

    {

        if(arra[i]!=0)

        {

            for(j=0;j<arra[i];j++)

            {





            if(!frst)

            {

                printf(" ");

            }

            else

            {

                frst=0;

            }

             printf("%d",i);

        }

    }

    }

    cout<<endl;







}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<stdlib.h>

#include<string.h>

#include<stdio.h>

#define max 2000001

#define vmax 10000

using namespace std;



int main()

{

	unsigned short *a,*b;

	

	int c[vmax+1];

	int n,i,j;

	scanf("%d",&n);

	

	memset(c,0,sizeof(c));

	a=(unsigned short *)malloc(sizeof(short)*n+1);

	b=(unsigned short *)malloc(sizeof(short)*n+1);

	for(i=0;i<n;i++)

	{

		scanf("%hu",&a[i+1]);

		c[a[i+1]]++;

	}

	for(i=1;i<=vmax;i++)

	    c[i]=c[i]+c[i-1];

	for(j=1;j<=n;j++)

	{

		b[c[a[j]]]=a[j];

		c[a[j]]--;

	}

	for(i=1;i<=n;i++)

	{

		if(i>1) printf(" ");

		printf("%hu",b[i]);

	}

	printf("\n");

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<fstream>

#include<algorithm>

using namespace std;

int a[2000005];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    for(int i=0;i<n;i++)

    {

        if(i) printf(" ");

        printf("%d",a[i]);

    }

    printf("\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

   int n;

   cin>>n;

   int a[n];

   for(int i=0;i<n;i++)

   {

      cin>>a[i];

   }

   sort(a,a+n);

   for(int i=0;i<n;i++)

   {

      if(i>0)

         cout<<" ";

      cout<<a[i];

   }

   cout<<endl;

   return 0;

}

// Optimized solution to the same problem (faster):
#define MAX 2000001

#define VMAX 10001

#include <stdio.h>





int A[MAX], C[VMAX], B[MAX];



int main()//被排序的数至少有一个，所以B数组中的数统一向后移动一位 

{

	int n, i, j;

	scanf("%d", &n);

	for(i=0;i<n;i++)

	{

		scanf("%d", &A[i]);

	}

	for(i=0;i<n;i++)

	{

		C[A[i]]++;

	}

	for(i=1;i<=VMAX;i++)

	{

		C[i]=C[i]+C[i-1];

	}

	for(i=0;i<n;i++)

	{

		B[C[A[i]]]=A[i];

		C[A[i]]--;

	}

	for(i=1;i<=n;i++)

	{

		if(i>1)

		{

			printf(" ");

		}

		printf("%d", B[i]);

	}

	printf("\n");

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;

int c[20000+200];

int a[3000000+200];

int n;



void countSort(){

    memset(c,0,sizeof(c));

    for(int i=0;i<n;i++){

        c[a[i]]++;

    }

    int index=0;

    for(int i=0;i<10000+10;i++){

        while(c[i]){

            a[index++]=i;

            c[i]--;

        }

        if(index==n)

            break;

    }

    printf("%d",a[0]);

    for(int i=1;i<n;i++){

        printf(" %d",a[i]);

    }

    cout<<endl;

    return;

}



int main(){

    cin>>n;

    for(int i=0;i<n;i++){

        scanf("%d",&a[i]);

    }

    countSort();

    return 0;

}

// Optimized solution to the same problem (faster):
#define MAX 2000001

#define VMAX 10001

#include <stdio.h>





int A[MAX], C[VMAX], B[MAX];



int main()//被排序的数至少有一个，所以B数组中的数统一向后移动一位 

{

	int n, i, j;

	scanf("%d", &n);

	for(i=0;i<n;i++)

	{

		scanf("%d", &A[i]);

	}

	for(i=0;i<n;i++)

	{

		C[A[i]]++;

	}

	for(i=1;i<=VMAX;i++)

	{

		C[i]=C[i]+C[i-1];

	}

	for(i=0;i<n;i++)

	{

		B[C[A[i]]]=A[i];

		C[A[i]]--;

	}

	for(i=1;i<=n;i++)

	{

		if(i>1)

		{

			printf(" ");

		}

		printf("%d", B[i]);

	}

	printf("\n");

	return 0;

}


// Fastest known solution for this problem: