akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
    
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long int
    #define ull unsigned long long int
    #define ld long double
    #define sb __builtin_popcount
    #define vi vector<int>
    #define vl vector<ll>
    #define vc vector<char>
    #define ii pair<int, int>
    #define pq priority_queue<ii, vector<ii>, greater<ii>>
    #define vii vector<ii>
    #define viii vector<tuple<ll, ll, ll>>
    #define sz(a) int((a).size())
    #define f(a, b) for (int i = a; i < b; i++)
    #define fr(a, b) for (int i = a - 1; i >= b; i--)
    #define tr(x, m) for (auto x : m)
    #define in(a, b) (b.find(a) != string::npos)
    #define minin(a) *min_element(all(a))
    #define maxin(a) *max_element(all(a))
    #define bs(l, h, k) equal_range(l, h, k);
    #define X first
    #define Y second
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define rall(v) reverse(v.begin(), v.end())
    #define unq(v) v.erase(unique(all(v)), v.end())
    #define el "\n"
    #define mx3(a, b, c) max(max(a, b), c)
    #define S(v) accumulate(all(v), (ll)0)
    #define IP(v1, v2) inner_product(all(v1), v2.begin(), (ll)0)
    
    const long double PI = atan(1.0) * 4.0;
    const ll MOD = 1e9 + 7;
    const ll INF = 1e18;
    const ld EPS = 0.0000001;
    #define N 100005   
        int main() {
            fio;
            ll n;
            cin>>n;
            ll a[n]={0};
            unordered_map<ll,ll> mp;
            ll ans=0;
            for(int i=0;i<n;i++){
                cin>>a[i];
                mp[a[i]]++;
            }
            for(auto x:mp){
                ans += (x.second)*(x.second-1);
            }
            ans/=2;
            ll tmp=0;
            //cout<<ans<<el;
            for(int i=0;i<n;i++){
                 tmp=ans-((mp[a[i]])*(mp[a[i]]-1))/2;
                 tmp+= ((mp[a[i]]-1)*(mp[a[i]]-2))/2;
                 cout<<tmp<<el;
            }
            return 0;
        }


Measured memory_bytes: 9160
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;


int main(){
    cin>>m>>a>>b>>c;
    cout<<max(ll(0),min(a,c)-max(m,b))<<endl;
    
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}

int n;
int main()
{
  cin >>n;
  int dx,dy;
  double dist,dist1;
  for(int i = 0;i < n;i++){
    int px,py;
    px = 0;
    py = 0;
    dist = dist1 = 0;
    int nx = 0;
    int ny = 0;
    while(cin>>dx>>dy,dx||dy){
      nx = dx + nx;
      ny = dy + ny;
     dist = (nx*nx+ny*ny);
     if(dist > dist1){
       px = nx;
       py = ny;
       dist1 = dist;
     }else if(dist==dist1){
       if(nx >px){
	 px = nx;
	 py = ny;
       }
     }
    }
    printf("%d %d\n",px,py);
  }

  return 0;
}

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

#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)

using ll = long long;
#define INF 1e9

int K, T;
vector<int> a;

