akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

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

using namespace std;

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int result=0;

  set<char> l;
  result=0;
  rep(i,n){
    l.insert(s[i]);
    set<char> r;
    rep(j,s.size()-i-1){
      r.insert(s[i+j+1]);
    }

    int tr=0;
    for(auto p:l){
      if(r.count(p)==1)tr++;
    }
    result=max(result, tr);
  }

  cout<<result;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <boost/integer/common_factor_rt.hpp> // gcd, lcm


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

int64_t N, M;
string S, T;
cin >> N >> M >> S >> T;

int64_t g = boost::integer::gcd(N, M),
        l = boost::integer::lcm(N, M);
N /= g, M /= g;
rep(i, 0, g)
    if (S[i * N] != T[i * M]) {
        cout << "-1\n";
        return 0;
    }
cout << l << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 640
n, k = map(int, input().split())
hhh = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    min_tmp = float('inf')
    if i - k >= 0:
        for j in range(i - k, i):
            tmp = dp[j] + abs(hhh[i] - hhh[j])
            min_tmp = min(tmp, min_tmp)
        dp[i] = min_tmp
    else:
        for j in range(i):
            tmp = dp[j] + abs(hhh[i] - hhh[j])
            min_tmp = min(tmp, min_tmp)
        dp[i] = min_tmp
print(dp[-1])

