stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#define _USE_MATH_DEFINES

#include <cassert>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <string>

#include <sstream>

#include <vector>

#include <queue>

#include <stack>

#include <list>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

#include <algorithm>

#include <complex>

#include <cmath>

#include <numeric>

#include <bitset>



using namespace std;



#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1){

  cerr << name << ": " << arg1 << endl;

}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){

  const char* comma = strchr(names + 1, ',');

  cerr.write(names, comma - names) << ": " << arg1 << " |";

  __f(comma + 1, args...);

}



typedef long long int64;

typedef pair<int, int> ii;

const int INF = 1 << 30;

const int MOD = 1e9 + 7;



struct Frac {

  int64 p, q;

};



Frac operator -(const Frac& a, const Frac& b) {

  int64 p = a.p * b.q - a.q * b.p;

  int64 q = a.q * b.q;

  int64 d = abs(__gcd(p, q));

  p /= d; q /= d;

  return Frac{p, q};

}



int main() {

  int n;

  cin >> n;

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

    for (int j = 1; j <= 3500; ++j) {

      auto cur = Frac{4, n} - Frac{1, i} - Frac{1, j};

      if (cur.p == 1) {

        cout << i << " " << j << " " << cur.q << endl;

        return 0;

      }

    }

  }

  return 0;

}


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

#include <cassert>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <string>

#include <sstream>

#include <vector>

#include <queue>

#include <stack>

#include <list>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

#include <algorithm>

#include <complex>

#include <cmath>

#include <numeric>

#include <bitset>



using namespace std;



#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1){

  cerr << name << ": " << arg1 << endl;

}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){

  const char* comma = strchr(names + 1, ',');

  cerr.write(names, comma - names) << ": " << arg1 << " |";

  __f(comma + 1, args...);

}



typedef long long int64;

typedef pair<int, int> ii;

const int INF = 1 << 30;

const int MOD = 1e9 + 7;



struct Frac {

  int64 p, q;

};



Frac operator -(const Frac& a, const Frac& b) {

  int64 p = a.p * b.q - a.q * b.p;

  int64 q = a.q * b.q;

  int64 d = abs(__gcd(p, q));

  p /= d; q /= d;

  return Frac{p, q};

}



int main() {

  int n;

  cin >> n;

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

    auto cur = Frac{4, n} - Frac{1, i};

    for (int j = cur.q / cur.p + 1; j <= 3500; ++j) {

      auto cur = Frac{4, n} - Frac{1, i} - Frac{1, j};

      if (cur.p == 1) {

        cout << i << " " << j << " " << cur.q << endl;

        return 0;

      }

    }

  }

  return 0;

}


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



using namespace std;

using ll = long long;



int main(int argc, const char *argv[]) {

  int n;

  cin >> n;



  ll h = 0, nn = 0, w = 0;

  for (ll i = 1; i <= 3500 && h == 0; ++i) {

    for (ll j = 1; j <= 3500 && h == 0; ++j) {

      ll l = lcm(n, lcm(i, j));

      ll m = 4ll * (l / n) - (l / i + l / j);

      if (m <= 0) {

        continue;

      }



      if (l % m != 0) {

        continue;

      }



      h = i;

      nn = j;

      w = l / m;

    }

  }



  cout << h << ' ' << nn << ' ' << w << '\n';

}

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

#include <numeric>



using namespace std;

using ll = long long;



int main(int argc, const char *argv[]) {

  int n;

  cin >> n;



  ll h = 0, nn = 0, w = 0;

  for (ll i = 1; i <= 3500 && h == 0; ++i) {

    for (ll j = 1; j <= 3500 && h == 0; ++j) {

      ll l = n * i * j;

      ll m = 4ll * (l / n) - (l / i + l / j);

      if (m <= 0) {

        continue;

      }



      if (l % m != 0) {

        continue;

      }



      h = i;

      nn = j;

      w = l / m;

    }

  }



  cout << h << ' ' << nn << ' ' << w << '\n';

}

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



#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



#define sf scanf

#define pf printf

#define pb push_back

#define mp make_pair

#define PI ( acos(-1.0) )

#define mod 998244353LL

#define IN freopen("C.in","r",stdin)

#define OUT freopen("output.txt","w",stdout)

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

#define DBG pf("Hi\n")

#define INF 1000000000

#define i64 long long int

#define eps (1e-8)

#define xx first

#define yy second

#define ln 17

#define off 2



using namespace __gnu_pbds;

using namespace std ;



typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