int main(){ 
  cin >> K >> T;
  a.resize(T);
  REP(i, T){
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int one = 0, two = 0;
  REP(i, T){
    if(one < two){
      one += a[i];
    }
    else{
      two += a[i];
    }
  }
  cout << max(0, abs(one-two)-1) << endl;

  return 0;
}



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

UL buf[9][8][8]={};
UL mask[9]={};
UL ans[8][8];

void put(int x, int y, int k){
 buf[k][x][y]=2;
 for(int xx=0; xx<8; xx++) for(int yy=0; yy<8; yy++){
  if(buf[k][xx][yy]) continue;
  if(xx==x || yy==y || (x+y)==(xx+yy) || (x-y)==(xx-yy))
   buf[k][xx][yy]=1;
 }
}

bool proc(UL k){
 if(k==8){ rep(x,8)rep(y,8) ans[x][y]=buf[8][x][y]; return true; }
 UL y=0; rep(i,8) if(~mask[k] & (1<<i)) y=i;
 mask[k+1] = mask[k] | (1<<y);
 rep(x,8){
  rep(xx,8)rep(yy,8) buf[k+1][xx][yy]=buf[k][xx][yy];
  if(buf[k+1][x][y]) continue;
  put(x,y,k+1);
  if(proc(k+1)) return true;
 }
 return false;
}

int main() {
 mask[0]=0;
 UL K; scanf("%u",&K);
 rep(i,K){
  UL x,y; scanf("%u%u",&y,&x);
  mask[K] |= (1<<y);
  put(x,y,K);
 }
 proc(K);
 rep(y,8){
  rep(x,8) printf((ans[x][y]==2)?"Q":".");
  printf("\n");
 }
 return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
    ll d = c-a-b;
    if(d>=0 && 4*a*b<(d*d)) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
typedef pair<int,int> P;

int gcd(ll a, ll b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(ll a, ll b){
  return a / gcd(a,b) * b;
}

struct Edge{int to, id;};
vector<Edge> g[55];
vector<int> es;

bool dfs(int v, int tv, int p = -1){
  if(v==tv) return true;
  for(Edge e : g[v]){
    if(e.to == p) continue;
    if(dfs(e.to,tv,v)){
      es.push_back(e.id);
      return true;
    }
  }
  return false;
}

int main(){
  int n,m; cin >> n;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--;b--;
    g[a].push_back({b,i});
    g[b].push_back({a,i});
  }
  cin >> m;
  vector<ll> eset(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    es = vector<int>(); 
    dfs(a,b);//a-b間のパスを取得
    for(int e:es){
      eset[i] |= 1LL<<e;//eset[i]で集合を管理
    }
  }
  
  ll ans = 0;
  rep(i,1<<m){ //全組み合わせをループ
    ll mask = 0;
    rep(j,m){
      if (i>>j&1) mask |= eset[j]; //jビット目が立っているかどうか。立っていたらmaskに追加。
    }
    int white = __builtin_popcountll(mask);//白く塗る辺がいくつあるか。
    ll now = 1LL << (n-1-white);//NGのパターンがいくつあるか。（自由に塗れる辺の数 x 2乗）
    if (__builtin_popcountll(i)%2 == 0) ans += now; //包含原理。集合が偶数なら足す
    else ans -= now;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
char s[100007];
int get[128];
int main()
{
    get['b'] = 0 , get['p'] = 1 , get['d'] = 2 , get['q'] = 3;
    scanf("%s",s+1);
    for(int l = strlen(s+1), i = 1; i <= (l>>1) + 1; ++i)
    {
        if(get[s[i]]^((get[s[l-i+1]]+2)%4)) return printf("No\n"),0;
    } 
    return printf("Yes\n"),0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int n, k;
  readf("%d %d\n", &n, &k);
  auto s = readln.chomp.to!(char[]);
  s[k-1] = std.ascii.toLower(s[k-1]);
  s.writeln;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a, b, c[1010];
vi e[1010];

bool rec(int v, int co) {
	c[v] = co;
	rep(i,e[v].size()) {
		if (c[e[v][i]]==co) return 0;
		if (c[e[v][i]]==0 && !rec(e[v][i],-co)) return 0;
	}
	return 1;
}

signed main() {
	while (1) {
		cin >> n >> m;
		if (n==0) break;
		rep(i,n) e[i].clear();
		rep(i,m) {
			cin >> a >> b;
			a--, b--;
			e[a].pb(b), e[b].pb(a);
		}
		zero(c);
		bool ng = 0;
		rep(i,n) if (c[i]==0 && !rec(i,1)) ng = 1;
		if (ng) cout << 0 << ln;
		else {
			a = b = 0;
			rep(i,n) (c[i]==1 ? a : b)++;
			vi res;
			if (a%2==0) res.pb(a/2);
			if (b%2==0) res.pb(b/2);
			unq(res);
			cout << res.size() << ln;
			rep(i,res.size()) cout << res[i] << ln;
		}
	}
}


Measured memory_bytes: 3320
a=[]
i=0
while True:
    
    N=int(input())
    if N==0:
        break
    else:
        for i in range(N):
            n=int(input())
            a.append(n)
        a.sort()
        a.pop()     
        a.pop(0)    
        print(sum(a) // len(a))
        a.clear()
            


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll dp[1010][10010]={};

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  ll n;cin>>n;
  V<PL> fs(n);
  V<ll> w(n),s(n),v(n);
  rep(i,0,n){
    cin>>w[i]>>s[i]>>v[i];
    fs[i]=mp(w[i]+s[i],i);
  }

  sort(all(fs));

  rep(i,0,n){
    int ind=fs[i].sc;
    rep(j,0,10005){
      if(j<=s[ind])chmax(dp[i+1][min(10004ll,j+w[ind])],dp[i][j]+v[ind]);
      chmax(dp[i+1][j],dp[i][j]);
    }
  }

  ll ans=0;
  rep(i,0,10005){
    chmax(ans,dp[n][i]);
  }
  cout<<ans<<ENDL;

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 76928
n = int(input())
h_list = list(map(int, input().split()))
ans = 0
while True:
    start = 0
    if all([h == 0 for h in h_list]):
        break
    while h_list[start] == 0:
        start += 1
    end = start
    for i in range(start, n):
        if h_list[i] == 0:
            end = i - 1
            break
    else:
        end = n - 1
    mi = min(h_list[start:end + 1])
    for i in range(start, end + 1):
        h_list[i] -= mi
    ans += mi
print(ans)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    ll dp[n + 1][n + 1];
    for (int i = 0; i <= n; i++) dp[i][i] = 0;

    for (int len = 1; len <= n; len++) {
        for (int i = 0; i <= n - len; i++) {
            int j = i + len;
            if ((n - len) % 2 == 0) {
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
            } else {
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
            }
        }
    }

    cout << dp[0][n] << endl;
    return 0;
}

Measured memory_bytes: 70528
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
	ll a,b,n;
	cin >> a >> b >> n;
	for (ll i = 0; i <n; i++) {
		if (i%2 != 1) {
			if (a % 2 == 0) {
				b += a / 2;
				a /= 2;
			}
			else {
				a--;
				b += a / 2;
				a /= 2;
			}
		}
		else if(i%2==1) {
			//cout << "work" << endl;
			if (b % 2 == 0) {
				a += b / 2;
				b /= 2;
			}
			else {
				b--;
				a += b / 2;
				b /= 2;
			}
		}
		//cout << a << " " << n%2<< endl;
	}

	cout << a << " " << b << endl;

}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> Box(N, 1);
    vector<bool> Red(N, false);
    Red[0] = true;
    while (M--) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        Red[y] = Red[y] || Red[x];
        if (Box[x] <= 1) Red[x] = false;
        --Box[x];
        ++Box[y];
    }
    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (Red[i]) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
import numpy as np
from collections import defaultdict

N,K = map(int,input().split())
A = [0] + [int(i)-1 for i in input().split()]
Acum = np.cumsum(A)
Acum = [i%K for i in Acum]

counter = defaultdict(int)
answer = 0
for i,x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i-K+1 >= 0:
        counter[Acum[i-K+1]] -= 1
  
print(answer)

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  LL h,w;
  cin >> h >> w;
  vector<pair<LL,int>> p(h+w);
  int a;
  for(int i=0;i<h;i++){
    cin >> a;
    p[i]={a,0};
  }
  for(int i=0;i<w;i++){
    cin >> a;
    p[h+i]={a,1};
  }
  sort(all(p));
  LL ans=0;
  LL nh=h,nw=w;
  for(int i=0;i<h+w;i++){
    if(p[i].second){
      ans+=nh*p[i].first;
      nw--;
    }else{
      ans+=nw*p[i].first;
      nh--;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
int n;
int h;
pair<int,int> a[1000009];
vector<pair<int,pair<int,int> > > v;
int vis[100009];
long long ans=0;
int main()
{
    cin>>n>>h;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    v.push_back(make_pair(a[i].first,make_pair(1,i)));
    v.push_back(make_pair(a[i].second,make_pair(2,i)));
    }
    sort(v.begin(),v.end());
    for(int i=v.size()-1;i>=0;i--)
    {
        int x=v[i].first;
        int is=v[i].second.first;
        int idx=v[i].second.second;
        if(is==2){
            h=h-x;
            ans++;
        }
        else
        {
            if(h%x==0)
                ans=(long long)ans+h/x;
            else ans=(long long)ans+h/x+1;
        h=0;
        }
        if(h<=0)break;
    }
    cout<<ans;
}


Measured memory_bytes: 5492
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int hoge[1000] = {};
int main() {
	int n, k;
	cin >> n >> k;
	REP(i, n) {
		string tmp;
		cin >> tmp;
		hoge[(int)tmp[0]]++;
	}
	vector<int> wow;
	for (int i = 'A';i <= 'Z';++i) {
		if (hoge[i] != 0) wow.push_back(hoge[i]);
	}
	sort(wow.begin(), wow.end());
	for (int i = 0;i >= 0;++i) {
		int can_go = k;
		for (int q = wow.size()-1;q >= 0;--q) {
			if (wow[q] != 0) {
				wow[q]--;
				can_go--;
				if (can_go == 0) goto ok;
			}
		}
		cout << i << endl;
		return 0;
	ok:;
		sort(wow.begin(), wow.end());
	}
}

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

using namespace std;
#define ll long long
#define ld long double
const int N = 1e6 + 5;
int f[N], a[N];
bool get(int x) {
    for(int i = 1 ; i * i <= x ; i++) {
        if (x % i) continue;
        if (!f[i] && !f[x / i]) continue;
        if (x / i == i) {
            return 1;
        } else {
           return 1;
        }
    }
    return 0;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n ;
    cin >> n;
    for(int i = 1 ; i <= n ; i++) {
        cin >> a[i];
        f[a[i]]++;
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++) {
        f[a[i]]--;
        ans += !get(a[i]);
        f[a[i]]++;
    }
    cout << ans;
    return 0;
}


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

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

    ll A[N];
    for(ll i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        A[tmp - 1] = i + 1;
    }

    for(ll i = 0; i < N; i++) {
        cout << A[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 4368
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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


int main(){
    
    int tmp,pre;
    int n;
    cin >> n;
    vector<int> g(n);
    
    cin >> pre;
    for(int i=1;i<n;i++){
        cin >> tmp;
        if(pre < tmp) g[i]=1;
        else if(pre == tmp) g[i]=0;
        else g[i] = -1;
        pre = tmp;
    }
    int cnt=0;
    for(int i=2;i<n;i++){
        if(g[i-1]*g[i]==1) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}


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

int N,M;
int G[15][15];

int dp[15][(1<<15)];
int INF=2e9;

int calc(int bit,int nbit){
  int sum=0;
  for(int i=0;i<N;i++)
    if(nbit>>i&1)
      for(int j=0;j<N;j++)
        if(~bit>>j&1)
          if(~nbit>>j&1)
            sum+=G[i][j];
  return sum;
}



int rec(int pos,int bit){
  static unordered_map< int , int > mem[15];
  if( mem[pos].count(bit) )return mem[pos][bit];
  
  if(pos==N-1)return 0;
  int res=INF;

  int sup=(1<<(N-1))-1-bit;
  
  int nbit=sup;
  while(1){

    if(nbit>>pos&1){
      int cost=calc(bit,nbit);
      for(int to=0;to<N;to++){
        if(bit>>to&1)continue;
        if(nbit>>to&1)continue;
        if(G[pos][to]==0)continue;
        res=min(res, rec(to,bit|nbit) + cost - G[pos][to]);
      }
    }
    nbit--;
    nbit&=sup;
    if(nbit==0)break;
  }
  return mem[pos][bit]=res;
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    G[a][b]=G[b][a]=c;
  }
  cout<< rec(0,0) <<endl;
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;
int gcm(int a, int b) {
	int tmp;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	while (1) {
		tmp = a % b;
		if (tmp ==0) {
			break;
		}
		else {
			a = b;
			b = tmp;
		}
	}

	return b;
}

int gcm3(int a, int b, int c) {
	return gcm(gcm(a, b), c);
}

int main() {
	int i, j, k, n;
	long long sum = 0;
	cin >> n;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			for (k = 1; k <= n; k++) {
				sum += gcm3(i, j, k);
			}
		}
	}

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 3168
#include <stdio.h> 
int main(void){    
int a;    
int b;    
int z;    
int min;    
int max;    
long int sum;    
min = 1000000;   
max = -1000000;     
sum = 0;     
scanf("%d",&a);     
for(b=0; b<a; b++)    
{        
scanf("%d",&z);                 
if(min > z)        {            
min = z;        
}        
if(max < z)        
{            
max =z;        
}        
sum = sum + z;    
}         
printf("%d %d %ld\n",min,max,sum);     
return 0;
}

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

int main() {
  int a,b;
  cin >> a>>b;
  int x = max(a,b);
  if(x > 8)cout << ":(" << endl;
  else cout << "Yay!" << endl;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  
  int n = 0;

  for(int i = a;i<=b;i++){
    if(i < 0)
      n++;
    if(i == 0){
      cout<<"Zero"<<endl;
      return 0;
    }
  }
  if(n %2 == 0)
    cout<<"Positive"<<endl;
  else
    cout<<"Negative"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    double n,d;
    cin >>n>>d;
    int ko = 0;
    for(int i = 0;i<n;i++){
      long x,y;
      cin >>x>>y;
      double k = pow(x*x+y*y,0.5);
      if(k<=d) ko++;
    }
 	cout<<ko;
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n,m; cin >> n >> m;
  if(n == 1){
    std::cout << m << '\n';
    return 0;
  }
  int ans = 0;
  for (int i = 1; i*i <= m; i++) {
    if(m%i != 0) continue;
    if(i <= (m-1)/(n-1)) chmax(ans, i);
    if(m/i <= (m-1)/(n-1)) chmax(ans, m/i);
  }

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


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

int main () {
  int x, y;
  while (true) {
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x < y) cout << x << " " << y << endl;
    else cout << y << " " << x << endl;
  }
  return 0;
}


Measured memory_bytes: 3004
#include <stdio.h>
int main(){
  int x, y, m, n, d;
  scanf("%d %d", &x, &y);
 
  if(x>y) {m=x; n=y;}
  else if(x<y) {m=y; n=x;}
  else d=x;

  do {
    d=m%n;
    m=n; n=d;
  }while (d != 0);

  printf("%d\n",m);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include<vector>
#include<string>

#define MAX_N 50
#define T 1
#define F 0

using namespace std;

int N;
vector< string > port(MAX_N);
vector <int> ans;

int isBoin(char a){
    if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o'){
        return 1;
    }else{
        return 0;
    }
}

int hikaku(string s1,string s2,int n){

    for(int i=0;i<n;i++){
        if(s1[i]!=s2[i]){
            return F;
        }
    }

    return T;
}

int main(){

    while(1){
        cin >> N;
        cin.ignore();

        if(N == 0){
            break;
        }

        for(int i=0;i<N;i++){
            cin >> port[i];
            cin.ignore();
        }
/*
        cout << "-------------" << endl;
        for(int i=0;i<N;i++){
            cout << port[i] << ",";
        }
        cout << endl;
        cout << "-------------" << endl;
*/
        int maxlen = 0;
        vector<string> cord(N);
        for(int i=0;i<N;i++){
            string cordsingle;
            for(int j =0;j<port[i].size();j++){
                if(j==0){
                    cordsingle+=port[i][j];
                }else{
                    if(isBoin(port[i][j-1])==T){
                        cordsingle+=port[i][j];
                    }
                }
            }
            if(maxlen < cordsingle.size()){
                maxlen = cordsingle.size();
            }
            cord[i] = cordsingle;
        }

/*
        cout << "-------------" << endl;
        for(int i=0;i<N;i++){
            cout << cord[i] << endl;
        }
        cout << endl;
        cout << "-------------" << endl;
*/
        for(int i=0;i<N;i++){
            //cout << "cord[" << i << "]:" << cord[i].size() << endl;
            //cout << maxlen - cord[i].size() << endl;
            int len = cord[i].size();
            for(int j=0;j<maxlen-len;j++){
                //cout << j << endl;
                cord[i] += '*';
            }
            //cout << cord[i] << endl;
        }

/*
        cout << maxlen << endl;
        cout << "-------------" << endl;
        for(int i=0;i<N;i++){
            cout << cord[i] << endl;
        }
        cout << endl;
        cout << "-------------" << endl;
*/

        int mini = 0;
        int count = 0;
        for(int i=1;i<=maxlen;i++){
            count = 0;
            for(int j=0;j<N;j++){
                for(int k=0;k<N;k++){
                    if(j!=k){
                        count += hikaku(cord[j],cord[k],i);
                    }
                }
            }
            if(count == 0){
                mini = i;
                break;
            }
        }

        if(mini == 0){
            mini = -1;
        }

        ans.push_back(mini);

    }

    for(int i=0;i<ans.size();i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int n;
	int a;
	int i;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(a%2==0){
			if(a%3!=0&&a%5!=0){
				printf("DENIED");
				exit(0);
			}
		}
	}
	printf("APPROVED");
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
using namespace std;
 int main()
 {
 	 int R,G,s;
 	 printf("\n");
  	 while(scanf(" %d%d",&R,&G)!=EOF)
	 {
	 	 s = (2 * G) - R;
	 	 printf("%d",s);
	 }
	 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class Match {

    multiset<ll> l, r;


public:
    void add(P p) {
        this->l.insert(p.first);
        this->r.insert(p.second);
    }

    ll point() {
        auto itl = l.end();
        itl--;
        ll lr = *itl;
        auto itr = r.begin();
        ll rl = *itr;

        return max<ll>(rl - lr + 1, 0);
    }

    void pop(P p) {
        l.erase(l.find(p.first));
        r.erase(r.find(p.second));
    }


};

int main() {
    int n;
    cin >> n;
    vector<P> v(n);
    for (P &p:v)cin >> p.first >> p.second;

    ll ans_one = [&] {
        Match a, b;
        rep(i, n) {
            b.add(v[i]);
        }

        ll ans = 0;
        rep(i, n) {
            b.pop(v[i]);
            a.add(v[i]);

            ll now = b.point() + a.point();
            cmax(ans, now);

            a.pop(v[i]);
            b.add(v[i]);
        }
        return ans;
    }();

    ll ans_split = [&]() -> ll {

        sort(v.begin(), v.end(), [](P p1, P p2) {
            return p1.second < p2.second;
        });

        Match a, b;
        for (P p : v) b.add(p);
        ll ans = 0;
        rep(i, n - 1) {
            P p = v[i];
            a.add(p);
            b.pop(p);
            ll now = a.point() + b.point();
            cmax(ans, now);
        }
        return ans;
    }();

    ll ans = max(ans_split, ans_one);

    cout << ans << endl;

}


Measured memory_bytes: 14088
/*
  Code By RyeCatcher
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <cmath>
#include <utility>
#define ri register int
#define ll long long
#define ull unsigned long long
#define pb push_back
#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define SIZE 23333
using std::min;
using std::max;
using std::pair;
using std::queue;
using std::priority_queue;
using std::vector;
inline char gc(){
    static char buf[SIZE],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;
    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;
}
const int maxn=100155;
const int size=100150;
const int inf=0x7fffffff;
const ll P=1e9+7;
int n,m;
int c[maxn],tot=0;
ll fac[maxn],inv_fac[maxn];
ll C(int n,int m){
	return fac[m]*inv_fac[n]%P*inv_fac[m-n]%P;
}
ll ksm(ll a){
	ll ans=1;
	ll c=P-2;
	while(c){
		if(c&1)ans=ans*a%P;
		a=a*a%P;
		c=c>>1;
	}
	return ans%P;
}
int main(){
	int x,y,M;
	read(n),read(m);
	M=m;
	for(ri i=2;i*i<=M;i++){
		if(M%i==0){
			c[++tot]=1;
			M/=i;
			while(M%i==0){M/=i;c[tot]++;}
		}
	}
	if(M>1)c[++tot]=1;
	fac[0]=fac[1]=1;
	for(ri i=2;i<=size;i++)
		fac[i]=fac[i-1]*i%P;
	inv_fac[size]=ksm(fac[size]);
	for(ri i=size-1;i>=0;i--)
		inv_fac[i]=inv_fac[i+1]*1ll*(i+1)%P;
	ll ans=1;
	for(ri i=1;i<=tot;i++){
		ans=ans*C(n-1,n+c[i]-1)%P;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

int main(){
    int n, j;
    int a[3];
    cin >> n;
    REP(i, n){
        cin >> a[0] >> a[1] >> a[2];
        sort(a, a+3);
        if(a[0]*a[0] +a[1]*a[1]==a[2]*a[2])
            printf("YES\n");
        else
            printf("NO\n");
    }
}

Measured memory_bytes: 3024
#include<iostream>
#include<algorithm>
using namespace std;
int i, j, n, a[100],v[100],l=0;
bool keisan(int,int);
int main() {
	int n,ans;
	bool bo;
	cin >> n;
	for (int i = 3; i <= n; i++) {
		bo=keisan(n,i);
		if (bo == true) {
			cout <<" "<< i;
		}
		else if (bo == false) {
			continue;
		}
	}
	cout << endl;
	return 0;
}
bool keisan(int n,int i) {
	int l,count=0,amari,last;
	while (1) {
		if (count == 0) {
			amari = i % 3;
		}
		last = i % 10;
		if (amari == 0 || last==3 || i == 3) {
			return true;
		}
		else if (amari != 0 && count==5) {
			return false;
		}
		else if (i != 3 && count < 5) {
			count++;
		}
		i/=10;
		
	}
}

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

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;

	string res;
	while (n != 0) {
		int t = n % 26;
		n /= 26;
		if (t == 0) {
			t = 26;
			n -= 1;
		}
		res += (t - 1) + 'a';
	}

	reverse(res.begin(), res.end());

	cout << res;

	return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

int F[1001], C[1001][1001], D[1001][1001];

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

vector<vector<int> > f(int N, ll t) {
	vector<vector<int> > a(N + 1);
	for (int n = 1; n <= N; n++) {
		vector<int> dp(N / n + 1);
		dp[0] = 1;
		for (int i = 0; i <= N / n; i++)
			for (int j = 1; i + j <= N / n; j++) {
				if (gcd(t, j * n) != j) continue;
				ll x = dp[i];
				x = x * C[i + j - 1][j - 1] % MOD;
				x = x * F[j - 1] % MOD;
				x = x * D[n][j - 1] % MOD;
				dp[i + j] = (dp[i + j] + x) % MOD;
			}
		a[n] = dp;
	}
	return a;
}

int main() {
	F[0] = 1;
	for (int i = 1; i <= 1000; i++)
		F[i] = (ll)F[i - 1] * i % MOD;
	for (int i = 0; i <= 1000; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}
	for (int i = 1; i <= 1000; i++) {
		D[i][0] = 1;
		for (int j = 1; j <= 1000; j++)
			D[i][j] = (ll)D[i][j - 1] * i % MOD;
	}
	int N; ll X, Y, Z;
	cin >> N >> X >> Y >> Z;
	vector<vector<int> > a = f(N, 2), b = f(N, abs(X - Y + Z));
	if (!X && !Y && !Z) {
		cout << (ll)a[1][N] * D[N][N] % MOD << endl;
		return 0;
	}
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int n = 1; n <= N; n++)
		for (int k = N; k >= 0; k--) {
			ll z = 1;
			for (int i = 1; k + i * n <= N; i++) {
				z = z * C[i * n - 1][n - 1] % MOD * F[n - 1] % MOD;
				ll x = dp[k];
				x = x * C[k + i * n][i * n] % MOD;
				x = x * z % MOD;
				x = x * a[n][i] % MOD;
				x = x * b[n][i] % MOD;
				dp[k + i * n] = (dp[k + i * n] + x) % MOD;
			}
		}
	cout << dp[N] << endl;
}

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

int main() {
  int r;
  cin >> r;
  cout << r * 2 * M_PI << endl;
  return 0;
}

Measured memory_bytes: 3784
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

bool check(string s) {
    
    int n=s.size(),flag=0;
    
    for(int i=0;i<n;i++){
        if(s[i]!=s[n-i-1]){
            flag = 1;
            break;
        }
    }
    if(flag)
    return false;
    else
    return true;
    
}
 
int32_t main() {
    fio

    int n;
    cin >> n;
    int arr[n],brr[n+1]={0};
    
    for(int i=0;i<n;i++) {
        cin >> arr[i];
        brr[arr[i]]++;
    }
    
    int sum=0;
    for(int i=1;i<n+1;i++) {
        int x = brr[i];
        if(x>=2) {
            int y = x*(x-1);
            y/=2;
            sum+=y;
            //brr[i]=y;
        }
    }
    
    for(int i=0;i<n;i++) {
        int x = brr[arr[i]];
        int z = sum;
        if(x>=2) {
        int y = x*(x-1);
        y/=2;
        z = z - y;
        }

        x--;
        if(x>=2) {
        int y = x*(x-1);
        y/=2;
        z+=y;
        }
        
        cout << z << endl;
    }
    
    

	return 0;
    
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int count[10] = {0};
		while(n--)
		{
			int num;
			cin >> num;
			++count[num];
		}
		for(int i = 0; i < 10; ++i)
		{
			if(count[i] == 0)
			{
				cout << "-" << endl;
				continue;
			}
			for(int j = 0; j < count[i]; ++j)
			{
				cout << "*";
			}
			cout << endl;
		}
	}
}

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

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

int main() {
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    // cout<<"temp1:"<<d<<"\n";
    ll ans;
    if(x/d>k){
        ans=x-d*k;
        // cout<<"temp3:"<<ans<<endl;
    }else{
        int kai =x/d;
        // cout<<"temp2:"<<kai<<endl;
        k-=kai;
        if(k %2==0) {
            ans=x-kai*d;
            // cout<<"temp4:"<<ans<<endl;
        }else{
            ans=abs((x-kai*d)-d);
            // cout<<"temp5:"<<ans<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

const int maxn = 100009;
int f[maxn], ans;
int n, a;

int main(){
	scanf("%d", &n); ans = n;
	for (int i=1; i<=n; i++){
		scanf("%d", &a);
		ans -= f[a];
		f[a] = 1;
	}
	if (ans % 2 == 0) ans--;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
// ITP1_7_D Matrix Multiplication
import java.io.*;

public class Main {

   public static void main(String[] args) {
      try {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         String strAry0[] = br.readLine().split(" ");
         int n = Integer.parseInt(strAry0[0]);
         int m = Integer.parseInt(strAry0[1]);
         int l = Integer.parseInt(strAry0[2]);
         long[][] A = new long[n][m];
         long[][] B = new long[m][l];
         long[][] C = new long[n][l];

         for (int i = 0; i < n; i++) {
            String strAry1[] = br.readLine().split(" ");
            for (int j = 0; j < m; j++) {
               A[i][j] = Integer.parseInt(strAry1[j]);
            }
         }

         for (int i = 0; i < m; i++) {
            String strAry2[] = br.readLine().split(" ");
            for (int j = 0; j < l; j++) {
               B[i][j] = Integer.parseInt(strAry2[j]);
            }
         }

         for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
               for (int k = 0; k < m; k++) {
                  C[i][j] += (A[i][k] * B[k][j]);
               }
            }
         }

         for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
               System.out.print(j < l - 1 ? C[i][j] + " ": C[i][j] + "\n");
            }
         }
      }

      catch (Exception e) {
         System.err.println(e);
      }
   }
}

Measured memory_bytes: 28780
# -*- coding: utf-8 -*-
num = int(raw_input())
a = int(raw_input())
b = int(raw_input())
diff = b - a
pre_min = min(a,b)

counter = 2
while counter < num:
    current_num = int(raw_input())
    if diff < current_num - pre_min:
        diff = current_num - pre_min
    if pre_min > current_num:
        pre_min = current_num
    counter += 1

print diff

Measured memory_bytes: 6436
#include <iostream>
using namespace std;
const int maxn = 100010;
int bn[maxn];
bool exist[maxn];
int main()
{
    fill(bn, bn + maxn, 1);
    fill(exist, exist + maxn, 0);
    exist[1] = 1;
    int N, M;
    cin >> N >> M;
    while (M--)
    {
        int x, y;
        cin >> x >> y;
        if (exist[x] == 1)
        {
            if (bn[x] == 1)
                exist[x] = 0;
            exist[y] = 1;
            bn[y]++;
            bn[x]--;
        }else
        {
            bn[x]--;
            bn[y]++;
        }
    }
    int count = 0;
    for (int i = 1; i <= N; i++)
    {
        if (exist[i] == 1)
            count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007
vector<int> a;

bool comp(int&f, int&s){
  return a[f] < a[s];
}

int main(){
  int n, m;
  cin >> n >> m;
  a = vector<int>(m);
  vector< int > costs((1 << n)+1, INF);
  vector<int > num((1 << n)+1, -1);
  vector< vector<int> > keys(n);
  vector<int> b(m);
  vector<vector<int> > c(m);
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    vector<int> x(n, 0);
    for(int j = 0; j < b[i]; j++){
      int t;
      cin >> t;
      x[t-1] = 1;
    }
    int tmp = 0;;
    for(int j = 0; j < n; j++){
      tmp += (1 << j) * x[j];
    }
    if(costs[tmp] > a[i]){
      costs[tmp] = a[i];
      num[tmp] = i;
    }
  }
for(int s = 1; s < (1 << n) ; s++){
  for(int t = s+1; t < (1 << n); t++){
    costs[(s | t)] = min(costs[(s | t)], costs[s]+costs[t]);
  }
}
  if(costs[(1<<n)-1] != INF)cout << costs[(1<<n)-1] << endl;
  else cout << -1 << endl;
}


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 vi vector<int>
#define pb push_back
#define INF 999999999


int main(){
    int pass[110][110];
    rep(i,110)rep(j,110)pass[i][j]=INF;
    
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        for(int j=a;j<=b;j++)pass[j][b+1]=1;
    }

    rep(wf_k,n+1){
        rep(wf_i,n+1){
            rep(wf_j,n+1){
                pass[wf_i][wf_j] = min(pass[wf_i][wf_j],pass[wf_i][wf_k]+pass[wf_k][wf_j]);
            }
        }
    }

    if(pass[0][n]>=10000)cout<<"Impossible"<<endl;
    else cout<<pass[0][n]<<endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    vector<int> y = x;
    sort(whole(y));
    int z1 = y[n/2-1];
    int z2 = y[n/2];
    rep(i, n) {
        int ans = 0;
        if (x[i]<=z1) ans = z2;
        else ans = z1;
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>

using namespace std;
int main()
{
  int n;
  int h[20];
  
  cin >> n;

  for (int i = 0; i < n; i++)
  {
	cin >> h[i];
  }
  
  int max = 0;
  int count = 0;
  
  for (int i = 0; i < n; i++)
  {
    if (i == 0){
      count++;
      continue;
    }
    else
    {
      bool result = true;
      for(int j = 0; j < i; j++)
      {
        if (h[i] < h[j])
        {
          result = false;
          break;
        }
      }  
      if (result)
      {
        count++;
      }
    }
  }
  cout << count;
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a, int b){
  if(a%b == 0) return b;
  else return gcd(b, a%b);
}
int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if(c%gcd(a, b) == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256