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



using namespace std;

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

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



ll fast(ll a, ll b){

	if(b == 0) return 1;

	ll tmp = fast(a,b/2);

	tmp = mulMod(tmp, tmp);

	if(b & 1) tmp = mulMod(tmp, a);

	return tmp;

}



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



const int N = 2e5;



int n;

int m;

int arr[N + 5];

vi lst[N + 5];

ll dp[N + 5];

int nxt[N + 5];



ll solve(int idx){

	if(idx == m+1){

		return 1;

	}

	ll& ret = dp[idx];

	if(ret != -1) return ret;

	ret = solve(idx+1);

	if(nxt[idx] != -1) ret = addMod(ret, solve(nxt[idx]));

	return ret;

}





int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(nxt,-1,sizeof nxt);

	m = 0;

	cin >> n;

	int bef = -1;

	int x;

	REP(i,1,n){

		cin >> x;

		if(x != bef){

			arr[++m] = x;

			bef = x;

			lst[x].PB(m);

		}

	}

	REP(i,1,N){

		if(lst[i].size() > 1){

			FOR(j,lst[i].size()-1){

				nxt[lst[i][j]] = lst[i][j+1];

			}

		}

	}

	memset(dp,-1,sizeof dp);

	cout << solve(1) << endl;

	return 0;

}

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

using namespace std;

int n,x,las,ans,c[200013];

int main(){

    scanf("%d",&n);

    ans=1;las=-1;

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

        scanf("%d",&x);

        if(x==las)continue;

        las=x;

        ans=(1LL*ans+c[x])%1000000007;

        c[x]=ans;

    }

    printf("%d",ans);

    return 0;

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



using namespace std;

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

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



ll fast(ll a, ll b){

	if(b == 0) return 1;

	ll tmp = fast(a,b/2);

	tmp = mulMod(tmp, tmp);

	if(b & 1) tmp = mulMod(tmp, a);

	return tmp;

}



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



const int N = 2e5;



int n;

int m;

int arr[N + 5];

vi lst[N + 5];

ll dp[N + 5];

int nxt[N + 5];



ll solve(int idx){

	if(idx == m+1){

		return 1;

	}

	ll& ret = dp[idx];

	if(ret != -1) return ret;

	ret = solve(idx+1);

	if(nxt[idx] != -1) ret = addMod(ret, solve(nxt[idx]));

	return ret;

}





int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(nxt,-1,sizeof nxt);

	m = 0;

	cin >> n;

	int bef = -1;

	int x;

	REP(i,1,n){

		cin >> x;

		if(x != bef){

			arr[++m] = x;

			bef = x;

			lst[x].PB(m);

		}

	}

	REP(i,1,N){

		if(lst[i].size() > 1){

			FOR(j,lst[i].size()-1){

				nxt[lst[i][j]] = lst[i][j+1];

			}

		}

	}

	memset(dp,-1,sizeof dp);

	cout << solve(1) << endl;

	return 0;

}

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

#include<cstdio>

#include<string>

using namespace std;

int pt[1000000], last[1000000];

