akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

bool f(vector<int> H, vector<int> W, vector<string> v, int k) {
	for (int z = 0; z < H.size(); z++) {
		for (int i = 0; i < v[0].size(); i++) {
			v[H[z]][i] = '?';
		}
	}
	for (int z = 0; z < W.size(); z++) {
		for (int i = 0; i < v.size(); i++) {
			v[i][W[z]] = '?';
		}
	}
	int cnt = 0;
	for (int i = 0; i < v.size(); i++)for (int j = 0; j < v[0].size(); j++)cnt += (v[i][j] == '#');
	// for (int z = 0; z < H.size(); z++)cout << H[z] << ' '; cout << endl;
	// for (int z = 0; z < W.size(); z++)cout << W[z] << ' '; cout << endl;
	// for (int i = 0; i < v.size(); i++) {
	// 	for (int j = 0; j < v[0].size(); j++) {
	// 		cout << v[i][j];
	// 	}
	// 	cout << endl;
	// }
	if (cnt == k) {

		return 1;
	}
	return 0;
}

void solve() {
	int h, w, k; cin >> h >> w >> k;
	vector<string> v(h);
	for (auto &i : v)cin >> i;
	int ans = 0;
	for (int i = 0; i < (1 << h); i++) {
		vector<int> H;
		for (int j = 0; j < h; j++)if ((1 << j)&i)H.push_back(j);
		for (int j = 0; j < (1 << w); j++) {
			vector<int> W;
			for (int z = 0; z < w; z++)if ((1 << z)&j)W.push_back(z);
			ans += f(H, W, v, k);
		}

	}
	cout << ans;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>

using namespace std;

int a[1000000];

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

	vector<int> g;
	int h = 1;
	g.push_back(h);
	while (h * 3 + 1 < n) {
		h = h * 3 + 1;
		g.push_back(h);
	}
	for (int k = g.size() - 1; k >= 0; k--) {
		for (int i = g[k]; i < n; i++) {
			int v = a[i], j = i - g[k];
			while (j >= 0 && a[j] > v) {
				a[j + g[k]] = a[j];
				j -= g[k];
				cnt++;
			}
			a[j + g[k]] = v;
		}
	}
	cout << g.size() << endl;
	for (int i = 0; i < g.size(); i++) {
		if (i != 0)cout << " ";
		cout << g[g.size()-i-1];
	}
	cout << endl << cnt << endl;
	for (int i = 0; i < n; i++)cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 7036
# E
N,K=map(int,input().split())
MOD=10**9+7
# e.g.
# N=3,K=4
#   gcd(A)=4 -> (4,4,4)=1**3=1
#   gcd(A)=3 -> (3,3,3)=1**3=1
#   gcd(A)=2 -> (2or4,2or4,2or4)-(4,4,4)=2**3-1**3=7
#   gcd(A)=1 -> (1~4,1~4,1~4)-上全部=4**3-(2**3-1**3)-1**3-1**3=55
# and=1*4+1*3+7*2+55*1=76
#
# gcd(A)=xとなるAをx=K,K-1,...,1として数えていく。
# A=(x or 2x or 3x or ...,x or 2x or 3x or ...,...)という形をしているが
# 2x,3x,...がK以下ならxより大きい場合で既にカウントしてしまっている
# (gcd(2x,2x)=2xをgcd(2x,2x)=xとして数えてしまっている)
# ->2x,3xについてカウント済みならそれを引けばいい: Kから数えればいい

ans=0 # 出力する答え
GCD=[0 for _ in range(K+1)] # GCD[i]:gcd(A)=iとなるAの総数
for x in range(K,0,-1): # gcd(A)=xとなるAを各xで数える
    Ai_cnt=K//x # 各Aiについてとりうる値の総数(x,2x,3x,...<=K)
    rep=0 # 既にカウント済みなものをここに数えてまとめておく

    # 既にカウント済みがあるか数える
    check=2*x
    while check<=K: #これを満たすならK以下である
        rep+=GCD[check] # 満たしたのでrepに足す
        check+=x # 次のxの倍数について調べるために足す

    # repができたのでGCD[i]に記録
    GCD[x]=pow(Ai_cnt,N,MOD)-rep #繰り返し2乗法: O(logN)
    # kについては完成したので,ansに足す
    ans+=x*(GCD[x])
    ans%=MOD
# 出力する前に計算量の確認
# 計算量はおよそ各xでK//x回の計算とpowが必要なので
#   sum(log(N)+K//x x:1toK)
# <=K*(log_2(N)+sum(1/x 1toK))
# ~ K*(log_2(N)+log_e(K))
# < (10**5)*(2*log_2(10**5))
# < 4*10**6
# よってギリ間に合うと思われる
print(ans)


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

int main() {
  int n, k;
  cin >> n >> k;
  int hn[n];
  rep(i,n){
    cin >> hn[i];
  }
  vector<int> dp(n, -1);
  dp[0] = 0;
  rep(i,n) rep(j,k) {
    if (i+j+1 < n) {
      if (dp[i+j+1] == -1) {
        dp[i+j+1] = dp[i] + abs(hn[i] - hn[i+j+1]);
      } else {
        dp[i+j+1] = min(dp[i+j+1], dp[i] + abs(hn[i] - hn[i+j+1]));
      }
    }
  }
  cout << dp[n-1];
  
}


Measured memory_bytes: 1024
def p_b():
    N, T = map(int, input().split())
    ans = 10 ** 9
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(ans, c)
    print(ans if ans != 10 ** 9 else "TLE")
    
p_b()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct mint {
	ll x;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
	assert(n < mod);
	fact[0] = 1;
	for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
	ifact[n] = fact[n].inv();
	for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
	if (k < 0 || k > n) return 0;
	return fact[n]*ifact[k]*ifact[n-k];
  }
};

