akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

void doRoutine() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    srand(322179);
#ifdef LOCAL
    freopen("/root/alg/clion_main/input.txt", "rt", stdin);
    freopen("/root/alg/clion_main/output.txt", "wt", stdout);
#endif
}

#define DBG(VAR) cerr << #VAR << ": " << VAR << endl

#define all(x) x.begin(), x.end()
#define vb vector<bool>
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define vc vector

#ifndef LOCAL
#define cerr if(0) cerr
#define DBG(...) (true)
#endif

#define D double
#define int long long

// ----------------------------- CODE NOW ------------------------


const int MAXN = 20;

char a[MAXN], b[MAXN];

map<pair<string, string>, int> cnt;


signed main() {
    doRoutine();

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

    for (int mask = 0; mask < (1 << n); ++mask) {
        string s1, s2;
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                s1.pb(a[i]);
            }
            else {
                s2.pb(a[i]);
            }
        }
        ++cnt[{s1, s2}];
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << n); ++mask) {
        string s1, s2;
        for (int i = 0; i < n; ++i) {
            if (mask & (1 << i)) {
                s1.pb(b[i]);
            }
            else {
                s2.pb(b[i]);
            }
        }
        reverse(all(s1));
        reverse(all(s2));
        ans += cnt[{s2, s1}];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 87040
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] h = new int[n+1];
			for(int i=0;i<=n;i++){
				h[i] = sc.nextInt();
			}
			if(n==4){
				if(h[3]-h[2]==h[2]-h[1] && h[2]-h[1]==h[1]-h[0]){
					System.out.println(h[4]);
				}else if(h[4]-h[2]==h[2]-h[1] && h[2]-h[1]==h[1]-h[0]){
					System.out.println(h[3]);
				}else if(h[4]-h[3]==h[3]-h[1] && h[3]-h[1]==h[1]-h[0]){
					System.out.println(h[2]);
				}else if(h[4]-h[3]==h[3]-h[2] && h[3]-h[2]==h[2]-h[0]){
					System.out.println(h[1]);
				}else{
					System.out.println(h[0]);
				}
		
			}else if(n>4){
				int sub = 0;
				int[] d = new int[5];
				for(int i=0;i<5;i++){
					d[i] = h[i+1]-h[i];
				}
				Arrays.sort(d);
				sub = d[2];
				
				for(int i=0;i<n;i++){
					if(h[i+1]-h[i]!=sub){
						if(i==n-1){
							System.out.println(h[i+1]);
							break;
						}else if(h[i+2]-h[i+1]!=sub){
							System.out.println(h[i+1]);
							break;
						}else{
							System.out.println(h[i]);
							break;
						}
					}
				}
			}
			
		}
	}
}

Measured memory_bytes: 35532
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VV<> d; assign(d, n, n, (int) 1e9);
  for (int i = 0; i < n; ++i) d[i][i] = 0;
  for (int i = 0; i < m; ++i) {
    int s, t, _d; cin >> s >> t >> _d;
    d[s][t] = _d;
  }
  VV<> dp; assign(dp, 1 << n, n, (int) 1e9);
  dp[0][0] = 0;
  for (int bit = 0; bit < 1 << n; ++bit) for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
    dp[bit][i] = min(dp[bit][i], dp[bit ^ 1 << i][j] + d[j][i]);
  }
  int res = dp.back()[0] != 1e9 ? dp.back()[0] : -1;
  cout << res << '\n';
}