int main(){

    int num;

    cin >> num;

    pt[0]=1;

    for(int i=1,x;i<=num;i++){

        cin>>x;

        pt[i]=pt[i-1];

        if(last[x]&&last[x]!=i-1)

            pt[i]+=pt[last[x]];

        last[x]=i;

        pt[i]%=1000000007;

    }

    cout<<pt[num];

    return 0;

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



using namespace std;

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

#define REP(i,a,b) REPP(i,a,b,1)

#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)

#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) REP(i,0,(int)a-1)

#define FORD(i,a) REV(i,(int)a-1,0)

#define PB push_back

#define POB pop_back

#define MP make_pair

#define FI first

#define SE second

typedef long long ll;

typedef unsigned long long ull;

typedef pair < int , int > pii;

typedef vector < int > vi;

typedef vector < pii > vii;

typedef vector < ll > vl;



const double EPS = 1e-9;

const double PI = acos(-1);

const int INF = 1e9;

const ll MOD = 1e9 + 7;



ll addMod(ll a, ll b){

	return (a+b) % MOD;

}



ll mulMod(ll a, ll b){

	return (a*b) % MOD;

}



ll fast(ll a, ll b){

	if(b == 0) return 1;

	ll tmp = fast(a,b/2);

	tmp = mulMod(tmp, tmp);

	if(b & 1) tmp = mulMod(tmp, a);

	return tmp;

}



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



const int N = 2e5;



int n;

int m;

int arr[N + 5];

vi lst[N + 5];

ll dp[N + 5];

int nxt[N + 5];



ll solve(int idx){

	if(idx == m+1){

		return 1;

	}

	ll& ret = dp[idx];

	if(ret != -1) return ret;

	ret = solve(idx+1);

	if(nxt[idx] != -1) ret = addMod(ret, solve(nxt[idx]));

	return ret;

}





int main(){

	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(nxt,-1,sizeof nxt);

	m = 0;

	cin >> n;

	int bef = -1;

	int x;

	REP(i,1,n){

		cin >> x;

		if(x != bef){

			arr[++m] = x;

			bef = x;

			lst[x].PB(m);

		}

	}

	REP(i,1,N){

		if(lst[i].size() > 1){

			FOR(j,lst[i].size()-1){

				nxt[lst[i][j]] = lst[i][j+1];

			}

		}

	}

	memset(dp,-1,sizeof dp);

	cout << solve(1) << endl;

	return 0;

}

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

using namespace std;

#define pb push_back

using ll = long long;

const ll N = 200500;

const ll m = (ll)1e9 + 7;

ll n,c[N],dp[N];

vector <ll> pos[N];



ll add(ll a , ll b) {

   return ((a % m) + (b % m)) % m;

}



ll f(ll curr) {

   if (curr > n) return 1;

   ll &sol = dp[curr];

   if (sol != -1) return sol;

   auto it = upper_bound(pos[c[curr]].begin() , pos[c[curr]].end() , curr);

   if (it == pos[c[curr]].end()) {

      sol = f(curr + 1);

   } else {

      if (abs((*it) - curr) == 1) {

         sol = f(curr + 1);

      } else {

         sol = add(f(curr + 1) , f(*it));

      }

   }

   return sol;

}



int main() {

   scanf("%lld" , &n);

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

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

      pos[c[i]].push_back(i);

   }

   memset (dp , -1 , sizeof dp);

   printf("%lld\n" , f(1));

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

using namespace std;

#define pb push_back

using ll = long long;

const ll N = 200500;

const ll m = (ll)1e9 + 7;

ll n,c[N],dp[N];

vector <ll> pos[N];



ll add(ll a , ll b) {

   return ((a % m) + (b % m)) % m;

}



ll f(ll curr) {

   if (curr > n) return 1;

   ll &sol = dp[curr];

   if (sol != -1) return sol;

   auto it = upper_bound(pos[c[curr]].begin() , pos[c[curr]].end() , curr);

   if (it == pos[c[curr]].end()) {

      sol = f(curr + 1);

   } else {

      if (abs((*it) - curr) == 1) {

         sol = f(curr + 1);

      } else {

         sol = add(f(curr + 1) , f(*it));

      }

   }

   return sol;

}



int main() {

   scanf("%lld" , &n);

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

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

      pos[c[i]].push_back(i);

   }

   memset (dp , -1 , sizeof dp);

   printf("%lld\n" , f(1));

}


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

#define rep(i, l, r) for (register int i = l; i <= r; i++)

#define per(i, r, l) for (register int i = r; i >= l; i--)

#define srep(i, l, r) for (register int i = l; i < r; i++)

#define sper(i, r, l) for (register int i = r; i > l; i--)

#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)

#define erep2(i, x) for (register int& i = cur[x]; i; i = e[i].next)

#define pii pair<int, int>

#define pll pair<ll, ll>

#define pdd pair<double, double>

#define fi first

#define se second

#define ui unsigned int

#define ld long double

#define ll long long int 

#define pb push_back

#define pc putchar

#define lowbit(x) (x & -x)

#define maxr 2000020

#define maxn 400020