combination comb(3000010);

mint solve(int x,int y){
	mint ret=0;
	rep(i,x+1){
		ret+=comb(i+1+y,y);
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> r(2),c(2);
	cin>>r[0]>>c[0]>>r[1]>>c[1];
	mint ans=solve(r[1],c[1])-solve(r[1],c[0]-1)-(solve(r[0]-1,c[1])-solve(r[0]-1,c[0]-1));
	cout<<ans.x<<endl;
}

Measured memory_bytes: 47104
use proconio::input;

fn main() {
    input! {
        s: usize,
    }

    let max = 510000;
    let m = 1000000007;

    let mut fac = vec![0; max];
    let mut finv = vec![0; max];
    let mut inv = vec![0; max];

    com_init(&mut fac, &mut finv, &mut inv, max, m);

    let mut ans = 0;
    for k in 1..=s/3 {
        if s-1 >=2*k {
            let tmp = com(s-2*k-1, k-1, &fac, &finv, m);
            ans = ans + tmp % m;
            ans %= m;
        }
        //println!("k: {}", k);
    }

    println!("{}", ans);
}

fn com_init(
    fac: &mut Vec<isize>,
    finv: &mut Vec<isize>,
    inv: &mut Vec<isize>,
    max: usize,
    m: isize,
) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[0] = 0;
    inv[1] = 1;

    let mut i = 2;
    while i < max {
        fac[i] = fac[i - 1] * i as isize % m;
        inv[i] = m as isize - inv[m as usize % i] * (m / i as isize) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
        i += 1;
    }
}

fn com(n: usize, k: usize, fac: &Vec<isize>, finv: &Vec<isize>, m: isize) -> isize {
    if n < k {
        return 0;
    }
    fac[n] * (finv[k] * finv[n - k] % m) % m
}



Measured memory_bytes: 13880
#include<iostream>
#include <math.h>
#include <algorithm>
#include<queue>
#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

