akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using ll = long long;
using ld = long double;
using Pa = std::pair<ll, ll>;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n, ll mod) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2, mod) % mod);
	else
		return (x * pow(x, n - 1, mod) % mod);
}ll zero = 0;
using namespace std;
signed main() {
	int n; cin >> n;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	ll sum = 0;
	rip(i, n)sum += a[i];
	vector<int>ans(n);
	ll sumsum = 0;
	rip(i, n)if (i % 2 == 1)sumsum += 2 * (long long)a[i];
	ans[0] = sum - sumsum;
	for (int i = 1; i < n; i++) {
		ans[i] = 2 * a[i - 1] - ans[i-1];
	}
	rip(i, n)cout << ans[i] << endl;
}


Measured memory_bytes: 4016
def solve():
    N = int(input())
    t = [0] * (N+1)
    x = [0] * (N+1)
    y = [0] * (N+1)
    t[0] = 0
    x[0] = 0
    y[0] = 0
    for i in range(1, N+1):
        t[i], x[i], y[i] = map(int, input().split())
        # 空間的に可能かどうか。奇数秒後はx+yが奇数に、偶数秒後はx+yが偶数にならないといけない。
        if (t[i]%2==0 and (x[i]+y[i])%2==1) or (t[i]%2==1 and (x[i]+y[i])%2==0):
            print('No')
            exit()
        #　時間的に可能かどうか。
        if (t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 11636
#include<iostream>
using namespace std;
#include<stdlib.h>    // use "exit" function.
#include<stdio.h>

int main()
{
    int i, n, d, p, q;  // n:how many node.
    scanf("%d", &n);
    int *P, *C, *S;  // P:parent, C:children, S:sibling.
    P = new int [n]; C = new int [n]; S = new int [n];
    if(P == NULL || C == NULL || S == NULL) exit(EXIT_FAILURE);

    for(i = 0; i < n; i++){ P[i] = -1; S[i] = -1; }  // initialize for -1.

    while(cin >> i){
        scanf("%d", &d);   // d:how many child.
        if(d == 0){     // if nobody ??? -1.
            C[i] = -1;
        }else{
            scanf("%d", &p);  // p is the first.
            C[i] = p; P[p] = i;
            while(d > 0){
                if(d == 1){ break; }
                else{ 
                    scanf("%d", &q);  // q is sibling of p.
                    S[p] = q; P[q] = i;  // i is parent of q.
                    p = q; d--;
                }
            };
        }
    };

    for(i = 0; i < n; i++){
        printf("node %d: parent = %d, depth = ", i, P[i]);
        p = P[i]; d = 0;
        while(p >= 0){ p = P[p]; d++; };
        printf("%d, ", d);
        if(P[i] < 0){
            printf("root");
        }else if(C[i] < 0){
            printf("leaf");
        }else{
            printf("internal node");
        }
        printf(", [");
        if(C[i] >= 0){
            printf("%d", C[i]);
            p = C[i];
            while(S[p] >= 0){ printf(", %d", S[p]); p = S[p]; };
        }
        printf("]\n");
    }
    delete [] P; delete [] C; delete [] S;

    return 0;
}

Measured memory_bytes: 2324
#include<iostream>
#define MOD 1000000007
using namespace std;
int a[25][25],v[25],b[2100000],dp[2100000];
int main()
{
    int n,i,j,f;
    cin>>n;
    for(i=0;i<n;i++)
    for(j=0;j<n;j++)
        cin>>a[i][j];
    v[0]=1;
    for(i=1;i<=n;i++)
        v[i]=v[i-1]*2;
    b[0]=0;
    for(i=0;i<v[n]-1;i++)
    {
        for(j=0;j<n;j++)
        if((i&v[j])==0)
            b[i|v[j]]=b[i]+1;
    }
    dp[0]=1;
    for(f=0;f<v[n]-1;f++)
    {
        i=b[f];
        for(j=0;j<n;j++)
        if(a[i][j]==1)
        {
            if((f&v[j])==0)
                dp[f|v[j]]+=dp[f];
            dp[f|v[j]]%=MOD;
        }
    }
    cout<<dp[v[n]-1];
    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    vector<ll> a(n), b(n);
    rep(i,n) {
        cin >> x[i] >> y[i];
        a[i] = x[i] - y[i];
        b[i] = x[i] + y[i];

    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll ans = max(a[n-1] - a[0], b[n-1] - b[0]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9520
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define mod 1000000007
using namespace std;

int main()
{
    //freopen("1.txt", "r", stdin);
    int n, m; cin >> n >> m;
    vector<int> v(n, 0);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        ++v[--a]; ++v[--b];
    }
    for (int i = 0; i < n; ++i) {
        if (v[i] % 2) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int N;

int digsum(int x){
    if(x < 10){
        return x;
    }
    return x % 10 + digsum(x / 10);
}

int rez = 1 << 30;

int main(){

    cin >> N;
    for(int A = 1;A < N;A++){
        int B = N - A;
        rez = min(rez,digsum(A) + digsum(B));
    }

    cout << rez;

    return 0;
}


Measured memory_bytes: 256
/// http://abc060.contest.atcoder.jp/tasks/arc073_b


/// Bismillahir Rahmanir Rahim
/// S. M. Shakir Ahsan Romeo ( Pure_Protea, #theromeo421, Cosmos_Freak )
/// CSE Discipline, Khulna University, Khulna
/// Monirampur, Jessore.

#include <bits/stdc++.h>
using namespace std;

typedef long long lng;
typedef vector < int >  vi;
typedef vector < lng >  vl;
typedef pair < int, int >  pii;
typedef vector < pii >  vpii;

const int inf = 1 << 30;
const long long linf = 1LL << 62;
const double PI = acos(-1.0), dinf = (double)(1LL << 62), eps = (double)(1e-9);

double distance(double x1, double y1, double x2, double y2)
{
    x1 -= x2;
    y1 -= y2;
    return sqrt(x1 * x1 + y1 * y1);
}
long long POW(long long b, long long p)
{
    if(p == 0)
        return 1;
    long long t = POW(b, p >> 1);
    if(p & 1)
        return t * t * b;
    return t * t;
}
long long bigmod(long long b, long long p, long long m)
{
    if(p == 0)
        return 1;
    long long t = POW(b, p >> 1) % m;
    t = (t * t) % m;
    if(p & 1)
        t = (t * b) % m;
    return t;
}
inline int getint()
{
    int x;
    scanf("%d", &x);
    return x;
}
inline long long getlng()
{
    long long x;
    scanf("%lld", &x);
    return x;
}

lng gcd(lng a, lng b)
{
    return !b ? a : gcd(b, a % b);
}

lng lcm(lng a, lng b)
{
    return (a / gcd(a, b)) * b;
}

int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

#define theromeo421 main()
#define segtree int lft = node << 1, rgt = lft | 1, mid = (b + e) >> 1;
#define mem(x, y) memset(x, y, sizeof x);
#define II getint()
#define LL getlng()
#define sz(x) ((int)x.size())
#define sqr(x) ((x) * (x))
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define pr1(x) cout << x << endl
#define pr2(x,y) cout << x << ' ' << y << endl
#define pr3(x,y,z) cout << x << ' ' << y << ' ' << z << endl
#define pr4(a,b,c,d) cout << a << ' ' << b << ' ' << c << ' ' << d << endl
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define repab(i, a, b) for(int i = a; i <= b; ++i)
#define repstl(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define repbstl(it, x) for(auto it = x.rbegin(); it != x.rend(); it++)
#define forch(it, x) for(auto it : x)
#define pb push_back
#define all(x) x.begin(), x.end()
#define xx first
#define yy second
#define dbg(x) cerr << #x << " :  " << x << endl;
#define read(a) freopen(a, "r", stdin);
#define write(a) freopen(a, "w", stdout);
#define prv(v) rep(i, v.size()) cout << v[i] << " \n"[i + 1 == v.size()];
#define prmp(x) repstl(it, x) pr2(it->xx, it->yy)
#define pause int ppause; cin >> ppause;
#define pf printf
#define sf scanf


int theromeo421
{
    string a, b, c;
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front())
        puts("YES");
    else
        puts("NO");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n){
		int ans=0;
		for(int i=1;i*i<=32768;i++){
			if(i*i==n)ans++;
			for(int j=i;i*i+j*j<=32768;j++){
				if(i*i+j*j==n)ans++;
				for(int k=j;i*i+j*j+k*k<=32768;k++){
					if(i*i+j*j+k*k==n)ans++;
					for(int l=k;i*i+j*j+k*k+l*l<=32768;l++){
						if(i*i+j*j+k*k+l*l==n)ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        2000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
} 
int dx[4]={-1, 1, 0, 0};
int dy[4]={0, 0, 1, -1};

void solve(){
    int n,m,k,x1,x2,y1,y2;
    cin >> n >> m >> k >> x1 >> y1 >> x2 >> y2;
    string s[n+5];
    int ans[n+5][m+5],inq[n+5][m+5];
    memset(inq,0,sizeof inq);
    FOR(i,1,n+1){
        FOR(j,1,m+1)ans[i][j] = inf;
    }
    FOR(i,1,n+1)cin >> s[i],s[i] = '#'+s[i];
    queue<pair<int,pii> >q;
    q.push({0,{x1,y1}});
    ans[x1][y1] = 0;
    inq[x1][y1] = 1;
    while(!q.empty()){  
        int r = q.front().se.f, c = q.front().se.se, tmp_ans = q.front().f;
        q.pop();
        //cout << r << " " << c << "\n";
        if(ans[r][c] < tmp_ans)continue;
        FOR(i,0,4){
            FOR(j,1,k+1){
                int cx = r+j*dx[i],  cy = c+j*dy[i];
                if(cx < 1 || cy < 1 || cx > n || cy > m || s[cx][cy] == '@')break;
                if(ans[cx][cy] >= ans[r][c]+1){
                    ans[cx][cy] = ans[r][c]+1;
                    if(!inq[cx][cy]){
                        q.push({ans[cx][cy],{cx,cy}});
                        inq[cx][cy] = 1;
                    }
                }
                else break;
            }
        }
    }
    if(ans[x2][y2] != inf)cout << ans[x2][y2] << "\n";
    else cout << "-1\n";
}

signed main()
{
    //showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 


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

int main(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(k+2,0));
    dp[0][k] = 1;
    rep(i,n){
        for(int j = k; j >= 0; j--){
            dp[i+1][j] = (dp[i+1][j+1] + dp[i][j]) % mod;
            if(j+a[i]+1 <= k) (dp[i+1][j] += -dp[i][j+a[i]+1] + mod) %= mod ;
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}

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

const int mxN=1e5;
int n, a[3][mxN], b[2][mxN/2], c[2], ft[mxN+1];

void fk() {
	cout << "No";
	exit(0);
}

void upd(int i) {
	for(; i<=n; i+=i&-i)
		++ft[i];
}

int qry(int i) {
	int r=0;
	for(; i; i-=i&-i)
		r+=ft[i];
	return r;
}

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

	cin >> n;
	for(int i=0; i<3; ++i)
		for(int j=0; j<n; ++j)
			cin >> a[i][j];
	for(int k : {0, 1}) {
		for(int i=k; i<n; i+=2) {
			if(a[1][i]%3^2||abs(a[0][i]-a[1][i])>1||abs(a[2][i]-a[1][i])>1||(a[1][i]/3^i)&1)
				fk();
			c[k]+=a[0][i]>a[2][i];
			c[k^1]+=qry(n-a[1][i]/3);
			upd(n-a[1][i]/3);
		}
		memset(ft+1, 0, 4*n);
	}
	if(c[0]&1||c[1]&1)
		fk();
	cout << "Yes";
}

Measured memory_bytes: 1792
#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;
int main()
{
	string s;
	cin>>s;
	bool flag=false;
	if(s[3]==s[2]&&s[5]==s[4])
	{
		printf("Yes\n");
	 } 
	 else
	 {
	 	printf("No\n");
	 }
}

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

typedef double dbl;
struct vec { dbl x, y; };
vec operator-(vec v1, vec v2) { return { v1.x - v2.x, v1.y - v2.y }; }
dbl len(vec v) { return hypot(v.x, v.y); }
dbl dis(vec v1, vec v2) { return len(v2 - v1); }
struct cir { vec v; dbl r; };

const int N = 1002;
cir c[N];

dbl dis(cir c1, cir c2) { return max(0., dis(c1.v, c2.v) - c1.r - c2.r); }

dbl w[N][N], d[N]; bool vis[N];

int main(void) {
    vec s, t;
    scanf("%lf%lf%lf%lf", &s.x, &s.y, &t.x, &t.y);
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%lf%lf%lf", &c[i].v.x, &c[i].v.y, &c[i].r);
    c[0].v = s; c[n + 1].v = t;

    for (int i = 0; i <= n + 1; ++i)
        for (int j = 0; j <= n + 1; ++j)
            w[i][j] = dis(c[i], c[j]);
    
    for (int i = 1; i <= n + 1; ++i) d[i] = DBL_MAX;
    int u = 0;
    while (u != n + 1) {
        int r = -1; dbl dr = DBL_MAX; vis[u] = 1;
        for (int v = 0; v <= n + 1; ++v) {
            if (vis[v]) continue;
            dbl dv = d[u] + w[u][v];
            d[v] = min(d[v], dv);
            if (d[v] < dr) dr = d[v], r = v;
        }
        u = r;
    }

    printf("%.15f\n", d[n + 1]);

    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	ll a,b;
	cin>>a;
	cin>>b;
	assert(a>=1 && a<=100000 && b>=1 && b<=100000 && a!=b);	
	ll m=max(a,b);
	ll t=m;
	bool found=false;
	while(!found){
		if(m%a==0 && m%b==0){
			cout<<m<<endl;
			found=true;
		}
		else
			m+=t;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
double aa[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  
  int n;cin>>n;double sum=0;
  for(int i=1;i<=n;i++)
  {
    cin>>aa[i];sum+=aa[i];
  }
  double avg=sum/(n*1.0);

  double mx=1e9;int ans;
  for(int i=1;i<=n;i++)
  {
    double df=abs(avg-aa[i]);
    if(df<mx)
    {
      mx=df;ans=i;
    }
  }
  cout<<ans-1<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
W = [input()]
for i in range(N-1):
    W.append(input())
    if W[i][-1] != W[i+1][0]:
        print("No")
        break
    elif W[i+1] in W[:i+1]:
        print("No")
        break
    else:
        if i == N-2:
            print("Yes")
        else:
            pass

Measured memory_bytes: 3060
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();

function main(){
  for(var i = 0, len = input.length; i < len; i++){
    var iarr = input[i].split(' ');
    j = 0;
    var v1 = new Vector2D(iarr[j++], iarr[j++]);
    var v2 = new Vector2D(iarr[j++], iarr[j++]);
    var v3 = new Vector2D(iarr[j++], iarr[j++]);
    var vp = new Vector2D(iarr[j++], iarr[j++]);

    var v12 = v2.sub(v1);
    var v2p = vp.sub(v2);
    
    var v23 = v3.sub(v2);
    var v3p = vp.sub(v3);

    var v31 = v1.sub(v3);
    var v1p = vp.sub(v1);

    var c1 = v12.cross(v2p);
    var c2 = v23.cross(v3p);
    var c3 = v31.cross(v1p);

    if((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0) ){
      console.log('YES');
    }else{
      console.log('NO');
    }
    
  }
}

function Vector2D(x, y){
  this.x = x - 0, this.y = y - 0;
  this.sub = function(v){
    return new Vector2D(this.x - v.x, this.y - v.y);
  };
  this.cross = function(v){
    return this.x * v.y - this.y * v.x;
  };
}

Measured memory_bytes: 8696
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var X int
	if sc.Scan() {
		X, _ = strconv.Atoi(sc.Text())
	}
	numOf500 := X / 500
	amari := X % 500
	numOf5 := amari / 5

	fmt.Println(numOf500*1000 + numOf5*5)

}


Measured memory_bytes: 640
// --------------
// Tejas Pandey  |
// 21 - 06 - 19  |
// Atcoder #131  |    |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
typedef long long int ll;
ll gcd (ll a, ll b)
{
	if(a%b)
	return gcd(b,a%b);
	else
	return b;
}
int main (void)
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	cin >> n;
	vector<pair<int,int>> w;
	for(int i = 0; i < n;i++)
	{
		int a,b;
		cin >> a >> b;
		w.push_back({b,a});
	}
	sort(w.begin(),w.end());
	ll cur = 0;
	for(int i = 0;i < n;i++)
	{
		if (cur + w[i].second <= w[i].first)
		cur += w[i].second;
		else
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
if(a==0)
return b;
if(b==0)
return a;
return gcd(b,a%b);
}
int main()
{
int x;
cin>>x;
if(360%x==0)
cout<<360/x;
else
cout<<360/gcd(360,x);
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int book[N],res;
signed main()
{
    int n;
    cin>>n;
    for(ri int i=0;i<n;i++)
    {
        char c;
        cin>>c;
        if(!book[c]) book[c]=1, res++;
    }
    (res==3)?puts("Three"):puts("Four");
    return 0;
}

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

#define ll long long
#define pb push_back
#define fs first
#define se second
#define M 1000000007

vector<ll>tree(100000,LLONG_MAX);
void build(ll s,ll e,ll p,vector<ll>&arr)
{
	if(s==e)
	{
		tree[p]=arr[s];
		return;
	}
	ll mid=(s+e)/2;
	build(s,mid,2*p+1,arr);
	build(mid+1,e,2*p+2,arr);
	tree[p]=min(tree[2*p+1],tree[2*p+2]);
}

ll query(ll s,ll e,ll l,ll u, ll p)
{
	if(e<l || s>u)
		return LLONG_MAX;
	else if(s<=l && u<=e && l<=u)
		return tree[p];
	ll mid=(l+u)/2;
	ll left=query(s,e,l,mid,2*p+1);
	ll right=query(s,e,mid+1,u,2*p+2);
	return min(left,right);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	set<ll>s;
	for(ll i=0;i<3;i++)
	{
		ll a;
		cin>>a;
		s.insert(a);
	}
	if(s.size()==2)
		cout<<"Yes";
	else
		cout<<"No";
	cout<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

const int N = 110;

int main()
{
  int H,W;
  cin >> H >> W;
  char a[N][N];

  REP(i,0,H) {
    REP(j,0,W) cin >> a[i][j];
  }

  // output
  REP(i,-1,H+1) {
    REP(j,-1,W+1) {
      if (i == -1 || i == H || j == -1 || j == W)
        cout << '#';
      else cout << a[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int sx = int.Parse(str[0]);
            int sy = int.Parse(str[1]);
            int tx = int.Parse(str[2]);
            int ty = int.Parse(str[3]);

            int incx = tx - sx;
            int incy = ty - sy;

            string[] result = new string[4 * (incx + incy) + 8];

            Program writer = new Program();

            writer.write1(incx, incy);
            writer.write2(incx, incy);
            Console.Write("DR");
            writer.write1(incx, incy);
            Console.Write("UL");
            Console.Write("UL");
            writer.write2(incx, incy);
            Console.Write("DR");
        }
        internal void write1(int incx, int incy)
        {
            for (int i = 0; i < incx; i++)
            {
                Console.Write("R");
            }
            for (int i = 0; i < incy; i++)
            {
                Console.Write("U");
            }
        }
        internal void write2(int incx, int incy)
        {
            for (int i = 0; i < incx; i++)
            {
                Console.Write("L");
            }
            for (int i = 0; i < incy; i++)
            {
                Console.Write("D");
            }
        }
    }
}


Measured memory_bytes: 11172
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int [] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i ++) {
			for(int j = 0; j <= d; j++ ) {
				if(j*a[i]+1 <= d) {
					x++;
				}
				else {
					break;
				}
			}
		}
		System.out.println(x);
		sc.close();
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    vector<int> X(N);
    REP(i,N)cin >> X[i];
    sort(all(X));
    int pows = 0,sum = 0;
    REP(i,N)pows += X[i]*X[i];
    REP(i,N)sum += X[i];
    int mini = 10000000;
    REP(i,100){
        mini = min(mini,pows - 2*(i+1)*sum + (i+1)*(i+1)*N);
    }
    cout <<mini<< "\n";
}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
const int mod = 1e9 + 7;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

const int nax = 1005;
char sl[nax][nax];

void add_self(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
int main() {
    int h = nxt(), w = nxt();
    REP(i, h)
    scanf("%s", sl[i]);
    VVI dp(h, VI(w));
    dp[0][0] = 1;
    REP(row, h)
    REP(col, w) {
        for (int r2 : {row, row + 1}) {
            int c2 = col;
            if (r2 == row) c2 = col + 1;
            if (r2 < h && c2 < w && sl[r2][c2] == '.') add_self(dp[r2][c2], dp[row][col]);
        }
    }
    printf("%d\n", dp[h - 1][w - 1]);
    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>

int main(void){

	int a,b,c,d,n,ans;

	while(scanf("%d",&n)!=EOF){;
		ans=0;
		for(a=0;a<=9;a++){
			for(b=0;b<=9;b++){
				for(c=0;c<=9;c++){
					for(d=0;d<=9;d++){
						if(n==(a+b+c+d)){
							ans+=1;
						}
					}
				}
			}
		}
		printf("%d\n",ans);
	}


	return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		String a=sc.next();
		pl(a.substring(0, 4)+" "+a.substring(4));

	}
	public static int f(int n) {
		return (n*n+4)/8;
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 21076
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll r;
  cin >> r;
  pri(r*r);

  return 0;
}







Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0)break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++)System.out.print("#");
                System.out.println();
            }
            System.out.println();
        }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 31664
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var ans = 0;
  for(var i = 1; i <= n; i++){
    if(i%3 && i%5)ans += i;
  }
  return ans;
}

Measured memory_bytes: 35180
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pb push_back
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, X, T;
  cin >> N >> X >> T;
  cout << (N + X - 1) / X * T << "\n";
}


Measured memory_bytes: 3648
grid = Array.new(3).map{Array.new(3, 0)}
grid[0] = gets.chomp.split(" ").map(&:to_i)
grid[1] = gets.chomp.split(" ").map(&:to_i)
grid[2] = gets.chomp.split(" ").map(&:to_i)
check = Array.new(3).map{Array.new(3, 1000)}
check[0][0] = grid[0][0] - grid[0][1]
check[0][1] = grid[0][1] - grid[0][2]
check[0][2] = grid[0][2] - grid[0][0]
check[1][0] = grid[1][0] - grid[1][1]
check[1][1] = grid[1][1] - grid[1][2]
check[1][2] = grid[1][2] - grid[1][0]
check[2][0] = grid[2][0] - grid[2][1]
check[2][1] = grid[2][1] - grid[2][2]
check[2][2] = grid[2][2] - grid[2][0]
if check[0][0] == check[1][0] && check[1][0] == check[2][0] && check[2][0] == check[0][0]
  if check[0][1] == check[1][1] && check[1][1] == check[2][1] && check[2][1] == check[0][1]
    if check[0][2] == check[1][2] && check[1][2] == check[2][2] && check[2][2] == check[0][2]
      check[0][0] = grid[0][0] - grid[1][0]
      check[0][1] = grid[1][0] - grid[2][0]
      check[0][2] = grid[2][0] - grid[0][0]
      check[1][0] = grid[0][1] - grid[1][1]
      check[1][1] = grid[1][1] - grid[2][1]
      check[1][2] = grid[2][1] - grid[0][1]
      check[2][0] = grid[0][2] - grid[1][2]
      check[2][1] = grid[1][2] - grid[2][2]
      check[2][2] = grid[2][2] - grid[0][2]
      if check[0][0] == check[1][0] && check[1][0] == check[2][0] && check[2][0] == check[0][0]
        if check[0][1] == check[1][1] && check[1][1] == check[2][1] && check[2][1] == check[0][1]
          if check[0][2] == check[1][2] && check[1][2] == check[2][2] && check[2][2] == check[0][2]
            puts "Yes"
            exit
          end
        end
      end
    end
  end
end


puts "No"


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
#include <ctime>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n, m; cin >> n >> m;
	vs a(n), b(m);
	rep(i, n) {
		cin >> a.at(i);
	}
	rep(i, m) {
		cin >> b.at(i);
	}
	bool ok = true;
	rep(i, n - m + 1) {
		rep(j, n - m + 1) {
			ok = true;
			rep(k, m) {
				rep(l, m) {
					if (a.at(i + k).at(j + l) != b.at(k).at(l)) {
						ok = false;
						break;
					}
				}
			}
			if (ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int two = 0;
  int four = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      four++;
    else if (a % 2 == 0)
      two++;
  }

  if (four + two / 2 >= n / 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int cnt = 0;
            int a = 0;
            for(int i = 0; i < 3; i++)
            {
                if(S[i] == 'R')
                {
                    cnt++;
                }
                else if(S[i] == 'S')
                {
                    cnt = 0;
                }
            a = Math.Max(cnt, a);
            }

            Console.WriteLine(a);
        }
    } 
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 25864
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int D, G;
	cin >> D >> G;

	vector<int> p(D, 0);
	vector<int> c(D, 0);

	for (size_t i = 0; i < D; i++)
	{
		cin >> p[i];
		cin >> c[i];
	}

	ll ans = 1e10;
	for (int bit = 0; bit < (1 << D); bit++)
	{
		ll score = 0;
		ll num = 0;
		for (int i = 0; i < D; i++)
		{
			if (bit & (1 << i))
			{
				score += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
		}

		if (score >= G)
		{
			ans = min(ans, num);
		}
		else
		{
			for (int i = D - 1; i >= 0; i--)
			{
				if (!(bit & (1 << i)))
				{
					for (int j = 0; j < p[i]; j++)
					{
						if (score >= G)
						{
							break;
						}
						score += 100 * (i + 1);
						num++;
					}
				}
			}
			ans = min(ans, num);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


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

for _ in range(M):
    A, B = map(int, input().split())
    UF.union(A - 1, B - 1)

ans = 0

for i in range(N):
    ans = max(ans, UF.size(i))

print(ans)


Measured memory_bytes: 14348
#!/usr/bin/env python3
def solve(k, a, b):
    if a - b <= 0:
        if k <= a:
            return 1
        else:
            return -1
    return 1 + (k - a + (a - b) - 1) // (a - b) * 2
k, a, b = map(int, input().split())
print(solve(k, a, b))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=5001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
 

int main()
{
  int n;
  cin>>n;
  int a[n],cnt=0;
  fo(i,0,n)
   cin>>a[i];
   sort(a,a+n);
   if(n&1)
   {
     cout<<"0";
   }
   else
   {
    
  int k=n/2;
  k--;
 int ans=a[k+1]-a[k];
 cout<<ans; 
   }
 // cout<<cnt<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n; cin >> n;
    cout << ((n<=999)?"ABC":"ABD") << endl;
}


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

int N, K;
long double ret = 0;

int main() {
	cin >> N >> K;
	for (int t = 1; t <= N; t++) {
		int sum = t;
		for (int i = 0; i <= 100; i++) {
			if (sum * (1 << i) >= K) {
				ret += 1.0L / (1.0L * (1 << i));
				break;
			}
		}
	}
	printf("%.12Lf\n", 1.0L * ret / N);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0;i < N;i++){
    cin >> S.at(i);
  }
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for(int i = 0;i < N;i++){
    if(S.at(i) == "AC"){
      AC += 1;
    }
    else if(S.at(i) == "WA"){
      WA += 1;
    }
    else if(S.at(i) == "TLE"){
      TLE += 1;
    }
    else if(S.at(i) == "RE"){
      RE += 1;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 6420
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,k,a):
    zan = 0
    count = 0
    p = 1
    t = {i:-1 for i in range(n)}
    t[0] = 0
    for i in range(k):
        count += 1
        p = a[p-1]
        if t[p-1] == -1 :
            t[p-1] = count
        else:
            loop = count - t[p-1]
            zan = (k- t[p-1]) % loop
            break
    for i in range(zan):
        p = a[p-1]
    return p

n,k = mi()
a = mi()
print(main(n,k,a))

Measured memory_bytes: 40076
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m;
    cin>>n>>m;
    long long int a=n,b=m;
    while (a%b!=0) {
        long long int tmp=b;
        b=a%b;
        a=tmp;
    }
    long long int l=(n*m)/b;
    string s,t;
    cin>>s>>t;
    std::map<long long int, char> W;
    for (long long int i=0;i<n;i++) {
        W[i*(l/n)]=s[i];
    }
    for (long long int i=0;i<m;i++) {
        if (W[i*(l/m)]=='\0') {
            W[i*(l/m)]=t[i];
        } else if (W[i*(l/m)]!=t[i]) {
            cout<<-1<<endl;
            return 0;
        } else {
            W[i*(l/m)]=t[i];
        }
    }
    cout<<l<<endl;
}


Measured memory_bytes: 14080
// https://beta.atcoder.jp/contests/abc110/submissions/3253060

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int slen = s.length();
  int tlen = t.length();
  if(slen != tlen){
    cout << "No" << endl;
    return 0;
  }

  int d[26];
  int e[26];
  for(int i = 0; i < 26; i++){
    d[i] = -1;
    e[i] = -1;
  }

  for(int i = 0; i < slen; i++){
    //if(s[i] != t[i]){
      if(d[s[i] - 'a'] == -1 && e[t[i] - 'a'] == -1){
        d[s[i] - 'a'] = t[i] - 'a';
        e[t[i] - 'a'] = s[i] - 'a';
      }else{
        if(d[s[i] - 'a'] != t[i] - 'a' || e[t[i] - 'a'] != s[i] - 'a'){
          cout << "No" << endl;
          return 0;
        }
      }
    //}
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		double xa,ya,ra,xb,yb,rb;
		cin>>xa>>ya>>ra>>xb>>yb>>rb;
		double dx=xb-xa,dy=yb-ya;
		double d=sqrt(dx*dx+dy*dy);
		if(ra+rb<d) cout<<"0"<<endl;
		else if(ra>rb and ra-rb>d) cout<<"2"<<endl;
		else if(rb>ra and rb-ra>d) cout<<"-2"<<endl;
		else cout<<"1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#import <Foundation/Foundation.h>
#import <stdio.h>

@interface Solution: NSObject
- (NSInteger)gcd: (NSInteger)a b: (NSInteger)b;
@end
@implementation Solution
- (NSInteger)gcd: (NSInteger)a b: (NSInteger)b {
    if(b == 0) {
        return a;
    }
    return [self gcd: b b: a % b];
}
@end
int main(int argc, char **argv) {
  NSInteger K;
  scanf("%ld", &K);

  Solution *s = [[Solution alloc] init];
 
  NSInteger sum = 0;
  for(NSInteger i = 1; i <= K; i++) {
      for(NSInteger j = 1; j <= K; j++) {
	      for(NSInteger k = 1; k <= K; k++) {
	          sum += [s gcd: i b: [s gcd: j b: k]];
	      }
      }
  }
  
  printf("%ld", sum); 
  
  return 0;
}

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
int n, c, w[105], v[105];
long long dp[100005];
int main() {
    cin >> n >> c;
    int minw = INT_MAX;
    for (int i=1; i<=n; i++) {
        cin >> w[i] >> v[i];
    }
    for (int i=1; i<=n; i++) {
        for (int j=c; j>=w[i]; j--) {
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
            //printf("%d %d %lld\n", i, j, dp[j]);
        }
    }
    cout << dp[c] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;

typedef long long int ll;


ll calc_pow(ll base, int pow, ll div)
{
    ll val = 1;
    while(pow>1)
    {
        if(pow%2==1)
        {
            val = val*base %div;
        }
        base = base*base % div;
        pow /= 2;
    }
    return val * base%div;
}

int main(void)
{

    int N;
    cin >> N;
    if(N<2)
    {
        cout << 0 << endl;
    }
    else if(N==2)
    {
        cout << 2 << endl;
    }
    else
    {
        ll Sum = 0;
        ll div = pow(10, 9)+7;

        ll comb1 = calc_pow(10, N, div);
        ll comb2 = calc_pow(8, N, div);
        ll comb3 = calc_pow(9, N, div);
        ll comb4 = (comb3-comb2+comb3)%div;
        if(comb4<0) comb4 += div;
        ll comb = comb1-comb4;
        if(comb<0) comb += div;
        cout << comb<<endl;



    }







    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
const int N=100007;
int n,m,as[N],ap=0,os[2],op=0,A[N],Ap=0,B[N],Bp=0;
void pA(int x){A[Ap++]=x;}
void pB(int x){if(x)B[Bp++]=x;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0,x;i<m;++i){
		scanf("%d",&x);
		if(x&1){
			if(op==2)return puts("Impossible"),0;
			os[op++]=x;
		}else as[ap++]=x;
	}
	while(ap&&op<2)os[op++]=as[--ap];
	if(op==1){
		pA(os[0]);
		pB(1);
		pB(os[0]-1);
	}else{
		pA(os[0]);
		pB(os[0]-1);
		pB(2);
		for(int i=0;i<ap;++i){
			pA(as[i]);
			pB(as[i]);
		}
		pA(os[1]);
		pB(os[1]-1);
	}
	for(int i=0;i<Ap;++i)printf("%d ",A[i]);
	printf("\n%d\n",Bp);
	for(int i=0;i<Bp;++i)printf("%d ",B[i]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
long long n,c,x[100005],v[100005],sz[100005],nz[100005],sj[100005],nj[100005],ans=0;
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
	}
	for(int i=1;i<=n;i++)
	{
		sj[i]=sj[i-1]+v[i];
		sz[i]=max(sz[i-1],sj[i]-x[i]);
	}
	for(int i=n;i>=1;i--)
	{
		nj[i]=nj[i+1]+v[i];
		nz[i]=max(nz[i+1],nj[i]-(c-x[i]));
		
	}
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,sz[i]);
		ans=max(ans,sj[i]+nz[i+1]-2*x[i]);
	}
	for(int i=n;i>=1;i--)
	{
		ans=max(ans,nz[i]);
		ans=max(ans,nj[i]+sz[i-1]-2*(c-x[i]));
	}
	cout<<ans;
	return 0;
	
} 


Measured memory_bytes: 4992