akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <limits>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int N;
  cin >> N;
  vector<LL> A(N);
  REP(i, N) { cin >> A[i]; }
  vector<LL> sA(A), sumA(N+1, 0);
  sort(sA.begin(), sA.end());
  
  for(int i=N-1; i>=0; --i) {
    sumA[i] = sA[i] + sumA[i+1];
  }
  LL tmax = 0, put = 0;
  REP(i, N) {
    if(A[i] > tmax) {
      tmax = A[i];
      int idx = upper_bound(sA.begin(), sA.end(), tmax) - sA.begin();
      LL tput = sumA[0] - put - (sumA[idx] - (N - idx) * tmax);
      cout << tput << endl;
      put += tput;
    } else {
      cout << 0 << endl;
    }
  }
}

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

namespace 演習4_1_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var y = new int[2];
            for(var i = 0; i < 2; i++)
            {
                y[i] = int.Parse(x[i]);
            }

            int a = (y[0] * (y[0] - 1)) / 2;
            int b = (y[1] * (y[1] - 1)) / 2;
            int c = a + b;
            Console.WriteLine(c);
        }
    }
}


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

h = list(map(int, input().split()))

ans = 0
result = 0

for x in range(n - 1):
    if h[x] >= h[x + 1] :
        result += 1
    else :
        ans = max(ans, result)
        result = 0
ans = max(ans, result)

print(ans)


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

int dp[1010][1010];

int main()
{
  int q;
  string x,y;

  cin >> q;

  for(int t = 0;t < q;t++){
    cin >> x;
    cin >> y;

    memset(dp, 0, sizeof(dp));
    
    for(int i = 1;i <= x.size();i++){
      for(int j = 1;j <= y.size();j++){

	if(x[i-1] == y[j-1]){
	  dp[i][j] = dp[i-1][j-1]+1;
	}
	else if(dp[i-1][j] <= dp[i][j-1]){
	  dp[i][j] = dp[i][j-1];
	}
	else{
	  dp[i][j] = dp[i-1][j];
	}
      }
    }
    cout << dp[x.size()][y.size()] << endl;
  }
  return 0;
}



Measured memory_bytes: 7160
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;