#define maxm

#define maxs

#define maxb

#define M 1000000007

#define mo(x) (x = (x >= M) ? (x - M) : x)

#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)

using namespace std;



char buffer[maxr], *p1, *p2;

template <class T> void read(T& x){

	char ch = gc(); x = 0; bool f = 1;

	while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();

	if (ch == '-') f = 0, ch = gc();

	while ('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + ch - '0', ch = gc();

	x = (f) ? x : -x;

}

int _num[20];

template <class T> void write(T x){	

	if (!x) {putchar('0'), putchar('\n'); return;}

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

	int c = 0;

	while (x) _num[++c] = x % 10, x /= 10;

	while (c) putchar('0' + _num[c--]); 

	putchar('\n');

}



int n, a[maxn], _n, _a[maxn], dp[maxn], c[maxn], pre[maxn];



int main(){

	scanf("%d", &_n); rep(i, 1, _n) scanf("%d", _a + i); 

	rep(i, 1, _n) {

		int now = _a[i]; a[++n] = now;

		while (i <= _n && _a[i] == now) i++; i--;

	}

	

	rep(i, 1, n){

		dp[i] = c[a[i]], pre[i] = pre[i - 1] + dp[i], mo(pre[i]);

		//c[a[i + 1]] += pre[i] + 1, mo(c[a[i + 1]]);

		c[a[i]] += pre[i - 1] + 1, mo(c[a[i]]);

	} 

	printf("%d\n", pre[n] + 1);

	return 0;

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

//#include <iomanip>

//#include <string>

#include <vector>

#include <algorithm>

//#include <utility>

//#include <set>

//#include <map>

//#include <queue>

//#include <deque>

//#include <bitset>

//#include <math.h>

using namespace std ;

using ll = long long ;

//using ld = long double ;

using vll = vector<ll> ;

using vvll = vector<vll> ;

//using vc = vector<char> ;

//using vvc = vector<vc> ;

//using vb = vector<bool> ;

//using vvb = vector<vb> ;

//using pll = pair<ll,ll> ;

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

ll mod = 1e9+7 ;

//long double pie = acos(-1) ;

//ll INF = 1000000000000 ;



//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}

//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}

//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}

//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}

//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}

//void fix_cout(){cout << fixed << setprecision(20) ;}



int main(){

	ll n ; cin >> n ;

	vvll b(200000,vll(0)) ;

	vll dp(n+1,0) ;

	dp.at(0) = 1 ;

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

		ll c ; cin >> c ;

		c-- ;

		dp.at(i) += dp.at(i-1) ;

		b.at(c).push_back(i) ;

		if(b.at(c).size()>=2&&i-1>b.at(c).at(b.at(c).size()-2)){

			dp.at(i) += dp.at(b.at(c).at(b.at(c).size()-2)) ;

		}

		dp.at(i) %= mod ;

	}

//	for(auto i:dp) cout << i << " " ; cout << endl ;

	cout << dp.at(n) << endl ;

//	cout << mod << endl ;

}


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

//#include <iomanip>

#include <string>

#include <vector>

#include <algorithm>

//#include <utility>

#include <set>

//#include <map>

//#include <queue>

//#include <deque>

//#include <bitset>

//#include <math.h>

using namespace std ;

using ll = long long ;

//using ld = long double ;

using vll = vector<ll> ;

//using vvll = vector<vll> ;

//using vc = vector<char> ;

//using vvc = vector<vc> ;

//using vb = vector<bool> ;

//using vvb = vector<vb> ;

//using pll = pair<ll,ll> ;

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

ll mod = 1000000007 ;

//long double pie = acos(-1) ;

//ll INF = 1000000000000 ;



//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}

void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}

//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}

//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}

//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}

//void fix_cout(){cout << fixed << setprecision(20) ;}



int main(){

	ll n ; cin >> n ;

	vll last(200001,-1) ;

	vll dp(n+1,0) ;

	dp.at(0) = 1 ;

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

		ll a ; cin >> a ;

		dp.at(i+1) = dp.at(i) ;

		if(last.at(a)!=-1&&last.at(a)+1!=i) dp.at(i+1) += dp.at(last.at(a)+1) ;

		dp.at(i+1) %= mod ;

		last.at(a) = i ;

	}

	cout << dp.at(n) << endl ;

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

