akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int f(vector<int> &, int);

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

  vector<int> A(N);
  rep(i,0,N-1) cin >> A[i];

  sort(A.begin(), A.end());

  int imin = 0, imid = A.back() / 2, imax = A.back();
  int ans = A.back();
  while (imin != imid && imid != imax)
  {
    int cnt = f(A, imid);
    if (cnt <= K)
    {
      ans = min(ans, imid);
      imax = imid;
      imid /= 2;
    }
    else
    {
      imin = imid;
      imid = (imin + imax) / 2;
    }
  }

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

int f(vector<int> & v, int len)
{
  int cnt = 0;
  for (auto rit = v.rbegin(); len < *rit; ++rit)
  {
    cnt += (*rit + len - 1) / len - 1;
  }
  return cnt;
}


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

int main() {
#define int long long
    int n,wt;
    cin >> n >> wt;

    int w[n+1],v[n+1];
    int dp[n+1][wt+1];
    for(int i=1;i<=n;i++)
    {
        cin >> w[i] >> v[i];
    }
    for(int i=0;i<=n;i++)
       dp[i][0]=0;
    for(int i=0;i<=wt;i++)
       dp[0][i]=0;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=wt;j++)
        {
            if(j>=w[i])
            {
                dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }

        }
    }
    cout << dp[n][wt] << endl;
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a<b) {
			if(b<c) {
				System.out.printf("%d %d %d\n",a,b,c);
			}else if(a<c) {
				System.out.printf("%d %d %d\n",a,c,b);				
			}else {
				System.out.printf("%d %d %d\n",c,a,b);
				
			}
		}else if(b>c) {
			System.out.printf("%d %d %d\n",c,b,a);
		}else if(a<c) {
			System.out.printf("%d %d %d\n",b,a,c);
		}else {
			System.out.printf("%d %d %d\n",b,c,a);
		}
		sc.close();

	}}


Measured memory_bytes: 26252
num = int(input())
A = list(map(int,input().split(" ")))
chg = 0
for i in range(num):
	for j in range(num-1,i,-1):
		if A[j] < A[j-1]:
			A[j],A[j-1] = A[j-1],A[j]
			chg += 1
print(*A)
print(chg)



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

using namespace std;

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

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;


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

	if(K==1)cout << 0 << endl;
	else cout<<(N-K)<<endl;


	return 0;
}



Measured memory_bytes: 256
import collections


N = int(input())
s = []

for _ in range(N):
    s.append(input())

M = int(input())
t = []

for _ in range(M):
    t.append(input())
    
c = collections.Counter(s).most_common()
d = collections.Counter(t).most_common()


m = 0
for e in c:
    g = e[1]
    for f in d:
        if e[0] == f[0]:
            g -= f[1]
    if g > m:
        m = g
print(m)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>

using namespace std;

int N;
int F[110];
int P[110][12];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        F[i] = 0;
        for (int j = 0; j < 10; j++)
        {
            int x; cin >> x;
            F[i] += (1 << j) * x;
        }
    }
    for (int i = 0; i < N; i++)
        for (int j = 0; j <= 10; j++)
            cin >> P[i][j];

    int nbest = -1e9;
    for (int i = 1; i < 1024; i++)
    {
        int cr = 0;
        for (int j = 0; j < N; j++)
        {
            int x = F[j] & i;
            int c = __builtin_popcount(x);
            cr += P[j][c];
        }
        nbest = max (nbest, cr);
    }
    cout << nbest << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int f(int p,int n){
    if(n%2!=0)n--;
    return min(n,p*2)/2;
}