main(){
    long long N;
    int sum = 0;
    double po;
    cin >> N;
    FOR(i, 0, to_string(N).length()){
        po = pow(10, i);
        sum += N / (int)po % 10;
    }
    if(N % sum){ cout << "No" << endl;}
    else {cout << "Yes" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int a, b, k;
	cin >> k >> a >> b;
	for (int i = a;i <=b; i++){
		if (i%k==0){
			cout << "OK" << endl;
			return 0;
		}
	}	
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli x,y,z,k;
    cin>>x>>y>>z>>k;
    lli a[x],b[y],c[z];
    for(lli i=0;i<x;i++)cin>>a[i];
    for(lli i=0;i<y;i++)cin>>b[i];
    for(lli i=0;i<z;i++)cin>>c[i];
	vl temp;
	for(lli i=0;i<x;i++)for(lli j=0;j<y;j++)temp.pb(a[i]+b[j]);
	sort(temp.begin(),temp.end());reverse(temp.begin(),temp.end());
	vl t;
	for(lli i=0;i<min(k,x*y);i++)t.pb(temp[i]);
	sort(t.begin(),t.end());reverse(t.begin(),t.end());
	vl ans;
	//for(lli i=0;i<t.size();i++)cout<<t[i]<<" ";cout<<endl;
	for(lli i=0;i<t.size();i++)for(lli j=0;j<z;j++)ans.pb(t[i]+c[j]);
	sort(ans.begin(),ans.end());reverse(ans.begin(),ans.end());
	cout<<endl<<endl;
	for(lli i=0;i<min(k,x*y*z);i++)cout<<ans[i]<<endl;


 	return 0;
 }

Measured memory_bytes: 43268
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    string a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;

    ll ans = 0;

    for(int i = 0; i < n; i++){
        if(a[i] == b[i] && b[i] == c[i]){

        }else if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]){
            ans++;
        }else{
            ans += 2;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            long x=scan.nextLong();
            long k=scan.nextLong();
            long d=scan.nextLong();
            long req=Math.abs(x)/d;
            if(Math.abs(x)%d!=0){
                req++;
            }
            req=Math.min(req,k);
            k-=req;
            if(x<0){
                x+=req*d;
            }else{
                x-=req*d;
            }
            if(k%2==0){
                out.println(Math.abs(x));
            }else{
                if(x>=0){
                    out.println(Math.abs(x-d));
                }else{
                    out.println(Math.abs(x+d));
                }
            }
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


Measured memory_bytes: 32424
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

import sys
from itertools import count
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


MOVES = [
    ((1, 0), [(2,-1),(2,0),(2,1),(2,2),(1,1)]),
    ((-1, 0),[(-2,-1),(-2,0),(-2,1),(-2,-2),(-1,-1)]),
    ((0, 1), [(1,2),(0,2),(-1,2),(-2,2),(-1,1)]),
    ((0, -1), [(1,-2),(0,-2),(-1,-2),(2,-2),(1,-1)]),
    ]

CONVERTED_MOVES = None

def solve(dist, start, goal):
    q = [start]
    cnt = 0
    while q:
        nq = []
        while q:
            x = q.pop()
            if x == goal:
                return cnt
            if dist[x] < cnt:
                continue
            for d,l in CONVERTED_MOVES:
                nx = x+d
                if dist[nx] > cnt:
                    dist[nx] = cnt
                    q.append(nx)
                if dist[nx] < 0:
                    for t in l:
                        p = x+t
                        if dist[p] > cnt+1:
                            dist[p] = cnt+1
                            nq.append(p)
        q = nq
        cnt += 1

    return -1




if __name__ == '__main__':
    H,W = map(int,readline().split())
    start = tuple(map(lambda i:int(i)+1,readline().split()))
    goal = tuple(map(lambda i:int(i)+1,readline().split()))

    H += 4
    W += 4

    dist = [-1]*(W*H)

    start = start[0]*W+start[1]
    goal = goal[0]*W+goal[1]

    for t,s in zip(count(2*W,W),read().split()):
        for i,c in zip(count(t+2),s.decode()):
            if c == '.':
                dist[i] = 10**7

    convert = lambda x,y: x*W+y
    CONVERTED_MOVES = []
    for d,l in MOVES:
        d = convert(*d)
        l = [convert(*d) for d in l]
        CONVERTED_MOVES.append((d,l))

    # print(CONVERTED_MOVES)

    print(solve(dist,start,goal))


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

#define MOD 1000000007
#define N 100010

typedef double lf;
typedef long long ll;
#define int ll
typedef long double ld;
typedef unsigned long long ull;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef vector<pair<ll,ll > >vpll;
typedef vector<vll > vvll;
#define endl "\n"
#define sd(a) scanf("%d",&a)
#define sstr(a) scanf("%s",a)
#define sl(a) scanf("%lld",&a)
#define debug(a) printf("check%d\n",a)
#define clr(a) memset(a,0,sizeof(a))
#define rtn return 
#define gc getchar
#define pb push_back
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define lp(i,b) for(ll i = ll(0); i<ll(b) ; i++) 
#define lpit(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define mid(s,e) (s+(e-s)/2)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define fast ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);
ll ip(){
  ll x = 0; bool isNeg = false; char c;
  c = gc();
  if(c == '-')  isNeg = true , c = gc();
  for( ; c >= '0'  && c <= '9' ; c = gc()); x = (x << 1) + (x << 3) + c - '0';
  if(isNeg) x *= -1;  return x;
}
//////////////////////////////////////////// CONTAINERS FOR FUNCTIONS MENTIONED IN TEMPLATE ///////////////////////////////////
#define MAX 100005
//bool isPrime[MAX];
//int spf[MAX];
//////////////////////////////////////////// FUNCTIONS THAT NEED COMMENTED OUT CONTAINERS ////////////////////////////////////


//void prime_sieve(){ for(ll i=2 ; i*i<=MAX ; i++){ if(!isPrime[i]){ for(ll j=i*i ; j<=MAX ; j+=i)  isPrime[j] = 1;} }  }
//void spf_sieve(){ for(ll i=2 ; i<MAX ; i+=2)  spf[i] = 2;
//  for(ll i=3 ; i<MAX ; i+=2){ if(!isPrime[i]){ spf[i] = i; for(ll j=i ; (j*i)<MAX ; j+=2){ if(!isPrime[i*j])  isPrime[i*j] = true , spf[i*j] = i; } } }
//}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline ll ncr(ll n,ll r){ ll ans = 1 ; if(r > n-r) r = n-r; lp(i,r+1){ans*=(n-i) ; ans/=(i+1); } rtn ans; }
inline ll gcd(ll a,ll b){if(!a) rtn b; rtn gcd(b%a,a); }
inline ll fme(ll x,ll n){ll ans=1;x%=MOD;while(n>0){if(n&1){ ans*=x;ans%=MOD;} x*=x;x%=MOD;n>>=1;}rtn ans%MOD;}
inline bool isPalin(string &s){ int len = s.size()-1;lp(i,(len/2)+2){if(!(s[i]==s[len-i]))  rtn false;} rtn true;}
inline ll lcm(ll a,ll b){rtn (a*b)/gcd(a,b); }
inline ll fmm(ll a,ll b) {ll r=0;a%=MOD;b%=MOD;while(b>0){if(b&1){r+=a;r%=MOD;}a+=a;a%=MOD;b>>=1;}rtn r%MOD;}
inline ll sfme(ll a,ll b) {ll r=1;a%=MOD;while(b>0){if(b&1)r=fmm(r,a);a=fmm(a,a);b>>=1;}rtn r%MOD;}
inline int in(){ int NR=0; register char c=gc(); while( c < 48 || c > 57 ){c=gc();} 
  while(c>47 && c< 58){ NR = (NR << 3) + (NR << 1) + (c - 48); c=gc();} return NR;
}

ll dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
//--------------------------------TEMPLATE ENDS HERE--------------------------------------------------//

#define NMAX 100005
#define LOGNMAX 20




signed main(){
	fast;	
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust"<<endl;
	}	
	else{
		cout<<"win"<<endl;
	}

}

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

X.sort()
temp = 10**10
a = 0
for i in range(X[0], X[N-1]+1):
    a = 0
    for j in X:
        a += (j - i) ** 2
    if a < temp:
        temp = a

print(temp)


Measured memory_bytes: 3060
n = input()
arr = list(map(int, input().split()))
ar = [0 for i in range(100001)]
res = 0
for i in arr:
    if i > 100000:
        res += 1
    else:
        ar[i] += 1
for i in range(len(ar)):
    if ar[i] > i:
        res += ar[i] - i
    if ar[i] < i:
        res += ar[i]
print(res)


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

int main() {
  int n, m;
  // 青
  cin >> n;
  vector<string> blue_cards(n);
  for (int i = 0; i < n; i++) {
    cin >> blue_cards[i];
  }
  // 赤
  cin >> m;
  vector <string> red_cards(m);
  for (int i = 0; i < m; i++) {
    cin >> red_cards[i];
  }
  
  // 最大の金額を出力するので探索対象は青カードのみでいい
  int max_income = 0;
  for (int i = 0; i < n; i++) {
    int now_income = 0;
    // 青の探索
    for (int blue_j = 0; blue_j < n; blue_j++) {
      if (blue_cards.at(blue_j) == blue_cards.at(i)) {
        now_income++;
      }
    }
    // 赤の探索
    for (int red_j = 0; red_j < m; red_j++) {
      if (red_cards.at(red_j) == blue_cards.at(i)) {
        now_income--;
      }
    }

    if (max_income < now_income) {
      max_income = now_income;
    }
  }

  cout << max_income << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 1000000
using namespace std;
char str1[MAXN+5],str2[MAXN+5];
int L,pos[MAXN+5],s,t;
int que[MAXN+5],que2[MAXN+5];
int main()
{
//	freopen("blank.in","r",stdin);
//	freopen("blank.out","w",stdout);
	scanf("%d %s %s",&L,str1+1,str2+1);
	if(strcmp(str1+1,str2+1)==0)
	{
		printf("0\n");
		return 0;
	}
	for(int i=L,j=L;i>=1&&j>=1;i--)
	{
		while(str2[i]==str2[i-1])
			i--;
		while(j&&(j>i||str1[j]!=str2[i]))
			j--;
		if(j==0)
		{
			printf("-1\n");
			return 0;
		}
		pos[i]=j;
	}
	int del=0,ans=1;
	for(int i=1;i<=L;i++)
	{
		if(pos[i]==0)	continue;
		int p=pos[i];
		while(s<t&&que[s]+del<p)
			s++;
		if(s==t&&pos[i]==i)
		{
			del=0;
			continue;
		}
		del++;
		if(i-2>=1&&str2[i-1]==str2[i-2])
			que[t]=i-del,que2[t++]=2-del;
		ans=max(ans,que2[s]+del);
	}
	printf("%d\n",ans);
	return 0;
}
/*
15
dqvfqxxbuizsxiw
ddqqvfqqxxxxbuu
5
abcde
aaacc

*/

Measured memory_bytes: 12800
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <climits>
#include <limits>
#include <queue>
#include <utility>

using namespace std;



#define ll long long

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

		int count = 0;
		int ang = 360;

		while (ang) {
			ang -= x;
			count++;
			if (ang < 0)
				ang += 360;
		}

		cout << count << endl;


		return 0;
	}