typedef pair<i64, i64> pii;



#define maxn 300005



map<int,int> Map ;



int a[maxn] ;



int main()

{

    int n , k ;



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



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



    Map[0] = 1 ;



    i64 ans = 0 ;



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

    {

        if( i-k >= 0 )

        {

            int val = ( (a[i-k] - (i-k) )%k + k )%k ;

            Map[ val ] = Map[val] - 1 ;

        }

        a[i] = ( a[i-1] + a[i] )%k ;

        int val = ( (a[i] - i)%k + k )%k ;



        if( Map.find( val ) == Map.end() ) Map[val] = 0 ;

        ans += Map[val] ;

        Map[val] = Map[val] +  1 ;

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

    }



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



    return 0 ;

}


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

#include<algorithm>

using namespace std;

struct node{

	int b,num;

}q[200010];

long long a[200010];

int cmp(const node&x,const node&y)

{

	if(x.b!=y.b)

	 return x.b<y.b;

	return x.num<y.num;

}

int main()

{

	int n,i,l;

	long long k,ans=0;

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

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

	 {

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

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

	 	q[i].b=(((a[i]-i)%k)+k)%k;

	 	q[i].num=i;

	 }

	sort(q+1,q+n+1,cmp);

	l=0;

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

	 if(q[i].b==q[i-1].b)

	  {

	  		while(q[i].num-q[l].num>=k)

	  		 l++;

	  		ans+=i-l;

	  }

	else

	 l=i;

	printf("%lld",ans);

	return 0;

}

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

#define ll long long

using namespace std;



int main() {

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

	int n, k;

	cin>>n>>k;

	vector<ll> a(n+1), pref(n+1);

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

		cin>>a[i];

		pref[i]=(pref[i-1]+a[i])%k;

	}

	map<ll, ll> cnt;

	ll ans=0;

	cnt[0]=1;

	if(k==1) {

		cout<<0;

		return 0;

	}

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

		if(i>=k) {

			cnt[(pref[i-k]-i%k+k)%k]--;

		}

		ans += cnt[(pref[i]-i%k+k)%k];

		cnt[(pref[i]-i%k+k)%k]++;

	}

	cout<<ans;

}


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

#include<algorithm>

using namespace std;

struct node{

	int b,num;

}q[200010];

long long a[200010];

int cmp(const node&x,const node&y)

{

	if(x.b!=y.b)

	 return x.b<y.b;

	return x.num<y.num;

}

int main()

{

	int n,i,l;

	long long k,ans=0;

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

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

	 {

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

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

	 	q[i].b=(((a[i]-i)%k)+k)%k;

	 	q[i].num=i;

	 }

	sort(q+1,q+n+1,cmp);

	l=0;

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

	 if(q[i].b==q[i-1].b)

	  {

	  		while(q[i].num-q[l].num>=k)

	  		 l++;

	  		ans+=i-l;

	  }

	else

	 l=i;

	printf("%lld",ans);

	return 0;

}

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

using namespace std;

typedef long long LL;

const int maxn = 200000+10;



int n,k;

int a[maxn],sum[maxn],b[maxn];

map<int,int> cnt;



int main()

{

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

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

    for (int i=1;i<=n;i++) sum[i]=(sum[i-1]+a[i])%k;

    for (int i=1;i<=n;i++) b[i]=((sum[i]-i)%k+k)%k;

    //for (int i=0;i<=n;i++) printf("%d ",b[i]); printf("\n");

    cnt[0]++;

    LL ans=0; int pre=0;

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

    {

        while (i-pre>=k)

        {

            cnt[b[pre]]--;

            pre++;

        }

        ans+=cnt[b[i]];

        cnt[b[i]]++;

    }

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

    return 0;

}


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

#include<algorithm>

using namespace std;

struct node{

	int b,num;

}q[200010];

long long a[200010];

int cmp(const node&x,const node&y)

{

	if(x.b!=y.b)

	 return x.b<y.b;

	return x.num<y.num;

}

int main()

{

	int n,i,l;

	long long k,ans=0;

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

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

	 {

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

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

	 	q[i].b=(((a[i]-i)%k)+k)%k;

	 	q[i].num=i;

	 }

	sort(q+1,q+n+1,cmp);

	l=0;

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

	 if(q[i].b==q[i-1].b)

	  {

	  		while(q[i].num-q[l].num>=k)

	  		 l++;

	  		ans+=i-l;

	  }

	else

	 l=i;

	printf("%lld",ans);

	return 0;

}

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