Measured memory_bytes: 55264
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
using u32 = unsigned int; using u64 = unsigned long long int;
template <typename T> using vec = vector<T>;
void in() {}; template <typename T, typename...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); };
template <typename T> void _out(const char *sep, const char *end, T &&x) { cout << x << end; };
template <typename T, typename...TS> void _out(const char *sep, const char *end, T &&x, TS &&...xs) { cout << x << sep; _out(sep, end, move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define put(...) _out("", "", __VA_ARGS__)
#define out(...) _out(" ", "\n", __VA_ARGS__)
#define times(n, i) for (i32 i =  0 ; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

str s;
i32 cnt[24];

bool valid(str s) {
    times(s.size(), si) {
        if (s[si] != s[0]) return false;
    }
    return true;
}

i32 main()
{
    ios::sync_with_stdio(false);
    in(s);

    i32 ans = INT_MAX;
    times(24, ci) {
        char c = 'a'+ci;
        str t = s;
        i32 cnt = 0;
        while (!valid(t)) {
            str tmp = "";
            times(t.size()-1, ti) {
                if (t[ti] == c || t[ti+1] == c) {
                    tmp += c;
                    continue;
                }
                tmp += t[ti];
            }
            t = tmp;
            cnt++;
        }
        ans = min(ans, cnt);
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int pref[100010]; 
int main() {
  int n;
  cin >> n;
  int a, b;
  ll ans = 0;
  rep(i,n) {
    cin >> a >> b;
    pref[i] = a+b;
    ans -= b;
  }
  sort(pref,pref+n,greater<int>());
  for (int i = 0; i < n; i += 2)
  {
    ans += pref[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3976
N = int(input())
Hs = list(map(int, input().split()))

for i in reversed(range(N-1)):
    if Hs[i] - Hs[i+1] >= 2:
        print('No')
        break
    elif Hs[i] - Hs[i+1] == 1:
        Hs[i] -= 1
else:
    print('Yes')


Measured memory_bytes: 14396
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		
		for(int i = n; i < 1000; i++) {
			if(i==111 || i == 222 || i== 333 || i == 444 || i == 555 || i == 666 || i == 777 || i == 888 || i == 999) {
				System.out.println(i);
				return;
			}
			
			
		}
		
		
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
void min_self(int &a, int b)
{
    a = min(a, b);
}
int32_t main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    vector<int> ar(n);
    for (auto &i : ar)
        cin >> i;
    vector<vector<int>> sum(n, vector<int>(n, 0));
    vector<int> prefix(n, 0);
    prefix[0] = ar[0];
    for (int i = 1; i < n; i++)
        prefix[i] = prefix[i - 1] + ar[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            if (i != 0)
                sum[i][j] = prefix[j] - prefix[i - 1];
            else
                sum[i][j] = prefix[j];
        }
    }
    //return 0;
    vector<vector<int>> dp(n, vector<int>(n, 1e15));
    for(int i=n-1;i>=0;i--)
    {
        for(int j=i;j<n;j++)
        {
            if(i==j)
            {
                dp[i][j]=0;
                continue;
            }
            if(i+1==j)
            {
                dp[i][j]=ar[i]+ar[j];
                continue;
            }
            for(int k=i;k<j;k++)
                min_self(dp[i][j],sum[i][j]+dp[i][k]+dp[k+1][j]);
        }
    }
    // for (int i = 0; i < n; i++)
    // {
    //     for (int j = 0; j < n; j++)
    //     {
    //         if(dp[i][j]==1e15)
    //             dp[i][j]=-1;
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    cout << dp[0][n - 1];
    return 0;
}

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

void show(int arr[], int N){
	for(int i=0; i<N; i++)
		if(i<N-1)
			cout<<arr[i]<<' '<<flush;
		else
			cout<<arr[i]<<flush;
	cout<<endl;
}


void swap(int& a, int& b){
	int t=a;
	a=b;
	b=t;
}

int SelectionSort(int*, int);

int main()
{
	int N;
	cin>>N;
	int* arr=new int[N];
	for(int i=0; i<N; i++)
		cin>>arr[i];
	
	int count=SelectionSort(arr, N);
	show(arr, N);
	cout<<count<<endl;

}

int SelectionSort(int* arr, int N){

	int mini,counter=0;
	for(int i=0; i<N-1; i++) {
		mini=i;

		for(int j=i+1; j<N; j++) {

			mini= (arr[mini] > arr[j])? j : mini;

		}

		if(mini != i){
			swap( arr[mini], arr[i] );
			counter++;
		}
		//show(arr, N);
	}
	return counter;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v[100005];
int color[100005];
int cnt[2];
int main(){
	memset(color,-1,sizeof(color));
	cin>>n;
	for(int i=1;i<=n-1;i++){
		int u,w;
		cin>>u>>w;
		v[u].push_back(w);
		v[w].push_back(u);
	}
	queue<int>q;
	color[1]=0;
	color[n]=1;
	q.push(1); q.push(n);
	while(!q.empty()){
		int k=q.front();
		q.pop();
		cnt[color[k]]++;
		for(int i=0;i<v[k].size();i++){
			int x=v[k][i];
			if(color[x]!=-1) continue;
			color[x]=color[k];
			q.push(x);
		}
	}
	if(cnt[1]>=cnt[0]) cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
	return 0;
}

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

int main(){
	int n;
	string s;
	cin>>n;
	getline(cin,s);
	while(n--){
		getline(cin,s);
		string ss=s;
		for(int i=0;i<99;i++){
				for(int j=0;j<26;j++){
					for(int k=0;k<s.size();k++)
						if(s[k]!=' ')ss[k]=((i*s[k]+j)%26)+'a';
					if(ss.find("that")+1||ss.find("this")+1)goto z;
				}
		}
		z:;
		cout<<ss<<endl;
	}
}

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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

const int MAX_N = 2e5 + 1;
const int INF = 1e9;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

int n;

int a[MAX_N];

void eraseFromRight(set<pii> & s, int margin)
{
    while (!s.empty())
    {
        pii it = *s.rbegin();
        if (it.X > margin)
        {
            s.er(it);
        }
        else
        {
            break;
        }
    }
}

set<pii> :: iterator findLetter(set<pii> & s, int pos)
{
    if (s.empty())
    {
        return s.end();
    }
    set<pii> :: iterator it = s.upper_bound(mp(pos, INF));
    if (it == s.begin())
    {
        return s.end();
    }
    else
    {
        it--;
        if (it -> X == pos)
        {
            return it;
        }
        else
        {
            return s.end();
        }
    }
}

bool add(set<pii> & s, int pos, int x)
{
    if (pos == 0)
    {
        return false;
    }
    set<pii> :: iterator it = findLetter(s, pos);
    if (it == s.end())
    {
        if (x == 1)
        {
            return false;
        }
        s.is(mp(pos, 2));
    }
    else if (it -> Y < x)
    {
        pii cur = *it;
        s.er(it);
        cur.Y++;
        s.is(cur);
    }
    else
    {
        s.er(it);
        return add(s, pos - 1, x);
    }
    return true;
}

bool check(int x)
{
    set<pii> s;
    for (int i = 2; i <= n; ++i)
    {

        if (a[i] <= a[i - 1])
        {
            eraseFromRight(s, a[i]);
            bool t = add(s, a[i], x);
            if (!t)
            {
                return false;
            }
        }
    }
    return true;
}

int solve()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    int l = 0;
    int r = MAX_N;
    while (r - l > 1)
    {
        int m = (l + r) / 2;
        if (check(m))
        {
            r = m;
        }
        else
        {
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}




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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() {
  int a, b;
  while (cin >> a >> b) {
    cout << a + (b - a) * 2 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
int h[101];
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<=n;i++) {
			scanf("%d",&h[i]);
		}
		for(int i=0;i<=n;i++) {
			vector<int> v;
			for(int j=0;j<=n;j++) {
				if(i!=j) v.push_back(h[j]);
			}
			int d=v[1]-v[0];
			bool OK=1;
			for(int i=2;i<n;i++) {
				if(v[i]!=v[i-1]+d) {OK=0;break;} 
			}
			if(OK) {printf("%d\n",h[i]);break;}
		}
	}
}

Measured memory_bytes: 1052
#include<cstdio>
#include<cstring>
const int N=3000+10;
int n;
long long f[N][N],a[N];
long long ma(long long a,long long b){return a>b?a:b;}
long long mi(long long a,long long b){return a<b?a:b;}
long long dp(int l,int r,bool ok)
{
	if(~f[l][r])return f[l][r];
	if(l==r)return f[l][r]=ok?a[l]:-a[l];
	if(ok)f[l][r]=ma(dp(l+1,r,!ok)+a[l],dp(l,r-1,!ok)+a[r]);
	else f[l][r]=mi(dp(l+1,r,!ok)-a[l],dp(l,r-1,!ok)-a[r]);
	return f[l][r];
}
int main()
{
	scanf("%d",&n);
	memset(f,-1,sizeof(f));
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	dp(1,n,1);
	printf("%lld",dp(1,n,1));
	return 0;
}


Measured memory_bytes: 71040
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

map<int, int> prime_factor(int n)
{
  map<int, int> mp;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) mp[n] = 1;
  return mp;
}

int main(void)
{
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  ll ans = 0;
  REP(i, n)
  {
    map<int, int> m = prime_factor(a[i]);
    if (m.count(2) > 0) ans += m[2];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long llint;

int main() {
  int k, n;
  cin >> k >> n;
  vector<llint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 2) {
    cout << min(a.back() - a[0], k - (a.back() - a[0])) << endl;
    return 0;
  }
  llint ans = k;
  for (int i = 0; i + 1 < n; i++) {
    ans = min(ans, k - (a[i + 1] - a[i]));
  }
  ans = min(ans, a.back() - a[0]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<map>

using namespace std;

const int MAXN=1e5+1+5;
int N,a[MAXN];
map<int,int> ct;

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

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

        pair<int,int> maxp;
        for (const auto& p : ct)
                if (p.second > maxp.second)
                        maxp = p;

        cout << maxp.second << "\n";
}

Measured memory_bytes: 5120
int tbl[11] = { 0,0,10000,464,100,39,21,13,10,7,6 };

int sb(int a)
{
	int s = 0;
	while (a) {
		s += a % 10;
		a /= 10;
	}
	return s;
}

int main()
{
	int a, n, m;
	int x, y, lim, ans;

	scanf("%d%d%d", &a, &n, &m);
	lim = tbl[n] - a, ans = 0;
	for (y = 1; y <= lim; y++) {
		x = (int)pow(y + a, n);
		if (x > m) {
		    break;
		}
		if (sb(x) == y){
		    ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2104
#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() {
    ll n,ans=0;
    cin >> n;
    for (int i = 1; i < n + 1; i++)
    {
        if(i%3 == 0 || i%5 == 0){

        }else{
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define N_MAX 30
int n;
double dp[N_MAX] = {0.0};
int ans = 0;

int main(){
	
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	
	while(cin >> n){
		if(n == 0){
			break;
		}
		for(int i = 3; i <= n; i++){
			dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
		}
		
		ans = (int)dp[n] / 3650;
		ans++;
		cout << ans << endl;
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll k, s, cnt;
    cnt = 0;
    cin >> k >> s;
    for(int x = 0; x <= k; x++) {
        for(int y = 0; y <= k; y++) {
            int z = s - x - y;
            // cout << x << " " << y << " " << z << endl;
            if(z <= k && z >= 0) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,D,x;
    cin >> r >> D >> x;
    REP(i,10){
        cout << r*x - D << endl;
        x = r * x - D;
    }

}

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

const int mod = 10;
int k;
int ans;

void calc(const int idx, vector<int> rests, const int sum) {
	if(idx == k) {
		ans = sum;
		return;
	}
	if(rests[idx] == 0) {
		calc(idx + 1, rests, sum);
		return;
	}

	const int next_sum = sum + 1;
	if(next_sum >= ans) return;
	const int next_idx = idx + 1;

	calc(next_idx, rests, next_sum);
	for(int i = idx + 1; i < k; ++i) {
		rests[i] = (rests[i] - rests[idx] + mod) % mod;
		calc(next_idx, rests, next_sum);
	}
}

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

	while(cin >> k && k) {
		string initial, unlock;
		cin >> initial >> unlock;

		vector<int> rests(k);
		for(int i = 0; i < k; ++i) {
			rests[i] = (unlock[i] - initial[i] + mod) % mod;
		}

		ans = k;
		calc(0, rests, 0);
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;

long long q[100005];
int ql[100005];
int ptr;
long long res[100005];
map<long long, long long> cnt;

int main(){
    int N, Q;
    scanf("%d%d", &N, &Q);
    ql[ptr++] = 0;
    q[0] = N;
    for(int i=1; i<=Q; i++){
        scanf("%lld", &q[i]);
        while(ptr > 0 && q[ql[ptr-1]] >= q[i]) ql[ptr-1] = 0, ptr--;
        ql[ptr++] = i;
    }
    ptr--;
    cnt[q[Q]] = 1;
    map<long long, long long>::iterator it = cnt.end();
    it--;
    ptr--;
    //printf("%d %d\n", ql[ptr], ptr);
    while(ptr >= 0){
        long long base = q[ql[ptr]];
        while(it->first > q[ql[ptr]]){
            cnt[base] += (it->second) * ((it->first)/base);
            cnt[(it->first)%base] += it->second;
            it->second = 0;
            it--;
        }
        ptr--;
    }
    for(auto ite : cnt){
        //printf("!%lld %lld\n", ite.first, ite.second);
        if(ite.first > N) break;
        res[ite.first] = ite.second;
    }
    for(int i=N; i>=1; i--){
        res[i] += res[i+1];
    }
    for(int i=1; i<=N; i++) printf("%lld\n", res[i]);
    return 0;
}

Measured memory_bytes: 25344
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static List<Integer> sieveOfEratosthenes(int n) {
        if (n < 2) {
            return new ArrayList<>();
        }
        boolean[] isPrime = new boolean[n];
        for (int i = 2; i < n; i++) {
            isPrime[i] = true;
        }
        int sqrt = (int) Math.sqrt(n);
        for (int p = 2; p <= sqrt; p++) {
            if (isPrime[p]) {
                for (int i = p * p; i < n; i += p) {
                    isPrime[i] = false;
                }
            }
        }
        List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (isPrime[i]) {
                ans.add(i);
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = sieveOfEratosthenes(55555);
        List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (ans.size() == n) {
                break;
            }
            if (list.get(i) % 5 == 1) {
                ans.add(list.get(i));
            }
        }
        StringJoiner sj = new StringJoiner(" ");
        for (int i = 0; i < n; i++) {
            sj.add(String.valueOf(ans.get(i)));
        }
        System.out.println(sj);
    }

}


Measured memory_bytes: 36260
#include<stdio.h>


int main(void){
	
	int a,b,y,x;
	
	
	
	scanf("%d %d",&a,&b);
	

    y = a*b;
	x = 2*(a+b);
	
	printf("%d %d\n",y,x);
    
    return 0;
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    int x = (n + a - 1) / a;
    int y = (n + c - 1) / c;
    x *= b;
    y *= d;
    cout << min(x, y) << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int n, m, k;
vi a, b;

bool Read() {
  cin >> n;
  if (cin.eof())
    return 0;
  cin >> m >> k;
  a.resize(n);
  b.resize(m);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  return 1;
}

void Process() {
  vector<ll> psaa(n), psab(m);
  psaa[0] = a[0];
  psab[0] = b[0];
  for (int i = 1; i < n; i++)
    psaa[i] = psaa[i - 1] + a[i];
  for (int i = 1; i < m; i++)
    psab[i] = psab[i - 1] + b[i];
  int i = 0, j = 0;
  while (i < n && psaa[i] <= k)
    i++;
  int ans = i;
  while (i >= 0) {
    const ll t = i ? psaa[i - 1] : 0;
    while (j < m && t + psab[j] <= k)
      j++;
    ans = max(ans, i + j);
    i--;
  }
  cout << ans << "\n";
}

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

  while (Read())
    Process();

  return 0;
}

Measured memory_bytes: 7944
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n ;
    ld d;    
    ll i,ans=0;
    cin>>n>>d;
    for(i=0;i<n;i++)
    {
    	ll x,y;
    	cin>>x>>y;
    	ld dis = sqrt(x*x + y*y);
    	if(dis<=d) ans++;
    	
    }
    cout<<ans;
}

Measured memory_bytes: 3760
import java.util.*;
import java.util.stream.Collector;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();

        for(int i = 0;i < n;i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);
        int a = list.get(list.size()/2-1);
        int b = list.get(list.size()/2);
        System.out.println(b - a);
    }

}



Measured memory_bytes: 61864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
long long n;
cin>>n;
if(n&1)cout<<0;
else{
  ll ans=0;
  for(ll i=5;n/2/i>0;i*=5)ans+=n/2/i;
  cout<<ans;
}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,al[26],c2[100],i,x,fir,sec,fi,j;
	char c[100];
	while(1)	{
		scanf(" %d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			scanf(" %c",&c[i]);
			c2[i]=c[i]-'A';
		}
		for(i=0;i<26;i++)	al[i]=0;
		for(i=0;i<n;i++)	{
			al[c2[i]]++;
			fir=-1;
			for(j=0;j<26;j++)	{
				if(fir<al[j])	{
					fir=al[j];	fi=j;
				}
			}
			sec=-1;
			for(j=0;j<26;j++)	{
				if(sec<al[j] && fi!=j)	{
					sec=al[j];
				}
			}
			if(fir>sec+(n-(i+1)))	break;
		}
		if(i==n)	printf("TIE\n");
		else printf("%c %d\n",fi+'A',i+1);
	}
	return 0;
}


Measured memory_bytes: 2688
N = int(input())
P = list(map(int,input().split()))
ANS = list(range(1,N+1))
count = 0 
dif = list()

for i in range(N):
	if ANS[i] != P[i]:
		count += 1 
		dif.append(P[i])

if count == 0 :
	print('YES')
elif count == 2 :
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define maxn 100+5 
int main()
{
	char s[maxn],t[maxn],a[105]={0};
	scanf("%s%s",&s,&t); 
	int len=strlen(s);
	int k,f=1;
	for(int j=1;j<=len;j++){
		k=1;
		for(int i=0;i<len-1;i++){
			a[k]=s[i];
			k++;
		}
		a[0]=s[len-1];
		strcpy(s,a);
		if(strcmp(a,t)==0){
			f=0;
			break;
		}
	}	
	if(f==0) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var inputInt = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var likeList = Enumerable.Range(1, inputInt[1]).ToList();
            for(int userId = 0;userId < inputInt[0]; userId++)
            {
                var userLike = Console.ReadLine().Split(' ').Skip(1).Select(x => int.Parse(x));
                for(int likeIndex = likeList.Count()-1;likeIndex >= 0; likeIndex--)
                {
                    if (!userLike.Contains(likeList[likeIndex])){
                        likeList.RemoveAt(likeIndex);
                    }
                }
                if (!likeList.Any())
                {
                    Console.WriteLine(0);
                    return;
                }
            }

            Console.WriteLine(likeList.Count());
        }
    }
}


Measured memory_bytes: 13280
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    a,b,c,d = map(int, readline().split())
    print(max(a*c,a*d,b*c,b*d))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();

    int a = sc.nextInt();
    int b = sc.nextInt();

    int ans = 0;

    for(int i = 0; i < n; i++){
      int a2 = sc.nextInt();
      int b2 = sc.nextInt();

      if(a <= a2 && b <= b2){
        ans++;
      }
    }

 
    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>

int main(){
	int i;
	long N, M;
	long *A;

	scanf("%ld %ld", &N, &M);
	A = malloc(M * sizeof(long));

	for(i=0; i<M; i++){
		scanf("%ld", &A[i]);
	}

	for(i=0; i<M; i++){
		N -= A[i];
	}

	if(N<0) printf("-1");
	else printf("%ld", N);

	return 0;
}


Measured memory_bytes: 1804
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int[] P ={0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2};
    int[] Q ={1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3};
    int[] R ={2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4};
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] D = new long[5];
    for (int i = 0; i < N; i++) {
      String name = sc.next();
      if (name.charAt(0) == 'M') D[0]++;
      if (name.charAt(0) == 'A') D[1]++;
      if (name.charAt(0) == 'R') D[2]++;
      if (name.charAt(0) == 'C') D[3]++;
      if (name.charAt(0) == 'H') D[4]++;
    }
    long res = 0;
    for (int d = 0; d < 10; d++) {
      res += D[P[d]] * D[Q[d]] * D[R[d]];
    }

    System.out.println(res);
  }
}


Measured memory_bytes: 47344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,mod=1e9+7;
int n,a[N],vis[N];
vector<int>v;
bool vv[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        int x=a[i];
        for(int j=2;j*j<=x;j++)
        {
            int tot=0;
            while(x%j==0)
            {
                x/=j;tot++;
            }
            if(tot)
            {
                if(!vv[j]) vv[j]=true,v.push_back(j);
            }
            vis[j]=max(vis[j],tot);
        }
        if(x>1)
        {
            vis[x]=max(vis[x],1);
            if(!vv[x]) vv[x]=true,v.push_back(x);
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll res=1;
        for(int j=0;j<v.size();j++)
        {
            int sum=vis[v[j]];
            while(a[i]%v[j]==0)
            {
                a[i]/=v[j];
                sum--;
            }
            res=res*qpow(v[j],sum)%mod;
        }
        ans=(ans+res)%mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 6400
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cstring>
using namespace std;

int main() {

	int h, a, i = 0;

	cin >> h >> a;

	while (h - a > 0) {
		h -= a;
		i++;
	}

	i++;

	cout << i << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 2
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def prime_factor(n):
    res = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            res.append(i)
            n = n//i
    if n != 1:
        res.append(n)
    return res

ans = 0
divisors = make_divisors(N)

if len(divisors) == 0 and N != 1:
    print(1)
    exit()

for i in divisors:
    primes = set(prime_factor(i))
    if len(primes) == 1 and N % i == 0:
        ans += 1
        N /= i
        N = int(N)

print(ans)


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int n ;
	cin >>  n ;
	vector<int> a(n);
	vector<int> b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll can = 0 ;
	ll need = 0 ;
	rep(i,n){
		if(a[i] < b[i]){
			can += (b[i] - a[i]) / 2 ;
		}else{
			need += (a[i] - b[i]) ;
		}

	}
	//debug(can);
	//debug(need);
	if(can >= need) coY();
	else coN();

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,d,ans=0;
    cin >> n >> d;
    while(n>0){
        n-=(2*d+1);
        ans++;
    }
    
    cout << ans;
    
	return 0;
}

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

signed main(){
  int W,H,N;
  cin>>W>>H>>N;
  int XH=W,YH=H,XL=0,YL=0;
  rep(i,N){
    int X,Y,A;
    cin>>X>>Y>>A;
    if(A==1){
      if(XL<=X)XL=X;
    }
    if(A==2){
      if(XH>=X)XH=X;
    }
    if(A==3){
      if(YL<=Y)YL=Y;
    }
    if(A==4){
      if(YH>=Y)YH=Y;
    }
  }
  int ans=(XH-XL)*(YH-YL);
  if(XH-XL<0&&YH-YL<0)ans=0;
  if(ans<0)ans=0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

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

    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == 'A')
            ++a;
        else
            ++b;
    }
    if (a == 3 || b == 3)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
  double a,b,C,S,L,h,R;//R ha radian
  scanf("%lf%lf%lf",&a,&b,&C);
  // 360do ha 2pi radian
  // M_PI ha ensyuuritsu.
  // sin(radian) no youni kaku.
  // sqrt ha heihoukon wo arawasu
  R = C*M_PI/180;
  S = a*b*sin(R)/2;
  L = a + b + sqrt((b*sin(R))*(b*sin(R)) + (a -  b*cos(R))*(a - b*cos(R))) ;
  h = b*sin(R);
  printf("%.16lf\n",S);
  printf("%.16lf\n",L);
  printf("%.16lf\n",h);
  return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll cnt[200010],a[200010];
void MAIN() {
	int n;
	cin>>n;
	rep(i,n)cin>>a[i],cnt[a[i]]++;
	ll ans=0;
	rng(i,1,n) {
		ans+=cnt[i]*(cnt[i]-1)/2;
	}
	rep(i,n) {
		cout<<ans-cnt[a[i]]*(cnt[a[i]]-1)/2+(cnt[a[i]]-1)*(cnt[a[i]]-2)/2<<'\n';
	}
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

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

class Dice {
	array<int, 6> m_faces;

public:
	Dice():
		m_faces( { 1,2,3,4,5,6 } )
	{}

	explicit Dice( const array<int, 6>& f ):
		m_faces( f )
	{}

	int top() const { return m_faces.at( 0 ); }
	int front() const { return m_faces.at( 1 ); }
	int right() const { return m_faces.at( 2 ); }
	int left() const { return m_faces.at( 3 ); }
	int back() const { return m_faces.at( 4 ); }
	int bottom() const { return m_faces.at( 5 ); }

	void roll( char dir ) {
		if( dir == 'N' ) {
			swapFace( 1, 5, 2, 3, 0, 4 );
		}
		else if( dir == 'S' ) {
			swapFace( 4, 0, 2, 3, 5, 1 );
		}
		else if( dir == 'W' ) {
			swapFace( 2, 1, 5, 0, 4, 3 );
		}
		else if( dir == 'E' ) {
			swapFace( 3, 1, 0, 5, 4, 2 );
		}
	}

	void swapFace( int i0, int i1, int i2, int i3, int i4, int i5 ) {
		array<int, 6> f = m_faces;

		m_faces.at( 0 ) = f.at( i0 );
		m_faces.at( 1 ) = f.at( i1 );
		m_faces.at( 2 ) = f.at( i2 );
		m_faces.at( 3 ) = f.at( i3 );
		m_faces.at( 4 ) = f.at( i4 );
		m_faces.at( 5 ) = f.at( i5 );
	}

	bool same( const Dice& d2 ) const {
		Dice d1 = *this;

		for( int i = 0; i < 2; ++i ) {
			for( int j = 0; j < 4; ++j ) {
				for( int k = 0; k < 4; ++k ) {
					if( d1.m_faces == d2.m_faces ) {
						return true;
					}
					d1.roll( 'N' );
				}
				d1.roll( 'W' );
			}
			d1.roll( 'N' );
		}

		return false;
	}
};

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

	vector<Dice> dv;
	string result = "Yes";

	for( int i = 0; i < n; ++i ) {
		array<int, 6> f;
		for( auto& v: f ) { cin >> v; }

		Dice d( f );

		for( auto& v: dv ) {
			if( d.same( v ) ) {
				result = "No";
				break;
			}
		}

		dv.push_back( d );
	}

	cout << result << endl;
}



Measured memory_bytes: 3204
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;
ll N;
const ll MAX_N = 50;
ll a[MAX_N];

bool check() {
  REP(i, N) {
    if(a[i] >= N) return false;
  }
  return true;
}

int main(){
  cin >> N;
  REP(i, N) cin >> a[i];
  ll b[N];
  ll ans = 0;
  while(!check()) {
    ll s = 0;
    REP(i, N) {
      b[i] = a[i] / N;
      s += b[i];
    }
    REP(i, N) {
      a[i] -= (b[i] * N - s + b[i]);
    }
    ans += s;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

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

void Main(){
	int n,k; cin >> n >> k;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	int ans = 1000000000;
	for(int i = 0; i < n - k + 1; i++){
	int a = x[i];
	int b = x[i + k - 1];
	if(a < 0){
		if(b < 0){
			ans = min(ans, -a);
		}else{
			ans = min(ans, min(-a, b) * 2 + max(-a, b));
		}
		}else{
			ans = min(ans, b);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define reg register

char S[4];
char T[4];

int main(){
        scanf("%s%s", S, T);
        int Ans = 0;
        for(reg int i = 0; i < 3; i ++) if(S[i] == T[i]) Ans ++;
        printf("%d\n", Ans);
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int d, t, s;
    cin >> d >> t >> s;
    if (t * s >= d) {
        cout << "Yes\n";
    } else cout << "No\n";
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
  int N,i,ans=0;
  bool flag = 0;
  int H[100000] = { 0 };
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", H + i);
  }
  for (i = 1; i < N; i++) {
    if (H[i - 1] < H[i]) {
      H[i]--;
    }
    else if(H[i-1] != H[i]){
      flag = 1;
      break;
    }
  }
  if (flag) {
    printf("No");
  }
  else {
    printf("Yes");
  }
  return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>d(N);
	int ans = 0;
	for (int i = 0; i < N; i++)cin >> d[i];
	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			ans += d[i] * d[j];
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC161D()
{
	int K;
	cin >> K;
	vi a(1);
	vector<set<ll>> s(1);
	int ct = 0;
	int j = 0;
	for (int i = 1; i < 10; ++i)
	{
		s.back().insert(i);
		++ct;
		if (ct == K)
		{
			cout << i << endl;
			return;
		}
	}
	ll z = 1;
	while (true)
	{
		z *= 10LL;
		s.push_back(set<ll>());
		const auto& t = s[j++];
		for (auto& u : t)
		{
			string xxx = std::to_string(u);

			ll w = xxx.back() - '0';
			if (w > 0)
			{
				ll next = u * 10 + w - 1;
				s.back().insert(next);
				++ct;

				if (ct == K)
				{
					cout << next << endl;
					return;
				}
			}
			ll next = u * 10 + w;
			s.back().insert(next);
			++ct;
			if (ct == K)
			{
				cout << next << endl;
				return;
			}
			if (w < 9)
			{
				ll next = u * 10 + w + 1;
				s.back().insert(next);
				++ct;
				if (ct == K)
				{
					cout << next << endl;
					return;
				}
			}
		}
	}
}

int main()
{
	ABC161D();
	return 0;
}

Measured memory_bytes: 4992