Measured memory_bytes: 3592
using System;
 
class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[2]);
    string op = input[1];
    
    if(op == "+") Console.WriteLine(a + b);
    else Console.WriteLine(a - b);
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

int han(int *buf,int N){
	for(int i=0;i<N;i++){
		if(buf[i]%2!=0){
			return 0;
		}
		buf[i]/=2;
	}
	return 1;
}

int main(){
	int n,b[200],c=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>b[i];

	while(han(b,n))
		c++;
	cout<<c<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
typedef map<int,int> ma;
typedef set<int> se;
typedef vector<int> ve;
const int maxn=1e2+7;
char a[107];
int K;
int dp[111][2][4];
int solve1(){
    int s=strlen(a);
    dp[0][0][0]=1;
    for(int i=0;i<s;i++)
	{
		for(int j=0;j<2;j++)
		{
			int lim=j?9:a[i]-'0';
			for(int k=0;k<=K;k++)
			{
				for(int l=0;l<=lim;l++)
				{
					int nk=k+!!l;
					if(nk<=K)
					{
						dp[i+1][j||l<lim][nk]+=dp[i][j][k];
					}
				}
			}
		}
	}
	///printf("%d\n",dp[s][0][K]+dp[s][1][K]);
	return dp[s][0][K]+dp[s][1][K];
}
int solve2(){
    int sum=0;
    int s=strlen(a);
    if(K==1){
        for(int i=0;i<s;i++){
            int x=a[i]-'0';
            if(i!=0)
                x=9;
            sum+=x;
        }
    }
    else if(K==2){
        int f=0;
        for(int i=0;i<s;i++){
            for(int j=i+1;j<s;j++){
                int x=a[i]-'0',y=a[j]-'0';
                if(f){
                    y=9;
                    if(i!=0)
                        x=9;
                }
                if(a[j]-'0') f=1;
                sum+=max(0,(x-1)*9+y);
            }
            f=1;
        }
    }
    else {
        int f1=0,f2=0;
        for(int i=0;i<s;i++){
            for(int j=i+1;j<s;j++){
                for(int p=j+1;p<s;p++){
                    int x=a[i]-'0',y=a[j]-'0',z=a[p]-'0';
                    if(f1){
                        z=9;
                        if(i!=0)
                            x=9;
                        if(f2) y=9;
                    }

                    if(a[p]-'0') f1=1;
                    sum+=max(0,(x-1)*81)+max(0,(y-1)*9+z);
                    //sum+=max(0,(x-1)*81+(y-1)*9+z);
                }
                if(a[j]-'0') f1=f2=1;
                f1=f2;
            }
            f1=f2=1;
        }
    }
    printf("%d\n",sum);
    return sum;
}
int main() {
    scanf("%s%d",a,&K);
    solve2();
//    while(1){
//
//        memset(dp,0,sizeof dp);
//
//        int t=5;
//        //scanf("%s",a);
//        for(int i=0;i<t;i++)
//           a[i]=rand()%10+'0';
//        if(a[0]=='0') a[0]++;
//        a[t]=0;
//
//        K=3;
//        int t1=solve1(),t2=solve2();
//        if(t1!=t2){
//            printf("************************\n");
//            printf("%s\n",a);
//            printf("%d %d\n",t1,t2);
//            printf("************************\n");
//            //while(1);
//        }
//    }


	return 0;
}



/**********************

740948824551711527614232216857618927954312

*********************/


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

int main()
{
    int n,k,x,y,tk1=1,tk2=1,total1=0,total2=0,total=0,i,j;
    scanf("%d %d %d %d",&n,&k,&x,&y);
    for(i=1;i<=k;i++)
    {
        if(i<=n)
    {
        tk1=1*x;
        total1+=tk1;
    }
    }
    for(j=k+1;j<=n;j++)
    {
    if (n>=j)
    {
        tk2=1*y;
        total2+=tk2;
    }
    }
    total=total1+total2;
    printf("%d",total);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
ll g[5000]={0};
ll c[5000]={0};
ll d[5000]={0};
char s[5000];
int main()
{
	ll n;
	scanf("%lld",&n);
	scanf(" %s",s);
	for(ll i=1;i<=n;i++)
	{
		if(s[i-1]=='G') g[i]++;
		if(s[i-1]=='R') c[i]++;
		if(s[i-1]=='B') d[i]++;
		g[i]+=g[i-1];
		c[i]+=c[i-1];
		d[i]+=d[i-1];
	}
	for(ll i=1;i<=n;i++)
	{
//		printf("%lld %lld %lld\n",g[i],c[i],d[i]);
	}
	ll sum=0;
	for(ll i=1;i<=n-2;i++)
	{
		if(s[i-1]=='G') sum+=(c[n]-c[i])*(d[n]-d[i]);
		if(s[i-1]=='R') sum+=(g[n]-g[i])*(d[n]-d[i]);
		if(s[i-1]=='B') sum+=(g[n]-g[i])*(c[n]-c[i]);
	}
//	printf("%lld",sum);
	for(ll i=1;i<=n;i++)
	{
		for(ll j=i+1;j<=n;j++)
		{
			ll k=j+(j-i);
			if(k>n) break;
			if(s[i-1]!=s[j-1]&&s[i-1]!=s[k-1]&&s[j-1]!=s[k-1]) sum--;
		}
	}
	printf("%lld",sum);
}

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

int min(int a, int b)
{
  if (a < b)
    return a;
  return b;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int mn = a + b - n;
  if (mn < 0) mn = 0;
  cout << min(a, b) << " " << mn << endl;  
  return 0;
}


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

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

    int count = 0;

    if (n.at(0) == '7') { count++; } 
    if (n.at(1) == '7') { count++; } 
    if (n.at(2) == '7') { count++; } 

    if (count > 0) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}

}

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

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = INT_MAX;
const LL INF = LLONG_MAX;