typedef struct SegTree{
    int n = 1;
    vector<int> dat;
    
    SegTree(int n_){
        while(n < n_) n *= 2;
        dat.resize(2*n-1);
        rep(i, 2*n-1) dat[i] = 0;
    }
    
    void update(int k, int a){
        k += n-1;
        dat[k] = a;
        while(k > 0){
            k = (k-1) / 2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }
    
    int getmax(int l, int r, int i, int a, int b){
        if(r<=a || b<=l) return 0;
        if(l<=a && b<=r) return dat[i];
        int vl = getmax(l, r, i*2+1, a, (a+b)/2);
        int vr = getmax(l, r, i*2+2, (a+b)/2, b);
        return max(vl, vr);
    }
}ST;

int main(){
    int n, t; cin >> n >> t;
    int a[n];
    ST st(n);
    rep(i, n) cin >> a[i], st.update(i, a[i]);
    int vmax = 0; int cnt = 0;
    rep(i, n-1){
        int amax = st.getmax(i+1, n, 0, 0, st.n) - a[i];
        if(vmax < amax) vmax = amax, cnt = 1;
        else if(vmax == amax) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{

    int n, k;
    cin >> n >> k;
    
    int r = 0;
    
    vector<int> data(n);
    
    vector<vector<int>> moti(100, vector<int>(100));

    int a;
    rep (i, k) {
        cin >> a;
        rep (j,a) {
            cin >> moti.at(i).at(j);
            data.at(moti.at(i).at(j)-1) = 1;
        }
    }
    rep (i, n) {
        if (data.at(i) == 1) r++;
    }
    
    
    
    
    

    cout << n-r;
}

Measured memory_bytes: 3684
//
//  main.c
//  abc060_a
//
//  Created by Ding Chao on 4/29/17.
//  Copyright © 2017 Ding Chao. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char end = 0, mid = 0, ini = 0;
    while (mid != ' ') {
        end = mid;
        mid = ini;
        ini = getchar();
    }
    if (end != ini) {
        printf("NO");
        return 0;
    }
    else {
        mid = 0;
        while (mid != ' ') {
            end = mid;
            mid = ini;
            ini = getchar();
        }
        if (end != ini) {
            printf("NO");
        }
        else
            printf("YES");
    }
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n, m = map(int, input().split())

head = 1
tail = n

for _ in range(m):
    l, r = map(int, input().split())
    head = max(head, l)
    tail = min(tail, r)

if head > tail:
    print(0)
else:
    print(tail - head + 1)

Measured memory_bytes: 3060
nums = list(map(int, list(input())))
n = len(nums) - 1

result = 0
for i in range(2 ** n):
    val = 0
    temp = nums[0]
    for j in range(n):
        if ((i >> j) & 1):
            temp *= 10
            temp += nums[j + 1]
        else:
            val += temp
            temp = nums[j + 1]
    val += temp
    result += val

print(result)


Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define all(v) v.begin(),v.end()
int mod =1e9+7;
        
int32_t main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3636
#define max(a,b)(a>b?a:b)
a[5][5];main(n,i,j,k,l,m,M){
	for(scanf("%d",&n);n--;printf("%d\n",M)){
		for(i=0;i<5;i++)for(j=0;j<5;j++)scanf("%d",a[i]+j);
		for(M=i=0;i<5;i++)for(j=0;j<5;j++)for(k=i;k<5;k++){
			for(l=j;l<5;l++)for(m=i;m<=k;m++)if(!a[m][l])goto e;
			e:l-=1;M=max(M,(k-i+1)*(l-j+1));
		}
	}
exit(0);}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ans=0;
    string S;//="2019/01/01"; //5 6=月 8 9=日
   // int day=365;
	cin>>S;
    string out[]={"Heisei","TBD"};
  //  while(day){
	    if(S[4]!='/'){
	        cout << out[0];
	        return 0;
	    }
	    if(S[0] > '2'){
	        ans=1;
	    }else if(S[0]=='2'){
	        if(S[1]>'0'||S[2]>'1'){
	            ans=1;
	        }else if(S[0]=='2'&&S[1]=='0'&&S[2]=='1'&&S[3]=='9'){
	            if(S[5]>'0'){
	                ans=1;
	            }else if(S[6]>'5'){
	                ans=1;
	            }else if(S[6]=='5'&&S[9]>'0'){
	                ans=1;
	            }
	        }
	    }
	   // cout<<S<<"->";
	    cout << out[ans]<<endl;
	    /*S[9]++;
	    if(S[9]>'9'){S[8]++; S[9]='0';}
	    if(S[5]=='0'&&S[6]=='1'&&S[8]=='3'&&S[9]=='2'){S[5]='0';S[6]='2';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='2'&&S[8]=='2'&&S[9]=='9'){S[5]='0';S[6]='3';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='3'&&S[8]=='3'&&S[9]=='2'){S[5]='0';S[6]='4';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='4'&&S[8]=='3'&&S[9]=='1'){S[5]='0';S[6]='5';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='5'&&S[8]=='3'&&S[9]=='2'){S[5]='0';S[6]='6';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='6'&&S[8]=='3'&&S[9]=='1'){S[5]='0';S[6]='7';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='7'&&S[8]=='3'&&S[9]=='2'){S[5]='0';S[6]='8';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='8'&&S[8]=='3'&&S[9]=='2'){S[5]='0';S[6]='9';S[8]='0';S[9]='1';}
	    if(S[5]=='0'&&S[6]=='9'&&S[8]=='3'&&S[9]=='1'){S[5]='1';S[6]='0';S[8]='0';S[9]='1';}
	    if(S[5]=='1'&&S[6]=='0'&&S[8]=='3'&&S[9]=='2'){S[5]='1';S[6]='1';S[8]='0';S[9]='1';}
	    if(S[5]=='1'&&S[6]=='1'&&S[8]=='3'&&S[9]=='1'){S[5]='1';S[6]='2';S[8]='0';S[9]='1';}
	    if(S[5]=='1'&&S[6]=='2'&&S[8]=='3'&&S[9]=='2'){S[5]='0';S[6]='1';S[8]='0';S[9]='1';}
	  day--;
   }*/
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int h, w;
    while(cin >> h >> w) {
        if(h == 0) break;
        for(int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if(i%2==1 && j%2==1) cout << '#';
                else if(i%2==0 && j%2==0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>

using namespace std;

#define int long long

int MOD = 1000000007;


signed main() 
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, m;    
    cin >> n >> m;
    
    int s[n + 1] = {};
    int t[m + 1] = {};
    
    for (int i = 1; i <= n; i++)
        {
            cin >> s[i];            
        }    
    
    for (int j = 1; j <= m; j++)
        {
            cin >> t[j];        
        }
    
    int dp[n + 1][m + 1] = {};    
    
    // Using Dynamic programming, let dp[i][j] signify the number of pairs made using the first i elements of the first set and j elements of the 2nd set.
    for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
                {   
                    // This dp[i][j] will also include the pairs made using the first i - 1 elements of the first set and j elements of the 2nd set and i elements of the 1st set and j - 1 elements
                    // of the second set
                    dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;                
                    
                    //Removing i - 1 and j - 1 pairs as they have been counted twice  
                    dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] + MOD) % MOD;

                    // If the elements are same, add the elements of the previous i - 1 and j - 1 pair as they will be counted twice
                    if (s[i] == t[j])
                        {   
                            dp[i][j] = (dp[i][j] + 1 + dp[i - 1][j - 1]) % MOD;                        
                        }
                }        
        }        
    // Taking in the null set as well
    cout << (dp[n][m] + 1) % MOD << endl;   
    
}

Measured memory_bytes: 31616
// Date: 2020-01-22

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) x.size()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, a[20], b[20], c[20], d[20], use[20];

int main() {
	FIO;
	cin >> n;
	rep(i, 0, n-1) cin >> a[i];
	rep(i, 0, n-1) cin >> b[i];
	int mx = (1 << n), ans = inf;
	rep(i, 0, mx-1) {
		vector<int> val;
		rep(j, 0, n-1) {
			if(i & (1 << j)) c[j] = 1, val.pb(b[j]);
			else c[j] = 0, val.pb(a[j]);
		}
		sort(all(val));
		mem(use, 0);
		bool ok = 1;
		for(int i = 0; i < val.size(); i++) {
			bool flag = 0;
			for(int j = 0; j < n; j++) {
				int v = c[j] ? b[j] : a[j];
				if(v == val[i] && abs(i-j)%2 == c[j] && !use[j]) {
					use[j] = 1;
					d[i] = j;
					flag = 1;
					break;
				}
			}
			if(!flag) { ok = 0; break; }
		}
		if(!ok) continue;
		int tp = 0;
		for(int i = 1; i < n; i++) {
			for(int j = 0; j < i; j++) {
				if(d[j] > d[i]) tp++;
			}
		}
		ans = min(ans, tp);
	}
	if(ans == inf) ans = -1;
	cout << ans;

	return 0;
}

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

typedef long long LL;

const int MAXN = 1e5 + 10;

int n, m, sum;
int head[MAXN];
struct Edge { int link, to; } e[MAXN << 1];
inline void add(int u, int v) { e[++sum] = (Edge) { v, head[u] }, head[u] = sum; }

namespace Tree {
	int del[MAXN];
	void dfs(int u, int fa, int D) {
		del[u] = D % 2 == 1 ? 1 : -1;
		for (int i = head[u]; i; i = e[i].to) {
			int v = e[i].link;
			if (v == fa) continue;
			dfs(v, u, D + 1), del[u] += del[v];
		}
	}
	inline void gao() {
		dfs(1, 0, 1);
		LL ans = 0;
		for (int i = 1; i <= n; ++i) ans += abs(del[i]);
		if (del[1]) puts("-1");
		else printf("%lld\n", ans);
	}
};
namespace GayRingTree {
	int S, T, cnt, len, tot;
	bool flg;
	int dep[MAXN], del[MAXN], f[MAXN], b[MAXN], tmp[MAXN];
	bool vis[MAXN];
	void dfs1(int u, int fa) {
		vis[u] = true, dep[u] = dep[fa] + 1, f[u] = fa;
		del[u] = dep[u] % 2 == 1 ? 1 : -1;
		for (int i = head[u]; i; i = e[i].to) {
			int v = e[i].link;
			if (vis[v] && v != fa) S = u, T = v;
			if (vis[v] || v == fa) continue;
			dfs1(v, u), del[u] += del[v];
		}
	}
	void dfs2(int u, int fa) {
		vis[u] = true, del[u] = dep[fa] + 1;
		del[u] = dep[u] % 2 == 1 ? 1 : -1;
		for (int i = head[u]; i; i = e[i].to) {
			int v = e[i].link;
			if (vis[v] || v == fa) continue;
			dfs2(v, u), del[u] += del[v];
		}
	}
	inline void gao() {
		dfs1(1, 0), flg = (dep[S] + dep[T] + 1) % 2;
		int L = S, R = T, lca; len = 1;
		while (L != R) {
			if (dep[L] > dep[R]) L = f[L];
			else R = f[R];
			++len;
		}
		lca = L;
		if (flg) {
			if (del[1] & 1) return puts("-1"), void();
			int hhz = del[1] >> 1;
			for (int i = S; i; i = f[i]) del[i] -= hhz;
			for (int i = T; i; i = f[i]) del[i] -= hhz;
			LL ans = abs(hhz);
			for (int i = 1; i <= n; ++i) ans += abs(del[i]);
			printf("%lld\n", ans);
		} else {
			// assert(0);
			if (del[1]) return puts("-1"), void();
			tmp[++tot] = lca;
			for (int i = S; i != lca; i = f[i]) tmp[++tot] = i;
			for (int i = T; i != lca; i = f[i]) tmp[++tot] = i;
			memset(vis, false, sizeof(vis));
			dfs2(S, 0);
			for (int i = 1; i <= tot; ++i) b[++cnt] = del[tmp[i]];
			std::sort(b + 1, b + cnt + 1);
			int QAQ = b[(cnt + 1) / 2];
			for (int i = 1; i <= tot; ++i) del[tmp[i]] -= QAQ;
			LL ans = 0;
			for (int i = 1; i <= n; ++i) ans += abs(del[i]);
			printf("%lld\n", ans);
		}
	}
};

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, u, v; i <= m; ++i) scanf("%d%d", &u, &v), add(u, v), add(v, u);
	if (n % 2 == 1) return puts("-1"), 0;
	if (m < n) Tree::gao();
	else GayRingTree::gao();
	return 0;
}

