akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	BIT(int n = 0) {
		initialize(n);
	}
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

const ll mod = 998244353;

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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>>p(N);
	vector<int>Y(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i].first >> p[i].second;
		Y[i] = p[i].second;
	}
	sort(all(p));
	sort(all(Y));

	BIT<int>unused(N);
	BIT<int>used(N);
	for (int i = 0; i < N; i++) {
		int ind = lower_bound(all(Y), p[i].second) - Y.begin();
		unused.plus(ind,1);
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		int ind = lower_bound(all(Y), p[i].second) - Y.begin();
		int a = unused.sum_between(ind + 1, N - 1);
		int b = used.sum_between(ind + 1, N - 1);
		int c = used.sum_between(0, ind - 1);
		int d = unused.sum_between(0,ind-1);
		ans += modpow(2,N-1);
		ans %= mod;
		ll num1 = ((modpow(2, a) - 1) * (modpow(2, c) - 1)) % mod;
		num1 *= (modpow(2,b) * modpow(2,d)) % mod;
		num1 %= mod;
		ll num2 = ((modpow(2, b) - 1) * (modpow(2, d) - 1)) % mod;
		num2 *= (modpow(2, a)*modpow(2, c))%mod;
		num2 %= mod;
		ll num3 = ((modpow(2, a) - 1)*(modpow(2, b) - 1))%mod;
		num3 *= ((modpow(2, c) - 1)*(modpow(2, d) - 1))%mod;
		num3 %= mod;
		ans += num1 + num2 - num3 + 10LL*mod;
		ans %= mod;
		unused.plus(ind, -1);
		used.plus(ind, 1);
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 4224
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long c=sc.nextLong();
    long k=sc.nextLong();
   	if(k<=a)System.out.println(k);
    else if(k<=a+b)System.out.println(a);
    else System.out.println(a-(k-a-b));
  }
}