int main(){
    int n,m;
    cin>>n>>m;
    
    vector<int> num(m,0);
    vector<int> sm(m,0);
    
    map<int,int> mp;
    
    rep(i,n){
        int x;
        cin>>x;
        num[ x%m ]++;
        mp[x]++;
    }
    
    for(auto &e:mp){
        sm[e.first%m]+=e.second/2;
    }
    
    
    
//    rep(i,m)cout<<num[i]<<" ";cout<<endl;
//    rep(i,m)cout<<sm [i]<<" ";cout<<endl;
    
    
    ll ans=0;
    ans+=num[0]/2;
    num[0]-=num[0];
    
    int c=1;

    while(1){
        if(c==m-c){
            ans+=num[c]/2;
            num[c]-=num[c];
            break;
        }
        if(c>m-c)break;
        ans+=min(num[c],num[m-c]);
        int mn = min(num[c],num[m-c]);
        num[c] -=mn;
        num[m-c] -= mn;
        c++;
    }

    rep(i,m){
        if(sm[i]!=0){
            ans+=f(sm[i],num[i]);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1000003;

/*
d==0ならpw(x,n)を求めればいいからO(n logn)
d!=0ならn>=MODの時はx+(n-1)dが0になる時があるのでO(1)
d!=0&&n<MODの時は？愚直に計算したら結局O(Q MOD)で間に合わない
*/
int w[1234567];
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
int g(int a,int n){
  if(a+n-1>=MOD)return 0;
  return w[a+n-1]*pw(w[a-1],MOD-2)%MOD;
}
int f(int x,int d,int n){
  if(d==0)return pw(x,n);
  if(n>=MOD)return 0;
  int D=pw(d,MOD-2);
  int res=pw(d,n);
  res*=g(D*x%MOD,n);
  return res%MOD;
}

signed main(){
  int Q;cin>>Q;
  vector<int> x(Q),d(Q),n(Q);
  w[1]=1;
  for(int i=2;i<=MOD;i++)w[i]=w[i-1]*i%MOD;
  for(int i=0;i<Q;i++)cin>>x[i]>>d[i]>>n[i];
  for(int i=0;i<Q;i++)cout<<f(x[i],d[i],n[i])<<endl;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
string s;

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

    cin >> n >> s;

    int i = 0;
    int j = n - 1;

    int cnt = 0;
    while(i < j) {
        while(i < n && s[i] == 'R')
            i++;
        while(j >= 0 && s[j] == 'W')
            j--;
        if(i >= j) break;
        swap(s[i], s[j]);
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	string str1,str2;
	int N;
	cin>>N;
	cin>>str1;
	cin>>str2;

	
	int answer = INF;
	for(int k = 0; k < N;k++){
	int i = k;
	int j = 0;
	int count = 0;

	while(1){
		if(str1[i] == str2[j]){
			count++;
		}
		else{
			break;
		}
		i++;
		j++;
		if(i >= N){
			break;
		}
	}
	answer = min(answer,2 * N - count);
	}
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<(n);++i)
#define itn int
#define ocut cout
#define ouct cout
int main(){
    int n;
    cin >> n;
    int a[n];
    re(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    re(i,n-1){
        if(a[i]==a[i+1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


Measured memory_bytes: 1024
# もらうDP

n = gets.to_i
h = gets.split.map(&:to_i)
INF = Float::INFINITY
cost = Array.new(n+10){INF}
cost[0] = 0
 
0.upto(n-1) do |i|
  cost[i] = [cost[i], cost[i-1]+(h[i]-h[i-1]).abs].min if i - 1 >= 0
  cost[i] = [cost[i], cost[i-2]+(h[i]-h[i-2]).abs].min if i - 2 >= 0
end
 
#p cost
puts cost[n-1]

Measured memory_bytes: 11404
a=[0]*26
w='abcdefghijklmnopqrstuvwxyz'
try:
    while True:
        s=list(input().upper())
        for i in s:
            if i=='A':
                a[0]+=1
            elif i=='B':
                a[1]+=1
            elif i=='C':
                a[2]+=1
            elif i=='D':
                a[3]+=1
            elif i=='E':
                a[4]+=1
            elif i=='F':
                a[5]+=1
            elif i=='G':
                a[6]+=1
            elif i=='H':
                a[7]+=1
            elif i=='I':
                a[8]+=1
            elif i=='J':
                a[9]+=1
            elif i=='K':
                a[10]+=1
            elif i=='L':
                a[11]+=1
            elif i=='M':
                a[12]+=1
            elif i=='N':
                a[13]+=1
            elif i=='O':
                a[14]+=1
            elif i=='P':
                a[15]+=1
            elif i=='Q':
                a[16]+=1
            elif i=='R':
                a[17]+=1
            elif i=='S':
                a[18]+=1
            elif i=='T':
                a[19]+=1
            elif i=='U':
                a[20]+=1
            elif i=='V':
                a[21]+=1
            elif i=='W':
                a[22]+=1
            elif i=='X':
                a[23]+=1
            elif i=='Y':
                a[24]+=1
            elif i=='Z':
                a[25]+=1 

except EOFError:
    pass

for i in range(26):
    print(w[i:i+1], ':', str(a[i]))

Measured memory_bytes: 7544
nLen = int(input())
items = input().split()
evens = []

for i in items:
  item = int(i)
  if item % 2 == 0:
    evens.append(item)
    
nLenEvens = len(evens)

OKs = []
for i in evens:
  if i%3 == 0 or i%5 == 0:
    OKs.append(i)
    
if nLenEvens == len(OKs):
	print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end() 

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1 << 25;

template<class T>
void chmin (T& a, const T& b) { a = min(a, b); }

template<class T>
void chmax (T& a, const T& b) { a = max(a, b); }


int main() {
    cin.tie();

    int n, k, min = INF;
    cin >> n >> k;

    vi a(n);
    int min_i;
    REP(i, n) {
      cin >> a[i];
      if (a[i] < min) {
        min = a[i];
        min_i = i;
      }
    }

    int ans = (n - 1 + k - 2) / (k - 1);
    cout << ans << endl;
}

Measured memory_bytes: 640
s = input()
if (s[0] == s[1] and s[2] == s[3] and s[0] != s[2]) or (s[0] == s[2] and s[1] == s[3] and s[0] != s[1]) or (s[0] == s[3] and s[1] == s[2] and s[0] != s[1]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
N = int(input())
A = [input() for _ in range(N)]
now = A[0]
Done = set()
Done.add(A[0])
for a in A[1:]:
    if a in Done:
        print('No')
        exit()
    if now[-1] == a[0]:
        now = a
        Done.add(a)
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 62452
#include<bits/stdc++.h>
using namespace std;
long long a[1000000];
int main()
{
long long t=0,n,m,i,j,k,l;
cin>>n;
for(i=0;i<n;i++)
        cin>>a[i];
for(i=0;i<n;i++)
{
   for(j=i+1;j<n;j++)
           t+=a[i]*a[j];
 }

cout<<t<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;
ll are=1000000007;

int main() {
    int n,c;
    cin >> n >> c;
    vector<vector<int>> a(c+1,vector<int>(100001));
    rep(i,c+1){
        rep(j,100001) a.at(i).at(j)=0;
    }
    int s,t,ch;
    rep(i,n){
        cin >> s >> t >> ch;
        a.at(ch).at(s)++;
        a.at(ch).at(t)--;
    }
    rep(i,c+1){
        rep(j,100001) if (a.at(i).at(j)==1) {a.at(i).at(j)=0;a.at(i).at(j-1)++;}
    }
    int ans=0,u=0,k=0;
    
        rep(j,100001) {
            rep(i,c+1){
            u+=a.at(i).at(j);
            
        }
        ans=max(ans,u);
    }
    cout << ans << endl;
}


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

int main()
{
    int i,j,k,m,n;
    char a[55];
    while(cin>>a)
    {
        for(i=0;i<strlen(a)-8;i++)
            cout<<a[i];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (u32, u32) {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  let vec: Vec<u32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
  (vec[0], vec[1])
}

fn main() {
  let (d, n) = input_int_tuple();
  if n != 100 {
    println!("{}", 100u32.pow(d) * n);
  } else {
    println!("{}", 100u32.pow(d) * (n+1));
  }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	}
}

Measured memory_bytes: 17192
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = map(int, input().split())
c = Counter(As)

ans = []
for k in reversed(sorted(c.keys())):
    v = c[k]
    while v >= 2:
        ans.append(k)
        v -= 2
        if len(ans) == 2:
            print(ans[0] * ans[1])
            sys.exit(0)
print(0)


Measured memory_bytes: 26080
def make_divisors(n):
    divisors = []

    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


N = int(input())
A = sorted([int(x) for x in input().split()])

divisors = sorted(set(make_divisors(A[0]) + make_divisors(A[1])), reverse=True)
ans = 1

for divisor in divisors:
    indivisible_count = 0
    for i in range(N):
        if A[i] % divisor != 0:
            indivisible_count += 1

    if indivisible_count <= 1:
        ans = divisor
        break

print(ans)


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

using namespace std;

int main()
{
//    freopen("int.txt","r",stdin);

    int a,c,v;
    while(cin>>a>>c>>v)
    {
        if(a<c&&c<v)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);

  while (in.hasNext()) {
	short n = in.nextShort();
	short[] pre = new short[n];
	short[] now = new short[n];
	short max = 0;
	for (int line = 0; line < n; line++) {
	  String str = in.next();
	  for (int posi = 0; posi < str.length(); posi++) {
		if (str.charAt(posi) == '*') {
		  now[posi] = 0;
		} else {
		  if (posi != 0) {
			now[posi] = ((pre[posi] > pre[posi - 1])
			    || (pre[posi] > now[posi - 1]))
			    ? ((now[posi - 1] < pre[posi - 1])
			        ? now[posi - 1]
			        : pre[posi - 1])
			    : pre[posi];
			now[posi]++;
		  } else {
			now[posi] = 1;
		  }
		}
		max = (max >= now[posi]) ? max : now[posi];
	  }
	  if (line < n - 1) {
		short[] buf = pre;
		pre = now;
		now = buf;
	  } else {
		System.out.println(max);
	  }
	}
  }
}
}

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

int main(){
  int N, K, S;
  cin >> N >> K >> S;

  const int big = 1e9;
  if(S == big){
    for(int i = 0; i < N - K; i++){
      if(i){
        cout << ' ';
      }
      cout << big - 1;
    }
    for(int i = 0; i < K; i++){
      cout << ' ' << big;
    }
    cout << endl;
  }else{
    for(int i = 0; i < K; i++){
      if(i){
        cout << ' ';
      }
      cout << S;
    }
    for(int i = 0; i < N - K; i++){
      cout << ' ' << big;
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 27 20:47:58 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
    
all(nstr.count(c) for c in '753')

ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
#A, B, totAB = zip(*ABT)

"""

N = int(input())

L = [0]*N
L[:] = map(int, input().split())


L.sort()
if L[-1] < sum(L[0:N-1]):
    print("Yes")
else:
    print("No")
    

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

typedef long long ll;
int n;

int main() {
  cin >> n;
  int a[n+1];
  for (int i=0; i<n; i++) cin >> a[i];
  // 和が0になるパターンがめんどくさいからありえる2パターンとも考えた
  ll sum;
  bool flag;
  // 最初がプラスから始まるパターン
  ll ans1 = 0;
  sum = 0;
  flag = true;
  for (int i=0; i<n; i++) {
    sum += a[i];
    if (flag) {
      if (sum <= 0) {
        ans1 += -sum + 1;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        ans1 += sum + 1;
        sum = -1;
      }
    }
    flag = !flag;
  }
  // 最初がマイナスで始まるパターン
  ll ans2 = 0;
  sum = 0;
  flag = false;
  for (int i=0; i<n; i++) {
    sum += a[i];
    if (flag) {
      if (sum <= 0) {
        ans2 += -sum + 1;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        ans2 += sum + 1;
        sum = -1;
      }
    }
    flag = !flag;
  }
  // 2つの答えの小さい方が答え
  cout << min(ans1, ans2) << endl;
  return 0;
}


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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007

typedef long long ll;
int main() {
  int n;
  int max = 0;
  int count = 0;
  cin >> n;
  int in[n];
  rep(i, n) {
    scanf("%d", &in[i]);
  }
  for(int i = 1; i < n; i++) {
    if(in[i] <= in[i-1]) {
      count++;
    } else {
      if(max < count) {
        max = count;
      }
      count = 0;
    }
  }
  if(max < count) {
    max = count;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, w,o , e;
    cin >> h >> w;
    if( h == 1 || w == 1){
        cout << "1\n";
        exit(0);
    }
    e = (w/2);
    if(w & 1) o = e+1 ;
    else o = e;

    o *= (h/2);
    if(h & 1){
        e *= (h/2 + 1);
    }
    else{
        e *=  h/2;
    }
    cout << ( h * w) - (o + e) << "\n";
}


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

bool check(int L, vector<int> &A, int K) {
    int sum = 0;
    for (int a : A) {
        sum += ((a + L - 1) / L) - 1;
        if (sum > K) {
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int low = 1, high = 1E9;
    while (low < high) {
        int mid = (low + high) / 2;
        if (check(mid, A, K)) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    cout << low << '\n';
    return 0;
}

Measured memory_bytes: 3988
import scala.io.{ StdIn => in}

object Main extends App {
  val s = in.readLine
    .replaceAll("eraser","")
    .replaceAll("erase","")
    .replaceAll("dreamer","")
    .replaceAll("dream","")

  val ans = if(s.isEmpty) "YES" else "NO"
  println(ans)
}

Measured memory_bytes: 33548
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    vector<int> b(0);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        for (unsigned long j = b.size(); j <= a[i]; j++)
        {
            b.push_back(0);
        }
        b[a[i]]++;
    }
    bool c = false;
    for (int i = 0; i < b.size(); i++)
    {
        for (int j = b[i]; j > 0; j--)
        {
            if(!c)
            {
                printf("%d", i);
                c = true;
            }
            else
            {
                printf(" %d", i);
            }
        }
    }
    printf("\n");
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  ll a, b, n;
  cin >> a >> b >> n;
  if (n/b >= 1) {
    cout << (a*(b-1)/b) << endl;
  }
  else {
    cout << a*n/b << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
n , l = map(int, input().split())
L = []

for i in range(n):
    L.append(i+l)

if L[0] > 0:
    print(sum(L[1:]))
elif L[0] <=0 and L[-1] >= 0:
    print(sum(L))
else:
    print(sum(L[:-1]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int main(){
    vector<int> p(26,1);string s;
    cin>>s;
    for(char c:s) p[c-'a']^=1;
    bool ans=true;
    for(auto b:p)ans&=b==1;
    cout<<(ans?"Yes":"No")<<endl;
	return 0;
}


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

typedef long long ll;
ll N,M;

bool check(ll tmp,vector<ll> a){
    ll cnt=0;
    for(int i=0;i<N;i++){
        int ind=lower_bound(a.begin(),a.end(),tmp-a[i])-a.begin();
        cnt+=(N-ind);
    }
    if(cnt>M) return true;
    else return false;
}

int main(){
    cin >> N >> M;
    vector<ll> a(N);
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a.begin(),a.end());
    vector<ll> sum(N+1,0);
    for(int i=1;i<=N;i++){
        sum[i]+=sum[i-1]+a[i-1];
    }
    ll right=1e18;
    ll left=0;
    while(right-left>1){
        ll mid=(right+left)/2;
        if(check(mid,a)){
            left=mid;
        }else{
            right=mid;
        }
    }
    //cout << left << " " << right << endl;
    ll ans=0; ll cnt=0;
    for(int i=0;i<N;i++){
        int ind=lower_bound(a.begin(),a.end(),right-a[i])-a.begin();
        cnt+=N-ind;
        ans+=(sum[N]-sum[ind])+a[i]*(N-ind);
    }
    ans+=left*(M-cnt);
    cout << ans << endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define FI first
#define SE second
const int INF = 1001001001;

int N;
int a[1 << 18];
int id[1 << 18];
int sum[100000];

void init(int n)
{
	N = 1;
	while (N < n){
		N <<= 1;
	}
	fill(id, id + (1 << 18), INF);
	for (int i = 0; i < n; i++){
		id[i + N - 1] = i;
	}
}

void update(int i, int x)
{
	i += N - 1;
	a[i] += x;
	while (i > 0){
		i = (i - 1) / 2;
		if (a[i * 2 + 1] >= a[i * 2 + 2]){
			a[i] = a[i * 2 + 1];
			id[i] = id[i * 2 + 1];
		}
		else {
			a[i] = a[i * 2 + 2];
			id[i] = id[i * 2 + 2];
		}
	}
}

int main()
{
	int n, r, l;
	scanf("%d %d %d", &n, &r, &l);
	init(n);
	
	int lastid = 0;
	int lasttime = 0;
	for (int i = 0; i < r; i++){
		int d, t, x;
		scanf("%d %d %d", &d, &t, &x);
		d--;
		update(d, x);
		sum[lastid] += t - lasttime;
		lastid = id[0];
		lasttime = t;
	}
	sum[lastid] += l - lasttime;
	
	int maxi = 0;
	for (int i = 0; i < n; i++){
		if (sum[maxi] < sum[i]){
			maxi = i;
		}
	}
	printf("%d\n", maxi + 1);
	
	return 0;
}

Measured memory_bytes: 3416
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,int> P;
ll INF=pow(10,18);

struct LazySegmentTree{
    int n;
    vec node,lazy;
    
    LazySegmentTree(int N){
        n=1;
        while(n<N)n*=2;
        node.resize(2*n-1,0);
        lazy.resize(2*n-1,0);
    }

    //k番目のノードについて遅延評価
    void eval(int k,int l,int r){
        if(lazy[k]!=0){
            node[k]+=lazy[k];

            if(r-l>1){
                lazy[2*k+1]+=lazy[k]/2;
                lazy[2*k+2]+=lazy[k]/2;
            }
            lazy[k]=0;
        }
    }

    //[a,b)にxを加算、kは区間[l,r)の節点
    void add(int a,int b,ll x,int k,int l,int r){
        eval(k,l,r);

        if(b<=l || r<=a)return;

        if(a<=l && r<=b){
            lazy[k]+=x*(ll)(r-l);
            eval(k,l,r);
        }

        else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }

    //[a,b)の区間和を取得
    ll getsum(int a,int b,int k,int l,int r){
        if(b<=l || r<=a) return 0;

        eval(k,l,r);
        if(a<=l && r<=b) return node[k];
        ll vl=getsum(a,b,2*k+1,l,(l+r)/2);
        ll vr=getsum(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }   
};

int main(){
    int N;ll K; scanf("%d %lld",&N,&K);
    vec a(N+1),S(N+1);S[0]=0;
    vector<P> T(N+1);T[0]={0,0};
    for(int i=1;i<=N;i++){
        scanf("%lld",&a[i]);
        S[i]=S[i-1]+a[i];
        T[i]={S[i]-i*K,i};
    }
    sort(T.begin(),T.end());
    vec U(N+1);
    for(int i=0;i<=N;i++){
        U[T[i].second]=i;
    }
    ll ans=0;
    LazySegmentTree LST(N+1);
    for(int i=0;i<=N;i++){
        ans+=LST.getsum(0,U[i],0,0,LST.n);
        LST.add(U[i],U[i]+1,1,0,0,LST.n);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 16256
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int main()
{
    ll n,K;
    cin>>n>>K;
    ll A[n],i;
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    sort(A,A+n);
    ll ans;
    ll lo=1,hi=A[n-1];
    ll mid;
    while(lo<=hi)
    {
        mid=(lo+hi)/2;
        ll cnt=0;
        for(i=0;i<n;i++)
        {
            if(A[i]>mid)
            {
                ll d=A[i]/mid;
                if(A[i]%mid==0)
                {
                    d--;
                }
                cnt+=d;
            }
        }
        if(cnt<=K)
        {
            ans=mid;
            hi=mid-1;
        }
        else
        {
            lo=mid+1;
        }
    }
    cout<<ans;

}


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

long A,B,K;

int main(){
    cin>>A>>B>>K;

    if(K<A){
        A=A-K;
    }else{
        B=B-(K-A);
        A=0;
    }

    if(B<0){
        B=0;
    }

    cout<<A<<' '<<B;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

//頂点fromから頂点toへのコストcostの辺
template<typename T>
struct edge{
    int f,t;
    T c;
    int id;
    edge(){};
    edge(int f,int t,T c,int id = 0):f(f),t(t),c(c),id(id){};
    bool operator< (const edge &s){
        return c < s.c;
    }
};

template<typename T>
struct graph{
    std::vector<std::vector<edge<T> > > data;
    graph(int v):data(v){};
    void add_edge(edge<T> &e){
        data[e.f].push_back(e);
    }
    void add_edge(int f,int t,T c){
        data[f].emplace_back(f,t,c);
        data[t].emplace_back(t,f,c);
    }
    size_t size(){
        return data.size();
    }
    std::vector<edge<T>> make_edges(){
        std::vector<edge<T>> r;
        for(auto &i:data)std::copy(i.begin(),i.end(),std::back_inserter(r));
        return r;
    }
};
// const int n = 1e5+10;
int is_moved[n_max] = {};
int res[n_max] = {};
template<typename T>
void dfs(graph<T> &g, int pos){
    is_moved[pos] = 1;
    for(auto i : g.data[pos]){
        if(!is_moved[i.t]){
            if(i.c%2 == 0)res[i.t] = res[i.f];
            else if(res[i.f] == 0)res[i.t] = 1;
            else res[i.t] = 0;
            dfs(g, i.t);
        }
    }
}

template<typename T>
void reach(graph<T> &g, int pos){
    is_moved[pos] = 1;
    for(auto i : g.data[pos]){
        if(!is_moved[i.t]){
            reach(g, i.t);
        }
    }
}


int main(){
    int n; cin >> n;
    graph<int> gr(n);
    rep(i,n-1){
        int from,to,cost;cin >> from >> to >> cost;
        from--;to--;
        gr.add_edge(from, to, cost);
    }
    dfs(gr, 0);
    rep(i,n) cout << res[i] << "\n";
    return 0;
}

Measured memory_bytes: 9216
#include<stdio.h>
#include<math.h>

int main()
{
	long long int HP, enemy = 1, total = 1;
	scanf("%lld", &HP);
	while(HP > 1) {
		HP /= 2;
		enemy *= 2;
		total += enemy;
	}
	printf("%lld\n", total);

	return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll m;
vector< vector<int> > g;
vector<ll> L[100005];
vector<ll> R[100005];
ll dp[100005];

ll dfs(int cur, int par) {
	ll& res = dp[cur];
	if (res > 0) return res;

	res = 1;
	L[cur].push_back(1);
	for (int nex : g[cur]) {
		if (nex == par) continue;
		ll tmp = (dfs(nex, cur) + 1) % m;
		(res *= tmp) %= m;
		L[cur].push_back(tmp);
		R[cur].push_back(tmp);
	}
	R[cur].push_back(1);
	int sz = L[cur].size();
	for (int i = 1; i < sz; i++) {
		(L[cur][i] *= L[cur][i - 1]) %= m;
	}

	for (int i = sz - 2; i >= 0; i--) {
		(R[cur][i] *= R[cur][i + 1]) %= m;
	}
	return res;
}

ll dp2[100005];

void dfs2(int cur, ll d_par, int par) {
	if (dp2[cur] > 0) return;
	//cout << cur << " " << d_par << endl;
	dp2[cur] = (d_par + 1) % m;
	for (int i = 0, j = 0; i < g[cur].size(); i++) {
		int nex = g[cur][i];
		if (nex == par) continue;
		(dp2[cur] *= (dp[nex] + 1) % m) %= m;
		//cout << nex << " " << L[cur][j] << " " << R[cur][j + 1] << endl;
		dfs2(nex, L[cur][j] * R[cur][j + 1] % m * (d_par + 1) % m, cur);
		j++;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n >> m;
	
	g.resize(n);
	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	dfs(0, -1);
	dfs2(0, 0, -1);

	for (int i = 0; i < n; i++) {
		cout << dp2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 27264
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
bool comp(tuple<string, int, int> i, tuple<string, int, int> j) {
  if (get<0>(i) != get<0>(j)) {
    return get<0>(i) < get<0>(j);
  }
  return get<1>(i) > get<1>(j);
}
int main()
{
  int n, p;
  string name;
  cin >> n;
  vector<tuple<string, int, int>> vec(n);
  REP(i, n) {
    cin >> name >> p;
    vec[i] = make_tuple(name, p, i+1);
  }
  sort(vec.begin(), vec.end(), comp);
  REP(i, n) {
    cout << get<2>(vec[i]) << endl;
  }
  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define ll  long long int
        #define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
        #define mod 1000000007
        using namespace std;
ll gcd(ll a, ll b){
    if(b==0)
        return a;


        return gcd(b, a%b);

}
ll arr[1000000+1], fact[1000000+1];
bool prime[1000000+1];

        int main()
            {fast;
            ll t =1;
            //cin>>t;

        while(t--){
            ll n;
            cin>>n;

            
            ll ma=0;
            for (int i=0; i<n;i++){
            cin>>arr[i];
            ma=max(arr[i],ma);
            }

       
            memset(prime,false,sizeof(prime));

     
          
            for(int i=0; i<=ma; i++)
                fact[i]=i;
            
            for(int i=2; i<=ma; i++){
                if(fact[i]==i)
                    for(ll j=2*i; j<=ma; j+=i){
                        if(fact[j]==j)
                        fact[j]=i;
                    }
                        
            }
            
    ll p=0;
            for (int i=0; i<n;i++){
             
                ll a=arr[i];
                while(a>1){
                    ll h=fact[a];
                    while(fact[a]==h)
                    a/=fact[a];

                    if(prime[h]==true)
                     {p=1;
                     break;
                     }
                    prime[h]=true;
                }
            }
            if(p==0)
            {cout<<"pairwise coprime";
            return 0;}

            p=0;
            ll a = gcd(arr[0], arr[1]);

           for(int i=0; i<n-1;i++)
            a = gcd(arr[i+1],a);

            if(a==1)
            cout<<"setwise coprime";
            else
            cout<<"not coprime";
            

        }
                return 0;
        }

Measured memory_bytes: 20192
#include<stdio.h>
int main(void)
{
	int a,s,d,f,i,z;
	scanf("%d",&a);
	for(i=1;i<=a;i++){
	z=0;
	scanf("%d %d %d",&s,&d,&f);
		if(s<f&&d<f){
			if(s*s+d*d==f*f){
				z=1;
				printf("YES\n");
			}
		}
		else if(s<d&&f<d){
			if(s*s+f*f==d*d){
				z=1;
				printf("YES\n");
			}
		}
		else if(f<s&&d<s){
			if(d*d+f*f==s*s){
				z=1;
				printf("YES\n");
			}
		}
		if(z==0){
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


const int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

int main(){
	fast;
	
	int n;
	cin>>n;
	
	queue<string>q;
	set<string>v;
	set<string>::iterator it;
	
	q.push("a");
	
	while(!q.empty()){
		string s=q.front();
		q.pop();
		
		if(s.size()==n)
		v.insert(s);
		
		if(s.size()<n){
			int max=-1;
			forr(i,0,s.size()){
				if(s[i]-'a'>max)
				max=s[i]-'a';
			}
			
			forr(i,0,max+2){
				char x=i+'a';
				q.push(s+x);
			}
		}
	}
	
	for(it=v.begin();it!=v.end();++it)
	cout<<*it<<"\n";
	
	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
int arr[200001];
int main(){
  int n;
  cin >> n;
  unordered_map<int, long long> m;
  for(int idx = 0; idx < n; ++idx) cin >> arr[idx], m[arr[idx]]++;
  long long res = 0;
  for(auto& e : m) res += e.second * (e.second - 1) / 2;
  for(int idx = 0; idx < n; ++idx) std::cout << res - m[arr[idx]] + 1 << std::endl;
  return 0;  
}

Measured memory_bytes: 9416
/**
 * 線形探索
 */
fun main(args: Array<String>) {

    Main.init()

    Main.execute()
}

class Main {

    companion object {

        private lateinit var inputs: List<String>

        private lateinit var searchLists: List<String>

        fun init() {

            readLine()

            inputs = readLine()!!.split(" ")

            readLine()

            searchLists = readLine()!!.split(" ")
        }

        fun execute() {
            println(searchLists.count {
                inputs.contains(it)
            })
        }
    }
}




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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  long long n, a, b; cin >> n >> a >> b;
  vector<long long> h(n); for (int i = 0; i < n; i++) cin >> h[i];
  sort(h.begin(), h.end());
  auto f = [&](int x) {
    long long c = 0;
    for (int i = 0; i < n; i++) c += max((h[i] - b * x + (a - b) - 1) / (a - b), 0LL);
    return c <= x;
  };
  int l = 0, r = 1e9;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m)) r = m;
    else l = m;
  }
  cout << r << '\n';
  return 0;
}

Measured memory_bytes: 1024
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math
def inpl(): return list(map(int, input().split()))

#### START
a_1, b_1 = map(int,input().split())
a_2, b_2 = map(int,input().split())
a_3, b_3 = map(int,input().split())

ans = [a_1, b_1, a_2, b_2, a_3, b_3]
c = collections.Counter(ans)
if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2 and c.most_common()[2][1] == 1 and c.most_common()[3][1] == 1:
  print("YES")
else:
  print("NO")
# if N-K>0:
#   print("YES")
# else:
#   print("NO")
# N, K = map(int,input().split())

# ans = math.ceil(N/2)
# if ans>=K:
#   print("YES")
# else:
#   print("NO")


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

using namespace std;

int main() {
  int sum = 0;
  int ma = 0;
  for (int i = 0; i < 5; ++i) {
    int a;
    cin >> a;
    int t = (a + 9) / 10 * 10;
    sum += t;
    ma = max(ma, t - a);
  }
  cout << sum - ma << endl;
}

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

long long int hcf(long long int a, long long int b){
    if(b==0)
        return a;
    else
    return hcf(b,a%b);
}



int main(){
    long long int a, b;
    cin >> a >> b;
    long long int c = max(a,b);
    long long int d = min(a,b);
    long long int ans = ((a*b)/hcf(c,d));
    cout << ans << endl;;
    return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{
   
   
    string s, t;
    

    cin >> s;
    ll ans = 0;
    for (int i = 0; i < s.size(); i++) {
        ans += (s[i] - '0');
    }

    if (ans % 9)cout << "No" << endl;
    else cout << "Yes" << endl;
    
   
    return 0;

}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
  int x;

  REPI(5)
  {
    cin >> x;
    if (x == 0)
    {
      cout << i+1 << endl;    
      return 0;
    }      
  }  
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans = 0;
  int i = 0;
  while (2*i + 1 < N-1) {
    bool check = true;
    for (int j = 0; j <= i; j++) {
      if (S[j] != S[i+j+1]) {
        check = false;
        break;
      }
    }
    if (check) {
      ans = (i+1)*2;
    }
    i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	// "math"
)

func main() {
	var s string
	fmt.Scan(&s)

	// if s == "Sunny" {
	// 	fmt.Println("Cloudy")
	// } else if s == "Cloudy" {
	// 	fmt.Println("Rainy")
	// } else if s == "Rainy" {
	// 	fmt.Println("Sunny")
	// }

	var ans string
	switch s {
	case "Sunny":
		ans = "Cloudy"
	case "Cloudy":
		ans = "Rainy"
	default:
		ans = "Sunny"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 30;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, q;
    string s;
    set<int> alp[MXN];
    cin >> n >> s >> q;
    FOR(i, 0, MXN)
    {
        alp[i].insert(0);
        alp[i].insert(n + 1);
    }
    FOR(i, 0, n) { alp[s[i] - 'a'].insert(i + 1); }
    FOR(i, 0, q)
    {
        int x;
        cin >> x;
        // cout << x << '\n';
        if (x == 2)
        {
            int y, z, ans = 0;
            cin >> y >> z;
            // cout << y << ' ' << z << '\n';
            FOR(j, 0, MXN)
            {

                // cout << j << ' ' << *alp[j].lower_bound(y) << ' '
                //      << k << "\n";
                if (*alp[j].lower_bound(y) <= z)
                {
                    ++ans;
                }
            }
            cout << ans << '\n';
        }
        else
        {
            int y;
            char z;
            cin >> y >> z;
            alp[s[y - 1] - 'a'].erase(y);
            s[y - 1] = z;
            alp[s[y - 1] - 'a'].insert(y);
        }
    }
}


Measured memory_bytes: 24220