Measured memory_bytes: 13980
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;
ll k,ans,sum,x;
queue <ll> q;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>k;
	
	if(k<10){
		cout<<k<<endl;
		return 0;
	}
	for(int i=1;i<=9;i++){
		q.push(i);
	}
	k-=9;
	while(true){
		sum=q.front();
		q.pop();
	//	cout<<sum<<" "<<k<<endl;
		x=sum%10;
		for(int i=-1;i<=1;i++){
			if((x+i)>=0 && (x+i)<=9){
				if(k==1){
					cout<<sum*10+(x+i)<<endl;
					return 0;
				} else {
					q.push(sum*10+(x+i));
					k--;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define foreach(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define all(c) begin(c),end(c)
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int M,T,P,R;cin>>M>>T>>P>>R,M|T|P|R;){
		vector<pii> res(T); // solved,penalty
		vvi cnt(T,vi(P));
		rep(i,R){
			int m,t,p,j; cin>>m>>t>>p>>j; t--,p--;
			if(j==0){
				res[t].first++;
				res[t].second-=m+20*cnt[t][p];
			}
			else
				cnt[t][p]++;
		}
		vi is(T); iota(all(is),0); reverse(all(is));
		stable_sort(all(is),[&](int i,int j){return res[i]>res[j];});
		cout<<is[0]+1;
		repi(i,1,T)
			cout<<(res[is[i]]==res[is[i-1]]?'=':',')<<is[i]+1;
		cout<<endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n, x;
    cin >> n;
    ll a[n+1];
    rep(i, n+1) cin >> a[i];
    sort(a, a+n+1);
    ll k = 0;
    rep(i, n)
    {
        k = __gcd(k, a[i+1]-a[i]);
    }
    cout << k;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
map<ll,ll> m;

int main(){
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        m[a[i]]++;
    }
    ll ans = m.size();
    ll cnt = 0;
    for(auto it = m.begin();it != m.end();it++){
        if((it -> second)%2 == 0)cnt++;
    }
    if(cnt % 2)ans--;
    cout << ans << endl;
    // sort(ALL(a));
    // rep(i,n)cout << a[i] << " ";
    // cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  int d[n+1];
  for ( int i = 0; i < n; i++){
    cin >> d[i];
  }

  sort(d, d+n);

  if ( d[n/2] == d[n/2 - 1]){
    cout << 0 << endl;
  }else {
    cout << d[n/2]-d[n/2 - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
penas = [0] * N
acs, pena = set(), 0
for _ in range(M):
    p, stat = input().split()
    p = int(p) - 1
    if stat == "AC" and p not in acs:
        acs.add(p)
        pena += penas[p]
    else:
        penas[p] += 1
print(len(acs), pena)


Measured memory_bytes: 12780
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    # A = [int(a) for a in input().split()]
    print(round(2 * N * math.pi, 4))

    # @lru_cache(None)
    # def f(i, j):
    #     if i < 0 or j < 0:
    #         return -INF
    #     if i == 0:
    #         return -INF
    #     if abs(j - i // 2 - 1) >= 2:
    #         return -INF
    #     if j == 0:
    #         return 0
    #     if j == 1:
    #         return max(A[:i])
    #     return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))
    #
    # print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max 2000
llong INF=100000000000;

int main(){
    llong n,z,w;
    cin >> n >> z >> w ;
    llong card[n_max + 5];
    REP(i,n) scanf("%ld",&card[n-i]);

    if(n==1){
        cout << abs(w-card[1]) << endl;
        return 0;
    }

    llong x,y;
    llong x_min=INF;
    llong y_max =- INF;
    FOR(i,1,n){
        x=max( abs(card[1] - card[i+1]) , y_max);
        y=min( abs(card[i+1] - card[1]), x_min);
        y_max=max(y,y_max);
        x_min=min(x,x_min);
    }
    cout << max( abs(card[1]-w) , y_max) << endl;
}

Measured memory_bytes: 256
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    vmax(a)        *max_element(all(a))
#define    vmin(a)        *min_element(all(a))
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"Yes"<<nn
#define    no             cout<<"No"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {ikarus_101

    ll n,m,i,j,k,x;



    cin>>n;
    vll v(n);
    vin(v);
    vll s(n+1,0);
    for(i=n-1;i>=0;i--)
        s[i] = (v[i]+s[i+1])%M;
    ll tot = 0;
    for(i=0;i<n-1;i++)
    {
        x = (v[i]*s[i+1])%M;
        tot+=x%M;
    }
    cout << tot%M << nn;








    return 0;
}


Measured memory_bytes: 6324
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int n, m;
	
	bool ID[5000];
	
	while(true){
		
		cin >> n >> m;
		
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i <= n; i++){
			ID[i] = true;
		}
		
		int j = 1;
		
		for(int i = 0; i < n - 1; i++){
			int count = 0;
			while(true){
				if(ID[j]){
					count++;
					if(count == m){
						//cout << j << " ";
						ID[j] = false;
						break;
					}
				}
				j++;
				if(j > n){
					j -= n;
				}
			}
		}
		
		for(int i = 1; i <= n; i++){
			if(ID[i]){
				printf("%d\n",i);
			}
		}
		
	}
	return 0;
}

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

struct Node {
  int key;
  Node *right, *left, *parent;  
};

Node  *NIL;

struct BST {
  Node *root;

  BST() {
    root = NIL;
  }

  void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z = (Node *)malloc(sizeof(Node));    
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while ( x != NIL ) {
      y = x;
      if ( z->key < x->key ) {
	x = x->left;
      } else {
	x = x->right;
      }
    }

    z->parent = y;
    if ( y == NIL ) {
      root = z;
    } else {
      if ( z->key < y->key ) {
	y->left = z;	
      } else {
	y->right = z;
      }
    }
  }

  Node* find(int k) {
    Node *u = root;
    while ( u != NIL ) {
      if ( k == u->key ) {
	return u;
      } else if ( k < u->key ) {
	u = u->left;
      } else {
	u = u->right;
      }
    }

    return NIL;
  }

  void deletes(int k) {
    Node* z = find(k);

    if ( z == NIL ) return;

    if ( z->left == NIL && z->right == NIL ) {
      Node* p = z->parent;      
      if ( k < p->key ) {
	p->left = NIL;
      } else {
	p->right = NIL;
      }
      free(z);      
    } else if ( z->left != NIL && z->right != NIL ) {     
      Node *d = z->right;
      while ( d->left != NIL ) d = d->left;      
      z->key = d->key;
      if ( z->right == d ) (d->parent)->right = NIL;
      else if ( d->right == NIL ) (d->parent)->left = NIL;
      else (d->parent)->left = d->right;
      free(d);
    } else if ( z->left != NIL ) {     
      Node* p = z->parent;
      Node* c = z->left;
      if ( p->key > c->key ) {
	p->left = c;
      } else {
	p->right = c;
      }
      c->parent = p;
      free(z);
    } else {
      Node* p = z->parent;
      Node* c = z->right;
      if ( p->key > c->key ) {
	p->left = c;
      } else {
	p->right = c;
      }
      c->parent = p;
      free(z);
    }
  }
};

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);  
}

void preorder(Node *u) {
  if ( u == NIL ) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);  
}

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

  BST bst;
  while ( m-- ) {
    string c;
    cin >> c;
    int n;
    if ( c == "insert" ) {      
      cin >> n;
      bst.insert(n);      
    } else if ( c == "find" ) {
      cin >> n;
      if ( bst.find(n) != NIL ) cout << "yes" << endl;      
      else cout << "no" << endl;
    } else if ( c == "delete" ) {
      cin >> n;
      bst.deletes(n);
    }else {
      inorder(bst.root);
      cout << endl;
      preorder(bst.root);
      cout << endl;      
    }
  }
  
  return 0;
}




Measured memory_bytes: 21896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, ll> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll segtree[816225][2],s[225816];
bool delayed[816225];

void eval(int i, int l, int r){
	if(delayed[i]){
		segtree[i][0] += segtree[i][1];
		if(r-l>1){
			segtree[2*i+1][1] += segtree[i][1];
			delayed[2*i+1] = true;
			segtree[2*i+2][1] += segtree[i][1];
			delayed[2*i+2] = true;
		}
		segtree[i][1] = 0ll;
		delayed[i] = false;
	}
}

void update(int a, int b, int i, int l, int r, ll v){
	eval(i,l,r);
	if(b<=l || r<=a){
		return;
	}
	if(a<=l && r<=b){
		segtree[i][1] = v;
		delayed[i] = true;
		eval(i,l,r);
	}else{
		update(a,b,2*i+1,l,(l+r)/2,v);
		update(a,b,2*i+2,(l+r)/2,r,v);
		segtree[i][0] = max(segtree[2*i+1][0],segtree[2*i+2][0]);
	}
}


void update2(int a, int i, int l, int r, ll v){
	eval(i,l,r);
	if(!(l<=a && a<r)){
		return;
	}
	if(r-l>1){
		update2(a,2*i+1,l,(l+r)/2,v);
		update2(a,2*i+2,(l+r)/2,r,v);
		segtree[i][0] = max(segtree[i*2+1][0],segtree[i*2+2][0]);
	}else{
		segtree[i][0] = v;
	}
}

