akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

// bool pairCompare(const P& firstElof, const P& secondElof){
//     return firstElof.first > secondElof.first;
// }

struct sort_pred {
    bool operator()(const P &left, const P &right) {
        return left.first < right.first;
    }
};

int main(int argc, char**argv){
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<pair<ll, ll> > cb;
    ll b, c;
    for (int i = 0; i < m; i++){
        cin >> b >> c;
        cb.push_back(make_pair(c, b));
    }

    sort(cb.begin(), cb.end(), sort_pred());

    vector<ll> x(n, 0);
    int cb_idx = m - 1;
    for (int i = n-1; i >= 0; i--){
        if (cb[cb_idx].second > 0){
            x[i] = cb[cb_idx].first;
            cb[cb_idx].second--;
        }else{
            cb_idx--;
            if (cb_idx < 0) break;
            x[i] = cb[cb_idx].first;
            cb[cb_idx].second--;
        }
        if (cb_idx < 0) break;
    }

    sort(a.begin(), a.end());

    int a_idx = n-1, x_idx = n-1;

    ll ans = 0;
    for (int i = 0; i < n; i++){
        if (a_idx < 0){
            ans += x[x_idx];
            x_idx--;
        }else if (x_idx < 0){
            ans += a[a_idx];
            a_idx--;
        }else {
            // main
            if (a[a_idx] > x[x_idx]) {
                ans += a[a_idx];
                a_idx--;
            } else {
                ans += x[x_idx];
                x_idx--;
            }
        }
    }
    cout << ans << endl;

    return 0;
}
















Measured memory_bytes: 3440
i,z=256,t[65536];main(j,k,l,x){for(;i<z;i++)for(j=i;j<z;j++)for(k=j;k<z;k++)for(l=k;l<z;l++){if((x=i*i+j*j+k*k+l*l)<z*z)t[x]++;}while(scanf("%d",&x),x)printf("%d\n",t[x]);return 0;}

Measured memory_bytes: 540
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] map = new int[100_002];
		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			map[ai]++;
		}
		
		int max = 0;
		for (int i = 1; i < map.length-1; i++) {
			int sum = map[i-1] + map[i] + map[i+1];
			max = Math.max(max, sum);
		}
		
		System.out.println(max);
	}
}


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

struct node{
	int num;
	node *parent,*left,*right;
};
node *root,*NIL;

void find(int a){
	node *x=root;
	while(x!=NIL){
		if(x->num < a) x=x->right;
		else if(x->num>a) x=x->left;
		else {
			printf("yes\n");
			return ;
		}
	}
	printf("no\n");
	return ;
}

void print_inorder(node *x){
	if(x==NIL) return ;
	print_inorder(x->left);
	printf(" %d",x->num);
	print_inorder(x->right);
	return ;
}

void print_preorder(node *x){
	if(x==NIL) return ;
	printf(" %d",x->num);
	print_preorder(x->left);
	print_preorder(x->right);
	return ;
}

void insert(int a){
	node *x=root,*y=NIL;
	node *z=new node();
	z->num=a;z->left=NIL;z->right=NIL;
	while(x!=NIL){
		y=x;
		if(z->num < x->num) x=x->left;
		else x=x->right;
	}
	z->parent=y;
	if(y==NIL) root=z;
	else {
		if(z->num < y->num) y->left=z;
		else y->right=z;
	}
	return ;
}

int main(){
	int n;
	cin>>n;
	string s;
	int a;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]=='i') cin>>a,insert(a);
		else if(s[0]=='p'){
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
		else cin>>a,find(a);
	}
	return 0;
}


Measured memory_bytes: 21972
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 

