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

using namespace std;

const int N=1e5+10;

string s[N];

int p[5],ans[N];

int n;

void solve(int i,int x,int y) {

	int x0,y0;

	if (p[x]>p[y]) {

		ans[i]=y; p[x]--; p[y]++;

	}

	else if (p[x]<p[y]) {

		ans[i]=x; p[x]++; p[y]--;

	}

	else if (p[x]>1) {

		ans[i]=x; p[x]++; p[y]--;

	}

	else if (p[x]==0) {

		cout<<"No"<<endl;

		exit(0);

	}

	else {

		if (i==n) {

			ans[i]=x; p[x]++; p[y]--; return;

		}

		x0=s[i+1][0]-'A'; y0=s[i+1][1]-'A';

		if (x0==x&&y0==y) {

			ans[i]=x; p[x]++; p[y]--; return;

		} 

		if (x==x0||x==y0) {

			ans[i]=x; p[x]++; p[y]--; return;

		}

		else {

			ans[i]=y; p[x]--; p[y]++; return;

		}

	}

}

int main() {

	int i;

	ios::sync_with_stdio(false);

	cin>>n>>p[0]>>p[1]>>p[2];

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

		cin>>s[i];

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

		if (s[i]=="AB") solve(i,0,1);

		else if (s[i]=="BC") solve(i,1,2);

		else solve(i,0,2); 

	}

	cout<<"Yes"<<endl;

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

		cout<<char(ans[i]+'A')<<endl;

	return 0;

}

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

#include <cstdio>

#include <iomanip>

#include <string>

#include <cmath>

#include <algorithm>

#include <iomanip>

#include <cstring>

#include <queue>

#include <stack>

#include <vector>

#include <map>

#include <set>

using namespace std;

typedef long long ll;

inline ll read() {

	ll kk=0,f=1;

	char cc=getchar();

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

	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}

	return kk*f;

}

inline void write(ll xx){

	if(xx < 0){putchar('-');xx=-xx;}

	if(xx > 9)write(xx/10);

	putchar(xx%10+'0');

	return;

}

ll n,a[3];

char s[100005][5];

vector<char> res;

int flag;

int cnt;

int main(){

	n = read();

	a[0] = read();

	a[1] = read();

	a[2] = read();

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

		scanf("%s",s[i]);

	}

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

		if(a[s[i][0] - 'A'] < a[s[i][1] - 'A']){

			a[s[i][0] - 'A']++;

			a[s[i][1] - 'A']--;

			res.push_back(s[i][0]);

		}else if(a[s[i][0] - 'A'] > a[s[i][1] - 'A']){

			a[s[i][0] - 'A']--;

			a[s[i][1] - 'A']++;

			res.push_back(s[i][1]);

		}else{

			if(s[i + 1][0] == s[i][0] || s[i + 1][1] == s[i][0]){

				a[s[i][0] - 'A']++;

				a[s[i][1] - 'A']--;

				res.push_back(s[i][0]);

			}else{

				a[s[i][0] - 'A']--;

				a[s[i][1] - 'A']++;

				res.push_back(s[i][1]);

			}

		}

		if(a[0] < 0 || a[1] < 0 || a[2] < 0){

			flag = 1;

			break;

		}

	}

	if(!flag){

		printf("Yes\n");

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

			printf("%c\n",res[i]);

		}

	}else{

		printf("No\n");

	}

	return 0;

}

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

#include<iostream>





using namespace std;





int main(){

    float n,m;



    cin>>n>>m;



    float ans=(m-n);

    ans=ans+m;

    cout<<ans;



    return 0;



}


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

int main()

{

	int a, b;

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

	printf("%d", 2*b-a);

}

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

using namespace std;

int main(){

    int a,b;

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

    printf("%d\n",b*2-a);

}


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

int main()

{

	int a, b;

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

	printf("%d", 2*b-a);

}

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



using namespace std;



int main()

{

float a,b,c;

cin>>a;

cin>>b;

if ((0<=a<=4500) && (0<=b<=4500)){

    c = (2*b)-a;

}

cout<<c<<endl;









return 0;

}


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

int main()

{

	int a, b;

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

	printf("%d", 2*b-a);

}

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

#include <vector>

#include <deque>

#include <math.h>

#include <set>

#include <iomanip>

#include <time.h>

#include <list>

#include <stdio.h>

#include <queue>

#include <map>

#include <algorithm>

#include <assert.h>

#include <memory.h>



#define mk make_pair

#define sc second

#define fr first

#define pb emplace_back

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

#define sz(s) ( (int)s.size() )

#define int unsigned long long



using namespace std;



const int N = 1005;



int n;



pair <int, int> ar[N];



main ()

{

    cin >> n;

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

        scanf("%d%d", &ar[i].fr, &ar[i].sc);



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

    {

        int l = 0, r = 2e18 / max( ar[i].fr, ar[i].sc );



        while (r - l > 1)

        {

            int md = (l + r) >> 1;

            if ( ar[i].fr * md >= ar[i - 1].fr && ar[i].sc * md >= ar[i - 1].sc )

                r = md;

            else

                l = md;

        }

        ar[i].fr *= r;

        ar[i].sc *= r;

    }

    cout << ar[n].fr + ar[n].sc << endl;

}


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



constexpr int kN = int(1E3 + 10);



long long int gcd(long long int a, long long int b) {return b == 0 ? a : gcd(b, a % b);}



long long int a[kN], b[kN];



int main() {

	int n;

	long long int l = 1, r = 1, tmp, nl, nr, nnl, nnr;

	scanf("%d", &n);

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

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

		tmp = gcd(l, r);

		if (l / tmp == a[i] && r / tmp == b[i]) continue;

			nl = ((l - 1) / a[i] + 1) * a[i];

			nr = nl / a[i] * b[i];

			nnr = ((r - 1) / b[i] + 1) * b[i];

			nnl = nnr / b[i] * a[i];

			if (nl >= l && nr >= r) {

				if (nnl >= l && nnr >= r) {

					if (nl < nnl) {

						l = nl;

						r = nr;

					}

					else {

						l = nnl;

						r = nnr;

					}

				}

				else {

					l = nl;

					r = nr;

				}

			}

			else {

				l = nnl;

				r = nnr;

			}

	}

	printf("%lld\n", l + r);

}


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

using namespace std;

 

#define pb push_back

#define ll long long

#define maxn 500005

#define fr(i,j,k) for(int i=j;i<k;i++)

#define f(n) fr(i,0,n)

#define f1(n) fr(i,1,n+1)

#define ms(i) memset(i,0,sizeof(i));

#define ms1(i) memset(i,-1,sizeof(i));

#define F first

#define S second



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int n;

    cin >> n;

    ll num1 = 0, num2 = 0;

    f(n){

        ll a, b;

        cin >> a >> b;

        ll l = 0, r = 1e18/max(a,b) + 5;

        while(l < r - 1){

            ll m = (l + r) >> 1;

            ll aa = a * m, bb = b * m;

            if(aa >= num1 && bb >= num2){

                r = m;

            }

            else{

                l = m;

            }

        }

        num1 = r * a;

        num2 = r * b;

    }

    cout << num1 + num2 << '\n';

}

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



constexpr int kN = int(1E3 + 10);



long long int gcd(long long int a, long long int b) {return b == 0 ? a : gcd(b, a % b);}



long long int a[kN], b[kN];



int main() {

	int n;

	long long int l = 1, r = 1, tmp, nl, nr, nnl, nnr;

	scanf("%d", &n);

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

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

		tmp = gcd(l, r);

		if (l / tmp == a[i] && r / tmp == b[i]) continue;

			nl = ((l - 1) / a[i] + 1) * a[i];

			nr = nl / a[i] * b[i];

			nnr = ((r - 1) / b[i] + 1) * b[i];

			nnl = nnr / b[i] * a[i];

			if (nl >= l && nr >= r) {

				if (nnl >= l && nnr >= r) {

					if (nl < nnl) {

						l = nl;

						r = nr;

					}

					else {

						l = nnl;

						r = nnr;

					}

				}

				else {

					l = nl;

					r = nr;

				}

			}

			else {

				l = nnl;

				r = nnr;

			}

	}

	printf("%lld\n", l + r);

}


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

using namespace std;

int main(){

	int n;

	long long px=1,py=1;

	scanf("%d",&n);

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

		int t,a;

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

		long long now=max((px+t-1)/t,(py+a-1)/a);

		px=now*t;

		py=now*a;

	}

	printf("%lld\n",px+py);

	return 0;

}


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



constexpr int kN = int(1E3 + 10);



long long int gcd(long long int a, long long int b) {return b == 0 ? a : gcd(b, a % b);}



long long int a[kN], b[kN];



int main() {

	int n;

	long long int l = 1, r = 1, tmp, nl, nr, nnl, nnr;

	scanf("%d", &n);

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

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

		tmp = gcd(l, r);

		if (l / tmp == a[i] && r / tmp == b[i]) continue;

			nl = ((l - 1) / a[i] + 1) * a[i];

			nr = nl / a[i] * b[i];

			nnr = ((r - 1) / b[i] + 1) * b[i];

			nnl = nnr / b[i] * a[i];

			if (nl >= l && nr >= r) {

				if (nnl >= l && nnr >= r) {

					if (nl < nnl) {

						l = nl;

						r = nr;

					}

					else {

						l = nnl;

						r = nnr;

					}

				}

				else {

					l = nl;

					r = nr;

				}

			}

			else {

				l = nnl;

				r = nnr;

			}

	}

	printf("%lld\n", l + r);

}


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

#include<algorithm>

#include<string>

#include<sstream>

#include<cmath>

#include<set>

#include<map>

#include<cstdio>

#include<ctime>

#include<vector>

#include<stdlib.h>



#define endl '\n'

#define ll long long

#define ull unsigned ll

#define x first

#define y second



using namespace std;







int main(){

    ll n;

    cin>>n;

    ll x=1,y=1;

    ll a,b;

    ll beshu,beshu1;

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

        cin>>a>>b;

        beshu=1;

        if(a<x){

            if(!(x%a))beshu=x/a;

            else beshu=x/a+1;

        }

        if(b<y){

            beshu1=1;

            if(!(y%b)) beshu1=y/b;

            else beshu1=y/b+1;

            beshu=max(beshu,beshu1);

        }

        x=a*beshu;

        y=b*beshu;

    }

    cout<<x+y<<endl;

    return 0;

}


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



constexpr int kN = int(1E3 + 10);



long long int gcd(long long int a, long long int b) {return b == 0 ? a : gcd(b, a % b);}



long long int a[kN], b[kN];



int main() {

	int n;

	long long int l = 1, r = 1, tmp, nl, nr, nnl, nnr;

	scanf("%d", &n);

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

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

		tmp = gcd(l, r);

		if (l / tmp == a[i] && r / tmp == b[i]) continue;

			nl = ((l - 1) / a[i] + 1) * a[i];

			nr = nl / a[i] * b[i];

			nnr = ((r - 1) / b[i] + 1) * b[i];

			nnl = nnr / b[i] * a[i];

			if (nl >= l && nr >= r) {

				if (nnl >= l && nnr >= r) {

					if (nl < nnl) {

						l = nl;

						r = nr;

					}

					else {

						l = nnl;

						r = nnr;

					}

				}

				else {

					l = nl;

					r = nr;

				}

			}

			else {

				l = nnl;

				r = nnr;

			}

	}

	printf("%lld\n", l + r);

}


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

#include <algorithm>



typedef long long ll;



using namespace std;



int main() {

    ll n, p = 1, q = 1, t, a, m;

    cin >> n;

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

        cin >> t >> a;

        m = max((p - 1) / t + 1, (q - 1) / a + 1);

        p = t * m, q = a * m;

    }

    cout << p + q << endl;

    return 0;

}


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

#include <algorithm>



typedef long long ll;



using namespace std;



int main() {

    ll n, p = 1, q = 1, t, a, m;

    scanf("%lld", &n);

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

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

        m = max((p - 1) / t + 1, (q - 1) / a + 1);

        p = t * m, q = a * m;

    }

    printf("%lld\n", p + q);

    return 0;

}


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





using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;



const int MAXN = 100 * 1000 + 123;











ll n, x, y;





int main() {

	{

		ll tmp, a, b;

		cin >> n;

		cin >> a >> b;

		x = a / __gcd(a, b);

		y = b / __gcd(a, b);

		

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

			cin >> a >> b;

			tmp = max((x + a - 1) / a, (y + b - 1) / b);

			x = tmp * a, y = tmp * b;

		}

	}

	cout << x + y;

	return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define maxn 1005

#define INF ((ll)(1e18)+1)

typedef long long ll;

int T[maxn], A[maxn];

int main(void)

{

	int n;

	scanf("%d", &n);

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

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

	ll t = T[0], a = A[0];

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

	{

		if (T[i] >= t && A[i] >= a) {

			t = T[i], a = A[i];

			continue;

		}

		ll k = max(t / T[i], a / A[i]);

		if (k < 1)k = 1;

		while (T[i] * k < t || A[i] * k < a)

			k++;

		t = T[i] * k, a = A[i] * k;

	}

	printf("%lld\n", t + a);

	return 0;

}

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

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=200005;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

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

ll ceils(ll x,ll y)

{

    if(x%y==0)

        return x/y;

    return x/y+1;

}

int main()

{

    std::ios::sync_with_stdio(false);

    int n;

    ll a,b;

    cin>>n>>a>>b;

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

    {

        ll x,y;

        cin>>x>>y;

        ll t=max(ceils(a,x),ceils(b,y));

        a=x*t,b=y*t;

    }

    cout<<a+b<<endl;

    return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define maxn 1005

#define INF ((ll)(1e18)+1)

typedef long long ll;

int T[maxn], A[maxn];

int main(void)

{

	int n;

	scanf("%d", &n);

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

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

	ll t = T[0], a = A[0];

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

	{

		if (T[i] >= t && A[i] >= a) {

			t = T[i], a = A[i];

			continue;

		}

		ll k = max(t / T[i], a / A[i]);

		if (k < 1)k = 1;

		while (T[i] * k < t || A[i] * k < a)

			k++;

		t = T[i] * k, a = A[i] * k;

	}

	printf("%lld\n", t + a);

	return 0;

}

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

using namespace std;



int main() {

    cin.tie(NULL);

    ios::sync_with_stdio(false);

    int n;

    cin>>n;

    long long int la=0,lb=0;

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

        long long int a,b;

        cin>>a>>b;

        if(a<la||b<lb){

            long long int da=la/a;

            long long int db=lb/b;

            if(la%a)da++;

            if(lb%b)db++;

            a*=max(da,db);

            b*=max(da,db);

        }

        la=a;

        lb=b;

    }

    cout<<la+lb;

    return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define maxn 1005

#define INF ((ll)(1e18)+1)

typedef long long ll;

int T[maxn], A[maxn];

int main(void)

{

	int n;

	scanf("%d", &n);

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

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

	ll t = T[0], a = A[0];

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

	{

		if (T[i] >= t && A[i] >= a) {

			t = T[i], a = A[i];

			continue;

		}

		ll k = max(t / T[i], a / A[i]);

		if (k < 1)k = 1;

		while (T[i] * k < t || A[i] * k < a)

			k++;

		t = T[i] * k, a = A[i] * k;

	}

	printf("%lld\n", t + a);

	return 0;

}

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

#define n 500000

#define mem(arr) memset(arr, 0, sizeof(arr))

using namespace std;

typedef long long lli;

typedef double llf;

typedef pair<int, int> P;

void solve();

int main()

{

	ios_base::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	int times = 1;

//	cin >> times;

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

	{

		solve();

		cout << '\n';

	}

	return 0;

}



int a, b, c, d, e, f, g, h;

//int arr[n + 50], arr1[n + 50], arr2[n + 50];



//type here



void solve()

{

	cin >> a;

	pair<lli, lli> arr[a + 50];

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

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

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

	{

		if(arr[i].first >= arr[i - 1].first && arr[i].second >= arr[i - 1].second) continue;

		lli one = arr[i - 1].first / arr[i].first, two = arr[i - 1].second / arr[i].second;

		if(arr[i - 1].first % arr[i].first != 0) one ++;

		if(arr[i - 1].second % arr[i].second != 0) two ++;

		lli res = max(one, two);

		arr[i].first *= res; arr[i].second *= res;

	}

	lli ans = arr[a - 1].first + arr[a - 1].second;

	cout << ans;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define maxn 1005

#define INF ((ll)(1e18)+1)

typedef long long ll;

int T[maxn], A[maxn];

int main(void)

{

	int n;

	scanf("%d", &n);

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

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

	ll t = T[0], a = A[0];

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

	{

		if (T[i] >= t && A[i] >= a) {

			t = T[i], a = A[i];

			continue;

		}

		ll k = max(t / T[i], a / A[i]);

		if (k < 1)k = 1;

		while (T[i] * k < t || A[i] * k < a)

			k++;

		t = T[i] * k, a = A[i] * k;

	}

	printf("%lld\n", t + a);

	return 0;

}

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

using namespace std;

int main(){

	ios::sync_with_stdio(false);

	int n,a,b;

	long long x=1,y=1;

	long long mid;

	cin>>n;

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

		cin>>a>>b;

		mid=max(x/a,y/b);

		while(mid*a<x || mid*b<y)

			mid++;

		x=mid*a;

		y=mid*b;	

	}

	cout<<x+y<<endl;

	return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define maxn 1005

#define INF ((ll)(1e18)+1)

typedef long long ll;

int T[maxn], A[maxn];

int main(void)

{

	int n;

	scanf("%d", &n);

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

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

	ll t = T[0], a = A[0];

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

	{

		if (T[i] >= t && A[i] >= a) {

			t = T[i], a = A[i];

			continue;

		}

		ll k = max(t / T[i], a / A[i]);

		if (k < 1)k = 1;

		while (T[i] * k < t || A[i] * k < a)

			k++;

		t = T[i] * k, a = A[i] * k;

	}

	printf("%lld\n", t + a);

	return 0;

}

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

#include <iomanip>

typedef long long ll;

using namespace std;

ll CEIL(ll a, ll b)

{

    ll res = a / b;

    if (a % b)

    {

        res++;

    }

    return res;

}

int main()

{

    ll a, b;

    ll n;

    cin >> n;

    cin >> a >> b;

    n--;

    ll x, y;

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

    {

        cin >> x >> y;

        ll num = max(CEIL(a, x), CEIL(b, y));

        a = num * x;

        b = num * y;

    }

    cout << a + b << endl;

    return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define maxn 1005

#define INF ((ll)(1e18)+1)

typedef long long ll;

int T[maxn], A[maxn];

int main(void)

{

	int n;

	scanf("%d", &n);

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

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

	ll t = T[0], a = A[0];

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

	{

		if (T[i] >= t && A[i] >= a) {

			t = T[i], a = A[i];

			continue;

		}

		ll k = max(t / T[i], a / A[i]);

		if (k < 1)k = 1;

		while (T[i] * k < t || A[i] * k < a)

			k++;

		t = T[i] * k, a = A[i] * k;

	}

	printf("%lld\n", t + a);

	return 0;

}

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

using namespace std;

int64_t MAXN = pow(10, 5) + 10;

int64_t N, first = 0;

vector<int64_t> A(MAXN);



int main()

{

  cin >> N;

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

  {

    cin >> A[i];

    if (A[i] % 2)

      first = 1;

  }

  cout << (first ? "first" : "second") << endl;

}


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

using namespace std;



int main()

{

  int64_t N, a, odds = 0;

  cin >> N;

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

  {

    cin >> a;

    if (a % 2)

      odds++;

  }

  cout << (odds == 0 ? "second" : "first") << endl;

}


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



using namespace std;



#define int long long



int n,x,dem;



main()

{

    cin>>n;

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

    {

        cin>>x;

        if(x%2==1) dem=1;

    }

    if(dem==0) cout<<"second";

    else cout<<"first";

}


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

int n;

int a[100100];

int main()

{

	scanf("%d", &n);

	bool flag = false;

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

	{

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

		if (a[i] & 1) flag = true;

	}

	if (flag) printf("first\n");

	else printf("second\n");

	return 0;

}


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

#include <vector>

#include <bitset>

using namespace std;



int main(){

	bitset<1121> isprime;

	isprime.set();

	isprime.reset(0);

	isprime.reset(1);

	

	for(int i = 2; i * i <= 1120; ++i){

		if( isprime[i] ){

			for(int j = i * i; j <= 1120; j += i){

				isprime.reset(j);

			}

		}

	}

	

	vector<int> prime;

	prime.reserve(200);

	for(int i = 2; i < 1120; ++i){

		if( isprime[i] ){

			prime.push_back(i);

		}

	}



	prime.push_back(1e9);



	vector<int>::iterator it;



	int n, k;

	while( scanf("%d%d", &n, &k), n != 0 ){

		vector<vector<int> > dp(k + 1, vector<int>(n + 1) );

		dp[0][0] = 1;



		for(it = prime.begin(); *it <= n; ++it){

			for(int j = n - *it; j >= 0; --j){

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

					dp[i + 1][j + *it] += dp[i][j];

				}

			}

		}

		

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

	}

}

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

#include <vector>

using namespace std;



bool isnp[1121];

int dp[15][1121];



int main(){

	for(int i = 2; i < 40; ++i){

		if( !isnp[i] ){

			for(int j = i * i; j <= 1120; j += i){

				isnp[j] = true;

			}

		}

	}



	dp[0][0] = 1;

	for(int i = 2; i < 1120; ++i){

		if( !isnp[i] ){

			for(int k = 14; k > 0; --k){

				for(int j = 1120; j >= i; --j){

					dp[k][j] += dp[k-1][j-i];

				}

			}

		}

	}

	

	int n, k;

	while(scanf("%d%d", &n, &k), n != 0){

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

	}

}

// Fastest known solution for this problem: