akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
    	map<ll,ll>mp;
    	ll n;
    	cin>>n;
    	ll arr[n];
    	for(ll i=0;i<n;i++)
    		cin>>arr[i];
    	sort(arr,arr+n,greater<int>());
    	ll ans=arr[0];
    	mp[arr[1]]+=2;
    	for(ll i=2;i<n;i++)
    	{
    		auto it=mp.rbegin();
    		ll x=it->first;
    		ans+=x;
    		mp[x]--;
    		if(mp[x]==0)
    			mp.erase(x);
    		mp[arr[i]]+=2;
    	}
    	cout<<ans;

    }
    return 0;
}

Measured memory_bytes: 11408
N = int(input())
W = list(map(int, input().split()))
ans = 10000
for i in range(N + 1):
    w1 = sum(W[:i])
    w2 = sum(W[i:])
    s = abs(w1 - w2)

    if s < ans:
        ans = s

print(ans)

Measured memory_bytes: 3060
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(long[]);
    const H = tmp[0], W = tmp[1];
    const s = H.iota.map!(_ => readln.chomp).array;
    foreach (y; 0..H) {
        foreach (x; 0..W) {
            if (s[y][x] == '.') continue;
            long[2][] n;
            if (0 < x) n ~= [x-1,y];
            if (0 < y) n ~= [x,y-1];
            if (x < W-1) n ~= [x+1,y];
            if (y < H-1) n ~= [x,y+1];

            if (n.all!(p => s[p[1]][p[0]] == '.')) {
                writeln("No");
                return;
            }
        }
    }
    writeln("Yes");
}


Measured memory_bytes: 764
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  a=s[0]
  dp[0]=b=5-a
  for i in range(1,w):
    t=s[i]
    dp[i]=b=b+(a^t)
    a=t
  a=s[0]
  b=dp[0]
  for i in range(x,h*x,x):
    t=s[i]
    dp[i]=b=b+(a^t)
    a=t
    for j in range(1,w):
      k=i+j
      sk=s[k]
      l=k-1
      t=dp[l]+(s[l]^sk)
      l=k-x
      u=dp[l]+(s[l]^sk)
      if t>u:t=u
      dp[k]=t
  print(dp[-2]+1>>1)
main()

Measured memory_bytes: 3188
S = input()
tmp = ""
ans = 0
i = 0
while i < len(S):
    if S[i] != tmp:
        tmp = S[i]
        ans += 1
        i += 1
    else:
        if i + 1 < len(S):
            tmp = S[i]+S[i+1]
            ans += 1            
        i += 2    
print(ans)

Measured memory_bytes: 3500
N = int(input())
A = list(map(int,input().split()))

n = [0]*N
n[0] = sum(A)-sum(A[1::2])*2
print(n[0], end = " ")

for i in range(N-1):
  n[i+1] = A[i]*2-n[i]
  print(n[i+1], end = " ")

print("")

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

#define H 250

int main(){
  
  int h,i,l,r,p;
  int A[H+1];
    scanf("%d",&h);

    for(i=1;i<h+1;i++){
     scanf("%d",&A[i]);
   }

    for(i=1;i<h+1;i++){
      l = 2*i;
      r = 2*i+1;
      p = i/2;
  
	printf("node %d: key = %d, ",i,A[i]);
	if(i != 1){
	  printf("parent key = %d, ",A[p]);
	}
	if(l <= h){
	  printf("left key = %d, ",A[l]);
	}
	if(r <= h){
	 printf("right key = %d, ",A[r]);
	}
	printf("\n");    
   }
 
 return 0;
}



Measured memory_bytes: 2044
DESTINATION = [(1, 0), (0, 1), (-1, 0), (0, -1)]


class UnionFindTree():
    def __init__(self, N):
        self.N = N
        self.__parent_of = [None] * N
        self.__rank_of = [0] * N
        self.__size = [1] * N

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, a):
        return self.__size[self.root(a)]

    def groups(self):
        groups = {}
        for k in range(self.N):
            r = self.root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x)-1, input().split())
    Dh, Dw = map(lambda x: int(x)-1, input().split())
    S = [input() for _ in range(H)]
    distance = [[float("inf")] * W for _ in range(H)]
    stack = [[Ch, Cw]]
    cost = 0
    while len(stack):
        visited = set()
        while len(stack):
            h, w = stack.pop()
            visited.add((h, w))
            for dh, dw in DESTINATION:
                nh, nw = h + dh, w + dw
                if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == "." and distance[nh][nw] == float("inf"):
                    stack.append([nh, nw])
                    distance[nh][nw] = cost
        for h, w in visited:
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    nh, nw = h + dh, w + dw
                    if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == "." and distance[nh][nw] == float("inf"):
                        stack.append([nh, nw])
                        distance[nh][nw] = cost + 1
        cost += 1
    if distance[Dh][Dw] == float("inf"):
        print(-1)
    else:
        print(distance[Dh][Dw])


if __name__ == "__main__":
    main()


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

#define N 100010
#define pii pair <int, int>
#define fi first
#define se second
int n, m;
int e[N][2]; 
vector <vector<pii>> G;
int used[N], d[N], del[N], vis[N];  

int fa[N], deep[N], sze[N], son[N], top[N]; 
void DFS(int u) {
	used[u] = 1;
	sze[u] = 1;
	for (auto it : G[u]) {
		int v = it.fi;
		int id = it.se;
		if (v == fa[u]) continue;
		if (used[v]) del[id] = 1;   
		if (!used[v]) {
			if (e[id][0] != u) {
				e[id][0] = u;
				e[id][1] = v;
				d[u] ^= 1;
				d[v] ^= 1;
			}
			fa[v] = u;
			deep[v] = deep[u] + 1;
			e[id][0] = u;
			e[id][1] = v;
			DFS(v);
			sze[u] += sze[v];
			if (!son[u] || sze[v] > sze[son[u]]) son[u] = v;  
		}
	}
}
void gettop(int u, int tp) { 
	top[u] = tp;
	if (!son[u]) return;
	gettop(son[u], tp);
	for (auto it : G[u]) if (!del[it.se]) {
		int v = it.fi;
		if (v != fa[u] && v != son[u]) {
			gettop(v, v);
		}
	} 
}
int query(int u, int v) {
	while (top[u] != top[v]) {
		if (deep[top[u]] < deep[top[v]]) swap(u, v);
		u = fa[top[u]];
	}
	if (deep[u] > deep[v]) swap(u, v);
	return u;
}

void DFS2(int u) {
	for (auto it : G[u]) if (!del[it.se]) {
		int v = it.fi;
		if (v != fa[u]) {
			DFS2(v);
			vis[u] += vis[v];
		}
	}
}

void DFS3(int u) {
	for (auto it : G[u]) if (!del[it.se]) {
		int v = it.fi;
		int id = it.se;
		if (v != fa[u]) {
			if (vis[v] % 2) {
				e[id][0] = v;
				e[id][1] = u;
			}	
			DFS3(v);
		}
	}
}

int main() {
	while (scanf("%d%d", &n, &m) != EOF) {
		G.clear(); G.resize(n + 1);
		memset(used, 0, sizeof used);
		memset(d, 0, sizeof d);
		memset(son, 0, sizeof son);
		memset(del, 0, sizeof del);
		memset(vis, 0, sizeof vis);
		for (int i = 1; i <= m; ++i) {
			int &u = e[i][0], &v = e[i][1];
			scanf("%d%d", &u, &v);
		    d[u] ^= 1; 	
			G[u].push_back(pii(v, i));
			G[v].push_back(pii(u, i)); 
		}
		DFS(1); gettop(1, 1);
		vector <int> vec;
		for (int i = 1; i <= n; ++i) if (d[i]) {
			vec.push_back(i);
		}
		if (vec.size() % 2 == 1) {
			puts("-1");
		} else {
			while (!vec.empty()) {
				int u = vec.back(); vec.pop_back();
				int v = vec.back(); vec.pop_back();
				int lca = query(u, v);
				++vis[u]; ++vis[v];
				vis[lca] -= 2;
			}
			DFS2(1); 
			DFS3(1);
			for (int i = 1; i <= m; ++i) printf("%d %d\n", e[i][0], e[i][1]);
		}
	}
	return 0;
}



Measured memory_bytes: 17912
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  int[] d; readM(n, d);

  writeln(d.sort().array.uniq.array.length);
}


Measured memory_bytes: 256
def A():
    d, t, s = map(int, input().split())
    print("Yes" if t*s>=d else "No")

def B():
    s = input()
    t = input()
    sa = len(s) - len(t)
    ret = 10000000000
    for i in range(sa+1):
        cnt = 0
        for j in range(len(t)):
            if s[j+i] != t[j]: cnt += 1
        ret = min(ret, cnt)
    print(ret)

def C():
    int(input())
    A = list(map(int, input().split()))
    S = sum(A)
    T = 0
    for e in A:
        T += e*e
    print((S * S - T)//2)

class UF:
    def __init__(self, N):
        self.N = N
        self.sz = [1] * N
        self.par = [i for i in range(N)]
        self.d = [1] * N

    def find(self, x):
        if self.par[x] == x: return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return False
        if self.d[y] > self.d[x]:
            self.par[x] = y
            self.sz[y] += self.sz[x]
        else:
            self.par[y] = x
            self.sz[x] += self.sz[y]
            if self.d[x] == self.d[y]: self.d[x] += 1

def D():
    n, m = map(int, input().split())
    uf = UF(n+1)
    for i in range(m):
        a, b = map(int, input().split())
        uf.unite(a, b)
    print(max(uf.sz))

D()


Measured memory_bytes: 90340
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	string s;
	while(getline(cin,s)>0){
		for(int i=0;i<=25;i++){
			if(s.find("the")!=string::npos || s.find("this")!=string::npos
			   ||s.find("that")!=string::npos){
				cout<<s<<endl;
				break;
			}

			for(unsigned int j=0;j<s.size();j++){
				if(s[j]>='a' && s[j]<='z') s[j]=(s[j]-'a'+1)%26+'a';
			}

		}
	}
	return 0;
}

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

int main() {
    string S;
    int Q, cnt = 0; cin >> S >> Q;
    vector<pair<int, char>> formation(S.size());
    for (int i = 0; i < S.size(); i++) {
        formation.at(i) = make_pair(i, S.at(i));
        cnt++;
    }
    int left = 0, right = cnt-1;
    bool key = true;
    for (int i = 0; i < Q; i++) {
        int query; cin >> query;
        if (query == 1) {
            if (key) key = false;
            else key = true;
        } else {
            int F;
            char C; cin >> F >> C;
            cnt++;
            if (key) {
                if (F == 1) {
                    left--;
                    formation.push_back(make_pair(left, C));
                } else {
                    right++;
                    formation.push_back(make_pair(right, C));
                }
            } else {
                if (F == 1) {
                    right++;
                    formation.push_back(make_pair(right, C));
                } else {
                    left--;
                    formation.push_back(make_pair(left, C));
                }
            }
        }
    }
    sort(formation.begin(), formation.end());
    if (key) {
        for (int i = 0; i < cnt; i++) {
            cout << formation.at(i).second;
        }
    } else {
        for (int i = cnt - 1; i >= 0; i--) {
            cout << formation.at(i).second;
        }
    }
    cout << endl;
}

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

using ll = long long;

int main() {
    string S;
    cin >> S;
    int n = S.size(), m = n / 2;
    char c = S[m];
    rep(i, m) {
        if (c != S[m - i - 1] || c != S[n - m + i]) {
            cout << n - m + i << endl;
            return 0;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i = (int)a; i < (int)b; ++i)
#define SORT(v) std::sort(v.begin(), v.end())
#define ALL(v) v.begin(), v.end()
#define cosnt const
using ll = long long;
using std::cin;
using std::cout;
constexpr char endl = '\n';

int main(){
  ll n, i, j;
  while(cin >> n >> i >> j, n || i || j) {
    std::string ans;
    --i; --j;
    for(int p = n-1; p >= 0; --p) {
      ans += ((i & 1) == (j & 1)) ? 'L' : 'R';
      if(1ll << p > i) i = (1ll << (p + 1)) - 1 - i;
      i -= 1ll << p;
      j >>= 1;
    }
    std::reverse(ALL(ans));
    std::cout << ans << std::endl;
  }
}



Measured memory_bytes: 3144
from collections import deque
N = int(input())
lis = []
ans = []
lis_append=lis.append
for i in range(N):
    x,l = map(int, input().split(" "))
    lis_append((x+l,x-l))
lis.sort()
lis = deque(lis)
ans.append(lis.popleft())
while lis:
    a = lis.popleft()
    if a[1] >= ans[-1][0]:
        ans.append(a)
print(len(ans))

Measured memory_bytes: 19108
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>

using namespace std;

vector<string> split(const string &str, char delim){
	vector<string> result;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos){
		result.push_back(string(str, current, found - current));
		current = found + 1;
	}
	result.push_back(string(str, current, str.size() - current));
	return result;
}


int main(){
	string field;
	getline(cin, field);
	vector<std::string> result = split(field, ' ');
	
	int i = 0;
	while(i < result.size()){
		if (result[i] == "*" || result[i] == "-" || result[i] == "+"){
			int Num1, Num2, Answer, PNum1, PNum2;
			// もどして探してくる
			int j = i;
			--j;
			while (result[j] == ""){ --j; }
			PNum1 = j;
			--j;
			while (result[j] == ""){ --j; }
			PNum2 = j;

			Num1 = atoi(result[PNum1].c_str());
			Num2 = atoi(result[PNum2].c_str());

			

			if (result[i] == "*"){
				Answer = Num1 * Num2;
			}
			else if (result[i] == "-"){
				Answer = Num2 - Num1;
			}
			else if (result[i] == "+"){
				Answer = Num1 + Num2;
			}

			char StrToNum[32];
			sprintf(StrToNum, "%d", Answer);
			string pushBack = StrToNum;
			result[PNum2] = pushBack;
			result[PNum1] = "";
			result[i] = "";
			i = 0;
			
		}
		else{
			++i;
		}
	}
	
	cout << result[0] << endl;
	
	return 0;
}

Measured memory_bytes: 1232
import fractions 
N=int(input())
A=list(map(int,input().split()))
t=A[0]
for i in range(1,N):
  t=(t*A[i])//fractions.gcd(t,A[i])
ans=0
for i in range(N):
  ans+=t//A[i]
print(ans%(10**9+7))


Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

long power(long a, long b) {
    return b ? power(a*a%MOD, b/2) * (b%2?a:1)%MOD:1;
}

long perm(int N, int K) {
    long x = 1;
    for(int i = 1; i <= K; i++) x = x * (N-i+1) % MOD;
    return x % MOD;
}

long comb(int N,int K) {
    long x = 1, y = 1;
    for(int i = 1; i <= K; i++) {
        x = x * (N-i+1) % MOD;
        y = y * i % MOD;
    }
    return x * power(y, MOD-2) % MOD;
}

bool isprime(int n) {
    if(n < 2) return false;
    for(int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

void dfs(const vector<vector<int> > &G, int v, vector<int> &seen) {
    seen[v] = true;

    for(int next_v : G[v]) {
        if(seen[next_v]) continue;
        dfs(G, next_v, seen);
    }
}

void yes() { cout << "Yes" << endl;}
void no() { cout << "No" << endl;}


int main() {
  
  int s, w; cin >> s >> w;
  if (s > w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
    

}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin >> n;
  vector<ll>v(n),sum(n);
  rep(i,n)cin >> v[i];
  rep(i,n){
    if(i)sum[i] += sum[i - 1] + v[i];
    else sum[i] += v[i];
  }
  ll ans = 10000000000;
  ll up = 0,cnt = 0;
  rep(i,n){// - + - +
    if(i % 2 == 0){
      if(sum[i] + up < 0)continue;
      else{
        cnt += sum[i] + up + 1;
        up -= sum[i] + up + 1;
      }
    }
    else{
      if(sum[i] + up> 0)continue;
      else{
        cnt += abs(sum[i] + up)+ 1;
        up += abs(sum[i] + up) + 1;
      }
    }
  }
  ans = cnt;
  up = 0;
  cnt = 0;
  rep(i,n){// - + - +
    if(i % 2 != 0){
      if(sum[i] + up < 0)continue;
      else{
        cnt += sum[i] + up + 1;
        up -= sum[i] + up + 1;
      }
    }
    else{
      if(sum[i] + up> 0)continue;
      else{
        cnt += abs(sum[i] + up)+ 1;
        up += abs(sum[i] + up) + 1;
      }
    }
  }
  cout << min(cnt,ans) << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
     
#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()
     
using namespace std;
using ll = long long;
using P = pair<int, int>;
     
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( a > b ) { a = b; return 1; } return 0; }
     
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
  string s; cin >> s;

  ll ans = 0;
  for( int bit = 0; bit < 1 << ( s.size() - 1 ); bit++ ){
    string t;
    REP( i, s.size() ){
      t += s[i];
      if( bit >> i & 1 ){
        ans += stoi( t );
        t = "";
      }
    }
    if( t != "" ) ans += stol( t );
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111



	void solve(){


		ini(n);
		int pos = 0;
		for(int i = 1;i*i<=n;i++){
			if(n%i == 0)pos = i;
		}
		pos  = n/pos;
		int tmp = 0;
		while(pos){
			pos/=10;
			tmp++;
		}
		out(tmp);







	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 256
import kotlin.math.*

fun main() {
    println(solve())
}

val solve: () -> Any = solve@{
    val N = readInt()
    val xy = List(N) { readIntList() }
    val ps = xy.map { it[0] + it[1] }
    val ng = xy.map { it[0] - it[1] }

    listOf(
        ps.max()!! - ps.min()!!,
        ng.max()!! - ng.min()!!,
        -ng.max()!! + ng.min()!!
    ).max()!!
}

val mod: Int = 1_000_000_007


fun readString() = readLine()!!
fun readStringList() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

fun <E> List<E>.toPair() = this[0] to this[1]

fun <T> readPair(t: (String) -> T) = readPair(t, t)
fun <S, T> readPair(s: (String) -> S, t: (String) -> T) =
    readLine()!!.split(" ").let { Pair(s(it[0]), t(it[1])) }

fun Int.pow(n: Int) = this.toDouble().pow(n).toInt()

fun minAndMax(a: Int, b: Int) = if (a < b) a to b else b to a

fun <T> T.ifOrThis(bool: (T) -> Boolean, trans: (T) -> T) = if (bool(this)) trans(this) else this
fun <T> T.ifOrThis(bool: Boolean, trans: (T) -> T) = if (bool) trans(this) else this

Measured memory_bytes: 82700
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    LL d,s,t;cin >> d >> s >> t;
    if(s * t < d) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 3624
def difference(two_lists):
    return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]


n = int(input())

txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
dtxy = list(map(difference, zip(txy, txy[1:])))

for i in range(n):
    dt, dx, dy = dtxy[i]
    if  dx + dy > dt or (dt - dx - dy) % 2:
        print("No")
        exit()
print("Yes")

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

int main(){
  int D;
  cin >> D;
  vector<int> C(26);
  for(int i=0;i<26;i++){
    cin >> C.at(i);
  }
  vector<vector<int>> S(D,vector<int> (26));
  for(int i=0;i<D;i++){
    for(int j=0;j<26;j++){
      cin >> S.at(i).at(j);
    }
  }
  for(int i=0;i<14;i++){
    for(int j=0;j<26;j++){
      cout << j+1 << endl;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#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 rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


vlint base_3(int k){
    vlint ret; while (k > 0){ ret.pb(k % 3); k /= 3;} reverse(all(ret)); return ret;
}

int main(){
    LINT(n); vlint a(n); line(a);
    lint ret = 0;
    rep1(i, n){
        if (a[i-1] > a[i]){
            ret += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    print(ret);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int two, four, odd;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin>>n;
	REP(i, n){
		cin>>a;
		if(a%4==0){
			++four;
		}
		else if(a&1){
			++odd;
		}
		else{
			++two;
		}
	}
	if(two){
		cout<<(odd<=four ? "Yes" : "No")<<'\n';
	}
	else{
		cout<<(odd<=four+1 ? "Yes" : "No")<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
XY = [tuple(map(int, input().split())) for _ in range(n)]

# 左下右上
mi = min(XY, key=lambda x: x[0] + x[1])
ma = max(XY, key=lambda x: x[0] + x[1])
ans1 = ma[0]-mi[0] + ma[1]-mi[1]

# 左上右下
mi = min(XY, key=lambda x: x[0] + (10**9)-x[1])
ma = min(XY, key=lambda x: (10**9)-x[0] + x[1])
ans2 = abs(ma[0]-mi[0]) + abs(ma[1]-mi[1])
print(max(ans1, ans2))


Measured memory_bytes: 99448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char a[101];
    int i,j,n,h,w;
    while(~scanf("%d %d",&h,&w))
    {
        for(i=1;i<=h;i++)
        {
            scanf("%s",a);
            printf("%s\n",a);
            printf("%s\n",a);
        }

    }
}


Measured memory_bytes: 1632
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;
   string S;
   cin >> S;

   for (char& c : S)
      c = 'A' + (c - 'A' + N) % 26;
   
   cout << S << endl;

   return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

@mt
def slv(N, K, A):
    from fractions import gcd
    G = reduce(gcd, A)
    if K <= max(A) and K % G == 0:
        return 'POSSIBLE'
    else:
        return 'IMPOSSIBLE'

def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 80364
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
  int a,b,c,d,ans;
  cin>>a>>b>>c>>d;
  if(a>=c){
    if(a>=d){
      ans=0;
    }else if(b>=d) ans=d-a;
    else ans=b-a;
  }else{
    if(c>=b) ans=0;
    else if(d>=b) ans=b-c;
    else ans=d-c;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
X,Y,Z,K=map(int,input().split())
lst1=sorted(list(map(int,input().split())))
lst2=sorted(list(map(int,input().split())))
lst3=sorted(list(map(int,input().split())))
ans=[]
heapq.heappush(ans,[-(lst1[-1]+lst2[-1]+lst3[-1]),1,1,1])
tmp=0
while tmp!=K:
  H=heapq.heappop(ans)
  V=-1*H[0]
  tmp+=1
  a,b,c=-H[1],-H[2],-H[3]
  print(V)
  if a-1>=-X and [-(lst1[a-1]+lst2[b]+lst3[c]),-a+1,-b,-c] not in ans:
    heapq.heappush(ans,[-(lst1[a-1]+lst2[b]+lst3[c]),-a+1,-b,-c])
  if b-1>=-Y and [-(lst1[a]+lst2[b-1]+lst3[c]),-a,-b+1,-c] not in ans :
    heapq.heappush(ans,[-(lst1[a]+lst2[b-1]+lst3[c]),-a,-b+1,-c])
  if c-1>=-Z and [-(lst1[a]+lst2[b]+lst3[c-1]),-a,-b,-c+1] not in ans:
    heapq.heappush(ans,[-(lst1[a]+lst2[b]+lst3[c-1]),-a,-b,-c+1])

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

const int MAXN = 1010;
const int MAXC = 33;
int N, C;
int D[MAXC][MAXC];

int costClass[3][MAXC];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> C;
	for (int x = 1; x <= C; x++) {
		for (int y = 1; y <= C; y++) {
			cin >> D[x][y];
		}
	}

	vector<int> classes[3];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int c; cin >> c;
			classes[(i+j)%3].push_back(c);
		}
	}

	for (int r = 0; r < 3; r++) {
		for (int tgt = 1; tgt <= C; tgt++) {
			for (int c : classes[r]) {
				costClass[r][tgt] += D[c][tgt];
			}
		}
	}

	int ans = 1e9;
	for (int x = 1; x <= C; x++) {
		for (int y = 1; y <= C; y++) {
			if (x == y) continue;
			for (int z = 1; z <= C; z++) {
				if (x == z || y == z) continue;
				ans = min(ans, costClass[0][x] + costClass[1][y] + costClass[2][z]);
			}
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1520
n, k = (int(x) for x in input().split())
r, s, p = (int(x) for x in input().split())
t = input()
ans = 0
flg = [0] * k
for i in range(n):
    if t[i] == 'r':
        v = p
    elif t[i] == 's':
        v = r
    else:
        v = s
    if i < k:
        ans += v
    else:
        if t[i] == t[i - k]:
            if flg[i % k] == 0:
                flg[i % k] = 1
            else:
                ans += v
                flg[i % k] = 0
        else:
            ans += v
            flg[i % k] = 0
print(ans)

Measured memory_bytes: 3956
import bisect

x = int(input())

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return table

table = sieve(10**5 + 100)

print(table[bisect.bisect_left(table, x)])


Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000
int A[MAX],n;
int partition(int p,int r)
{
	int x,i,j,t;
	x = A[r];
	i = p - 1;
	for(j = p;j < r;j++)
	{
		if(A[j] <= x)
		{
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}
int main(int argc, char const *argv[])
{
	int i,q;
	scanf("%d",&n);
	for(i = 0;i < n;i++)
	{
		scanf("%d",&A[i]);
	}
	q = partition(0,n - 1);
	for(i = 0; i < n;i++)
	{
		if(i) printf(" ");
		if(i == q) 
			{
				printf("[");
			}
				printf("%d",A[i] );
			
		if(i == q) printf("]");
	}
	printf("\n");
	return 0;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string S;
    int N,K;
    cin >> N >> K >> S;
    if(S.at(K-1)=='A') S.at(K-1) = 'a';
    else if(S.at(K-1)=='B') S.at(K-1) = 'b';
    else S.at(K-1) = 'c';
    cout << S << endl;
}

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

using namespace std;

int main()
{
    int h1, s1, h2, s2;
    cin >>h1 >>s1 >> h2 >> s2;
    if (h2-s1 == 0) {cout << "YES";return 0 ;}
   int eiles0=(h2+s1-1)/s1;
   int eiles2=(h1+s2-1)/s2;
    if (eiles0 > eiles2 )cout << "No";
    else cout << "Yes";

}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int N;
    cin >> N;
    map<char,ll> cnt;
    string c = "MARCH";
    REP(i,N){
        string s;
        cin >> s;
        cnt[s[0]]++;
    }
    ll ans = 0;
    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans += cnt[c[i]]*cnt[c[j]]*cnt[c[k]];
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 998244353
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

template<typename Monoid>
struct SegmentTree{
    using F=function<Monoid(Monoid,Monoid)>;
    int sz;
    vector<Monoid> seg;
    const F f;
    const Monoid gen;
    SegmentTree(int n,const F f,const Monoid &gen):f(f),gen(gen){
        sz=1;
        while(sz<n)sz<<=1;
        seg.assign(2*sz,gen);
    }
    void set(int k,const Monoid &x){
        seg[k+sz]=x;
    }
    void build(){
        for(int k=sz-1;k>0;k--) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        while(k>>=1) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
    // [a,b)
    Monoid query(int a,int b){
        Monoid L=gen,R=gen;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L,seg[a++]);
            if(b&1) R=f(seg[--b],R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k)const {
        return seg[k+sz];
    }
};
int f(int a,int b){
    if(a<b) return b;
    else return a;
}

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

    int n;cin>>n;
    vector<pair<ll,ll>> v(n);
    rep(i,n){
        cin>>v[i].first>>v[i].second;
    }
    sort(ALL(v));
    vector<ll> x(n),d(n);
    vector<int> reach(n,0);
    reach[n-1]=n-1;
    rep(i,n) x[i]=v[i].first,d[i]=v[i].second;
    SegmentTree<int> seg(n,f,0);
    seg.set(n-1,reach[n-1]);seg.build();
    for(int i=n-2;i>=0;i--){
        int idx=lower_bound(ALL(x),x[i]+d[i])-x.begin();
        reach[i]=max(i,seg.query(i,idx));
        seg.update(i,reach[i]);
    }
    vector<ll> dp(n+1,0);
    dp[0]=1;
    rep(i,n){
        dp[i+1]+=dp[i];dp[i]%=mod;
        dp[reach[i]+1]+=dp[i];dp[reach[i]+1]%=mod;
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int X,Y;
    cin >> X >> Y;
    for(int i = 0;i <= X;i++) {
        if(i * 2 + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin >> k;

    int x = k / 2;
    if (k % 2 == 0) {
        cout << x * x << endl;
    } else {
        cout << x * (x + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys


def main():
    n, m = map(int, sys.stdin.readline().split())
    g = [[] for i in range(n)]
    deg = [0] * n
    for i in range(m):
        l, r, d = map(int, sys.stdin.readline().split())
        g[l - 1].append((r - 1, d))
        deg[r - 1] += 1
    dis = [-1] * n
    for i in range(n):
        if deg[i]:
            continue
        stack = list([i])
        dis[i] = 0
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if dis[u] == -1:
                    dis[u] = dis[v] + d
                    stack.append(u)
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 70064
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))

c1, c2 = 0, 0
for i in range(m):
    if a[i] < x:
        c1 += 1
    else:
        c2 += 1
print(min(c1, c2))


Measured memory_bytes: 2940
import sys


def solve(inp):
    (N, K) = map(int, inp.readline().split(' '))
    L = list(reversed(sorted(map(int, inp.readline().split(' ')))))

    r = 0
    for i in range(K):
        r += L[i]

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/

int main() {
	int N; cin >> N;
	bool ok = false;
	int max = 0;
	int ans = 0;
	VLL a(N);
	for (int i = 0;i < N;i++) cin >> a[i];
	for (int i = 0;;i++) {
		bool ok = false;
		for (int j = 0;j < N;j++) {
			if (a[j]%2 == 0) {
				ok = true;
				a[j] /= 2;
				ans++;
			}
		}
		if (!ok) {
			cout << ans << endl;
			break;
		}
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,m;
    cin >> n >> m;
    vector<bool> liked(m,true);
    rep(i,n) {
        int k;
        cin >> k;
        vector<bool> now(m,false);
        rep(j,k) {
            int a;
            cin >> a;
            a--;
            now[a] = true;
        }
        rep(i,m) liked[i] = liked[i]&&now[i];
    }
    int ans = 0;
    rep(i,m) if(liked[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
unsigned long long factorial(int n)
{
	if (n == 1)
	{
		return 1;
	}
	else
	{
		return n * factorial(n - 1);
	}
}
int main()
{
	int n;
	std::cin >> n;
	std::cout << factorial(n) << std::endl;
	return 0;
}


Measured memory_bytes: 3056
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n];
		int[] a = new int[n];
		boolean[] tt = new boolean[n];
		boolean[] aa = new boolean[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		tt[0] = true;
		aa[n - 1] = true;
		for (int i = 1; i < n; i++) {
			if (t[i] > t[i - 1]) {
				tt[i] = true;
			}
		}
		for (int i = n - 2; i >= 0; i--) {
			if (a[i] > a[i + 1]) {
				aa[i] = true;
			}
		}
		long ans = 1;
		int div = 1000000007;
		for (int i = 0; i < n; i++) {
			if (aa[i] && !tt[i]) {
				if (a[i] <= t[i]) {
				} else {
					ans = 0;
					break;
				}
			} else if (!aa[i] && tt[i]) {
				if (a[i] >= t[i]) {
				} else {
					ans = 0;
					break;
				}
			} else if (aa[i] && tt[i]) {
				if (a[i] == t[i]) {
				} else {
					ans = 0;
					break;
				}
			} else if (!aa[i] && !tt[i]) {
				ans = (ans * Math.min(a[i], t[i])) % div;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 82428
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s;
    int k;
    cin >> s >> k;
    int n = s.length();
    rep(i, n) {
        if (s[i]=='a') continue;
        int sn = 'z' + 1 - s[i];
        if (sn > k) continue;
        k -= sn;
        s[i] = 'a';
    }
    k %= 26;
    rep(i, k) {
        s[n-1]++;
        if (s[n-1] > 'z') s[n-1] = 'a';
    }
    cout << s << endl;
    return 0;
}

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

int main()
{
    long long m,n;
    scanf("%lld%lld",&n,&m);
    if(m>2&&n>2) printf("%lld\n",(m-2)*(n-2));
    else if(m==1&&n>1) printf("%lld\n",n-2);
    else if(n==1&&m>1) printf("%lld\n",m-2);
    else if(m==1&&n==1) printf("1\n");
    else if(m==2||n==2) printf("0");
}


Measured memory_bytes: 256
n;s[101][26];p[101];r[101];k[100];q[100][100];t[26];G(i){scanf("%s",t);for(i=0;i<n&&strcmp(s[i],t);i++);return i;}R(o){int m=p[o],i;if(r[o]+1)for(m=i=0;i<k[r[o]];)m+=R(q[r[o]][i++]);return p[o]<m?p[o]:m;}main(){int i,j,m;for(;scanf("%d",&n),n;printf("%d\n",R(G()))){for(i=n;i--;)scanf("%s%d",s[i],p+i);memset(r,i,404);for(scanf("%d",&m);m--;){r[G()]=m;scanf("%d",k+m);for(j=k[m];j--;)q[m][j]=G();}}exit(0);}

Measured memory_bytes: 0
n,m,k = map(int,input().split())

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

a = [0]*(n+1)
b = [0]*(m+1)
for i in range(n):
    a[i+1] = a[i] + A[i]
    
for i in range(m):
    b[i+1] = b[i] + B[i]

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    
    while b[j] > k-a[i]:
        j -= 1
    
    ans = max(ans,i+j)
    
print(ans)


Measured memory_bytes: 47488
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 21:52:29 2018

@author: Yuki
"""

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

if N==1 and M == 1:
    print(1)
elif min(N, M)  == 1:
    print(max(N, M) - 2)
else:
    print((N - 2) * (M - 2))

Measured memory_bytes: 3060
N = gets.to_i
AS = N.times.map { gets.to_i }
x = 1
num = 0
AS.each do |a|
  if x == 1
    num += a - 1
    a = 1
  elsif x < a
    if a % x == 0
      num += (a - 1) / x
      a = x - 1
    else
      num += a / x
      a %= x
    end
  end
  if x == a
    x += 1
  end
end
puts num


Measured memory_bytes: 2996
#include <stdio.h>
int main(void) {
    int b1,b2,b3;
    scanf("%d %d %d",&b1,&b2,&b3);
    if (b3==1||(b1==1&&b2==1)) {
        printf("Open\n");
    } else {
        printf("Close\n");
    }
    return 0;
}

Measured memory_bytes: 584