#include<cstdio>

#include<cstdlib>

#include<vector>

#include<cmath>

#include<algorithm>

#include<iomanip>

#include<cctype>

#include<queue>

#include<map>

#include<stack>

#include<string>

#include<cstring>

#include<set>

using namespace std;

typedef long long ll;

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef vector<pii> vpi;

#define mp make_pair

#define pb push_back



int a[200200],n,s[200200];

int k;

map<int,int> m;

vi b[200200];



int main(){

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

	s[0]=0;

	int cnt=1;

	m.clear();

	m[0]=1;

	b[1].pb(0);

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

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

		a[i]--;

		a[i]%=k;

		s[i]=(s[i-1]+a[i])%k;

		if (m.find(s[i])==m.end()) m[s[i]]=++cnt;

		b[m[s[i]]].pb(i);

	}

	ll ans=0;

	for (map<int,int>::iterator it=m.begin();it!=m.end();it++){

		int p=it->second;

		int sz=b[p].size();

		if (sz==1) continue;

		int i=0,j=1;

		while (j<sz){

			if (b[p][j]-b[p][i]>=k) i++;

			else{

				ans+=(ll)j-i;

				j++;

			}

		}

	}

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

	return 0;

}

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



using namespace std;

 

typedef long long ll;

#define For(i,x,y) for(int i=x; i<y; ++i)

#define mem(x,y) memset(x,y,sizeof(x))

#define ALL(a) a.begin(),a.end()

#define PII pair<int,int>

#define INF 0x3f3f3f3f

#define DOF 0x7f7f7f7f

#define se second

#define fi first

#define endl '\n'

 

template <typename T>

inline void read(T &r){

    static char c; r=0; int f=1;

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

    for(; c>='0'&&c<='9'; r=(r<<1)+(r<<3)+(c^48),c=getchar());

    r*=f;

} // -_-



const int N = 2e5 + 105;

ll a[N], pre[N], k;

int main(){

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

    scanf("%lld", &k);

    pre[0] = 0;

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

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

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

    }

    map<ll, int>ma;

    ll ans = 0;

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

        if(i >= k){

            ma[(pre[i - k] - (i - k))%k] --;

        }

        if(ma[(pre[i] - i)%k]){

            ans += ma[(pre[i] - i)%k];

        }

        ma[(pre[i] - i)%k] ++;

    }

    cout<<ans<<endl;

    // system("pause");

    return 0;

}

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

#include<vector>



using namespace std;



int main(void){

	while(1){

		vector<vector<int> > kek[31];

		

		int n;

		scanf("%d",&n);

		if(n==0){break;}

		

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

			vector<int> hn;

			hn.push_back(i);

			kek[i].push_back(hn);

			

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

				

				for(int k=0;k<kek[i-j].size();k++){

					int flg=0;

					

					for(int p=0;p<kek[i-j][k].size();p++){

						if(kek[i-j][k][p]>j){

							flg=1;

							break;

						}

					}

					

					if(flg==1){

						continue;

					}

					

					vector<int> u;

					u.push_back(j);

					

					for(int p=0;p<kek[i-j][k].size();p++){

						u.push_back(kek[i-j][k][p]);

					}

					kek[i].push_back(u);

				}

			}

		}

		

		for(int j=0;j<kek[n].size();j++){

			printf("%d",kek[n][j][0]);

			for(int k=1;k<kek[n][j].size();k++){

				printf(" %d",kek[n][j][k]);

			}

			puts("");

		}

	}

}

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



using namespace std;



int syutu[30];



void saiki(int m,int n,int atnum){

	

	int flg=0;

	//printf("%d %d %d\n",m,n,atnum);

	

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

		if(i>m){

			continue;

		}

		

		syutu[atnum]=i;

		saiki(i,n-i,atnum+1);

		syutu[atnum]=-1;

		flg=1;

	}

	

	if(flg==0){

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

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

			if(syutu[i]==-1){

				break;

			}

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

		}

		puts("");

	}

}



int main(){

	

	while(1){

		int n;

		scanf("%d",&n);

		

		if(n==0){

			return 0;

		}

		

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

			syutu[i]=-1;

		}

		saiki(n,n,0);

	}

}

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

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()

{

    int n,k;

    cin>>n>>k;

    int x=1;

    while(n--)

    {

        if(x<=k)

        {

            x*=2;

        }

        else

        {

            x+=k;

        }

    }

    cout<<x;

    return 0;

}

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



