stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int main()

{

	int n,temp;

	list<int> l;

	while(~scanf("%d",&n)){

		l.clear();

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

			scanf("%d",&temp);

			if(i&1){

				l.push_front(temp);

			}else{

				l.push_back(temp);

			}

		}

		if(n&1){

			list<int>::reverse_iterator a,b;

			a=l.rbegin(),b=l.rend();

			printf("%d",*a);

			++a;

			for(;a!=b;++a){

				printf(" %d",*a);

			}

		}else{

			list<int>::iterator a,b;

			a=l.begin(),b=l.end();

			printf("%d",*a);

			++a;

			for(;a!=b;++a){

				printf(" %d",*a);

			}

		}

		putchar('\n');

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.646412496002038x):
#include <stdio.h>

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

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

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

            for(int i = 0; i < num_i - 1; i++)

            {

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

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;



const int M = 2e5;

int a[M];

int main()

{

	

	int n;

	while (cin >> n)

	{

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

			cin >> a[i];

		if (n % 2 == 1)

		{

			cout << a[n];

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

				cout << " " << a[i];

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

				cout << " " << a[i];

			cout << endl;

		}

		else

		{

			cout << a[n];

			for (int i = n - 2; i >= 2; i = i - 2)

				cout << " " << a[i];

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

				cout << " " << a[i];

			cout << endl;

		}

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.659291782271674x):
#include <stdio.h>

#include <string.h>

#define MAXN 100005



int main()

{

    int n;

    while(scanf("%d", &n) != EOF)

    {

        int a,num = n,flag = 1;

        int head[MAXN],tail[MAXN];

        int num_i = 0, num_j = 0;

        while(num--)

        {

            scanf("%d", &a);

            if(flag)

                tail[num_j++] = a;

            else

                head[num_i++] = a;

            flag = !flag;

        }

        if(n%2 == 0)

        {

            for(int i = num_i - 1; i >= 0; i--)

            {

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

            }

            for(int j = 0; j < num_j - 1; j++)

            {

                printf("%d ", tail[j]);

            }

            if(num_j)printf("%d\n", tail[num_j - 1]);

            else printf("\n");

        }

        else

        {

            for(int j = num_j - 1; j >= 0; j--)

            {

                printf("%d ", tail[j]);

            }

            for(int i = 0; i < num_i - 1; i++)

            {

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

            }

            if(num_i)printf("%d\n", head[num_i - 1]);

            else printf("\n");

        }

    }

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



deque<int> a(200000,0);

deque<int> b;



int main(void)

{

    int n;

    cin >> n;



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

        cin >> a[i];

    }



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

        if( (n-1) % 2 == i % 2 ){

            b.push_front(a[i]);

        }else{

            b.push_back(a[i]);

        }

    }

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

        cout << b[i] << " ";

    }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9211443835932065x):
#include <bits/stdc++.h>

using namespace std;



int main(void)

{

    int N;

    cin >> N;

    int a[N];

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

        cin >> a[i];

    }

    deque<int> A;

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

        if( (i+N-1) % 2 == 0){

            A.push_front(a[i]);

        }else {

            A.push_back(a[i]);

        }

    }

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

        cout << A[i] << " ";

    }

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



deque<int> a(200000,0);

deque<int> b;



int main(void)

{

    int n;

    cin >> n;



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

        cin >> a[i];

    }



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

        if( (n-1) % 2 == i % 2 ){

            b.push_front(a[i]);

        }else{

            b.push_back(a[i]);

        }

    }

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

        cout << b[i] << " ";

    }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8937698819252842x):
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

	int N; cin >> N;

	int a[N];

	rep(i, N) cin >> a[i];

	deque<int> dq;

	rep(i, N) {

		if (i % 2 != N % 2) dq.push_front(a[i]);

		else dq.push_back(a[i]);

	}

	rep(i, N) cout << dq[i] << " ";

	cout << endl;



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



struct Bit

{

    int data[100005];



    Bit ()

    {

        fill(begin(data), end(data), 0);

    }



    void add ( int k, int x )

    {

        for ( k++; k < 100005; k += (k & -k) ) {

            data[k] += x;

        }

    }



    int sum ( int k )

    {

        int sum = 0;

        for ( k++; k > 0; k -= (k & -k) ) {

            sum += data[k];

        }

        return ( sum );

    }

};



int main()