ll query(int a, int b, int i, int l, int r){
	ll vl,vr;
	if(b<=l || r<=a){
		return -INFLL;
	}
	eval(i,l,r);
	if(a<=l && r<=b){
		return segtree[i][0];
	}else{
		vl = query(a,b,2*i+1,l,(l+r)/2);
		vr = query(a,b,2*i+2,(l+r)/2,r);
		return max(vl,vr);
	}
}

vector<P> t[225816];

int main(void){
	int n,m,l,r,i,j;
	ll a,ans=0ll;
	fill(s,s+225816,0ll);
	fill(segtree[0],segtree[816225],0ll);
	fill(delayed,delayed+816225,false);
	cin >> n >> m;
	for(i=0; i<m; ++i){
		cin >> l >> r >> a;
		s[l] += a;
		t[r].push_back(P(l,a));
	}
	for(i=1; i<=n; ++i){
		update(0,i,0,0,n+1,s[i]);
		a = query(0,i,0,0,n+1);
		ans = max(a,ans);
		update2(i,0,0,n+1,a);
		for(j=(t[i].l_ength()-1); j>=0; --j){
			l = t[i][j].first;
			a = t[i][j].second;
			update(0,l,0,0,n+1,-a);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 27136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] result = new int[n];

			for (int i = 0; i < n; i++) {
				result[sc.nextInt() - 1] = i;
			}
			StringBuilder sb = new StringBuilder();
			for (int i : result) {
				if (0 < sb.length()) {
					sb.append(" ");
				}
				sb.append(i + 1);
			}
			System.out.println(sb);
		}
	}
}