int main (){

	

	int n, k;

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

	int z = 1;

	

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

        if (2 * z <= z + k) {

            z *= 2;

        } else {

            z += k;

        }

    }

    printf("%d", z);

	

	

	return 0;

}

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

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;

int n,m;

long long sum,ans,a,k;

int main(){

	scanf("%lld%lld",&a,&k);

	ans=1;

	while(a--)

		ans=min(ans*2,ans+k);

	printf("%lld",ans);

	return 0;

}

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



int main (){

	

	int n, k;

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

	int z = 1;

	

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

        if (2 * z <= z + k) {

            z *= 2;

        } else {

            z += k;

        }

    }

    printf("%d", z);

	

	

	return 0;

}

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

using namespace std;

int main()

{

    int no=1,n,k;

    cin>>n>>k;

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

    {

        if(no*2<=no+k)no*= 2;

        else no+=k;

    }

    cout<<no<<endl;

    return 0;

}


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

int main (){

	int Na;

	int Ka;

	int hasil = 1;

	

	scanf("%d", &Na);

	scanf("%d", &Ka);

	

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

		if(hasil<Ka){

			hasil*=2;

		}else{

			hasil=hasil+Ka;

		}

	}

	printf("%d", hasil);

	return 0;

}

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

using namespace std;

int n, k, x=1;

int main (){

	cin >> n>> k;

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

		if(x+k<=2*x) x=x+k;

		else if(x+k>2*x) x=x*2;

	}

	cout << x;

}


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

int main (){

	int Na;

	int Ka;

	int hasil = 1;

	

	scanf("%d", &Na);

	scanf("%d", &Ka);

	

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

		if(hasil<Ka){

			hasil*=2;

		}else{

			hasil=hasil+Ka;

		}

	}

	printf("%d", hasil);

	return 0;

}

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

using namespace std;



int N,K,i,sum;



int main(){

	cin>>N>>K;

	sum = 1;

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

		if ((sum + K) > (sum * 2)){

			sum = sum * 2;

		}

		else {

			sum = sum + K;

		}

	}

	cout<<sum<<endl;

}


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

int main (){

	int Na;

	int Ka;

	int hasil = 1;

	

	scanf("%d", &Na);

	scanf("%d", &Ka);

	

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

		if(hasil<Ka){

			hasil*=2;

		}else{

			hasil=hasil+Ka;

		}

	}

	printf("%d", hasil);

	return 0;

}

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

using namespace std;

int main(){

    int ans=1,n,k;

    cin>>n>>k;

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

    	ans+=min(ans,k);

    cout<<ans<<endl;

    return 0;

}

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

#include <cstring>

#include <cmath>

#include <algorithm>

using namespace std;



int main(){

	int ans = 1,n,k;

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

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

		ans += min(ans,k);

	}

	printf("%d",ans);

	return 0;

}

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

using namespace std;



int main(){

	long long a,n,k; cin>>n>>k;

	a=1;

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

		if(a*2<a+k) a*=2;

		else a+=k;

	}

	cout<<a<<endl;

	return 0;

}

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

using namespace std;



int n, k, ans = 1;

int main() {

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

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

		ans += ans < k ? ans : k;

	}

	printf("%d", ans);

	return 0;

}

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

#include<iostream>

using namespace std;

long long ans=1,n,k;

int main()

{

	cin>>n>>k;

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

	{

		ans+=min(ans,k);

	}

	cout<<ans<<endl;;

}

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

using namespace std;



int n, k, ans = 1;

int main() {

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

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

		ans += ans < k ? ans : k;

	}

	printf("%d", ans);

	return 0;

}

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



using namespace std;

int n,ans=1,k;

int main()

{

	cin>>n>>k;

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

		ans+=min(k,ans);

	cout<<ans<<endl;

	

	

	return 0;

}

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

using namespace std;



int n, k, ans = 1;

int main() {

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

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

		ans += ans < k ? ans : k;

	}

	printf("%d", ans);

	return 0;

}

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

using namespace std;



int main(){

	int a, k, sum = 1;

	cin >> a >> k;

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

		sum = min(sum * 2,sum + k);

	}

	cout << sum;

}




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



int main(){

	

	

	int n, k;

	int ans = 1;

	

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

	

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

		if(ans <= k){

			ans *= 2;

		}else{

			ans += k;

		}

	}

	printf("%d", ans);

}

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

using namespace std;



int N, K;

int main(){

	cin>>N>>K;

	int num=1;

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

		if(K>num){

			num=num*2;

		}else{

			num=num+K;

		}

	}

	cout<<num;

}

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