{

    int N, M;

    int cnt = 0;

    Bit tree;

    pair < int , int > data[100005];



    cin >> N >> M;

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

        cin >> data[i].second >> data[i].first;

    }

    sort(data, data + M);



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

        if ( tree.sum(data[i].first) - tree.sum(data[i].second - 1) == 0 ) {

            tree.add(data[i].first - 1, 1);

            cnt++;

        }

    }

    cout << cnt << endl;

    return ( 0 );

}


// Faster C++ solution for the same problem (measured speedup: 1.2242981182046833x):
#include <bits/stdc++.h>

using namespace std;



int main()

{

    int N, M;

    int cnt = 0;

    pair < int , int > data[100005];



    cin >> N >> M;

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

        cin >> data[i].second >> data[i].first;

    }

    sort(data, data + M);



    int ma = -1;

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

        if ( ma <= data[i].second ) {

            ma = data[i].first;

            cnt++;

        }

    }

    cout << cnt << endl;

    return ( 0 );

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define repd(i,a,b) for (int i=(a);i<(b);i++)

#define rep(i,n) repd(i,0,n)

typedef long long ll;

using namespace std;

const int MOD = 1000000007;

const int INF = 1010000000;

const double EPS = 1e-10;

const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



int main(){

  int n,m;cin>>n>>m;

  pair<int,int> d[100000];

  rep(i,m){

    int a,b;cin>>a>>b;

    d[i] = make_pair(a,b);

  }

  sort(d,d+m);

  int ans = 0;

  int pre_tail = 0;

  rep(i,m){

    if(d[i].first >= pre_tail){

      ans++;

      pre_tail = d[i].second;

    }else if(d[i].second < pre_tail)pre_tail = d[i].second;

  }

  cout << ans << endl;

}




// Faster C++ solution for the same problem (measured speedup: 1.8037009654035403x):
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);i++)

#define rep(i,n) repd(i,0,n)

typedef long long ll;

typedef long double lb;

#define int long long

#define double long double

#define endn "\n"

typedef pair<int,int> P;

template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}

template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}

const int MOD = 1000000007;

//const int MOD = 998244353;

template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};

template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};

const ll INF = 1e16;

const double EPS = 1e-10;

const double PI = 3.141592653589793;

const string abc="abcdefghijklmnopqrstuvwxyz";

const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



////////////////////////////////////////////////////////////////////

///////////////////////___modpow___////////////////////

ll modpow(ll a,  ll n, const ll &MOD = MOD){

  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);

  (ret *= ret) %= MOD;

  if(n%2)((ret *= a) %= MOD);

  return ret;

}

///////////////////////___modinv___////////////////////

ll modinv(ll d, const ll &MOD = MOD){

  return modpow(d, MOD-2, MOD);

}

////////////////////////////////////////////////////////////////////



int n,m,ans;P p[110000];

signed main(){

  cin>>n>>m;

  rep(i,m)cin>>p[i].second>>p[i].first;

  sort(p, p+m);

  int t = -1;

  rep(i,m){

    if(t < p[i].second){

      t = p[i].first-1;

      ans++;

    }

  }

  cout << ans << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int N, M;

vector<pair<int, int>> P(100010);

bool compare(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }



int main(void){

    

    cin >> N >> M;

    for(int i = 0; i < M; ++i) cin >> P[i].first >> P[i].second;

    sort(P.begin(), P.begin() + M, compare);

    

    int ans = 0, end = 0;

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

        if(P[i].first >= end){

            end = P[i].second;

            ++ans;

        }

    }

    cout << ans << endl;

    

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8166322966890835x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

typedef tuple<int, int, int> T;



int N, M;

vector<P> ab;



int main(void){

    

    scanf("%d %d", &N, &M);

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

        int a, b; scanf("%d %d", &a, &b);

        ab.push_back(make_pair(b, a));

    }

    sort(ab.begin(), ab.end());

    

    int ans = 0, t = 0;

    for(int i = 0; i < ab.size(); ++i){

        if(t <= ab[i].second){

            t = ab[i].first;

            ++ans;

        }

    }

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

    

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define mod 1000000007





int main(){

   int n,m;



   pair<int,int> data[100005];

   cin>>n>>m;

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

       int a,b;

       cin>>a>>b;

       data[i]=make_pair(b,a);

   }

   sort(data,data+m);

   int before=-1;

   int ans=0;

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

       if(before>=data[i].second) continue;

       ans++;

       before=data[i].first-1;

   }

   cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.8063449323293543x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MOD 1000000007