template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int maxn = 200 + 5;

int N;
int A[maxn], K[maxn];

//int sg[maxn][maxn];
//
//inline int get_sg (int lef, int k)
//{
//	if (sg[lef][k] != -1) return sg[lef][k];
//	if (lef < k) return 0;
//
//	int tmp[maxn], cnt = 0;
//	for (int i = lef / k; i >= 1; --i) tmp[++cnt] = get_sg (lef - i, k);
//	sort (tmp + 1, tmp + cnt + 1);
//	cnt = unique (tmp + 1, tmp + cnt + 1) - tmp - 1;
//	for (int i = 1; i <= cnt; ++i) 
//	{
//		if (sg[lef][k] + 1 != tmp[i]) break;
//		else sg[lef][k] += 1;
//	}
//
//	return sg[lef][k] += 1;
//}

inline void solve ()
{
	int SG = 0;
	for (int i = 1; i <= N; ++i)
	{
		while (A[i] % K[i] > 0) 
		{
			int v = A[i] / K[i];
			A[i] = A[i] - ceil((A[i] % K[i]) * 1.0 / (v + 1)) * (v + 1);
		}
		SG ^= A[i] / K[i];
	}
	if (SG) printf ("Takahashi");
	else printf ("Aoki");
}

inline void input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>(), K[i] = read<int>();
}

int main ()
{

  

	input ();
    solve ();

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
        FastScanner cin = new FastScanner();
        String s = cin.next();
        StringBuilder p = new StringBuilder(s);
        int numG = 0, numP = 0, score = 0;
 
        for (int i = 0, j = 0; i < s.length(); ++i) {
            if (p.charAt(i) == 'p') {
                ++numP;
 
                if (numP > numG) {
                    while (s.charAt(j) == p.charAt(j))
                        ++j;
 
                    p.setCharAt(j, 'g');
                    --numP;
                    --score;
                    ++numG;
                    ++j;
                }
            } else {
                if (numP < numG) {
                    ++score;
                    ++numP;
                    p.setCharAt(i, 'p');
                } else {
                    ++numG;
                }
            }
        }
 
        System.out.println(score);
    }
 
    static class FastScanner {
        StringTokenizer tokenizer;
        Scanner scanner;
 
        FastScanner() {
            tokenizer = null;
            scanner = new Scanner(System.in);
        }
 
        int nextInt() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(scanner.nextLine());
 
            return Integer.parseInt(tokenizer.nextToken());
        }
 
        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(scanner.nextLine());
 
            return tokenizer.nextToken();
        }
    }
}

