akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

struct NumberTheory
{
	vector<ll> primes;
	vector<bool> prime;
	vector<ll> totient;
	vector<ll> sumdiv;
	vector<ll> bigdiv;
	void Sieve(ll n)
	{
		prime.assign(n+1, 1);
		prime[1] = false;
		for(ll i = 2; i <= n; i++)
		{
			if(prime[i])
			{
				primes.pb(i);
				for(ll j = i*2; j <= n; j += i)
				{
					prime[j] = false;
				}
			}
		}
	}
	
	ll phi(ll x)
	{
		map<ll,ll> pf;
		ll num = 1; ll num2 = x;
		for(ll i = 0; primes[i]*primes[i] <= x; i++)
		{
			if(x%primes[i]==0)
			{
				num2/=primes[i];
				num*=(primes[i]-1);
			}
			while(x%primes[i]==0)
			{
				x/=primes[i];
				pf[primes[i]]++;
			}
		}
		if(x>1)
		{
			pf[x]++; num2/=x; num*=(x-1);
		}
		x = 1;
		num*=num2;
		return num;
	}
	
	int mobius(ll x)
	{
		int ans=1;
		for(ll i = 0; primes[i]*primes[i] <= x; i++)
		{
			int cnt=0;
			while(x%primes[i]==0)
			{
				x/=primes[i];
				cnt++;
			}
			if(cnt>=2) return 0;
			if(cnt==1) ans*=-1;
		}
		if(x>1) ans*=-1;
		return ans;
	}
};

const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

map<int,vi> D;
map<int,int> phimap;
map<int,int> mobiusmap;	
NumberTheory nt;

int phi(int x)
{
	if(phimap.find(x)==phimap.end()) return (phimap[x]=nt.phi(x));
	return phimap[x];
}

int mobius(int x)
{
	if(mobiusmap.find(x)==mobiusmap.end()) return (mobiusmap[x]=nt.mobius(x));
	return mobiusmap[x];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	nt.Sieve(100011);
	vector<int> divi;
	for(int d=1;d*d<=n;d++)
	{
		if(n%d==0)
		{
			divi.pb(d);
			if(d*d!=n) divi.pb(n/d);
		}
	}
	sort(divi.begin(),divi.end());
	for(int x:divi)
	{
		for(int y:divi)
		{
			if(x%y==0) D[x].pb(y);
		}
	}
	int ans = 0;
	for(int d:divi)
	{
		//minimal period = d
		int res = 0;
		for(int v:D[d])
		{
			res = add(res, mult(MOD+mobius(d/v),modpow(k,(v+1)/2)));
		}
		if(d%2==0) res=mult(res,modpow(2,MOD-2));
		res=mult(res,d);
		ans=add(ans,res);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1280
function f()
    p = parse.(Int, split(readline()))
    N = parse(Int, readline())
    N *= 4
    
    ppl = [(i,p[i]/(2^(i-1))) for i in 1:4]
    sort!(ppl, by=x->x[2])
    
    price = 0
    for l in ppl
        un = 2^(l[1]-1)
        count = Int(floor(N/un))
        N -= count*un
        price += p[l[1]]*count
    end
       
    println(price)
end

f()

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


int main()
{
    int Q;
    cin >> Q;


    long long sum_b = 0, sumL = 0, sumR = 0;
    priority_queue<int> qL;
    priority_queue<int, vector<int>, greater<int>> qR;

    for( int i = 0; i < Q; ++i )
    {
        int q, a, b;
        cin >> q;

        if( q == 1 )
        {
            cin >> a >> b;
            sum_b += b;

            // 2つpushすることで常に中央値を探索できる
            if( qR.empty() or a >= qR.top() ){
                sumR += 2*a;
                qR.push(a), qR.push(a);
                int tmp = qR.top(); qR.pop();
                sumR -= tmp;
                sumL += tmp;
                qL.push(tmp);
            }else{
                sumL += 2*a;
                qL.push(a), qL.push(a);
                int tmp = qL.top(); qL.pop();
                sumL -= tmp;
                sumR += tmp;
                qR.push(tmp);
            }
        }else cout << qL.top() << " " << (sumR-sumL)/2 + sum_b << endl;
    }

    return 0;
}

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

int main()
{
ll x , k , d ;
cin >> x >> k >> d ;
if(x<0)x=-x;
if(x/d-k>0)ans=x-k*d;
else{
  k=(k-x/d)%2;
  x=x%d;
  ans=x;
  if(k==1)ans=-x+d;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int n = Cin();
        int[] ques = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        int m = Cin();
        int[,] drink = new int[m, 2];
        int[] box = new int[2];
        for (int i = 0; i < m; i++)
        {
            box = SpRead(' ').Select(a => int.Parse(a)).ToArray();
            drink[i, 0] = box[0];
            drink[i, 1] = box[1];
        }
        //ドリンクの数だけ
        for (int i = 0; i < m; i++)
        {
            Console.WriteLine(ques.Sum() - ques[drink[i, 0] - 1] + drink[i, 1]);
        }

    }
}



public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13524
#include<iostream>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 100
#define INFTY (1<<21)

int G[MAX][MAX], c, n, s, d;

int dijkstra(){
    int D[MAX][11];
    bool V[MAX][11];
    rep(i, n) rep(k, c+1) { D[i][k] = INFTY; V[i][k] = false; }

    D[s][c] = 0;

    while(1){
	int u, w, minv = INFTY;
	rep(i, n) rep(k, c+1){
	    if ( !V[i][k] && minv > D[i][k] ){ 
		minv = D[i][k]; u = i; w = k; 
	    }
	}
	if ( minv == INFTY ) break;
	V[u][w] = true;
	rep(v, n){
	    if ( G[u][v] == INFTY ) continue;
	    D[v][w] = min(D[v][w], D[u][w] + G[u][v]);
	    if ( w ) D[v][w-1] = min(D[v][w-1], D[u][w] + G[u][v]/2);
	}
    }
    int minv = INFTY;
    rep(k, c+1) minv = min(minv, D[d][k]);
    return minv;
}

main(){
    int m, a, b, f;
    while( cin >> c >> n >> m >> s >> d && c){
	s--; d--;
	rep(i, n) rep(j, n) G[i][j] = INFTY;
	rep(i, m){
	    cin >> a >> b >> f; a--; b--;
	    G[a][b] = G[b][a] = f;
	}
	cout << dijkstra() << endl;
    }
}

Measured memory_bytes: 904
#include<iostream>
using namespace std;
int main()
{
    int h,w;
    cin >> h >> w;
    while(h!=0)
    {
        for(int i=0; i<h; i++)
        {
            for(int j=0; j<w; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}



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

int main() {
    int N; cin >> N;
    vector<int> p(N);
    rep(i, N){
        cin >> p[i];
    }

    int x = 0;
    int ans = 0;
    while(x < N){
        if(p[x] == x+1){
            ans++;
            x++;
        }
        x++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);
$dp = array_fill(0, 2**$N, 10**18);
$dp[0] = 0;

for($i = 0; $i < $M; $i++){
    fscanf(STDIN, "%d%d", $a, $b);
    $c = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $mask = 2**$N-1;
    foreach($c as $cc){
        $cc--;
        $mask = $mask ^ (1 << $cc);
    }
    for($j = 0, $J = 2**$N; $j < $J; $j++){
        $dp[$j] = min($dp[$j], $dp[$j&$mask] + $a);
    }
}
if($dp[2**$N-1] == 10**18){
    echo -1;exit;
}
echo $dp[2**$N-1];


Measured memory_bytes: 4728
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	edge := make([][]bool, n)
	for i := range edge {
		edge[i] = make([]bool, n)
	}
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		edge[a][b], edge[b][a] = true, true
	}

	ans := 0

	var dfs func(visited []bool, cur int)
	dfs = func(visited []bool, cur int) {
		visited[cur] = true
		finish := true
		for i := 0; i < n; i++ {
			if i == cur {
				continue
			}
			finish = finish && visited[i]
			if edge[cur][i] && !visited[i] {
				dfs(visited, i)
			}
		}
		if finish {
			ans++
		}
		visited[cur] = false
	}
	dfs(make([]bool, n), 0)

	puts(ans)
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

const int N = 1e5 + 10;
const ll INF = (ll)1e60;

struct Edge
{
    int nxt, to;
    ll val;
} eg[N << 1];
int head[N], en, n, siz[N];
ll f[N][3];

void setEdge(int u, int v, ll w)
{
    eg[++en] = (Edge) {head[u], v, w};
    head[u] = en;
}

void dfs(int u, int fa)
{
    siz[u] = 1;
    ll t1 = -INF, t2 = -INF, t3 = -INF, sum = 0;
    for (int e = head[u]; e; e = eg[e].nxt)
    {
        if (e == fa) continue;
        int v = eg[e].to;
        dfs(v, e ^ 1);
        siz[u] += siz[v];
        sum += f[v][0];
        if (f[v][1] - f[v][0] > t1)
        {
            t2 = t1;
            t1 = f[v][1] - f[v][0];
        } else
            if (f[v][1] - f[v][0] > t2)
                t2 = f[v][1] - f[v][0];
        if (f[v][2] - f[v][0] > t3)
            t3 = f[v][2] - f[v][0];
    }
    f[u][0] = sum;
    if (t1 > -INF) f[u][1] = sum + t1;
    if (t2 > -INF) f[u][2] = sum + t1 + t2;
    if (t3 > -INF) f[u][2] = max(f[u][2], sum + t3);
    f[u][2] = max(f[u][2], f[u][1]);
    f[u][1] = max(f[u][1], f[u][0]);
    if (siz[u] < n - siz[u])
    {
        f[u][0] += eg[fa].val * (siz[u] * 2);
        f[u][1] += eg[fa].val * (siz[u] * 2 - 1);
        f[u][2] += eg[fa].val * (siz[u] * 2 - 2);
    }
    if (siz[u] == n - siz[u])
    {
        f[u][0] += eg[fa].val * (siz[u] * 2 - 2);
        f[u][1] += eg[fa].val * (siz[u] * 2 - 1);
        f[u][2] += eg[fa].val * (siz[u] * 2 - 2);
    }
    if (siz[u] > n - siz[u])
    {
        f[u][0] += eg[fa].val * ((n - siz[u]) * 2 - 2);
        f[u][1] += eg[fa].val * ((n - siz[u]) * 2 - 1);
        f[u][2] += eg[fa].val * ((n - siz[u]) * 2);
    }
}

int main()
{
    n = read();
    en = 1;
    for (int i = 1; i < n; i++)
    {
        int u = read(), v = read();
        ll w = read();
        setEdge(u, v, w);
        setEdge(v, u, w);
    }
    dfs(1, 0);
    printf("%lld\n", f[1][2]);
}


Measured memory_bytes: 13184
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string str;
    getline(cin,str);
    int i=0;
    for(i=0; i<str.size(); i++){
        if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
    }
    cout << str << endl;
}


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

struct City {
  int num;
  int p;
  int y;
};

bool ascByYear(const City& c1, const City& c2) { return c1.y < c2.y; }

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

  vector<City> cities;

  rep(i, m) {
    int p, y;
    cin >> p >> y;
    struct City c = {i, p, y};
    cities.push_back(c);
  }

  sort(cities.begin(), cities.end(), ascByYear);

  map<int, int> pCnt;
  vector<string> ans(m);

  for (City c : cities) {
    pCnt[c.p]++;
    stringstream s;
    s << setfill('0') << right << setw(6) << c.p;
    s << setfill('0') << right << setw(6) << pCnt[c.p];
    ans[c.num] = s.str();
  }

  rep(i, m) cout << ans[i] << endl;

  return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9



int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  REP(i, N){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  REP(i, N){
    if(x >= a[i]){
      cnt++;
      x -= a[i];
    }
    else{
      x = 0;
    }
  }
  if(x){
    cnt--;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin>>a>>b;
    
    if(a>0&&b>0){
        cout1("Positive");
    }else if(a<=0&&b>=0){
        cout1("Zero");
    }else{
        int n=abs(a-b);
        if(n%2==0){
            cout1("Negative");
        }else{
            cout1("Positive");
        }
    }
}

Measured memory_bytes: 256
@solve = Hash.new
def solve(i, n)
  @solve[i + n * 100] ||= (
    if n < 0 or n > 20
      0
    elsif i == Last
      n == Eq ? 1 : 0
    else
      solve(i + 1, n + Nums[i]) + solve(i + 1, n - Nums[i])
    end
  )
end

N = gets.to_i
Last = N - 1
Nums = gets.split.map(&:to_i)
Eq = Nums.pop

a = solve(0, 0)
a /= 2 if Nums[0] == 0
p a

Measured memory_bytes: 6204
n, k = map(int, input().split())
pack = []
for i in range(n):
    pack.append(int(input()))

def trucks(p, k):
    t = 0
    c = 1
    for i in range(len(p)):
        if p[i] > k:
            return 1000000
        elif t + p[i] <= k:
            t += p[i]
        else:
            t = p[i]
            c += 1
    return c

minp = int(sum(pack) / k)
maxp = max(pack) * n
while minp < maxp - 1:
    p = int((maxp + minp) / 2)
    if trucks(pack, p) <= k:
        maxp = p
    else:
        minp = p

if trucks(pack, maxp - 1) <= k:
    print(maxp - 1)
else:
    print(maxp)


Measured memory_bytes: 9560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			char[] t = in.nextString().toCharArray();
			int sl = s.length, tl = t.length;

			List<String> list = new ArrayList<>();

			for (int i = 0; i < sl-tl+1; i++) {
				int idx = i;
				boolean ok = true;
				for (int j = 0; j < tl; j++) {
					if (s[idx+j] == '?') {
						continue;
					}
					if (s[idx+j] != t[j]) {
						ok = false;
						break;
					}
				}
				if (ok) {
					char[] ans = s.clone();
					for (int j = 0; j < tl; j++) {
						ans[i+j] = t[j];
					}
					list.add(new String(ans).replaceAll("\\?", "a"));
				}
			}

			Collections.sort(list);

			if (list.size() == 0) {
				out.println("UNRESTORABLE");
			} else {
				out.println(list.get(0));
			}
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 24660
#include <stdio.h>

int main(void){
    int A,B;
    int i;
      scanf("%d", &A);
      scanf("%d", &B);
  
  
 
    int ans[3];
    int a,b;
    a = A-1;
    b = B-1;
    ans[0] = A + a;
    ans[1] = A + B;
    ans[2] = B + b;

    int max;
  max = 0;
    for(i=0;i<3;i++){
        if(max < ans[i]){
            max = ans[i];
        }
    }
    printf("%d",max);
       return 0;
}

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



int ans;
void dfs(vector<int> A, int n, int m, int q, vector<int> a, vector<int> b, vector<int> c, vector<int> d){
    if(A.size() == n) {
        int sum = 0;
        for(int i = 0; i < q; i++) {
            int aa = a.at(i);
            int bb = b.at(i);
            int cc = c.at(i);
            int dd = d.at(i);
            if(A.at(bb) - A.at(aa) == cc) sum += dd;
        }
        ans = max(ans, sum);
        return;
    }
    for(int i = 1; i <= m; i++) {
        if(A.empty()) {
            A.push_back(i);
            dfs(A, n, m, q, a, b, c, d);
        }
        if(A.back() <= i && A.size() < n) {
            A.push_back(i);
            //cout << A.size() << endl;
            dfs(A, n, m, q, a, b, c, d);
            A.pop_back();
        }
    }
}

int main(void){
    int n, m, q;
    vector<int> A = {};
    cin >> n >> m >> q;
    vector<int> a(q),b(q),c(q),d(q);
    for(int i = 0; i < q; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
        a.at(i)--; b.at(i)--;
    }
    dfs(A, n, m, q, a, b, c, d);
    cout << ans << endl;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n;
	cin >> n;
	cout << n / 2 + n % 2 << "\n";
	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
  size_t N;
  string buff;
  
  cin >> N;
  cin >> buff;
  
  if(buff.size() <= N)
  {
    cout << buff << endl;
  }
  else
  {
    cout << buff.substr(0, N) << "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
string s[200010];
map<string, int>mp;
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> s[i];
	}
	rep(i, n) {
		mp[s[i]]++;
	}
	int max = 0;
	for (auto p : mp) {
		if (p.second > max) {
			max = p.second;
		}
	}
	for (auto p : mp) {
		if (p.second == max) {
			cout << p.first << endl;
		}
	}
}


Measured memory_bytes: 26752
import java.util.*;

public class Main{
	int INF = 1 << 24;
	int n;
	int [][] g;
	ArrayList<Node> nlist;
	
	class Node implements Comparable<Node>{
		int [] dis;
		ArrayList<Integer> edge;
		public Node() {
			this.dis = new int[n];
			Arrays.fill(this.dis, -1);
			this.edge = new ArrayList<Integer>();
		}
		@Override
		public String toString() {
			return "Node [dis=" + Arrays.toString(dis) + ", edge=" + edge + "]";
		}
		@Override
		public int compareTo(Node o) {
			return this.edge.size() - o.edge.size();
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			g = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					g[i][j] = sc.nextInt();
				}
			}
			nlist = new ArrayList<Node>();
			
			for(int i = 0; i < g[0][1]-1; i++){
				nlist.add(new Node());
				nlist.get(i).edge.add(i-1);
				if(i != 0){
					nlist.get(i-1).edge.add(i);
				}
			}
			nlist.get(nlist.size()-1).edge.add(-2);
			calcdis(0, 1, 0, -1);
			calcdis(g[0][1] - 2, 1, 1, -1);
			
			for(int i = 2; i < n; i++){
				for(int j = 0; j < nlist.size(); j++){
					int x = g[0][i] - nlist.get(j).dis[0];
					if(x <= 0)continue;
					boolean flg = true;
					for(int k = 1; k < i;k++){
						int nowx = g[k][i] - nlist.get(j).dis[k];
						if(nowx != x){
							flg =false;
							break;
						}
					}
					if(flg){
						for(int k = 0; k < x-1; k++){
							nlist.add(new Node());
							int ind = nlist.size()-1;
							if(k == 0){
								nlist.get(ind).edge.add(j);
								nlist.get(j).edge.add(ind);
							}
							else{
								nlist.get(ind).edge.add(ind-1);
								nlist.get(ind-1).edge.add(ind);
							}
							for(int l = 0; l < i; l++){
								nlist.get(ind).dis[l] = nlist.get(j).dis[l] + k + 1;
							}
						}
						if(x == 1){
							nlist.get(j).edge.add(-i-1);
							calcdis(j, 1, i, -1);
						}
						else{
							nlist.get(nlist.size()-1).edge.add(-i-1);
							calcdis(nlist.size()-1, 1, i, -1);
						}
						break;
					}
				}
			}
			
			//print
			Collections.sort(nlist);
			StringBuilder sb = new StringBuilder();
			for(Node node: nlist){
				sb.append(" " + node.edge.size());
			}
			System.out.println(sb.substring(1));
		}
		
	}
	private void calcdis(int nowpos, int dis, int ind,int prev) {
		if(nowpos < 0) return;
		nlist.get(nowpos).dis[ind] = dis;
		
		for(int i = 0; i < nlist.get(nowpos).edge.size(); i++){
			int nextnode = nlist.get(nowpos).edge.get(i);
			if(nextnode == prev) continue;
			calcdis(nextnode, dis+1, ind, nowpos);
		}
	}
	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define sz(x) (int)x.size()
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i;
    cin>>n;
    int a[n],b[n];
    REP(i,0,n-1) cin>>a[i]>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    if(n&1) {
        n--;
        if(a[n/2]>b[n/2]) cout<<0;
        else cout<<b[n/2]-a[n/2]+1;
    }
    else {
        n--;
        double ma,mb;
        ma=(a[n/2]+a[n/2+1])/2.0;
        mb=(b[n/2]+b[n/2+1])/2.0;
        if(ma>mb) cout<<0;
        cout<<int(2*(mb-ma))+1;
    }
	return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++){
    cin >> d[i];
  }
  int x = 0;
  while (1){
    string s = to_string(x);
    int m = s.size();
    bool ok = false;
    for (int i = 0; i <= n - m; i++){
      bool ok2 = true;
      for (int j = 0; j < m; j++){
        if (d[i + j] != s[j] - '0'){
          ok2 = false;
          break;
        }
      }
      if (ok2){
        ok = true;
        break;
      }
    }
    if (!ok){
      cout << x << endl;
      break;
    }
    x++;
  }
}


Measured memory_bytes: 3288
// Nurbakyt Madibek
// Look at my code! IT'S AWESOME

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <bitset>
#include <unordered_set>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) (int)((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;
typedef pair < int, ull > pu;

const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const double eps = 1e-9;

const int MAX_N = (int)2e5 + 5;
const int mod = (int)1e9 + 7;

int mini[105];

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    string s;
    cin >> s;
    for (int ans = 0; ans < sz(s); ans++) {
        for (int alpha = 0; alpha < 26; alpha++) {
            for (int i = 0; i < sz(s) - ans; i++)
                mini[i] = inf;
            for (int i = 0; i < sz(s); i++) {
                if (s[i] != char(alpha + 'a'))
                    continue;
                for (int j = 0; j < min(i + 1, sz(s) - ans); j++)
                    mini[j] = min(mini[j], abs(j - i));
            }
            bool good = 1;
            for (int i = 0; i < sz(s) - ans; i++)
                if (mini[i] > ans) {
                    good = 0;
                    break;
                }
            if (good) {
//                cout << char(alpha + 'a') << endl;
//                for (int i = 0; i < sz(s) - ans; i++)
//                    cout << mini[i] << ' ';
//                cout << endl;
                cout << ans << endl;
                return 0;
            }
        }
    }
    assert(0);
    return 0;
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    double n, m, k;
    cin >> n >> m >> k;
    int64_t ans = 0;
    if (n/k <= m) ans = 1;
    cout << ( ans ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <map>

using namespace std;

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

#define PB push_back
#define MP make_pair

int main() {
	while (1) {
		int a, b, c, n;
		int ans[300];
		vector<pair<int, pair<int, int> > > v;

		cin >> a >> b >> c;
		if (!a && !b && !c) break;
		cin >> n;

		fill(ans, ans + a + b + c, 2);

		REP(i, n) {
			int in[4];
			REP(j, 4) cin >> in[j]; 
			REP(j, 3) in[j]--;
			if (in[3] == 1) REP(j, 3) ans[in[j]] = 1;
			else v.PB(MP(in[0], MP(in[1], in[2])));
		}
		REP(i, v.size()) {
			int in[3], count = 0;
			bool flag[3] = {0};

			in[0] = v[i].first;
			in[1] = v[i].second.first;
			in[2] = v[i].second.second;

			REP(j, 3) if (ans[in[j]] == 1) {flag[j] = true; count++;}
			if (count == 2) REP(j, 3) if (!flag[j]) ans[in[j]] = 0;
		}

		REP(i, a + b + c) cout << ans[i] << endl;
	}
	return 0;
}

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

typedef long long int ll;
ll mod= 1000000007;

vector<ll> g[100001];
ll black[100001], white[100001];

void dfs(ll current, ll parent)
{
    if(white[current]!=0)
    {
        return;
    }
    white[current]=1;
    black[current]=1;
    for(auto child: g[current])
    {
        if(child!=parent)
        {
            dfs(child, current);

            black[current]*=white[child];
            black[current]%=mod;

            white[current]*=((white[child]+black[child])%mod);
            white[current]%=mod;
       
        }
    }
}

int main()
{

    ll n;
    cin >> n;
   
   
    for(int i=0; i<n-1; i++)
    {
        ll x, y;
        cin >> x >>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1, -1);
    cout << (black[1] + white[1])%mod;

}

Measured memory_bytes: 17576
<?php
  $count   = trim(fgets(STDIN));
  $dice_1  = explode(" ", trim(fgets(STDIN)));
  $a_dice  = array();
  $upper_1 = $dice_1[0];
  $side_1  = array($dice_1[2], $dice_1[1], $dice_1[3], $dice_1[4]);
  $bottom_1  = $dice_1[5];
  for($x=0;$x<($count-1);$x++) {
    $dice_2 = explode(" ", trim(fgets(STDIN)));
    array_push($a_dice, $dice_2);
  }
  for($x=0;$x<($count-1);$x++){
    $side_2  = array($a_dice[$x][2], $a_dice[$x][1], $a_dice[$x][3], $a_dice[$x][4]);
    $upper_2 = $a_dice[$x][0];
    $bottom_2  = $a_dice[$x][5];
    $n = 0;
    while (true) {
      for($i=0;$i<4;$i++) {
        // print_r($side_1);
        // print_r($side_2);
        // print $bottom_1;
        // print $bottom_2;
        // print $upper_1;
        // print $upper_2;
        // print "?????????";
        if (($upper_1 == $upper_2) && ($bottom_1 == $bottom_2) && ($side_1[0] == $side_2[0]) && ($side_1[1] == $side_2[1]) && ($side_1[2] == $side_2[2]) && ($side_1[3] == $side_2[3])) {
          print "No\n";
          return;
        } else {
          $z = array_shift($side_2);
          array_push($side_2, $z);
        }
      }
      if ($n < 4) {
        $b = $bottom_2;
        $u = $upper_2;
        $upper_2 = $side_2[2];
        $bottom_2 = $side_2[0];
        $side_2[2] = $b;
        $side_2[0] = $u;
      } else if ($n < 10 && $n > 3) {
        $b = $bottom_2;
        $u = $upper_2;
        $upper_2 = $side_2[1];
        $bottom_2 = $side_2[3];
        $side_2[1] = $b;
        $side_2[3] = $u;
      } else if ($n > 10) {
        break 1;
      }
      $n++;
    }
  }
  print "Yes";
?>

Measured memory_bytes: 6748
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    // 出力
    if( a == b  && a == c || a != b && a != c && b != c )
      System.out.println("No");
    else
      System.out.println("Yes");
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  vi b(n);
  int maxProfit = 0;
  int mnSoFar = a[0];
  for (int i=1; i<n; i++) {
    int profit = a[i] - mnSoFar;
    b[i] = profit;
    chmin(mnSoFar, a[i]);
    chmax(maxProfit, profit);
  }
  int ans = 0;
  rep(i, n) {
    if (b[i] == maxProfit) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4036
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"["; 
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif     
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,x,t;
        cin>>n>>x>>t;
        ll ans=n/x;
        if(n%x)ans++;
      
        cout<<ans*t<<endl;
    }
} 

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include "atcoder/dsu.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 atcoder;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000000;
const int K = 100000;
const int mod = 1e9 + 7;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, q;
    cin >> n >> q;
    dsu d(n);
    while(q--){
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0){
            d.merge(u,v);
        } else{
            cout << d.same(u, v) << endl;
        }
    }
}


Measured memory_bytes: 3940
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 600
int dirx[] = {1, -1,0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};



//=============================================ASIFAZAD==============================================//

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

int32_t main()
{
    io;
    int n;
    cin>>n;
    vll ad, sub;
    for(int i = 0; i< n; i++)
    {
        ll u, v;
        cin>>u>>v;
        ad.pb(u+v);
        sub.pb(u-v);
    }
    sort(all(ad));
    sort(all(sub));
    cout<<max(ad.back() - ad[0], sub.back() - sub[0]);
    return 0;
}



Measured memory_bytes: 6672
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
    

ll dp[101][5][5][5];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;

    dp[0][0][0][0] = 1;

    rep(i, n){
        rep(j, 5){
            rep(k, 5){
                rep(l, 5){
                    reps(m, 1, 5){
                        if(k == 1 && l == 3 && m == 2) continue;
                        if(k == 3 && l == 1 && m == 2) continue;
                        if(k == 1 && l == 2 && m == 3) continue;
                        if(j == 1 && k == 3 && m == 2) continue;
                        if(j == 1 && l == 3 && m == 2) continue;
                        dp[i+1][k][l][m] += dp[i][j][k][l];
                        dp[i+1][k][l][m] %= ll(1e9+7);
                    }
                }
            }
        }
    }

    ll res = 0;
    reps(i, 1, 5){
        reps(j, 1, 5){
            reps(k, 1, 5){
                res += dp[n][i][j][k];
                res %= ll(1e9+7);
            }
        }
    }

    cout << res << endl;
    
    return 0;
}

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

vector<string> split(string s){
    vector<string> v;
    auto itrst=s.begin();
    itrst++;
    int count=1;
    int target=1;
    for(int i=2;i<s.size();i++){
        if(s[i]=='[')count++;
        else if(s[i]==']')count--;
        
        if(!count){
            v.push_back(s.substr(target,i-target+1));
            target=i+1;
        }
    }
    return v;
}

int minimal(string s){
    if(*s.begin()!='['){
        return (stoi(s)+1)/2;
    }
    int val=0;
    vector<string> v;
    vector<int> value;
    v=split(s);
    
    for(string x:v){
        value.push_back(minimal(x));
    }

    sort(value.begin(),value.end());
    for(int i=0;i<(value.size()+1)/2;i++){
        val+=value[i];
    }
    return val;
}

void solve(string s){
    cout << minimal(s) << endl;
}

int main(void){
    int n;
    string str;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >> str;
        solve(str);
    }
}

Measured memory_bytes: 3336
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main(){
	
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	
	int a=0,b=28;
	string in;
	
	cin >> in;
	
	if(in=="SAT"){
		a=27;
	}else if(in=="SUN"){
		a=21;
	}else if(in=="MON"){
		a=22;
	}else if(in=="TUE"){
		a=23;
	}else if(in=="WED"){
		a=24;
	}else if(in=="THU"){
		a=25;
	}else if(in=="FRI"){
		a=26;
	}
	
	cout << (b-a) << endl;
	
return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

bool sumdec(const pair<ll, ll>& a, const pair<ll, ll>& b) {
  return a.first + a.second > b.first + b.second;
}

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

  ll ans = 0;
  vector<pair<ll, ll>> values(n);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    values[i] = make_pair(a, b);
  }

  sort(ALL(values), sumdec);
  rep(i, n){
    if (i % 2 == 0) {
      ans += values[i].first;
    } else {
      ans -= values[i].second;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



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

	for (int i = 0; i < 10000; i++) {
		sum = b * i + c;
		if (sum % a == 0) break;
	}
	if (sum % a == 0) cout << "YES";
	else cout << "NO";

	cout << endl;
	return 0;
}

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

int main(){
 
  int n, x;
  string mark;
  cin >> n;
  int cards[4][13] = {};
  for(int i = 0; i < n; i++){
      cin >> mark >> x;
      if( mark == "S" ) cards[0][x-1] = 1;
      if( mark == "H" ) cards[1][x-1] = 1;
      if( mark == "C" ) cards[2][x-1] = 1;
      if( mark == "D" ) cards[3][x-1] = 1;
    }
  string str[4] = {"S", "H", "C", "D"};
  for( int j = 0; j < 4; j++){
    for( int k = 0; k < 13; k++){
      if(cards[j][k] == 1) continue;
      cout << str[j] << " " << k + 1 << endl;
    }
  } 
  
  return 0;
}
        


Measured memory_bytes: 3112