#define INF 1e9

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(void){

    int N,M;

    vector<pair<int,int>> A;

    cin>>N>>M;

    A.resize(M);

    for(int i=0;i<M;i++) cin>>A[i].second>>A[i].first;

    sort(A.begin(),A.end());

    int res=0;

    int endtime=0;

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

        if(A[i].second>=endtime){

            endtime=A[i].first;

            res++;

        }

    }

    cout<<res<<endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define mod 1000000007





int main(){

   int n,m;



   pair<int,int> data[100005];

   cin>>n>>m;

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

       int a,b;

       cin>>a>>b;

       data[i]=make_pair(b,a);

   }

   sort(data,data+m);

   int before=-1;

   int ans=0;

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

       if(before>=data[i].second) continue;

       ans++;

       before=data[i].first-1;

   }

   cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.805901073213034x):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)

#define all(v) v.begin(), v.end()

#define MOD 1000000009

const long long INF = 1LL<<60;



int main() {

    int n,m;

    cin>>n>>m;

    vector<pair<int,int>> v;

    rep(i,m){

        int a,b;

        cin>>a>>b;

        v.push_back({b,a});

    }

    sort(all(v));

    int ans=0;

    int prev=0;

    rep(i,m){

        if(v[i].second<prev) continue;

        ans++;

        prev=v[i].first;

    }



    cout<<ans<<endl;

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <string>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <stack>

#include <iostream>

#include <algorithm>

using namespace std;

typedef long long ll;

const int Inf = 1 << 30;

const int maxx = 1e5 + 7;

int n, m;

int ans;



struct PP {

	int a, b;

} p[maxx];



bool Cmp(PP x, PP y) { return x.b < y.b; }



int main() {

	scanf("%d %d", &n, &m);

	for(int i = 1; i <= m; i++) scanf("%d %d", &p[i].a, &p[i].b);

	sort(p + 1, p + m + 1, Cmp);

	int t = 0;

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

		if(p[i].a >= t){

			t = p[i].b; ans++;

		}

	}

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

}

// Faster C++ solution for the same problem (measured speedup: 5.148352128428058x):
#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

using namespace std;

const int maxx = 1e5 + 7;

int n, m, ans;



struct PP {

	int a, b;

} p[maxx];



bool Cmp(PP x, PP y) { return x.b < y.b; }



int main() {

	scanf("%d %d", &n, &m);

	for(int i = 1; i <= m; i++) scanf("%d %d", &p[i].a, &p[i].b);

	sort(p + 1, p + m + 1, Cmp);

	int t = 0;

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

		if(p[i].a >= t){

			t = p[i].b; ans++;

		}

	}

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

}
// Slower C++ solution:
#include <cstdio>

#include <algorithm>

#include <deque>



using namespace std;



struct war

{

    int a;

    int b;

};



bool cmp(const war& left, const war& right) {

    return left.b < right.b;

}



int main () {

    int N,M,a,b,sum=0;

    scanf("%d %d",&N,&M);

    war w;

    deque<war> wars;

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

        scanf("%d %d",&a,&b);

        wars.push_back(war{a,b});

    }

    sort(wars.begin(),wars.begin()+M,cmp);

    while (wars.size() != 0) {

        w = wars.front(); wars.pop_front();

        for (size_t i=0; i<wars.size(); i++) {

            if(wars[i].a <= w.b-1) {

                wars.erase(wars.begin()+(int)i);

                i--;

            }

        }

        sum++;

    }

    printf("%d\n",sum);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.846053841913594x):
#include <cstdio>

#include <algorithm>



using namespace std;



struct war

{

    int a;

    int b;

};



bool cmp(const war& left, const war& right) {

    return left.b < right.b;

}



int main () {

    int N,M,a,b,sum=0,bridge=-1,i;

    scanf("%d %d",&N,&M);

    war wars[M];

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

        scanf("%d %d",&a,&b);

        wars[i] = war{a,b};

    }

    sort(wars,wars+M,cmp);

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

        if (wars[i].a > bridge) {

            bridge = wars[i].b-1;

            sum++;

        }

    }

    printf("%d\n",sum);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int a[20];



bool check(int x)

{

	int pre = 0;

	for (int i = 0; i < 10; i++) if (x & (1 << i))

	{

		if (a[i] < pre) return false;

		pre = a[i];

	}

	return true;

}



bool dfs(int i, int x, int pre)