signed main(){
  fio;
    int n;
	cin>>n;
    for(int c=0;c<=n/100;c++)
	{
		int zan=n-c*100;
		if(0<=zan&&zan<=5*c)
		{
			cout<<"1";
			rr;
		}
	}
	cout<<"0";
  rr;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    cin >> H >> W;
    vector<string>s(H);
    rep(i,H) cin >> s[i];
    vector<int>v(100,0);
    for(auto a:s)for(auto itr:a)v[itr-'a']++;
    bool flag  = true;
    if(H%2 == 0 && W%2 == 0){
        for(auto num : v){
            if(num%4)flag = false;
        }
    } else if(!(H%2&&W%2)){
        if(W%2)swap(W, H);
        int cnt = 0;
        for(auto num : v){
            if(num%4 == 2)cnt++;
            else if(num%2)flag = false;
        }
        if(cnt > W/2) flag = false;
    } else {
        int cnt = 0,a = 0;
        for(auto  num :v){
            if(num%4 == 1) a++;
            else if(num%4 == 2)cnt++;
            else if(num%4)flag = false;
        }
        if((a != 1 || cnt >(H-1)/2+(W-1)/2))
            flag = false;
    }
    cout << (flag ? "Yes":"No") << endl;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<ll> A,B;
ll H,N;

//dp
vector<ll> table;
ll dp(ll i){
  if(i<=0) return 0;
  if(table[i]<INF) return table[i];
  
  ll ret=INF-1;
  rep(j,N) chmin(ret,dp(i-A[j])+B[j]);
  
  return table[i]=ret;
}

int main()
{
  cin>>H>>N;
  A=vector<ll>(N),B=vector<ll>(N); rep(i,N) cin>>A[i]>>B[i];
  
  //dp
  table=vector<ll>(H+1,INF);
  
  cout<<dp(H)<<endl;
  
  return 0;
}

Measured memory_bytes: 4764
N, M = map(int, input().split())
edges = [[] for _ in range(N)]

for _ in range(M):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

leafList = set([])
ans = 0
while True:
    isAll = True
    for v in range(N):
        if v in leafList:
            continue
        edgeCount = 0
        for to in edges[v]:
            if to in leafList:
                continue
            edgeCount += 1
        if edgeCount == 1:
            isAll = False
            ans += 1
            leafList.add(v)
    if isAll:
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
 
int dp[N][N];
string a,b;
 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,0,sizeof(dp));
 
	cin>>a>>b;
	int n = a.size();
	int m = b.size();
 
	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
		{
			if(i) dp[i][j] = max(dp[i][j],dp[i-1][j]);
 
			if(j) dp[i][j] = max(dp[i][j],dp[i][j-1]);
 
			if(i && j)
			{
				if(a[i-1] == b[j-1]) dp[i][j] = max(dp[i][j],dp[i-1][j-1] + 1);
				else dp[i][j] = max(dp[i][j],dp[i-1][j-1]);
			}
		}
 
	string ans = "";
	int i = n,j = m;
 
	while(i > 0 && j> 0)
	{
		int x = i - 1,y = j - 1;		
 
		if(a[x] == b[y]) i = x,j = y,ans += a[x];
		else
		{
			if(dp[x][j] < dp[i][y]) j = y;
			else i = x;
		}
	}
 
	reverse(ans.begin(),ans.end());
	cout<<ans;
}


Measured memory_bytes: 35456
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power( ll a, ll b, ll m )
{
	 if (b == 0)
		  return( 1 );
	 ll sol = power( a, b / 2, m );
	 sol = ( sol * sol ) % m;
	 if (b % 2 == 1)
		  sol = ( sol * a ) % m;
	 return( sol );
}

ll gcd( ll a, ll b )
{
	 if (b == 0)
		  return a;
	 else
	 {
		  return gcd( b, a % b );
	 }
}
void solve()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	for (int i = 0; i < n; i++)
	{
		cout << s[i] << t[i];
	}
}
int main()
{
	 int t = 1;
	 //cin >> t;
	 while (t--)
	 {
		  solve();
	 }
	 return 0;
}

Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
X.sort()
Y.sort()
if X[n-1] < Y[0] and x < y and x < X[n-1] and y > Y[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n=s.size(),c=0,cn=0;
  for(int i=0;i<n;i++){
    if(s[i]!=(i%2)+48){c++;}
  }
  for(int k=0;k<n;k++){
    if(s[k]!=((k+1)%2)+48){cn++;}
  }
  cout<<min(c,cn)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,h;
    cin>>a>>b>>h;
    
    cout << (a+b)*h/2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int n, a;
  cin >> n;
  int ans = 0;

  vector<int> vec(100000);
  for (int i = 0; i < n; i++){
    cin >> a;
    vec.at(a)++;
  }

  for(int i = 0; i <= 100000; i++){
      int match = vec[i - 1] + vec[i] + vec[i + 1];
      ans = max(ans, match);
  }
 
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iterator>
using namespace std ;
long long int power(long long int x,long long int y) ;
long long int power(long long int x,long long int y)
{ if(y==0)
   return 1 ;
   long long int z=power(x,y/2) ;
   if(y%2==0)
   return z*z ;
   else return x*z*z ; }


int main()
 { long long int t,n,m,count,i,j,x,a,b,sum,bal,e,o,y,k,z,temp,q,c,d,x1,x2,y1,y2 ;
    cin>>n>>m ;
    if(n>m)
    { n=n%m ;
        cout<<min(n,m-n) ;
        return 0 ;
    } else {
      cout<<min(n,m-n) ;
        return 0 ; }
 }


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
  int n,a[100],i,j,v,flag,count=0;

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

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      if(a[j]>a[j+1]){      
	v=a[j];
	a[j]=a[j+1];
	a[j+1]=v;
	count++;
      }
    }
  }
    for(i=0;i<n;i++){
      if(i<n-1){
	cout<<a[i]<<" ";
      }else{
	cout<<a[i]<<endl;
      }
    }
    cout<<count<<endl;

  return 0;
}