Measured memory_bytes: 28228
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define sf(a)                scanf("%lld",&a)
#define sff(a,b)             scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)          scanf("%lld %lld %lld",&a,&b,&c)
#define case(a,b)            printf("Case %lld: %lld\n",a,b)
#define pf(a)                printf("%lld\n",a)
#define pff(a,b)             printf("%lld %lld\n",a,b)
#define pb                   push_back
#define cln(x)               memset(x, 0, sizeof(x))
#define nl                   printf("\n");
const int N=1234;
ll arr[N], i, j;
using namespace std;
int main()
{
    ll n, x;
    while(sff(n,x)==2)
    {
        ll sum=0, mn=10000;
        for(i=0; i<n; i++)
        {
            sf(arr[i]);
            mn=min(arr[i],mn);
            sum+=arr[i];
        }
        ll rem=x-sum;
        ll ext=rem/mn;
        ll ans=n+ext;
        pf(ans);
    }
    return 0;
}


/*
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
*/









Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int K = nextInt();
        int X = nextInt();

        int Yen = K * 500;
        String ans = Yen >= X ? "Yes" : "No";
        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

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

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


Measured memory_bytes: 22612
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		boolean attended[]=new boolean[31];
		for(int i=0; i<28; i++){
			attended[sc.nextInt()]=true;
		}
		for(int i=1; i<=30; i++){
			if(!attended[i]){
				println(i+"");
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int n, m;
char A[210][210];

int d[186][186][186][19];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) scanf("%s", A[i] + 1);
	for(int i=1;i<=n;i++) for(int k=1;k<=m;k++) {
		for(int a=k;a<=m;a++) {
			if(A[i][k] != A[i][a]) break;
			d[i][i][k][0] = a;
		}
	}
	for(int i=1;i<=n;i++) for(int k=1;k<=m;k++) {
		for(int j=i+1;j<=n;j++) {
			if(A[i][k] != A[j][k]) d[i][j][k][0] = -1;
			else {
				d[i][j][k][0] = min(d[i][j-1][k][0], d[j][j][k][0]);
			}
		}
	}
	for(int a=1;a<19;a++) {
		for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) {
			for(int k=1;k<=m;k++) {
				d[i][j][k][a] = -1;
				int v = d[i][j][k][a-1];
				if(v != -1 && v < m) v = d[i][j][v+1][a-1];
				if(v != -1) d[i][j][k][a] = v;
				if(i < j) {
					int low = i, high = j-1;
					while(low <= high) {
						int mid = (low + high) >> 1;
						int v1 = d[i][mid][k][a-1];
						int v2 = d[mid+1][j][k][a-1];
						d[i][j][k][a] = max(d[i][j][k][a], min(v1, v2));
						if(v1 < v2) high = mid - 1;
						else low = mid + 1;
					}
				}
			}
		}
	}
	rep(a, 19) if(d[1][n][1][a] == m) {
		printf("%d\n", a);
		return 0;
	}
	return 0;
}


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

using namespace std;

long gcd(long x, long y);

int main(){
    long a,b,c,d,cdl;
    cin >> a >> b >> c >> d;
    cdl = long(c * d / gcd(c,d));
    --a;
    long rc, rd, rcdl;
    rc = (b-(b%c))/c - (a-(a%c))/c;
    rd = (b-(b%d))/d - (a-(a%d))/d;
    rcdl = (b-(b%cdl))/cdl - (a-(a%cdl))/cdl;
    long ans = b - a - (rc + rd - rcdl);
    cout << ans << endl;
    return 0;
}

long gcd(long x, long y){
    long temp;
    if(x<y){
        long t=y;
        y = x;
        x = t;
    }
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
int N;
//const ll mod = 1000000007;
void f(string S) {
    if(S.size() == N) {
        cout << S << "\n";
        return;
    }
    S.push_back('a');
    f(S);
    S.pop_back();
    for(char a = 'b'; a <= 'z'; a++) {
        bool ok = false;
        for(auto b : S) {
            if(a == b + 1) ok = true;
        }
        if(ok) {
            S.push_back(a);
            f(S);
            S.pop_back();
        }
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    f("");
    return 0;
}

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

int main()
{
    ll n;cin>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;++i){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n&1){
        int m=n/2;
        cout<<b[m]-a[m]+1<<endl;
    }else{
        int m=n/2;
        cout<<(b[m]+b[m-1])-(a[m]+a[m-1])+1<<endl;
    }
}

Measured memory_bytes: 4716
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

int par[110000];
int rnk[110000];
ll dw[110000];
void init(int n)
{
  REP(i, n) {
    par[i] = i;
    rnk[i] = 0;
  }
}
int find(int x)
{
  if (par[x] == x) return x;
  else {
    int p = find(par[x]);
    dw[x] += dw[par[x]];
    return par[x] = p;
  }
}
int weight(int x)
{
  find(x);
  return dw[x];
}
int diff(int x, int y)
{
  return weight(y) - weight(x);
}
void unite(int x, int y, int w)
{
  w += weight(x);
  w -= weight(y);

  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]) swap(x, y), w = -w;
  if (rnk[x] == rnk[y]) rnk[x]++;
  par[y] = x;
  dw[y] = w;
}
bool same(int x, int y)
{
  return find(x) == find(y);
}

