akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define endl "\n"

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli n; cin>>n;
    vector< vector<lli> > days;
    vector< vector<lli> > dp;
    days.assign(n, vector<lli>(3,0));
    dp.assign(n, vector<lli>(3,-1));

    for(auto &x: days)
    {
        cin>>x[0]>>x[1]>>x[2];
    }

    dp[n-1][0] = days[n-1][0];
    dp[n-1][1] = days[n-1][1];
    dp[n-1][2] = days[n-1][2];

    for(int i = n-2; i>=0; i--)
    {
        for(int j = 0; j<3; j++)
        {
            if(j==0)
            {
                dp[i][j] = max( days[i][j] + dp[i+1][1], days[i][j] + dp[i+1][2]  );
            }
            else if (j==1)
            {
                dp[i][j] = max(days[i][j] + dp[i+1][0], days[i][j] + dp[i+1][2]);
            }
            else
            {
                dp[i][j] = max(days[i][j] + dp[i+1][0], days[i][j] + dp[i+1][1] );
            }
        }
    }

    /*
    for(auto x: dp)
    {
        cout<<x[0]<<" "<<x[1]<<" "<<x[2]<<endl;
    }
    */
    cout<<max( {dp[0][0], dp[0][1], dp[0][2] }  )<<endl;
    return 0;
}

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

using namespace std;

vector<int> dp(100005, -1);
vector<vector<int>> adjList(100005);

//dp[node] stores the longest path length ending at that node
int dfs(int node)
{
    int maxlen = -1;
    if(dp[node] != -1)
        return(dp[node]);
    if(adjList[node].empty())
        return(0);
    for(int i=0;i<(int)adjList[node].size();i++)
        maxlen = max(maxlen, dfs(adjList[node][i]) + 1);
    return(dp[node] = maxlen);
}

int solve(int n)
{
    for(int i=1;i<=n;i++)
        if(dp[i] == -1)
            dfs(i);
    return(*(max_element(dp.begin(), dp.end())));
}

int main()
{
    int n, m, node1, node2, ans;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        cin >> node1 >> node2;
        adjList[node2].push_back(node1);    //reverse directions
    }
    ans = solve(n);
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 10624
#include<iostream>
#include<cmath>

using namespace std;

int main(void) {
	double s;

	while(!cin.eof()) {
		cin >> s;
		if(!cin.eof()) { cout << ceil(((s/9.8)*(s/9.8)*4.9+5)/5) << endl; }
	}

	return 0;
}

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

int main(){
    int a,b;
    int ans;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b << endl;
    }
    else{
        cout << b-a << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3620
readline = open(0).readline
ans = []
while 1:
    N, M, P = map(int, readline().split())
    if N == 0:
        break
    X = [int(readline()) for i in range(N)]
    s = sum(X)
    t = X[M-1]
    if t == 0:
        ans.append("0\n")
        continue
    ans.append("%d\n" % int(s * (100-P) / t))
open(1, 'w').writelines(ans)


Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<int> enum_div(int n){
	vector<int> ret;
	for(int i=1 ; i*i<=n ; i++){
		if(n%i == 0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
int main(void){
    int a,b,k,n;
    cin >> a >> b >> k;
    if(a<b){
        swap(a,b);
    }
    n = a % b;
    while(n!=0){
        a = b;
        b = n;
        n = a % b;
    }
    vector<int> r = enum_div(b);
    sort(r.begin(),r.end(),greater<int>());
    cout << r[k-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    cout << 48-a << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#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++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

int main(){
    int N, flag = 0;
    cin >> N;
    FOR(i, 1, 10){
        if (N % i == 0 && N / i < 10){
            flag = 1;
        }
    }
    if (flag){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;

const int INF = 100100100;
int N, M, X;
vector<vector<int>> A;
vector<int> C;

int minVec(vector<int> V) {
    int min = INF;
    for (auto v : V) {
        if (min > v) {
            min = v;
        }
    }
    return min;
}


int main() {
    cin >> N >> M >> X;
    vector<int> rowA;
    
    rep(i, N) {
        int c, a;
        cin >> c;
        C.push_back(c);
        rep(j, M) {
            cin >> a;
            rowA.push_back(a);
        }
        A.push_back(rowA);
        rowA = {};
    }
    
    vector<int> costs;
    for(int bit=0; bit<(1<<N); ++bit) {
        vector<int> nowSkill(M);
        int cost = 0;
        rep(i, N) {
            if(1&(bit>>i)) {    
                cost += C[i];
                rep(m, M) {
                    nowSkill[m] += A[i][m];
                }
            }
            else {
                continue;
            }
        }
        int c = 0;
        for(int s: nowSkill) {
            if(s<X) {
                break;
            }
            ++c;
        }
        if(c==M) {
            costs.push_back(cost);
        }
    }

    if(costs.size() == 0) {
        cout << -1 << endl;
        return 0;
    }
    
    cout << minVec(costs) << endl;


    return 0;
}

Measured memory_bytes: 3644
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [i-1 for i in A]

check = [0]*N
i = 0
c = 1
check = []
visited = [0]*N
flag = False
while c<=K:
    if visited[i] == 1:
        flag = True
        break
    else:
        check.append(i)
        visited[i] = 1
        i = A[i]
        c += 1
if flag==True:
    X = check[check.index(i):]
    print(1+X[(K-check.index(i))%len(X)])  
else: 
    print(i+1)

Measured memory_bytes: 32256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[202020];
int main(){
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    ll sum=0, tmp1=0, tmp2, half, idx;
    REP(i, 0, n) sum+=a[i];
    half=sum/2;
    REP(i, 0, n){
        tmp1+=a[i];
        if(tmp1>=half){
            idx=i;
            break;
        }
    }
    tmp2=tmp1-a[idx];

    cout<<min(abs(tmp1-(sum-tmp1)), abs(tmp2-(sum-tmp2)))<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 998244353
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
vector<int> G[200010];
struct mint {
    int x;
    mint(int x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return *this *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
mint F[2100010];
void fact(void) {
	F[0] = mint(1);
	F[1] = mint(1);
	for (int i = 2; i <= 2100000; i++) {
        mint x(i);
		F[i] = x * F[i - 1];
	}
}
 
mint square(mint x) {
    return x * x;
}
 
mint power(mint x, int y) {
    if (y == 0) return mint(1);
    else if (y == 1) return x;
    else if (y % 2 == 0) return square(power(x, y / 2));
    else return square(power(x, y / 2)) * x;
}

mint dfs(int v) {
    mint res(1);
    for(auto to: G[v]) {
        res *= dfs(to);
    }
    return res + 1;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    set<P> st;
    RREP(i, n - 1, 0) {
        int x = p[i].first, d = p[i].second;
        while(st.size() && st.begin()->first < x + d) {
            //cout << i << " " << st.begin()->second << endl;
            G[i].push_back(st.begin()->second);
            st.erase(st.begin());
        }
        st.emplace(x, i);
    }
    mint ans(1);
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        int v = itr->second;
        ans *= dfs(v);
    }
    cout << ans.x << endl;

    return 0;
}


Measured memory_bytes: 40064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	V<int> a(N);
	rep(i,N) cin >> a[i];
	int ans = 0;
	rep1(i,N-2){
		if(a[i-1] < a[i] && a[i] < a[i+1]) ans++;
		if(a[i-1] > a[i] && a[i] > a[i+1]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> P;
  for(int i=0;i<N;i++) P.push_back(i);
  map<int,bitset<8>> m;
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    x--,y--;
    if(!m.count(x)) m[x];
    if(!m.count(y)) m[y];
    m[x].set(y);
    m[y].set(x);
  }
  int tt = 0;
  do{
    if(P[0] != 0) continue;
    bool tf = false;
    for(int i=1;i<N;i++){
      if(!m[P[i-1]].test(P[i]))break;
      if(i == N-1) tf = true;
    }
    if(tf)tt++;
  } while(next_permutation(all(P)));
  cout << tt << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};


int main(){
	int n; cin>> n;
	double l = n/3.0;
	std::cout << std::setprecision(15);
	cout<<l*l*l;
    return 0;
}
	


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

const int N = 1e5 + 5;
int n;

int bitcount(long long x){
    return x == 0? 0: bitcount(x/2) + 1; //2进制的位数
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    int x = bitcount(n);
    cout<<(1<<(x-1))<<endl;
    
    
    
    return 0;
}



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

using namespace std;

const int N=1e6+6,MOD=998244353;

int fac[N],invfac[N],siz,n,m,ans;

int plu(int u,int v){
	return (u+v)%MOD;
}

int dec(int u,int v){
	return u<v?u-v+MOD:u-v;
}

int mul(int u,int v){
	return (int)(1LL*u*v%MOD);
}

int qpow(int u,int v){
	int rep=1;
	while(v){
		if(v&1){
			rep=mul(rep,u);
		}
		u=mul(u,u);
		v>>=1;
	}
	return rep;
}

int c(int u,int v){
	return mul(mul(invfac[v],invfac[u-v]),fac[u]);
}

int main(){
	scanf("%d%d",&n,&m);
	if(n>m){
		swap(n,m);
	}
	siz=n+m;
	fac[0]=1;
	for(int i=1;i<=siz;i++){
		fac[i]=mul(fac[i-1],i);
	}
	invfac[siz]=qpow(fac[siz],MOD-2);
	for(int i=siz-1;~i;i--){
		invfac[i]=mul(invfac[i+1],i+1);
	}
	for(int i=1;i<=n;i++){
		ans=plu(ans,mul(c(n+m-i-i,n-i),c(i+i,i)));
	}
	ans=mul(ans,qpow(mul(2,c(n+m,n)),MOD-2));
	ans=plu(ans,m);
	printf("%d\n",ans);
//	for(int i=0;i<=5;i++){
//		for(int j=0;j<=i;j++){
//			printf("%d%c",c(i,j)," \n"[i==j]);
//		}
//	}
	return 0;
}

Measured memory_bytes: 8064
from collections import Counter
n = int(input())

def foo(a):
    d, m = divmod(a, 2)
    if m:
        return 0
    elif d%2 == 0:
        return 2
    else:
        return 1

cnt = Counter(map(foo, (map(int, input().split()))))

if cnt[2] >= cnt[0] or (cnt[0] == cnt[2] +1 and cnt[1] == 0):
    print("Yes")
else:
    print("No")


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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	ll a, b; cin >> a >> b;
	cout << max(0LL, a - b * 2) << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int so(int a){
  for(int i=2;i*i<=a;i++){
    if(a%i==0)return 0;
  }
  return 1;
}
 
int main(){
  int n,a,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    cnt+=so(a);
  }
  cout<<cnt<<endl;
  return 0;
}



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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int a, b;

int main()
{
  while(cin >> a >> b){
    cout << (int)log10(a + b) + 1<< endl;
  }

  return 0;
}

Measured memory_bytes: 1204
n,x = map(int,input().split())
l = list(map(int,input().split()))
dist = [0]*(n+1)
for i in range(1,n+1):
    dist[i] = dist[i-1] + l[i-1]
    
cnt = 0
for i in range(n+1):
    if dist[i]<= x:
        cnt += 1
print(cnt) 

Measured memory_bytes: 9120
/* Just_Do_It ___________ICARUS__________________*/
                     
    #include <bits/stdc++.h>
    using namespace std;
           
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define per(i,n,a) for (int i=n;i>a;i--)
    #define te int t; std::cin >> t; while(t--)
    #define SZ 200010
    //# define M_PIl  3.141592653589793238462643383279502884L 
    /*   Proceed with CAUTION   */
    
    ll a[SZ],b[SZ];
    vector<ll> v;
    int main(){
        fastio;
        ll n;
        cin>>n;
        rep(i,0,n) {
          cin>>a[i]>>b[i];
          if( (abs(a[i])+abs(b[i]))&1 ^ (abs(a[0])+abs(b[0]))&1 ) {
             cout<<-1<<endl;
              return 0;
          }
        }
        per(i,30,-1) v.push_back(1<<i);
        v.push_back(1);
        v.push_back(1);
        if((abs(a[0])+abs(b[0]))&1^1) v.push_back(1);
        cout<<v.size()<<endl;
        rep(i,0,v.size()) cout<<v[i]<<" ";
        cout<<endl;
        rep(i,0,n){
          string s;
          ll x = a[i], y = b[i];
          rep(j,0,v.size()){
            s+= abs(x)>abs(y) ? ( x>0 ? x-=v[j] , "R" : (x+=v[j] , "L") ) : ( y>0 ? y-=v[j] , "U" : (y+=v[j] , "D" ));
          }
          cout<<s<<endl;
        }
    }



Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

const int64 INF = 1LL << 60;

int N;
int64 a[300000];

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

    cin >> N;
    for (int j = 0; j < 3*N; ++j) {
        cin >> a[j];
    }

    priority_queue<int64> pq;
    int64 ss = 0;
    for (int j = 0; j < N; ++j) {
        pq.emplace(-a[j]);
        ss += a[j];
    }

    int64 mf[300000];
    fill(mf+N, mf+2*N, 0);

    mf[N] = ss;
    for (int j = N; j < 2*N; ++j) {
        int64 c = -pq.top(); pq.pop();
        ss += max(c, a[j]) - c;
        pq.push(-max(c, a[j]));
        mf[j+1] = ss;
    }


    while (!pq.empty()) pq.pop();
    ss = 0;
    for (int j = 2*N; j < 3*N; ++j) {
        pq.emplace(a[j]);
        ss += a[j];
    }
    mf[2*N] -= ss;

    int64 ans = mf[2*N];
    for (int j = 2*N-1; j >= N; --j) {
        int64 c = pq.top(); pq.pop();
        ss += min(c, a[j]) - c;
        pq.push(min(c, a[j]));
        mf[j] -= ss;

        ans = max(ans, mf[j]);
    }

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


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

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

  for(int i=0; i<s.size(); i++) {
    s[i] += n;
    if(s[i]>90) s[i] -= 26;
  }

  cout<<s<<endl;

  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (N % 2) {
        ll ans = B[N / 2] - A[N / 2] + 1;
        cout << ans << '\n';
    } else {
        ll ans = (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1]) + 1;
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6324
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
using namespace std;


int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.length();i++)if(s[i]=='x')ans++;
	
	if(ans<=7)cout << "YES"<<endl;
	else cout <<"NO"<<endl;
	
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int A, B, C;
  cin >> A >> B >> C;
  if(A == B){
    cout << C << endl;
  }else if(B == C){
    cout << A << endl;
  }else{
    cout << B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a_L = list(map(int,input().split()))

import collections

L = collections.Counter(a_L)

L = sorted(L.items(),key=lambda x:x[0],reverse=True)

flag = 0
#print(L)
ans = 0
for k,v in L:
    #print(k,v)
    if v>=4:
        ans = max(ans,k**2)

    if v >= 2:
        if flag== 0:
            tmp = k
            flag += 1
        elif flag == 1:
            ans = max(tmp*k,ans)
            #print(tmp*k)
            #print("ans",tmp,k)
            print(ans)
            exit()

print(0)

Measured memory_bytes: 72472
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
  ll a,b,c ; cin>>a>>b>>c ;
  ll ans = (a-1)/c ;
  ll bns = b/c ;
  cout<< bns-ans<<endl ;
  
   return 0 ;
 }



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			if (line.equals("0")) {
				break;
			}

			int N = Integer.parseInt(line);
			char[] cards = br.readLine().toCharArray();

			int p, b = 0;
			int[] score = new int[N];

			for (int i = 0; i < cards.length; i++) {
				p = i % N;
				switch (cards[i]) {
				case 'M':
					score[p]++;
					break;
				case 'S':
					b += ++score[p];
					score[p] = 0;
					break;
				case 'L':
					score[p] += ++b;
					b = 0;
					break;
				default:
					break;
				}
			}
			Arrays.sort(score);
			for (int i = 0; i < score.length; i++) {
				System.out.print(score[i] + " ");
			}
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 19092
cnt = 0
n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
    for j in range(n-1,i,-1):
        if lst[j] < lst[j-1]:
            lst[j-1:j+1] = lst[j], lst[j-1]
            cnt += 1
print(*lst)
print(cnt)

Measured memory_bytes: 7696
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        long cnt = 0;
        for(int b = k+1; b <= n; b++) {
        	int p = n / b;
    		
        	if(k == 0)
        		cnt += Math.max(b - k, 0) * p + Math.max((n % b) - k, 0);
        	else
        	    cnt += Math.max(b - k, 0) * p + Math.max((n % b) - k + 1, 0);
    	}
        System.out.println(cnt);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
    fast;
 string s;
 cin>>s;

 ll cnt=0,ans=0;
 fr(i,0,s.size())
 {
    if(s[i]=='R')
        cnt++;
    else
    {
        ans=max(ans,cnt);
        cnt=0;
    }
 }
 ans=max(ans,cnt);
 cout<<ans<<endl;
    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 3640
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    res=l[i]+l[j]
    mid=bisect.bisect_left(l,res)
    ans+=mid-j-1
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int x,y,w;
int main()
{
	cin>>w>>x>>y;
	if (x==y||(x+w>y&&x<y)||(y+w>x&&y<x))
	{
		cout<<0;
	}
	else cout<<abs(y-x)-w;
	return 0;
}

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

int main()
{
    int a, b, c;
    cin>>a>>b>>c;

    if(a==b && b==c)
        cout<<"No";
    else if(a==b)
        cout<<"Yes";
    else if(b==c)
        cout<<"Yes";
    else if(c==a)
        cout<<"Yes";
    else
        cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, x;
    cin >> n >> x;
    int l[n];

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

    if(n == 0) {
        cout << 0 << endl;
        return 0;
    }

    int count = 1;
    int bound = 0;
    for(int i = 0; i < n; i++) {
        bound += l[i];
        if(bound <= x) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
n ,m = list(map(int, input().split()))
flg = [False] * n
wa = [0] * n
ac = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if not flg[p]:
        if s == 'WA':
            wa[p] = wa[p] + 1
        else:
            ac = ac + 1
            flg[p] = True

was = [0] * n
for i in range(n):
    if flg[i]:
        was[i] = wa[i]
# print(sum(was))

print("%d %d" % (ac, sum(was)))


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

int main(void)
{
    int A, B;
    cin >> A >> B;

    int ans;

    if(A+B > A-B){
        if(A*B > A+B){
            ans = A*B;
        }else{
            ans = A+B;
        }
    }else{
        if(A*B > A-B){
            ans = A*B;
        }else{
            ans = A-B;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<cstring>
#include <stack>
#include <numeric>
#include<climits>
#include<cmath>
#include<set>
#include<unordered_set>
#include<iomanip>
#include<queue>
#include<unordered_map>
#define vi vector<float>
#define vl vector<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define loop(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define mp make_pair
#define ll long long
const int mod = 1e9 + 7;
using namespace std;

#define xx first
#define yy second


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


	int n, m;
	cin >> n >> m;
	vector<double> vec(n);
	double sum  = 0 ;
	for (auto &val : vec) {
		cin >> val;
		sum += val;
	}

	sort(all(vec), greater<double>());
	double cur = (double)sum / double(4 * m);
	
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (vec[i] >= cur) {
			count++;
		}
	}

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

	return 0;
}










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

int main() {
  int N,M;
  cin >> N >> M;
  int i,count = 0;
  vector<int> A(N);
  int sum;
  for (i = 0;i < N ;i++) {
  cin >> A[i];
  sum += A[i];
  }
  for (i = 0;i < N ;i++) {
    if (A[i]*4*M < sum){
    continue;
    }
    else{
    count++;
    }
  }
  if (count >= M) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
  }
}
  



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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << endl;
}


Measured memory_bytes: 3612
s = input()
s_list = [s[_] for _ in range(len(s))]

dic = dict()
for c in s_list:
  if c in dic:
    dic[c] += 1
  else:
    dic[c] = 1

flg = True
for key in dic:
  if dic[key]%2 != 0:
    flg = False
    break
    
if flg:
  print('Yes')
else:
  print('No')

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,r;
    string s;
    cin>>n>>r;
    ll k = min(10LL,n);
    ll ans=r+100*(10-k);
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,ll> pii;
const int max_N=1e5+10;
vector<int> fives;
vector <pii> G[max_N],rg[max_N];
bool isprime[55600];
ll ans=0;
ll sortcase=0;
class Cake
{
public:
  ll be,de,po;
  Cake(ll a,ll b,ll c)
  {
    be=a;
    de=b;
    po=c;
  }
};


bool sortstand(const Cake& l,const Cake& r)
{
  ll lscore=0,rscore=0;
  for(int i=0;i<3;i++)
    {
      if(sortcase&(1<<i))
	{
	  if(i==0) lscore+=l.be,rscore+=r.be;
	  else if(i==1) lscore+=l.de,rscore+=r.de;
	  else if(i==2) lscore+=l.po,rscore+=r.po;
	}
      else
	{
	  if(i==0) lscore+=l.be*(ll)-1,rscore+=r.be*ll(-1);
	  else if(i==1) lscore+=l.de*(ll)-1,rscore+=r.de*ll(-1);
	  else if(i==2) lscore+=l.po*(ll)-1,rscore+=r.po*ll(-1);
	}
    }
  return lscore>rscore;
}

void calc(vector<Cake> cakes,int m)
{
  //cout << sortcase << endl;
  ll betot=0,detot=0,potot=0;
  for(int i=0;i<m;i++)
    {
      //cout << cakes[i].be << ' ' << cakes[i].de << ' ' << cakes[i].po << endl;
      betot+=cakes[i].be;
      detot+=cakes[i].de;
      potot+=cakes[i].po;
    }
  ans=max(ans,abs(betot)+abs(detot)+abs(potot));
  //cout << endl;
}


int main()
{
  int n,m;
  cin >> n >> m;
  vector<Cake> cakes;
  for(int i=0;i<n;i++)
    {
      ll x,y,z;
      cin >> x >> y >> z;
      cakes.push_back(Cake(x,y,z));
    }
  while(sortcase!=8)
    {
      //cout << sortcase << endl;
      sort(cakes.begin(),cakes.end(),sortstand);
      calc(cakes,m);
      sortcase++;
    }
      cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N;
  invec<int> A(N);
  
  vector<ll> gram(N+1, 0);
  
  ll r = 0LL;
  for (auto i : A) {
    r += gram[i];
    gram[i]++;
  }

  for (auto i : A) {
    cout << r - (gram[i] - 1LL) << endl;
  }
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h> 
#define IRONMAN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define l long long
#define ull unsigned long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define at(i,a) for(auto &i: a)
using namespace std; 
void solve(); 
int main() 
{ 
   IRONMAN

   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   freopen("output.txt", "w", stdout); 
   #endif 
   
   int t=1;//cin>>t; 
   while(t--) 
   { 
      solve(); 
      cout<<"\n"; 
   } 
   
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
} 
void solve() 
{
   l n,sum=0;
   cin>>n;
   for(int i=1; i<=n-1; i++) sum+=(n-1)/i;
   cout<<sum;
} 

Measured memory_bytes: 3788
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	int a[n+1][3]={0};
	for(int i=1;i<=n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	int dp[n+1][3];
	memset(dp,0,sizeof(dp));
	dp[1][0]=a[1][0];
	dp[1][1]=a[1][1];
	dp[1][2]=a[1][2];
	for(int i=2;i<=n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	int ans=0;
	ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

#[allow(dead_code)]
fn read<T : FromStr>() -> T {
  let token: String = stdin().lock()
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parse")
}

#[allow(dead_code)]
fn read2<T : std::str::FromStr>() -> (T, T) {
  (read::<T>(), read::<T>())
}

#[allow(dead_code)]
fn read3<T : std::str::FromStr>() -> (T, T, T) {
  (read::<T>(), read::<T>(), read::<T>())
}

#[allow(dead_code)]
fn reads<T : std::str::FromStr>() -> Vec<T> {
  let mut line = String::new();
  stdin().read_line(&mut line).ok();
  line.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

struct MaxSegTree {
  n: usize,
  data: Vec<i64>,
}

impl MaxSegTree {
  fn new(data_: &[i64]) -> Self {
    let m = data_.len();
    let mut n = 1;
    while n < m { n *= 2; }

    let mut data = vec![std::i64::MIN; 2*n];

    for i in 0..m {
      data[i + n - 1] = data_[i];
    }

    for ri in 0..n-2 {
      let i = n - 2 - ri; // [n-2 .. 0]
      data[i] = max(data[i*2+1], data[i*2+2]);
    }

    Self {
      n,
      data,
    }
  }

  fn update(&mut self, i: usize, val: i64) {
    let mut i = self.n - 1 + i;
    self.data[i] = val;
    while i > 0 {
      i = (i - 1) / 2;
      self.data[i] = max(self.data[i*2+1], self.data[i*2+2]);
    }
  }

  fn query(&self, l: usize, r: usize) -> i64 {
    let mut l = l + self.n - 1;
    let mut r = r + self.n - 1;

    let mut res = std::i64::MIN;
    while l < r {
      if (l & 1) == 0 {
        res = max(res, self.data[l]);
      }
      if (r & 1) == 0 {
        res = max(res, self.data[r]);
      }
      l = l / 2;
      r = (r - 1) / 2;
    }

    res
  }

  fn query2(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> i64 {
    if r <= a || b <= l { return std::i64::MIN; }
    if a <= l && r <= b { return self.data[k]; }

    let mid = (l + r) / 2;
    let vl = self.query2(a, b, k * 2 + 1, l, mid);
    let vr = self.query2(a, b, k * 2 + 2, mid, r);
    max(vl, vr)
  }

  fn query3(&self, a: usize, b: usize) -> i64 {
    self.query2(a, b, 0, 0, self.n)
  }
}

fn main() {
  let n: usize = read();
  let k: usize = read();
  let mut xs: Vec<usize> = Vec::with_capacity(n);
  for _ in 0..n {
    let x = read();
    xs.push(x);
  }

  const LIMIT: usize = 300000 + 10;
  let mut seg = MaxSegTree::new(&vec![0; LIMIT]);
  let mut res = 1;
  for x in xs {
    let l = if x >= k { x - k } else { 0 };
    let r = if x + k + 1 <= LIMIT { x + k + 1 } else { LIMIT };
    let head = seg.query3(l, r);

    seg.update(x, head + 1);
    res = max(res, head + 1);
  }

  // let res = seg.query(0, LIMIT);
  println!("{}", res);
}

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

int main(){

  int a=0;
  int b=0;
  
  cin>>a>>b;
  
  int count=0;
  if(a>1)count+=a*(a-1)/2;
  if(b>1)count+=b*(b-1)/2;
  cout<<count<<endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        if (i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

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

int main() {
  int a, n[200000];
  cin >> a;
  for(int i = 0; i < a; ++i) {
    cin >> n[i];
  }
  int maxv = -1000000000;
  int minv = n[0];
  for(int j = 1; j < a; ++j) {
    maxv = max(maxv, n[j] - minv);
    minv = min(minv, n[j]);
  }
  cout << maxv << endl;
}


Measured memory_bytes: 3876
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
A.sort()


T=[]
if n%2==0:
    for i in range(n//2):
        T.append(2*i+1)
        T.append(2*i+1)
else:
    T.append(0)
    for i in range(n//2):
        T.append(2*i+2)
        T.append(2*i+2)
        
for i in range(n):
    if A[i] != T[i]:
        print(0)
        break
else:
    print((2**(n//2))%mod)

Measured memory_bytes: 13880
#include<stdio.h>
#include<string.h>
#include<utility>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1000000000
int C,N,M,S,D,g1[101][101],s,t,c,d[11][101];
typedef struct P{int p,c,t;}P;
struct Order
{
	bool operator ()(P const& a, P const& b) const
	{
		return a.c>b.c;
	}
};

P tmp,tmp2;
priority_queue<P,vector<P>,Order>Q;
int main()
{
	for(;scanf("%d%d%d%d%d",&C,&N,&M,&S,&D),C;)
	{
		for(int i=0;i<=N;i++)
			for(int j=0;j<=N;j++)
				g1[i][j]=INF;
		for(int i=0;i<=C;i++)
			for(int j=0;j<=N;j++)
				d[i][j]=INF;
		for(int i=0;i<M;i++)
		{
			scanf("%d%d%d",&s,&t,&c);
			if(g1[s][t]>c)
				g1[s][t]=g1[t][s]=c;
		}
		d[C][S]=0;
		tmp.c=0;tmp.p=S;tmp.t=C;
		Q.push(tmp);
		for(;!Q.empty();)
		{
			tmp=Q.top(),Q.pop();
			for(int i=0;i<=N;i++)
			{
				int nc=tmp.c+g1[tmp.p][i];
				if(d[tmp.t][i]>nc)
				{
					tmp2.c=d[tmp.t][i]=nc;
					tmp2.p=i;
					tmp2.t=tmp.t;
					Q.push(tmp2);
				}
				nc=tmp.c+g1[tmp.p][i]/2;
				if(tmp.t>0&&d[tmp.t-1][i]>nc)
				{
					tmp2.c=d[tmp.t-1][i]=min(d[tmp.t][i],nc);
					tmp2.p=i;
					tmp2.t=tmp.t-1;
					Q.push(tmp2);
				}
			}
		}
		printf("%d\n",d[0][D]);
	}
}

Measured memory_bytes: 1172
#include<stdio.h>
int main()
{
    int A,B,C,sum;
    scanf("%d%d%d",&A,&B,&C);
    sum=A-B;
    if(sum<C){
        printf("%d\n",C-sum);
    }else
    {
        printf("0\n");

    }
    return 0;



}


Measured memory_bytes: 128