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

using namespace std;

int a[2*100001];
int so[1000002];
int num[1000002];
bool flgs[1000002];
bool anss[1000002];

int ans=0;
bool check(int n,vector<int>& res,int idx,int sum){
    if(idx==res.size()){
        if(num[sum]==0){
            return false;
        }
        if(sum == n && num[sum]==1){
            return false;
        }
        return true;
    }
    bool flg = check(n,res,idx+1,sum);
    if(!flg) flg = check(n,res,idx+1,sum*res[idx]);
    return flg;
}

void soinsu(int n){
    vector<int> res;
    int nn = n;
    for(int a=2;a*a<=n;a++){
        if(n%a!=0)continue;
        while(n%a==0){  
            res.push_back(a);
            n/=a;
        }
    }
    if(n!=1)res.push_back(n);
    //sort(res.begin(),res.end());
    if(flgs[nn]==false){
        flgs[nn]=true;
        anss[nn]=check(nn,res,0,1);
    }

    if(anss[nn]==false){
        ans++;
    }
}

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

    for(int i=1;i<=n;i++){
        cin >> a[i]; 
        num[a[i]]++;
    }

    for(int i=1;i<=n;i++){
        soinsu(a[i]);
    }

    cout << ans << endl;

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)


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

    int A, B, M;
    cin >> A >> B >> M;

    vll a(A);
    vll b(B);

    for (int i=0;i<A;i++) cin >> a[i];
    for (int i=0;i<B;i++) cin >> b[i];


    ll best = a[0] + b[0];
    for (int i=0;i<M;i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;

        best = min(best, a[x] + b[y] - c);
    }

    ll minA = a[0];
    ll minB = b[0];
    for (ll ap : a) minA = min(ap, minA);
    for (ll bp : b) minB = min(bp, minB);

    best = min(best, minA + minB);

    cout << best << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int i,j,n,m,x;
	int a[100][100],b[100];
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(j=0;j<m;j++){
		scanf("%d",&b[j]);
	}
	
	for(i=0;i<n;i++){
		x = 0;
		for(j=0;j<m;j++){
			x += a[i][j] * b[j];
		}
		printf("%d\n",x);
	}
	return 0;
}

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

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

int main(){
    int n;
    cin >> n;
    set<ll> S, D;
    ll qmax = 0;
    rep(i,n){
        ll a;
        cin >> a;
        if(!S.count(a)){
            S.insert(a);
        }else if(D.count(a)){
            chmax(qmax, a);
        }else{
            D.insert(a);
            S.erase(a);
        }
    }

    if(D.size() < 2){
        cout << qmax*qmax << endl;
    }else{
        ll x,y;
        x = *rbegin(D);
        D.erase(x);
        y = *rbegin(D);
        chmax(x,qmax); chmax(y,qmax);
        cout << x*y << endl;
    }

    return 0;
}

Measured memory_bytes: 4992
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  if (x >= 30) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

int main() {

  int ans = 0;
  string S; cin >> S;
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+') {
      ans++;
    }
    else {
      ans--;
    }
  }
  cout << ans << endl;

}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int nai = 0, gai = 0;
    REP(i, n) {
        if(s[i] == 'a') {
            if(nai + gai < a+b) {
                cout << "Yes" << endl;
                nai++;
            } else {
                cout << "No" << endl;
            }
        } else if(s[i] == 'b') {
            if((nai + gai < a+b) && (gai < b)) {
                cout << "Yes" << endl;
                gai++;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int[] num=new int[n];
		for(int i=1;i<n;i++){
			int a=sc.nextInt()-1;
			num[a]++;
		}
		
		for(int nn:num){
			System.out.println(nn);
		}
	}
}

Measured memory_bytes: 60360
n = int(input())
ans = 0
for i in range(1, n+1):
    ans += i*(n-i+1)
for _ in range(n-1):
    u, v = map(int, input().split())
    if u>v:
        u, v = v, u
    ans -= u*(n-v+1)
print(ans)

Measured memory_bytes: 74348
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *p,const void *q){
  return *(int*)p - *(int*)q;
}
int main(){
  int i,n,m,x[100000],xsub[100000],maxi,max=0,sum=0;
  scanf("%d %d",&n,&m );
  for(i=0;i<m;i++){
  scanf("%d",&x[i]);
}
  qsort(x,m,sizeof(int),cmp);

  for(i=0;i<m;i++)
  xsub[i]=abs(x[i+1]-x[i]);

  qsort(xsub,m-1,sizeof(int),cmp);
  for(i=0;i<m-n;i++)
  sum+=xsub[i];

  printf("%d",sum );
}


