akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nn 65536*8
ll a[nn];ll sa[nn];
ll b[nn];ll n;ll mod;
map<ll,ll> m;
pair<ll,ll> range[nn];
ll rf[nn];
ll modi(ll x)
{
	return (x%mod+mod)%mod;
}
int tot=0;
struct travellerspride{
	ll tree[nn*2+10];
	int llc[nn*2+10],rrc[nn*2+10];
	ll tag[nn];ll nul=-1e17;int all;
	#define lc llc[id]
	#define rc rrc[id]
	void up(int id)
	{
		tree[id]=min(tree[lc],tree[rc]);
	}
	void set(int id,ll y)
	{
		tree[id]=y;
		tag[id]=y;
	}
	void down(int id)
	{
		if(tag[id]>nul)
		{
			set(lc,tag[id]);
			set(rc,tag[id]);
		}
		tag[id]=nul;
	}
	#define mid (l+r)/2
	void build(int l,int r,int &id)
	{
		if(!id) id=++all;
		tag[id]=nul;
		if(l==r)
		{
			if(l>tot) tree[id]=0-rf[l-tot];
			else tree[id]=0-rf[l];
			return ;
		}
		build(l,mid,lc);build(mid+1,r,rc);
		up(id);
	}
	ll query(int a,int b,int l,int r,int id)
	{
		if(l>=a and r<=b)
			return tree[id];
		down(id);
		if(b<=mid) return query(a,b,l,mid,lc);
		else if(a>mid) return query(a,b,mid+1,r,rc);
		else return min(query(a,b,l,mid,lc),query(a,b,mid+1,r,rc));
	}
	void update(int a,int b,int l,int r,int id,ll y)
	{
		if(a>b) return ;
		if(l>=a and r<=b)
		{
			set(id,y);
			return ;
		}
		down(id);
		if(a<=mid) update(a,b,l,mid,lc,y);
		if(b>mid) update(a,b,mid+1,r,rc,y);
		up(id);
	}
	ll query(int l,int r,int id)
	{
		if(l==r)
		{
			if(l>tot) return tree[id]+rf[l-tot];
			else return tree[id]+rf[l];
		}
		down(id);
		return min(query(l,mid,lc),query(mid+1,r,rc));
	}
	
}trcyx;


int main()
{
	scanf("%lld%lld",&n,&mod);
	set<ll> s;
	for(int i=0;i<n;i++) 
	{
		scanf("%lld%lld",&a[i],&b[i]);
		if(b[i]==1 and a[i]*2>mod)
		{
			puts("-1");
			exit(0);
		}
		if(i)a[i]+=a[i-1];//aishouldnotbe modded
		if(2==b[i]) continue;
		ll r=-2*a[i],l=0;if(i) l=-2*a[i-1];//this range is what we can stay
		l=modi(l),r=modi(r);
		range[i]=make_pair(l,r);
		s.insert(l);s.insert(r);
	}
	for(set<ll>::iterator it=s.begin();it!=s.end();it++)
		m[*it]=++tot,rf[tot]=*it;
	int rt=0;ll totot=tot+tot;
	trcyx.build(1,totot,rt);
	for(int i=0;i<n;i++)
	{
		ll l=range[i].first,r=range[i].second;
		l=m[l],r=m[r];if(l>r) r+=tot;//thus we can have real ranges
		if(b[i]==1)
		{
			ll fl=trcyx.query(1,l,1,totot,rt)+rf[l];
			fl=min(fl,trcyx.query(l,totot,1,totot,rt)+rf[l]+mod);
			trcyx.update(l,l,1,totot,rt,fl-rf[l]);
			trcyx.update(l+tot,l+tot,1,totot,rt,fl-rf[l]);
			//these poins are same
			l=range[i].first,r=range[i].second;
			l=m[l],r=m[r];
			if(l<=r)
			{
				trcyx.update(r+1,tot,1,totot,rt,1e17);
				trcyx.update(1,l-1,1,totot,rt,1e17);
				
				trcyx.update(r+1+tot,totot,1,totot,rt,1e17);
				trcyx.update(1+tot,l-1+tot,1,totot,rt,1e17);
			}
			else
			{
				trcyx.update(r+1,l-1,1,totot,rt,1e17);
				
				trcyx.update(r+1+tot,l-1+tot,1,totot,rt,1e17);
			}
			//thus these ranges are mpossible
		}
	}
	cout<<trcyx.query(1,totot,rt)+a[n-1]*2;
}

Measured memory_bytes: 31616
#include<iostream>


using namespace std;