using namespace std;

typedef long long ll;

const int maxn = 2e5+5;

const ll mod=1e9+7;

ll qp(ll t1,ll t2) { ll s=1;for (;t2;t1=t1*t1%mod,t2>>=1) if (t2&1) s=s*t1%mod; return s;}

inline int read() {

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

    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}

    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();

    return x * f;

}

vector<int> p[maxn];

int a[maxn];

int b[maxn];

ll dp[maxn];

ll temp[maxn];

int main()

{

    int n;



    n=read();



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

    a[q]=read();



    int tot=1;

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

    {

        if( a[q]!=a[q-1])

        {

            b[tot++]=a[q];

        }

    }



    dp[0]=1;

    int z,x,sz;

    memset(temp,0,sizeof temp);

    for (int q=1;q<tot;q++)

    {



        dp[q]=dp[q-1];

        z=b[q],x;

        if (temp[z]==0)

        temp[z]=dp[q-1];

        else 

        {

            dp[q]+=temp[z];

            temp[z]+=dp[q-1];

            dp[q]%=mod;

            temp[z]%=mod;

        }

    }



    printf("%lld\n",dp[tot-1]);





    return 0;

}

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

using namespace std;

typedef long long ll;

const int maxn = 2e5+5;

const ll mod=1e9+7;

ll qp(ll t1,ll t2) { ll s=1;for (;t2;t1=t1*t1%mod,t2>>=1) if (t2&1) s=s*t1%mod; return s;}

inline int read() {

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

    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}

    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();

    return x * f;

}

ll p[maxn];

int a[maxn];

int b[maxn];

ll dp[maxn];

int main()

{

    int n;



    n=read();



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

    a[q]=read();



    int tot=1;

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

    {

        if( a[q]!=a[q-1])

        {

            b[tot++]=a[q];

        }

    }



    dp[0]=1;

    int x;

    memset(p,0,sizeof p);

    for (int q=1;q<tot;q++)

    {

        dp[q]=dp[q-1];

        x=b[q];

        if (p[x]==0)

        p[x]=dp[q-1];

        else 

        {

            dp[q]+=p[x];

            p[x]+=dp[q-1];

            dp[q]%=mod;

            p[x]%=mod;

        }

    }



    printf("%lld\n",dp[tot-1]);

  



    return 0;

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

#include<algorithm>

using namespace std;

#define MAX 1000000

int n;



pair<int, int> T[MAX];



main(){

    int id, m, s;

    while( cin >> n && n ){

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

	    cin >> id;

	    int sum = 0;

	    for ( int j = 0; j < 4; j++ ){

		cin >> m >> s;

		sum += m*60 + s;

	    }

	    T[i] = make_pair(sum, id);

	}

	sort( T, T + n );



	cout << T[0].second << endl;

	cout << T[1].second << endl;

	cout << T[n-2].second << endl;

    }

}

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

#define MAX 100000

#define INF (1<<21)



int id[MAX], total[MAX];

int n;



int searchMin(){

    int minv = INF;

    int target;

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

	if ( total[i] < 0 ) continue;

	if ( total[i] < minv ){

	    minv = total[i];

	    target = i;

	}

    }

    total[target] = -1;

    return id[target];

}



int searchMax(){

    int maxv = 0;

    int target;

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

	if ( total[i] < 0 ) continue;

	if ( total[i] > maxv ){

	    maxv = total[i];

	    target = i;

	}

    }

    total[target] = -1;

    return id[target];

}



main(){

    int m, s;

    while(1){

	scanf("%d", &n);

	if ( n == 0 ) break;

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

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

	    total[i] = 0;

	    for ( int j = 0; j < 4; j++ ){

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

		total[i] += m*60+s;

	    }

	}



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

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

	searchMax();

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

    }

}
// Slower C++ solution:
// 基本テンプレート



#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

using namespace std;



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

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define int long long int