int main(){

	

	

	int n, k;

	int ans = 1;

	

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

	

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

		if(ans <= k){

			ans *= 2;

		}else{

			ans += k;

		}

	}

	printf("%d", ans);

}

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

#include<iostream>

#include<bits/stdc++.h>

#include<vector>

#include<iterator>

#include<algorithm>

#include<iomanip>

#include <string.h>

#include<set>



#define ll long long int

using namespace std;







int main(){

        ll n,k;

        cin >> n;

        cin >> k;

        ll sum=1,s=0;

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

            if(sum <= k){

                sum = sum*2;

            }

            else{

                sum += k;

            }

          //  cout << sum << " "; //for tasting error

        }

        cout << sum  << endl;

}

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



int main() {

	int a, b;	

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

	

	int sum = 1;

	

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

			if(sum*2 < sum+b) {

				sum = sum*2;

			}

			else if (sum*2 > sum+b) {

				sum += b;

			}

			else {

				sum = sum * 2;

			}

		}

	printf("%d", sum);



	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*  ***  In The Name of God ... ***  */

#include <bits/stdc++.h>



using namespace std ;



typedef long long ll ;

typedef long double ld ;





#define int long long

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



template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}

template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}



const int N = 3000 + 10 ;



int n , ar [ N ] , dp [ N ] ; 

vector < int > adj [ N ] ; 

pair < int , int > pi [ N ] ; 



int32_t main()                     

{

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

	cin >> n ;

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

		cin >> ar [ i ] ;

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

		int u , v ;

		cin >> u >> v ;

		-- u , -- v ;

		adj [ u ] . push_back ( v ) ;

		adj [ v ] . push_back ( u ) ; 

	}

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

		pi [ i ] = make_pair ( ar [ i ] , i ) ;

	sort ( pi , pi + n ) ;

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

		int v = pi [ j ] . second ;

		for ( int u : adj [ v ] ) {

			if ( ar [ v ] > ar [ u ] && !dp [ u ] )

				dp [ v ] = 1 ; 

		}

	}

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

		if ( dp [ i ] )

			cout << i + 1 << ' ' ;

	cout << '\n' ; 

}


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

#include<algorithm>

using namespace std;

#define MAXN 3010

int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;

void AddEdge(int u,int v)

{

	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;

}

bool f[MAXN];

int a[MAXN],n;

void dfs(int u,int p)

{

	f[u]=0;

	for(int i=Adj[u];i;i=nxt[i])

		if(V[i]!=p)

		{

			dfs(V[i],u);

			if(f[V[i]]==0&&a[u]>a[V[i]])

				f[u]=1;

		}

}

int main()

{

	scanf("%d",&n);

	int u,v;

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

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

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

	{

		scanf("%d%d",&u,&v);

		AddEdge(u,v);

		AddEdge(v,u);

	}

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

	{

		dfs(i,0);

		if(f[i])

			printf("%d ",i);

	}

}


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

using namespace std;



const int N = 3e3 + 7;



vector <int> ad[N];

int a[N], n, ord[N];

bool win[N];



int main() {

	cin >> n;

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

		cin >> a[i], ord[i] = i;

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

		int x, y;

		cin >> x >> y;

		ad[x].push_back(y);

		ad[y].push_back(x);

	}

	sort (ord + 1, ord + n + 1, [](int x, int y) {

		return a[x] < a[y];

	});

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

		int v = ord[i];

		for (auto u: ad[v]) {

			if (a[u] < a[v] && !win[u])

				win[v] = 1;

		}

	}

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

		if (win[i])

			cout << i << " ";





	return 0;

}

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



const int N(3010);

struct edge { int next, to; } e[N << 1];

int n, A[N], head[N], e_num, ans[N];

inline void add_edge(int from, int to)

{

	e[++e_num] = (edge) {head[from], to};

	head[from] = e_num;

}



void dfs(int x, int f)

{

	ans[x] = 0;

	for (int i = head[x]; i; i = e[i].next) if (e[i].to != f && A[e[i].to] < A[x])

		{ dfs(e[i].to, x); if (!ans[e[i].to]) { ans[x] = 1; break; } }

}



int main()

{

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) scanf("%d", A + i);

	for (int i = 1, a, b; i <= n; i++)

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

	for (int i = 1; i <= n; i++) { dfs(i, 0); if (ans[i]) printf("%d ", i); }

	return 0;

}


// Fastest known solution for this problem: