stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

using namespace std;

int n;

int main() {

	cin >> n;

	cout << n * 800 - n / 15 * 200 << endl;

	return 0;

}

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

int main() {

	int n;

	scanf("%d", &n);

	printf("%d\n", n * 800 - n / 15 * 200);

	return 0;

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



using namespace std;



int main()

{

int a,b,c,d,e;



cin>>b;

c=b/15;

e=c*200;

a=b*800;

d=a-e;

cout<<d;



return 0;

}

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

using namespace std;

int main()

{

   int N, B, x, y;

   scanf("%d", &N);

   x=N*800;

   y=(N/15)*200;

   printf("%d\n", x-y);

   return 0;

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

using namespace std;



int main(){

    int a,b;

    cin>>a;

    b=a/15;

    a=(a*800)-(b*200);

    cout<<a;

}

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

using namespace std;

int main()

{

   int N, B, x, y;

   scanf("%d", &N);

   x=N*800;

   y=(N/15)*200;

   printf("%d\n", x-y);

   return 0;

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

using namespace std;

int main()

{

	int x, n, y, z=0, i, t;

	scanf("%d", &n);

	z=800*n;

	if(n>15){

		i=n/15;

		t=z-(i*200);

		printf("%d", t);

	}

	else{

		printf("%d", z);

	}

	return 0;

}

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

using namespace std;

int main()

{

   int N, B, x, y;

   scanf("%d", &N);

   x=N*800;

   y=(N/15)*200;

   printf("%d\n", x-y);

   return 0;

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

using namespace std;

int main()

{

    int n,x,y,d;

    scanf("%d",&n);

    x=n*800;

    y=(n/15)*200;

	d=x-y;

	printf("%d",d);

    return 0;

}


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

using namespace std;

int main()

{

   int N, B, x, y;

   scanf("%d", &N);

   x=N*800;

   y=(N/15)*200;

   printf("%d\n", x-y);

   return 0;

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

using namespace std;



int N;



int main () {

	cin >> N;

	cout << N*800-(N/15)*200 << endl;

}

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

using namespace std;

int main()

{

   int N, B, x, y;

   scanf("%d", &N);

   x=N*800;

   y=(N/15)*200;

   printf("%d\n", x-y);

   return 0;

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

#include<cstdio>

#include<stack>

#include<cmath>

#include<cstring>

using namespace std;



int a[55];

int main()

{

	int n;

	while(cin>>n)

	{

		memset(a,0,sizeof(a));

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

		{

			cin>>a[i];

		}

		long long int sum=0;

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

		{

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

			{

				sum+= a[i]*a[j];

			}

		}

		cout<<sum<<endl;

	}

}

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

#include <string.h>

#pragma warning(disable:4996)



int d[50];

int main() {

	int n;

	while (scanf("%d", &n) != -1) {

		memset(d, 0, sizeof(d));

		long long sum = 0;

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

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

		}

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

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

				sum += d[i] * d[j];

			}

		}

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

	}

	return 0;

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

#include<cstdio>

#include<stack>

#include<cmath>

#include<cstring>

using namespace std;



int a[55];

int main()

{

	int n;

	while(cin>>n)

	{

		memset(a,0,sizeof(a));

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

		{

			cin>>a[i];

		}

		long long int sum=0;

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

		{

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

			{

				sum+= a[i]*a[j];

			}

		}

		cout<<sum<<endl;

	}

}

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

#include <math.h>

int main()

{

    int n,sum=0;

    scanf("%d",&n);

    int ch[55];

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

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

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

    {

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

        {

            sum=sum+ch[i]*ch[j];

        }

    }

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

    return 0;

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

#include<algorithm>

#define debug(x) cout<<"***"<<x<<"***"<<endl;

using namespace std;

int a[55];

int main()

{

	int sum=0,n;

	cin>>n;

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

	{

		cin>>a[i];

	}

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

	{

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

		{

			sum+=a[i]*a[j];

		}

	}

	cout<<sum;

	return 0;

}

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

#include<stdlib.h>

#pragma warning(disable:4996)

int main()

{

	int n, d[105],s=0;

	scanf("%d",&n);

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

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

	{

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

		{

			s+=d[i]*d[j];

		}

	}

	printf("%d",s);

	return 0;

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

using namespace std;

int sum=0, n, a[53], b[53];

int main()

{

	cin>>n;

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

		cin>>a[i];

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

	}

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

		sum+=(a[i]*b[i]);

	}

	cout<<sum<<endl;

	return 0;

}

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

#include<stdlib.h>

#pragma warning(disable:4996)

int main()

{

	int n, d[105],s=0;

	scanf("%d",&n);

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

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

	{

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

		{

			s+=d[i]*d[j];

		}

	}

	printf("%d",s);

	return 0;

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

#include<algorithm>

#define debug(x) cout<<"***"<<x<<"***"<<endl;

using namespace std;

int a[55];

int main()

{

	int sum=0,n;

	cin>>n;

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

	{

		cin>>a[i];

	}

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

	{

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

		{

			sum+=a[i]*a[j];

		}

	}

	cout<<sum;

	return 0;

}

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

int main(){

	int n,ci,sum;

	int d[51];

	sum=0;

	scanf("%d",&n);

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

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

	}

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

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

			sum=sum+d[i]*d[j];

		}

	}

	printf("%d",sum);

	return 0;

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

using namespace std;

int sum=0, n, a[53], b[53];

int main()

{

	cin>>n;

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

		cin>>a[i];

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

	}

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

		sum+=(a[i]*b[i]);

	}

	cout<<sum<<endl;

	return 0;

}

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

int main(){

	int n,ci,sum;

	int d[51];

	sum=0;

	scanf("%d",&n);

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

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

	}

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

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

			sum=sum+d[i]*d[j];

		}

	}

	printf("%d",sum);

	return 0;

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