int main()
{
  ll N, M;
  cin >> N >> M;
  init(N);
  REP(i, M) {
    ll L, R, D;
    cin >> L >> R >> D;
    L--; R--;
    if (! same(L, R)) unite(L, R, D);
    else {
      if (diff(L, R) != D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
typedef long long ll;
int n;
ll a[maxn],s[maxn],ans;
int main() {
	scanf("%d",&n);
	s[0]=0;
	for (int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		s[i]=s[i-1]+a[i];
	}
	ans=-1;
	for (int i=1;i<n;i++) {
		ll tmp=abs(s[i]-(s[n]-s[i]));
		if (ans==-1)
			ans=tmp;
		else ans=min(tmp,ans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
main(){
  int i,x;
  double sum0=0,sum1=0,sum2=0,max;
  double a[1000],b[1000];
  scanf("%d",&x);
  for(i=0;i<x;i++)
    scanf("%lf",&a[i]);
  for(i=0;i<x;i++){
    scanf("%lf",&b[i]);
    sum0+=fabs(a[i]-b[i]);
    sum1+=pow(a[i]-b[i],2);
    sum2+=pow(fabs(a[i]-b[i]),3);
    if(i==0)
      max=fabs(a[i]-b[i]);
    else if(max<fabs(a[i]-b[i]))
      max=fabs(a[i]-b[i]);
  }
  printf("%f\n%f\n%f\n%f\n",sum0,sqrt(sum1),cbrt(sum2),max);
  return 0;
}

Measured memory_bytes: 740
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,n,ans=0,gen=0;cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++){
		int b;cin>>b;
		a[b-1]=i;
	}
	for(i=1;i<n;i++){
		if(a[i-1]<a[i]){gen++;}else{gen=0;}
		maxeq(ans,gen);
	}
	cout<<n-ans-1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n,m,a[55],b[55];

int main() {
	map<int,int> ma;
	cin >> n >> m;
	for(int i = 0; i < m; i++) cin >> a[i] >> b[i];
	
	for(int i = 0; i < m; i++)ma[a[i]]++,ma[b[i]]++;
	
	for(int i = 1; i <= n; i++) cout << ma[i] <<endl;
}

Measured memory_bytes: 256
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

from itertools import permutations, combinations,combinations_with_replacement,product
#a=['a','b','C']
a = range(1,N+1)
PP = list(permutations(a))

#print(PP[1])
if P==Q:
    print(0)

else:
    flag=0
    i=0
    while True:
        if P == PP[i]:
            a = i+1
            flag+=1
            #print(1)
            if flag==2:
                break
        elif Q == PP[i]:
            b = i+1
            flag+=1
            #print(2)
            if flag==2:
                break
        i+=1

    print(abs(a-b))

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

int main() {
	int n, h, w;
	cin >> n >> h >> w;
	vector<int>a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i) >> b.at(i);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a.at(i) >= h && b.at(i) >= w) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define min(a, b) ( (a) < (b) ? (a) : (b) )
#define max(a, b) ( (a) > (b) ? (a) : (b) )
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> vi;

template <class T>
const bool is_impar(T x) {return (bool) (x & 1);}

int n, rez = 1e9, leftE[300005], leftW[300005];
string s;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> s;
    FOR (i, 0, n, 1) {
        if (s[i] == 'E')
            leftE[i + 1] = leftE[i] + 1;
        else
            leftE[i + 1] = leftE[i];
        if (s[i] == 'W')
            leftW[i + 1] = leftW[i] + 1;
        else
            leftW[i + 1] = leftW[i];
    }
    FOR (i, 0, n, 1)
        rez = min(rez, leftW[i] + leftE[n] - leftE[i + 1]);
    cout << rez;
}

Measured memory_bytes: 2964
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)

boxes = dict()
have_balls = list()
for bn in range(n, 0, -1):
    a = A[bn]
    s = 0
    for t in range(2, n+1):
        if bn * t > n:
            break
        s += boxes[bn*t]

    if s % 2 == a:
        boxes[bn] = 0
    else:
        boxes[bn] = 1
        have_balls.append(str(bn))

print(len(have_balls))
print(' '.join(have_balls))


Measured memory_bytes: 38416