template<typename T> void chmax(T &a, T b) {a = max(a, b);}

template<typename T> void chmin(T &a, T b) {a = min(a, b);}

template<typename T> void chadd(T &a, T b) {a = a + b;}



typedef pair<int, int> pii;

typedef long long ll;



int dx[] = {0, 0, 1, -1};

int dy[] = {1, -1, 0, 0};

constexpr ll INF = 1001001001001001LL;

constexpr ll MOD = 1000000007LL;



signed main() {

    int N, M; cin >> N >> M;

    cout << ((M*1900 + (N-M)*100) << M) << endl;

    return 0;

}

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

using namespace std;

int main() {

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

    int submit_time = 100*N + 1800*M;

    printf("%d\n", submit_time * (1 << M));

    return 0;

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



using namespace std;



typedef long long LL;



int N, M;

double t1 = 1900, t2 = 100;



void Solve()

{

  t1 *= M;

  double ans = 0;

  int a = (N - M) * t2;

  int p = 1 << M;

  double pp = 1;

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

    ans += (a + t1) * i / p * pp;

    pp = pp * (p - 1) / p;

  }

  int ians = ans + 0.5;

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

}



int main()

{

#ifdef linjian

freopen("in", "r", stdin);

#endif

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

  Solve();

  return 0;

}

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



using namespace std;



typedef long long LL;



int N, M;



void Solve()

{

  int tot = 1900 * M + 100 * (N - M);

  int p = 1 << M;

  int ans = tot * p;

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

}



int main()

{

#ifdef linjian

freopen("in", "r", stdin);

#endif

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

  Solve();

  return 0;

}
// Slower C++ solution:
#define _USE_MATH_DEFINES

#include <algorithm>

#include <cstdio>

#include <functional>

#include <iostream>

#include <cfloat>

#include <climits>

#include <cstring>

#include <cmath>

#include <map>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <time.h>

#include <vector>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> i_i;

typedef pair<ll, int> ll_i;

typedef pair<double, int> d_i;

typedef pair<ll, ll> ll_ll;

typedef pair<double, double> d_d;

struct edge { int u, v; ll w; };



ll MOD = 1000000007;

ll _MOD = 1000000009;

double EPS = 1e-10;



struct bit {

	vector<ll> v;

	bit(int n) : v(n + 1) {}

	ll sum(int i) {

		ll res = 0;

		for (; i > 0; i -= i & -i) res += v[i];

		return res;

	}

	void add(int i, ll x) {

		for (i++; i < v.size(); i += i & -i) v[i] += x;

	}

	int lower_bound(ll x) {

		if (x <= 0) return 0;

		int res = 0;

		for (int i = 1 << 24; i > 0; i >>= 1)

			if (res + i < v.size() && v[res + i] < x) {

				res += i; x -= v[res];

			}

		return res + 1;

	}

};



int main() {

	for (;;) {

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

		if (n == 0) break;

		bit b(n);

		for (int i = 0; i < n; i++) b.add(i, 1);

		for (n--; n > 0; n--) {

			b.add(m - 1, -1);

			int x = (b.sum(m) + k) % n;

			if (x == 0) x = n;

			m = b.lower_bound(x);

		}

		cout << m << endl;

	}

}

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

#include <algorithm>

#include <cstdio>

#include <functional>

#include <iostream>

#include <cfloat>

#include <climits>

#include <cstring>

#include <cmath>

#include <map>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <string>

#include <time.h>

#include <vector>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> i_i;

typedef pair<ll, int> ll_i;

typedef pair<double, int> d_i;

typedef pair<ll, ll> ll_ll;

typedef pair<double, double> d_d;

struct edge { int u, v; ll w; };



ll MOD = 1000000007;

ll _MOD = 1000000009;

double EPS = 1e-10;



int f(int n, int k) {

	return n == 1 ? 0 : 1 + (k - 1 + f(n - 1, k)) % (n - 1);

}



int main() {

	for (;;) {

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

		if (n == 0) break;

		cout << 1 + (m - 1 + f(n, k)) % n << endl;

	}

}