using namespace std;

int a[1005],b[1005]={0},m,n;

int main(){

	cin>>n;

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

		cin>>a[i];

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

		b[j]=b[j+1]+a[j];

	}

	int ans=0;

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

		ans+=a[i]*b[i+1];		

	}

	cout<<ans<<endl;

	return 0; 

} 

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

using namespace std;



int main() {

	int n,d[100];

	scanf("%d", &n);

	int i0 = 0; long result = 0;

	for(; i0<n; i0++) {scanf("%d", &d[i0]);}

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

		for(int j = i+1; j < i0;j++){

			result += d[i]*d[j];

		}

	}

	printf("%d", result);

	return 0;

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

using namespace std;

int a[51];

int main(){

	int n;

	cin>>n;

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

		cin>>a[i];

	}

	int sum=0;

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

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

			sum+=a[i]*a[j];

		}

	}

	cout<<sum;

}

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

using namespace std;



int main() {

	int n,d[100];

	scanf("%d", &n);

	int i0 = 0; long result = 0;

	for(; i0<n; i0++) {scanf("%d", &d[i0]);}

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

		for(int j = i+1; j < i0;j++){

			result += d[i]*d[j];

		}

	}

	printf("%d", result);

	return 0;

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

using namespace std;

int a[100];

int main()

{int n,i,j,sum=0;

cin >> n;

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

cin >> a[i];

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

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

  sum+=a[i]*a[j];

cout << sum;

return 0;







}

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

using namespace std;



int main() {

	int n,d[100];

	scanf("%d", &n);

	int i0 = 0; long result = 0;

	for(; i0<n; i0++) {scanf("%d", &d[i0]);}

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

		for(int j = i+1; j < i0;j++){

			result += d[i]*d[j];

		}

	}

	printf("%d", result);

	return 0;

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

using namespace std; 

int main(){

//  freopen("test.in","r",stdin);

//  freopen("test.out","w",stdout);

	int n,sum=0;

	cin>>n;

	int a[n+1];

	memset(a,0,sizeof(a));

	for(int i =0;i<n;i++) cin>>a[i];

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

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

			sum+=a[i]*a[j];

		}

	}

	cout<<sum;

    return 0;

}

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

using namespace std;



int main() {

	int n,d[100];

	scanf("%d", &n);

	int i0 = 0; long result = 0;

	for(; i0<n; i0++) {scanf("%d", &d[i0]);}

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

		for(int j = i+1; j < i0;j++){

			result += d[i]*d[j];

		}

	}

	printf("%d", result);

	return 0;

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