Measured memory_bytes: 49064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head
int main(void){
    int n,k;
    cin>>n>>k;
    ll ans=0,l=0,r=0;
    rep(i,0,k-1){
        l+=i;
        r+=n-i;
    }
    rep(i,k-1,n+1){
        l+=i;
        r+=n-i;
        ans+=r-l+1;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

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

int main() {
  int H,N;
  cin>>H>>N;
  vector<long> a(N);

  for(int i=0;i<N;i++) cin>>a[i];
  long sum=0;

  for(int i=0;i<N;i++){
    sum+=a[i];
    }

if(sum>=H) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}


Measured memory_bytes: 1024
def isprime(x):
    import math
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2
    return True

n = int(input())
cnt = 0
for i in range(n):
    j = isprime(int(input()))
    if j == True:
        cnt += 1
print(cnt)



Measured memory_bytes: 5684
// 4/23
// 順列組み合わせの練習

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int N, M;
    cin >> N >> M;

    Graph G(N);

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

        G[a].push_back(b);
        G[b].push_back(a);
    }

    int perm[100];
    for (int i = 0; i < N; i++) {
        perm[i] = i;
    }

    int ans = 0;
    do {
        if (perm[0] != 0) continue;

        bool is_pass = false;

        for (int i = 0; i < N - 1; i++) {
            is_pass = false;

            int from = perm[i];
            int to = perm[i + 1];

            // printf("from, to = %d %d\n", from, to);

            for (auto x : G[from]) {
                if (x == to) {
                    // printf("x, to = %d %d\n", x, to);
                    is_pass = true;
                    break;
                }
            }

            if (!is_pass) {
                break;
            }
        }

        if (is_pass) {
            // cout << "ans++" << endl;
            ans++;
        }

    } while (next_permutation(perm, perm + N));

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        sc.close();

        List<Integer> ans = new ArrayList<>();
        for (int i = x - k + 1; i < x + k; i++) {
            ans.add(i);
        }
        String result = ans.stream().map(e -> e.toString()).collect(Collectors.joining(" "));
        System.out.println(result);
    }

}


Measured memory_bytes: 27220
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader a = new BufferedReader(new InputStreamReader(System.in));
        String input = a.readLine();
        int x = Integer.parseInt(input);
        if(x==3 || x==5 || x==7){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22484
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int x=sc.nextInt();
	int y=sc.nextInt();
	//	int area=x*y;
	//int s=2*x+2*y;
	System.out.println(x*y+" "+2*(x+y));
    }
}



Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 2020;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =  1e9+7;
ll n,m;
ll a[N];
ll b[N];
ll dp[N][N];