Measured memory_bytes: 26996
//題意はすぐ分かる。数列の順番関係なくて、個数が大事。
#include <iostream>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[100000];
int q, b, c;
int cnt[100001], ans = 0;

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) { cnt[a[i]]++; ans += a[i]; }
	
	cin >> q;
	rep(i, q) {
		cin >> b >> c;
		ans += (c - b) * cnt[b];
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> R(N), B(N);
  int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    R[i] = make_pair(a, b);
  }
  int c, d;
  for (int i = 0; i < N; i++) {
    cin >> c >> d;
    B[i] = make_pair(c, d);
  }

  int ans = 0;
  sort(R.begin(), R.end(), [](auto a1, auto a2){return a2.second < a1.second;});
  sort(B.begin(), B.end());
  vector<bool> mada(N, true);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (R[j].first < B[i].first && R[j].second < B[i].second && mada[j]) {
        ans++;
        mada[j] = false;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return -1;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        //res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    vector <ll> v(n);
    REP(i,0,n){
        cin>>v[i];
    }
    sort(v.B,v.E);
    ll ans=0;
    REP(i,0,n){
        REP(j,i+1,n){
            REP(k,j+1,n){
                if(v[i]+v[j]>v[k] && v[i]!=v[j] && v[i]!=v[k] && v[k]!=v[j]){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
    
}

Measured memory_bytes: 3640
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1e9+7;
const ll maxn = 1000005;
const ll mm = 1e+18;
void solve()
{
    int n,m;
    cin>>n>>m;
    double tot=0;
	double arr[n];
    rep0(i,n) {cin>>arr[i];tot+=arr[i];}
    tot/=(4*m);
    int yy=0;
    rep0(i,n){
        if(arr[i]>=tot) yy++;
    }
    if(yy>=m) cout<<"Yes";
    else cout<<"No";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){ //1e6くらいまでしか使えん
	vl x(n);
	REP(i, sqrt(n)+2){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll N;
// 変数定義end

void solve(){
	cin >> N;
	if(N % 2 == 0){
		cout << (long double)N/(2*(long double)N) << endl;
	} else {
		cout <<((floor((long double)N/2))+1)/(long double)N << endl;
	}
}

int main(){

    //clock_t start = clock();

    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve(); clock_t end = clock();

    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
}


Measured memory_bytes: 256
N = input()
nlen = len(N)
n = int(N)
j = nlen
ans = 0
while j > 0:
    if j % 2 == 0:
        j -= 1
        continue
    else:
        if j == nlen:
            ans += n - 10**(j-1) + 1
        else:
            ans += 10**j - 10**(j-1)
        j -= 1
print(ans)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    double D;
    cin >> N >> D;
    ll ans = 0;
    rep(i, N){
        double x,y;
        cin >> x >> y;
        if(sqrt(x*x + y*y) <= D){
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

bool is_ok(ll n, ll k, vll &a, vll &f, ll m) {
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll score = a[i] * f[n - 1 - i];
    ll train = ceil((double)(score - m) / f[n - 1 - i]);
    ans += max(0LL, train);
  }
  return (ans <= k);
}

//二分探索
//main関数で呼び出す前に，min, maxの一方が条件を満たし他方が満たさないことを確認すること
ll binary_search(ll min, ll max, ll n, ll k, vll &a, vll &f) {
  if (min + 1 == max) { //解近傍の処理
    if (is_ok(n, k, a, f, min)) return min;
    return max;
  }

  ll med = (min + max) / 2;
  if (is_ok(n, k, a, f, med)) return binary_search(min, med, n, k, a, f);
  else return binary_search(med, max, n, k, a, f);
}

int main() {
  ll n, k;
  cin >> n >> k;

  vll a(n), f(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  for (ll i = 0; i < n; i++) cin >> f[i];
  sort(all(a));
  sort(all(f));

  ll min = 0, max = 1e12;
  if (is_ok(n, k, a, f, min)) {
    cout << min << endl;
    return 0;
  }
  cout << binary_search(min, max, n, k, a, f) << endl;
}

Measured memory_bytes: 3328
n,m=map(int,input().split())
L=[]
for i in range(m):
    p,y=map(int,input().split())
    L.append([p,y,i])
L.sort(key=lambda L:(L[0],L[1]))
L[0][1]=1
for i in range(1,m):
    if L[i][0]!=L[i-1][0]:
        L[i][1]=1
    else:
        L[i][1]=L[i-1][1]+1
L.sort(key=lambda L:L[2])
for i in range(m):
    print('{h1:0=6}{h2:0=6}'.format(h1=L[i][0],h2=L[i][1]))   



Measured memory_bytes: 31188
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//using namespace atcoder;

int main(){
    ll N;
    //cout << __gcd(0,27) << endl;
    cin >> N;
    vector<ll> A(N), L(N+1), R(N+1);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        L[i+1] = __gcd(L[i], A[i]);
    }
    for(ll i=N-1;i>=0;i--){
        R[i] = __gcd(R[i+1], A[i]);
    }
    ll ans = 0;
    rep(i,N){
        cmax(ans, __gcd(L[i], R[i+1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5580
#include <iostream>

using namespace std;

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

signed main() {
  int n, k;
  cin >> n >> k;
  int p[n], c[n];
  rep(i,n) cin >> p[i];
  rep(i,n) p[i]--;
  rep(i,n) cin >> c[i];
  
  int ms = (int)-1e10;
  rep(i,n) {
    int da[n], ds[n];
    rep(i,n) da[i] = -1;
    
    int a = i, s = 0;
    rep(j,k) {
      int rk = k - j, ll = j - da[a];
      if(da[a] != -1 && rk > ll) {
        int lc = rk / ll - 1, nk = rk - ll * lc;
        s += (s - ds[a]) * lc;
        rep(j,nk) {
          a = p[a];
          s += c[a];
          ms = max(ms, s);
        }
        break;
      }
      da[a] = j;
      ds[a] = s;
      a = p[a];
      s += c[a];
      ms = max(ms, s);
    }
  }
  cout << ms << endl;
  return 0;
}

Measured memory_bytes: 3344
#include <stdio.h>

int main(void){
  int n, m;
  scanf("%d %d", &n, &m);

  int a[n], total=0; //総投票数
  for(int i=0; i<n; i++){
    scanf("%d", &a[i]);
    total += a[i];
  }

  int ninki=0; //人気商品に選ぶ条件を満たす商品の数
  for(int i=0; i<n; i++){
    if(a[i] * 4 * m >= total) ninki++;
  }

  if(ninki >= m) printf("Yes\n");
  else printf("No\n");

  return 0;
}


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

using ll=long long;
const ll MOD=1e9+7;

ll powm(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res*=a;
        a*=a;
        a%=MOD;
        res%=MOD;
        b>>=1;
    }
    return res;
}

ll mod_inv(ll x){
    return powm(x,MOD-2);
}

int main(){
    ll n,k;
    cin>>n>>k;
    set<int> divisor;
    for(int i=1;i<1e5;i++){
        if(n%i==0){
            divisor.insert(i);
            divisor.insert(n/i);
        }
    }
    vector<ll> div(divisor.begin(),divisor.end());

    vector<ll> dp(div.size());
    ll res=0;
    
    for(int i=0;i<div.size();i++){
        ll cnt=powm(k,div[i]/2+(ll)(div[i]%2!=0));
        cnt=(cnt+MOD)%MOD;
        for(int j=0;j<i;j++){
            if(div[i]%div[j]==0) cnt-=dp[j];
            cnt=(cnt%MOD+MOD)%MOD;
        }
        dp[i]=cnt;
        if(div[i]%2==0){
            res+=(((cnt*mod_inv(2))%MOD)*div[i])%MOD;
        }
        else{
            res+=(cnt*div[i])%MOD;
        }
        res%=MOD;
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 384
a=int(input())
ct=0
b=list(map(int,input().split()))
for i in range (a-2):
    if (b[i]<b[i+1])and(b[i+1]<b[i+2]):
        ct+=1
    elif (b[i+2]<b[i+1])and(b[i+1]<b[i]):
        ct+=1
print(ct)

Measured memory_bytes: 3060
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []

for i in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])

BC.sort(reverse=True, key=lambda x: x[1])

heapq.heapify(A)

flag = True
for bc in BC:
    for j in range(bc[0]):
        min_a = heapq.heappop(A)
        if min_a >= bc[1]:
            heapq.heappush(A, min_a)
            flag = False
            break
        else:
            min_a = bc[1]
        heapq.heappush(A, min_a)
    if not flag:
        break

print(sum(A))

Measured memory_bytes: 98712
from collections import deque
s = deque(input())
q = int(input())

ok = True
for i in range(q):
    query = input()
    if query[0] == '1':
        if ok:
            ok = False
        else:
            ok = True
    else:
        query = query.split()
        if ok:
            if query[1] == '1':
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if query[1] == '1':
                s.append(query[2])
            else:
                s.appendleft(query[2])
if not ok:
    s.reverse()
print(''.join(list(s)))

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

int main() {
  int N;

  cin >> N;

  vector<int> V(N);
  vector<int> C(N);

  for (int i = 0; i < N; ++i) cin >> V[i];

  for (int i = 0; i < N; ++i) cin >> C[i];

  int ans = 0;

  for (int i = 0; i < N; ++i) {
    if (V[i] > C[i]) {
      ans += V[i] - C[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int K, S;
    cin >> K >> S;

    int ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - (x + y);
            if (0 <= z && z <= K) ans++;
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 3604
#include<iostream>
#include <cstdio>
#include<cctype>
 
using namespace std;
 
int main(){
     
    char ch;
     
    while((ch = getchar()) != EOF){
        if(islower(ch))
            ch = toupper(ch);
        else
            ch = tolower(ch);
        cout << ch;
    }
     
    return 0;
}

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

int main() {
  int K;
  cin >> K;
  queue<long long> q;
  for (int i = 1; i <= 9; ++i)
    q.push(i);
  for (int i = 0; i < K - 1; ++i) {
    long long X = q.front();
    q.pop();
    if (X % 10 != 0)
      q.push(X * 10 + X % 10 - 1);
    q.push(X * 10 + X % 10);
    if (X % 10 != 9)
      q.push(X * 10 + X % 10 + 1);
  }
  cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

vector<ll> G[200005];
bool gone[200005];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s;
  cin >> t;
  char st[26], ts[26];
  REP(i,26){
    st[i] = '0';
    ts[i] = '0';
  }
  REP(i,s.size()){
    int a = s[i] - 'a';
    int b = t[i] - 'a';
    if(st[a] == '0'){
      st[a] = t[i];
    }else{
      if(st[a] != t[i]){
        cout << "No" << endl;
        return 0;
      }
    }
    if(ts[b] == '0'){
      ts[b] = s[i];
    }else{
      if(ts[b] != s[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
 
}




Measured memory_bytes: 5652
import sys
import bisect
input = sys.stdin.readline

def main():
    N,M = map(int, input().split())
    PY_input = []
    PY_dict = {}
    for _ in range(M):
        p, y = map(int, input().split())
        PY_input.append((p, y))
        PY_dict.setdefault(p, []).append(y)

    for i in PY_dict.values():
        i.sort()

    for p, y in PY_input:
        print("{:06}{:06}".format(p, bisect.bisect_right(PY_dict[p], y)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 35260
// https://atcoder.jp/contests/abc081/tasks/abc081_b
#include <bits/stdc++.h>
using namespace std;

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

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

  int ans = 1e9;
  while (N--) {
    int a, c = 0;
    cin >> a;

    while (a % 2 == 0) {
      c++;
      a /= 2;
    }
    ans = min(c, ans);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,l=0;
int a[200000];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    if(n%2){
        for(int i=0;i<n;i+=2){
            if(i==n-1&&a[i]==0){
                int ans=1;
                for(int j=0;j<l;j++){
                    ans*=2;
                    ans%=mod;
                }
                cout<<ans<<endl;
                return 0;
            }
            else if(a[i]==(n-1)-i&&a[i+1]==(n-1)-i){
                l++;
            }
            else break;
        }
        cout<<0<<endl;
    }
    else{
        for(int i=0;i<n;i+=2){
            if(a[i]==(n-1)-i&&a[i+1]==(n-1)-i){
                l++;
                if(i==n-2){
                    int ans=1;
                    for(int j=0;j<l;j++){
                        ans*=2;
                        ans%=mod;
                    }
                    cout<<ans<<endl;
                    return 0;
                }
            }
            else break;
        }
        cout<<0<<endl;
        return 0;
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <vector>
#include <tuple>
using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double eps = 1e-8;
 
#define INF 2147483647
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define FILL(v,n) memset(v,n,sizeof(v))
#define EB emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rep1n(i,n) for(int i=1;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie();cout.tie();
 
#define MXN 1000010 //10^6

int main(){
    ll n, k, ans;
    vector<ll> v;
    map<int, int> mp;
    
    cin>>n>>k;
    
    ans = 0;
    v.resize(n+1);
    
    rep1(i, n){
        cin>>v[i];
        v[i] += v[i-1];
    }
    
    for(int i=1;i<=n;i++){
        mp[(v[i-1] - (i-1))%k]++;
        if(i >= k)
            mp[(v[i-k] - (i-k))%k]--;
        ans += mp[(v[i] - i)%k];
        //cout<<ans<<' ';
    }
    cout<<ans;
    
}







Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair


int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    LL res = 700;
    for(int i = 0 ; i < s.size(); i++)if(s[i] == 'o')res += 100;
    cout << res << endl;
    return 0;
}


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


#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int M,N,A,B;

int a,b,c=~(1<<31),m=(1<<16)-1;
int r() {
  a = 36969 * (a & m) + (a >> 16);
  b = 18000 * (b & m) + (b >> 16);
  return (c & ((a << 16) + b)) % 1000000;
}

map<int,int>lis[333333];

void solve(){
    vector<tuple<int,int,int>>ps;
    rep(i,M){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        ps.pb(make_tuple(x,y,z));
    }
    a=A;b=B;
    rep(i,N){
        int x,y,z;
        x=r();y=r();z=r();
        ps.pb(make_tuple(x,y,z));
    }

    N+=M;
    rep(i,N)get<1>(ps[i])*=-1;
    sort(all(ps));
    rep(i,N)get<1>(ps[i])*=-1;

    rep(i,N+1)lis[i].clear();

    /*
    vector<int>latte;
    rep(i,N){
        latte.pb(get<0>(ps[i]));
        latte.pb(get<1>(ps[i]));
        latte.pb(get<2>(ps[i]));
    }
    sort(all(latte));latte.erase(unique(all(latte)),latte.end());
    rep(i,N){
        get<0>(ps[i])=lower_bound(all(latte),get<0>(ps[i]))-latte.begin();
        get<1>(ps[i])=lower_bound(all(latte),get<1>(ps[i]))-latte.begin();
        get<2>(ps[i])=lower_bound(all(latte),get<2>(ps[i]))-latte.begin();
    }
    rep(i,N){
        cout<<get<0>(ps[i])<<" "<<get<1>(ps[i])<<" "<<get<2>(ps[i])<<endl;
    }*/

    for(auto &w:ps){
        int x=get<1>(w),y=get<2>(w);
        //cout<<" in "<<x<<" "<<y<<endl;
        int lb=0,ub=N;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if([&](){
                auto it=lis[mid].lower_bound(x);
                if(it==lis[mid].begin())return false;
                it--;
                return it->se<y;
            }())lb=mid;
            else ub=mid;
        }

        if(lis[ub].find(x)!=lis[ub].end())chmin(lis[ub][x],y);
        else lis[ub][x]=y;

        while(true){
            auto it=lis[ub].upper_bound(x);
            if(it==lis[ub].end())break;
            if(it->se<=y)break;
            lis[ub].erase(it);
        }
        /*
        for(int j=0;j<=N;j++){
            if(lis[j].size()==0)continue;
            cout<<j<<"-------"<<endl;
            for(auto &z:lis[j])cout<<"("<<z.fi<<","<<z.se<<")"<<" ";cout<<endl;
        }*/
    }

    int ans=0;
    rep(i,N+1)if(lis[i].size())ans=i;
    printf("%d\n",ans);
}
signed main(){
    while(scanf("%d%d%d%d",&M,&N,&A,&B),M||N||A||B)solve();
    return 0;
}

Measured memory_bytes: 32864
package main

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

func main() {
	sc := NewScanner()
	N, Y := sc.NextInt(), sc.NextInt()
	for i := 0; i <= N; i++ {
		if Y == i*2+(N-i)*4 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1756
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=10000005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli N,i,j,p,q;
	cin>>p>>q;
	cout<<p*q;
}

Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;


void solve(long long N, std::vector<std::string> S){

    std::sort(S.begin(), S.end());
    S.erase(std::unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;
    return;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 9516
#include <stdio.h>

#define M 100002

int partition(int *,int,int);

int main(){
  int len,num,A[M];
  int i;
  
  scanf("%d",&len);
  for(i=0;i<len;i++) scanf("%d",&A[i]);
  num=partition(A,0,len-1);

  for(i=0;i<len;i++){
    if(i>0) printf(" ");
    if(i==num) printf("[");
     printf("%d",A[i]);
    if(i==num) printf("]");
  }
  printf("\n");
  
  return 0;
}

int partition(int *A,int p,int r){
  int x,temp;
  int i,j;
  
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if (A[j]<=x){
      i=i+1;
      //A[i] と A[j] を交換
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  //A[i+1] と A[r] を交換
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  
  return i+1;
}



Measured memory_bytes: 2176
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, A := sc.nextInt(), sc.nextInt()
	X := sc.nextIntSlice(N)
	ma := A
	for _, x := range X {
		if ma < x {
			ma = x
		}
	}
	dp := make([][][]int, N+1)
	for j := 0; j <= N; j++ {
		dp[j] = make([][]int, N+1)
		for k := 0; k <= N; k++ {
			dp[j][k] = make([]int, N*ma+1)
		}
	}
	for j := 0; j <= N; j++ {
		for k := 0; k <= N; k++ {
			for s := 0; s <= N*ma; s++ {
				if j == 0 && k == 0 && s == 0 {
					dp[j][k][s] = 1
				} else if j >= 1 && s < X[j-1] {
					dp[j][k][s] = dp[j-1][k][s]
				} else if j >= 1 && k >= 1 && s >= X[j-1] {
					dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[j-1]]
				} else {
					dp[j][k][s] = 0
				}
			}
		}
	}
	ans := 0
	for k := 1; k <= N; k++ {
		ans += dp[N][k][k*A]
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 54528
#include <iostream>
#include<set>
#include<iterator>
#include <algorithm>
using namespace std;

int main() {
    
    int n;
    cin>>n;
    
    set<string> st;
    
    string s;
    cin>>s;
    st.insert(s);
    char ch = s[s.size()-1];
    
    
    for(int i=0;i<n-1;++i)
    {
        cin>>s;
        st.insert(s);
        if(s[0]!=ch)
        {
            cout<<"No";
            return 0;
        }
        ch = s[s.size()-1];
        
        
    }
    
    if(st.size()==n)
        cout<<"Yes";
    else
        cout<<"No";
    
	  
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int x;
	cin>>x;
	if(x==3||x==5||x==7){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt(int x) {
	int num=0;
	while(x>0) {
		num+=x%10;
		x/=10;
	}
	return num;
}
int main() {
	int n,ans=2000000000;
	scanf("%d",&n);
	for(int i=1;i<n;i++) ans=min(ans,cnt(i)+cnt(n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/11/ITP1_11_A
/*
    1        N
  4 2 3 5  W   E
    6        S

    N: 1->5 2->1 6->2 5->6
    S: 1->2 2->6 6->5 5->1  
    E: 1->3 3->6 6->4 4->1
    W: 1->4 4->6 6->3 3->1 
*/

#include <iostream>
#include <cstring>

class dice
{
public:
    dice();
    void GetPips();
    void RollDice();
    void PrintPips();

private:
    int pip[6];
    std::string order;
};

int main()
{
    dice d;
    d.GetPips();
    d.RollDice();
    d.PrintPips();
}

dice::dice() : pip{}
{
}

void dice::GetPips()
{
    for (int i = 0; i < 6; i++)
        std::cin >> pip[i];

    std::cin >> order;
}

void dice::RollDice()
{
    int len = order.length();
    int tmp[6] = {};
    for (int i = 0; i < len; i++)
    {
        switch (order[i])
        {
        case 'N':
        {
            tmp[0] = pip[1];
            tmp[1] = pip[5];
            tmp[2] = pip[2];
            tmp[3] = pip[3];
            tmp[4] = pip[0];
            tmp[5] = pip[4];
            break;
        }
        case 'S':
        {
            tmp[0] = pip[4];
            tmp[1] = pip[0];
            tmp[2] = pip[2];
            tmp[3] = pip[3];
            tmp[4] = pip[5];
            tmp[5] = pip[1];
            break;
        }
        case 'E':
        {
            tmp[0] = pip[3];
            tmp[1] = pip[1];
            tmp[2] = pip[0];
            tmp[3] = pip[5];
            tmp[4] = pip[4];
            tmp[5] = pip[2];
            break;
        }
        case 'W':
        {
            tmp[0] = pip[2];
            tmp[1] = pip[1];
            tmp[2] = pip[5];
            tmp[3] = pip[0];
            tmp[4] = pip[4];
            tmp[5] = pip[3];
            break;
        }
        }
        memcpy(pip, tmp, sizeof(tmp));
    }
}
void dice::PrintPips()
{
    std::cout << pip[0] << std::endl;
}


Measured memory_bytes: 3200
import java.util.*;
class Main{
	public static void main(String[] argv){
		rated();
	}
	static void rated(){
		Scanner sc = new Scanner(System.in);
		int rate = sc.nextInt();
		if (rate<1200){
			System.out.println("ABC");
		}else{
			if(rate<2800){
				System.out.println("ARC");
			}else{
				System.out.println("AGC");
			}
		}
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,C;
  cin>>N>>C;
//メモ
  vector<vector<int>> A(3,vector<int>(C+1,0));
  int CC[C+1][C+1];
  for(int i=1; i<=C; i++){
    for(int j=1; j<=C; j++){
      int c;
      cin>>c;
      CC[i][j]=c;
    }
  }
  int NN[N+1][N+1];
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      int n;
      cin >>n;
      NN[i][j]=n;
    }
  }
  for(int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      if((i+j)%3==0)
        A[0][NN[i][j]]++;
      if((i+j)%3==1)
        A[1][NN[i][j]]++;
      if((i+j)%3==2)
        A[2][NN[i][j]]++;
    }
  }
  int ans=1e9;
  for(int i=1; i<=C; i++){
    for(int j=1; j<=C; j++){
      for(int k=1; k<=C; k++){
        if(i==j || j==k || k==i)
          continue;
        int tmp0=0, tmp1=0, tmp2=0;
        for(int n=1; n<=C; n++){
          tmp0+=CC[n][i]*A[0][n];
          tmp1+=CC[n][j]*A[1][n];
          tmp2+=CC[n][k]*A[2][n];
        }
        ans=min(ans,tmp0+tmp1+tmp2);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1280
/******************************************c++
using System; //Console, IComparable
using System.IO; //StreamWrtier
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>
using System.Reflection; //PropertyInfo[], GetProperties[]
*********************************************/

namespace TempName{
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Reflection;
    using static System.Console;
    using static IOmacro.CInput;
    
    public class CRun{
        private static class gv{
            public static int N;
            public static int[] A;
            public static int[] H;
        }
    
        public void build() {            
            gv.N = _int;
            gv.A = _inta;
            gv.H = new int[gv.N+2]; Array.Clear(gv.H, 0, gv.H.Length);
            foreach (var x in gv.A) gv.H[x]++;
        }
    
        public void solve() {
            var algo = new libcsharp.Math.combination();
            
            long ans = 0;
            
            foreach (int x in gv.H) {
                ans += (x >= 2 ? algo.nCr(x, 2) : 0L);
            }
            
            foreach (var x in gv.A) {
                long ans_buf = ans;
                int H_now = gv.H[x];
                
                ans_buf -= (H_now >= 2 ? (long)(H_now -1) : 0L);
                Console.WriteLine(ans_buf);
            }

            
        }
    }
    class Program { 
        static void Main() { 
            var run = new CRun();
            run.build();
            run.solve();
        } 
    }
}

namespace IOmacro {
    using System; 
    using System.Linq; 
    using System.IO;
    public static class CInput {
        public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput());
        public const char separator = ' ';
        public static string _string{get{return Console.ReadLine();}}
        public static string[] _stringa{get{return (Console.ReadLine().Split(separator));}}
        public static int _int{get{return int.Parse(Console.ReadLine());}}
        public static int[] _inta{get{return Console.ReadLine().Split(separator).Select(int.Parse).ToArray();}}
        public static long _long{get{return long.Parse(Console.ReadLine());}}
        public static long[] _longa{get{return Console.ReadLine().Split(separator).Select(long.Parse).ToArray();}}    
    }
}

namespace libcsharp.Math {
    
    using System;
    public class combination {
        public long nCr(int n, int r) {
            if (n == r || r == 0) return 1L;
            else return fact(n, r)/fact(r, r);
        }
        private long fact(int n, int m) {
            long res = 1;
            for (int i=n-m+1; i<=n; i++) res *= i;
            return res;
        }
    }
}


Measured memory_bytes: 35132
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {

string S;
cin>>S;
long ans=0;
for(long i=0;i<(S.size())/2;i++){
if(S.at(i)!=S.at(S.size()-1-i)){
    ans++;
}
}
cout<<ans<<endl;
}




Measured memory_bytes: 237508
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c)cout << "No" << endl;
  else if(a!=b&&b!=c&&c!=a)cout<<"No"<<endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sws ios_base::sync_with_stdio(false)
#define MOD 1000000007
#define ll long long
#define sd(a) scanf("%d", &a)
#define sd2(a,b) scanf("%d%d", &a, &b)
#define sd3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sld(a) scanf("%lld", &a)
#define sld2(a,b) scanf("%lld%lld", &a, &b)
#define sld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define pd(a) printf("%d", a)
#define pld(a) printf("%lld", a)
#define sp printf(" ")
#define nl printf("\n")
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define clr(a, val) memset((a), (val), sizeof(a))
#define pb push_back
#define endl "\n"
#define mp(a, b) make_pair(a, b)
#define pii pair<int, int>
#define pll pair<long long,long long>
#define xx first
#define yy second
#define mx 100001
ll a[mx];
int main()
{
	sws;
	ll k;cin>>k;
	for(int i=1;i<=k;i++) cin>>a[i];
	ll l=2,r=2;
	int flag=1;
	for(int i=k;i>=1;i--)
	{
		r=(r%a[i]==0)?r:((r/a[i])*a[i]+a[i]);
		if(r>l) flag=0;
		l=(l/a[i])*a[i]+a[i]-1;
	}
	if(flag) printf("%lld %lld\n",r,l);
	else printf("-1\n");
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
  int n,x;
  int i,j,k;
  int c;
 
  while(1){
    scanf("%d%d",&n,&x);
 
    if(n==0&&x==0)
      return 0;
 
    c=0;    
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
    for(k=j+1;k<=n;k++){
      if(i+j+k==x)
        c++;
    }
      }
    }
    printf("%d\n",c);
  }
}

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

using namespace std;

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int Mod = 998244353;

int add(int a, int b) {
  return (a += b) >= Mod ? a - Mod : a;
}

int sub(int a, int b) {
  return (a -= b) < 0 ? a + Mod : a;
}

int mul(int a, int b) {
  return 1ll * a * b % Mod;
}

int fast_pow(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) res = mul(res, a);
  }
  return res;
}

const int N = 2e5 + 10;

int n, pri[N], vis[N], mu[N], tot = 0;
int f[N], g[N];
char x[N], y[N];

void get_prime(int n = N - 1) {
  mu[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!vis[i]) {
      pri[++tot] = i;
      mu[i] = -1;
    }
    for (int j = 1; j <= tot && i * pri[j] <= n; j++) {
      vis[i * pri[j]] = 1;
      if (i % pri[j] == 0) {
        mu[i * pri[j]] = 0;
        break;
      } else {
        mu[i * pri[j]] = -mu[i];
      }
    }
  }
  for (int i = 1; i <= n; i++) if (mu[i] < 0) mu[i] += Mod;
}

int check(int len) {
  int res = 0;
  for (int i = 1; i <= len; i++) y[i] = x[i];
  for (int i = len + 1; i <= n; i++) {
    if (y[i - len] == '0') y[i] = '1';
    else y[i] = '0';
  }
  bool flag = 1;
  for (int i = 1; i <= n; i++) {
    if (y[i] > x[i]) {flag = 0; break;}
    if (y[i] < x[i]) {flag = 1; break;}
  }
  if (flag) res++;
  int bas = 1;
  for (int i = len; i >= 1; i--) {
    if (x[i] == '1') {
      res = add(res, bas);
    }
    bas = mul(bas, 2);
  }
  return res;
} 

int main() {
  get_prime();
  n = read();
  scanf("%s", x + 1);
  for (int i = 1; i <= n; i++) {
    if ((n % i == 0) && ((n / i) & 1)) {
      g[i] = check(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      f[j] = add(f[j], mul(mu[j / i], g[i]));
    }
  }  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if ((n % i == 0) && ((n / i) & 1)) {
      ans = add(ans, mul(f[i], mul(i, 2)));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pii;
typedef pair<double, pair<int, int>> tii;
int n, w;
ll dp[105][100005];
vector<ll> vals;
vector<ll> weights;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> w;
    for (int i = 0; i<n;i++) {
        ll z, x;
        cin >> z >> x;
        vals.pb(x);
        weights.pb(z);
    }
    for (int i = 0; i<=n;i++) {
        for (int j = 0; j<=w ;j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            }
            else if (weights[i-1] <= j) {
                dp[i][j] = max(vals[i-1] + dp[i-1][j-weights[i-1]], dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][w] << "\n";

}


Measured memory_bytes: 80128