using namespace std;

#define ll long long

int main()

{

    ll a,b,c,d,e,k,n,p,ct=0;

    cin>>a>>b>>c>>d>>e>>k;

    if(abs(a-b)>k) ct++;

    if(abs(a-c)>k) ct++;

    if(abs(a-d)>k) ct++;

    if(abs(a-e)>k) ct++;

    if(abs(b-c)>k) ct++;

    if(abs(b-d)>k) ct++;

    if(abs(b-e)>k) ct++;

    if(abs(c-d)>k) ct++;

    if(abs(c-e)>k) ct++;

    if(abs(d-e)>k) ct++;

    if(ct>0) cout<<":\("<<endl;

    else cout<<"Yay!"<<endl;

    return 0;

}






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

int main(){

  int a, b, c, d, e, k;

  scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);



  if( ((a-b)<=k) && ((a-c)<=k) && ((a-d)<=k) && ((a-e)<=k) && ((b-a)<=k) && ((b-c)<=k) && ((b-d)<=k) && ((b-e)<=k) && ((c-a)<=k) && ((c-b<=k)) && ((c-d)<=k) && ((c-e)<=k) && ((d-a)<=k) && ((d-b)<=k) && ((d-c)<=k) && ((d-e)<=k) && ((e-a)<=k) && ((e-b)<=k) && (e-c)<=k && (e-d)<=k)

    printf("Yay!\n");

  else printf(":(\n");



  return 0;

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

using namespace std;



int main()

{

  ios::sync_with_stdio(false);

  vector<int> v(5);

  int k, a = 5, max = 0;



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

    cin >> v[i];



  cin >> k;



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

  {

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

    {

      if (v[j] - v[i] > max)

        max = v[j] - v[i];

    }

  }



  if (max > k)

    cout << ":(\n";

  else

    cout << "Yay!\n";



  return 0;

}

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

int main(){

  int a, b, c, d, e, k;

  scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);



  if( ((a-b)<=k) && ((a-c)<=k) && ((a-d)<=k) && ((a-e)<=k) && ((b-a)<=k) && ((b-c)<=k) && ((b-d)<=k) && ((b-e)<=k) && ((c-a)<=k) && ((c-b<=k)) && ((c-d)<=k) && ((c-e)<=k) && ((d-a)<=k) && ((d-b)<=k) && ((d-c)<=k) && ((d-e)<=k) && ((e-a)<=k) && ((e-b)<=k) && (e-c)<=k && (e-d)<=k)

    printf("Yay!\n");

  else printf(":(\n");



  return 0;

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



using namespace std;



int main(){



    int ant[5],k;



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

        cin>>ant[i];

    }

    cin>>k;



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

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

            if(ant[j]-ant[i]>k){

                cout<<":(\n";

                return 0;

            }

        }

    }



    cout<<"Yay!\n";





    return 0;

}

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

int main(){

  int a, b, c, d, e, k;

  scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);



  if( ((a-b)<=k) && ((a-c)<=k) && ((a-d)<=k) && ((a-e)<=k) && ((b-a)<=k) && ((b-c)<=k) && ((b-d)<=k) && ((b-e)<=k) && ((c-a)<=k) && ((c-b<=k)) && ((c-d)<=k) && ((c-e)<=k) && ((d-a)<=k) && ((d-b)<=k) && ((d-c)<=k) && ((d-e)<=k) && ((e-a)<=k) && ((e-b)<=k) && (e-c)<=k && (e-d)<=k)

    printf("Yay!\n");

  else printf(":(\n");



  return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.408967434246541x):
#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;

}
// Slower C++ solution:
#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;



}


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

int main()

{

	int a, b;

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

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

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

using namespace std;

int main(){

    int a,b;

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

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

}


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

int main()

{

	int a, b;

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

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

}
// Slower C++ solution:
#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;

}


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

int main()

{

	int a, b;

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

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

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.2344016270980696x):
#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);

}
// Slower C++ solution:
#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';

}

// Faster C++ solution for the same problem (measured speedup: 5.298923827532273x):
#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);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.157092583514252x):
#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);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.213972442047763x):
#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);

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.216916909759262x):
#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;

}