akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;


int main() {
    
    int a, b, c;
    cin >> a >> b >> c;
    int minimumOfTwoNums;
    
    if(a <= b) {
        if(b <= c) {
            minimumOfTwoNums = a + b;
        } else {
            minimumOfTwoNums = a + c;
        }
    } else {
        if(a <= c) {
            minimumOfTwoNums = a + b;
        } else {
            minimumOfTwoNums = b + c;
        }
    }
    
    cout << minimumOfTwoNums;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define forn(i,n)       for(int i=0; i<n; i++)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





int32_t main()
{
    //zeus();

    int a, b, c, k; cin >> a >> b >> c >> k;

    if (k <= a) {
        cout << k;
    }
    else if (k <= a + b) {
        cout << a;
    }
    else {
        cout << a - (k - a - b);
    }


}

Measured memory_bytes: 3640
#include<cstdio> 
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#define ms(i, j) memset(i, j, sizeof i)
#define LL long long
#define db double
#define fir first
#define sec second
#define mp make_pair
using namespace std;

namespace flyinthesky {

    const LL MO = 1000000007;

    LL n, k, jc[50000 + 5], jc_inv[50000 + 5];

    LL ksm(LL a, LL b) {
        LL bs = a, ans = 1;
        while (b) {
            if (b & 1) ans = ans * bs % MO;
            bs = bs * bs % MO;
            b >>= 1;
        }
        return ans;
    }

    LL C(LL n, LL m) {
        if (n < m) return 0;
        return jc[n] * jc_inv[m] % MO * jc_inv[n - m] % MO;
    }
    LL H(LL n, LL k) {
    	if (n < k) return 0;
    	if (n == 0) {
    		if (k == 0) return 1; else return 0;
		}
    	return C(n - 1, k - 1);
	}

    void clean() {
    }
    int solve() {

        clean();

        jc[0] = 1;
        for (LL i = 1; i <= 50000; ++i) jc[i] = jc[i - 1] * i % MO;
        for (LL i = 0; i <= 50000; ++i) jc_inv[i] = ksm(jc[i], MO - 2);
        
        cin >> n >> k;
        for (int i = 1; i <= k; ++i) {
        	LL B = k, A = n - k;
        	cout << H(B, i) * ((H(A, i + 1) + 2ll * H(A, i) + H(A, i - 1)) % MO) % MO << endl;
		}

        return 0;
    } 
}
int main() {
    flyinthesky::solve();
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define w cout
#define e '\n'
#define all(v) (begin(v) , end(v))
#define pb push_back
using namespace std;
const int N = 1e6 + 5 , MOD = 1e9 + 7;

signed main() {
	int n , m , ans = 1; cin >> n >> m;
	vector<int> fac;
	for(int i = 1; i <= int(sqrt(m)) ; i ++ ) {
		if(m % i == 0) {
			fac.push_back(i);
			if(m / i != i) fac.push_back(m / i);
		}
	}
	
	for(auto i : fac) {
		int x = m / i;
		if(x / n > 0) {
			ans = max(ans , i);
		}
	}
	w << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int N;
vector <int> G[5005];
int Sz[5005], DP[5005][5005];
int C[5005][5005], root, Fact[5005];
const int MOD = 1000000007;
void precalcC()
{
    C[0][0] = 1;
    for(int i = 1; i <= N; i++)
        C[i][0] = 1;
    for(int i = 1; i <= N; i++)
        for(int j = 1; j <= i; j++)
        {
            C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            if(C[i][j] >= MOD)
                C[i][j] -= MOD;
        }
}
void DFS(int node, int father)
{
    Sz[node] = 1;
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father)
            continue;
        DFS(neighb, node);
        Sz[node] += Sz[neighb];
    }
}
void findCentroid(int node, int father)
{
    bool centroid = 1;
    for(int i = 0; i < G[node].size(); i++)
    {
        int neighb = G[node][i];
        if(neighb == father)
            continue;
        if(Sz[neighb] >= (N + 1) / 2)
        {
            findCentroid(neighb, node);
            centroid = 0;
            break;
        }

    }
    if(centroid == 1)
    {
        root = node;
    }
}

void Case1()
{
    cout << (1LL * Fact[N / 2] * Fact[N / 2]) % MOD;
}
inline void Add(int& x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}
void Case2()
{
    int cnt = 0, s = 0;
    DP[0][0] = 1;
    int lim = G[root].size();
    for(int i = 1; i <= G[root].size(); i++)
    {
        int sz = Sz[G[root][i - 1]];
        for(int j = 0; j <= s; j++)
        {
            for(int k = 0; k <= sz; k++)
            {
                int aux = (1LL * C[sz][k] * C[sz][k]) % MOD;
                aux = (1LL * aux * Fact[k]) % MOD;
                Add(DP[i][j + k], (1LL * DP[i - 1][j] * aux) % MOD);
            }
        }
        s += sz;
    }
    int ans = 0;
    for(int i = 0; i <= N; i++)
    {
        int aux = (1LL * Fact[N - i] * DP[lim][i]) % MOD;
        if(i % 2 == 1)
            aux = MOD - aux;
        Add(ans, aux);
    }
    cout << ans << "\n";
}
void Read()
{
    cin >> N;
    for(int i = 1; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
}
int main()
{
    Read();
    Fact[0] = 1;
    for(int i = 1; i <= N; i++)
        Fact[i] = (1LL * Fact[i - 1] * i) % MOD;
    precalcC();
    DFS(1, 0);
    findCentroid(1, 0);
    DFS(root, 0);
    for(int i = 0; i < G[root].size(); i++)
    {
        int neighb = G[root][i];
        if(Sz[neighb] == N - Sz[neighb])
        {
            Case1();
            return 0;
        }
    }
    Case2();
    return 0;
}


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

using p = bitset<2001 * 2001>;
int main()
{
    int n;
    cin >> n;
    int b;
    p cur;
    cur[0] = true;

    int sum = 0;
    rep(i, n)
    {
        cin >> b;
        sum += b;
        cur |= (cur << b);
    }
    for (int i = (sum+1) / 2; i < 2001 * 2001; i++) {
        if (cur[i]) {
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 1792
s = gets.chomp
s.reverse!
while true do
if s.empty?
    puts "YES"
    break
elsif s.start_with?("maerd")
    s = s.slice(5..-1)
elsif s.start_with?("remaerd")
    s = s.slice(7..-1)
elsif s.start_with?("esare")
    s = s.slice(5..-1)
elsif s.start_with?("resare")
    s = s.slice(6..-1)
else 
    puts "NO"
    break
end
end

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

using namespace std;

const int MX = 100005;
const int MOD = 1000000007;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n;
char str[MX];
int f[MX], s[MX];
int nxt[MX];

int main()
{
	scanf("%s", str+1);
	n = strlen(str+1);
	bool con = 0;
	for(int i=2; i<=n; i++)
		if(str[i] == str[i-1])
			con = 1;
	if(!con) puts("1");
	else
	{
		nxt[n+1] = n+1;
		for(int i=n; i>=1; i--)
			nxt[i] = (str[i]==str[i+1]) ? i+1 : nxt[i+1];
		f[0] = 1;
		for(int i=0; i<n; i++)
		{
			f[i+1] = (f[i+1] + f[i]) % MOD;
			f[nxt[i+1]] = (f[nxt[i+1]] + f[i]) % MOD;
			//if the sum of subsequence between i and nxt[i] is 0,
			//it means that we add the contribution of i to the neares
			//j which i<j and sum[i...j]!=0, by repeatedly jumping nxt[].
			//the subsequence s[i...nxt[i]] can always be eliminated by canceling characters with neibours.
			//it can be proved that one can never construct a input such that nxt[nxt[...[i]]] is not the nearest one.
			//the meaning of nxt[] is explained in the tutorial.
		}
		int ans = 0;
		for(int i=n; i>=1; i--)
		{
			s[i] = (s[i+1] + str[i+1] - 'a' + 1) % 3;
			if(s[i] == 0) ans = (ans + f[i]) % MOD;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;
  vector<P> v(n);
  rep(i, 0, n) cin >> v[i].second >> v[i].first;

  sort(v.begin(), v.end());
  int now = 0;
  rep(i, 0, n) {
    now += v[i].second;
    if (now > v[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

#define ll long long int
#define vi vector<int>
#define ii pair< int , int >
#define vii vector<ii>
#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)
int MAX(int a, int b){return (a > b) ? a:b;}
int MIN(int a, int b){return (a < b) ? a:b;}
int ABS(int x){return (x > 0) ? x:-x;}
int left(int x){return (x<<1);}
int right(int x){return (x<<1)+1;}
int lsone(int x){return (x&(-x));}

const ll is_query = -(1LL<<62);
struct Line{
	ll m, b;
	mutable function<const Line*()> succ;
	bool operator<(const Line& rhs) const {
		if(rhs.b != is_query) return m < rhs.m;
		const Line* s = succ();
		if(!s) return 0;
		ll x = rhs.m;
		return b - s->b < (s->m - m) * x;
	}
};
struct HullDynamic : public multiset<Line>{
	bool bad(iterator y){
		auto z = next(y);
		if(y == begin()){
			if(z == end()) return 0;
			return y->m == z->m && y->b <= z->b;
		}
		auto x = prev(y);
		if(z == end()) return y->m == x->m && y->b <= x->b;
		return (x->b - y->b)*(z->m - y->m) >= (y->b - z->b)*(y->m - x->m);
	}
	void insert_line(ll m, ll b){
		auto y = insert({ m, b });
		y->succ = [=] {return next(y) == end() ? 0 : &*next(y); };
		if(bad(y)) { erase(y); return; }
		while(next(y) != end() && bad(next(y))) erase(next(y));
		while(y != begin() && bad(prev(y))) erase(prev(y));
	}
	ll eval(ll x){
		auto l = *lower_bound((Line){x, is_query});
		return l.m * x + l.b;
	}
};

const int maxn = 2e5 + 5;

int n;
ll c;
ll h[maxn], ans[maxn];

int main(){
	scanf("%d %lld", &n, &c);
	for(int i = 0; i < n; i++){
		scanf("%lld", &h[i]);
	}
	HullDynamic ch;
	for(int i = n-1; i >= 0; i--){
		if(i == n-1){
			ans[i] = 0;
		}else{//ans[i] = h[i]^2 - 2*h[i]*h[j] + h[j]^2 + c + ans[j]
			ans[i] = -ch.eval(h[i]) + h[i]*h[i];
		}
		ch.insert_line(2*h[i], -(ans[i] + c + h[i]*h[i]));
	}
	printf("%lld\n", ans[0]);
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
namespace mp = boost::multiprecision;
using namespace std;
typedef mp::cpp_int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, const char * argv[]) {
   	cin.tie(0); ios::sync_with_stdio(false);
    // source code
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> ans;
    int p = n;
    int t = n;
    for (int i = n - 1; i >=0; i--) {
        if (i == 0) ans.push_back(p);
        else if ((p - i) == m && s[i] == '0') {
            p = i, t = i, ans.push_back(m);
            //cout << i << " " << p << " " << t << " " << __LINE__ << endl;
        } else if ((p - i) == m && s[i] == '1' && p == t ) { 
            cout << -1 << endl; return 0;
            //cout << i << " " << p << " " << t << " " << __LINE__ << endl;
        } else if ((p - i) == m && s[i] == '1') {
            ans.push_back(p - t), p = t, t = i;
            //cout << i << " " << p << " " << t << " " << __LINE__ << endl;
        } else if (s[i] == '0' && (p - i) < m) {
            t = i;
            //cout << i << " " << p << " " << t << " " << __LINE__ << endl;
        }

    }
    for (auto i = ans.rbegin(), e = ans.rend(); i != e; ++i) cout << *i << " ";
    cout << endl;

    
    return 0;
}


Measured memory_bytes: 1096
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def parse(S):
    S = S + "$"
    cur = 0
    mp = {"01": 0}
    sp = {"01": {0}}
    sv = {"01": (0, 1)}
    lbl = 1
    fmt = "0{}{}1".format
    def comp(left, right):
        lcs, lb = left
        rcs, rb = right
        a0, b0 = sv[lb]
        a1, b1 = sv[rb]
        if a1*b0 != a0*b1:
            return a1*b0 - a0*b1
        if lcs is None and rcs is None:
            return 0
        ll, lr = lcs
        rl, rr = rcs

        cl = comp(ll, rl)
        if cl != 0:
            return cl
        cr = comp(lr, rr)
        if cr != 0:
            return cr
        return 0
    def expr():
        nonlocal cur, lbl
        if S[cur] == "x":
            cur += 1 # "x"
            return (None, "01")
        cur += 1 # "("
        left = expr()
        cur += 1 # " "
        right = expr()
        cur += 1 # ")"

        lb = left[1]; rb = right[1]

        eb = fmt(lb, rb) if lb < rb else fmt(rb, lb)
        if eb not in mp:
            mp[eb] = lbl
            sp[eb] = sp[lb] | sp[rb] | {lbl}
            sv[eb] = (len(sp[lb] & sp[rb]), len(sp[lb] | sp[rb]))
            lbl += 1
        if comp(left, right) < 0:
            left, right = right, left
        return ((left, right), eb)
    return expr()

def dfs(root, m):
    if root[0] is None:
        return "x"
    left, right = root[0]
    if m == 0:
        return "({} {})".format(dfs(left, 0), dfs(right, 1))
    return "({} {})".format(dfs(right, 0), dfs(left, 1))

def solve():
    S = readline().strip()
    if S == "0":
        return False
    res = parse(S)
    write(dfs(res, 0))
    write("\n")
    return True
while solve():
    ...


Measured memory_bytes: 6304
#include <bits/stdc++.h>
#define MAX (ll)(1e5)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;

int main () {
	int x, y;
	cin >> x >> y;
	x--, y--;
	int ar[3] = {3, 2, 1};
	int s = 0;
	if (x < 3) {
		s +=  ar[x];	
	}
	if (y < 3) {
		s += ar[y];
	}
	if (x == 0 && y == 0) {
		s += 4;
	}
	cout << s * 100000 << "\n";
}
	



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
LL modinv(LL a, LL mod){
	LL x,y;
	gcdex(a,mod,x,y);
	if(x<0){
		x+=mod;
	}
	return x;
}

const int N=1e6;
const int M=1e9+7;
template<int S>
struct Comb
{
	LL f[S+1];
	LL r[S+1];
	LL mod;
	Comb(int m)
	{
		mod=m;
		f[0]=1;
		r[0]=1;
		for(LL i=1;i<=S;i++){
			f[i]=i*f[i-1]%m;
			r[i]=modinv(i,m)*r[i-1]%m;
		}
	}
	LL c(int n,int i){
		if(i<0||n<i)
		{
			return 0;
		}
		return f[n]*r[i]%mod*r[n-i]%mod;
	}
};
Comb<N> comb(M);
int main() {
	LL N;
	cin >> N;
	LL pre=0;
	LL ret=0;
	for(LL K=1;K<=N-1;K++){
		LL v=0;
		if(2*K-N>=0){
			v=comb.c(K-1,2*K-N)*comb.f[K]%M*comb.f[N-1-K]%M;
		}
		//cerr << K << ", " << v << endl;
		ret+=(v+M-pre)%M*K%M;
		ret%=M;
		pre=v;
	}
	cout << ret << endl;

	return 0;
}




Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for(ll i = 0; i < (n); i++)
#define fori(i, b, e) for(ll i = (b); i < (e); i++)
#define forr(i, b, e) for(ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    Arr a(n);
    forn(i, n) cin >> a[i];
    multiset<ll> lasts;
    forn(i, n)
    {
        if(lasts.empty() || *lasts.begin() >= a[i])
            lasts.insert(a[i]);
        else
        {
            auto it = lasts.lower_bound(a[i]);
            it--;
            ll val = *it;
            ll cnt = lasts.count(val);
            lasts.erase(val);
            forn(i, cnt - 1) lasts.insert(val);
            lasts.insert(a[i]);
        }
    }
    cout << lasts.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
S = input()
T = input()

if not set(S) >= set(T):
    print(-1)
    exit()

str_repeat_num = 0
now_idx = 0
for t in T:
    if t in S[now_idx:]:
        now_idx += S[now_idx:].index(t) + 1
    else:
        str_repeat_num += 1
        now_idx = now_idx = S[:now_idx].index(t) + 1
print(len(S) * str_repeat_num + now_idx)


Measured memory_bytes: 3444
#include <iostream> pre processor directive
#include <string>
#include <iomanip>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    string S,T,U;
    cin>>S>>T;
    int A,B;
    cin>>A>>B>>U;
    if(U==S){A--;}
    else{B--;}
    cout<<A<<" "<<B<<endl;
}


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

int main(void){
	string str,pat;
	int n;
	cin>>pat>>n;
	int c=0;
	while (n--) {
		cin>>str;
		str+=str;
		if(str.find(pat)!=string::npos)c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3172
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
   if(n>=13) cout << m << endl;
   else if(n>=6) cout << m/2 << endl;
   else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int m,f,r,s;
    while(1)
    {

    scanf("%d %d %d",&m,&f,&r);
    if(m==-1 && f==-1 && r==-1)break;
    if(r==-1) r=0;
    s=0;
    s=m+f;

    if(m==-1 || f==-1)printf("F\n");
    else if(s>=80 )printf("A\n");
    else if(s<80 && s>=65) printf("B\n");
    else if(s<65 && s>=50) printf("C\n");
    else if(s<50 && s>=30 && r>=50) printf("C\n");
    else if(s<50 && s>=30) printf("D\n");
    else if(s<30) printf("F\n");
    }

}



Measured memory_bytes: 2592
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
sum_s = sum(s)
if sum_s % 10 != 0:
    ans = sum_s
else:
    s_10 = [i for i in s if (i%10 != 0)]
    s_10.sort()
    if len(s_10) > 0:
        ans = sum_s - s_10[0]
    else:
        ans = 0
print(ans)

Measured memory_bytes: 3064
# seishin.py
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

M = 32
MOD = [(2 << i) for i in range(M+1)]

from bisect import bisect
def make(B, mode):
    S = [None]*M
    s = {}; get = s.get
    for b in B:
        s[b] = get(b, 0) ^ 1
    S[M-1] = sorted(b for b in s if s[b])

    for i in range(M-2, -1, -1):
        t = S[i+1]; l = len(t)
        m = MOD[i]
        mid = q = bisect(t, m-1)
        p = 0
        if q < l:
            if p < mid:
                def gen(p, q):
                    u = t[p]; v = t[q]
                    while p < mid and q < l:
                        if u+m == v:
                            p += 1; u = t[p] if p < mid else None
                            q += 1; v = t[q] if q < l else None
                        elif u+m < v:
                            yield u
                            p += 1; u = t[p] if p < mid else None
                        else:
                            yield v-m
                            q += 1; v = t[q] if q < l else None
                    while p < mid:
                        yield t[p]; p += 1
                    while q < l:
                        yield t[q]-m; q += 1
                *S[i], = gen(p, q)
            else:
                *S[i], = (u-m for u in t)
        else:
            *S[i], = t
    if mode:
        for i in range(M):
            m = MOD[i]
            S[i] += list(map(lambda x: x+m, S[i]))
    return S
S = make(A, 0)
T = make(B, 1)

ans = 0
if 0 in S[0]:
    ans ^= 1 in T[0]
if 1 in S[0]:
    ans ^= 0 in T[0]

for i in range(1, M):
    s = S[i]; ls = len(S)
    t = T[i]; lt = len(t)
    m = MOD[i]; p = MOD[i-1]
    P = p+m; Q = 2*m

    if lt:
        c = 0
        f = lt
        while P <= t[f-1]:
            f -= 1

        u = f; v = lt
        for a in s:
            while u > 0 and P <= a + t[u-1]:
                u -= 1
            while v > 0 and Q <= a + t[v-1]:
                v -= 1
            c += (v - u)
        if c & 1:
            ans ^= 1 << i
print(ans)

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

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

  int t = sqrt(s);
  int v = 1e9;
  if(t*t == s){
    cout << "0 0 " << t << " 0 0 " << t << endl;
    return 0;
  }

  t += 1;
  int e = t*t-s;
  cout << "0 0 " << t << " " << e << " 1 " << t << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<ll> num(k, 0);
  FORe(i, 1, n) num[i%k]++;
  ll ans = 0;
  REP(a, k){
    ll b = (k-a)%k;
    ll c = (k-a)%k;
    if((b+c)%k != 0) continue;
    ans += num[a]*num[b]*num[c];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main()
{
	int a [100][100];
	int b [100];
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for(int i = 0; i < m; i++)
	{
		scanf("%d", &b[i]);
	}
	int c[100] = {0};
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			c[i]+=a[i][j] * b[j]; 
		}
	}
	for(int i = 0; i < n; i++)
	{
		printf("%d\n", c[i]);	
	} 
	return 0;
} 


Measured memory_bytes: 2752
#include <bits/stdc++.h>
	using namespace std;
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds; 
	#define ordered_set tree<int,int_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
	#define ordered_set_pair tree<pair<int,int>,int_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
	 
	typedef long long int ll;
	typedef long double ld;
	typedef unsigned long long int ull;
	typedef pair<int,int> pi; 
	#define PI 3.1415926535897932384
	#define FOR(i,vv,n) for(int i=vv;i<n;i++)
	#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
	#define ve vector 
	#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
	#define minind(v) (min_element(v.begin(),v.end())-v.begin())
	#define maxe(v) *max_element(v.begin(),v.end())
	#define mine(v) *min_element(v.begin(),v.end())
	#define pb push_back
	#define pf push_front
	#define ppb pop_back
	#define ppf pop_front
	#define eb emplace_back
	#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#define mp make_pair
	#define M 1000000007ll
	#define M1 100000000000000000ll
	#define PRECISE cout.precision(18);
	#define BS(v,n) binary_search(v.begin(),v.end(),n)
	#define srt(v) sort(v.begin(),v.end())
	#define rsrt(v) sort(v.begin(),v.end(),greater <int>())
	#define F first
	#define S second
	#define GET(i,p) get<i>(p)


	ve <ll> parent(100000);
	void make_set(){
		FOR(i,0,100000)
		parent[i]=i;
	}
	ll find_set(ll u){
	if(u==parent[u])
	return u;
	else return parent[u]=find_set(parent[u]);
	}
	void combine(ll u,ll v){
		ll a1=find_set(u);
		ll a2=find_set(v);
		parent[a1]=a2;
	}



	int main(){

	    FAST
	//	PRECISE

	make_set();
	ll n;
	cin>>n;
	ve <pair<pair<ll,ll>,ll>> v[2];
	FOR(i,0,n){
		ll x,y;
		cin>>x>>y;
		v[0].pb({{x,y},i});
		v[1].pb({{y,x},i});
	}
	ve <tuple<ll,ll,ll> > edges;
	srt(v[1]);srt(v[0]);
	FOR(j,0,2)
	FOR(i,1,v[j].size()){

		edges.pb(make_tuple(v[j][i].F.F-v[j][i-1].F.F,v[j][i].S,v[j][i-1].S));
	}
	srt(edges);
	ll ans=0;
	FOR(i,0,edges.size()){
	ll d1=GET(0,edges[i]);
	ll a1=GET(1,edges[i]);
	ll a2=GET(2,edges[i]);

	if(find_set(a1)!=find_set(a2)){
		ans+=d1;
		combine(a1,a2);
	}



	}

	cout<<ans;






	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
	 }

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

int main()
{
    int n, a, b, all = 0;
    cin >> n >> a >> b;
    int ans, ans1, ans2, ans3, ans4, ans5;

    for (int i=1; i<=n; i++) { 
        ans1 = i%10;
        ans2 = (i-ans1)%100;
        ans3 = (i-ans1-ans2)%1000;
        ans4 = (i-ans1-ans2-ans3)%10000;
        ans5 = (i-ans1-ans2-ans3-ans4)%100000;
        ans = ans1 + ans2/10 + ans3/100 + ans4/1000 + ans5/10000;
        if (ans >= a && ans <= b) {
            all += i;
        }
    }
    cout << all << endl;
}   

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

#define ll long long int
int main()
{
    ll n, d, c = 0;
    cin >> n >> d;
    while(n--)
    {
        ll x, y, D, da;
        cin >> x >> y;
        D = (x*x) + (y*y);
        da = sqrt(D);
        if(da * da != D)
            da = da + 1;
        if(da <= d)
            c++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 3180
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    l <- length.filter (=='o').take 15 . (++repeat 'o') <$> getLine
    if l >= 8
    then putStrLn "YES"
    else putStrLn "NO"

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 380
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

sum_A = sum(A)

for n in reversed(range(N)):
    beated = min(B[n], A[n+1])
    B[n] -= beated
    A[n+1] -= beated

    beated = min(B[n], A[n])
    B[n] -= beated
    A[n] -= beated

print(sum_A - sum(A))


Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

long long int modpow(int b, int p){
    long long int num = 1, power = b;
    for(int i=0; i<=30; i++){
        if((p>>i) & 1) num *= power;

        num %= MOD;
        power *= power;
        power %= MOD;
    }
    return num;
}

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

    int n = s.length();
    long long int ans = 0;
    for(int i=0; i<=k; i++){
        long long int add = nCr((k-i)+(n-1), k-i);
        add *= modpow(25,k-i);
        add %= MOD;
        add *= modpow(26,i);
        add %= MOD;

        ans += add;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 66680
#include <stdio.h>

int main(void)
{
    long long int i, n, a[200005], tmp = 0;
    scanf("%lld", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%lld", a + i);
        tmp ^= a[i];
    }
    for (i = 0; i < n; i++)
    printf("%lld ", tmp ^ a[i]);
}


// 14

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N,M;

vector<i64> A,B;

int main(){
  cin >> N >> M;
  A.resize(M);
  B.resize(M);
  rep(i,0,M - 1) cin >> A[i] >> B[i];
  vector<i64> vec;
  rep(i,0,M - 1){
    vec.push_back(B[i]);
  }

  sort(all(vec));
  int ans = 0;
  rep(i,0,M - 2){
    ans +=  max(0LL,vec[i] - N);
  }

  cout << ans << endl;
}



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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
  const char* c = strchr(na + 1, ',');
  cerr.write(na, c - na) << " : " << arg1 << " , ";
  __f(c + 1, args...);
}
#define endl "\n"
#define all(v) v.begin(), v.end()
#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif // LOCAL
  int n, tot;
  cin >> n >> tot;
  vector <int> v(n + 1);
  for (int i = 1; i <= n; i++) cin >> v[i];
  vector <bool> win(tot + 1, false);
  for (int i = 1; i <= tot; i++){
    for (int j = 1; j <= n; j++) {
      if (v[j] <= i && win[i - v[j]] == 0) {
        win[i] = 1;
      }
    }
  }
  cout << (win[tot] ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int min = Integer.MAX_VALUE, ans = 0;
        for (int i = 0; i < N; i++) {
            int n = Integer.parseInt(scanner.next());
            if (n < min) {
                ans++;
                min = n;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 48120
/* ex 9_1
   アカウント名 */

#include <stdio.h>
#include <stdlib.h>
#define SIZE 11


typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

void push(stack *stk, char x){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", x);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = x;
        stk->count++;
    }
}

char pop(stack *stk){
    char x;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        x = *(stk->top);
        stk->top++;
        stk->count--;
        return x;
    }
}


int main(void){
    stack stk;
    int i;
    char input_seq[SIZE];
    char tmp, *ptr;
    scanf("%s", input_seq);
    ptr = input_seq;
    initialize_stack(&stk);
    while(*ptr != '\0'){
        if(*ptr != 'B'){
            push(&stk, *ptr);
        }
        else if(stk.count > 0){
            tmp = pop(&stk);
        }
        ptr++;
    }
    for(i = 0; i < stk.count+1; i++){
        if(stk.data[SIZE - i] != '\0'){
            printf("%c", stk.data[SIZE - i]);
        }
    }
    printf("\n");
    return 0;
}


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

int main() {
	int i, wl, tl, count = 0;
	char w[10], t[1000];
	cin >> w;
	wl = strlen(w);
	for (i = 0; i < wl; i++) {
		if ('A' <= w[i] && w[i] <= 'Z')w[i] += 'a' - 'A';
	}
	while (1) {
		cin >> t;
		if (!strcmp(t, "END_OF_TEXT"))break;
		tl = strlen(t);
		for (i = 0; i < tl; i++) {
			if ('A' <= t[i] && t[i] <= 'Z')t[i] += 'a' - 'A';
		}
		if (!strcmp(w, t))count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1140
using System;
using System.Linq;
//using System.Collections.Generic;

class Test
{
    static void Main()
    {
        Dice dice1 = new Dice(Console.ReadLine());
        int q = int.Parse(Console.ReadLine());

        for (int i = 0; i < q; i++)
        {
            string[] f = Console.ReadLine().Split();
            string f1 = f[0];
            string f2 = f[1];

            if (f1 == dice1.d2) dice1.North();
            else if (f1 == dice1.d3) dice1.West();
            else if (f1 == dice1.d4) dice1.East();
            else if (f1 == dice1.d5) dice1.South();
            else if (f1 == dice1.d6) { dice1.South(); dice1.South(); }
        
            while (dice1.d2 != f2)
            {
                dice1.Spin();
            }

            Console.WriteLine(dice1.d3);
        }
    }
}

class Dice
{
    string[] ss ;
    public string d1, d2, d3, d4, d5, d6;

    public Dice(string s)
    {
        this.ss = s.Split();
        d1 = ss[0];
        d2 = ss[1];
        d3 = ss[2];
        d4 = ss[3];
        d5 = ss[4];
        d6 = ss[5];
    }

    string tmp;

    public void North()
    {
        tmp = d1;
        d1 = d2;
        d2 = d6;
        d6 = d5;
        d5 = tmp;
    }

    public void East()
    {
        tmp = d1;
        d1 = d4;
        d4 = d6;
        d6 = d3;
        d3 = tmp;
    }

    public void West()
    {
        tmp = d1;
        d1 = d3;
        d3 = d6;
        d6 = d4;
        d4 = tmp;
    }

    public void South()
    {
        tmp = d1;
        d1 = d5;
        d5 = d6;
        d6 = d2;
        d2 = tmp;
    }

    public void Spin()
    {
        tmp = d2;
        d2 = d4;
        d4 = d5;
        d5 = d3;
        d3 = tmp;
    }
}


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

int main() {
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld rad=2*M_PI*((h/12)+((m/60)/12)-(m/60));
    ld ans2=ld(pow(a,2))+ld(pow(b,2))-ld(2*a*b)*cosl(rad);
    cout<<fixed<<setprecision(15)<<sqrtl(ans2);
    return 0;
}

Measured memory_bytes: 4144
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		long[] f=new long[(int)1e7+1];
		for (int div=1;div<=1e7;++div) {
			for (int add=div;add<=1e7;add+=div) {
				f[add]+=1;
			}
		}
		long ans=0;
		int N=sc.nextInt();
		for (long i=1;i<=N;++i) {
			ans+=i*f[(int)i];
		}
		System.out.println(ans);
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 112536
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");mp;
int n;
cin>>n;
vector<long long int >mp(n+1,0);
vector<int>v;
for(int i=0;i<n;i++)
{
  int x;
  cin>>x;
  mp[x]++;
v.push_back(x);
}
long long int tot=0;
vector<long long >ans(n+1,0);
for(int i=1;i<=n;i++)
{
  ans[i]=1LL*mp[i]*(mp[i]-1)/2;
  ans[i]=1LL*max(ans[i],0LL);
  tot+=ans[i];

}


for(int i=0;i<n;i++)
{

  cout<<tot-mp[v[i]]+1<<"\n";
}




    return 0;
  }


Measured memory_bytes: 6644
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define sc scanf
#define pr printf
using namespace std;
typedef long long ll;
const ll N = 100000;
int main()
{
    ll n,m;
    while(~sc("%lld%lld",&n,&m))
    {
       ll ans = 0;
       if(n < m/2)
       {
           ans += n;
           m -= n*2;
           ans += m/4;
       }
       else if(n >= m/2)
       {
           ans += m/2;
       }
      pr("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        String s1 = scan.next();
        String s2 = scan.next();
        String s3 = scan.next();
        
        String s1_large = s1.toUpperCase();
        String s2_large = s2.toUpperCase();
        String s3_large = s3.toUpperCase();
            
        System.out.println(s1_large.substring(0,1) + s2_large.substring(0,1) + s3_large.substring(0,1));
	  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v)              \
  cerr << #v ":[ ";          \
  for (auto macro_vi : v)    \
  {                          \
    cerr << macro_vi << " "; \
  }                          \
  cerr << "]" << endl;
#define ddump(v)                     \
  cerr << #v ":" << endl;            \
  for (auto macro_row : v)           \
  {                                  \
    cerr << "[";                     \
    for (auto macro__vi : macro_row) \
    {                                \
      cerr << macro__vi << " ";      \
    }                                \
    cerr << "]" << endl;             \
  }
#define damp(m)                                                   \
  for (auto macro_pair : m)                                       \
  {                                                               \
    cerr << macro_pair.first << ":" << macro_pair.second << endl; \
  }
#define dpair(p) cerr << #p ":" \
                      << "(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v, i) macro_v.begin() + i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "SUN")
  {
    cout << "7" << endl;
  }
  else if (s == "MON")
  {
    cout << "6" << endl;
  }
  if (s == "TUE")
  {
    cout << "5" << endl;
  }
  if (s == "WED")
  {
    cout << "4" << endl;
  }
  if (s == "THU")
  {
    cout << "3" << endl;
  }
  if (s == "FRI")
  {
    cout << "2" << endl;
  }
  if (s == "SAT")
  {
    cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b)
  {
    if(a!=c)
      cout<<"Yes";
    else
      cout<<"No";
  }
  else
  {
    if(a==c||b==c)
      cout<<"Yes";
    else
      cout<<"No";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


typedef long long ll;

using namespace std;

int main() 
{ 

	ll x;
	cin >> x;

	ll res = 0;

	while (x){

		if (x >= 500){
			x -= 500;
			res += 1000;
		}
		else if (x >= 5) {
			x -= 5;
			res += 5;
		}
		else if (x >= 100) {
			x -= 100;
		}
		else if (x >= 50) {
			x -= 50;
		}
		else if (x >= 10) {
			x -= 10;
		}

		else if (x >= 1) {
			x -= 1;
		}
		else {
			break;
		}
		// cout << " x " <<  x << endl;
	}

	cout << res << endl;

	return 0; 
} 


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            string ans = "UNRESTORABLE";

            for (int i = 0; i < s.Length - t.Length + 1; i++)
            {
                for (int j = 0; j < t.Length; j++)
                {
                    if (!new char[2] { t[j], '?' }.Contains(s[i + j])) break;
                    if (j == t.Length - 1) ans = s.Substring(0, i) + t + s.Substring(i + t.Length, s.Length - i - t.Length);
                }
            }
            ans = string.Join("", ans.Select(c => { if (c == '?') return 'a'; else return c; }).ToArray());
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396