{

	if (i == 10)

	{

		return check(x);

	}

	bool temp = false;

	if (a[i] > pre) temp = dfs(i + 1, x, a[i]);

	return temp || dfs(i + 1, x | (1 << i), pre);

}



int main()

{

	int T;

	cin >> T;

	while (T--)

	{

		for (int i = 0; i < 10; i++) scanf("%d", &a[i]);

		printf("%s\n", dfs(1, 0, a[0]) ? "YES" : "NO");

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.220416115008701x):
#include<cstdio>  

int a,l1,l2,n;

bool f;

int main()

{

	scanf("%d",&n);

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

	{

	    f=0;l1=0;l2=-1;

		for(int j=1;j<=10;j++)

		{

			scanf("%d",&a);

			if(!f&&a<l2&&a<l1){printf("NO\n");f=1;continue;}

			if(!f&&l1>l2)

			{

				if(l1<a)l1=a;

				else l2=a;

			} 

			if(!f&&l2>l1)

			{

				if(l2<a)l2=a;

				else l1=a;

			}

		}

		if(!f)printf("YES\n");

	}

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

#define N 200010



int f[N];

int pos[N][26];

char s[N];



int main() {

	memset(f, 0x3f, sizeof(f));

	scanf("%s", s + 1);

	int n = strlen(s + 1);

	for(int i = 0; i < 26; ++i) pos[n + 1][i] = n + 1;

	f[n + 1] = 1, f[n + 2] = 0;

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

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

			pos[i][j] = pos[i + 1][j];

		pos[i][s[i] - 'a'] = i;

	}

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

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

			f[i] = min(f[i], f[pos[i][j] + 1] + 1);

	int now = 1;

	for(int j = f[1]; j; --j)

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

			if(f[now] == f[pos[now][i] + 1] + 1) {

				putchar(i + 'a');

				now = pos[now][i] + 1;

				break;

			}

}


// Faster C++ solution for the same problem (measured speedup: 1.7669004958085301x):
#include<iostream>

#include<cstdio>

#include<iomanip>

#include<algorithm>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cmath>

#include<vector>

#include<queue>

#include<map>

#include<set>



#define ll long long

#define db double

#define rg register int



using namespace std;



int n;

string s;

int a[500005];

int f[500005][26];

int t[500005];



inline int qr(){

	register char ch; register bool sign=0; rg res=0;

	while(!isdigit(ch=getchar()))if(ch=='-')sign=1;

	while(isdigit(ch))res=res*10+(ch^48),ch=getchar();

	if(sign)return -res; else return res;

}



inline int dfs(int i){

	if(i==0)return 0;

	if(t[i])return t[i];

	t[i]=1e9;

	for(rg j=0;j<26;++j){

		t[i]=min(t[i],dfs(f[i][j])+1);

	}return t[i];

}



int main(){

	cin>>s; n=s.size();

	for(rg i=1;i<=n;++i) a[i]=s[i-1]-'a';

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

		for(rg j=0;j<26;++j)

			f[i][j]=f[i+1][j];

		f[i][a[i+1]]=i+1;

	}

	for(rg j=0;j<26;++j)

		f[n+1][j]=f[1][j];

	f[n+1][a[1]]=1;

	dfs(n+1);

	rg i=n+1,v=t[n+1];

	while(i){

		for(rg j=0;j<26;++j){

			if(t[f[i][j]]==v-1){

				printf("%c",j+'a');

				i=f[i][j]; v=t[i];

				break;

			}

		}

	}puts("");

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

#define N 200010



int f[N];

int pos[N][26];

char s[N];



int main() {

	memset(f, 0x3f, sizeof(f));

	scanf("%s", s + 1);

	int n = strlen(s + 1);

	for(int i = 0; i < 26; ++i) pos[n + 1][i] = n + 1;

	f[n + 1] = 1, f[n + 2] = 0;

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

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

			pos[i][j] = pos[i + 1][j];

		pos[i][s[i] - 'a'] = i;

	}

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

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

			f[i] = min(f[i], f[pos[i][j] + 1] + 1);

	int now = 1;

	for(int j = f[1]; j; --j)

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

			if(f[now] == f[pos[now][i] + 1] + 1) {

				putchar(i + 'a');

				now = pos[now][i] + 1;

				break;

			}

}


// Faster C++ solution for the same problem (measured speedup: 9.150069960189095x):
#include <stdio.h>

#include <string.h>

#define N 200002

#define M 26