int main()
{
cin>>n>>m;
rep(i,1,n+1)
cin>>a[i];
rep(i,1,m+1)
cin>>b[i];
rep(i,0,N-5)
{
	dp[i][0]=1;
	dp[0][i]=1;
}
rep(i,1,n+1)
{
	rep(j,1,m+1)
	{
		if(a[i]==b[j])
		{

		dp[i][j]=dp[i-1][j]+dp[i][j-1];

	}
		else
		dp[i][j]=(mod+dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1]);
	
	   	dp[i][j]=(dp[i][j])%mod;
	}
}
cout<<dp[n][m];
}
	



Measured memory_bytes: 31872
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int a,b;
  cin >> a >> b;
  int a1 = a;
  if(a%2 == 1) a1 = a+1;
  int b1 = b;
  if(b%2 == 0) b1 = b-1;
  if(a1>b1){
    int ans = a;
    for(int i=a+1;i<=b;i++){
      ans ^= i;
    }
    cout << ans << endl;
    return 0;
  }
  int ans = 0;
  if(a!= a1) ans ^= a;
  if(b!= b1) ans ^= b;
  if(((b1-a1)/2)%2==0) ans ^= 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s1, s2, s3;
	while (cin >> s1){
		if (s1 == "0")return 0;
		cin >> s2 >> s3;
		if (s1[0] != '+') {
			if (s1[0] == s1[1] && s1[0] == s1[2]) { cout << s1[0]; goto heaven; }
			else if (s1[0] == s2[1] && s1[0] == s3[2]) { cout << s1[0]; goto heaven; }
			else if (s1[0] == s2[0] && s1[0] == s3[0]) { cout << s1[0]; goto heaven; }
		}
		if (s1[1] != '+') {
			if (s1[1] == s2[1] && s1[1] == s3[1]) { cout << s1[1]; goto heaven; }
		}
		if (s1[2] != '+') {
			if (s1[2] == s2[1] && s1[2] == s3[0]) { cout << s1[2]; goto heaven; }
			else if (s1[2] == s2[2] && s1[2] == s3[2]) { cout << s1[2]; goto heaven; }
		}
		if (s2[0] != '+') {
			if (s2[0] == s2[1] && s2[0] == s2[2]) { cout << s2[0]; goto heaven; }
		}
		if (s3[0] != '+') {
			if (s3[0] == s3[1] && s3[0] == s3[2]) { cout << s3[0]; goto heaven; }
		}
		cout << "NA";
	heaven:cout << endl;
	}
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

// 75 = 74, 3 * 25, 15 * 5, 3 * 5 * 5

int main() {
    int N;
    cin >> N;
    map<int, int> factor;
    FOR(i, 1, N + 1) {
        int num = i;
        FOR(j, 2, 100) {
            if (num == 1) break;
            while (num % j == 0) {
                factor[j]++;
                num /= j;
            }
        }
    }

    int c24 = 0, c14 = 0, c4 = 0, c2 = 0;
    for (auto p : factor) {
        if (p.second >= 24) c24++;
        if (p.second >= 14) c14++;
        if (p.second >= 4) c4++;
        if (p.second >= 2) c2++;
    }
    int ans = 0;
    if (factor[2] >= 74) ans++;              // 75
    ans += c24 * (c2 - 1);                  // 3 * 25
    ans += c14 * (c4 - 1);                  // 15 * 5
    // 3 * 5 * 5
    if (c4 >= 2)
        ans += (c4 * (c4 - 1)) / 2 * (c2 - 2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
	string s,answer="";
	int i,j,k;
	cin>>s;
	sd(k);
	for(i=0;i<s.size();i+=k)answer+=s[i];
	cout<<answer<<endl;
	return 0;
}

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

struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
              return x<a.x;
    }
};


vector<int> v;
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[114111];

int o[112335];
int j[112215];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z;

//P u[100100];
stack<int> s;

//set<int> s;
//queue<int> q[100100];

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p[100100];
//list<int> l;

//string r;
char r[3];
//deque<int> de;
bool as(P a,P b)
{
    if(a.y*b.x!=b.y*a.x)
    return a.y*b.x>b.y*a.x;
    return a.y<b.y;
}

int f(int a)
{
    if(j[a]==a) return a;
    return j[a]=f(j[a]);
}

int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    for(int t=1;t<=a;j[t]=t,t++);
    for(int t=1;t<=b;t++)
    {
        scanf("%d %d",&n,&m);
        if(n>m) swap(n,m);
        j[f(m)]=f(n);

    }
    for(int t=1;t<=a;t++)
        p[f(t)][t]=1;
    for(int t=1;t<=a;t++)
        if(p[f(t)][o[t]]) k++;
        printf("%d",k);
}


Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

