akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return !f?x:-x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
char S[MAXN+5],T[MAXN+5];
int pos[30][MAXN+5],siz[30];
int main(){
	scanf("%s",S+1);
	scanf("%s",T+1);
	LL ans=0,p=0;
	int n=strlen(S+1),m=strlen(T+1);
	for(int i=1;i<=n;i++)
		pos[S[i]-'a'][++siz[S[i]-'a']]=i;
	for(int i=1;i<=m;i++){
		if(!siz[T[i]-'a']){
			puts("-1");
			return 0;
		}
		int j=T[i]-'a',nxt=upper_bound(pos[j]+1,pos[j]+siz[j]+1,p)-pos[j];
		if(nxt==siz[j]+1)
			ans+=n-p+pos[j][1],p=pos[j][1];
		else 
			ans+=pos[j][nxt]-p,p=pos[j][nxt];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 19072
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    vector<int> num(3);
    cin >> num[0] >> num[1] >> num[2];
    sort(num.begin(), num.end());

    int ans = 0;
    ans += num[2]-num[1];
    num[0] += ans;
    if((num[2]-num[0])%2==0){
        ans += (num[2]-num[0])/2;
    }
    else{
        ans += (num[2]-num[0]+1)/2;
        ans += 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int a[11][10001];
int main(){
	int R,C;
	while(true){
	cin>>R>>C;
	if(R==0&&C==0)break;
	rep(i,R){
		rep(j,C){
			cin>>a[i][j];
		}
	}
	int ans=0;
	rep(i,1<<R){
		int used[11];
		rep(j,R){
		//	if((i>>j)==1)used[j]=1;
		//	else  used[j]=0;
			used[j]=(i>>j)&1;
		}
		int tmp=0;
		rep(j,C){
			int tmp2=0;
			rep(k,R){
				if(used[k]==1){
					tmp2+=(1-a[k][j]);
				}
				else{
					tmp2+=a[k][j];
				}
			}
			tmp+=max(tmp2,R-tmp2);
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3448
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int result = 0;
		ArrayList<Integer> A = new ArrayList<Integer>();
		ArrayList<Integer> B = new ArrayList<Integer>();
		for(int i = 0; i < N -1; i++) {
			B.add(sc.nextInt());
		}

		if(N <= 2) {
			for(int i = 0; i < N; i++) {
				A.add(B.get(0));
				result += A.get(i);
			}
		}else {
			A.add(B.get(0));
			result += A.get(0);
			for(int i = 1; i < N - 1; i++) {
				if(B.get(i - 1) < B.get(i)) {
					A.add(B.get(i - 1));
				}else {
					A.add(B.get(i));
				}
				result += A.get(i);
			}
			A.add(B.get(N - 2));
			result += A.get(N - 1);
		}
		System.out.println(result);
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> node(N);
    for(int i = 0;i < N;i++){
        node.at(i) = i + 1;
    }

    vector<pair<int,int>> edge(M);
    int a,b;
    for(int i = 0;i < M;i++){
        cin >> a >> b;
        edge.at(i) = pair<int,int>(a,b);
    }

    bool can = false;
    bool can_can = false;
    int count = 0;
    do{
        can = true;
        for(int i = 0;i < N - 1;i++){
            can_can = false;
            pair<int,int> p(min(node.at(i),node.at(i+1)),max(node.at(i),node.at(i+1)));
            for(auto q : edge){
                if(p == q){
                    can_can = true;
                    break;
                }
            }
            if(!can_can){
                can = false;
                break;
            }
        }
        if(can){
            count++;
        }
    }while(next_permutation(node.begin()+1,node.end()));

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)


//AtCoder Beginner Contest 126 - B
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll front = (s[0] - '0') * 10 + (s[1] - '0');
	ll back = (s[2] - '0') * 10 + (s[3] - '0');

	if ((front > 12 && back > 12) || (front > 12 && back == 0) || (back > 12 && front == 0) || (back == 0 && front == 0)) {
		printf("NA\n");
	}
	else if (front > 12 || front == 0) {
		printf("YYMM\n");
	}
	else if (back > 12 || back == 0) {
		printf("MMYY\n");
	}
	else {
		printf("AMBIGUOUS\n");
	}
}

//AtCoder Beginner Contest 126 - A
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll K;
	scanf("%lld", &K);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	s[K - 1] = s[K - 1] - 'A' + 'a';

	printf("%s\n", s);
}
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<char> A = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
   for(int i=0;i<S.size();i++){
       for(int j=0;j<26;j++){
           if(S.at(i)==A.at(j)){
               S.at(i)=A.at(j+N);
               break;
            }
       }
   }
   cout << S << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	int i,n,p;
	cin>>n;
	vi a(100010,0);
	for0(i,n){
		cin>>p;
		a[p]++;
		}
	int t,x = 0;
	for(i=1 ; i<=100000 ; i++){
		t = 0;
		t += a[i];
		t += a[i-1];
		t += a[i+1];
		x = max(x,t);	
		}
	cout<<x<<nw;
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        while (true) {
            String s = String.valueOf(n);
            char c = s.charAt(0);
            boolean f = true;
            for (int i = 1; i < s.length(); i++) {
                if (c != s.charAt(i)) {
                    f = false;
                    break;
                }
            }
            if(f){
                break;
            }
            n++;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 23892
#include<iostream>
using namespace std;

int main(void){
	int l[5000];
	int n;
	while(cin>>n,n){
		for(int i = 0 ; i < n ; i++)cin>>l[i];
		int res = -1000000;
		for(int i = 0 ; i < n ; i ++){
			int sum = 0;
			res = max(l[i],res);
			for(int j = i ; j < n ; j ++){
				sum += l[j];
				res = max(sum,res);
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin >> n;
    cout << 800*n - (n/15)*200 << endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

char neighbor(char me, char other, char answer) {
    if (answer == 'o') {
        if (me == 'S') {
            if (other == 'S') {
                return 'S';
            } else {
                return 'W';
            }
        } else {
            if (other == 'S') {
                return 'W';
            } else {
                return 'S';
            }

        }
    } else {
        if (me == 'S') {
            if (other == 'S') {
                return 'W';
            } else {
                return 'S';
            }
        } else {
            if (other == 'S') {
                return 'S';
            } else {
                return 'W';
            }
        }
    }
}

int main() {
    int n;
    string s;
    cin >> n >> s;

    char st[4][2]{{'S', 'S'}, {'S', 'W'}, {'W', 'S'}, {'W', 'W'}};
    for (int i = 0; i < 4; i++) {
        char t[n]{st[i][0], st[i][1]};

        char last = neighbor(t[0], t[1], s[0]);

        for (int j = 1; j < n - 1; j++) {
            t[j+1] = neighbor(t[j], t[j-1], s[j]);
        }

        if (last == t[n-1] && t[0] == neighbor(t[n-1], t[n-2], s[n-1])) {
            for (int k = 0; k < n; k++) {
                cout << t[k];
            }
            cout << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	getline(cin,a);
	int n=a.size(),p;
	for(int i=0;i<n;i++){
		p=0;
		if((i+1)%2==1){
			if(a[i]=='U'||a[i]=='R'||a[i]=='D')
				p=1;
		}
		else{
			if(a[i]=='L'||a[i]=='U'||a[i]=='D')
				p=1;
		}
		if(p==0)
			break;
	}
	if(p==1)
		cout<<"Yes";
	else
		cout<<"No";
} 

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

const int maxn = 1e6 + 6;
double p[maxn];
double dp[3050][3050];
int n;
int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    n = read();
    rep(i, 1, n) sf(p[i]);
    dp[1][1] = p[1];
    dp[1][0] = 1.0 - p[1];
    rep(i, 2, n) {
        rep(j, 0, i) {
            if (j == 0) {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]);
                continue;
            }
            dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1.0 - p[i]);
        }
    }
    double ans = 0.0;
    for (int i = (n + 1) / 2; i <= n; ++i) {
        ans += dp[n][i];
    }
    printf("%.10lf\n", ans);
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 72320
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<vector<int>> v(2, vector<int>(N));
  rep(i, 0, 2) rep(j, 0, N) { cin >> v[i][j]; }
  rep(i, 1, N) { v[0][i] += v[0][i - 1]; }
  rep(i, 0, N) {
    v[1][i] = max(v[1][i] + (i - 1 >= 0 ? v[1][i - 1] : 0), v[1][i] + v[0][i]);
  }
  cout << v[1][N - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;


long long gcd(long long a, long long b) {return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) {return (a/gcd(a,b))*b;}

int N;
ll ans, M;
ll a[100005];
ll cnt = 0;

int main(void) {
    scanf("%d %lld", &N, &M);
    rep(i, 0, N) {
      scanf("%lld", &a[i]);
      a[i] >>= 1;
    }

    ll L = 1;
    for(int i=0; i<N; i++) {
        L = lcm(L, a[i]);
        if (L>M) {
            puts("0");
            return 0;
        }
    }
    rep(i, 0, N) if ((L/a[i])%2==0) {
      puts("0");
      return 0;
    }

    
    ans = ((M/L)+1)/2;

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<int,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//lint sho[512810],ama[512810];
lint num[512810];
int n;
lint ka(int t){
	lint ret=0,zyo=1;
	REP(i,t,n){
		ret+=num[i]*zyo;zyo*=10;
	}
	return ret;
}
bool cal(lint mi){
	lint mo=0;
	rep(i,n){
		lint ne=((num[i]-mo)%10+10)%10;
		if(ne>mi) return false;
		//if(n-i<18 && ka(i)<=mi) return true;
		lint x=(mi-ne)/10;
		//cout<<ne<<' '<<x<<endl;
		ne+=x*10;
		mo+=ne;mo-=num[i];
		mo/=10;mi=ne;
	}
	return true;
}
int main()
{
	lint inf=1145141919810893LL;
	string s;
	cin>>s;n=s.size();reverse(All(s));
	rep(i,n) num[i]=(s[i]-'0');
	lint lo=0,hi=inf;
	//cal(0);
	while(hi>lo){
		lint mi=(hi+lo)/2;
		if(cal(mi)) hi=mi;else lo=mi+1;
	}
	cout<<(lo+8)/9<<endl;
}


Measured memory_bytes: 4740
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

long long a[200010];
int main(){
	int i,n,b,j;
	long long k,sum=0,ans1,ans2=10000000000000;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		a[i]= a[i]-i-1;
		sum += a[i];
	}
	
	k = sum/n;
	if(n==1){
		cout << 0 << endl;
		return 0;
	}
	if(n==2){
		cout << abs(a[1]-a[0]) << endl;
		return 0;
	}
	sort(a,a+n);
	//cout << sum << " " <<  k << endl;
		ans1 = 0;
	b = a[n/2];
		for(i=0;i<n;i++){
		ans1 += abs(a[i]-b);
		}
		//cout << ans1 << endl;
		ans2 = min(ans1,ans2);
		//cout << " " << ans2 << endl;
	cout << ans1 << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
//#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


//namespace mp = boost::multiprecision;

//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int size(int n) {
	int count = 0;
	while (n > 0) {
		n /= 10;
		count++;
	}
	return count;
}

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}
int main() {
	int N, M;
	scanf("%d %d",&N ,& M);
	map<int,int>Y_Cnt;
	vector<pair<int, int>>P_Y(M);
	vector<pair<int, int>>P_Y_Copy(M);

	rep(i, M) {
		scanf("%d %d",& P_Y[i].first,& P_Y[i].second);
	}
	P_Y_Copy = P_Y;
	sort(all(P_Y), ps3);

	vector<int>cnt(N+1);
	FOR(i,0 ,M) {
		cnt[P_Y[i].F]++;
		Y_Cnt[P_Y[i].S] = cnt[P_Y[i].F];
	}

	rep(i, M) {
		int sizep = size(P_Y_Copy[i].F);
		int sizenum = size(Y_Cnt[P_Y_Copy[i].S]);
		rep(i, 6 - sizep) {
			printf("0");
		}
		printf("%d", P_Y_Copy[i].F);
		rep(i, 6 - sizenum) {
		printf("0");
		}
		printf("%d\n", Y_Cnt[P_Y_Copy[i].S]);

	}




}


Measured memory_bytes: 8192
from fractions import gcd
def lcm(x,y):
  return (x*y)//gcd(x,y)
a,b,c,d=map(int,input().split())
cnt_c=b//c-(a-1)//c
cnt_d=b//d-(a-1)//d
cnt_cd=b//lcm(c,d)-(a-1)//lcm(c,d)
print(b-a+1-cnt_c-cnt_d+cnt_cd)

Measured memory_bytes: 5076
#include <iostream>
#include <string>
using namespace std;

int main()
{
    char A[101], B[101];
    cin >> A >> B;
    if(strlen(A)>strlen(B)){
        cout << "GREATER" << endl;
        return 0;
    }else if(strlen(A)<strlen(B)){
        cout << "LESS" << endl;
        return 0;
    }else{
        for(int i=0;i<strlen(A);i++){
            if(A[i]>B[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(A[i]<B[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
    }

    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(true){
            int n = scan.nextInt();//????£????????????°
            int p = scan.nextInt();//????????°
            boolean end_flag = false;
            if(n==0 && p==0) break;
            int[] num = new int[n];
            for(int i=0;i<n;i++){
                num[i] = 0;     
            }
            while(true){
                if(end_flag) break;
                for(int i=0;i<n;i++){
                    if(end_flag) break;
                    //System.out.println(i);
                    if(p==0){
                       p = num[i];
                       num[i] = 0; 
                    }
                    else{
                        p--;
                        //System.out.println(p);
                        num[i]++;
                        if(p==0){
                            for(int j=0;j<n;j++){
                                if(j==i) {}
                                else{
                                    if(num[j] == 0){}
                                    else break;
                                } 
                                if(j==n-1){
                                    System.out.println(i);
                                    end_flag = true;
                                }
                            }
                        }
                    }
                }
		    }
        }
	}

    public static void main(String[] args){
		Main app = new Main();
		app.run();
    }
}

Measured memory_bytes: 27236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    int n;
    cin >> n;
    int v[n];
    int c[n];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    int s=  0; 
    for(int i = 0; i < n; i++){
        if(v[i] > c[i]) s += v[i]-c[i];
    }
    cout << s;
    

}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
D = get_ints

sum = 0
D.combination(2) do |a, b|
  sum += a * b
end

puts sum


Measured memory_bytes: 14444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
struct edge{int f,t,l;}w[N];
int n,m,S,T,head[N],nxt[N];
void add(int f,int t,int l){
	static int cnt=0;
	w[++cnt]=(edge){f,t,l};
	nxt[cnt]=head[f];
	head[f]=cnt;
}
ll disS[N],disT[N];
int dpS[N],dpT[N];
bool vis[N];
typedef pair<ll,int> pii;
priority_queue<pii,vector<pii>,greater<pii> > Q;
int q[N];ll *val;
bool cmp(int x,int y){return val[x]<val[y];}
void dijsktra(int S,ll *dis,int *dp){
	for (int i=1;i<=n;i++) dis[i]=1e18,vis[i]=0;
	Q.push(pii(dis[S]=0,S));
	while (!Q.empty()){
		int v=Q.top().second;Q.pop();
		if (vis[v]) continue;vis[v]=1;
		for (int i=head[v];i;i=nxt[i]){
			int u=w[i].t;
			if (dis[u]>dis[v]+w[i].l) Q.push(pii(dis[u]=dis[v]+w[i].l,u));
		}
	}
	dp[S]=1;
	for (int i=1;i<=n;i++) q[i]=i;
	val=dis;sort(q+1,q+n+1,cmp);
	for (int x=1;x<=n;x++){
		int v=q[x];
		for (int i=head[v];i;i=nxt[i]){
			int u=w[i].t;
			if (dis[u]==dis[v]+w[i].l) dp[u]=inc(dp[u],dp[v]);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	for (int i=1;i<=m;i++){
		int u,v,l;
		scanf("%d%d%d",&u,&v,&l);
		add(u,v,l);add(v,u,l);
	}
	dijsktra(S,disS,dpS);dijsktra(T,disT,dpT);
	ll len=disS[T];
	int ans=mul(dpS[T],dpS[T]);
	for (int i=1;i<=n;i++){
		int k=mul(dpS[i],dpT[i]);k=mul(k,k);
		if (disS[i]*2==len&&disS[i]==disT[i]) ans=dec(ans,k);
	}
	for (int v=1;v<=n;v++)
	for (int i=head[v];i;i=nxt[i]){
		int u=w[i].t;
		if (disS[v]+w[i].l!=disS[u]||len!=disS[v]+disT[u]+w[i].l) continue;
		int k=mul(dpS[v],dpT[u]);k=mul(k,k);
		if (disS[v]*2<len&&disS[u]*2>len) ans=dec(ans,k);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17520
#include <iostream>
#include <algorithm>
int main(){
    long long N,A,B;
    std::cin >>N>>A>>B;
    //計算
    if(A!=0){
        long long  shou,amari,res;
        shou = N/(A+B);
        amari = N%(A+B);
        res = shou*A+std::min(A,amari);
        //出力
        std::cout<<res;
    }else{
        std::cout<<0;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)

Sum = sum(T)
for i in range(M):
    print(Sum - T[P[i] - 1] + X[i])


Measured memory_bytes: 8904
n,m,x = gets.chomp.split.map(&:to_i)
ca = []
n.times do |i|
  ca[i] = gets.chomp.split.map(&:to_i)
end

ans = 10**9
[0,1].repeated_permutation(n) do |ar|
  tmp = 0
  ri = Array.new(m, 0)
  n.times do |i|
    next if ar[i] == 0

    tmp += ca[i][0]
    m.times do |mm|
      ri[mm] += ca[i][mm+1]
    end
  end
  if ri.all? {|rr| rr >= x}
    ans = [ans, tmp].min
  end
end

if ans == 10**9
  p -1
else
  p ans
end


Measured memory_bytes: 14644
#include<cstdio>
#include<vector>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int MOD=1e9+7;
const double EPS=1e-12;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(double x){
    return fabs(x) < EPS ? 0 : x>0 ? 1 : -1 ;
}

int main(void){
    ll n;
    sf(n);
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    string ans="";
    while(n){
        ll t=n%(-2);
        n/=(-2);
        if(t<0) t+=2,n++;
        ans+='0'+t;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
n = int(input())
txy = [tuple(map(int, input().split(" "))) for i in range(n)]

for txy_i in txy:
	t, x, y = txy_i
	remain = t - x - y
	if not (0 <= remain and remain % 2 == 0):
		print("No")
		exit()
print("Yes")

Measured memory_bytes: 17408
#include <stdio.h>

int main()
{
  int i, j;
  long long int m = 100;
  long long int ans = 0;
  long long int x;
  scanf("%lld", &x);
  while(m < x){
    m *= 1.01;
    ans++;
  }
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>

using namespace std;

int N, K;
vector<int> A;

int main(){
    cin >> N >> K;
    A.resize(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }

    int res = 0;
    int right = 0;
    while(true){
        if(res == 0){
            right += K;
        }else{
            right += K-1;
        }
        res++;

        if(right >= N){
            break;
        }
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int passed,limit;
    cin >> limit;
    string names[limit];
    int scores[limit];
    int values[limit];
    for(passed=0;passed<limit;passed++){
        cin >> names[passed] >> scores[passed];
        values[passed] = passed+1;
    }
    for(int i=0;i<limit-1;i++){
        for(int j=i+1;j<limit;j++){
            if(names[i]==names[j]){
                if(scores[i]<scores[j]){
                    swap(names[i], names[j]);
                    swap(scores[i], scores[j]);
                    swap(values[i], values[j]);
                }
            }else if(names[i]>names[j]){
                swap(names[i], names[j]);
                swap(scores[i], scores[j]);
                swap(values[i], values[j]);
            }
        }
    }


    for(int i=0;i<limit;i++){
        cout << values[i] << endl;
    }
}


Measured memory_bytes: 256
function Main(input) {
	var idata = input.split(/\s/);
	console.log(Math.max(0,parseInt(idata[2])-parseInt(idata[0])+parseInt(idata[1])));
}    
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int c[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            c[i][j] = 1;
        }
    }
    for(int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        switch(a) {
            case 1:
                for(int j = 0; j < x; j++) {
                    for(int i = 0; i < h; i++) {
                        c[i][j] = 0;
                    }
                }
                break;
            case 2:
                for(int j = x; j < w; j++) {
                    for(int i = 0; i < h; i++) {
                        c[i][j] = 0;
                    }
                }
                break;
            case 3:
                for(int i = 0; i < y; i++) {
                    for(int j = 0; j < w; j++) {
                        c[i][j] = 0;
                    }
                }
                break;
            case 4:
                for(int i = y; i < h; i++) {
                    for(int j = 0; j < w; j++) {
                        c[i][j] = 0;
                    }
                }
                break;
        }
    }
    int res = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            res += c[i][j];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	long A, B, C;
	scanf("%ld%ld%ld", &A, &B, &C);
	long answer = 0;

	if (C <= A + B + 1) {
		answer = B + C;
	}
	else
	{
		answer = B + (A + B + 1);
	}

	printf("%ld", answer);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    string s; cin >> s;
    for (int i = 0; i < s.length(); i++) {
        cout << 'x';
    } cout << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  ll sum = 0;
  ll mv;
  repLRE(i, 1, n){
    sum += i;
    if(sum >= n) {
      mv = i;
      break;
    }
  }

  vll ans;
  rrepLRE(i, mv, 1){
    if(i <= n){
      ans.push_back(i);
      n -= i;
    }
  }
  Sort(ans);
  rep(i, (ll)ans.size()) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>

int main(){
  long long int N,A,B;
  scanf("%lld %lld %lld",&N,&A,&B);
  long long int Q=N/(A+B);
  long long int R=N%(A+B);
  printf("%lld\n",Q*A+(R<=A?R:A));
  return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main()
{
	int a, b;
	int n;
	cin >> n;
	string v;
	while(n > 0){
		cin >> v;
	sort(v.begin() , v.end());
	a = stoi(v);
	sort(v.begin() , v.end(), greater<int>());
	b = stoi(v);
	cout << b - a << endl;
		n--;
	}
	

	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll; typedef pair<int, int> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
bool isincluded(char x, string str) {
	bool f = 0;
	for (size_t i = 0; i < str.size(); i++) {
		if (str.at(i) == x)f = 1;
	}
	return f;
}

int main(void) {
	int a, b;
	cin >> a >> b;
	int mi=-1, ma = 1000000;
	rep(i, b) {
		int x, y;
		cin >> x >> y;
		mi = max(x, mi);
		ma = min(y, ma);
	}
	if (ma < a)
		cout << max(ma - mi + 1,0) << endl;
	else
		cout << max(a - mi + 1,0) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
	Scanner in = new Scanner(System.in);
	
	int n = in.nextInt();
	int a[] = new int[n];
	for(int i=0;i<n;i++){
	    a[i] = in.nextInt();
	}
	long ans = 0;
	for(int i=0;i<n;i++){
	    for(int j=i+1;j<n;j++){
		ans += (a[i] * a[j]);
	    }
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<iostream>
int main()
{
	int i = 1;
	int v = 1;
	std::cin >> v;
	for ( int i = 1; i <= v; i++ )
	{
		if ( i % 3 == 0 || i / 1000 == 3 || i % 1000 / 100 == 3 ||i % 1000 % 100 / 10 == 3 || i / 100 == 3 || i % 100 / 10 == 3 || i % 10 == 3 )
			{
			std::cout << ' ' << i;
		    }
	}
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"

using namespace std;

long long MOD = 1e9 + 7;

map<int, int> factorize(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i != 0) {
            continue;
        }

        int pow = 0;
        while (n % i == 0) {
            n /= i;
            ++pow;
        }
        ret.insert(make_pair(i, pow));
    }
    if (n != 1) {
        ret.insert(make_pair(n, 1));
    }
    return ret;
}

void Main() {
    int N;
    cin >> N;

    map<int, int> factorizedFactorial;
    for (int i = 1; i <= N; ++i) {
        map<int, int> decomp = factorize(i);
        for (auto x : decomp) {
            if (factorizedFactorial.count(x.first) == 0) {
                factorizedFactorial.insert(make_pair(x.first, x.second));
            }
            else {
                factorizedFactorial[x.first] += x.second;
            }
        }
    }

    long long ans = 1;
    for (auto x : factorizedFactorial) {
        ans *= ((long long)x.second + 1LL);
        ans = ans % MOD;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
    string w;
    string t;
    cin >> w;
    int i;
    for(i = 0;i < w.size(); i++) {
        if('A' <= w[i] && w[i] <= 'Z') w[i] += 'a' - 'A';
    }
    int o = 0;
    cin >> t;
    while(t != "END_OF_TEXT"){
        for(i = 0;i < t.size(); i++) {
            if('A' <= t[i] && t[i] <= 'Z') t[i] += 'a' - 'A';
        }
        if(w == t) o++;
        cin >> t;
    }
    cout << o << endl;
}


Measured memory_bytes: 3212
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        //int m = sc.nextInt();

        int a = sc.nextInt();
        int b = sc.nextInt();

        StringBuilder stb1 = new StringBuilder();
        for (int i = 0;i<b;++i) stb1.append(a);
        Long l1 =  Long.parseLong(stb1.toString());

        StringBuilder stb2 = new StringBuilder();
        for (int i = 0;i<a;++i) stb2.append(b);
        Long l2 =  Long.parseLong(stb2.toString());

        if (l1 >= l2) System.out.println(l1);
        else if (l2 >= l1) System.out.println(l2);
        //if (n >= m) System.out.println("Yes");
        //else System.out.println("No");

        sc.close();
    }
}

Measured memory_bytes: 19796
import heapq
n,m=map(int,raw_input().split())
l=list(map(int,raw_input().split()))

h=[]
for i in l:
  heapq.heappush(h,-i)

for j in range(m):
  m=-((-heapq.heappop(h))//2)
  heapq.heappush(h,m)
print -sum(h)

Measured memory_bytes: 12284
a, b, c, d = input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
def m():
    if -1000000000<=a<=b<=1000000000 and -1000000000<=c<=d<=1000000000:
        if a>=0 and d<=0:
            max=a*d
            print(max)
        elif a>=0 and c>=0:
            max=b*d
            print(max)
        elif b<=0 and c>=0:
            max=b*c
            print(max)
        elif b<=0 and d<=0:
            max=a*c
            print(max)
        elif a<=0 and b>=0 and c<=0 and d>=0:
            if a*c>=b*d:
                max=a*c
                print(max)
            else:
                max=b*d
                print(max)
        elif a>=0 and c<=0 and d>=0:
            max=b*d
            print(max)
        elif b<=0 and c<=0 and d>=0:
            max=a*c
            print(max)
        elif a<=0 and b>=0 and c>=0:
            max=b*d
            print(max)
        elif a<=0 and b>=0 and d<=0:
            max=a*c
            print(max)

m()

Measured memory_bytes: 9276
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
cond = []
for i in range(n):
    cond.append(iil())
cond = sorted(cond)
#print(cond)
cand = (cond[0][1]+1)+(cond[0][0]-1)
for i in range(1,n):
#    print(cond[i])
    if cond[i][0] - cond[i-1][0] >= cond[i-1][1]-cond[i][1]:
        cand = (cond[i][1]+1)+(cond[i][0]-1)
    else:
        cand -= (cond[i-1][1]-cond[i][1]) - (cond[i][0] - cond[i-1][0])
print(cand)

Measured memory_bytes: 28680
#include <stdio.h>

int main() {
    int T;
    char op[16];
    scanf("%d", &T);
    while (T--) {
        int out = 0, r = 0, p = 0;
        while (out < 3) {
            scanf("%s", op);
            if (op[0] == 'O') out++;
            else if (op[1] == 'O') { p += r+1; r = 0; }
            else if (op[1] == 'I') { r++; if (r == 4) r--, p++; }
        }
        printf("%d\n", p);
    }
    return 0;
}

Measured memory_bytes: 0
def main():
    n = input()
    S = map(int,raw_input().split())
    q = input()
    T = map(int,raw_input().split())
    m = 0
    for i in range(q):
        t = T.pop()
        for j in range(n):
            s = S[j]
            if t == s:
                m += 1
                break
                
    print m

if __name__ == "__main__":
    main()

Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;

int main() {
  string S;
  cin >> S;
  vector<int> base(S.size());
  int N = S.size();
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      base.at(i) = 1;
    }
    else {
      base.at(i) = base.at(i - 1) * 10 % 2019;
    }
  }
  vector<int> mod(S.size());
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      string s;
      s = s + S.at(N - 1);
      int ai = stoi(s);
      mod.at(i) = ai;
    }
    else {
      string s;
      s = s + S.at(N - i - 1);
      int ai = stoi(s);
      mod.at(i) = (mod.at(i - 1) + base.at(i) * ai) % 2019;
    }
  }
  int count = 0;
  for (int i = 0; i < 2019; i++) {
    int sum = 0;
    for (int j = 0; j < N; j++) {
      if (mod.at(j) == i) {
        sum += 1;
      }
    }
    if (i == 0) {
      count += sum * (sum - 1) / 2 + sum;
    }
    else {
      count += sum * (sum - 1) / 2;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 5164
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int a[3],k; cin>>a[0]>>a[1]>>a[2]>>k;
    sort(a,a+3);
    rep(i,k) a[2]*=2;
    cout<<a[0]+a[1]+a[2]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a+b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Solver
        {
            private readonly int[] colors;
            private readonly List<int>[] paths;
            private readonly HashSet<Tuple<int, int>> set;
            public Solver(int N, int[][] edges)
            {
                colors = new int[N];
                paths = new List<int>[N];
                for (int i = 0; i < N; ++i)
                {
                    paths[i] = new List<int>();
                }
                foreach (var edge in edges)
                {
                    int a = edge[0] - 1;
                    int b = edge[1] - 1;
                    paths[a].Add(b);
                    paths[b].Add(a);
                }
                set = new HashSet<Tuple<int, int>>();
            }
            private void Paint(int v, int d, int c)
            {
                var key = new Tuple<int, int>(v, d);
                if (!set.Contains(key))
                {
                    if (d == 0)
                    {
                        colors[v] = c;
                    }
                    else
                    {
                        Paint(v, d - 1, c);
                        foreach (int u in paths[v])
                        {
                            Paint(u, d - 1, c);
                        }
                    }
                    set.Add(key);
                }
            }
            public IEnumerable<int> Solve(int[][] queries)
            {
                foreach (var q in queries.Reverse())
                {
                    int v = q[0] - 1;
                    int d = q[1];
                    int c = q[2];
                    Paint(v, d, c);
                }
                return colors;
            }
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            var N = V[0];
            var M = V[1];
            var edges = new int[M][];
            for (int i = 0; i < M; ++i) { edges[i] = ReadInts(); }
            var Q = ReadInt();
            var queries = new int[Q][];
            for (int i = 0; i < Q; ++i) { queries[i] = ReadInts(); }
            foreach (int ans in new Solver(N, edges).Solve(queries))
            {
                Console.WriteLine(ans);
            }
        }
    }
}


Measured memory_bytes: 107040
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const double PI=3.14159265358979323846;

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;

  double mi = (60 * h) + m;
  double a_rad = (2 * PI) * (mi / 720);
  double b_rad = (2 * PI) * (mi / 60);
  double rad = a_rad - b_rad;
  // printf("a_rad: %lf\n", a_rad);
  // printf("b_rad: %lf\n", b_rad);
  // printf("rad: %lf\n", rad);

  double c = sqrt((a*a) + (b*b) - (2*a*b*cos(rad)));
  printf("%.10lf\n", c);
  return 0;
}

Measured memory_bytes: 4228
// Aviral Gupta
#include<bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
#define ll long long int
#define ld long double
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
int power(ll A, ll B) 
{ 
    // Base cases 
    if (A == 0) 
        return 0; 
    if (B == 0) 
        return 1; 
  
    // If B is even 
    ll y; 
    if (B % 2 == 0) { 
        y = power(A, B / 2); 
        y = (y * y) % mod; 
    } 
  
    // If B is odd 
    else { 
        y = A % mod; 
        y = (y * power(A, B - 1) % mod) % mod; 
    } 
  
    return (int)((y + mod) % mod); 
} 

int main()
{
  string s1,s2;
  cin>>s1>>s2;
  cout<<s2+s1<<endl;
}


Measured memory_bytes: 256