Measured memory_bytes: 6232
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// nの約数を昇順に列挙したvectorを返す。計算量はO(√n)
vector<ll> yakusu(ll n) {
    vector<ll> res;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) {
            res.pb(i);
            if(i != n/i) {
                res.pb(n/i);
            }
        }
    }
    sort(all(res));
    return res;  
}

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

    if(n == 1) {
        out(m);
        re0;
    }

    ll k = m/n;  // 答えはk以下のmの素因数の最大値
    vl v = yakusu(m);

    ll ans;
    for(auto p : v) {
        if(p <= k) {
            ans = p;
        }
        else {
            out(ans);
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//説明用//
int main (){
	int N;//リンゴの個数
  	int L;//リンゴの味の一部
  	int ans;//アップルパイの味
  	int A;//食べるリンゴの味　
  	int F;//リンゴが0未満の味があった時のフラグ
  	int C;//リンゴの味が0未満かつ正と負の数があった場合のフラグ
 	int	T[N];//各リンゴの味
  	N = L = ans = A = F = C = 0;
  	cin >> N >> L; 
  	for (int i = 1;i<=N;i++){
    	T[i] = L + i -1;//各リンゴの味を算出
      	if(T[i]<0){//リンゴの味が負数であれば正数にする
        	T[i] = T[i]*-1;
          	F = 1;
        }
    }
  	A = T[1];
    for(int i = 2;i<=N;i++){
        if(A > T[i] || T[i] == 0){//食べるリンゴを比較
        	A = T[i];
        }
    }
  	for (int i = 1;i<=N;i++){
      	if(T[i] == 0 && F == 1){//負と正数の味があれば正数にした味を負数に
      	 	while (i>=1){
         		T[i] = T[i] * -1;
           		i--;
         	}
         	C = 1;
        	break;
      	}
    }
    for (int i = 1;i<=N;i++){
      	if(F == 1 && C == 0){//すべて負数であれば正数にした味を負数に
        	i = N;
      	 	while (i>=1){
         		T[i] = T[i] * -1;
           		i--;
         	}
      	}
      	break;
    }
  	for(int i = 1;i<=N;i++){
    	ans += T[i]; //すべての味を加算し算出
    }
	if(ans < 0){
    	ans = ans + A;//ansが負数なら食べるリンゴを加算しAPの味を算出
    }
    else{
  		ans = ans - A;//ansが正数なら食べるリンゴを減算しAPの味を算出
    }
  	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
  
using namespace std;
  
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)break;
		
		
		vector<int> cand;
		reps(i,1,n+1)cand.push_back(i);
		
		int ind = cand.size()-1;
		
		while(1){
			rep(i,m){
				ind = (ind+1)%cand.size();
			}
			
			//printf("*%d %d\n",ind,cand[ind]);
			cand.erase(cand.begin()+ind);
			
			ind = (ind+cand.size()-1)%cand.size();
			
			if(cand.size()==1){
				printf("%d\n",cand[0]);
				break;
			}
		}
	}
}

Measured memory_bytes: 1208
s=input()
t=input()
ans=len(t)
cnt=0

for _ in range(len(s)):
  if _+len(t)>len(s):
    break
  mj=s[_:_+len(t)]
  for i in range(len(t)):
    if mj[i]!=t[i]:
      cnt += 1
  if ans>cnt:
    ans=cnt
  cnt=0
    
print(ans)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
const int N = 2e7+5;
typedef long long ll;
const int mod = 998244353;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
/* math */
int n,a,b;
int fac[N], ifac[N];
inline void init(int n = 2e7){
	fac[0] = ifac[0] = 1;for(int i=1;i<=n;i++)fac[i] = mul(fac[i-1], i);
	ifac[n] = qpow(fac[n], mod-2);for(int i=n-1;i;i--)ifac[i] = mul(ifac[i+1],i+1);
}
inline int binom(int a,int b){
	if(b>a)return 0;
	if(b==a)return 1;
	if(b<0)return 0;
	return mul(fac[a],mul(ifac[b],ifac[a-b]));
}

int main()
{
	init();
	cin >> n >> b >> a;
	int ans = 0;
	for(int j=0;j<=b;j++){
		int buc = a-j-(a-b), rest = n-a-j;
		if(rest < 0 || buc < 0)continue;
		if(rest == 0 && buc > 0)continue;
		// cout << a << " " << j << endl;
		int sum = sub(binom(a+j-1,j),binom(a+j-1,a));
		if(j==0 && a==0)sum = 1;
		int w = binom(buc+rest-1,rest-1);
		ans = add(ans, mul(sum,w));
	}
	cout << ans << endl;
}