long long cnt[233];
char s[23333333];

int main(void) {
	scanf("%s", s+1);
	long long len=strlen(s+1);
	for (int i=1; i<=len; i++) {
		cnt[s[i]]++;
	}
	long long ans=len*(len-1)/2;
	for (int i='a'; i<='z'; i++) {
		ans-=cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans+1;
	return 0;
}

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

int n,x[maxn],c[maxn],a[maxn*maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	bool ER = 0;
	for(int i=1;i<=n*n;i++){
		for(int j=1;j<=n;j++) if(x[j] == i){
			c[j] ++;
			if(c[j] != j){
				ER = 1;
			}
			a[i] = j;
			break;
		}
		if(!a[i]){
			int p=0 , lc = n*n+2;
			for(int j=1;j<=n;j++) if(c[j] < j-1 && x[j] > i){
				if(x[j] < lc){
					lc = x[j];
					p = j;
				}
			}
			if(p){
				a[i] = p ,
				c[p] ++;
			}
		}
	}
	for(int i=n*n;i>=1;i--)if(!a[i]){
		if(!a[i]){
			int p=0 , lc = 0;
			for(int j=1;j<=n;j++) if(c[j] < n && x[j] < i){
				if(x[j] > lc){
					lc = x[j];
					p = j;
				}
			}
			if(p){
				a[i] = p ,
				c[p] ++;
			}
			else{
				ER = 1;
			}
		}
	}
	
	if(ER){
		puts("No");
	}
	else{
		puts("Yes");
		for(int i=1;i<=n*n;i++) printf("%d%c",a[i]," \n"[i==n*n]);
	}
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int a,p;
    cin >> a>> p;
    cout << (a*3+p)/2 << endl;
    return 0;
}

Measured memory_bytes: 888
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, P = map(int, readline().split())
    print((3*A+P)//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		int n= sc.nextInt();
		int k = sc.nextInt();
		int x[] = new int[n];
		for(int i= 0; i < n ; i ++){
			x[i]  =sc.nextInt();
			
		}
		int sum = 0;
		for(int i = 0 ; i< n ; i++){
			sum += Math.min(x[i],k-x[i])*2;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21716
"use strict";
const main = arg => {
  let A = arg.split("\n").map(n=>n*1);
  let N = A[0];
  A = A.slice(1, N+1);
  let AA = arg.split("\n").map(n=>n*1).slice(1, N+1);
  let sortNum = AA.sort((a,b)=> {return b - a })
  let max = sortNum[0];
  let secondMax = sortNum[1];
  for(let i = 0; i < N; i++){
	if(max != A[i]){
      console.log(max)
    }else{
      console.log(secondMax);
    };
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 70000
n = int(input())
a = list(map(int, input().split()))

printed = False
if 0 in a:
    print(0)
    printed = True

ans = 1

for x in a:
    ans *= x
    if ans > 1e18:
        if not printed:
            print(-1)
            printed = True
        break    
    
if not printed:
    print(ans)

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

int main(){
  long N;cin>>N;
  vector<pair<int,int>>J(N);
  for(int i=0;i<N;i++)cin>>J[i].second>>J[i].first;
  sort(J.begin(),J.end());
  int t=0;
  for(int i=0;i<N;i++){
    t+=J[i].second;
    if(t>J[i].first){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>


#define deb(x,y) cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   " << #x << ':' << x <<" ###### "<< y <<"\n";
#define ll long long  


using namespace std;

int main(){

	//freopen("input.txt","r",stdin);

	int a,b,c,i,sum=1,p=0;

	cin>>a;

	vector <int> v;

	for(i=0 ; i<a ;i++){
		cin>>b;
		v.push_back(b);

	}

	sort(v.begin(),v.end());

	/*for(i=0 ; i<a ;i++){
		cout<<v[i]<<" ";
		
	}*/

	for(i=1 ; i<a ; ++i){
		if(v[i]==v[i-1] && p==0){
			--sum;//cout<<v[i]<<" "<<v[i-1]<<endl;cout<<sum<<" "<<endl;
			++p;
		}
		else{
			++sum;
			p=0;
			//cout<<v[i]<<" "<<v[i-1]<<endl;cout<<sum<<" "<<endl;
		}
	}
	cout<<sum;

}



Measured memory_bytes: 892
import heapq
def neg(x):
	return x * (-1)

N, M = map(int, input().split())
A = list(map(neg, map(int, input().split())))
heapq.heapify(A)
for i in range(M):
	a = heapq.heappop(A) * (-1)
	heapq.heappush(A,  a // 2 * (-1))
print(sum(A) * (-1))

Measured memory_bytes: 14252