int main() {
	int H;
	int W;
	int N;
	cin >> H;
	cin >> W;
	cin >> N;

	int paintCount = 0;
	int paintBlack = 0;
	while (1) {

		if (H > W) {
			paintBlack = paintBlack + H;
			paintCount++;
		}
		else {
			paintBlack = paintBlack + W;
			paintCount++;
		}

		if (N <= paintBlack) {
			break;
		}
	}

	cout << paintCount << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
  
#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
 
using namespace std;
/*
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  */
const int inf = 2e9+7, mod=1e9+7;
const int N = 1e3;
 
ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

int main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	vector<int> v;
	int cnt=0, sum1=0;
	int n, m;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		sum1+=a;
		v.pb(a);
	}
	for(int i=0; i<n; i++)
		if(v[i]*4*m>=sum1)
			cnt++;
	if(cnt>=m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
import itertools

N,M,Q = map(int,input().split())

# nullで初期化
abcd = [None] * Q
for i in range(Q):
  abcd[i] = list(map(int,input().split()))

ans = 0
# itertools.combinations_with_replacement(リスト,取り出す数)で順列の組み合わせを出力
for list in list(map(list, itertools.combinations_with_replacement(range(1,M+1), N))):
  num = 0
  for x in abcd:
    if list[x[1]-1] - list[x[0]-1] == x[2]:
      num += x[3]
  ans = max(ans,num)
print(ans)

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

namespace AProduct
{
    public class Core
    {
        static public bool isProductEven(int a, int b)
        {
            var product = a * b;
            return product % 2 == 0;
        }

        static public string printDependsOnProductIsEven(int a, int b)
        {
            return isProductEven(a, b) ? "Even" : "Odd";
        }

        static public void core()
        {
            var firstLine = Console.ReadLine();
            var data = firstLine.Split(' ');
            var retStr = printDependsOnProductIsEven(int.Parse(data[0]), int.Parse(data[1]));

            Console.Write(retStr);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Core.core();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#define N 100
using namespace std;

void swap(int *,int *);
int partition(int [],int,int);

int main(){
	int n,a[100000];
	cin>>n;
	for(int i=0;i<n;i++) cin >> a[i];
	int k = partition(a,0,n-1);
	for(int i=0;i<n;i++){
		if(i==k) cout<< "["<<a[i]<<"]";
		else cout<<a[i];
		if(i!=n-1) cout<<" ";
	}
	cout<<endl;
	return 0;
}

int partition(int a[],int p,int r){
	int x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			swap(&a[i],&a[j]);
		}
	}
	swap(&a[i+1],&a[r]);
	return i+1;
}

void swap(int *a,int *b){
	int w=*a;
	*a=*b;
	*b=w;
}

Measured memory_bytes: 1548
class RAQ(object):
    INIT = 0

    def __init__(self, num) -> None:
        n = 1
        while n <= num:
            n = n * 2
        self.n = n
        self.val = [self.INIT] * (2 * n - 1)

    def update(self, beg: int, end: int, k: int, l: int, r: int, x: int) -> None:
        if (l == r or l == beg and r == end):  # noqa: E741
            self.val[k] += x
            return
        mid = (l + r) // 2
        if (end <= mid):
            self.update(beg, end, k * 2, l, mid, x)
        elif (beg > mid):
            self.update(beg, end, k * 2 + 1, mid + 1, r, x)
        else:
            self.update(beg, mid, k * 2, l, mid, x)
            self.update(mid + 1, end, k * 2 + 1, mid + 1, r, x)

    def find(self, k: int, l: int, r: int, idx: int) -> int:
        if (l == r):  # noqa: E741
            return self.val[k]
        mid = (l + r) // 2
        if (idx <= mid):
            return self.val[k] + self.find(k * 2, l, mid, idx)
        else:
            return self.val[k] + self.find(k * 2 + 1, mid + 1, r, idx)


if __name__ == "__main__":
    n, q = map(lambda x: int(x), input().split())
    raq = RAQ(n)

    for _ in range(q):
        com, *v = map(lambda x: int(x), input().split())
        if (0 == com):
            raq.update(v[0], v[1], 1, 1, n, v[2])
        else:
            print(f"{raq.find(1, 1, n, v[0])}")



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

using namespace std;

int main(void)
{
    string N;
    cin >> N;

    for(int i = 0;i < (int)N.size();i++){
        if(N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{
    long int A, B, N, x;
    cin >> A >> B >> N;
    if (B <= N){
        x = B - 1;
    }
    else if (B > N){
        x = N;
    }
    long int a, b, c, d;
    a = A * x;
    b = x / B;
    c = a / B;
    d = c - A * b;
    cout << d; 
}

Measured memory_bytes: 3624
def warshall_floyd():
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
warshall_floyd()
res = 0
for _ in range(H):
    A = list(map(int, input().split()))
    res += sum(C[a][1] for a in A if a != -1)
print(res)

Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int cur = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == '(') cur++;
        else
        {
            if(cur == 0) ans++;
            else cur--;
        }
    }
    while(ans--) printf("(");
    cout << s;
    while(cur--) printf(")");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const long long int INF=1e9;

vector<vector<int> > Edge;
queue<int> que;
int counter;
vector<int> dist;

bool bfs() {
    counter=0;
    while(!que.empty()) {
        int cur=que.front(); que.pop();
        
        for(int e=0; e<Edge[cur].size(); e++) {
            if(dist[Edge[cur][e]]!=INF) continue;
            que.push(Edge[cur][e]);
            dist[Edge[cur][e]] = dist[cur]+1;
        }
    }

    return dist[Edge.size()-1]<=2;
}

int main() {
    int N, M;
    cin >> N >> M;
    Edge.resize(N);
    dist.resize(N, INF);
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        Edge[a-1].push_back(b-1);
        Edge[b-1].push_back(a-1);
    }
    
    que.push(0);
    dist[0] = 0;
    
    if(bfs()) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 13168
#include<iostream>
using namespace std;
int main()
{
    int n, i = 0;
    string s;
    cin >> n >> s;
    while(s[i] == s[n/2 + i] && i < n/2)
    {
        i++;
    }
    if(n % 2 == 0 && i == n/2)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
int main() {
	cin >> N;
	for (i = 1; i <= N; i++) {
		ll M = nod(i);
		ll P = pow(10, M-1);
		ll U = i / P;
		ll D = i % 10;
		for (j = 1; j <= M; j++) {
			if (D > 0) {
				if (j == 1) {
					if (U == D) {
						if (M == 1) {
							ans += 1;
						}
						else {
							ans += 2;
						}
					}
				}
				else {
					if (U == D) {
						if (M == j) {
							ll pre = ((i - U * P - D) / 10) * 2 + 1;
							ans += pre;
						}
						else {
							ans += pow(10, j - 2) * 2;
						}
					}
					else if (U > D) {
						ans += pow(10, j - 2) * 2;
					}
					else {
						if (M > j) {
							ans += pow(10, j - 2) * 2;
						}
					}
				}
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

double dp[1<<14][14][2];
int n;
double x[2][101];
double y[2][101];
double dist[14][2][14][2];

double calc(){
  for(int mask=(1<<n)-1;mask>=1;mask--){
    for(int j=0;j<n;j++){
      for(int k=0;k<2;k++){
	double res=1000000000;
	if(mask==((1<<n)-1))res=0;
	else{
	  // テつ催つ。テつづδ古つ湘δェテつ湘つ甘つづつゥテつづδァテつ陛δ甘つづδ古つ湘δェテつ湘つ甘つづδ姪つ暗δ堙つ禿つョ
	  for(int l=0;l<n;l++){
	    // テつづδ愿つづつセテつ選テつ妥δーテつづつウテつづδェテつづδつづつ「テつづδ暗つづつ「
	    if(!((mask>>l)&1)){
	      int nmask=(mask|(1<<l));
	      // テつづδつづつソテつづδァテつづδ古つ端テつづδ姪つ暗δ堙つ禿つョテつづつキテつづδゥテつづつゥ
	      for(int m=0;m<2;m++)
		res=min(res,dist[j][!k][l][m]+dp[nmask][l][m]);
	    }
	  }
	}
	dp[mask][j][k]=res;
      }
    }
  }
  double res=1000000000;
  for(int i=0;i<n;i++)
    for(int j=0;j<2;j++)
      res=min(res,dp[(1<<i)][i][j]);
  return res;
}

int main(){
  int cnt=0;
  while(cin>>n&&n){
    cnt++;
    // テつ静δシテつ陛つェテつづδ古つ津つキテつづつウ
    double len=0;
    for(int i=0;i<n;i++){
      cin>>x[0][i]>>y[0][i]>>x[1][i]>>y[1][i];
      len+=sqrt(pow(x[0][i]-x[1][i],2)+pow(y[0][i]-y[1][i],2));
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<2;j++){
	for(int k=0;k<n;k++){
	  for(int l=0;l<2;l++){
	    //テつ点テつ甘δ氾つづδ古つ津つキテつづつウテつづδーテつ計テつ算
	    dist[i][j][k][l]
	      =sqrt(pow(x[j][i]-x[l][k],2)+pow(y[j][i]-y[l][k],2));
	  }
	}
      }
    }
    double res=calc()+len;
    printf("Case %d: %.10f\n",cnt,res);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(a) for(int i=0; i<a; i++)
using namespace std;
typedef pair<int, int> P;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
bool cmp(int a, int b)
{
	return a > b;
}
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge one, two;
	one.from = a; one.to = b; one.weight = c;
	two.from = b; two.to = a; two.weight = c;
	V[a].push_back(one);
	V[b].push_back(two);
}


//////////////////////////////////////////


void solve()
{
	cin >> a;
	if(a >= 1000) printf("ABD");
	else          printf("ABC");
	printf("\n");
}
int main()
{
	int times = 1;
//	cin << times;
	loop(times)
	{
		solve();
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n, W, w[100], v[100];
ll dp[100][100001];
ll f(int i, int W=::W)
{
    if( W < 0)
        return -1e9;
    if( i == n )
        return 0;
    if( dp[i][W] != -1 )
        return dp[i][W];
    return dp[i][W] = max(f(i+1, W-w[i])+v[i], f(i+1, W));
}
int main()
{
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    memset(dp, -1, sizeof dp);
    cin >> n >> W;
    for(int i=0; i<n; ++i)
        cin >> w[i] >> v[i];
    cout << f(0);
}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;

int main()
{
    fast;ll int n;
    cin>>n;
    ll int a[n];ll int i,k,w,f,j;
    for(i=1;i<=n;i++)
    {	
    	cin>>a[i];
    }
    ll int dp[n+1][n+1];
    for(i=0;i<=n;i++)
    {
    	for(j=0;j<=n;j++)
    		dp[i][j]=0;
    }
    if(n%2==0)
    	f=1;
    else
    	f=0;//     0 for j and 1 for t;
    for(i=1;i<=n;i++)
    {
    	w=i;
    	f=1^f;
    	for(j=1;j<=(n-i+1);j++)
    	{
    		k=j+i-1;
    		if(i==1 && f==0)
    		{
    			dp[j][k]=-1*a[k];
    		}
    		else if(i==1 && f==1)
    			dp[j][k]=a[k];
    		else if(f==0)
    		{
    			dp[j][k]=min(dp[j+1][k]-a[j],dp[j][k-1]-a[k]);
    		}
    		else if(f==1)
    			dp[j][k]=max(a[j]+dp[j+1][k],a[k]+dp[j][k-1]);
    	}
    }
    cout<<dp[1][n]<<endl;
  /*  for(i=1;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    		cout<<dp[i][j]<<" ";
    	cout<<endl;
    }*/
   
}

Measured memory_bytes: 73928
N, M, X = map(int, input().split())
Clist = []
Alist = []
for i in range(N):
    C, *A = map(int, input().split())
    Clist.append(C)
    Alist.append(list(A))
ans = []
for i in range(2**N):
    money = 0
    rikai = [0] * M
    for j in range(N):
        if ((i >> j) & 1):
            money += Clist[j]
            for k in range(M):
                rikai[k] += Alist[j][k]
    if all([r>=X for r in rikai]):
        ans.append(money)
if ans:
    print(min(ans))
else:
    print(-1)

Measured memory_bytes: 9256
//************************************************************************
// File Name: F.cpp
// Author: Shili_Xu
// E-Mail: shili_xu@qq.com 
// Created Time: 2018年03月24日 星期六 22时32分59秒
//************************************************************************

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-8, PI = acos(-1);
const int MAXN = 105;

struct point {
	double x, y;
	int id;
	
	point() {}
	point(double _x, double _y, int _id = -1) : x(_x), y(_y), id(_id) {}
	bool operator<(const point &another) const;
};

struct ans {
	double val;
	int id;

	ans() {}
	bool operator<(const ans &another) const
	{
		return id < another.id;
	}
};

int tot, n;
point p[MAXN], s[MAXN], normal[MAXN];
ans an[MAXN];
bool visited[MAXN];

int sgn(double x)
{
	if (fabs(x) < EPS) return 0;
	return (x > 0 ? 1 : -1);
}

double det(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.y - b1.y) - (a2.y - a1.y) * (b2.x - b1.x));
}

double dot(const point &a1, const point &a2, const point &b1, const point &b2)
{
	return ((a2.x - a1.x) * (b2.x - b1.x) + (a2.y - a1.y) * (b2.y - b1.y));
}

double dist(const point &p1, const point &p2)
{
	return sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));
}

bool point::operator<(const point &another) const
{
	if (sgn(det(p[0], *this, p[0], another)) == 0)
		return dist(p[0], *this) < dist(p[0], another);
	else
		return det(p[0], *this, p[0], another) > 0;
}

void graham()
{
	double min_y = p[0].y, min_x = p[0].x;
	int index = 0;
	for (int i = 1; i <= n - 1; i++) {
		if (p[i].y < min_y || (sgn(p[i].y - min_y) == 0 && p[i].x < min_x)) {
			min_y = p[i].y;
			min_x = p[i].x;
			index = i;
		}
	}
	swap(p[0], p[index]);
	sort(p + 1, p + n);
	s[0] = p[0]; s[1] = p[1];
	tot = 2;
	for (int i = 2; i <= n - 1; i++) {
		while (tot >= 2 && sgn(det(s[tot - 1], p[i], s[tot - 1], s[tot - 2]) < 0)) tot--;
		s[tot++] = p[i];
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf %lf", &p[i].x, &p[i].y);
		p[i].id = i;
	}
	graham();
	for (int i = 0; i < tot; i++) {
		if (i == 0) {
			normal[i].y = -(s[i].x - s[tot - 1].x);
			normal[i].x = s[i].y - s[tot - 1].y;
			normal[i].id = s[i].id;
		}
		else {
			normal[i].y = -(s[i].x - s[i - 1].x);
			normal[i].x = s[i].y - s[i - 1].y;
			normal[i].id = s[i].id;
		}
	}
	point zero(0, 0);
	for (int i = 0; i < tot; i++) {
		if (i == tot - 1) {
			an[i].val = acos(dot(zero, normal[i], zero, normal[0]) / dist(zero, normal[i]) / dist(zero, normal[0])) / PI / 2;
			an[i].id = normal[i].id;
		}
		else {
			an[i].val = acos(dot(zero, normal[i], zero, normal[i + 1]) / dist(zero, normal[i]) / dist(zero, normal[i + 1])) / PI / 2;
			an[i].id = normal[i].id;
		}
	}
	memset(visited, false, sizeof(visited));
	for (int i = 0; i < tot; i++) visited[s[i].id] = true;
	for (int i = 0; i < n; i++)
		if (!visited[i]) {
			an[tot].val = 0.0000000;
			an[tot++].id = i;
		}
	sort(an, an + n);
	for (int i = 0; i < n; i++) printf("%.8f\n", an[i].val);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;

    int c=a+b,d=a-b,e=a*b;
    if(c<d){
        if(d<e)
            cout << e;
        else
            cout << d;
    }
    else{
        if(c<e)
            cout << e;
        else  
            cout << c;
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	count := 0
	fmt.Scanf("%d", &N)
	number := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &number[i])
	}

	for i := 0; i < N; i++ {
		if((i+1) % 2 == 1) {
			if(number[i] % 2 == 1) {
				count++
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 1832
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<int,int> P;


int main(){
    int n,a,b; cin >> n >> a >> b;
  
    if(a>b||(n==1&&a!=b)){
        cout << 0 << endl;
        return 0;
    }
    if(a==b||n==2){
        cout << 1 << endl;
        return 0;
    }
    n-=2;
    ll MAX=0,MIN=0;
    rep(i,n){
        MAX+=b;
        MIN+=a;
    }

    cout << MAX-MIN+1 << endl;
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop,heappush
x,y,z,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
B = list(map(int,input().split()))
B.sort(reverse=True)
C = list(map(int,input().split()))
C.sort(reverse=True)

Q=[]
heappush(Q,(-(A[0]+B[0]+C[0]),0,0,0))
S=set()

for n in range(K):
	p,i,j,k = heappop(Q)
	print(-p)
	
	if i+1 < x and ((i+1,j,k) not in S):
		S.add((i+1,j,k))
		heappush(Q,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
	if j+1 < y and ((i,j+1,k) not in S):
		S.add((i,j+1,k))
		heappush(Q,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
	if k+1 < z and ((i,j,k+1) not in S):
		S.add((i,j,k+1))
		heappush(Q,(-(A[i]+B[j]+C[k+1]),i,j,k+1))

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
struct PP { int y, x, ny, nx; };

int H, W;
int a[505][505];
vector<PP> ans;

void f(int y, int x, int ny, int nx) {
  if (ny == H) return;
  if (a[y][x] % 2) {
    a[y][x]--; a[ny][nx]++;
    ans.push_back({y + 1, x + 1, ny + 1, nx + 1});
  }
}

void visit(int y, int x) {
  if (y == H) return;
  int ny, nx;
  if (y % 2) {
    if (x == 0) {
      ny = y + 1;
      nx = x;
    } else {
      ny = y;
      nx = x - 1;
    }
  } else {
    if (x == W - 1) {
      ny = y + 1;
      nx = x;
    } else {
      ny = y;
      nx = x + 1;
    }
  }
  f(y, x, ny, nx);
  visit(ny, nx);
}

int main() {
  cin >> H >> W;
  rep(i, 0, H) rep(j, 0, W) cin >> a[i][j];
  visit(0, 0);
  cout << ans.size() << endl;
  for (auto p : ans) printf("%d %d %d %d\n", p.y, p.x, p.ny, p.nx);
  return 0;
}


Measured memory_bytes: 5232
#include<stdio.h>

int main()
{
  char s[10] = {};

  scanf("%s", s);

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    printf("Bad\n");
  } else {
    printf("Good\n");
  }
  
  return 0;
}


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

int main() {
    /* 入力受け取り */
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    /* しゃくとり法 */
    long long res = 0;
    int right = 0;
    int sum = 0; // AND 和
    for (int left = 0; left < n; ++left) {
        while (right < n && (sum ^ a[right]) == (sum + a[right])) {
            sum += a[right];
            ++right;
        }
        res += right - left;
        if (left == right) ++right;
        else {
            sum -= a[left]; // a[left] を削除 (sum ^= a[left] でも OK)
        }
    }

    cout << res << endl;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct edge {
    ll to;
    ll cost;
};

int n;
vector<vector<edge>> g;
vector<ll> d;

void dfs(ll s, ll di, ll pa = -1) {
    d[s] = min(d[s], di);

    for (auto t : g[s]) {
        if (t.to == pa) continue;

        dfs(t.to, di + t.cost, s);
    }
}

int main() {

    cin >> n;

    g.resize(n);
    d.resize(n, LINF);

    for (int i = 0; i < n - 1; ++i) {
        ll a, b, c; cin >> a >> b >> c;
        --a; --b;

        g[a].push_back(edge({b, c}));
        g[b].push_back(edge({a, c}));
    }

    ll q, k; cin >> q >> k;
    --k;

    dfs(k, 0);

    for (int i = 0; i < q; ++i) {
        ll x, y; cin >> x >> y;
        --x; --y;

        ll ans = d[x] + d[y];

        cout << ans << endl;
    }
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    int c = 0;
    for (int i = a; i <= b; i++) {
        if (i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10) {
            c++;
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 256
import sys
R = lambda:map(int,raw_input().split())

n = int(raw_input())
le = [0 for i in xrange(6)]
for i in xrange(n):
    num = float(raw_input())
    if num < 165: le[0] += 1
    elif 165 <= num < 170: le[1] += 1
    elif 170 <= num < 175: le[2] += 1
    elif 175 <= num < 180: le[3] += 1
    elif 180 <= num < 185: le[4] += 1
    else: le[5] += 1

for j in xrange(6):
   print "%d:%s" % (j+1, '*'*le[j])

Measured memory_bytes: 4272
/*input
5
1 7 2 11 15
*/

#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define endl "\n"
#define sp " " 
#define all(v) v.begin(),v.end()
#define makepr(a,b) make_pair(a, b)
#define loop(i,k,n) for(ll i=k;i<n;i++)
#define rlop(i,n,k) for(ll i=n-1;i>=k;i--)
#define lop(i ,a) for(auto i : a)
#define vecl vector<ll>
#define vecprl vector<pair<ll, ll> > v;
#define mpll map<ll, ll>
#define mpsl map<string, ll>
#define setl set<ll>
#define mod(a,b) a%b
#define PI 3.14159265

typedef long long ll;
typedef long double ld;

int main()
{
    fast;
    ll n;
    cin >>n;
    ll a[n];
    loop(i, 0,n)
    {
        cin >>a[i];
       
    }
    ll mx = a[0], ans =1;

    loop(i ,1, n)
    {
        if(a[i]>=mx)
        {
            ans++;
            mx= max(mx, a[i]);
        }
       
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int N = 3000;
    int tmp = 0;
    vector<int> vx(N);
    vector<int> vy(N);
    for (int i = 0; i <= N; i++) {
        int x,y;
        cin >> x >> y;
        if (x == 0 && y == 0){ 
            tmp = i - 1;
            break;
        }
        vx.at(i) = x;
        vy.at(i) = y;
    }
  for (int i = 0; i <= tmp; i ++){
      if (vx[i] > vy[i]) {
          cout << vy[i] << ' ' << vx[i] << endl;
      } else {
          cout << vx[i] << ' ' << vy[i] << endl;

      }
  }
  
  return 0;
}


Measured memory_bytes: 3096
# https://atcoder.jp/contests/abc121/tasks/abc121_b
n, m, c = map(int, input().split())

B = [int(i) for i in input().split()]
codes = []
for _ in range(n):
    row = [int(i) for i in input().split()]
    codes.append(row)

ans = 0
for i in range(n):
    code = codes[i]
    t = c
    for a, b in zip(code, B):
        t += a * b
    if t > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
//-------------------------------------------MACROS---------------------------------------------
#define 	TIEMPO_CORRIDA		cerr << "tiempo: "<<1.0*clock()/CLOCKS_PER_SEC <<" seg.\n";
#define 	FILES				freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define 	FORIT(it,e)			for(it = e.begin() ; it != e.end() ; it++)
#define 	FOR(i,a,b)			for(i = a ; i < b ; i++)
#define 	RFOR(i,a,b)			for(i = a ; i >= b ;i--)
#define 	FORSW(i,a,b,sw)		for(i = a ; i < b && sw ; i++)
#define 	RFORSW(i,a,b,sw)	for(i = a ; i >= b && sw ; i--)
#define 	fast 				ios::sync_with_stdio(false),cin.tie(),cout.tie();
#define 	to_int(x) 			atoi(x.data())
#define 	to_long(x) 			atoll(x.data())
#define 	ALL(x) 				x.begin(),x.end()
#define 	RALL(x) 			x.rbegin(),x.rend()
typedef 	long long 			ll;
typedef 	pair<int,int> 		ii;
typedef 	pair<ll,ll> 		pl;
const		int 				modN = 1e9+7;
const		double 				PI = 3.1415926535897932384626433832795028841;
int mov_x[4]={0,0,1,-1};
int mov_y[4]={1,-1,0,0};
//---------------------------------------------------------------------------------------------

double coin[3002];
int n; 
double memo[3000][1500];

double f(int i , int c){
	if(c<0) return 0;
	if(i == n) return memo[i][c]=1;
	if(memo[i][c]!=-1.0)return memo[i][c];
	return memo[i][c] = f(i+1,c-1)*(1.0-coin[i])+f(i+1,c)*coin[i];
}

int main(){
	int i,j;	
	while(cin >> n){
		FOR(i,0,3000) FOR(j,0,1500) memo[i][j]=-1.0;
		FOR(i,0,n) cin >> coin[i];
		cout <<fixed<<setprecision(10)<< f(0,(n-1)>>1)<<endl;
	}
	return 0;
}

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

int syou(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int kou(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
  int i,j,k,N,M;
  scanf("%d %d",&N,&M);
  int A[M],B[M];
  
  for(i=0;i<M;i++){
    scanf("%d %d",&A[i],&B[i]);
  }
  qsort(A,M,sizeof(int),kou);
  qsort(B,M,sizeof(int),syou);
  if(B[0]-A[0] >= 0)
    printf("%d\n",B[0]-A[0] +1);
  else
    puts("0");
  return 0;
}

Measured memory_bytes: 1396
#include <cstdio>
#pragma warning(disable : 4996)
int n, x, a[100009];
int main() {
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	bool flag = false;
	for (int i = 1; i < n && !flag; i++) {
		if (a[i] + a[i - 1] >= x) {
			flag = true;
			printf("Possible\n");
			for (int j = 1; j < i; j++) printf("%d\n", j);
			for (int j = n - 1; j > i; j--) printf("%d\n", j);
			printf("%d\n", i);
		}
	}
	if (!flag) printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int x;
	cin>>x;
	
	if(x<1200)cout<<"ABC"<<endl;
	else cout<<"ARC"<<endl;
	
    return 0;
}



Measured memory_bytes: 256
import numpy as np

N, W = map(int, input().split())
knap = []

for _ in range(N):
    knap.append(tuple(map(int, input().split())))
    
dp = np.zeros((N+1, W+1), dtype=np.int64)

for i, (w, v) in enumerate(knap):
    dp[i+1] = np.maximum(dp[i+1], dp[i])
    dp[i+1][w:] = np.maximum(dp[i][w:], dp[i][:-w]+v)
       
print(dp[N][-1])

Measured memory_bytes: 106320
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  bool a[10];
  rep(i,10)a[i]=0;
  int cnt=0;
  rep(i,n){
    int x;cin>>x;
    if(x>=3200)cnt++;
    else a[x/400]=true;
    }
  int ans=0;
  rep(i,10)ans+=a[i];
  if(ans==0)cout<<"1 "<<cnt<<endl;
  else cout<<ans<<" "<<ans+cnt<<endl;
  return 0;
  }

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

s=0
flag = True

if N==1:
    print("Yes")
    exit()

for i in range(N-1):
    s = max(s,H[i])
    if s-H[i+1]>1:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N;
    cin >> N;

    vector<i64> A(N),x(N);
    rep(i,0,N){
        cin >> A[i];
        x[i]=A[i]-i-1;
    }
    sort(begin(x),end(x));

    vector<i64> bs;
    if(N%2) bs.push_back(x[N/2]);
    else{
        i64 m=(x[N/2]+x[N/2-1])/2;
        rep(i,-2,3) bs.push_back(m+i);
    }

    cerr << bs << endl;

    i64 ans=inf64;
    rep(i,0,bs.size()){
        i64 b=bs[i],tmp=0;
        rep(j,0,N) tmp+=abs(A[j]-(b+j+1));
        ans=min(ans,tmp);
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3456
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define MAXN 206
using namespace std;
bool vis[MAXN];
int match[MAXN],a,n,m,ans,p,x[MAXN],y[MAXN],x0,y0;
vector<int> road[MAXN];
bool find(int x)
{
	for(int i=0;i<(int)road[x].size();i++)
	{
		int next=road[x][i];
		if(vis[next]) continue;
		vis[next]=1;
		if(!match[next]||find(match[next]))
		{
			match[next]=x;
			return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x0,&y0);
		for(int j=1;j<=n;j++)
			if(x0>x[j]&&y0>y[j]) road[i].push_back(j);
	}
	for(int i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		if(find(i)) ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define OUT(a) cout<<(a)<<endl;
#define ALL(v) (v).begin(), (v).end()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
const LL LINF=1ll<<62; const int INF=1ll<<30; const LL MOD=1E9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,l[100010]={},h[100010],ans=1;
    cin >>n;
    fill(l,l+100010,1);
    fill(h,h+100010,INF);
    vector<LL> t(n+1),a(n+1);
    REP(i,n) cin >> t[i+1];
    REP(i,n) cin >> a[i];
    a[n]=0;

    REPN(i,1,n){
        if(t[i]>t[i-1]) l[i]=h[i]=t[i];
        else h[i]=t[i];
    }
    REP(i,n){
        if(a[n-1-i]>a[n-i]){
            l[n-i]=max(l[n-i],a[n-1-i]);
            h[n-i]=min(h[n-i],a[n-1-i]);
        }else{
            l[n-i]=max(1ll,l[n-i]);
            h[n-i]=min(h[n-i],a[n-1-i]);
        }
    }

    REPN(i,1,n){
        if(l[i]>h[i]){
            ans=0;
            break;
        }else{
            ans=(ans*(h[i]-l[i]+1)%MOD);
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3328
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a: Int = sc.nextInt()
    val op: String = sc.next()
    val b: Int = sc.nextInt()
    if (op == "+") {
        println(a + b)
    } else {
        println(a - b)
    }
}

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

#define ll long long

int N, K, G[5000], C[5000];
vector < int > costs, vis;

void dfs(int u){
	vis[u] = true;
	costs.push_back(C[u]);
	if (!vis[G[u]])
		dfs(G[u]);
	else
		return;
}

int main(){
	cin >> N >> K;
	for (int i = 0; i < N; i ++){
		int X; cin >> X; X -= 1;
		G[i] = X;
	}
	for (int i = 0; i < N; i ++)
		cin >> C[i];
	long long result = -2e18;
	for (int i = 0; i < N; i ++){
		vis = vector < int > (N, 0);
		costs.clear();
		dfs(G[i]);
		int sz = costs.size();
		int p0 = K / sz, p1 = K % sz;
		long long curr1 = 0;
		for (int i = 0; i < costs.size() && i < K; i ++){
			curr1 += costs[i];
			result = max(curr1, result);
		}
		if (p0 > 0){
			long long curr2 = accumulate(costs.begin(), costs.end(), 0ll) * (p0);
			for (int i = 0; i < costs.size() && i < p1; i ++){
				curr2 += costs[i];
				result = max(curr2, result);
			}
		}
		if (p0 > 1){
			long long curr3 = accumulate(costs.begin(), costs.end(), 0ll) * (p0 - 1);
			for (int i = 0; i < costs.size() && i < K; i ++){
				curr3 += costs[i];
				result = max(curr3, result);
			}
		}
	}
	cout << result << "\n";
}


Measured memory_bytes: 3680
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1];

            Console.WriteLine((A + B) % 24);
        }
    }
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,ll> ii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 1000005;
/*
	|x1-x2| + |y1-y2|:
	ordenate over x:
	x2 >= x1, then |x1-x2| = (x2-x1)
	also if y1 >= y2 : |y1-y2| = (y1-y2)
	otherwise |y1-y2| = (y2-y1)
*/
int main(){
	fastio;
	int n;
	cin >> n;
	vector<ii> v(n);
	for(int i = 0; i < n; i++)
		cin >> v[i].fst >> v[i].snd;
	sort(all(v), [](const ii a, const ii b){
		if(a.fst != b.fst)
			return a.fst < b.fst;
		return a.snd < b.snd;
	});
	ii a = {0,0},b = {mod,mod};
	for(int i = 0; i < n; i++){ // (x2+y2)-(x1+y1)
		int x = v[i].fst, y = v[i].snd;
		if(x + y > a.fst + a.snd)
			a = v[i];
		if(y <= a.snd){
			if(x + y < b.fst + b.snd)
				b = v[i];
		}
	}
	ll ans = abs((a.fst + a.snd)-(b.fst+b.snd));
	a = {0, mod};
	b = {mod, 0};
	for(int i = 0; i < n; i++){ // (x2-y2)-(x1-y1)
		ll x = v[i].fst, y = v[i].snd;
		if(x - y > a.fst - a.snd)
			a = v[i];
		if(y >= a.snd){
			if(x - y < b.fst - b.snd)
				b = v[i];
		}
	}
	ans = max(ans, abs((a.fst-a.snd)-(b.fst-b.snd)));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6300
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

bool issq(int n){
    int i=1;
    while(i*i<=n){
        if(i*i==n){
            return true;
        }
        i++;
    }
    return false;
}
int main(){
    int N;
    cin >>N;
    int a[N+1];
    int count=0;
    a[0]=-1;
    FOR(i,N){
        cin >>a[i+1];
    }
    int box[N+1]={0};
    for(int i=N;i>N/2;i--){
        box[i]=a[i];
        if(box[i]==1)count++;
    }
    for(int i=N/2;i>0;i--){
        int tmp=0;
        int k=2;
        while(i*k<N+1){
            tmp+=box[i*k];
            k++;
        }
        tmp%=2;
        box[i]=tmp xor a[i];
        if(box[i]==1)count++;
    }
    
    cout <<count<<endl;
    FOR(i,N+1){
        if(box[i]==1){
            cout<<i<<endl;
        }    
    }
    return 0;
}




Measured memory_bytes: 2432
def Warshall_Floyd(edges,N):
  import copy
  d=copy.deepcopy(edges)
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

H,W=map(int,input().split())
path1=[list(map(int,input().split())) for i in range(10)]
Path=Warshall_Floyd(path1,10)
ans=0
for i in range(H):
  w=list(map(int,input().split()))
  for j in range(W):
    if w[j]==-1: continue
    ans+=Path[w[j]][1]
print(ans)

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

const int nil = -1;
const int MAX = 100001;

struct Node{int parent,left_child,right_brother;};
Node node_array[MAX];
int depth_array[MAX];

void set_depth(int node_number,int depth){
    depth_array[node_number] = depth;
    int r = node_array[node_number].right_brother;
    if(r != nil){
        set_depth(r,depth);
    }
    int l = node_array[node_number].left_child;
    if(l != nil){
        set_depth(l,depth+1);
    }
}

void print(int n){
    int i,c;
    cout << "node " << n << ": ";
    cout << "parent = " << node_array[n].parent << ", ";
    cout << "depth = " << depth_array[n] << ", ";
    
    if(node_array[n].parent == -1) cout << "root, ";
    else if(node_array[n].left_child == -1) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for(i=0,c = node_array[n].left_child; c != -1;i++, c = node_array[c].right_brother){
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        node_array[i].left_child = node_array[i].parent = node_array[i].right_brother = nil;
    }
    for(int i=0;i<n;i++){
        int node_number,deg;
        cin >> node_number >> deg;
        int left;
        for(int j=0;j<deg;j++){
            int c;
            cin >> c;
            if(j == 0){
                node_array[node_number].left_child = c;
            }else{
                node_array[left].right_brother = c;
            }
            left = c;
            node_array[c].parent = node_number;
        }
    }
    int root;
    for(int i=0;i<n;i++){
        if(node_array[i].parent == nil){
            root = i;
        }
    }

    set_depth(root,0);
    for(int i=0;i<n;i++){
        print(i);
    }
}




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

int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    if (n > a + b)
    {
        long long r = n % (a + b);
        if (r <= a)
        {
            cout << (a * (n / (a + b)) + r) << endl;
        }
        else
        {
            cout << (a * (n / (a + b)) + a) << endl;
        }
    }
    else
    {
        if (n <= a)
        {
            cout << n << endl;
        }
        else
        {
            cout << a << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[4]={0};
  string s[4]={"AC","WA","TLE","RE"};
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    string t;
    cin>>t;
    for(int j=0;j<4;j++)
    {
      if(t==s[j]) a[j]++;
    }
  }
  cout<<"AC x "<<a[0]<<"\n";
  cout<<"WA x "<<a[1]<<"\n";
  cout<<"TLE x "<<a[2]<<"\n";
  cout<<"RE x "<<a[3]<<"\n";
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX = 1e5 + 50 ;
const ll oo = 1e16;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , q , ans; string s ;
string pat = "AGCT";

ll dp[101][5][5][5];
bool check(int i , int j , int k , int p){

    string tmp = "";
    for(int l = 0 ; l < 4 ; ++l)
        tmp.pb('A');

    tmp[0] = pat[i]; tmp[1] = pat[j]; tmp[2] = pat[k]; tmp[3] = pat[p];

     if((tmp[0] == 'A' && tmp[1] =='G' && tmp[2] == 'C' ) || (tmp[1] == 'A' && tmp[2] =='G' && tmp[3] == 'C' ))
            return false;

    for(int l = 0 ; l < 3 ; ++l){
        swap(tmp[l] , tmp[l + 1]);
        if((tmp[0] == 'A' && tmp[1] =='G' && tmp[2] == 'C' ) || (tmp[1] == 'A' && tmp[2] =='G' && tmp[3] == 'C' ))
            return false;

        swap(tmp[l] , tmp[l + 1]);
    }
   // cout << tmp << '\n';
    return true;
}

ll solve(int i , int prev1 , int prev2 , int prev3){

        if(i == n){
            //cout << pat[prev1] << pat[prev2] << pat[prev3] << '\n';
            return 1LL;

        }


        ll &ret = dp[i][prev1][prev2][prev3];

        if(~ret)
            return ret ;

        ll ans = 0 ;
        for(int j = 0 ; j < 4 ; ++j)
                if(check(prev1 , prev2 , prev3 , j))
                    ans += solve(i + 1 , prev2 , prev3 , j)%MOD , ans %= MOD;

        return ret = ans;

}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n ;

    for(int i = 0 ; i < n ; ++i)
        for(int j = 0 ; j < 5 ; ++j)
            for(int k = 0 ; k < 5 ; ++k)
                for(int p = 0 ; p < 5 ; ++p)
                    dp[i][j][k][p] = -1;

    cout << solve(0 , 3 , 3 , 3) << '\n';

     return 0;
}


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

    int main(){
        int x = 0, y = 0, z = 0;
        int m = 1000000, e = 0;
        while(cin >> e && e > 0){
            z = 0;
            while(z*z*z <= e){
                z++;}
            z--;
            REP(i,z+1){
                y = 0;
                while(y*y <= e-i*i*i){
                    y++;
                }
                y--;
                x = e - y*y - i*i*i;
                m = min(x+y+i,m);
            }
            cout << m << endl;
            m = 1000000;
        }
        return 0;
    }

Measured memory_bytes: 1160
N,K =map(int,input().split())
D =[i for i in input().split()]
s =True
while True:
  Ns =str(N)
  for i in D:
    if i in Ns:
      s =False
  if not s:
    s =True
    N += 1
  else:
    break
print(N)
    

Measured memory_bytes: 2940
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = N.iota.map!(_ => readln.split.map!(to!int).array).array;
    A.sort!"a[0] < b[0]";

    int p = 0;
    long ans = 0;
    auto pq = new BinaryHeap!(Array!int, "a < b");

    foreach_reverse (i; 0..M+1) {
        while (p < N && i + A[p][0] <= M) {
            pq.insert(A[p][1]);
            ++p;
        }
        if (!pq.empty) {
            ans += pq.front;
            pq.removeFront;
        }
    }

    ans.writeln;
}


Measured memory_bytes: 12760
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
string s, t;

int32_t main(){_
      
   cin >> s >> t;

   cout<<t+s;


   return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int n,q,i,t,x,ansa[200005],ansb[200005],mna,mnb;
long long ans;
set<int> a,b;
int main()
{
	scanf("%d %d",&n,&q);
	mna=mnb=n-2;
	ans=1ll*(n-2)*(n-2);
	while(q--)
	{
		scanf("%d %d",&t,&x);
		if(t==1)
		{
			auto it=a.lower_bound(x);
			if(it!=a.begin())
			{
				--it;
				ansa[x]=ansa[*it];
			}
			else
				ansa[x]=mnb;
			ans-=ansa[x];
			mna=min(mna,x-2);
			a.insert(x);
		}
		else
		{
			auto it=b.lower_bound(x);
			if(it!=b.begin())
			{
				--it;
				ansb[x]=ansb[*it];
			}
			else
				ansb[x]=mna;
			ans-=ansb[x];
			mnb=min(mnb,x-2);
			b.insert(x);
		}
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 14624