akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    if(n<=x)
        cout<<t<<endl;
    else
    {
        int x1=x,t1=t;
        while(x1<n)
        {
            x1+=x;
            t1+=t;
        }
        cout<<t1<<endl;
    }
}

Measured memory_bytes: 3584
def partition(array, p, r)
    x = array[r]
    i = p-1
    (p..(r-1)).each do |j|
        if array[j] <= x
            i += 1
            tmp = array[i]
            array[i] = array[j]
            array[j] = tmp
        end
    end
    tmp = array[i+1]
    array[i+1] = array[r]
    array[r] = tmp
    i+1
end

n=gets.to_i
array=gets.chomp.split(" ").map(&:to_i)
index = partition(array, 0, n-1)
puts array.map.with_index{|e,i| i==index ? "[#{e}]" : e.to_s }.join(" ")


Measured memory_bytes: 18004
#include <iostream>
#include <vector>
#include <tuple>
#include <array>
#include <initializer_list>

using namespace std;

int main(void)
{
    int  mm[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};

    int N;
    while(cin >> N, N){
        vector<array<int, 2>> vs;
        vs.emplace_back();
        vs[0][0] = 0; vs[0][1] = 0;
        while(--N){
            int n, d;
            cin >> n >> d;
            auto t = vs[n];
            auto& m = mm[d];

            t[0] += mm[d][0];
            t[1] += mm[d][1];

            vs.emplace_back(t);
        }

        int maxX = 0, minX = 0, maxY = 0, minY = 0;
        for(auto& t: vs){
            auto x = t[0];
            auto y = t[1];
            if(maxX < x) maxX = x;
            if(minX > x) minX = x;
            if(maxY < y) maxY = y;
            if(minY > y) minY = y;
        }

        cout << maxY - minY + 1 << ' ' << maxX - minX + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int h[n];for(int i=0;i<n;i++)cin>>h[i];
  int dp[n];
  fill(dp,dp+n,2000000000);
  dp[0]=0;
  for(int i=0;i<n-1;i++){
    for(int j=1;j<=k;j++){
      if(i+j<n){
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{	
	vector<int> ans;
	while (true)
	{
		string tmp;cin >> tmp;
		if(tmp == "0")break;
		int sum = 0;
		rep(i, sz(tmp)) sum += (tmp[i]-'0');
		ans.push_back(sum);
	}
	rep(i, sz(ans))cout << ans[i] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3204
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n-i; j++) {
			int ret = max(n - i - j,0);
			if (10000 * i + 5000 * j + 1000 * ret == y) {
				cout << i << " " << j << " "<<ret << endl;
				return 0;
			}
		}
	}

	cout << -1 << " " << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t x[100000];

int main(void) {
	size_t N, X;

	scanf("%zu %zu\n", &N, &X);
	for (size_t idx = 0; idx < N; idx++) {
		scanf("%zu", &x[idx]);
		if (idx < N - 1) {
			scanf(" ");
		}
	}
	
	qsort(x, N, sizeof(size_t), compare_f);

	size_t minAbss = (size_t)UINT32_MAX;

	if (X < x[0]) {
		const size_t rightAbssX = x[0] - X;
		if (rightAbssX < minAbss) {
			minAbss = rightAbssX;
		}
	}
	else if (x[N - 1] < X) {
		const size_t leftAbssX = X - x[N - 1];
		if (leftAbssX < minAbss) {
			minAbss = leftAbssX;
		}
	}

	for (size_t idx = 0; idx < N - 1; idx++) {
		const size_t abss = x[idx + 1] - x[idx];
		if (abss < minAbss) {
			minAbss = abss;
		}
		if (x[idx] < X && X < x[idx + 1]) {
			const size_t leftAbssX = X - x[idx];
			if (leftAbssX < minAbss) {
				minAbss = leftAbssX;
			}
			const size_t rightAbssX = x[idx + 1] - X;
			if (rightAbssX < minAbss) {
				minAbss = rightAbssX;
			}
		}
	}

	size_t dCandidate = minAbss;
	while (1 < dCandidate) {
		bool isCommonDivisor = true;
		for (size_t idx = 0; idx < N; idx++) {
			const size_t abss = ABSS(X, x[idx]);
			if (abss%dCandidate != 0) {
				isCommonDivisor = false;
			}
		}
		if (isCommonDivisor) {
			break;
		}
		dCandidate--;
	}

	printf("%zu\n", dCandidate);

	return 0;
}


Measured memory_bytes: 1788
import sys
import bisect
from heapq import heappop, heappush, heapify
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
N,Q= map(int,input().split())
STX = [list(map(int,input().split())) for i in range(N)]
D = [int(input()) for i in range(Q)]

'''
import random
N = 2*10**5
Q = 2*10**5
STX = []
for i in range(N):
    S,T = sorted([random.randint(0,10**9-1) for i in range(2)])
    if S == T:
        T += 1
    X = random.randint(1,10**9)
    STX.append([S,T,X])
D = sorted([random.randint(0,10*9) for i in range(Q)])
'''

inf = 10**15
PFXS = [(s-x,True,x) for s,t,x in STX]
PFXT = [(t-x,False,x) for s,t,x in STX]
PFX = PFXS + PFXT
PFX.append((-inf,True,inf))
PFX.append((inf,False,inf))
PFX.sort()

addq = [inf]
delq = [inf+1]
iterD = iter(D)

d = next(iterD)
for p,f,x in PFX:
    while d < p:
        ans = addq[0] if not addq[0] == inf else -1
        print(ans)
        try:
            d = next(iterD)
        except:
            exit()
    if f:
        heappush(addq, x)
    else:
        heappush(delq, x)
    while addq[0] == delq[0]:
        heappop(addq)
        heappop(delq)






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

int main() {
 int A,B;
 cin >> A >> B;

 if(A >= 13) {
   cout << B << endl;
 }else if(A >= 6 && A <= 12) {
   cout << B / 2 << endl;
 }else  {
   cout << 0 << endl;
 }
 


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int n, k;
int niz[maxn];
bool dp[maxn];
int main()
{
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> niz[i];
    dp[0] = 0;
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i >= niz[j] && !dp[i - niz[j]]){
                dp[i] = 1;            }
        }
    }
    if(dp[k])cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  long long y = 0, x = 0;
  for (int i = 0; i < n - 1; i++) {
    if (!y) {
      if (a[i] == a[i+1]) {
        y = a[i];
        i++;
      }
    } else {
      if (a[i] == a[i+1]) {
        x = a[i];
        break;
      }
    }
  }
  cout << y * x << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int ex[7]={1,2,4,8,16,32,64};
    int n;
    cin >> n;
    rep(i,7){
        if(ex[i]>n){
            cout << ex[i-1];
            return 0;
        }
    }
    cout << ex[6];
    return 0;
}

Measured memory_bytes: 3556
from heapq import heappop, heappush, heapify

MAX_MONEY = 2500
INF = float("inf")
n, m, s = map(int, input().split())
s = min(s, MAX_MONEY)
graph = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1; v -= 1
    graph[u].append((v, a, b))
    graph[v].append((u, a, b))
cd = [tuple(map(int, input().split())) for _ in range(n)]

dp = [[INF] * (MAX_MONEY+10) for _ in range(n)]
dp[0][s] = 0

q = [(0, 0, s)]
while q:
    dist, v, money = heappop(q)
    if dp[v][money] < dist: continue
    for nv, fare, cost in graph[v]:
        nm = money - fare
        if nm < 0: continue
        if dp[nv][nm] > dp[v][money] + cost:
            dp[nv][nm] = dp[v][money] + cost
            heappush(q, (dp[nv][nm], nv, nm))
    
    nm = min(money+cd[v][0], MAX_MONEY)
    if dp[v][nm] > dp[v][money] + cd[v][1]:
        dp[v][nm] = dp[v][money] + cd[v][1]
        heappush(q, (dp[v][nm], v, nm))

for i in range(1, n):
    print(min(dp[i]))


Measured memory_bytes: 99608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n[10000], x[10000];
    int N;
    for(int i=0;i<10000;i++){
        cin >> n[i] >> x[i];
        if(n[i]==0 && x[i]==0){
            N=i;
            break;
        }
    }
    
    int count[N];
    for(int i=0;i<N;i++) count[i]=0;
    
    for(int i=0;i<N;i++){//count
        for(int j=n[i];j>0;j--){//right to left
            if(j>=x[i]) continue;//cut
            for(int k=1;k<j;k++){//left to right
                int m=x[i]-j-k;
                if(m>k && m< j) ++count[i];
            }
        }
        cout << count[i] << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <utility>
#include <functional>

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)

using ll = long long;
using P = std::pair<int, int>;
using namespace std;

constexpr int INF = 1000000000; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18
constexpr int MAX_N = 201;

// d[i][j]はi->jの最小コスト
int d[MAX_N][MAX_N];
// S->すでに訪れた点の集合, v->現在位置, dp[S][v]: 左の状況での最小コスト
int dp[256][8];
int N, M, R;
vector<int> r;

int func(int s, int v) {
	if (s == (1 << R) - 1) {
		return 0;
	}
	if (dp[s][v] != INF) { return dp[s][v]; }
	REP(u, R) {
		if (!((s >> u) & 1)) {
			dp[s][v] = min(dp[s][v], func(s | (1 << u),u) + d[r[v]][r[u]]);
		}
	}
	return dp[s][v];
}

// dpテーブルを埋める
void solve() {
	for (int s = (1 << R) - 2; s >= 0; --s) {
		REP(v, R) {
			func(s, v);
		}
	}
	return;
	//for (int s = (1 << R) - 1; s >= 0; --s)
	//{
	//	for (int v = 0; v < R; v++)
	//	{
	//		if (s&(1 << v))
	//		{
	//			for (int u = 0; u < R; u++)
	//			{
	//				//v<-uと移動したとする
	//				if ((s >> u) & 1) {
	//					dp[s & ~(1 << v)][u] = min(dp[s & ~(1 << v)][u], d[r[u]][r[v]] + dp[s][v]);
	//				}
	//			}
	//		}
	//	}
	//}
	for (int s = (1 << R) - 2; s >= 0; --s) {
		REP(v, R) {
			REP(u, R) {
				if (!((s >> u) & 1)) {
					dp[s][v] = min(dp[s][v], dp[s | (1 << u)][u] + d[r[v]][r[u]]);
				}
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	// 初期化
	cin >> N >> M >> R;
	r = vector<int>(R);
	REP(i, R) cin >> r[i];
	for (int i = 1; i <= N; ++i) {
		fill(d[i], d[i] + N+1, INF);
		d[i][i] = 0;
	}
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	for (int S = 0; S < (1 << R); ++S) {
		fill(dp[S], dp[S] + R, INF);
	}

	// WF法

	REP(k, N + 1) {
		REP(i, N + 1) {
			REP(j, N + 1) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	// ビットDP

	REP(i, R) dp[(1 << R) - 1][i] = 0; // 全て通った後のコストを0にする

	solve();

	int m = INF;
	REP(i, R) {
		m = min(m, dp[1 << i][i]);
	}

	cout << m << "\n";

	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 120000;
const int K = 350;
vector < pair < int, int > > ans;
vector < int > g[N];
int used[N], c[N], in[N];
void dfs(int v, int p = -1){
    used[v] = 1;
    in[v] = 1;
    for (auto u: g[v]){
        if (used[u]){
            if (u == p || in[u] == 0) continue;
            ans.pb({u, v});
            c[u] ^= 1;
        } else{
            dfs(u, v);
        }
    }
    if (p == -1){
        if (c[v] != 0){
            cout << "-1";
            exit(0);
        }
        return;
    }
    in[v] = 0;
    if (c[v] == 0){
        ans.pb({p, v});
        c[p] ^= 1;
    } else{
        ans.pb({v, p});
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    if (m & 1){
        cout << -1;
        return 0;
    }
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    for (auto i: ans){
        cout << i.F << " " << i.S << endl;
    }
}


Measured memory_bytes: 17776
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define N 100050
#define GG puts("NO");exit(0)
int head[N],to[N<<1],nxt[N<<1],cnt,n,root;
int f[N],val[N],du[N],a[N],la;
inline void add(int u,int v) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;
}
void dfs(int x,int y) {
	int i;
	if(du[x]==1) {f[x]=val[x]; return ;}
	for(i=head[x];i;i=nxt[i]) if(to[i]!=y) dfs(to[i],x);
	ll s=0;
	int mx=0;
	for(i=head[x];i;i=nxt[i]) if(to[i]!=y) {
		mx=max(mx,f[to[i]]);
		s+=f[to[i]];
	}
	int k=s-val[x];
	if(k<0) {GG;}
	if(s-mx<mx&&s-mx<k) {GG;}
	if(s-mx>=mx&&s/2<k) {GG;}
	f[x]=2*val[x]-s;
}
int main() {
	scanf("%d",&n);
	int i;
	for(i=1;i<=n;i++) scanf("%d",&val[i]);
	if(n==2) {puts(val[1]==val[2]?"YES":"NO"); return 0;}
	int x,y;
	for(i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x),du[x]++,du[y]++;
	for(i=1;i<=n;i++) if(du[i]>1){root=i; break;}
	dfs(root,0);
	puts(f[root]?"NO":"YES");
}


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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,x,d=0,ans;
	cin >> n >> x;
	for(int i=1;i<=n;++i){
		int l;
		cin >> l;
		d+=l;
		if(d>x){
			ans=i;
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const ll MAXN = 1e18;

ll h,m, a[1 << 18];

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	cin >> h >> m;
	for(int i=0; i<m; i++){
		cin >> a[i];
		h-=a[i];
	}
	if(h<=0){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}

//^-^

Measured memory_bytes: 4396
#include<iostream>
#include<cmath>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    double a,b,c;
    cin >> a >> b >> c;
    double r=c/180*M_PI;
    double s=a*b*sin(r)/2;
    double l=a+b+sqrt(a*a+b*b-2*a*b*cos(r));
    double h=b*sin(r);
    printf("%.10f\n%.10f\n%.10f\n",s,l,h);
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int m;
    cin >> m;
    cout << 24 + (24-m) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL n;
    cin >> n;
    string ans="";
    while ( n>0 ) {
        --n;
        int d=n%26;
        n/=26;
        ans+=(char)(d+'a');
    }
    reverse(ALL(ans));
    cout << ans << '\n';
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> A(n);
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i);
  }

  sort(A.begin(), A.end(), greater<pair<int, int>>());

  ll dp[n+1][n+1];
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=n; j++) dp[i][j] = 0;
  }

  for (int i=0; i<n; i++) {
    ll v = (ll)A[i].first;
    int x = A[i].second;
    for (int j=0; j<=i; j++) {
      dp[j+1][i-j] = max(dp[j+1][i-j], dp[j][i-j] + v * abs(x - j));
      dp[j][i-j+1] = max(dp[j][i-j+1], dp[j][i-j] + v * abs(x - (n-i+j-1)));
    }
  }
  ll ans = 0;
  for (int i=0; i<=n; i++) {
    ans = max(ans, dp[i][n-i]);
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long;
using namespace std;

struct RollingHash {
    using I = long long;
    static constexpr size_t L = 2;
    static constexpr I bs[L] = {1007, 2009};
    static constexpr I ms[L] = {1000000007, 1000000009};

    using T = pair<I, I>;

    vector<I> hs[L], pws[L];

    RollingHash(const string &s) {
        size_t n = s.size();
        for(size_t i=0; i<L; i++) {
            hs[i].assign(n+1, 0);
            pws[i].assign(n+1, 0);
            pws[i][0] = 1;
            for(size_t j=0; j<n; j++) {
                pws[i][j+1] = (pws[i][j]*bs[i]) % ms[i];
                hs[i][j+1] = (hs[i][j]*bs[i] + s[j]) % ms[i];
            }
        }
    }

    // [l, r)
    inline T hash(size_t l, size_t r) const {
        return {
            (((hs[0][r] - hs[0][l] * pws[0][r-l]) % ms[0]) + ms[0]) % ms[0],
            (((hs[1][r] - hs[1][l] * pws[1][r-l]) % ms[1]) + ms[1]) % ms[1],
        };
    }
};
// for <= C++14
constexpr RollingHash::I RollingHash::bs[];
constexpr RollingHash::I RollingHash::ms[];

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;

    auto f = [](string &a, string &b, string &c) {
        ll na = a.size(), nb = b.size(), nc = c.size();

        vector<int> ab(na+1), bc(nb+1), ac(na+1);
        for(ll i=0; i<na; i++) {
            bool ok = true;
            for(ll j=0; ok && j<min(na-i, nb); j++)
                ok &= a[i+j] == '?' || b[j] == '?' || a[i+j] == b[j];
            ab[i] = (int)ok;
        }
        ab[na] = 1;
        for(ll i=0; i<nb; i++) {
            bool ok = true;
            for(ll j=0; ok && j<min(nb-i, nc); j++)
                ok &= b[i+j] == '?' || c[j] == '?' || b[i+j] == c[j];
            bc[i] = (int)ok;
        }
        bc[nb] = 1;
        for(ll i=0; i<na; i++) {
            bool ok = true;
            for(ll j=0; ok && j<min(na-i, nc); j++)
                ok &= a[i+j] == '?' || c[j] == '?' || a[i+j] == c[j];
            ac[i] = (int)ok;
        }
        ac[na] = 1;
        ll r = 1e9;
        for(ll i=0; i<=na; i++) {
            for(ll j=i; j<=max(na, i+nb); j++) {
                bool ok = true;
                ok &= i>=na || ab[i];
                ok &= j-i >= nb || bc[j-i];
                ok &= j>=na || ac[j];
                if(ok) r = min(r, max({na, i+nb, j+nc}));
            }
        }
        return r;
    };

    ll r = 1e9;
    r = min(r, f(a, b, c));
    r = min(r, f(a, c, b));
    r = min(r, f(b, a, c));
    r = min(r, f(b, c, a));
    r = min(r, f(c, a, b));
    r = min(r, f(c, b, a));
    cout << r << endl;
    
}


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

int main() {
    int n, f_st = 0, ans = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(f_st) {
            if(s[i] == 'T') {
                f_st--;
            } else {
                f_st++;
            }
        } else {
            if(s[i] == 'T') {
                ans++;
            } else {
                f_st++;
            }
        }
    }
    cout << ans + f_st << '\n';
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {

	var N int
	fmt.Scan(&N)
	sl := make([]int, N)

	for i, _ := range sl{
		fmt.Scan(&sl[i])
	}
	maps := map[int]int{}

	for i, v := range sl {
		maps[v]	= i+1
	}
	for i :=1; i <= N; i++{
		fmt.Printf("%v ",maps[i] )
	}

}


Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
int main() {
	bool prime[300000] = {};
	for (int i = 6; i < 300000; i % 7 == 6 ? i += 2 : i += 5) prime[i] = true;
	for (int i = 6; i < 300000; i % 7 == 6 ? i += 2 : i += 5)
		if (prime[i])
			for (int j = 2; i*j < 300000; ++j) prime[i*j] = false;
	vector<int>primeList;
	for (int i = 6; i < 300000; i % 7 == 6 ? i += 2 : i += 5)
		if (prime[i]) primeList.push_back(i);
	int n;
	while (cin >> n && n != 1) {
		cout << n << ":";
		for (int i = 0; i < primeList.size(); ++i)
			if (n%primeList[i] == 0) cout << " " << primeList[i];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b,c;
  cin>>b>>c;
  ll g=b;
  ll h=-1;
  
  if(a==1||b==0){
    cout<<g<<endl;
    return 0;
  }
  for(ll i=0;i<min(a,c)-1;i++){
    b=b*b%c;
    
    if(b==0){
      cout<<g<<endl;
      return 0;
    }
    if(b==1){
      cout<<g+a-1-i<<endl;
      return 0;
    }
    g+=b;
  }
  if(a<=c){
    cout<<g<<endl;
    return 0;
  }
  g-=b;
  ll k=b;
  vector<ll>vec(1,b);
  for(ll i=0;i<c;i++){
    b=b*b%c;
    if(b==vec.at(0)){
      h=i+1;
      break;
      
    }
    else{
      k+=b;
      vec.push_back(b);
    }
  }
  ll x=(a-c+1)%h;
  ll y=(a-c+1)/h;
  ll z=0;
  
  if(x!=0){
    for(ll i=0;i<x;i++){
      z+=vec.at(i);
    }
  }
  cout<<g+y*k+z<<endl;
  return 0;
}

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


signed main(){
    int A,B,C;
    int Ans=810;
    int sum;
    cin >> A >> B >> C;
    REP(i,60){//目標の数
        sum=0;
        if(i>=A){
            sum+=(i-A+1)/2 + (i+A)%2;
        }else{
            sum+=A-i;
        }
        if(i>=B){
            sum+=(i-B+1)/2 + (i+B)%2;
        }else{
            sum+=B-i;
        }
        if(i>=C){
            sum+=(i-C+1)/2 + (i+C)%2;
        }else{
            sum+=C-i;
        }
        Ans=min(Ans,sum);
    }
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,ar[5];
  //cin>>x>>y;
  for(int i=0;i<5;i++){
    cin>>ar[i];
    if(ar[i]==0){
      x=i+1;
      break;
    }
  }
  cout<<x<<endl;
}

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

struct dat {
  long long a, b, c;
  dat(long long _a = 0, long long _b = 0, long long _c = 0)
      : a(_a), b(_b), c(_c) {}
  bool operator<(const dat &r) const { return b - a > r.b - r.a; }
};

long long x, y, z, n;
vector<dat> v;
priority_queue<long long> pqb;
map<long long, int> mpu, mpn;

long long solve();

int main() {
  cin >> x >> y >> z;
  n = x + y + z;
  v.resize(n);
  for (int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b >> v[i].c;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, now = 0;
  for (int i = 0; i < n; ++i) {
    if (i < y) {
      now += v[i].b;
      pqb.push(v[i].c - v[i].b);
    } else
      now += v[i].a;
  }
  {  // prepair mp
    vector<long long> tmp;
    for (int i = y; i < n; ++i) tmp.push_back(v[i].c - v[i].a);
    sort(tmp.begin(), tmp.end(), greater<long long>());
    for (int i = 0; i < tmp.size(); ++i)
      if (i < z) {
        now += tmp[i];
        ++mpu[tmp[i]];
      } else
        ++mpn[tmp[i]];
  }
  for (int i = y; i + x <= n; ++i) {
    res = max(res, now);
    // b->c
    pqb.push(v[i].c - v[i].b);
    now += pqb.top();
    pqb.pop();
    // a->b
    now += v[i].b - v[i].a;
    long long num = v[i].c - v[i].a;
    if (mpu.find(num) != mpu.end()) {
      now -= num;
      if (--mpu[num] == 0) mpu.erase(num);
    } else {
      if (--mpn[num] == 0) mpn.erase(num);
      if (mpu.size()) {
        num = (*mpu.begin()).first;
        now -= num;
        if (--mpu[num] == 0) mpu.erase(num);
      }
    }
  }
  return res;
}

Measured memory_bytes: 12456
#include <stdio.h>

int main(){

  int n,x,y,stone[21][21];
  int m,l,i,j,locx,locy,sum;
  char d;

  while(scanf("%d",&n),n){

    for(i=0;i<=20;i++)for(j=0;j<=20;j++)stone[i][j]=0;
    
    for(i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      stone[x][y]=1;
    }

    locx=10;
    locy=10;
    
    scanf("%d",&m);
    for(i=0;i<m;i++){
      scanf("%c",&d);

      
      scanf("%c%d",&d,&l);
      //printf("d=%c ,l=%d\n",d,l);
      if(d=='N'){
	for(j=0;j<l;j++){
	  locy++;
	  stone[locx][locy]=0;
	}
      }else if(d=='S'){
	for(j=0;j<l;j++){
	  locy--;
	  stone[locx][locy]=0;
	}
      }else if(d=='E'){
	for(j=0;j<l;j++){
	  locx++;
	  stone[locx][locy]=0;
	}

      }else if(d=='W'){
	for(j=0;j<l;j++){
	  locx--;
	  stone[locx][locy]=0;
	}
      }
    }
    
    sum=0;
    for(i=0;i<=20;i++){
      for(j=0;j<=20;j++){
	sum+=stone[i][j];
      }
    }
    
    if(sum==0)printf("Yes\n");
    else printf("No\n");

  }

  return 0;

}

Measured memory_bytes: 584
n = gets.strip.to_i
bars = gets.strip.split(' ').map(&:to_i)
max_count = 0
count = 0
bars.each_with_index do |v, i|
  break if i >= n - 1
  if v >= bars[i + 1]
    count += 1
    max_count = count if count > max_count
  else
    count = 0
  end
end

puts max_count

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

int main()
{
	int N, A[100], B[100],ans = 0;

	cin >> N;

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

	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	for (int i = 0,sum = 0,sumb = 0; i < N; i++) {
		sum += A[i];
		sumb = sum;
		for (int k = i; k < N; k++) {
			sumb += B[k];
		}
		if (sumb > ans)ans = sumb;
		if (i == N - 1 && sum > ans)ans = sum;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    bool isok = true;
    int ans = 0;
    for(int i = 0, j = s.size()-1; i<j;){
        if (s[i] == s[j]) i++, j--;
        else if (s[i] == 'x') i++,ans++;
        else if (s[j] == 'x') j--,ans++;
        else isok = false;
        if (!isok) break;
    }
    if(isok) cout << ans << endl;
    else cout << -1 << endl;
}



Measured memory_bytes: 512
n = int(input())

A = [chr(i) for i in range(ord('a'), ord('z') + 1)]

B = []

for i in range(n):
    B.append(input())

C = []
m = 100
for i in A:
    for j in B:
        n = j.count(i)
        if n < m:
            m = n
    C.append(m)
    m = 100
s = ""
for i, j in zip(A, C):
    s += i * j
print(s)

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

int main(){
	ll h, w;
	cin >> h >> w;
	if(h == 1 || w == 1){
		cout << 1 << endl;
		return 0;
	}
	ll ans;
	ans = h * w / 2;
	if(h % 2 == 1 && w % 2 == 1){
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
class String
  def to_ia
    self.split(/\s+/).map {|s| s.to_i}
  end
end
 
def maximun_profit(numbers)
  min = numbers[0]
  max = nil
  numbers[1..-1].each do |n|
    val = n - min
    max = max ? [max, val].max : val
    min = [min, n].min
  end
  max
end
 
lines = STDIN.read.split(/\n/)
numbers = lines[1..-1].map {|l| l.to_i}
puts maximun_profit(numbers)

Measured memory_bytes: 26680
#include<cstdio>
#include<algorithm>
#include<queue>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<cstring>
#define eps 1e-8
#define pi acos(-1)
#define mp make_pair
#define PH push
#define pb push_back
#define PII pair<ll,ll>
#define VI vector<int>
#define fi first
#define se second
#define N(a,b) a=N(a,b)
#define Min(a,b) a=min(a,b)
#define sqr(x) ((x)*(x))
#define CL(a) memset(a,0,sizeof a)
#define fr(i,n) for(int i=1;i<=n;i++)
#define FR(i,S,n) for(int i=S;i<=n;i++)
#define dr(i,n) for(int i=n;i;i--)
#define DR(i,n,S) for(int i=n;i>=S;i--)
#define SZ(x) ((int)(x).size())
#define all(n) n.begin(),n.end()
#define rd(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
#define prn(x) printf("%d\n",x)
typedef long long ll;
typedef unsigned long long ull;
ll expow(ll a,ll b,ll p) {ll v=1; for (; b; b>>=1,a=a*a%p)if (b&1)v=v*a%p; return v;}
ll inv(ll a,ll p) {return expow(a,p-2,p);}
using namespace std;
const int N=1000+10;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    //cout<<a[0]<<" "<<a[1];
    puts(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i=0; i<N; i++)

int main(int argc, char *argv[])
{
    int N;
    cin >> N;

    vector<int> a(N), b(N), c(N);
    Rep(i, N) {
        cin >> a[i] >> b[i] >> c[i];
    }

    // dp[i][0]: a[i]を通る中で最大の幸福度
    // dp[i][1]: b[i]を通る中で最大の幸福度
    // dp[i][2]: c[i]を通る中で最大の幸福度

    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i=0; i<N-1; i++) {
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i+1];
        dp[i+1][1] = max(dp[i][2], dp[i][0]) + b[i+1];
        dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i+1];
    }

    cout << *max_element(dp[N-1].cbegin(), dp[N-1].cend()) << endl;

    return 0;
}

Measured memory_bytes: 6912
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var jpy =0;
  var btc =0;
  for(var i=0;i<N;i++){
    tmp=input[i+1].split(" ");
    if(tmp[1]=="JPY"){
      jpy+=parseInt(tmp[0]);
    }else{
      btc+=parseFloat(tmp[0]);
    }
  }
  var ans=jpy+btc*380000.0;
  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;
int A[200010];
int num[200010];

void calc(){
	REP(i,N){
		num[i]=0;
	}
	REP(i,N){
		int l=max(0,i-A[i]);
		int r=min(N-1,i+A[i]);
		num[l]++;
		num[r+1]--;
	}
	REP(i,N){
		num[i+1]+=num[i];
	}
	REP(i,N){
		A[i]=num[i];
	}
}

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,min(50,K)){
		calc();
	}
	REP(i,N){
		cout<<A[i];
		if(i<N-1)cout<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 6756
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val s = read().toCharArray()
    val ans = ArrayDeque<Char>()
    s.forEach{
        ans.addLast(it)
    }
    var dir = true
    val q = readint()
    repeat(q){
        val a = reads()
        if(a[0] == "1"){
            dir = !dir
        }
        else{
            val f = a[1].toInt()
            if(f == 1){
                if(dir){
                    ans.addFirst(a[2][0])
                }
                else{
                    ans.addLast(a[2][0])
                }
            }
            else{
                if(!dir){
                    ans.addFirst(a[2][0])
                }
                else{
                    ans.addLast(a[2][0])
                }
            }
        }
    }
    val res = StringBuilder()
    if(dir){
        while(ans.isNotEmpty()){
            res.append(ans.first)
            ans.removeFirst()
        }
    }
    else{
        while(ans.isNotEmpty()){
            res.append(ans.last)
            ans.removeLast()
        }
    }
    println(res)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 78084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	vpll p(n);
	for(int i=0 ; i<n ; ++i){
		cin >> p[i].F >> p[i].S;
	}
	
	sort(all(p));
	
	ll ans=0;
	ll mx = p[0].S - p[0].F;
	ll mn = p[0].F + p[0].S;
	for(int i=1 ; i<n ; ++i){
		ans = max(ans, p[i].F - p[i].S + mx);
		ans = max(ans, p[i].F + p[i].S - mn);
		
		mx = max(mx, p[i].S - p[i].F);
		mn = min(mn, p[i].F + p[i].S);
	}
	
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


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

// AtCoder ABC 111 C-/\/\/\/
int main(){
  int n;
  scanf("%d", &n);
  int data[n], ans;
  vector<int> up(n/2), dn(n/2);
  for(int i = 0; i < n; i++){
    scanf("%d", &data[i]);
    if (i&1) { dn[(i-1)/2] = data[i]; }
    else  { up[i/2] = data[i]; }
  }

  int up_tmpcnt = 1, upcount = 1, upsemicnt = 1;
  int dn_tmpcnt = 1, dncount = 1, dnsemicnt = 1;
  sort(up.begin(), up.end() );
  sort(dn.begin(), dn.end() );

  int upnum = up[0], dnnum = dn[0];
  int upmode = upnum, dnmode = dnnum;
  int upsemi = 0, dnsemi = 0;
  for(int i = 1; i < n/2; i++){
    if ( up[i] == upnum )
      up_tmpcnt++;
    if ( up[i] != upnum || i == n/2-1){
      if ( up_tmpcnt > upcount ){
        upsemicnt = upcount;
        upcount = up_tmpcnt;
        upsemi = upmode;
        upmode = upnum;
      }
      else if ( up_tmpcnt > upsemicnt ){
      	upsemicnt = up_tmpcnt;
      	upsemi = upmode;
      }
      up_tmpcnt = 1;
      upnum = up[i];
    }
    if ( dn[i] == dnnum )
      dn_tmpcnt++;
    if ( dn[i] != dnnum || i == n/2-1 ){
      if ( dn_tmpcnt > dncount ){
        dnsemicnt = dncount;
        dncount = dn_tmpcnt;
        dnsemi = dnmode;
        dnmode = dnnum;
      }
      else if ( dn_tmpcnt > dnsemicnt ){
      	dnsemicnt = dn_tmpcnt;
      	dnsemi = dnnum;
      }
      dn_tmpcnt = 1;
      dnnum = dn[i];
    }
  }
  if( upmode != dnmode ) {
    ans = n - upcount - dncount;
  }else{
    if ( upcount > dncount ){
      ans = n - upcount - dnsemicnt;
    }else if( upcount < dncount ){
      ans = n - upsemicnt - dncount;
    }else{  // upcount == dncount
      if( upsemicnt > dnsemicnt ){
        ans = n - upsemicnt - dncount;
      }else {
        ans = n - upcount - dnsemicnt;
      }
    }

    if( upcount == n/2 && dncount == n/2 ){
      ans = n/2;
    }
  }
  printf("%d\n", ans);

  return 0;
}


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


int main() {
    int N; cin >> N;
    vector<char> S(N);
    for (int i = 0; i < N; ++i) {
        cin >> S.at(i);
    }
    S.erase(unique(S.begin(), S.end()), S.end());

    cout << S.size() << endl;
}

Measured memory_bytes: 384
hs=Hash.new()
hs2=Hash.new(0)
n,m=gets.split(" ").map{|e| e.to_i}
arr=[]
arr2=[]
m.times{
	a,b=gets.split(" ").map{|e| e.to_i}
	arr<<[b,a]
}
arr2=arr.sort
arr2.each{|e|
	hs2[e[1]]+=1
	hs[e]=hs2[e[1]]
}
arr.each{|e|
	a=hs[e]
	puts format('%06d%06d',e[1],a)
}

Measured memory_bytes: 24556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue> 
#include<algorithm>
#define INF 0x3f3f3f3f
#define maxn 200000
#define maxm 1000000
using namespace std;
template<typename T> void qread(T &x){
	x=0;
	T sign=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') sign=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	x=x*sign; 
} 

struct edge{
	int from;
	int to;
	int next;
	int flow;
}E[maxm*2+5];
int sz=1;
int head[maxn+5];
int cur[maxn+5];//当前弧优化 
void add_edge(int u,int v,int w){
//	printf("%d->%d %d\n",u,v,w);
	sz++;
	E[sz].from=u;
	E[sz].to=v;
	E[sz].next=head[u];
	E[sz].flow=w;
	head[u]=sz;
	sz++;
	E[sz].from=v;
	E[sz].to=u;
	E[sz].next=head[v];
	E[sz].flow=0;
	head[v]=sz;
}
int deep[maxn+5];
bool bfs(int s,int t){
	for(int i=s;i<=t;i++) deep[i]=0;
	queue<int>q;
	q.push(s);
	deep[s]=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=head[x];i;i=E[i].next){
			int y=E[i].to; 
			if(E[i].flow&&!deep[y]){
				deep[y]=deep[x]+1;
				q.push(y);
			}
		}
	}
	return deep[t]>0;
} 
int dfs(int x,int t,int minf){
	if(x==t) return minf;
	int rest=minf,k;
	for(int &i=cur[x];i;i=E[i].next){
		int y=E[i].to;
		if(E[i].flow&&deep[y]==deep[x]+1){
			k=dfs(y,t,min(rest,E[i].flow));
			E[i].flow-=k;
			E[i^1].flow+=k;
			rest-=k; 
			if(k==0) deep[y]=0;
			if(rest==0) break;
		}
	}
	return minf-rest;
}
int dinic(int s,int t){
	int ans=0,now=0;
	while(bfs(s,t)){
		for(int i=s;i<=t;i++) cur[i]=head[i];
		while((now=dfs(s,t,maxm+1))) ans+=now;
	}
	return ans;
} 

int n;
int p[maxn+5],q[maxn+5];
int cnt=0;//环个数 
int idp[maxn+5],idq[maxn+5];//所在环编号
void mark(int *id,int *a,int x){
	while(!id[x]){
		id[x]=cnt;
		x=a[x];
	}
}
int main(){
	qread(n);
	for(int i=1;i<=n;i++){
		qread(p[i]);
		p[i]++; 
	}
	for(int i=1;i<=n;i++){
		qread(q[i]);
		q[i]++;
	}
	for(int i=1;i<=n;i++){//找出每个环 
		if(!idp[i]){
			cnt++;
			mark(idp,p,i);
		} 
	}
	for(int i=1;i<=n;i++){
		if(!idq[i]){
			cnt++;
			mark(idq,q,i);
		}
	}
	int s=0,t=cnt+1;
	int eq=0;//相等的个数 
	for(int i=1;i<=n;i++){
		if(p[i]==i&&q[i]==i) eq++;
		else if(p[i]==i&&q[i]!=i) add_edge(idq[i],t,1);
		else if(p[i]!=i&&q[i]==i) add_edge(s,idp[i],1);
		else if(p[i]!=q[i]) add_edge(idq[i],idp[i],1);
		else{
			add_edge(idq[i],idp[i],1);
			add_edge(idp[i],idq[i],1);
		}
	}
	eq+=dinic(s,t);
	printf("%d\n",n-eq);
}

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

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s-x-y;
            if (0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import Data.Array.IO

rInt = read :: String -> Int

type Ary = IOUArray Int Int

increment :: Ary -> Int -> IO ()
increment ary x = do
    v <- readArray ary x
    writeArray ary x (v + 1)

main = do
    n <- rInt <$> getLine
    a <- ((map rInt) . words) <$> getLine
    ary <- newArray (-1,100001) 0 :: IO Ary
    let a' = (map (+) [-1..1]) <*> a
    mapM_ (increment ary) a'
    list <- getElems ary
    print $ maximum list
    

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

using namespace std;
const int N = 55, M = 105;
int n, k, a[N], mem[N][N][M];
int go(int i, int j, int k) {
	if (k == 0 || i > j)
		return 0;
	int &ret = mem[i][j][k];
	if (~ret)
		return ret;
	ret = max(go(i + 1, j, k - 1) + a[i],
			  go(i, j - 1, k - 1) + a[j]);
	if (k >= 2) {
		ret = max(ret, go(i + 1, j, k - 2));
		ret = max(ret, go(i, j - 1, k - 2));
	}
	ret = max(ret, 0);
	return ret;
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	memset(mem, -1, sizeof mem);
	printf("%d\n", go(0, n - 1, k));
	return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<iostream>
#include<string>
using ull = unsigned long long;
const static int MOD = 1000000007;
ull RepeatSquaring(ull N, ull P){
	if(P == 0 || N == 1) return 1;
	if(N == -1) return P & 1 ? -1 : 1;
	if(!(P & 1)){
		ull t = RepeatSquaring(N, P >> 1);
		return t*t %MOD;
	}
	return N*RepeatSquaring(N, P - 1) % MOD;
}

int main(){
    ull K;
    scanf("%llu", &K);
    std::string S;
    std::cin >> S;
    ull sz = S.size(), answer = 1, power = 1, cmb = sz;
    for (size_t i = sz; i < K + sz; i++){
        power = power*25 %MOD;
        answer = (answer*26 %MOD + cmb*power %MOD) %MOD;
        cmb = cmb*(i+1) %MOD *RepeatSquaring(i + 2 - sz, MOD-2) %MOD;
    }
    printf("%llu\n", answer);
	return 0;
}

Measured memory_bytes: 5328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}
#define maxn 100005
const int inf = 0x3f3f3f3f;
int A, B, M, a[maxn], b[maxn], mina = inf, minb = inf;
int main() {
  A = getint(), B = getint(), M = getint();
  for (int i = 1; i <= A; i++) a[i] = getint(), mina = min(mina, a[i]);
  for (int i = 1; i <= B; i++) b[i] = getint(), minb = min(minb, b[i]);
  int ans = mina + minb;
  for (int i = 1; i <= M; i++) {
    int x = getint(), y = getint(), c = getint();
    ans = min(ans, a[x] + b[y] - c);
  }
  putint(ans, '\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 1152