Measured memory_bytes: 1396
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

typedef vector<int> vi;
typedef vector< vi > vvi;

vector<bool> Prime;
vector<int> PrimeStk;
void initPrime(long num) {
	Prime = vector<bool>(num + 1, true);
	Prime[1] = Prime[0] = false;
	long sq_num = sqrt((double)num);

	for (int i = 0; i < 7; i++) {
		if (i == 1 || i == 6)
			continue;
		for (long j = i; j <= num; j += 7) {
			Prime[j] = false;
		}
	}

	for (long i = 2; i < sq_num; i++) {
		if (Prime[i]) {
			for (long j = i + i; j <= num; j += i) {
				Prime[j] = false;
			}
		}
	}
}
void initPrimeStk(long begin) {
	PrimeStk.clear();
	for (long i = begin; i < Prime.size(); i++) {
		if (Prime[i]) {
			PrimeStk.push_back(i);
		}
	}
}

int main(void) {
	initPrime(310000);
	initPrimeStk(0);

	int N;
	while (cin >> N, N != 1) {
		cout << N << ":";
		for (long i = 0; PrimeStk[i] <= N && i < PrimeStk.size(); i++) {
			if (!(N % PrimeStk[i])) {
				cout << " " << PrimeStk[i];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1420
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;

int main(){
	lld n,a;
	cin>>n>>a;
	vector<lld > v(n);
	for(lld i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.rbegin(),v.rend());
	lld sum=0;
	for(lld i=0;i<min(a,n);i++){
		sum+=v[i];
	}
	cout<<sum;
	
}

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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y;

	n = y - x;

	cout << n*(n+1)/2 - y << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int c = scan.nextInt();
        int sumH = 0;
        int sumV = 0;
        int[][] l = new int[r + 1][c + 1];

        for (int v = 0; v < r; v++) {
            for (int h = 0; h < c; h++) {
                l[v][h] = scan.nextInt();
            }
        }

        for (int v = 0; v < r; v++) {
            for (int h = 0; h < c; h++) {
                sumH += l[v][h];
            }
            l[v][c] = sumH;
            sumH = 0;
        }


        for (int h = 0; h < c +1; h++) {
            for (int v = 0; v < r +1; v++) {
                sumV += l[v][h];
            }
            l[r][h] = sumV;
            sumV = 0;
        }

        for (int v = 0; v < r + 1; v++) {
            for (int h = 0; h < c + 1; h++) {
                System.out.print(h == c ? l[v][h] : l[v][h] + " ");
                
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 41908
#include <stdio.h>


int main(void){

  int min = 1001,max = -1;
  int num;

  scanf("%d",&num);

  int i;
  for(i = 0; i < num;i++){
    int tmp;

    scanf("%d",&tmp);
    if(tmp < min)
      min = tmp;

    if(tmp > max)
      max = tmp;

  }

  printf("%d",max - min);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    unsigned long ulW_D_inact[100][100];    /* 行列Ａの格納用変数 */
    unsigned long ulW_D_act[100];           /* 行列Ｂの格納用変数 */
    unsigned long ulW_D_ans[100];           /* 積の格納用変数 */
    unsigned short row, col;          /* 行列の要素数の格納用変数 */
    unsigned short i, j;              /* ループ変数 */

    /* 配列の初期化 */
    for(i = 0;i < 100;i++){
        for(j = 0;j < 100;j++){
            ulW_D_inact[i][j] = 0;
        }
        ulW_D_act[i] = 0;
        ulW_D_ans[i] = 0;
    }

    /* 行列の要素数の入力 */
    scanf("%d %d", &row, &col);

    /* 行列Ａの入力 */
    for(i = 0;i < row;i++){
        for(j = 0;j < col;j++){
            scanf("%d", &ulW_D_inact[i][j]);
        }
    }

    /* 行列Ｂの入力 */
    for(i = 0;i < col;i++){
        scanf("%d", &ulW_D_act[i]);
    }

    /* ＡとＢの積の計算 */
    for(i = 0;i < row;i++){
        for(j = 0;j < col;j++){
            /* i番目の積の計算 */
            ulW_D_ans[i] += ulW_D_inact[i][j] * ulW_D_act[j];
        }
    }
    /* 積の出力 */
    for(i = 0;i < row;i++){
        /* i番目の積の出力 */
        printf("%d\n", ulW_D_ans[i]);
    }
    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

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

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

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

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}



int main(void)
{
    int r, d, k;
    scanf("%d %d %d", &r, &d, &k);
    for (int i = 0; i < 10; i++)
    {
        k = r * k - d;
        printf("%d\n", k);
    }
    
    
    
    
 
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
	int MAX(int a,int b) {
		return a>b?a:b;
	}
	int MIN(int a,int b) {
		return a<b?a:b;
	}
	int ABS(int a) {
		return a<0?-a:a;
	}
	int GCD(int a,int b) {
		return !b?a:GCD(b,a%b);
	}
	int LCM(int a,int b) {
		return a/GCD(a,b)*b;
	}
	int QSM(int a,int b,int p) {
		int ret=1;
		while (b) {
			if (b&1)
				ret=ret*a%p;
			a=a*a%p;
			b>>=1;
		}
		return ret;
	}
	int ROUND(double a) {
		return a+0.5;
	}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
int n,k;
int change();
int main() {
	cin>>n>>k;
	cout<<change()<<'\n';
	return 0;
}
int change() {
	int ans=0;
	while (n) {
		n/=k;
		ans++;
	}
	return ans;
}

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

int main() {
  char c;
  cin >> c;
  if ('a' <= c && c <= 'z') {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = [0] + list(map(int, input().split())) + [0]
pre = 0
yen = sum(abs(i - j) for i, j in zip(A, A[1:]))
ans = [yen] * N
for i in range(N):
    ans[i] += -abs(A[i] - A[i+1]) - abs(A[i+1] - A[i+2]) + abs(A[i] - A[i+2])
print(*ans, sep='\n')


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


int main() {
  vector<int> A(3) ; 
  cin >> A[0] >> A[1] >> A[2] ;
  sort(A.begin(), A.end()) ; 
  reverse(A.begin() , A.end()) ; 
  
  cout << 10*A[0] + A[1] + A[2] << endl ; 
}


Measured memory_bytes: 3612
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;
typedef long long ll;

int N;
ll A, B, H[100000];

bool ok(ll n) {
  ll cnt = 0;
  REP(i, 0, N) if(H[i] > B * n) {
    cnt += (H[i] - B * n) / (A - B);
    if((H[i] - B * n) % (A - B) != 0) cnt++;
  }
  return cnt <= n;
}

int main(void) {
  cin >> N >> A >> B;
  REP(i, 0, N) cin >> H[i];

  ll l = 0, r = 10000000000LL;
  while(l + 1 < r) {
    ll m = (l + r) / 2;
    if(ok(m)) r = m;
    else l = m;
  }

  cout << r << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        swap(a, b);
    }
    for(int i = 0; i < b; i++){
        cout << a;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

int main() {
  int n;
  string s;
  cin >> n >> s;
  int mx = 0;
  int cnt = 0;
  rep(i, 0, n) {
    cnt += (s[i] == 'I' ? 1 : -1);
    mx = max(mx, cnt);
  }
  cout << mx << endl;
  return 0;
}

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

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

  multiset<int> st{-1};  // 見つからなかったら-INFが出てくる
  for (int i = 0; i < n; i++) {
    cin >> a;
    auto it = --st.lower_bound(a);
    if (*it != -1) st.erase(it);  // 使える色がある
    st.insert(a);
  }

  cout << st.size() - 1 << endl;
}


Measured memory_bytes: 4992
#include <stdio.h>

int a[20][20];
int n;
int cnt;

int fills(int x, int y){
	if(x >= n){
		x -= n;
	}else if(x < 0){
		x += n;
	}
	if(y >= n){
		y -= n;
	}else if(y < 0){
		y += n;
	}
	if(a[x][y] != 0){
		return 1;
	}else{
		a[x][y] = cnt;
		cnt++;
	}
	if(fills(x + 1, y + 1)){
		fills(x + 2, y);
	}

	return 0;
}

int main(void)
{

	scanf("%d",&n);
	while(n != 0){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				a[i][j] = 0;
			}
		}
		cnt = 1;
		fills((n + 1) / 2, (n - 1) / 2);
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(a[i][j] >= 100){
					printf(" %d",a[i][j]);
				}else if(a[i][j] >= 10){
					printf("  %d",a[i][j]);
				}else{
					printf("   %d",a[i][j]);
				}
			}
			printf("\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1032
import java.util.Scanner;

// https://atcoder.jp/contests/abc166/tasks/abc166_D
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		sc.close();

		for (long i = 1L; i * i <= x; i++) {
			if (x % i == 0) {
				//				System.out.println("i："+i);
				for (long a = -220; a <= 220; a++) {
					for (long b = -220; b <= 220; b++) {
						long xx = (long) (Math.pow(a, 5) - Math.pow(b, 5));
						if (xx == x) {
							System.out.println(a + " " + b);
							return;
						}
					}
				}
			}
		}

	}
}


Measured memory_bytes: 27076
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
int main(){	
	ll n;
	string s;
	cin>>n;
	cin>>s;
	ll i=0,cont=0;
	string tar = "ABC";
	while(s[i]){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cont++;
		i++;
	}
	cout<<cont<<"\n";
}

Measured memory_bytes: 3568
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

H, W = mi()
A = [input() for i in range(H)]

dp = dp2(float("inf"), W, H)
dp[0][0] = 1
INF = 10**9+7

for i in range(H):
    for j in range(W):
        if i==0 and j == 0:
            dp[0][0] = 1
            continue
        if A[i][j] == '.':
            dp[i][j] = 0
            if i > 0 and A[i-1][j] == '.':
                dp[i][j] = (dp[i][j] + dp[i-1][j]) % INF
            if j > 0 and A[i][j-1] == '.':
                dp[i][j] = (dp[i][j] + dp[i][j-1]) % INF

print(dp[H-1][W-1])

Measured memory_bytes: 77020
#define NOMINMAX
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

string join(const vector<string>& v, const char* delim = 0) {
	string s;
	if (!v.empty()) {
		s += v[0];
		for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
			if (delim) s += delim;
			s += v[i];
		}
	}
	return s;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

template<typename T>
T bit_count(T N) {
	T cnt = 0;
	while (N) {
		if (N & 1) cnt++;
		N >>= 1;
	}
	return cnt;
}

template<typename T>
void print_vec(ostream& ostream, vector<T> a) {
	rep(i, a.size() - 1) ostream << a[i] << " ";
	ostream << a.back() << endl;
}

template<class T>
T pow_n(T x, T n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

struct Point {
	int y, x;
};

class Solver {
public:
	int H, W;

	bool grid_ok(int y, int x) {
		return 0 <= y && y < H && 0 <= x && x < W;
	}
	
	string s;

	void solve() {
		cin >> s;
		
		int cnt = 0;
		rep(i, 3) {
			if (s[i] == 'o') cnt += 1;
		}
		cout << (7 + cnt) * 100 << endl;
	}

};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}


Measured memory_bytes: 256
function main()
  N,M=map(x->parse(Int,x),split(readline()))
  A=ones(Int,N)
  B=zeros(Int,N)
  B[1]=1
  for s=readlines()
    x,y=map(x->parse(Int,x),split(s))
    A[x]-=1
    A[y]+=1
    if B[x]==1
      B[y]=1
    end
    if A[x]==0
      B[x]=0
    end
  end
  println(+(B...))
end
main()

Measured memory_bytes: 159752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r;
  cin >> r;
  if(r<1200){
    cout << "ABC" << endl;
  }
  else if(1200<=r&&r<2800){
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;

char str[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {

	scanf("%s",str + 1);
	int len = strlen(str + 1);

	ll ans = 0,cnt = 0;
	For(i,1,len) {
		if(str[i] == 'W') ans += cnt;
		else cnt++;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n;
vector<int> G[100010];
int grundy[100010];

void dfs(int s,int par){
    for(int t:G[s]){
        if(t==par) continue;
        dfs(t,s);
        grundy[s]^=(grundy[t]+1);
    }
}

void solve(){
    cin >> n;
    rep(i,n-1){
        int x,y;cin >> x >> y;x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0,-1);
    if(grundy[0]) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <stack>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
const int mxn = 101;
char s[mxn];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long a, b, c, d; cin>>a>>b>>c>>d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << '\n';

	return 0;
}
//comparator function in sorting
//swapping arguments
//missing cases in dp
//dividing in modulo
//Beware of overflow and modulo
//Be mindful of overflow
//s is a matrix but forget
//length of ranges
//working with bit using ull

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    // calculation
    int S = (A*B >= C*D) ? A*B: C*D;
    cout << S << "\n";
    
    return 0;
}


Measured memory_bytes: 256
MOD = 10**9+7
N, K = map(int, input().split())
*A, = map(int, input().split())

allm = True
for a in A:
    if a > 0:
        allm = False
        break

if N == K:
    ans = 1
    for a in A:
        ans = (ans*a) % MOD
    print(ans)
elif allm and K % 2 == 1:
    A.sort()
    A.reverse()
    ans = 1
    for a in A[:K]:
        ans = (ans*a) % MOD
    print(ans)
else:
    p, m = [], []
    for a in A:
        if a > 0:
            p.append(a)
        if a < 0:
            m.append(-a)
    p.sort(key=lambda k: -k)
    m.sort(key=lambda k: -k)

    pi, mi = 0, 0
    ans = 1
    while K > 0:
        if K == 1:
            ans = (ans*p[pi]) % MOD
            break
        elif pi < len(p)-1 or mi < len(m)-1:
            pv, mv = 0, 0
            if pi < len(p)-1:
                pv = p[pi]*p[pi+1]
            if mi < len(m)-1:
                mv = m[mi]*m[mi+1]

            if pv > mv:
                ans = (ans*p[pi]) % MOD
                pi += 1
                K -= 1
            else:
                ans = (ans*mv) % MOD
                mi += 2
                K -= 2
        else:
            ans = 0
            break
    print(ans)


Measured memory_bytes: 116508
def main():
    n = int(input())

    points = [0, 0]

    for i in range(n):
        t, h = input().split(' ')

        points = map(lambda x, y: x+y, points, judge(t, h))

    print("{0[0]} {0[1]}".format(list(points)))

def judge(t, h):
    if t < h:
        return (0, 3)
    elif t > h:
        return (3, 0)

    return (1, 1)

if __name__ == '__main__': main()

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

int main(){
    char X ,Y;
    cin >> X >> Y;
    if(X==Y){
        cout << '=' << endl;
    }
    else if(X<Y){
        cout << '<' << endl;
    }
    else{
        cout << '>' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;

int n, m, K, MOD;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }

inline void updata(int &x, int y) { x = inc(x,y); }

inline int power(int x, int k) {
	int tmp = 1;
	while(k) {
		if(k & 1) tmp = mul(tmp,x);
		x = mul(x,x);
		k >>= 1;
	}
	return tmp;
}

int xs[2][maxn][maxn][maxn], dp[maxn][maxn][maxn][2], fac[maxn], ifac[maxn], C[maxn][maxn];

//inline int C(int n, int m) {
//	if(n < 0 || m < 0 || n < m) return 0;
//	return mul(fac[n],mul(ifac[m],ifac[n - m]));
//}

int main() {
	scanf("%d%d%d%d", &n, &m, &K, &MOD);
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= 100;i ++) fac[i] = mul(fac[i - 1],i);
	ifac[100] = power(fac[100],MOD - 2);
	for(int i = 99;i >= 1;i --) ifac[i] = mul(ifac[i + 1],i + 1);
	C[0][0] = 1;
	for(int i = 1;i <= 100;i ++) {
		C[i][0] = 1;
		for(int j = 1;j <= 100;j ++) C[i][j] = inc(C[i - 1][j],C[i - 1][j - 1]);
	}
	for(int i = 1;i <= K;i ++) {
		for(int j = 0;j <= m;j ++) {
			int now = mul(dec(power(i,m - j),power(i - 1,m - j)),power(K - i + 1,j)), tmp = 1;
			for(int k = 0;k <= n;k ++) {
				xs[0][i][j][k] = tmp;
				tmp = mul(tmp,now);
			}
		}
	}
	for(int i = 1;i <= K;i ++) {
		for(int j = 0;j <= n;j ++) {
			int now = mul(dec(power(K - i + 1,j),power(K - i,j)),power(i,n - j)), tmp = 1;
			for(int k = 0;k <= m;k ++) {
				xs[1][i][j][k] = tmp;
				tmp = mul(tmp,now);
			}
		}
	}
	dp[1][0][0][0] = 1;
	for(int k = 1;k <= K;k ++) {
		for(int i = 0;i <= n;i ++) {
			for(int j = 0;j <= m;j ++) {
        for(int l = 0;l + i <= n;l ++) {
					int now = mul(xs[0][k][j][l],C[n - i][l]);
					updata(dp[k][i + l][j][1],mul(dp[k][i][j][0],now));
				}
				for(int l = 0;l + j <= m;l ++) {
					int now = mul(xs[1][k][i][l],C[m - j][l]);
					updata(dp[k + 1][i][j + l][0],mul(dp[k][i][j][1],now));
				}
			}
		}
	}
	int Ans = dp[K + 1][n][m][0];
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 20608
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

ll N, M;
bool check(ll x) {
    if(M / 2 < x)return false;
    ll s = N + (M - x * 2) / 2;
    return s >= x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while(cin >> N >> M) {
        ll lb = 0, ub = N + M + 1;
        while(ub - lb > 1) {
            ll mid = (lb + ub) / 2;
            (check(mid) ? lb : ub) = mid;
        }
        cout << lb << endl;
    }
}


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

int main() {
    int n;
    int taro = 0, hanako = 0;
    string tarocard, hanakocard;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> tarocard >> hanakocard;
        if(tarocard.compare(hanakocard) == 0) { 
            taro++; 
            hanako++;
        } else if (tarocard.compare(hanakocard) > 0) {
            taro += 3;
        } else {
            hanako += 3;
        }
    }
    cout << taro << " " << hanako << endl;
}


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 4e1 + 5, M = 18, K = 1 << M;

int DP[N][K];

bool Sub(int a, int b) { return (a & b) == a; }

int main() {
 
	sync;
	
	int n, x, y, z; cin >> n >> x >> y >> z;
	int good = 1; good <<= x;
	good++; good <<= y;
	good++; good <<= z;
	DP[0][1] = 1;
	for (int i = 0; i < n; i++) for (int mask = 0; mask < K; mask++) {
		if (!DP[i][mask]) continue;
		for (int j = 1; j <= 10; j++) {
			int newMask = ((mask << j) | 1) & (K - 1);
			if (!Sub(good, newMask)) DP[i + 1][newMask] = (DP[i + 1][newMask] + DP[i][mask]) % MOD;
		}
	}
	int ans = 1;
	for (int i = 0; i < n; i++) ans = 10LL * ans % MOD;
	for (int mask = 0; mask < K; mask++) ans = (ans - DP[n][mask] + MOD) % MOD;
	cout << ans << endl;

	return 0;
}


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

int main(int argc, char const *argv[])
{
   int N;
   cin >> N;
   for(int i = 1; i < 10; i++)
   {
      for (int j = 1;  j < 10 && j <= i;  j++)
      {
         if(i*j == N)
         {
            cout << "Yes" << endl;
            return 0;
         }
      }
   }
   cout << "No" << endl;
   
   return 0;
}

Measured memory_bytes: 256
import sys
import fractions
input = sys.stdin.readline
N = int(input())
list_A = list(map(int, input().split()))
ans = list_A[0]
sum = 0
for i in range(1, N):
  ans = ans * list_A[i] // fractions.gcd(ans, list_A[i])
for a in list_A:
  sum += ans//a
print(sum%(7+10**9))

Measured memory_bytes: 6200
#include <bits/stdc++.h>
#include <limits>
using ll = long long;
constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll LNF = std::numeric_limits<ll>::max() / 2;

using namespace std;

vector<int> make_primes() {
    vector<int> primes;
    vector<bool> is_prime(277776, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < (int)is_prime.size(); i++) {
        if (is_prime[i]) primes.push_back(i);
        for (int j = i*2; j < (int)is_prime.size(); j += i) {
            is_prime[j] = false;
        }
    }
    return primes;
}

int main() {
    auto primes = make_primes();

    int N; cin >> N;

    vector<int> ans(N);
    for (int i = 0, j = 0; i < N && j < (int)primes.size(); j++) {
        assert(primes[j] <= 55555);
        if (primes[j] % 10 == 9) ans[i++] = primes[j];
    }

    copy(ans.begin(), ans.end(), ostream_iterator<int>(cout, " "));
    cout << endl;

    return 0;
}


Measured memory_bytes: 512
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> v(N + 1, 0);
  rep(i, N) {
    int num;
    cin >> num;
    v[num]++;
  }

  sort(v.rbegin(), v.rend());
  int ans = 0;
  rep(i, v.size()) {
    if (K > 0) {
      --K;
      continue;
    }
    ans += v[i];
  }

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

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i<=i##end;++i)
#define DREP(i,st,ed) for(int i=(int)(st),i##end=(int)(ed);i>=i##end;--i)
template<typename T>bool chkmin(T &x,const T &y){return x>y?x=y,1:0;}
template<typename T>bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
template<typename T>T read(){
	T x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
#define read() read<int>()
template<typename T>void write(T x,char c){
	static char t[25];
	static int tlen;
	t[tlen=1]=c;
	if(x<0)putchar('-'),x=-x;
	do t[++tlen]=(x%10)^48;
	while(x/=10);
	while(tlen)putchar(t[tlen--]);
}
#define pb push_back
typedef long long ll;
typedef double lf;
int n,m;
int main(){
	n=read(),m=read();
	ll ans=1ll*n*(n-m);
	REP(i,m+1,n)
		ans-=1ll*m*(n/i)+max(0,min(m-1,n%i));
	write(ans,'\n');
	return 0;
}

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

int x[100010], y[100010];

int main() {
  int N, M;
  cin >> N >> M;
  for (auto i = 0; i < M; i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  bool red[100010];
  int sp[100010];
  fill(red, red+100010, false);
  red[0] = true;
  fill(sp, sp+100010, 1);
  for (auto i = 0; i < M; i++) {
    sp[x[i]]--;
    sp[y[i]]++;
    if (red[x[i]] && (sp[x[i]] > 0)) {
      red[y[i]] = true;
    } else if (red[x[i]] && (sp[x[i]] == 0)) {
      red[y[i]] = true;
      red[x[i]] = false;
    }
  }
  int ans = 0;
  for (auto i = 0; i < N; i++) {
    if (red[i]) {
      ans += 1;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1536
abcd = list(input())
n = len(abcd) - 1 
for i in range(2**n):
    ans = abcd[0]
    for j in range(n):     
        if ((i >> j) & 1):
            ans = ans + "+" + abcd[j+1]
        else:
            ans = ans + "-" + abcd[j+1]
    if eval(ans) == 7:
        print(ans + "=7")
        quit()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456];
int ok[213456];
signed main() {
	int n, a = 0, b = 0, ans = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'A') { a = 1; }
		if (s[h] == 'B') { b = 1; }
	}
	if (a == 1 && b == 1) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define maxn 200010
using namespace std;

int a[maxn], cnt[maxn], mx=0;
LL ans = 0, out = 0;
int main()
{
    int n;
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
        // mx表示输入数组a的最大值
        mx = max(mx, a[i]);
    }
    // 计算所有相同的个数
    for(int i = 1; i <= mx; i++)
    {
        if(cnt[i] >= 2)     ans += (LL)cnt[i] * (cnt[i] - 1) / 2;
    }
    for(int i = 0; i < n; i++)
    {
        out = ans;
        if(cnt[a[i]] >= 2)
        {
            out -= cnt[a[i]] * (cnt[a[i]] - 1) / 2;
            out += (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        }
        cout<<out<<endl;
    }
    return 0;
}

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

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

const int INF = 1e9 + 7;

using namespace std;

class UnionFind {
public:
	vector<pair<ll, ll>> tree;

	UnionFind(int n) : tree(n) {
		rep (i, 0, n) {
			tree[i].first = i;
			tree[i].second = 1;
		}
	}

	int root(int x) {
		if (tree[x].first == x) {
			return x;
		} else {
			int r = root(tree[x].first);
			tree[x].first = r;
			tree[x].second = tree[r].second;
			return r;
		}
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);

		if (rx == ry) {
			return ;
		} else {
			tree[ry].first = rx;
			tree[rx].second += tree[ry].second;
			tree[ry].second = tree[rx].second;
		}
	}
};

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

	int n, m;
	cin >> n >> m;

	vector<int> a(m);
	vector<int> b(m);
	rep (i, 0, m)
		cin >> a[i] >> b[i];

	UnionFind un(n);
	vector<ll> res(m);
	res[m - 1] = (ll)n * ((ll)n - 1) / 2LL;

	for (int i = m - 1; i >= 0; i--) {
		a[i]--;
		b[i]--;
		int min_v = min(a[i], b[i]);
		int max_v = max(a[i], b[i]);

		int rmin = un.root(min_v);
		int rmax = un.root(max_v);
		if (rmin != rmax) {
			ll a = (un.tree[rmin].second + un.tree[rmax].second) * (un.tree[rmin].second + un.tree[rmax].second - 1) / 2;
			ll b = un.tree[rmin].second * (un.tree[rmin].second - 1) / 2;
			ll c = un.tree[rmax].second * (un.tree[rmax].second - 1) / 2;

			if (i > 0)
				res[i - 1] = max(res[i] - (a - (b + c)), 0LL);
		} else {
			if (i > 0)
				res[i - 1] = res[i];
		}

		un.unite(min_v, max_v);
	}


	rep (i, 0, m)
		cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 4480
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
int A,B,C;
  cin>>A>>B>>C;
  if((C-A>-1)&&(B-C>-1)) cout<<"Yes";
  else cout<<"No";
      
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
from collections import deque
from copy import deepcopy

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

def DFS(m):
  t_l=deepcopy(l)
  del t_l[m]

  tree=[[] for j in range(n)]
  for a,b in t_l:
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)

  seen=set()
  seen.add(0)

  dq=deque()
  dq.append(0)

  while dq:
    x=dq.pop()
    for i in tree[x]:
      if i not in seen:
        dq.append(i)
        seen.add(i)

  return seen

ans=0
for i in range(m):
  st=DFS(i)
  if len(st)!=n:
    ans+=1

print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a[5],k;
   // while(1){
        for(int i=0;i<5;i++){
            cin>>a[i];
        }
        cin>>k;
       a[4]-a[0]>k?cout<<":("<<endl:cout<<"Yay!"<<endl;
   // }
    return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

a, b = map(int, raw_input().split())

h = 101
w = 101

grid = [['.' for i in xrange(w)] for j in xrange(h)]

for i in xrange(51, h):
    for j in xrange(1, w):
        grid[i][j] = '#'

cnt = a - 1 # paint white

for i in xrange(52, h, 2):
    for j in xrange(1, w, 2):
        if cnt == 0: break
        grid[i][j] = '.'
        cnt -= 1
        
    if cnt == 0: break

cnt = b - 1 # paint black

for i in xrange(1, h, 2):
    for j in xrange(1, w, 2):
        if cnt == 0: break
        grid[i][j] = '#'
        cnt -= 1
        
    if cnt == 0: break

print(100, 100)
for i in xrange(1, h):
    for j in xrange(1, w):
        print(grid[i][j], end = "")
    print()


Measured memory_bytes: 33768
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main() {
  int m,d,count=0; cin >> m >> d;
  for(int i=1;i<=m;i++) {
    for(int j=1;j<=d;j++) {
    int d1=j%10,d10=j/10;
      if(d1>=2 && d10>=2) {
    int date=d1*d10;
    if(i==date) count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
 int n,i,ans=0;
 cin>>n;
 vector <int>a(n);
 for(i=0;i<n;i++)
 {
     cin>>a[i];
 }
 for(i=1;i<n-1;i++)
 {
     if(a[i-1]<a[i]&&a[i]<a[i+1])
        ans++;
     if(a[i-1]>a[i]&&a[i]>a[i+1])
        ans++;
 }
 cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int a, b; cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    int n;  cin >> n;
    vector<vector<ll>> g(n, vector<ll>(10)), p(n, vector<ll>(11));
    vector<ll> cnt(n, 0LL);
    for(int i=0; i<n; i++)
        for(int j=0; j<10; j++) cin >> g.at(i).at(j);

    for(int i=0; i<n; i++)
        for(int j=0; j<=10; j++) cin >> p.at(i).at(j);
    
    ll ans = -1e+15;
    for(int bit=1; bit<(1<<10); bit++){
        ll sum=0;
        for(int i=0; i<n; i++){
            int chk=0;
            for(int j=0; j<10; j++)
                if(bit&1<<j && g[i][j])    chk += 1; 
                
            sum += p[i][chk];
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#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;
  vector<int> a(n);
  rep(i, n) {
    int x;
    cin >> x;
    x--;
    a[i] = x;
  }
  
  int ans = 0;
  int cnt = 0;
  while(1) {
    if (cnt == 1) {
      cout<<ans<<endl;
      return 0;
    }
    if (ans >= n) {
      cout<<-1<<endl;
      return 0;
    }
    ans++;
    cnt=a[cnt];
  }
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();

        int res = (t / a) * b;
        System.out.println(res);

    }


}


Measured memory_bytes: 21972
//abc060_b.cpp
//Tue Oct 30 21:43:22 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int x = a%b;
	if (x==c){
		cout << "YES" << endl;
	}else {
		int temp = x*2;
		int flag = 0;
		while (temp%b!=x){
			if (temp%b == c){
				cout << "YES" << endl;
				flag = 1;
				break;
			}
			temp += x;
		}
		if (flag == 0){
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[]={0,1,3,6,10,15,21,28,36,45,55};
int main(){
	LL n;scanf("%lld",&n);
	int ans=0;
	for(LL i=2;i*i<=n;i++){
		if(n%i==0){
			int w=0;
			while(n%i==0)w++,n/=i;
			for(int j=10;j;j--)if(w>=a[j]){ans+=j;break;}
		}
	}
	if(n>1)ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3828