akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, k, i, j, l, m;
	scanf("%d%d", &n, &k);
	vector<pll> r(n);
	for (i = 0; i < n; i++) {
		scanf("%lld%lld", &r[i].first, &r[i].second);
	}
	ll ans = INF;
	for (i = 0; i < n; i++) {
		for (j = i; j < n; j++) {
			for (l = 0; l < n; l++) {
				for (m = l; m < n; m++) {
					if (i == 0 && j == 3 && l == 0 && m == 2) {
					}
					ll x1, x2, y1, y2;
					x1 = min(r[i].first, r[j].first); x2 = max(r[i].first, r[j].first);
					y1 = min(r[l].second, r[m].second); y2 = max(r[l].second, r[m].second);
					int cnt = 0;
					for (int i2 = 0; i2 < n; i2++) {
						ll x = r[i2].first, y = r[i2].second;
						if (x >= x1 && x <= x2 && y >= y1 && y <= y2) {
							cnt++;
						}
					}
					if (cnt >= k) {
						//printf("%lld\n", (x2 - x1)*(y2 - y1));
						ans = min(ans, (x2 - x1)*(y2 - y1));
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

from collections import defaultdict
pth = defaultdict(list)

for _ in range(M):
    A, B = map(int, input().split())
    pth[A].append(B)
    pth[B].append(A)

sign = [0] * (N+1)
sign[0] = 1
sign[1] = 1
q = [1]
hist = set()

while len(q) != 0:
    key = q.pop(0)

    for n in pth[key]:
        if sign[n] == 0:
            sign[n] = key
            # print("sign[",n,"]=",key)
            q.append(n)
        else:
            continue
    # print(q)

if not all([x != 0 for x in sign[2:]]):
    print("No")
else:
    print("Yes")
    for s in sign[2:]:
        print(s)

Measured memory_bytes: 40028
#include <iostream>
#include<stdio.h>
using namespace std;


int main(void) {
	int N;
	cin >> N;
	 long int x = 1;
	for (long long int i = 0; i < N; i++)
	{
	x *= (i + 1);
	x %= 1000000007;
	
	}
	cout << x << endl;
	getchar();
	getchar();
}

Measured memory_bytes: 256
/*input
4 4
2 4
1 1
2 3
2 4
*/

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

int main() {
    int h, w;
    cin >> h >> w;

    map<int, int> s;
    multiset<int> vals;

    rep(i, w) s[i] = i;
    rep(i, w) vals.insert(0);

    rep(i, h) {
        int l, r;
        cin >> l >> r;
        --l;
        auto it = s.lower_bound(l);
        int mr = -1;
        while (it != s.end() && it->first <= r) {
            mr = max(mr, it->second);
            int x = it->first-it->second;
            vals.erase(vals.find(x));
            s.erase(it++);
        }
        if (mr != -1 && r < w) {
            vals.insert(r-mr);
            s[r] = mr;
        }
        int ans = -1;
        if (vals.size() > 0) {
            ans = *vals.begin()+(i+1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 22324
#include <bits/stdc++.h>
using namespace std;
int main(){
   int h, n;
   cin >> h >> n;
   
   long long int sum = 0;
   for(int i =0; i < n;i++){
          int k;
          cin >> k;
          sum += k;
   }
   
   if(sum >= h)
   cout << "Yes" << endl;
   else cout << "No" << endl;
}





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

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	int turn = 0;
	string ans;
	while( 1 ) {
		if( turn ) {
			if( B - 1 == A ) {
				if( B == N ) {
					ans = "Alice";
					break;
				}
				else {
					B++;
				}
			}
			else B--;
		}
		else {
			if( A + 1 == B ) {
				if( A == 1 ) {
					ans = "Borys";
					break;
				}
				else {
					A--;
				}
			}
			else A++;
		}
		turn = 1 - turn;
	}

	cout << ans << endl;
}


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


int main() {
    int s,m,h;
    cin >> s;
    h = s/3600;
    m = (s%3600)/60;
    s = (s%3600)%60;
    cout << h << ':' << m << ':' << s << endl;
    
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
K = int(input())
X = [int(i) for i in input().split()]

total = 0
for i in range(N):
    if abs(X[i] - K) < abs(X[i]):
        total += 2 * abs(X[i] - K)
    else:
        total += 2 * abs(X[i])

print(total)

Measured memory_bytes: 3060
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a, b, k = inpm()
ta = a - k
ao = b
if(ta < 0):
    ao = b + ta
    ta = 0
if(ao < 0):
    ao = 0
print(str(ta) + ' ' + str(ao))



Measured memory_bytes: 74832
n, m = map(int, input().split())
A = list(map(lambda x:int(x)-1, input().split()))
value = [0]*(m+1)
length = [0]*(m+1)
ans = 0
for i in range(1, n):
    a, b = A[i-1], A[i]
    if a<b:
        value[a+1]+=1
        value[b+1]-=1
        length[b+1]-=(b-a)
        ans+=b-a
    else:
        value[a+1]+=1
        value[m]-=1
        value[0]+=1
        value[b+1]-=1
        length[0]+=(m-a-1)
        length[b+1]-=(m-a)+(b)
        ans+=m-a+b
for i in range(m):
    value[i+1] = value[i]+value[i+1]
for i in range(m+1):
    length[i] += value[i]
for i in range(m):
    length[i+1] += length[i]
for i in range(m):
    length[i]-=value[i]
ans -= max(length[::-1])
print(ans)

Measured memory_bytes: 54636
#include <stdio.h>
int main(void){
    char a[3][101];
    int b[3]={0};
    int j=0;
    scanf("%s%s%s",a[0],a[1],a[2]);
    while(1){
        if(a[j][b[j]]=='\0'){
            printf("%c",'A'+j);
            break;
        }
        j = a[j][b[j]++]-'a';
        // printf("%d %d %d\n",b[0],b[1],b[2]);
    }
}


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

N = ii()
que = deque([33, 35, 37, 53, 55, 57, 73, 75, 77])
ele = ['3', '5', '7']

ind = 0
while True:
    num = que[ind] * 10
    que.append(num + 3)
    que.append(num + 5)
    que.append(num + 7)
    if len(str(num)) >= 10:
        break
    ind += 1

ind = bisect.bisect_right(que, N)

ele = ['3', '5', '7']
cnt = 0
for i in range(ind):
    tmp = str(que[i])
    for e in ele:
        if e not in tmp:
            cnt += 1
            break

print(ind - cnt)

Measured memory_bytes: 4464
import java.util.Scanner;
 
/**
 * @author Lillard
 */
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (b < 0) {
            if ((b-a+1)%2 == 1) {
                System.out.println("Negative");
            } else {
                System.out.println("Positive");
            }
        } else if (a > 0) {
            System.out.println("Positive");
        } else {
            System.out.println("Zero");
        }
 
        System.exit(0);
    }
}

Measured memory_bytes: 9548
#include<stdio.h>
#include<stdlib.h>
#define min(a,b) a<b?a:b
int main()
{
    long long n,a[100001],s1=0,t,m,i;
    scanf("%lld",&n);
    for(i=0;i<=n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
       {
           scanf("%lld",&m);
           t=min(m,a[i]);
           a[i]-=t;
           s1+=t;
           m-=t;
           if(m)
           {
               t=min(m,a[i+1]);
               a[i+1]-=t;
               s1+=t;
           }
       }
    printf("%lld\n",s1);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const int maxn = 200005;
typedef pair<ll, ll>par;
const ll mod = 1000000007;

map< par, int > M;

ll pot( ll b, ll e ){
    ll ret = 1, a = b;
    while( e ){
        if( e & 1 ) ret = (ret * a)%mod;
        a = (a*a)%mod;
        e >>= 1;
    }
    return ret;
}

map<par, int>mark;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm

    int n;
    cin >> n;

    ll a, b;
    ll c0 = 0;
    ll c01 = 0, c02 = 0;
    for( int i = 1; i <= n; i++ ){
        cin >> a >> b;
        if( a == 0 && b == 0 ){
            c0++;
            continue;
        }

        if( a == 0 ){
            c01++;
            continue;
        }
        if( b == 0 ){
            c02++;
            continue;
        }
        if( a < 0 )
            a*= -1, b*=-1;

        ll g = __gcd(abs(a), abs(b));
        a /= g, b /= g;

        M[ par(a, b) ]++;
    }

    ll cant0 = c0;

    ll q = (pot(2, c01)-1+mod)%mod;
    ll w = (pot(2, c02)-1+mod)%mod;
    ll sol = (q+w+1)%mod;
    for( auto &i : M ){
        auto p = i.first;
        if( mark[p] )continue;
        mark[p] = 1;
        a = p.fi, b = p.se;
        ll c1 = i.se, c2 = 0;

        ll na = -b, nb = a;
        if( na < 0 )
            na *= -1, nb *= -1;

        if( M.count( par(na, nb) ) ){
            c2 = M[ par(na, nb) ];
            //M[ par(na, nb) ] = 0;
            mark[ par(na, nb) ] = 1;
        }

        //M[ par(a, b) ] = 0;
        ll x = (pot(2, c1)-1+mod)%mod;
        ll y = (pot(2, c2)-1+mod)%mod;
        ll z = (x + y + 1 + mod)%mod;

        sol = (sol * z)%mod;
    }

    cout << (sol - 1 + mod + cant0)%mod;

    return 0;
}


Measured memory_bytes: 28548
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n,k;
ll dp[110][100010];
ll dp_sum[110][100010];
int a[110];
  

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  rep(i,3){
    int h1,m1,s1,h2,m2,s2;
    cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
    int total=h2*3600+m2*60+s2-(h1*3600+m1*60+s1);
    cout << total/3600 << " ";
    total-=(total/3600)*3600;
    cout << total/60 << " ";
    total-=(total/60)*60;
    cout << total << endl;
  }
}



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

int main() {
    ll n;
    cin >> n;
    map<int, int>mp;
    int m = 0;
    string ans = "YES";
    rep(i, n){
        int s;
        cin >> s;
        if(mp[s] == 0){
            mp[s] = 1;
        }else{
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12940
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int main(){
	double a,b,x;
	cin>>a>>b>>x;
	double v=(2*x+0.0-b*a*a)/(a*a+0.0);
	if(v<0){
		double u=atan(2*x/(a*b*b))*180/pi;
		printf("%.8f\n",90-u);
		return 0;
	}
	double u=atan(a/(b-v+0.0))*180/pi;
	printf("%.8f\n",90-u);
}

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

int main() {
  int N,M;

  cin >> N;
  vector<string> Blue(N);
  for(int i=0 ; i<N ; i++)
    cin >> Blue.at(i);

  cin >> M;
  vector<string> Red(M);
  for(int i=0 ; i<M ; i++)
    cin >> Red.at(i);
  
  int point = 0;

  for(int i=0 ; i<N ; i++){
    int p = 0;
    for(int j=0 ; j<N ; j++){
      if(Blue.at(i) == Blue.at(j))
        p++; 
    }
    for(int j=0 ; j<M ; j++){
      if(Blue.at(i) == Red.at(j))
        p--;
    }
    if(point < p)
      point = p;
  }

  cout << point << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

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

  ull res = 0;
  for (ll b = max(1LL, K); b <= N; b++) {
    ll q = (b - K) * (N / b);
    ll r = 0;
    if (N % b != 0) {
      if (K == 0) r = N % b;
      else r = max(0LL, N % b + 1 - K);
    }
    res += q + r;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 


#define M 100010


int main(){
	IOS;
	tihs;

	ll s,w;cin>>s>>w;
	if(w>=s)cout<<"unsafe";
	else cout<<"safe";
	
	return 0;
}

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

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

    float bit = 0;
    float yen = 0;
    float num;
    string s;

    for (int i = 0; i < n; i++) {
        cin >> num;
        cin >> s;
        if (s[0] == 'J')
            yen = yen + num;
        else
            bit = bit + num;
    }

    float all = yen + bit*380000.0;

    cout << all << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=list(map(int, input().split()))
c=list(map(int, input().split()))

x=0
y=0
z=0
ans=0
for i in range(a-1):
	x=c[i]
	if c[i]<=c[i+1]-b:
		ans=ans+b
	else:
		ans=ans+c[i+1]-c[i]
print(ans+b)

Measured memory_bytes: 25200
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
 
using namespace std;

typedef long long ll;

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

    ll N, M;
    
    cin >> N >> M;

    priority_queue<ll, vector<ll>, less<ll> > q;

    for(int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        q.push(A);
    }

    for(int i = 0; i < M; i++) {
        ll x = q.top();
        q.pop();
        q.push(x / 2);
    }

    ll count = 0;

    for(int i = 0; i < N; i++) {
        count += q.top();
        q.pop();
    }

    cout << count << endl;
}


Measured memory_bytes: 1400
n = int(input())
D = tuple(map(int, input().split()))
m = int(input())
T = tuple(map(int, input().split()))

from collections import Counter
CD = Counter(D)
CT = Counter(T)
for t, ct in CT.items():
    cd = CD[t]
    if ct > cd:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 170608
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);


    int n; cin >> n;
    ll data[500][3];

    REP(i,n-1) REP(j,3) cin>>data[i][j];

    REP(i,n-1){

      ll start=data[i][1];

      for(int j=i; j<n-1; ++j){
        if(data[j][1]>=start) start=data[j][1];
        else start=data[j][2]*((ll) ceil((start+0.0)/(data[j][2]+0.0)));

        start+=data[j][0];
      }

      cout << start << endl;

  }
  cout << 0 << endl;


    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// @formatter:on


class BDistance {
public:
  
  void solveOne(istream& cin, ostream& cout) {
    int n, d;
    cin >> n >> d;
    int res = 0;
    for (int i = 0; i < n; ++i) {
      ld x, y;
      cin >> x >> y;
      ld dis = hypot(x, y);
      if (dis <= d) {
        res++;
      }
    }
    cout << res << '\n';
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int t = 1;
//    cin >> t;
    for (int tc = 1; tc <= t; ++tc) {
      //	cout << "Case #" << tc << ": ";
      solveOne(cin, cout);
    }
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	BDistance solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int P, Q, R;
	cin >> P >>Q >>R;

	int a, b, c;
	a = P + Q;
	b = Q + R;
	c = R + P;
	int answer=a;
	if (b < a) {
		answer = b;
		if (c < b) {
			answer = c;
		}
	}
	else if (c<a){
		answer = c;
	}
	cout << answer<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define MAX 100
int is[MAX];
int h, w;
string s[8];
bool judge() {
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '#') {
				if (i != 0 && j != 0) {
					if (s[i - 1][j] == '#' && s[i][j - 1] == '#') {
						return false;
					}
				}
				if (i < h - 1 && j > 0) {
					if (s[i + 1][j - 1] == '#' && s[i][j - 1] == '#') {
						return false;
					}
				}
			}
		}
	}
	return true;
}

int main(void) {
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		cin >> s[i];
	}
	bool f = judge();
	cout << (f ? "Possible" : "Impossible") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
#include <bitset>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int n;
	string s, t,ans="";

	CI n;
	CI s >> t;

	REP(i, n) {
		ans = ans + s[i];
		ans = ans + t[i];

	}
	CO ans EN;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
G = [[] for _ in range(N)]
for a, b in AB:
    G[a-1].append(b-1)
    G[b-1].append(a-1)
visited = [False] * N
visited[0] = True
ans = 0
def dfs(x):
    global ans
    if all(visited):
        ans += 1
        return
    for y in G[x]:
        if not visited[y]:
            visited[y] = True
            dfs(y)
            visited[y] = False
dfs(0)
print(ans)

Measured memory_bytes: 3064
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;

	int a[26];

	memset(a, 0, sizeof(a));

	for (int i = 0; i < s.size(); i++)
	{
		a[s[i] - 'a']++;
		if (a[s[i] - 'a'] > 1)
		{
			cout << "no" << endl;
			return 0;
		}
	}

	cout << "yes" << endl;

	
	return 0;
}


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

int main()
{
    long long N, M;
    cin >> N >> M;
    if (N == 1 && M == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if (N == 1 && M != 1)
    {
        cout << M - 2 << endl;
        return 0;
    }
    if (M == 1 && N != 1)
    {
        cout << N - 2 << endl;
        return 0;
    }
    cout << (N - 2) * (M - 2) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
void solve(){
    ll n, k;
    cin >> n >> k;
    ll p = 0, s = 0, ans = 0;
    for(ll i =1; i<=n+1; i++){
        s += i;
        p += n+2-i;
        s%=mod;
        p%=mod;
        if(i>=k){
            ans += p-s+mod+1;
            ans %mod;
        }
    }
    cout << ans%mod;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t =1, i = 1;
    //cin >> t;
    while(t--){
        solve();
        ++i;
    }
    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main(void) {
    int N;
    cin >> N;
    multimap<int, int> L;
    multimap<int, int> R;
    map<int, bool> X;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        cin >> tmp;
        L.emplace(i + tmp, i);
        R.emplace(i - tmp, i);
        X.emplace(i + tmp, false);
        X.emplace(i - tmp, false);
    }
    ll count_L = 0;
    ll count_R = 0;
    ll count = 0;
    for (auto itr = X.begin(); itr != X.end(); ++itr) {
        count_L = L.count(itr->first);
        count_R = R.count(itr->first);
        auto l = L.equal_range(itr->first);
        if (count_L > 0 && count_R > 0)
            count += count_L * count_R;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 39332
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace lineAralgebra
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine();

			switch(input) {
				case "Sunny":
				System.Console.WriteLine("Cloudy");
				break;
				case "Cloudy":
				System.Console.WriteLine("Rainy");
				break;
				case "Rainy":
				System.Console.WriteLine("Sunny");
				break;
			}
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;
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; }
const int INF = 1<<29;
int main() {
    ll N; cin >> N;
    Graph G(N);
    for (int i=1;i<=N-1;++i){
        int Ai; cin >> Ai; --Ai;
        G[Ai].push_back(i);
    }
    for (int i=0;i<N;++i){
        ll cnt = (ll)G[i].size();
        cout << cnt << endl;
    }

    return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* sort the job w/ deadline asc (start time order does not matter) */

typedef tuple<int,int> Job;

bool cmp(const Job& x, const Job& y)
{
    int a,b,aa,bb; tie(a,b) = x; tie(aa,bb) = y;
    return b < bb;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        vector<Job> A;
        FOR(i,0,n) {
            int a,b; cin >> a >> b;
            A.push_back(Job(b-a,b));
        }
        sort(ALL(A),cmp);
        int t = 0; bool good = true;
        FOR_ALL(a,A) {
            int x,y; tie(x,y) = *a;
            if (t > x)
                good = false;
            t += y-x;
        }
        cout << (good ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string s;
  cin >> s;
  cout << 2018 << s.substr(4) << endl;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> tri;
const int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int h,w,n,t[22];
string area[22][22];
int d[1000][22][22];

int main(){
  cin >> h >> w;
  rep(i,h)cin >> area[0][i];
  cin >> n;
  rep(i,n){
    cin >> t[i];
    rep(j,h)cin >> area[i+1][j];
  }
  
  memset(d,-1,sizeof(d));
  deque<tri> q;
  rep(i,h)rep(j,w){
    if(area[0][i][j] == 'S'){
      q.push_back(tri(0,pii(i,j)));
      d[0][i][j] = 0;
    }
  }

  while(q.size()){
    tri p = q.front(); q.pop_front();
    int cur = p.fs, y = p.sc.fs, x = p.sc.sc;
    if(area[0][y][x] == 'G'){
      cout << d[cur][y][x] << endl;
      return 0;
    }

    int id = n;
    for(int i=0;i<n;i++){
      if(cur+1<t[i]){
	id = i; break;
      }
    }

    if(area[id][y][x] != '#'){
      if(d[cur+1][y][x]<0){
	d[cur+1][y][x] = d[cur][y][x];
	q.push_front(tri(cur+1,pii(y,x)));
      }
    }

    for(int i=0;i<4;i++){
      int ny = y+dy[i], nx = x+dx[i];
      if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
      if(area[id][ny][nx] == '#')continue;
      if(d[cur+1][ny][nx]<0){
	d[cur+1][ny][nx] = d[cur][y][x]+1;
	q.push_back(tri(cur+1,pii(ny,nx)));
      }
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 3272
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    sort(ALL(A));

    ll sum = 0;
    FOR(i, 0, N-1){
        sum += A[i];
    }

    if(sum > A.back()){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>                                                                                                                                                                                          
using namespace std;                                                                                                                                                                                        
                                                                                                                                                                                                            
int main(){                                                                                                                                                                                                 
    int A,B;                                                                                                                                                                                                
    cin >> A >> B;                                                                                                                                                                                          
                                                                                                                                                                                                            
    int ans = A+B;                                                                                                                                                                                          
    if(ans >= 24){                                                                                                                                                                                          
        ans -= 24;                                                                                                                                                                                          
    }                                                                                                                                                                                                       
                                                                                                                                                                                                            
    cout << ans << endl;                                                                                                                                                                                    
                                                                                                                                                                                                            
    return 0;                                                                                                                                                                                               
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		Main instance = new Main();
		sc = instance.new Scanner();
		instance.solve();
	}

	private void solve() {
		try {
			int N = sc.nextInt();
			String S = sc.next();

			int max =0;
			int cnt =0;
			for (int i=0;i<=N-1;i++) {
				if (S.charAt(i) == 'I'){
					cnt++;
					max = Math.max(cnt,max);
				} else {
					cnt--;
				}

			}

			System.out.println(max);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private class Scanner {
		String[] s;
		int i;
		BufferedReader br;
		String regex = " ";

		public Scanner() {
			s = new String[0];
			i = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		@Override
		protected void finalize() throws Throwable {
			try {
				super.finalize();
			} finally {
				destruction();
			}
		}

		private void destruction() throws IOException {
			if (br != null)
				br.close();
		}

		public String next() throws IOException {
			if (i < s.length)
				return s[i++];
			String st = br.readLine();
			while (st == "")
				st = br.readLine();
			s = st.split(regex, 0);
			i = 0;
			return s[i++];
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  
  int c=0;
  int s=0;
  
  for(int i=1; i<=100; i++){
    for(int j=0; j<n; j++){
      if(a[j]%2 == 0){
        c++;
      }
    }
    
    if(c == n){
      for(int j=0; j<n; j++){
        a[j] /= 2;
        c = 0;
      }
      s++;
    }
    else{
      break;
    }
  }
  
  cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    rep(i,8){
        int c=s[0]-'0';
        rep(j,3){
            if(i&(1<<j)) c+=s[j+1]-'0';
            else c-=s[j+1]-'0';
        }
        if(c==7){
            cout<<s[0];
            rep(j,3){
                if(i&(1<<j)) cout<<"+"<<s[j+1];
                else cout<<"-"<<s[j+1];
            }
            cout<<"=7"<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(void){
        double r;
        cin>>r;
        double area, len;
        area=M_PI*r*r;
        len=2*M_PI*r;
        printf("%f %f",area,len);
        return 0;
}



Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(void)
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> R(M);
	for (auto &i : R) cin >> i.first >> i.second;
	sort(R.begin(), R.end());
	int ans = 0, now = 0;
	int c, d;
	for (auto i = R.begin(); i != R.end();)
	{
		c = i->first;
		d = i->second;
		for (i++; i != R.end(); i++)
		{
			if (i->first > d) break;
			d = max(d, i->second);
		}
		ans += (d - now);
		ans += (d - c);
		now = c;
	}
	ans += (N + 1 - now);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>

int main(){
	std::string s;
	std::string t;

	std::cin>>s>>t;

	bool isCorrect= true;

	for(int i=0; i<s.size(); i++)
		if(s[i]!=t[i])
			isCorrect=false;

	if(isCorrect)
		std::cout<<"Yes"<<std::endl;
	else
		std::cout<<"No"<<std::endl;

	return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define fto(i,a,b) for(int i=a; i<=b; ++i)
#define mp make_pair
#define fi first
#define se second

using namespace std;
const int maxn =200009;
int n,x[maxn],y[maxn],cnt[maxn];
pair<int,int> a[maxn*2];
main()
{
    #ifdef abcxyz
    freopen("a.inp", "r", stdin);
    #endif
    cin >> n;
    int mn=1e9,mx=0,mn1=0,mx1=1e9;
    fto(i,1,n){
        cin >> x[i] >> y[i];
        if(x[i]>y[i])swap(x[i],y[i]);
        mn=min(mn,x[i]);
        mn1=max(mn1,x[i]);
        mx=max(mx,y[i]);
        mx1=min(mx1,y[i]);
    }
    int res=(mn1-mn)*(mx-mx1);
    if(n==1){cout << res; return 0;}
    int m=0;
    fto(i,1,n){
        a[++m]=mp(x[i],i);
        a[++m]=mp(y[i],-i);
    }
    sort(a+1,a+m+1);
    if(a[1].se+a[m].se==0){
        if(a[1].fi==a[2].fi)swap(a[1],a[2]);
        else if(a[m].se==a[m-1].se)swap(a[m],a[m-1]);
        else{cout << res; return 0;}
    }
    int j=2;
    int s=0;
    //cout << res <<endl;
    for(int i=2; i<m; ++i){
        while(s<n && j<m){
            int tg=++cnt[abs(a[j].se)];
            if(tg==1)++s;
            ++j;
        }
        if(s==n)res=min(res,(a[m].fi-a[1].fi)*(a[j-1].fi-a[i].fi));
        else break;
        //cout << i <<' '<<s<<' '<< (a[m].fi-a[1].fi)<<' '<<(a[j-1].fi-a[i].fi) <<endl;
        int tg=--cnt[abs(a[i].se)];
        if(tg==0)--s;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()

signed main(){
	int N,x;
	x = 0;
	string S;
	cin >> S;
	N = S.size();
	rep(i, N) {
		if (S[i] != S[N - i-1])
			x++;
	}
	cout << x/2;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    ll N, M;
    cin >> N >> M;
    ll cnt[33]={};
    ll i, j;
    
    for(i=0; i<N; i++) {
        ll k;
        cin >> k;
        for(j=0; j<k; j++) {
            ll a;
            cin >> a;
            a--;
            cnt[a]++;
        }
    }
    
    ll ans=0;
    for(i=0; i<M; i++) {
        if(cnt[i]==N) ans++;
    }
    
    pt(ans);
    
}





Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);



int main()
{
	int n, m;  cin >> n >> m;
	if (n == m)
		cout << "Yes";
	else
		cout << "No";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n;
	cin>>n;
	vector<ll> ball(n);
	map<ll,ll> m;
	rep(i,n){
		cin>>ball[i];
		m[ball[i]]++;
	}
	ll ans = 0LL;
	for(auto x : m){
		ans += x.second * (x.second-1LL)/2;
	}
	rep(i,n){
		ll t = m[ball[i]];
		ll n_ans = ans;
		n_ans -= t * (t-1LL) /2LL;
		n_ans += max((t-1LL)*(t-2LL)/2LL,0LL);
		cout<<n_ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <string.h>

int main() {
    unsigned int b;
    double res, frac;
    char s[20];
    int i, q;
    scanf("%d", &q);

    while ( q-- ) {

	scanf("%x", &b);

	res = (b&0x7fffffff) >> 7;//整数部の値で初期化
	
	//小数部を加算
	frac = 0.5;
	for ( i=6; i>=0; --i ) {
	    if ( (b>>i)&1 ) res += frac;
	    frac *= 0.5;
	}

	snprintf( s, 20, "%16.15lf", res );
	for ( i=strlen(s)-1; i>0; --i ) {
	    if ( s[i] == '0' ) s[i] = '\0';
	    else break;
	}
	printf("%s%s%s\n", (b>>31)?"-":"", s, (b&0x0000007f)?"":"0");

    }

    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
const int N=100000;
ll add(ll a){
	ll ans=0,w;
	while(a){
		w=a%10;
		a/=10;
		ans+=w;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,b,ans,w;
	cin>>n>>a>>b;
	ans=0;
	FOR(i,1,n+1){
		w=add(i);
		if(w>=a&&w<=b){
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;

#define MOD (100000)
#define NOR(x) ((x) % MOD)



int main() {
	for (int N, M, S; cin >> N >> M >> S, (N | M | S) != 0; ) {
		int N2 = N * N;
		int dp[3010][55];
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		REP(i, 1, M) {
			for (int j = S; j >= i; j--) for (int k = N2; k >= 1; k--) {
				dp[j][k] = NOR(dp[j][k] + dp[j - i][k - 1]);
			}
		}
		cout << dp[S][N2] << endl;
	}
	return 0;
}

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

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

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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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

void WF(ll N,  vector<vector<ll>> &g) {
	repn(k, N) {
		repn(i, N) {
			repn(j, N) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {

    ll N,M,R;
    cin >>N>>M>>R;

    vector<ll> r(R+1);
    repn(i,R) cin >>r[i];

    vector<vector<ll>> g(N+1,vector<ll>(N+1,INF));

    repn(i,M){
        ll a,b,c;
        cin >>a>>b>>c;

        g[a][b]=c;
        g[b][a]=c;
    }

    WF(N,g);

    //repn(i,N)repn(j,N) cout <<g[i][j];

    ll ans=INF;

    vector<ll> v(R+1);
    repn(i,R) v[i]=i;

    do{
        ll d=0;
        repn(i,R-1) d+=g[r[v[i]]][r[v[i+1]]];
        ans=min(ans,d);
    }
    while(next_permutation(++v.begin(),v.end()));

    cout <<ans;


 
	

}


Measured memory_bytes: 512