Measured memory_bytes: 3084
#include <stdio.h>

int main(void)
{
  int N, i;
  char S[200000];
  int count = 0;
  
  scanf("%d", &N);
  scanf("%s", S);

  for (i = 0; i < N; i++) {
    if (S[i] == S[i + 1])
      count++;
  }

  printf("%d\n", N - count);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int A, B;
int D[11][11];
int U[111][111];
int idx[111][111];
int cnt;
void add(int s, int t) {
    if (idx[s][t] == 0) idx[s][t] = cnt++;
}

void MAIN() {
    scanf("%d%d", &A, &B);
    REP (i, A) REP (j, B) scanf("%d", &D[i][j]);

    REP (i, A) REP (j, B) REP (s, 101) REP (t, 101) {
	amax(U[s][t], D[i][j] - s*(i+1) - t*(j+1));
    }

    cnt = 1;
    add(0, 0);
    REP (i, A) REP (j, B) {
	REP (s, 101) REP (t, 101) {
	    if (s*(i+1) + t*(j+1) + U[s][t] == D[i][j]) {
		add(s, t);
		goto BREAK;
	    }
	}

	puts("Impossible");
	return;
BREAK:
	;
    }

    for (int s=101; s--;) for (int t=101; t--;) if (idx[s][t]) {
	if (s == 0 && t == 0) continue;
	if (s && idx[s-1][t]) continue;
	if (t && idx[s][t-1]) continue;
	if (s < t) add(s, t-1);
	else add(s-1, t);
    }

    puts("Possible");
    VI from, to, cst;
    REP (s, 101) REP (t, 101) {
	if (idx[s][t]) {
	    if (idx[s][t+1]) {
		from.push_back(idx[s][t]);
		to.push_back(idx[s][t+1]);
		cst.push_back(-2);  // Y
	    }
	    if (idx[s+1][t]) {
		from.push_back(idx[s][t]);
		to.push_back(idx[s+1][t]);
		cst.push_back(-1);  // X
	    }
	    from.push_back(idx[s][t]);
	    to.push_back(cnt);
	    cst.push_back(U[s][t]);
	}
    }

    printf("%d %d\n", cnt, (int)from.size());
    REP (i, from.size()) {
	printf("%d %d ", from[i], to[i]);
	if (cst[i] == -2) puts("Y");
	else if (cst[i] == -1) puts("X");
	else printf("%d\n", cst[i]);
    }
    printf("1 %d\n", cnt);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
N = gets.to_i
P=gets.chomp.split(' ').map{|n| n.to_i}
count = 0
min = -1

0.upto(P.size - 1) do |i|
  if min == -1 || min >= P[i]
    min = P[i]
    count = count + 1
  end
end

puts count

Measured memory_bytes: 16516
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,pair<int,int> > P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXH=500;
const int MAXW=500;
const ll INF=1e9;

int main(){
    int N,M,R;
    cin>>N>>M>>R;
    vector<vector<int> > c(N,vector<int>(N,INF));
    vector<int> r(R);
    for(int i=0;i<R;i++){
        cin>>r[i];
        r[i]--;
    }
    sort(r.begin(),r.end());
    for(int i=0;i<M;i++){
        int a,b,cst;
        cin>>a>>b>>cst;
        a--;b--;
        c[a][b]=cst;
        c[b][a]=cst;
    }
    for(int i=0;i<N;i++) c[i][i]=0;
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    int ans=INF;
    do{
        int tmp=0;
        for(int i=0;i<R-1;i++){
            tmp+=c[r[i]][r[i+1]];
        }
        ans=min(ans,tmp);
    }while(next_permutation(r.begin(),r.end()));
    cout<<ans<<endl;
    return 0;
}

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

const int N=2e5+100;
int mod=1e9+7;
typedef long long ll;
ll a[N],b[N];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll n,m,k;cin>>n>>m>>k;
    ll x;
    for(int i=1;i<=n;i++){
        cin>>x;
        a[i]=a[i-1]+x;
    }
    for(int i=1;i<=m;i++){
        cin>>x;
        b[i]=b[i-1]+x;
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ll kk=k-a[i];
     //   cout<<kk<<endl;
       if(kk<0) break;
      int j=lower_bound(b+1,b+1+m,kk)-b;
      if(b[j]!=kk)
       j--;
     // cout<<j<<endl;
        ans=max(ans,1ll*(i+j));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6716
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a = INT()
b = INT()
c = INT()

grid = list2d(3, 3, 0)
grid[0][0] = a
grid[0][1] = b
grid[1][1] = c

for i in range(301):
    grid[0][2] = i - a - b
    grid[2][2] = i - a - c
    grid[2][1] = i - b - c
    grid[1][2] = i - grid[0][2] - grid[2][2]
    grid[1][0] = i - grid[1][1] - grid[1][2]
    grid[2][0] = i - grid[0][0] - grid[1][0]
    if grid[2][0] == i - grid[1][1] - grid[0][2] \
            and grid[2][0] == i - grid[2][1] - grid[2][2]:
        for i in range(3):
            print(*grid[i])
        exit()


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < 12; i++){
    cout << s[i];
    if(i == 3)cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
import sys
N=int(input())
task_lst = sorted([list(map(int,input().split())) for i in range(N)], key=lambda x:x[1])
now_task_time=0
for i in task_lst:
    now_task_time += i[0]
    if now_task_time > i[1]:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 55252
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, m; cin >> n >> m;
  vector<string> a(n), b(m);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) cin >> b[i];
  for(int i = 0; i <= n - m; i++){
    for(int j = 0; j <= n - m; j++){
      //cout << "i : " << i << " j : " << j << endl;
      int x = 0, sum = 0;
      for(int k = i; k < i + m; k++){
        int y = 0;
        for(int l = j; l < j + m; l++){
          //cout << a[k][l] << " " << b[x][y] << endl;
          if(a[k][l] == b[x][y]) sum++;
          y++;
        }
        x++;
      }
      //cout << sum << endl;
      if(sum == m * m){
        cout << "Yes\n";
        return;
      }
    }
  }
  cout << "No\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
//
// Created by 李青坪 on 2018/10/3.
//
#include "cstdio"
#include "vector"
#include "stack"
#include "iostream"

using namespace std;

int main(){
    stack<int > location;
    stack<pair<int, int > > square;
    int i = 0;
//    char ch ;
//    while (cin >> ch){
//        if (ch == '\\'){
//            location.push(i);
//        }
//        else if (ch == '/' && !location.empty()){
//            int lastLoc = location.top();
//            int s = i - lastLoc;
//            location.pop();
//            while (!square.empty() && lastLoc < square.top().first){
//                s += square.top().second;
//                square.pop();
//            }
//            square.push(make_pair(lastLoc, s));
//        }
//        ++i;
//    }
    char chr[20001];
    scanf("%s", chr);
    while (chr[i] == '\\' || chr[i] =='/' || chr[i] == '_'){
        if (chr[i] =='\\'){
            location.push(i);
        }
        else if (chr[i] == '/' && !location.empty()){
            int lastLoc = location.top();
            location.pop();
            int s = i - lastLoc;
            while (!square.empty() && lastLoc < square.top().first){
                s += square.top().second;
                square.pop();
            }
            square.push(make_pair(lastLoc, s));
        }
        ++i;
    }
    int sum = 0, count = 0;
    vector<int > squ;
    while (!square.empty()){
        sum += square.top().second;
        squ.push_back(square.top().second);
        square.pop();
        ++count;
    }
    cout << sum << endl << count;
    while (!squ.empty()){
        int s = squ.back();
        squ.pop_back();
        cout << ' ' << s;
    }
    cout << endl;
    return 0;
}

/*

\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\

 */



Measured memory_bytes: 3284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String in = reader.readLine();
    String[] params = in.split(" ");
    int n = Integer.parseInt(params[0]);
    int m = Integer.parseInt(params[1]);
    double div = 1.0 / (4.0 * m);
    String inVotes = reader.readLine();
    int[] voteArray = Arrays.stream(inVotes.split(" "))
        .mapToInt(Integer::valueOf).toArray();
    int sum = Arrays.stream(voteArray).sum();
    double min = sum * div;
    long toVote = Arrays.stream(voteArray)
        .filter(i -> i >= min)
        .count();
    if (toVote < m) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 26708
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    a1 = a[0::2]
    a2 = a[1::2]
    r = []
    if n % 2 == 0:
        r = a2[::-1] + a1
    else:
        r = a1[::-1] + a2
    return ' '.join(map(str, r))


print(main())





Measured memory_bytes: 33364
import java.math.BigDecimal;
import java.util.*;

public class Main {

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

    public static void main(String[] args) {
        int N = sc.nextInt();
        long K = sc.nextLong();

        TreeMap<Integer, Long> map = new TreeMap<>();
        for (int i = 0; i < N; i++) {
            int value = sc.nextInt();
            int count = sc.nextInt();
            map.put(value, map.containsKey(value) ? map.get(value) + count : count);
        }

        long sum = 0;
        for (Map.Entry<Integer, Long> entry: map.entrySet()) {
            if (sum < K && K <= sum + entry.getValue()) {
                System.out.println(entry.getKey());
            }
            sum += entry.getValue();
        }
    }
}

Measured memory_bytes: 96772
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull base=1000000007;
string i2b(int n){
  string buf;
  for(int i=5;i>=0;i--){
    if(n>>i&1) buf+="1";
    else buf+="0";
  }
  return buf;
}
int s2i(char c){
  if('A'<=c&&c<='Z') return (c-'A');
  if('a'<=c&&c<='z') return (c-'a'+26);
  if('0'<=c&&c<='9') return (c-'0'+52);
  if(c=='+') return 62;
  if(c=='/') return 63;
  return -1;
}
int main(){
  int w,h,p;
  while(cin >> w >> h >> p,w||h||p){
    string st[1005];
    int i,j,k;
    for(i=0;i<h;i++) cin >> st[i];
    string wa[105];
    for(i=0;i<p;i++)cin >> wa[i];
    
    string co[1005];
    for(i=0;i<h;i++){
      for(j=0;j<st[i].size();j++) co[i]+=i2b(s2i(st[i][j]));
      co[i]=co[i].substr(0,w);
      //cout << co[i] <<  endl;
    }
    
    ull ha[1005][1005]={{}};
    ull xx;
    for(i=0;i<h;i++){
      xx=1;
      for(k=p-1;k>=0;k--){
	if(co[i][k]=='1') 
	  ha[i][0]+=xx;
	if(k!=0) xx*=base;
      }
      for(j=1;j+p<=w;j++){
	ha[i][j]=(ha[i][j-1]-(co[i][j-1]-'0')*xx)*base+(co[i][j+p-1]-'0');
      }
    }
    //cout << "x" << endl;

    string wal[105][8];
    for(i=0;i<p;i++){
      for(j=0;j<wa[i].size();j++){
	wal[i][0]+=i2b(s2i(wa[i][j]));
      }
      wal[i][0]=wal[i][0].substr(0,p);
    }
    
    for(k=1;k<4;k++){
      for(i=0;i<p;i++){
	for(j=p-1;j>=0;j--){
	  wal[i][k]+=wal[j][k-1][i];
	}
      }
    }
    
    for(k=0;k<4;k++){
      for(i=0;i<p;i++){
	for(j=p-1;j>=0;j--){
	  wal[i][k+4]+=wal[i][k][j];
	}
      }
    }
    bool same[8]={};
    for(i=0;i<8;i++){
      for(j=i+1;j<8;j++){
	if(same[i]) break;
	same[i] = true;
	for(k=0;k<p;k++){
	  if(wal[k][i]!=wal[k][j]) same[i]=false;
	}
      }
    }
    
    //cout << "y" << endl;

    ull has[105][8]={{}};
    int x,y;
    ull ans=0;
    for(k=0;k<8;k++){
      if(same[k]) continue;
      //cout << endl;
      //for(i=0;i<p;i++) cout << wal[i][k] << endl;
      for(i=0;i<p;i++){
	xx=1;
	for(j=p-1;j>=0;j--){
	  if(wal[i][k][j]=='1') 
	    has[i][k]+=xx;
	  xx*=base;
	}
	//cout << has[i][k] << endl;
      }
      //cout << k << endl;
      for(i=0;i+p<=h;i++){
	for(j=0;j+p<=w;j++){
	  //cout << ans <<":"<<i <<"/"<<j<<endl;
	  //cout << ha[i][j] << " " << has[i][k] << endl;
	  bool f=true;
	  for(y=0;y<p;y++){
	    //cout << ha[i+y][j] << " " << has[i+y][k] << endl;    
	    if(ha[i+y][j]!=has[y][k]) {
	      //cout << ha[i+y][j] << " " << has[y][k] << endl;   
	      //cout << ans <<":"<<i+y <<"/"<<j<<endl;
	      f=false;
	      break;
	    }
	  }
	  /*
	  for(x=0;x<p;x++){ 
	    for(y=0;y<p;y++){
	      if(co[i+y][j+x]!=wal[y][k][x]){
		f=false;
		break;
	      }
	    } 
	    if(!f) break;
	  }
	  */
	  if(f) {
	    ans++;
	    
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10592
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll a,b,k,i;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b>>k;
    rep(i,0,k){
        if(i & 1){
            if(b & 1)
                b -= 1;
            b /= 2;
            a += b;
        }
        else{
            if(a & 1)
                a -= 1;
            a /= 2;
            b += a;
        }
    }
    cout<<a<<" "<<b;
    return 0;
}

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

int n,a[MAX];

int main(){
    int m=0;

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

    cin>>n;
    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++){
            m=max(m,abs(a[i]-a[j]));
        }
    }
    cout<<m<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back

int main()
{
    ll n, q, m, a = 2, k, x, i, tc, j, ans = 1, l, sum = 0;
    cin >> n;
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            for(k = 1; k <= n; k++){
                sum += __gcd(__gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream> //cout
#include <cstring> //c
#include <vector> //vector
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main() {
    string S;
    cin >> S;

    int num = atoi(S.c_str());
    num = num % 10;

    if(num == 2 | num == 4 | num == 5 | num == 7 | num == 9){
        cout << "hon" << endl;
    }
    else if(num == 0 | num == 1 | num == 6 | num == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <cstdio>

using namespace std;

typedef struct matrix{
  int row;
  int column;
  struct matrix *next;
  struct matrix *back; 
}Matrix;

Matrix *push_back(Matrix *begin, int row, int column) {
  Matrix *p = (Matrix*)malloc(sizeof(Matrix));
  p->row = row;
  p->column = column;
  p->next = NULL;
  p->back = NULL;
  if(begin == NULL) return p;
  Matrix *p2 = begin;
  while(p2->next != NULL) p2 = p2->next;
  p2->next = p;
  p->back = p2;
  return begin;
}

Matrix *product_count(Matrix *x, int type, int *count) {
  Matrix *a,*b;
  if(type == 0) {
    a = x->back;
    b = x;
  }
  else {
    a = x;
    b = a->next;
  }
  *count = 0;
  if(a == NULL || b == NULL) return x;
  *count += a->row * a->column * b->column;
  Matrix *c = (Matrix*)malloc(sizeof(Matrix));
  c->row = a->row;
  c->column = b->column;
  c->next = b->next;
  c->back = a->back;
  if(a->back != NULL) a->back->next = c;
  if(b->next != NULL) b->next->back = c;
  free(a);
  free(b);
  return c;
}

Matrix *product_atob(Matrix *a, Matrix *b, int type,  long *sum) {
  int count;
  if(a == b) return a;
  if(type == 0) {
    while(a->next != b) {
      b = product_count(b, 0, &count);
      *sum += count;
    }
  }
  else {
   while(a->next != b) {
      a = product_count(a, 1, &count);
      *sum += count;
    }
  }
  a = product_count(a, 1, &count);
  *sum += count;
  return a;
}

Matrix *solve(Matrix *x, long *sum) {
  if(x->next == NULL) return x;
  Matrix *min = x->next, *p = x;
  while (p->next != NULL) {
    p = p->next;
    if(min->column > p->column) min = p;
  }
  if(min->column < x->row) {
    x = product_atob(x, min, 0, sum);
    if(x->next != NULL) {
      p = solve(x->next,sum);
      x = product_atob(x,p,0,sum);
    }
  }
  else if(min->column > x->row) {
    if(x->back == NULL || x->back->row > x->row) {
      while(min->next != NULL) min = min->next;
      x = product_atob(x, min, 1, sum);
    }
    else{
      x = product_atob(x,min,1,sum);
    }
  }
  else {
    Matrix *min2 = x->next;
    p = x->next;
    while (p != min) {
      if(min2->column > min->column && min2->column > p->column) min2 = p;
      p = p->next;
    }
    x = product_atob(x, min2, 1, sum);
    product_atob(x->next, min, 0, sum);
    x = product_atob(x, x->next, 1, sum);
    if(x->next != NULL) {
      p = solve(x->next,sum);
      x = product_atob(x,p,0,sum);
    }
    p = solve(x,sum);
  }
  return x;
}

int main()
{
  int i,n,r,c;
  Matrix *begin = NULL;
  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d %d",&r,&c);
    begin = push_back(begin,r,c);

  }
  long sum = 0;
  begin = solve(begin, &sum);
  cout << sum << endl;
  
  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pii;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define sz(a) ll(a.size())
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front 
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define debug(x) cout << '>' << #x << ':' << x << " ";
#define nl '\n'
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define int long long int

const int N = 1e6+10;
vector<int> sieve(N, 0);
void preprocess(){
    for(int i = 1; i < N; i++){
        sieve[i] = i;
    }
    for(int i = 2; i < N; i++){
        if (sieve[i]!=i)
        {
            continue;
        }
        for(int j = i * i; j < N;j+=i){
            sieve[j] = i;
        }
    }
}

void solve(){
    preprocess();
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++){
        int x = i;
        // set<int> fac;
        map<int, int> freq;
        while(x != sieve[x]){
            // fac.insert(sieve[x]);
            freq[sieve[x]]++;
            x/=sieve[x];
        }
        if(x > 1){
            freq[sieve[x]]++;
            // fac.insert(x);
        }
        int cur = 1;
        for(auto i: freq){
            cur *= (i.second+1);
        }
        ans += cur;
    }
    cout << ans << nl;
}
main()
{
    IO;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
	int T = 1;
    // cin >> T;
    fo(c, 1, T){
        solve();
        // cout<<"Case #"<<c<<": ";
    }
    return 0;
}

Measured memory_bytes: 10980
#include<bits/stdc++.h>
using namespace std ; 
  
int main () { 
  int x,y;
  cin>>x>>y;
  for(int i=1;i<=x;i++){
      if(i*2+(x-i)*4==y or i*4+(x-i)*2==y){
          cout<<"Yes";
          return 0;
      }
      
  }cout<<"No";
  return 0;
}





Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cmath>
#include <type_traits>

template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v){
	os << "{ ";
	for( auto itr=v.begin(); itr!=v.end(); itr++ ){
		os << *itr << " ";
	}
	os << "}";
	return os;
}
int main(void){
	using namespace std;

	vector<pair<unsigned int, unsigned int>> input;
	map<unsigned int, map<unsigned int, unsigned int>> N;

	{
		unsigned int n,s;
		while(cin >> n >> s){
			input.push_back( make_pair(n,s) );
			N[n];
		}
	}

	for(auto itr=N.begin(); itr!=N.end(); itr++){
		unsigned int n = itr->first;

		vector<bool> permTable(10);
		fill(permTable.begin()+n, permTable.end(), true);
		do {
			vector<unsigned int> tmp;
			tmp.reserve(n);
			for (unsigned int i = 0; i < 10; ++i) {
				if (!permTable[i]) {
					tmp.push_back(i);
				}
			}
			do{
				unsigned int sum = 0;
				for(int i=0; i<n; i++){
					sum += (i+1)*tmp[i];
				}
				itr->second[sum]++;
			}while(std::next_permutation(tmp.begin(), tmp.end()));

		} while (std::next_permutation(permTable.begin(), permTable.end()));
	}

	for (auto itr=input.begin(); itr!=input.end(); itr++){
		cout << N[itr->first][itr->second] << endl;
	}
}

Measured memory_bytes: 1236
from collections import deque
n = int(input())
num753 = set()
q = deque([3,5,7])
while q:
    x = q.pop()
    if x <= 10**9:
        num753.add(x)
        q.append(x*10+3)
        q.append(x*10+5)
        q.append(x*10+7)
count = 0
for i in num753:
    if i <= n:
        lst = list(str(i))
        if "3" in lst and "5" in lst and "7" in lst:
            count += 1
print(count)

Measured memory_bytes: 43624
#include<bits/stdc++.h>
 
using namespace std;
 
 
 
int main() {
	
	ios_base :: sync_with_stdio(0); cin.tie(NULL);
 
	string s;
	cin >> s;
 
	bool A = false, B = false;
	for(int i = 0; i < s.length(); ++i) {
		if (s[i] == 'A') A = true;
		else if(s[i] == 'B') B = true;
	}
 
	if (A && B) cout << "Yes" << '\n';
	else cout << "No" << '\n';
 
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>

#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

int A,B;
int x[111];
ll coudp[111][111][5555];
string divide[4] = { "dream","dreamer","erase","eraser" };
int main()
{	
		string data;
		cin >> data;

		data.at(5) = ' ';
		data.at(13) = ' ';

		cout << data << endl;
		
		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B){

}

int main(){
    long long N;
    scanf("%lld",&N);
    vector<pair<ll,ll>> a(N);
    for(int i = 0 ; i < N ; i++){
        ll x,y;
        cin >> x >>y;
        a[i] = make_pair(x,y);
    }
    RSORT(a);

    cout << a[0].first+a[0].second<<endl;
    return 0;
}


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

int N, M, Q;
vector<int> a, b, c, d;

int score(vector<int> &A) {
  int ans = 0;
  rep(i, Q) {
    if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) ans += d.at(i);
  }
  return ans;
}

int dfs(vector<int> &A) {
  // Aが完成していたら得点をチェック
  if ((int)A.size() == N) return score(A);

  // 数列を作成
  int res = 0;
  int prev = (A.empty() ? 1 : A.back());
  for (int i = prev; i <= M; i++) {
    A.push_back(i);
    res = max(res, dfs(A));
    A.pop_back();
  }
  return res;
}

int main() {
  cin >> N >> M >> Q;
  a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
  rep(i, Q) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--; b.at(i)--;
  }

  vector<int> A;
  cout << dfs(A) << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a;
  cin >> a;
  if(a == 'A')
    cout << 'T' << endl;
  if(a == 'T')
    cout << 'A' << endl;
  if(a == 'C')
    cout << 'G' << endl;
  if(a == 'G')
    cout << 'C' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll a,b,n,last=-9999999999999999;
 cin>>a>>b>>n;
 ll l=1,r=n;
 last=0;
 while(l<=r)
 {
     ll mid=l+(r-l)/2;
     //cout<<last<<" "<<l<<" "<<r<<endl;
     if((a*mid)/b-a*(mid/b)>=last)
     {
         last=(a*mid)/b-a*(mid/b);
         l=mid+1;
     }
     else
        r=mid-1;
 }
 cout<<last<<endl;

return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
#include <list>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> vi;

int main(void){
	int d, n, m;
	cin >> n >> m >> d;
	m--;
	double x = 2 * (n - d);
	if(d == 0) x = n;
	printf("%.12lf\n", (x * m) / n / n);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

template <int N>
struct Pow5
{
    ll ary[N];
    constexpr Pow5() : ary()
    {
        for (ll i = 0; i < N; i++)
        {
            ary[i] = i * i * i * i * i;
        }
    }
};

int main()
{
    ll X;
    scanf("%lld", &X);

    constexpr auto pow5 = Pow5<1000>();
    for (ll a = 1; a < 1000; a++)
    {
        for (ll b = -1000; b < 1000; b++)
        {
            ll ap5 = a < 0 ? -pow5.ary[-a] : pow5.ary[a];
            ll bp5 = b < 0 ? -pow5.ary[-b] : pow5.ary[b];
            if (ap5 - bp5 == X)
            {
                printf("%lld %lld\n", a, b);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3808