Measured memory_bytes: 156544
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		
		int[]num=new int[26];
		
		for(int i=0;i<s.length();i++){
			num[s.charAt(i)-'a']++;
		}
		
		for(int i=0;i<26;i++){
			if(num[i]>=2){
				System.out.println("no");
				return;
			}
		}
		System.out.println("yes");
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    rep(i,A) cin >> p[i];
    rep(i,B) cin >> q[i];
    rep(i,C) cin >> r[i];
    ll ans = 0;
    gsort(p); gsort(q); gsort(r);
    int i = 0, iA = 0, iB = 0, iC = 0, iX = 0, iY = 0;
    while (i < X + Y) {
        int _maxR = (iX < X ? p[iA] : 0);
        int _maxG = (iY < Y ? q[iB] : 0);
        int _maxN = (iC > (C - 1) ? r[iC] : 0);
        int _max = max(max(_maxR, _maxG), r[iC]);
        if (_max == _maxR) {
            iA++;
            iX++;
        }
        else {
            if (_max == _maxG) {
                iB++;
                iY++;
            }
            else iC++;
        }
        ans += _max;
        i++;
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
	
	int n;
	long long k;
	cin >> n >> k;
	
	vector<long long> v(101010);
	for(int i = 0 ; i < n ; i ++){
		int x;
		long long f;
		cin >> x >> f;
		v[x] += f;
	}
	
	long long s = 0;
	for(int i = 0 ; i < 101010 ; i ++){
		s += v[i];
		if(s >= k){
			cout << i << "\n";
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define C(n,m) (jc[n]*Jc[m]%998244353*Jc[(n)-(m)]%998244353)
#define min(a,b) (a<b?a:b)
#define mod 998244353
#define Mod 998244351
#define ll long long
#define G 3
//#define file
using namespace std;

ll A[1048576],B[1048576],a[1048576],b[1048576],w[500001],jc[500001],Jc[500001],ans;
int N,len,n,m,i,j,k,l;

ll qpower(ll a,int b) {ll ans=1;while (b) {if (b&1) ans=ans*a%mod;a=a*a%mod;b>>=1;} return ans;}
void swap(int &x,int &y) {int z=x;x=y;y=z;}
ll dft(ll *a,int type)
{
	int i,j,k,l,S=N,s1=2,s2=1;
	
	fo(i,0,N-1)
	{
		j=i;k=0;
		fo(l,1,len) k=k*2+(j&1),j>>=1;
		A[k]=a[i];
	}
	memcpy(a,A,N*8);
	
	fo(i,1,len)
	{
		ll W=(type==1)?qpower(G,(mod-1)/s1):qpower(G,(mod-1)-(mod-1)/s1);
		S>>=1;
		
		fo(j,0,S-1)
		{
			ll w=1;
			fo(k,0,s2-1)
			{
				ll u=a[j*s1+k],v=a[j*s1+k+s2]*w;
				a[j*s1+k]=(u+v)%mod;
				a[j*s1+k+s2]=(u-v)%mod;
				w=w*W%mod;
			}
		}
		s1<<=1,s2<<=1;
	}
}

void mul(ll *a,ll *b)
{
	ll s=qpower(N,Mod);
	int i;
	
	memset(B,0,sizeof(B));
	memcpy(B,b,4*N);
	dft(a,1);
	dft(B,1);
	fo(i,0,N-1) a[i]=a[i]*B[i]%mod;
	dft(a,-1);
	fo(i,0,N/2-1) a[i]=a[i]*s%mod;
	fo(i,N/2,N-1) a[i]=0;
}

int main()
{
	#ifdef file
	freopen("agc035F.in","r",stdin);
	#endif
	
	scanf("%d%d",&n,&m);len=ceil(log2(n+1))+1;N=qpower(2,len);
	if (n>m) swap(n,m);
	jc[0]=jc[1]=Jc[0]=Jc[1]=w[1]=1;fo(i,2,500000) w[i]=mod-w[mod%i]*(mod/i)%mod,jc[i]=jc[i-1]*i%mod,Jc[i]=Jc[i-1]*w[i]%mod;
	
	fo(i,0,n) a[i]=qpower(n+1,m-i)*C(m,i)*qpower(-1,i)%mod; //or min(n,m)
	fo(i,0,n) b[i]=qpower(m,i)*Jc[i]%mod;
	mul(a,b);
	
	fo(i,0,n) ans=(ans+Jc[n-i]*a[i])%mod;
	fo(i,1,n) ans=ans*i%mod;
	printf("%lld\n",(ans+mod)%mod);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 42880
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;



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

    int x = k;

    for(int i = 0; i < n-1; i++)
    {
        x *= k-1;
    }

    cout << x << endl;
    
    return 0;
}

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

using namespace std;

int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    if(n<=k)cout<<s<<endl;
    else{
        string t;
        for(int i=0;i<k;i++){
            t.push_back(s[i]);
        }
        cout<<t<<"..."<<endl;
    }
}


Measured memory_bytes: 3632
from collections import deque

h,w=map(int, input().split())
S = [input() for _ in range(h)]

move=((1,0),(-1,0),(0,1),(0,-1))

def bfs(i,j): # 幅優先探索、マス i,j から始まる時の最長経路
    if S[i][j] == '#': # そのマスが壁ならスタート地点にならないのでパス
        return 0
    
    visited=[[0]*w for _ in range(h)] # 探索済のリスト
    visited[i][j]=1 # 最初のマスは探索済へ
    
    que=deque([(i,j,0)]) # キュー（queueは待ち行列）,各マスの情報をタプルにしてる
    
    while len(que)>0:
        ci,cj,d = que.popleft() #キューの左側から取り出してキューから削除

        for mi,mj in move: #moveで定義したそれぞれの動きについて
            ni,nj = ci+mi,cj+mj # 移動先の座標をni,njとしている。
            if 0 <= ni < h and 0 <= nj < w and visited[ni][nj]==0:
                if S[ni][nj] == '.':
                    visited[ni][nj] = 1
                    que.append((ni, nj, d+1))
    return d
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(ans)

Measured memory_bytes: 44396
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n, x, t; cin >> n >> x >> t;
    lol n2 = n/x;
    if(n%x != 0) n2++;
    result = n2*t;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt(), no = K, i = A, j = B;
		SortedSet<Integer> s = new TreeSet<Integer>();
		while (no-->0) {
			if (i>B) break;
			s.add(i++);
		}
		no = K;
		while (no-->0) {
			if (j<A) break;
			s.add(j--);
		}
		for (int a : s) System.out.println(a);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

struct train{
  int to;
  int64_t yen;
  int64_t snuke;
};

int main(){
  const int64_t INF=1e15;
  int n,m,s,t;
  cin >> n >> m >> s >> t;
  vector< vector<train> > V(n+1);
  for(int i=0;i<m;i++){
    int u,v;
    int64_t a,b;
    cin >> u >> v >> a >> b;
    V.at(u).push_back({v,a,b});
    V.at(v).push_back({u,a,b});
  }
  priority_queue<P,vector<P>, greater<P> > pq;
  vector<vector<int64_t> > cost(2,vector<int64_t> (n+1,INF));
  cost.at(0).at(s)=0;
  pq.push(make_pair(cost.at(0).at(s),s));
  while(!pq.empty()){
    P p=pq.top();
    pq.pop();
    int x=p.second;
    if(cost.at(0).at(x)<p.first){
      continue;
    }
    for(auto &e: V.at(x)){
      int y=e.to;
      if(cost.at(0).at(y)>cost.at(0).at(x)+e.yen){
        cost.at(0).at(y)=cost.at(0).at(x)+e.yen;
        pq.push(make_pair(cost.at(0).at(y),y));
      }
    }
  }

  cost.at(1).at(t)=0;
  pq.push(make_pair(cost.at(1).at(t),t));
  while(!pq.empty()){
    P p=pq.top();
    pq.pop();
    int x=p.second;
    if(cost.at(1).at(x)<p.first){
      continue;
    }
    for(auto &e: V.at(x)){
      int y=e.to;
      if(cost.at(1).at(y)>cost.at(1).at(x)+e.snuke){
        cost.at(1).at(y)=cost.at(1).at(x)+e.snuke;
        pq.push(make_pair(cost.at(1).at(y),y));
      }
    }
  }
  for(int i=1;i<=n;i++){
    pq.push(P(cost.at(0).at(i)+cost.at(1).at(i),i));
  }
  int64_t ans=1e15;
  cout << ans-pq.top().first << endl;
  for(int i=1;i<n;i++){
    while(pq.top().second<=i){
      pq.pop();
    }
    cout << ans-pq.top().first << endl;
  }
  return 0;
}


Measured memory_bytes: 14956
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;//都市の数
int m;//橋の数
/*クラスカル法*/
const int MAX_E = 110;
const int MAX_V = 110;
int V,E;//頂点数、辺の数
struct edge{
	int u,v,cost;//頂点uからvへのcost
	edge(int _u,int _v,int _cost){u =_u;v = _v;cost =_cost;};
};
vector<edge> es;
//union-find
int parent[MAX_V];//parent[x]=xの時xが根である
int rank[MAX_V];//木の高さ
void init(int V){
	for(int i= 0;i < V;i++){
		parent[i] = i;
		rank[i] =0;
	}
}

int find(int x){
	if(parent[x] == x)
		return x;
	else{
		return find(parent[x]);
	}
}

void unit(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y)
		return;
	if(rank[x] < rank[y]){
		parent[x] = y;
	}
	else{
		parent[y] = x;
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}
bool comp(const edge& e1,const edge& e2){
	return e1.cost <e2.cost;
}

int kruskal(){
	sort(es.begin(),es.end(),comp);
	init(V);
	int res = 0;
	for(int i = 0;i < E;i++){
		edge e = es[i];
		if(!same(e.u,e.v)){
			unit(e.u,e.v);
			res += e.cost;
		}
	}
	return res;
}


int main(){
	while(cin>>V>>E,V||E){
		es.clear();
		rep(i,E){
			int a,b,c;
			cin>>a>>b>>c;
			es.push_back(edge(a,b,c));
		}
		cout <<kruskal()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#!/usr/bin/env python3
#ABC102 B

N = int(input())
A = list(map(int,input().split()))

ans = 0
for i in range(1,N):
    for j in range(i):
        if ans < abs(A[i]-A[j]):
            ans = abs(A[i]-A[j])
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const int inf   = 1<<30;
const int mod=998244353;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

ll fact[1000001],invfact[1000001];

ll inv(ll n){
  ll ret=1,k=mod-2;
  while(k>0){
    if(k&1)ret=ret*n %mod;
    n=n*n %mod;
    k/=2;
    }
  return ret;
  }

ll comb(int n,int k){
  ll ret=invfact[k]*invfact[n-k] %mod;
  return fact[n]*ret %mod;
  }

int main(){   
  ll n,m;
  cin>>n>>m;
  fact[0]=invfact[0]=1;
  rep(i,n+m){
    fact[i+1]=fact[i]*(i+1) %mod;
    invfact[i+1]=inv(fact[i+1]);
    }
  ll ans=0;
  if(n<m)swap(n,m);
  for(int i=n-m;i<n+m;i+=2){
    int k=(i-n+m)/2;
    ans+=comb(i,k)*comb(n+m-i,m-k);
    ans%=mod;
    }
  ans=ans*inv(comb(n+m,n)) %mod;
  cout<<(ans*inv(2)+n)%mod<<endl;
  return 0; 
  }

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
const int INF = 100000000;
typedef pair<int, int> P;

struct edge{
	int to;
	int cost;
};

int N, M;
vector<edge> G[100];
int d[100][100], dist[100];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(dist, dist+N, INF);
	dist[s] = 0;
	que.push(P(0, s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(int i=0; i<G[v].size(); i++){
			edge e = G[v][i];
			if(dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}
	for(int i=0; i<N; i++) d[s][i] = dist[i];
}

int main(){
	cin >> N >> M;
	int a[M], b[M], c[M];
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			d[i][j] = INF;
		}
		d[i][i] = 0;
	}
	for(int i=0; i<M; i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
		edge e1 = {b[i], c[i]}, e2 = {a[i], c[i]};
		G[a[i]].push_back(e1);
		G[b[i]].push_back(e2);
	}
	for(int i=0; i<N; i++) dijkstra(i);
	int ans = 0;
	for(int i=0; i<M; i++){
		bool flag = true;
		for(int j=0; j<N; j++){
			for(int k=0; k<N; k++){
				if(c[i] + d[j][a[i]] + d[b[i]][k] == d[j][k] || c[i] + d[j][b[i]] + d[a[i]][k] == d[j][k]){
					flag = false;
				}
			}
		}
		if(flag) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace  std;

int main() {
	long long int N;
	cin >> N;
	string ans = "", alphabet = "abcdefghijklmnopqrstuvwxyz";
	vector<int> data(100);
	while (N > 0) {
		N--;
		ans += alphabet[N%26];
		N /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <algorithm>
using namespace std;

int N;
int A[100010];
int cc[100010];

void solve()
{
	sort(A, A+N);
	int i;
	int cnt = 1;
	for(i=1; i<N; i++){
		if(A[i] == A[i-1])
			cnt ++;
		else{
			cc[cnt] ++;
			cnt = 1;
		}
	}
	cc[cnt] ++;
	int res = 0;
	for(i=N; i>=3; i--){
		if(cc[i] == 0)
			continue;
		if(i % 2 == 1){
			res += (i-1)/2 * cc[i];
		}
		else{
			res += (i-2)/2 * cc[i];
			cc[2] += cc[i];
		}
	}
	res += cc[2]/2;
	if(cc[2] % 2 == 1)
		res ++;
	printf("%d\n", N-res*2);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d", &A[i]);
	solve();
	return 0;
}

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

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

int main(void){
    int N; cin >> N;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int a; cin >> a;
        while(a % 2 == 0){
            cnt++;
            a /= 2;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,i,j,k;scanf("%d%d",&h,&w);
  int a[h][w],b[h][w],c[h][w],MAX = (h+w-1)*80;bool dp[h][w][MAX*2+1] = {};//-MAX is 0,MAX is MAX*2
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) scanf("%d",&a[i][j]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) scanf("%d",&b[i][j]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) c[i][j] = abs(a[i][j]-b[i][j]);
  }
  dp[0][0][c[0][0]+MAX] = 1;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(i==0 && j==0) continue;
      if(i!=0){
        for(k=0;k<=MAX*2;k++){
          dp[i][j][k] |= dp[i-1][j][k-c[i][j]];
          dp[i][j][k] |= dp[i-1][j][k+c[i][j]];
        }
      }
      if(j!=0){
        for(k=0;k<=MAX*2;k++){
          dp[i][j][k] |= dp[i][j-1][k-c[i][j]];
          dp[i][j][k] |= dp[i][j-1][k+c[i][j]];
        }
      }
    }
  }
  for(i=MAX;i<=MAX*2;i++){
    if(dp[h-1][w-1][i]){
      printf("%d\n",i-MAX);return 0;
    }
    if(dp[h-1][w-1][MAX*2-i]){
      printf("%d\n",i-MAX);return 0;
    }
  }
}

Measured memory_bytes: 159360
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,a[200000];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    map<int,int>mp;
    for(int i=0;i<n;i++)
        mp[a[i]]++;
    int sum=0;
    for(auto x:mp)
        sum+=x.second*(x.second-1)/2;
    for(int i=0;i<n;i++)
        cout<<sum-mp[a[i]]+1<<endl;
}


Measured memory_bytes: 11776
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  double p = 1/pow(2, M);
  int t = 1900*M+100*(N-M);
  double ans = 0, q = 1;
  for(int i = 1; ; i++) {
    if(t*i*q*p <= 0)
      break;
    ans += t*i*q*p;
    q *= 1-p;
  }
  cout << floor(ans+0.5) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int s, w;
	while(scanf("%d%d", &s, &w)==2)
	{
		bool ans=(s>w);

		printf("%s\n", ans?"safe":"unsafe");
	}
	return 0;
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int n,m,u[10];
vector<int> v;

void w(int x, int y){
    for(int i=0;i<y;i++){
        v.push_back(u[x]);
        n-=x;
    }
}

bool b(int x){
    return u[x]>0;
}

int main(void){
    cin>>n>>m;
    fill(u, u+10, 0);
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        if(a==1)u[2]=1;
        if(a==2)u[5]=max(u[5],2);
        if(a==3)u[5]=max(u[5],3);
        if(a==4)u[4]=4;
        if(a==5)u[5]=5;
        if(a==6)u[6]=max(u[6],6);
        if(a==7)u[3]=7;
        if(a==8)u[7]=8;
        if(a==9)u[6]=9;
    }
    if(b(2)){
        if(n%2==1){
            if(b(3))w(3, 1);
            else if(b(5))w(5, 1);
            else if(b(7))w(7, 1);
        }
        w(2, n/2);
    }else if(b(3)){
        if(n%3==1){
            if(b(4))w(4, 1);
            else if(b(7))w(7, 1);
            else if(b(5))w(5, 2);
        }else if(n%3==2){
            if(b(5))w(5, 1);
            else if(b(4))w(4, 2);
            else if(b(7))w(7, 2);
        }
        w(3, n/3);
    }else if(b(4)){
        if(n%4==1){
            if(b(5))w(5, 1);
            else if(b(6)&&b(7))w(6, 1),w(7, 1);
            else if(b(7))w(7, 3);
        }else if(n%4==2){
            if(b(6))w(6, 1);
            else if(b(5))w(5, 2);
            else if(b(7))w(7, 2);
        }else if(n%4==3){
            if(b(7)&&(n==7||u[6]!=9||!b(5)))w(7, 1);
            else if(b(5)&&b(6))w(5, 1),w(6, 1);
            else if(b(5))w(5, 3);
        }
        w(4, n/4);
    }else if(b(5)){
        if(b(6)&&b(7)&&u[6]==9&&n%5>1){
            if(n%5==2){
                if(n==7)w(7, 1);
                else w(6, 2);
            }else if(n%5==3){
                if(n==13)w(6, 1),w(7, 1);
                else w(6, 3);
            }else{
                if(n==14)w(7, 2);
                else if(n==19)w(7, 1),w(6, 2);
                else w(6, 4);
            }
        }else if(n%5==1){
            if(b(6))w(6, 1);
            else if(b(7))w(7, 3);
        }else if(n%5==2){
            if(b(7))w(7, 1);
            else if(b(6))w(6, 2);
        }else if(n%5==3){
            if(b(7)&&b(6))w(7, 1),w(6, 1);
            else if(b(6))w(6, 3);
            else if(b(7))w(7, 4);
        }else if(n%5==4){
            if(b(7))w(7, 2);
            else if(b(6))w(6, 4);
        }

        w(5, n/5);
    }else if(b(6)){
        if(n%6>0){
            w(7, n%6);
        }
        w(6, n/6);
    }else{
        w(7, n/7);
    }
    sort(v.begin(),v.end(),greater<int>());
    for(int i=0;i<v.size();i++){
        cout<<v[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
def factorize(n):
    fct = []
    tmpN, cnt = 2, 0
    while tmpN * tmpN <= n:
        while n % tmpN == 0:
            n = n // tmpN
            cnt += 1
        if cnt > 0:
            fct.append([tmpN, cnt])
        tmpN, cnt = tmpN + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct

N = int(input())

a = 1
for i in range(1,N+1):
    a *= i
N = a

lis = factorize(N)

ans = 1
for l in lis:
    ans *= (l[1] + 1)
    ans %= 1000000007
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[6]={0,9,0,900,0,90000};
int main()
{
	int n,n1,tot=0,ans=0,t1=1;
	scanf("%d",&n);
	n1=n;
	while(n1)
	tot++,n1/=10,t1*=10;
	t1/=10;
	for(int i=1;i<tot;i+=2)
		ans+=a[i];
	if(tot%2==1)
	ans+=n-t1+1;
	printf("%d",ans);
}

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

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

Measured memory_bytes: 640
import bisect as bs
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
    a = bs.bisect_left(A, b)
    c = N - bs.bisect_right(C, b)
    ans += a * c
print(ans)

Measured memory_bytes: 107108
n = int(raw_input())
ls = map(int, raw_input().split())
ct = 0
l = 0
r = 0
x = ls[0]
while l < n:
    while r < n-1:
        if x + ls[r+1] == x ^ ls[r+1]:
            r += 1
            x ^= ls[r]
        else:
            break
    ct += r - l + 1
    x ^= ls[l]
    l += 1
print ct


Measured memory_bytes: 19996
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    vector<int> v;
    rep(i, 3){
        int x; cin >> x; v.push_back(x);
    }
    sort(all(v), greater<int>());
    cout << v[0] * 10 + v[1] + v[2] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    A[i] -= i+1;
  }
  sort(A.begin(),A.end());
  ll ans = 0;
  if(N%2){
    ll mid = A[N/2];
    for(int i=0; i<N; i++){
      ans += abs(mid-A[i]);
    }
  }else{
    ll mid = (A[N/2]+A[N/2-1])/2;
    for(int i=0; i<N; i++){
      ans += abs(mid - A[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
 
using namespace std;
int main() {
  int k,a,b;
  cin>>k;
  cin>>a>>b;
  
 if(b/k-a/k>0 ||a%k==0 ||b%k==0){
   cout<<"OK"<<endl;
 }
  else{
    cout<<"NG"<<endl;
 }
}


Measured memory_bytes: 3552
#include<stdio.h>
#include<stdlib.h>
const int NIL = -1;
const int MAXSIZE = 100000 + 2;
struct Node {
	int parent, left, right;
};
Node Tree[MAXSIZE];
int Depth[MAXSIZE];
void Get_depth(int node_id, int depth) {
	Depth[node_id] = depth;
	if (Tree[node_id].right != NIL)	Get_depth(Tree[node_id].right, depth);
	if (Tree[node_id].left != NIL)	Get_depth( Tree[node_id].left, depth + 1);
}
void Print(int node_id) {
	printf("node %d: ", node_id);
	printf("parent = %d, ", Tree[node_id].parent);
	printf("depth = %d, ", Depth[node_id]);
	if (Tree[node_id].parent == NIL)	printf("root, ");
	else if (Tree[node_id].left == NIL)	printf("leaf, ");
	else printf("internal node, ");

	printf("[");
	for (int i = 0, c = Tree[node_id].left; c != NIL; c = Tree[c].right, i++) {
		if (i) printf(", ");
		printf("%d", c);
	}
	printf("]\n");
}
int main() {
	int num_node = 0;
	int parent_id= 0, out_connect = 0;
	scanf("%d", &num_node);
	for (int i = 0; i < num_node; i++) {
		Tree[i].right = Tree[i].left = Tree[i].parent = NIL;
	}
	for (int i = 0; i < num_node; i++) {
		int c = 0;
		int son_tree;
		scanf("%d %d", &parent_id, &out_connect);
		for (int j = 0; j < out_connect; j++) {
			scanf("%d", &c);
			if (j == 0) Tree[parent_id].left = c;
			else 	Tree[son_tree].right = c;
			son_tree = c;
			Tree[c].parent = parent_id;
		}
	}
	int root_id = -1;
	for (int i = 0; i < num_node; i++) {
		if (Tree[i].parent == NIL) {
			root_id = i;
		}
	}
	Get_depth(root_id, 0);
	for (int i = 0; i < num_node; i++) {
		Print(i);
	}

	return 0;
}

Measured memory_bytes: 7308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    do{
        int sq = sqrt(n);
        if(sq * sq == n){
            cout << n << endl;
            return 0;
        }
    }while(n--);
}


Measured memory_bytes: 256
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

bool comp(P a , P b){

    int val1 = a.F + a.S;
    int val2 = b.F + b.S;

    if(val1 < val2)return true;
    // if(val1 < val2)return a;
    return false;

    // return 

}


bool comp2(P a , P b){

    int val1 = a.F - a.S;
    int val2 = b.F - b.S;

    if(val1 < val2)return true;
    // if(val1 < val2)return a;
    return false;

    // return 

}

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    P arr[n];

    for(int i=0;i<n;i++){
        cin>>arr[i].F>>arr[i].S;
    }  

    sort(arr , arr + n ,comp);
    ans = max(ans  , arr[n- 1].F + arr[n  -1].S - arr[0].F - arr[0].S );
    // for(int i=0; i<n - 1; i++) {
    // }
    sort(arr , arr + n ,comp2);
    ans = max(ans  , arr[n- 1].F - arr[n  -1].S - arr[0].F + arr[0].S );

    // for(int i=1; i<n; i++) {
    //     ans = max(ans ,abs(arr[i].F - arr[0].F) + abs(arr[i].S - arr[0].S) );
    // }

    // ans = abs(arr[0].F - arr[n - 1].F) + abs(arr[0].S - arr[n - 1].S);

    cout<<ans<<endl; 

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 6716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    if(n==1 && m==1){
        cout<<1<<endl;
    }
    else if(n==1){
        cout<<m-2<<endl;
    }else if(m==1){
        cout<<n-2<<endl;
    }else{
        cout<<(n-2)*(m-2)<<endl;
    }
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
int H;
int *T;
int parent(int i){return i / 2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

void maxHeapify(int *A,int i){
	int l = left(i);
	int r = right(i);
	int largest = i;
	if(l <= H && A[l] > A[i]){
		largest = l;
	}
	if(r <= H && A[r] > A[largest]){
		largest = r;
	}
	if(largest != i){
		swap(A[i],A[largest]);
		maxHeapify(A,largest);
	}
}

int main(){
	cin >> H;
	T = new int[H+1];
	for(int i = 1;i <= H;i++) cin >> T[i];
	for(int i = H/2;i >= 1;i--) maxHeapify(T,i);
	for(int i = 1;i <= H;i++){
		if(i != H) cout << " " << T[i];
		else cout << " " << T[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
void solve() {
    int n;
    cin >> n;
    pair<int, int> a[n];
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[i] = {x + y, x - y};
    }
    sort(a,a+n);
    int cur = INT_MIN;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(cur <= a[i].second){
            ans++;
            cur = a[i].first;
        }
    }
    cout<<ans<<endl;


}
int32_t main() {
    IOS;
    int test = 1;
    //cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
int h,w;
int a[81][81];
int b[81][81];
bool valid(int x,int y)
{
	if(x>h || y>w) return false;
	return true;
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>h>>w;
	repA(i,1,h)
	{
		repA(j,1,w)
		{
			cin>>a[i][j];
		}
	}
	int maxn=0;
	repA(i,1,h)
	{
		repA(j,1,w)
		{
			cin>>b[i][j];
			maxn=max(maxn,abs(a[i][j]-b[i][j]));
		}
	}
	maxn=(h+w)*maxn;
	maxn+=1;
	bool dp[h+1][w+1][maxn];
	memset(dp,false,sizeof(dp));
	//dp[0][0][0]=true;
	dp[1][1][abs(a[1][1]-b[1][1])]=true;
	repA(i,1,h)
	{
		repA(j,1,w)
		{
			rep(k,maxn)
			{
				if(dp[i][j][k])
				{
					if(valid(i+1,j))
					{
						int val1=k+abs(a[i+1][j]-b[i+1][j]);
						if(val1<maxn) dp[i+1][j][val1]=true;
						int val2=abs(k-abs(a[i+1][j]-b[i+1][j]));
						if(val2<maxn) dp[i+1][j][val2]=true;
					}
					if(valid(i,j+1))
					{
						int val1=k+abs(a[i][j+1]-b[i][j+1]);
						if(val1<maxn) dp[i][j+1][val1]=true;
						int val2=abs(k-abs(a[i][j+1]-b[i][j+1]));
						if(val2<maxn) dp[i][j+1][val2]=true;
					}
				}
			}
		}
	}
	ll ans=maxn;
	repD(i,maxn-1,0)
	{
		if(dp[h][w][i]) ans=i;
	}
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 85704
#include <stdio.h>

int main(){
	int i,j,a;
	int data[10];
	for(i=0; i<10; i++)
		scanf("%d",&data[i]);
	for(i=0; i<10; i++){
		for(j=1; j<10-i; j++){
			if(data[i]<data[i+j]){
				a=data[i];
				data[i]=data[i+j];
				data[i+j]=a;
			}
		}
	}
	for(i=0; i<3; i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

Measured memory_bytes: 600
var input = require( 'fs' ).readFileSync( '/dev/stdin' ).toString();
  var data = input.split( " " ).map( Number );
  var a = data[0];
  var b = data[1];
  var C = data[2]*(Math.PI/180);
  var h = Math.sin( C )*b;
  var S = (a*h)*0.5;
  var ta = (a-Math.cos( C )*b);
  var L = a+b+Math.sqrt( Math.pow( ta,2 )+Math.pow( h, 2) );
  console.log( S+'\n'+L+'\n'+h );

Measured memory_bytes: 15616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

void solve(void){
    ll N, M;
    cin >> N >> M;
    ll cnt = 0LL;
    while (N <= M) {
        cnt++;
        N *= 2LL;
    }
    cout << cnt << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
K = [0]*N
A = [[0]*M for i in range(N)]
for i in range(N):
  x = list(map(int, input().split()))
  K[i] = x[0]
  A[i] = x[1:]
l = A[0]
for i in range(1, N):
  j = 0
  max_j = len(l)-1
  j = 0
  while(j != max_j+1):
    if l[j] not in A[i]:
      del l[j]
      max_j -= 1
      j -= 1
    j += 1
print(len(l))

Measured memory_bytes: 3064