char s[N], a[N], f[N];

int head[M] = {0}, last[N][M], c[N], l;



int dfs(int p, int d)

{

	int i, td = d + 1, tp;

	

	a[d] = s[p], f[d] = 1;

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

		if(d + c[tp = last[p][i]] < l){

			if(tp){

				if(td < l && dfs(tp, td)) return 1;

			}

			else{

				a[td] = i + 97, f[td] = 1;

				return 1;

			} 

		}

	}

	f[d] = 0;

	return 0;

}



int main()

{		

	int i, j, m, t, mp, tp;

		

	scanf("%s", s + 1);

	l = strlen(s + 1);

	for(i = l, c[0] = 0; i; i--){

		for(j = 0, m = l; j < M; j++){

			t = c[last[i][j] = head[j]];

			if(t < m) m = t;

		}

		c[i] = m + 1;

		head[s[i] - 97] = i;

	}

	

	for(i = 1, m = c[head[mp = 0]]; i < M; i++){

		if(c[head[i]] < c[head[mp]]) mp = i;

	}

	tp = head[mp];



	if(!tp){

		putchar(mp + 97);

		putchar(10);

		return 0;

	}

	l = c[tp];

	for(i = 0; i <= l; i++) f[i] = 0;	

	dfs(tp, 0);

	a[l + 1] = 0;

	for(i = l; !f[i]; i--) a[i] = 97;

	puts(a);

						

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<iomanip>

#include<algorithm>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cmath>

#include<vector>

#include<queue>

#include<map>

#include<set>



#define ll long long

#define db double

#define rg register int



using namespace std;



int n;

string s;

int a[500005];

int f[500005][26];

int t[500005];



inline int qr(){

	register char ch; register bool sign=0; rg res=0;

	while(!isdigit(ch=getchar()))if(ch=='-')sign=1;

	while(isdigit(ch))res=res*10+(ch^48),ch=getchar();

	if(sign)return -res; else return res;

}



inline int dfs(int i){

	if(i==0)return 0;

	if(t[i])return t[i];

	t[i]=1e9;

	for(rg j=0;j<26;++j){

		t[i]=min(t[i],dfs(f[i][j])+1);

	}return t[i];

}



int main(){

	cin>>s; n=s.size();

	for(rg i=1;i<=n;++i) a[i]=s[i-1]-'a';

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

		for(rg j=0;j<26;++j)

			f[i][j]=f[i+1][j];

		f[i][a[i+1]]=i+1;

	}

	for(rg j=0;j<26;++j)

		f[n+1][j]=f[1][j];

	f[n+1][a[1]]=1;

	dfs(n+1);

	rg i=n+1,v=t[n+1];

	while(i){

		for(rg j=0;j<26;++j){

			if(t[f[i][j]]==v-1){

				printf("%c",j+'a');

				i=f[i][j]; v=t[i];

				break;

			}

		}

	}puts("");

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.1785994638040105x):
#include <stdio.h>

#include <string.h>

#define N 200002

#define M 26



char s[N], a[N], f[N];

int head[M] = {0}, last[N][M], c[N], l;



int dfs(int p, int d)

{

	int i, td = d + 1, tp;

	

	a[d] = s[p], f[d] = 1;

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

		if(d + c[tp = last[p][i]] < l){

			if(tp){

				if(td < l && dfs(tp, td)) return 1;

			}

			else{

				a[td] = i + 97, f[td] = 1;

				return 1;

			} 

		}

	}

	f[d] = 0;

	return 0;

}



int main()

{		

	int i, j, m, t, mp, tp;

		

	scanf("%s", s + 1);

	l = strlen(s + 1);

	for(i = l, c[0] = 0; i; i--){

		for(j = 0, m = l; j < M; j++){

			t = c[last[i][j] = head[j]];

			if(t < m) m = t;

		}

		c[i] = m + 1;

		head[s[i] - 97] = i;

	}

	

	for(i = 1, m = c[head[mp = 0]]; i < M; i++){

		if(c[head[i]] < c[head[mp]]) mp = i;

	}

	tp = head[mp];



	if(!tp){

		putchar(mp + 97);

		putchar(10);

		return 0;

	}

	l = c[tp];

	for(i = 0; i <= l; i++) f[i] = 0;	

	dfs(tp, 0);

	a[l + 1] = 0;

	for(i = l; !f[i]; i--) a[i] = 97;

	puts(a);

						

	return 0;

}