akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#include<bitset>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    bitset<1000> person;
    int n, m;
    while(cin >> n >> m, m){
        rep(i,n){
            person[i + 1] = 1;
        }
        int i = 0;
        while(person.any()){
            rep(j,m){
                i++;
                if(i > n){
                    i-= n;
                }
                if(person[i] == 0){
                    j--;
                }
            }
            person[i] = 0;
        }
        cout << i << endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
    int n, i, min=1000000, max=-1000000;
    long a, sum=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%ld", &a);
        sum+=a;
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
typedef pair<int64_t ,int64_t> P;

int main(){
    int n,m;
    cin >> n >> m;

    priority_queue<P ,vector<P> ,greater<P>> que;

    for(int i=0;i<n;i++){
        int64_t a,b;
        cin >> a >> b;
        que.push(P (a ,b));
    }

    int64_t sumc = 0 ,sumn = 0;

    while(true){
        P p = que.top(); que.pop();
        int64_t cost = p.first;
        int64_t num = p.second;
        if(sumn + num >= m){
            sumc += (m - sumn)*cost;
            break;
        }

        sumc += cost * num;
        sumn += num;
    }

    cout << sumc << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int main() {
	int ans1 = 0, ans2 = 0, ans3 = 0, a, b, c, d;
	char op1, op2, op3;
	int A;
	cin >> A;
	d = A % 10;
	A = A / 10;
	c = A % 10;
	A = A / 10;
	b = A % 10;
	A = A / 10;
	a = A % 10;

	REP(i, 2) {
		ans1 = 0;
		if (i == 0) {
			ans1 = a + b;
			op1 = '+';
		}
		else {
			ans1 = a - b;
			op1 = '-';
		}
		REP(j, 2) {
			if (j == 0) {
				ans2 = ans1 + c;
					op2 = '+';
			}
			else {
				ans2 =ans1-c;
				op2 = '-';
			}
			REP(k, 2) {
				if (k == 0) {
					ans3 = ans2 + d;
					op3 = '+';
				}
				else {
					ans3 = ans2 - d;
					op3 = '-';
				}
				if (ans3 == 7) {
					cout << a << op1 << b << op2 << c << op3 << d << "=7";
					return 0;
				}
			}
		}
	}
}



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

#define int  long long int

signed main() {
  while(1) {
    int a, m[3] = {};
    for(int i = 0; i < 3; i++) {
      cin >> a >> m[i];
      if(a != 0 || m[i] != 0) {
	int x = 1;
	int cnt = 0;
	do {
	  x = a*x%m[i];
	  cnt++;
	}
	while(x != 1);
	m[i] = cnt;
	if(i){
	  int l = max(m[i], m[i-1]), r = min(m[i], m[i-1]);
	  while(l % r != 0) {
	    int temp = r;
	    r = l % r;
	    l = temp;
	  }
	  m[i] = m[i-1]/r*m[i];
	}
      }
    }
    if(m[2]) cout << m[2] << endl;
    else break;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int main() {
	int n, y, k10, k5, k1;

	scanf("%d%d", &n, &y), y /= 1000;
	for (k10 = 0; k10 <= n; k10++)
		for (k5 = 0; k10 + k5 <= n; k5++) {
			k1 = n - k10 - k5;
			if (k10 * 10 + k5 * 5 + k1 == y) {
				printf("%d %d %d\n", k10, k5, k1);
				return 0;
			}
		}
	printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vp a;

int main(){
	cin>>n;
	a=vp(n);
	for(int i=0;i<n;i++) cin>>a[i].first;
	for(int i=0;i<n;i++) cin>>a[i].second;
	sort(a.begin(),a.end());
	vp c(n);
	for(int i=0;i<n;i++) c[i]={a[i].second,i};
	sort(c.begin(),c.end());
	vi b(n);
	bool B=1;
	for(int i=0;i<n;i++){
		if(c[i].first<a[i].first) B=0;
		b[c[i].second]=i;
	}
	int x=0,t=0;
	do{
		x=b[x];
		t++;
	}while(x);
	if(t==n){
		B=0;
		for(int i=1;i<n;i++) if(c[i-1].first>=a[i].first) B=1;
	}
	cout<<(B?"Yes":"No")<<endl;
}

Measured memory_bytes: 2176
#include <stdio.h>

#define endl '\n'

int main()
{
    int n, i;
    scanf("%d", &n);
    int a[n], b[n];

    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        b[a[i]-1]=i+1;
    }

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

    return 0;
}

Measured memory_bytes: 2464
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	
	static int[][] map;
	
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		
		while(true){
			map = new int[12][];
			for(int i = 0; i < 12; i++)
				map[i] = app.toIntegerArrays(reader.readLine().toCharArray());
			
			int count = 0;
			for(int i = 0; i < 12; i++){
				for(int j = 0; j < 12; j++){
					if(map[i][j] == 1){
						app.check(i, j);
						count++;
					}
				}
			}
			System.out.println(count);
			
			if(reader.readLine() == null) break;
		}
		isr.close();
		reader.close();
	}
	
	public void check(int x, int y){
		if(x > 11 || y > 11 || x < 0 || y < 0 || map[x][y] == 0) return;
		map[x][y] = 0;
		check(x + 1, y);
		check(x - 1, y);
		check(x, y + 1);
		check(x, y - 1);
	}
	public int[] toIntegerArrays(char[] array){
		int[] result = new int[12];
		for(int i = 0; i < 12; i++) result[i] = Integer.parseInt(String.valueOf(array[i]));
		return result;
	}
	
}

Measured memory_bytes: 24148
n,m,c=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
count=0
for a in range(n):
    alist=[int(x) for x in input().split()]
    sum=0
    for i in range(m):
        sum+=b[i]*alist[i]
    if (sum+c)>0:
        count+=1
print(count)


Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<=n;i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);

#define INF 1010000000

int hav[1001];
int get[1001];
int point[1001];
pair<int,int> bou[100001];

int main(){
	while(1){
		int n,m,h,k;
		scanf("%d%d%d%d",&n,&m,&h,&k);
		
		if(n==0)break;
		
		reps(i,n){
			sint(point[i]);
		}
		
		rep(i,m){
			int a,b;
			sintt(a,b);
			bou[i]=make_pair(b,a);
		}
		
		sort(bou,bou+m);
		
		rep(i,n+1)hav[i]=i;
		
		rep(i,m){
			int a=bou[i].second;
			swap(hav[a],hav[a+1]);
		}
		
		reps(i,n){
			get[hav[i]]=point[i];
		}
		
		
		
		rep(i,n+1)hav[i]=i;
		
		int mini[1001];
		rep(i,n+1)mini[i]=get[i];
		rep(i,m){
			int a=bou[i].second;
			if(hav[a+1]>k){
				mini[hav[a]]=min(mini[hav[a]],min(get[hav[a]],get[hav[a+1]]));
			}
			swap(hav[a],hav[a+1]);
			
			if(hav[a+1]>k){
				mini[hav[a]]=min(mini[hav[a]],min(get[hav[a]],get[hav[a+1]]));
			}
		}
		
		int ans=0;
		int maxs=0;
		int maxp=0;
		reps(i,k){
			ans+=get[i];
			if(maxs<get[i]-mini[i]){
				maxs=get[i]-mini[i];
				maxp=i;
			}
		}
		
		//printf("%d %d %d\n",ans,maxs,maxp);
		
		ans-=maxs;
		/*
		reps(i,n){
			printf("%d ",mini[i]);
		}puts("");
		*/
		printf("%d\n",ans);
	}
}

/*
4 1 7 2
20
80
100
50
1 1

*/

Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w;
vector<pair<pair<int,int>,int> >PP;

bool comp(const pair<pair<int,int>,int> & P1,const pair<pair<int,int>,int> & P2){
	if(P1.second!=P2.second){
		return P1.second<P2.second;
	}else{
		return P1.first.first<P2.first.first;
	}
}

void v_calc(){
	for(int i=1;i<=149;i++){
		for(int j=i+1;j<=150;j++){
			pair<pair<int,int>,int> temp=make_pair(make_pair(i,j),i*i+j*j);
			PP.push_back(temp);
		}
	}
	sort(PP.begin(),PP.end(),comp);
}

int main(){
	
	v_calc();
	while(1){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)break;
		for(int i=0;i<PP.size()-1;i++){
			if(PP[i].first.first==h&&PP[i].first.second==w){
				printf("%d %d\n",PP[i+1].first.first,PP[i+1].first.second);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3292
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int max[3];
    max[0] = 0;
    max[1] = 0;
    max[2] = 0;
    int n = 0;
back:
    while(~scanf("%d",&n)){
     if( n >= max[0]){
         max[2] = max[1];
         max[1] = max[0];
         max[0] = n;
         goto back;
     } else if ( n >= max[1]){
             max[2] = max[1];
             max[1] = n;
             goto back;
         } else if ( n >= max[2]){
             max[2] = n;
             goto back;
         }
     }
     printf("%d\n%d\n%d\n",max[0],max[1],max[2]);
     return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>

int sum(int a){
  if(a==0) return 0;
  else{
    return a%10+sum(a/10);
  }
}
int main(){
  int n,i,s,min=100000;
  scanf("%d",&n);
  for(i=1;i<=n/2;i++){
    s=sum(i)+sum(n-i);
    if(min>s) min=s;
  }
  printf("%d",min);
}

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

int main()
{
	int H, W;
	do
	{
		cin >> H >> W;
		for (int x = 0; x < H; x++)
		{
			for (int y = 0; y < W; y++)
			{
				if (y == W - 1) cout << "#" << endl;
				else cout << "#";
				if (y == W - 1 && x == H - 1)
				{

					cout << endl;
				}
			}
		}
	} while (H != 0 || W != 0);
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  stack<char> stk;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size()){
    char now = s.at(i);
    if(stk.empty() == false && stk.top() != now){
      stk.pop();
      ans += 2;
    }else{
      stk.push(now);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,k,c;
string s;
int prerk[200100],aftrk[400100];
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k>>c>>s;
	s="A"+s+"C";
	int t=1;
	for(int i=1;i<=k;i++){
		while(s[t]=='x') t++;
		prerk[t]=i;
		t+=(c+1);
	}
	for(int i=n;i>=1;i--){
		aftrk[i]=aftrk[i+1];
		if(s[i]=='o')
			aftrk[i]=max(aftrk[i],aftrk[i+c+1]+1);
	}
	for(int i=1;i<=n;i++){
		if(prerk[i]==0) continue;
		if(aftrk[i+1]+prerk[i]-1<k){
			cout<<i<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    cout << "ABC" << N << endl;
}


Measured memory_bytes: 256
N = int(input())
A_raw = [0] * N
for i in range(N):
    A_raw[i] = (int(input()), i)
A_raw.sort(key=lambda x: x[0])
A = [0] * N
for i in range(N):
    A[A_raw[i][1]] = i

ans = 0
for i in range(N):
    if i % 2 == 0:
        if A[i] % 2 == 1:
            ans += 1

print(ans)


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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 1;
	rep(i , n - 1)
	{
		if (s[i] != s[i + 1])
			cnt++;
	}
	cout << cnt << endl;
	return (0);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define fast_io ios_base::sync_with_stdio(false)
#define pb push_back
#define fir first
#define sec second
#define tr(it,x) for(it = x.begin();it != x.end();it++)
#define mp make_pair
#define sz(x) (ll)x.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define double long double
#define accuracy ll precision = numeric_limits<double>::digits10
#define pll pair<ll,ll>
#define N 100005

ll n,a[N][3],dp[N][3];

int main() {
	// freopen("input.txt", "r", stdin); 
	// freopen("output.txt", "w", stdout);
	fast_io;	 
	accuracy;
	cin >> n;
	fr(i,1,n) {
		fr(j,0,2) cin >> a[i][j];
	}
	fr(i,0,N-1) {
		fr(j,0,2) dp[i][j] = LLONG_MIN;
	}
	fr(j,0,2) dp[1][j] = a[1][j];
	fr(i,2,n) {
		fr(j,0,2) {
			fr(k,0,2) {
				if(k != j) {
					dp[i][j] = max(dp[i][j],dp[i-1][k] + a[i][j]);
				}
			}
		}
	}
	ll MAX = LLONG_MIN;
	fr(j,0,2) {
		MAX = max(MAX,dp[n][j]);
	}
	cout << MAX << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    int x, ans;
    cin >> x;
    if (400 <= x && x <= 599) {
        ans = 8;
    } else if (600 <= x && x <= 799) {
        ans = 7;
    } else if (800 <= x && x <= 999) {
        ans = 6;
    } else if (1000 <= x && x <= 1199) {
        ans = 5;
    } else if (1200 <= x && x <= 1399) {
        ans = 4;
    } else if (1400 <= x && x <= 1599) {
        ans = 3;
    } else if (1600 <= x && x <= 1799) {
        ans = 2;
    } else if (1800 <= x && x <= 1999) {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
/*
#include<rabbit>;
using blueHulkStress;
using AceOfSpades;
*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
const int dx[] = {1,-1,0,0,1,-1,1,-1};
const int dy[] = {0,0,1,-1,1,-1,-1,1};
const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};



int main(int argc, char const *argv[])
{
	
	int n,k;cin>>n>>k;

	cout<<(k==1?0:n-k);
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

int a[10];

int main(){
	rep(i,1,4){
		int x;
		scanf("%d",&x);
		a[x]++;
	}
	if ( a[1] == 1 && a[7] == 1 && a[9] == 1 && a[4] == 1 ) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b]=nrin(2)
  out((a + b) % 2 == 0?(a + b) / 2:'IMPOSSIBLE')
}
main()

Measured memory_bytes: 7372
s = list(input())
if int(s[0])*10 + int(s[1]) > 12 or int(s[0]) + int(s[1]) == 0:
    if int(s[2])*10 + int(s[3]) <= 12 and int(s[2]) + int(s[3]) != 0:
        print("YYMM")
    else:
        print("NA")

else:
    if int(s[2])*10 + int(s[3]) > 12 or int(s[2]) + int(s[3]) == 0:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
	int n, neg = 0;
	vector<ll> a;
	ll ans = 0;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0) neg++, a[i] *= -1;
		ans += a[i];
	}
	sort(a.begin(), a.end());
	if (neg & 1) ans -= a[0] << 1LL;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))

a,b,c = 0,0,0

for i in P:
    if i <= A:
        a+=1
    elif i <= B:
        b+=1
    else:
        c+=1
else:
    print(min(a,b,c))


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

int N;
vector<int> G[100010];
int ans;

int DFS1(int v,int p)
{
    int cnt = 0,sum = 0;
    for(int i = 0; i < G[v].size(); i++)
    {
        int ne = G[v][i];
        if(ne == p)continue;
        sum += DFS1(ne,v);
        cnt++;
    }
    if(cnt == 0)return 1;
    return sum - (cnt - 1) / 2;
}

int DFS2(int v,int p,int x)
{
    vector<int> V;
    int cnt = 0;
    for(int i = 0; i < G[v].size(); i++)
    {
        int ne = G[v][i];
        if(ne == p)continue;
        V.push_back(DFS2(ne,v,x));
        cnt++;
    }
    if(cnt == 0)
    {
        return 1;
    }
    sort(V.begin(),V.end());
    if(V.back() > x)
    {
        return 0;
    }
    if(V[0] == 0)
    {
        return 0;
    }
    if(cnt % 2 == 0)
    {
        for(int i = 0; i < V.size() / 2 + 1; i++)
        {
            if(i == V.size() / 2)
            {
                return 1;
            }
            if(V[i] + V[V.size() - 1 - i] > x)
            {
                if(V.back() > x)
                {
                    return 0;
                }
                V.pop_back();
                break;
            }
        }
    }
    int l = -1,r = V.size() - 1;
    while(r - l > 1)
    {
        int mid = (l + r) / 2;
        int L = 0,R = V.size() - 1;
        for(int i = 0; i <= V.size() / 2; i++,L++,R--)
        {
            if(i == V.size() / 2)
            {
                r = mid;
                break;
            }
            if(L == mid)L++;
            if(R == mid)R--;
            if(V[L] + V[R] > x)
            {
                l = mid;
                break;
            }
        }
    }

    int L = 0,R = V.size() - 2;
    for(int i = 0; i <= V.size() / 2; i++,L++,R--)
    {
        if(i == V.size() / 2)
        {
            return V[r] + 1;
        }
        if(L == r)L++;
        if(R == r)R--;
        if(V[L] + V[R] > x)
        {
            return 0;
            break;
        }
    }
}

bool judge(int mid)
{
    int res;
    for(int i = 1; i <= N; i++)if(G[i].size() == 1)
    {
        res = DFS2(i,0,mid);
        break;
    }
    return (res != 0 && mid >= res - 1);
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    //ans = DFS1(1,0);
    for(int i = 1; i <= N; i++)if(G[i].size() % 2)ans++;
    ans /= 2;

    int l = 0,r = N - 1;
    while(r - l > 1)
    {
        int mid = (l + r) / 2;
        if(judge(mid))r = mid;
        else l = mid;
    }

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


Measured memory_bytes: 18176
=begin
???????????´??°a, b, c?????????????????????????????? a < b < c????????¶????????????????????°"Yes"?????????????????????????????°"No"???????????????????????°?????????????????????????????????
=end
if __FILE__ == $0
     while line = STDIN.gets
              tokes = line.chomp!.split.map!(&:to_i)
              a,b,c   = tokes[0],tokes[1],tokes[2]
      end
      if a < b && c > b
         puts "Yes"
      else
         puts "No"
      end
end

Measured memory_bytes: 8652
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
int main(void){
	int n,q;
	int m,t,x;
	int i;
	V v[1001];
	cin>>n>>q;
	for(i=0;i<q;i++){
		cin>>m;
		if(m==0){
			cin>>t>>x;
			v[t].push_back(x);
		}
		else if(m==1){
			cin>>t;
			if(v[t].empty()){
				cout<<endl;
			}
			else{
				for(int j=0;j<v[t].size();j++){
					if(j)	cout<<" ";	
					cout<<v[t][j];
				}
				cout<<endl;
			}
		}
		else{
			cin>>t;
			v[t].clear();
		}
	}
	return 0;
}


Measured memory_bytes: 5848
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 101000
#define M 510
using namespace std;
int last[M],nxt[N],n,m,to[N],rd[M],cd[M],tot=0,bz[M];
void link(int x,int y)
{
	nxt[++tot]=last[x];last[x]=tot;to[tot]=y;
	rd[y]++;cd[x]++;
}
void dg(int x)
{
	if(bz[x]==1) return;bz[x]=1;
	for(int i=last[x];i;i=nxt[i]) dg(to[i]);
}
int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,n)
	{
		int a,b,c,d,x,y;scanf("%d%d%d%d",&a,&b,&c,&d);
		if(c==0) x=a+m;
		else x=c;
		if(d==0) y=b;
		else y=d+m;
		link(x,y);
	}
	int q=0,w=0;
	fo(i,1,m)
	{
		if(rd[i]<cd[i]) q++;
		if(rd[i]>cd[i]) w++;
	}
	if(q>0||w==0) return printf("NO\n"),0;
	q=0,w=0;
	fo(i,m+1,m+m)
	{
		if(rd[i]>cd[i]) q++;
		if(rd[i]<cd[i]) w++;
	}
	if(q>0||w==0) return printf("NO\n"),0;
	q=0,w=0;
	fo(i,1,m) if(rd[i]>cd[i]) w++;
	fo(i,m+1,m+m) if(rd[i]<cd[i]) q++;
//	if(q!=w) return printf("NO\n"),0;
	fo(i,m+1,m+m) if(rd[i]<cd[i]) dg(i);
	fo(i,1,m) if((rd[i]>0||cd[i]>0)&&bz[i]==0) return printf("NO\n"),0;
	printf("YES\n");
}

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);



int main() {
	std::string s;
	std::cin >> s;
	for (int i = 0; i < s.size() - 8; i++)
		std::cout << s[i];
	std::cout << std::endl;
	return 0;
}

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

namespace ABC081B_ShiftOnly
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int count = 0;
            while(input.Count(x => x % 2 == 0) == input.Length)
            {
                input = input.Select(x => x / 2).ToArray();
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13252
#include <iostream>
using namespace std;
int main()
{
    long long x;cin>>x;
    for(long long i=-1000;i<=1000;++i){
        for(long long j=-1000;j<=1000;++j){
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout<<i<<' '<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
typedef long long lint;
using namespace std;

int main()
{
	string str;
	lint sum[200010]={};
	lint ans=0;
	
	cin >> str;
	
	for(lint i=0;i<str.size();i++)
	{
		if(str[i]=='B')sum[i]++;
		sum[i+1]+=sum[i];
	}
	
	for(lint i=0;i<str.size();i++)
	{
		if(str[i]=='W')ans+=sum[i];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template< typename T >
struct edge {
    int src,to;
    T cost;

    edge() = default;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

template<typename T>
vector<T> Dijkstra(vector<vector<edge<T>>> &G, int s, T inf) {
    vector<T> dist(G.size(),inf);

    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> pq;
    dist[s] = 0;
    pq.emplace(dist[s],s);
    while (!pq.empty()) {
        T d; int v;
        tie(d,v) = pq.top(); pq.pop();
        if (d > dist[v]) continue;
        for (auto &e : G[v]) {
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                pq.emplace(dist[e.to],e.to);
            }
        }
    }

    return dist;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<edge<ll>>> G(N);
    rep(i,N-1) {
        G[i+1].emplace_back(i,0);
    }
    rep(i,M) {
        ll L,R,C; cin >> L >> R >> C;
        --L; --R;
        G[L].emplace_back(R,C);
    }

    auto dist = Dijkstra<ll>(G, 0, 1e18);
    cout << ((dist[N-1] == 1e18) ? -1 : dist[N-1]) << ln;
}


Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG
const int INF=1e15;

signed main(){
    int N;cin>>N;
    map<int,int>memo;
    REP(i,N){
        int a;cin>>a;
        memo[a]++;
    }
    int ans=0;
    for(auto it=memo.begin();it!=memo.end();it++) ans++;
    cout<<ans<<endl;
}

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

int main(){
  long double a,b; cin >> a >> b;
  b *= 100;
  ll aa = round(a);
  ll bb = round(b);
  cout << (aa*bb)/100 << endl;
  
}

Measured memory_bytes: 3792
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

// For every i, finds the largest j < i such that `compare(values[j], values[i])` is true, or -1 if no such j exists.
template<typename T, typename T_compare>
vector<int> closest_left(const vector<T> &values, T_compare &&compare) {
    int n = int(values.size());
    vector<int> closest(n);
    vector<int> stack;

    for (int i = 0; i < n; i++) {
        while (!stack.empty() && !compare(values[stack.back()], values[i]))
            stack.pop_back();

        closest[i] = stack.empty() ? -1 : stack.back();
        stack.push_back(i);
    }

    return closest;
}

// For every i, finds the smallest j > i such that `compare(values[j], values[i])` is true, or `n` if no such j exists.
template<typename T, typename T_compare>
vector<int> closest_right(vector<T> values, T_compare &&compare) {
    int n = int(values.size());
    reverse(values.begin(), values.end());
    vector<int> closest = closest_left(values, compare);
    reverse(closest.begin(), closest.end());

    for (auto &c : closest)
        c = n - 1 - c;

    return closest;
}

template<typename T>
int64_t largest_rectangle_in_histogram_modified(const vector<T> &histogram) {
    int n = int(histogram.size());
    vector<int> left = closest_left(histogram, less_equal<T>());
    vector<int> right = closest_right(histogram, less<T>());
    int64_t best = 0;

    for (int i = 0; i < n; i++)
        best = max(best, int64_t(histogram[i] + 1) * (right[i] - left[i]));

    return best;
}


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int H, W;
    cin >> H >> W;
    vector<string> grid(H);

    for (auto &row : grid)
        cin >> row;

    H--; W--;
    vector<int> histogram(W, 0);
    int64_t best = max(H + 1, W + 1);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int square = (grid[i][j] ^ grid[i][j + 1] ^ grid[i + 1][j] ^ grid[i + 1][j + 1]) % 2;

            if (square == 0)
                histogram[j]++;
            else
                histogram[j] = 0;
        }

        best = max(best, largest_rectangle_in_histogram_modified(histogram));
    }

    cout << best << '\n';
}


Measured memory_bytes: 7416
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int N,K;
int V[55];
vector<pair<int,int> > ans;
void op(int x,int y){
   V[y] += V[x];
   ans.push_back({x,y});
}
int k,l;
int main() {
    cin >> N;
    k = l = 1;
    for(int i = 1;i <= N;i++){
       cin >> V[i];
       if(V[k] < V[i]){
          k = i;
       }
       if(V[l] > V[i]){
          l = i;
       }
    }
    int mini = V[l];
    int maxi = V[k];
    if(mini <= 0 && maxi >= 0){
       if(- mini > maxi){
          for(int i = 1;i <= N;i++){
             if(V[i] > 0){
                op(l,i);
             }
          }
          for(int i = N;i > 1;i--){
             if(V[i] < V[i - 1]){
                op(i,i - 1);
             }
          }
       }
       else {
          for(int i = 1;i <= N;i++){
             if(V[i] < 0){
                op(k,i);
             }
          }
          for(int i = 1;i < N;i++){
             if(V[i] > V[i + 1]){
                op(i,i + 1);
             }
          }
       }
    }
    else {
       if(maxi < 0){
          for(int i = N;i > 1;i--){
             if(V[i] < V[i - 1]){
                op(i,i - 1);
             }
          }
       }  
       else {
          for(int i = 1;i < N;i++){
             if(V[i] > V[i + 1]){
                op(i,i + 1);
             }
          }
       }
    }
    cout << ans.size() << "\n";
    for(auto it:ans){
       cout << it.first << " " << it.second << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import bisect

A,B,Q = map(int,input().split())

s = [-1 * float("inf")]
t = [-1 * float("inf")]

for i in range(A):

    S = int(input())
    s.append(S)

for i in range(B):

    T = int(input())
    t.append(T)

s.append(float("inf"))
t.append(float("inf"))

for i in range(Q):

    x = int(input())

    si = bisect.bisect_left(s,x)
    ti = bisect.bisect_left(t,x)

    now = min( max(s[si],t[ti]) - x  ,  x - min(s[si-1],t[ti-1]) )
    now = min( now , 2 * min( s[si] - x , x - t[ti-1] ) + max(s[si] - x , x - t[ti-1]))
    now = min( now , 2 * min( t[ti] - x , x - s[si-1] ) + max(t[ti] - x , x - s[si-1]))

    print (now)

Measured memory_bytes: 12084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
int main(){
    ll n,k;cin>>n>>k;
    vvi v(n,vi(3));
    ll sum=0;
    rep(i,n){
        v[i][2]=k+n*2+i;
        sum+=v[i][2];
    }
    if(sum<(k+(k+n*2-1))*n){
        out(-1);
        return 0;
    }
    for(int i=0;i*2<n;i++){
        v[i*2][0]=k+i;
        v[i*2][1]=k+n+n/2+i;
    }
    for(int i=0;i*2+1<n;i++){
        v[i*2+1][0]=k+(n+1)/2+i;
        v[i*2+1][1]=k+n+i;
    }
    outvv(v);
}


Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define ll int
#define maxn 10001
#define MOD 1000000007
using namespace std;
 
string s;
ll k, n;
ll dp[maxn][101][2];
vector<ll> num;
 
/*
 dp[p][s][f]
    p = position
    s = sum upto p
    f = flag if the value is crossing the range or not
*/
 
ll solve(ll pos, ll sum, ll f){
    if(n==pos){
        if(sum==0) return 1;
        else return 0;
    }
    if(dp[pos][sum][f] != -1) return dp[pos][sum][f];
    ll res = 0, lmt;
    if(f==0){ // the pos can only be (0, s[pos])
        lmt = num[pos];
    }
    else { // the pos can be anything
        lmt = 9;
    }
    for(ll i = 0; i <= lmt; i++){
        ll newf = f; // newf is the flag value for next position
        if(f==0 && i<lmt) newf = 1; // if currently f =0 ie restricted and
                                 // current pos is less than the edge value
                                 //the next pos can be anything bw (0,9), hence newf is 1
        res += solve(pos+1, (sum+i)%k, newf);
        res %= MOD;
    }
    return dp[pos][sum][f] = res;
}
 
int main(){
    //ll t; cin >> t; while(t--){
        cin >> s >> k;
        num.clear();
        n = s.length();
        for(ll i=0; i<n; i++){
            num.push_back(s[i]-'0');
        }
        memset(dp, -1, sizeof(dp));
        ll ans = solve(0,0,0);
        ans--;
        if(ans<0) ans+= MOD;
        cout << ans << endl;
    //}
}

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

int main() {
    map<string, int> card;
    int n, m, t = 0;
    string str;

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

    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> str;
        card[str]--;
    }

    map<string, int>::iterator iter;
    int max_card = INT32_MIN;
    for (iter = card.begin(); iter != card.end(); iter++) {
        if (iter->second > max_card)
            max_card = iter->second;
    }
    if (max_card < 0 )
        cout << 0 << endl;
    else
        cout << max_card << endl;
}

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

int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(n - 1) << " ";

  vector<long long> b(n - 1);
  for (long long i = 0; i < n - 1; i++)
    b.at(i) = min(a.at(i), a.at(n - 1) - a.at(i));
  long long maxb = 0, memo;
  for (long long i = 0; i < n - 1; i++) {
    if (maxb < b.at(i)) {
      maxb = b.at(i);
      memo = i;
    }
  }
  cout << a.at(memo) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int64_t zet(int64_t x, int64_t y){
    if (x >= y) return x - y;
    else return y - x;
}
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int64_t y = 0;
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
        y += a.at(i);
    }
    int64_t x = 0, ans_f = 0;
    int64_t ans;
    for (int i = 0; i < N - 1; i++){
        x += a.at(i);
        y -= a.at(i);
        ans = zet(x, y);
        if (i == 0) ans_f = ans;
        else if (ans < ans_f) ans_f = ans;
    }
    cout << ans_f << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e6+5;
ll n,m,p;
int vis[maxn];
ll a[15],b[15];
ll path[15];
ll cnt=0;
ll cnta,cntb;
int judgea()
{
    for(int i=1;i<=n;i++)
        if(a[i]!=path[i]) return 0;
    return 1;
}
int judgeb()
{
    for(int i=1;i<=n;i++)
        if(b[i]!=path[i]) return 0;
    return 1;
}
void dfs(int x)
{
    if(x==n+1)
    {
        ++cnt;
        if(judgea()) cnta=cnt;
        if(judgeb()) cntb=cnt;
        return;
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            vis[i]=1;
            path[x]=i;
            dfs(x+1);
            vis[i]=0;
        }
    }
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
    dfs(1);
    printf("%lld\n",abs(cnta-cntb));
    return 0;
}





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

int N,Q;
ll A[101010],sum[101010],sumE[101010],sumO[101010];

int main(){
  cin>>N>>Q;
  for(int i=1;i<=N;i++){
    cin>>A[i];
    sum[i]=sum[i-1]+A[i];
    sumE[i]=sumE[i-1]+(i%2==0?A[i]:0);
    sumO[i]=sumO[i-1]+(i%2?A[i]:0);
  }
  while(Q--){
    int X; cin>>X;
    ll res=0;
    int ok=0,ng=N+1;
    while(abs(ng-ok)>1){
      int mid=(ok+ng)/2;
      int l=N-mid+1,r=N-mid/2+(mid%2==0);
      if(abs(A[l]-X)<=(abs(A[r]-X))) ok=mid;
      else ng=mid;
    }
    // 上からok個まで、あとは偶奇
    int r=N-ok/2+(ok%2==0),l=N-ok+1;
    if(r==l){
      if(N%2) cout<<sumO[N]<<endl;
      else cout<<sumE[N]<<endl;
      continue;
    }
    res=sum[N]-sum[r-1];
    if((l-1)%2){
      if(ok%2) res+=sumE[l-1];
      else res+=sumO[l-1];
    }else{
      if(ok%2) res+=sumO[l-1];
      else res+=sumE[l-1];
    }
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <math.h>

int main (void){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    int c,d,e;
    c=a+b;
    d=a-b;
    e=a*b;
if (d>c){
    c=d;
}
if(e>c){
    c=e;
}
printf("%d",c);
return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mx=1e6;
vector<int>adj[mx];
bool visited[mx];
queue<int>q;
int level[mx];
void bfs(int x)
{
    q.push(x);
    visited[x]=1;
    level[x]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<adj[u].size();i++)
        {
            int v=adj[u][i];
            if(!visited[v])
            {
                q.push(v);
                level[v]=level[u]+1;
                visited[v]=1;
            }
        }
    }
}
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset(visited,0,sizeof(visited));
    bfs(1);
    if(level[n]==2)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 2000007

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vll>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const int& a, const int& b) {return a > b;}

pair <ll, ll> a[maxN], b[maxN];

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen("tmp.inp", "r", stdin);
//        freopen("tmp.out", "w", stdout);
//    #endif // ONLINE_JUDGE

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

    fto (i, 1, n) scanf("%lld%lld", &a[i].FF, &a[i].SS);
    fto (i, 1, m) scanf("%lld%lld", &b[i].FF, &b[i].SS);

    fto (i, 1, n) {
        ll ans = 4LL*OO;
        int pos = 0;
        fto (j, 1, m) {
            if (ans > abs(a[i].FF-b[j].FF)+abs(a[i].SS-b[j].SS)) {
                ans = abs(a[i].FF-b[j].FF)+abs(a[i].SS-b[j].SS);
                pos = j;
            }
        }
        printf("%d\n", pos);
    }

    return 0;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string n;
	cin >> n;
	long long int s = 0;
	for (int i = 0; i < n.size(); i++) {
		s = s + (n[i] - '0');
	}
	if (s % 9 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 3768