akhauriyash/Code-Regression huggingface dataset:
x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.reverse
b = gets.split.map(&:to_i).sort.reverse
c = gets.split.map(&:to_i).sort.reverse

results = []
q = [[a[0]+b[0]+c[0],0,0,0]]
checks = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) }

while qq = q.shift do
  results.push qq[0]
  if results.size >= k
    break
  end
  _a, _b, _c = qq[1], qq[2], qq[3]
  if _a + 1 < x && checks[_a+1][_b][_c] != true
    q.push([a[_a + 1] + b[_b] + c[_c], _a + 1, _b, _c])
    checks[_a+1][_b][_c] = true
  end
  if _b + 1 < y && checks[_a][_b+1][_c] != true
    q.push([a[_a] + b[_b + 1] + c[_c], _a, _b + 1, _c])
    checks[_a][_b+1][_c] = true
  end
  if _c + 1 < z && checks[_a][_b][_c + 1] != true
    q.push([a[_a] + b[_b] + c[_c + 1], _a, _b, _c + 1])
    checks[_a][_b][_c+1] = true
  end
  q = q.sort_by{|qq| -qq[0] }
  if q.size + results.size > k
    q = q[0..(k-results.size-1)]
  end
end

results.each do |r|
  puts r 
end

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

int main() {
  int n;
  cin >> n;
  
  long int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0)
      ans += i;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

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

    while(1) {
        bool f = true;
        for (int i=2; i<x; i++) {
            if (x%i == 0) {
                f = false;
                break;
            }
        }
        if (f) break;
        x++;
    }

    cout << x << endl;
}


Measured memory_bytes: 256
# N
# X1, XN
#Pに参加するには(Xi - P)^2を消費
#消費の最小化

N = gets.to_i
X = gets.split.map(&:to_i)
dis = []

(1..100).each do |i|
  cost = 0
  X.each do |x|
    cost += (i - x) ** 2
  end
  dis << cost
end
puts dis.min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll linf=0x3f3f3f3f3f3f3f3f;
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    ll a, b;
    while (~scanf("%lld%lld", &a, &b)) {
        ll ans=1;
        for (ll i = 1; i * i <= b; i++) {
            if (b % i == 0) {
                if (i * a <= b) {
                    ll tmp = b/i;
                    if (tmp * a <= b) ans = max(max(i, tmp), ans);
                    else ans = max(ans, i);
                } else {
                    break;
                }
            }
        }
        printf("%lld\n", ans);
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int m;
    cin>>m;
    int a[n];int sum;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m=m-a[i];
    }
    sort(a,a+n);
    int y=n+m/a[0];
    cout<<y;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())

ll N, K;
vector<ll> P, M;
ll p, m, z;

bool jugde_m(ll x) {
  ll cnt = 0;
  int ip = p, im = 0;
  while (im<m) {
    while (ip>0 && M[im]*P[ip-1]>x) {
      ip--;
    }
    cnt += ip;
    im++;
  }
  return cnt>=K;
}

bool jugde_p(ll x) {
  ll cnt = 0;
  int a, b;
  a = 0; b = p-1;
  while (a<b) {
    while (a<b && P[a]*P[b]<=x) {
      b--;
    }
    cnt += b-a;
    a++;
  }
  a = 0; b = m-1;
  while (a<b) {
    while (a<b && M[a]*M[b]<=x) {
      b--;
    }
    cnt += b-a;
    a++;
  }
  return cnt<=p*(p-1)/2+m*(m-1)/2-K;
}


int main() {
  cin >> N >> K;
  rep(i,N) {
    ll a;
    cin >> a;
    if (a>0) {
      P.push_back(a);
      p++;
    } else if (a==0) {
      z++;
    } else {
      M.push_back(a);
      m++;
    }
  }
  sort(all(M)); rsort(P);
  if (p*m>=K) {
    ll l = -1e18-1, u = -1;
    while (u-l>1) {
      ll mid = (l+u)/2;
      if (jugde_m(mid)) {
        u = mid;
      } else {
        l = mid;
      }
    }
    print(u);
  } else if (z*(z-1)/2+p*m+m*z+z*p>=K) {
    print(0);
  } else {
    K -= z*(z-1)/2+p*m+m*z+z*p;
    ll l = -1, u = 1e18;
    while (u-l>1) {
      ll mid = (l+u)/2;
      if (jugde_p(mid)) {
        u = mid;
      } else {
        l = mid;
      }
    }
    print(u);
  }
  return 0;
}

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

struct data{int left,right;};

int main()
{
  int n,m,a,h,p,q;
  multimap< int,data,greater<int> > line;
  multimap<int,data>::iterator it;
  while(cin>>n>>m>>a,n|m|a){
    line.clear();
    while(m-->0){
      cin>>h>>p>>q;
      data d={p,q};
      line.insert(multimap<int,data>::value_type(h,d));
    }
    for(it=line.begin();it!=line.end();it++){
      if(it->second.left==a)a=it->second.right;
      else if(it->second.right==a)a=it->second.left;
    }
    cout<<a<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int n,m;
    cin>>n>>m;
    //素因数分解して、その因数のうち、大きい順に試して行って、大丈夫ならそれを採用。
    for(int i=m/n+1;i>=1;i--){
        if(m%i==0){
            if((m-(n-1)*i)%i==0 and m-(n-1)*i>0){
                cout<<i<<endl;
                return 0;
            }
        }
    }

    return 0;
}


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

int main() {
    vector<char> s(3);
    for (int i = 0; i < 3; i++) {
        cin >> s.at(i);
    }
    if (s.at(0) != s.at(1) && s.at(0) != s.at(2) && s.at(1) != s.at(2))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=10000002,M=1e9+7;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
char pbuf[100000],*pp=pbuf;
inline void pc(char ch){if(pp==pbuf+100000)fwrite(pbuf,1,100000,stdout),pp=pbuf;*pp++=ch;}
inline void wri(int x){
	static char st[19];
	int tp=0;
	if(x<0)pc(45),x=-x;
	if(!x)pc(48);
	while(x)st[tp++]=x%10|48,x/=10;
	while(tp)pc(st[--tp]);
}
inline void wln(int x){wri(x),pc(10);}
inline void flush(){fwrite(pbuf,1,pp-pbuf,stdout);}
int n,k,p,inv[N],fac[N],i;
int main(){
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for (i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%M;
	inv[N-1]=pw(fac[N-1],M-2);
	for (i=N-2;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%M;
	p=1ll*fac[n-k+1]*fac[k-1]%M;
	for (i=1;i<=k;i++){
		if (i>n-k+1) wln(0);
		else wln(1ll*p*inv[i]%M*inv[n-k+1-i]%M*inv[i-1]%M*inv[k-i]%M);
	}
	flush();
}

Measured memory_bytes: 78336
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <math.h>
#define MODD 1000000007
#define ll long long

#define Inf 1000000000
#define MAXN 100000
using namespace std;

int main() {
    int N,M;
    cin>>N>>M;
    
    int T = (N-M)*100+1900*M;
    // (N-M)*100+1900*M
    
    // p*T+(1-p)*p*2T+...
    
    // p*T*(1+2*(1-p)+...)
    // p*T*(1-p)/p
    
    // p+p^2+..p/(1-p)

    // 1/p
    
    
    // T*p/(1-p)^2
    
    double p = pow(0.5,M);
    
    
    ll ans = T*(1ll<<M);
    cout << ans << endl;
    
    
}

Measured memory_bytes: 384
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> one = nextStrArray();
      myout(one.get(1) + one.get(0));
	}
	//Method addition frame start



	//Method addition frame end
}


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

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

using namespace std;

int MOD;
class mint{
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int ask(int t,int l,int b,int r){
	map<tuple<int,int,int,int>,int> memo;
	if(memo.count({t,l,b,r})>0) return memo[{t,l,b,r}];

	printf("? %d %d %d %d\n",t,l,b,r);
	fflush(stdout);
	int res; scanf("%d",&res);
	return memo[{t,l,b,r}]=res;
}

int main(){
	int h,w,n; scanf("%d%d%d%d",&h,&w,&n,&MOD);

	mint ans=0;
	rep(i,h){
		int m=ask(i,0,i,w-1);
		int lo,hi=-1;
		for(int k=1;k<=m;k++){
			lo=hi;
			hi=w-1;
			while(hi-lo>1){
				int mi=(lo+hi)/2;
				if(ask(i,0,i,mi)>=k) hi=mi;
				else                 lo=mi;
			}
			ans+=pow(mint(2),i*w+hi);
		}
	}
	printf("! %d\n",ans.to_int());

	return 0;
}


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

#define For(i,N) for(int i=0;i<N;i++)

void QuickSort(int left, int right, int array[]) {
	int left0 = left, right0 = right;
	int buff;
	int pivot;
	if (left >= right)return;
	pivot = (array[left] + array[right] + array[(right + left) / 2]) / 3;
	while (1) {
		while (array[left] < pivot)left++;
		while (array[right] > pivot)right--;
		if (left >= right)break;
		buff = array[left];
		array[left] = array[right];
		array[right] = buff;
		left++;
		right--;
	}
	QuickSort(left0, left - 1, array);
	QuickSort(right + 1, right0, array);
}

int main() {
	int N;
	char top4[4][6] = { "9997","9998","9999","10000" };
	int madeNum[16];
	char read[6];
	char s[15];
	scanf("%d", &N);
	For(i, N) {
		scanf("%s", &read);
		For(i, 4) {
			if (atoi(top4[i]) > atoi(read)) {
				for (int k = 3; k != i; k--) {
					strcpy(top4[k], top4[k - 1]);
				}
				strcpy(top4[i], read);
				break;
			}
		}
	}
	For(i, 4) {
		For(j, 4) {
			if (i == j) { madeNum[i + 4 * j] = 0; continue; }
			strcpy(s, top4[i]);
			strcat(s, top4[j]);
			madeNum[i + 4 * j] = atoi(s);
		}
	}
	QuickSort(0, 15, madeNum);
	printf("%d\n", madeNum[6]);
	return 0;
}


Measured memory_bytes: 2104
/*
 * Problem Description: Dictionary
 * Category:
 * Author: Khan
 * Date: 14th October, 2017
 */

#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
    switch(ch)
    {
    case 'A': return 1;
    case 'C': return 2;
    case 'T': return 3;
    case 'G': return 4;
    default: return 0;
    }
}

long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (int i = 0; i < strlen(str); ++i)
    {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key)
{
    return key % M;
}

int h2(int key)
{
    return 1 + (key % (M - 1));
}

int find(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (int i = 0; ; ++i)
    {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0)
            return 1;
        else if(strlen(H[h]) == 0)
            return 0;
    }
    return 0;
}

int insert(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (int i = 0; ; ++i)
    {
        h = (h1(key) + i * h2(key)) % M;
        if(strcmp(H[h], str) == 0)
            return 1;
        else if(strlen(H[h]) == 0)
        {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int i, n, h;
    char str[L], com[9];
    for (int i = 0; i < M; ++i)
    {
        H[i][0] = '\0';
    }
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%s %s", com, str);
        if(com[0] == 'i')
            insert(str);
        else
        {
            if(find(str))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 16072
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  bool ok=true;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i))ok=false;
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
S =input()
ans_list = []
if len(S) == 1:
    print(int(S))
else:
    for i in range(2**(len(S)-1)):
        comb = bin(i)[2:].zfill(len(S)-1)
        num_list = []
        num = S[0]
        for i in range(len(comb)):
            if comb[i] == "1":
                num_list.append(int(num))
                num = S[i+1]
            else:
                num += S[i+1]
        num_list.append(int(num))
        ans_list.append(sum(num_list))
    print(sum(ans_list))

Measured memory_bytes: 3064
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;

int main(void){
    char s[28];
    bool ans = true;
    cin >> s;
    for (int i = 0; s[i] != '\0'; i++) {
        for (int j = i + 1; s[j] != '\0'; j++) {
            if (s[i] == s[j]) ans = false;
        }
    }
    if (ans) cout << "yes";
    else cout << "no";
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int n = sc.nextInt();
    int ans = 0;
    
    for(int i = 0; i <= n; i++){
	  for(int j = 0; j <= n; j++){
        if(r * i + g * j > n) continue;
        if((n - r * i - g * j) % b == 0) ans++;
      }
    }
    
    System.out.println(ans);
    
  }
  
}


Measured memory_bytes: 35812
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
// FOR VIEWERS, CODE STARTS HERE

int main()
{
    //#ifndef ONLINE_JUDGE
     //freopen("input.txt","r",stdin);
     //freopen("output.txt","w",stdout);
    //#endif
    FIO;
    ll t, q, n, m, prev, maxx,  i, j, k1, k2, k3, k, x, y, flag, sum, cnt, ans;
    cin>>n;
    if( n%2)
    {
        cout<<0<<endl;
    }
    else
    {
        ans = 0;
        k = n/2;
        while( k > 0)
        {
            ans+=k/5;
            k/=5;
        }
        cout<<ans<<endl;
    }
    return 0;    
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int n;
    cin >> n;
    
    vector<int> a(n+1);
    a[0] = 0;
    
    rep(i,n){
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    
    int ans = 1e15;
    reps(i,1,n-1){
        ans = min(ans, abs((a[i])-(a[n]-a[i])));
    }
    
    cout << ans << endl;
}

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

int main() {
	std::string s;
	std::cin >> s;
	std::cout << s[0] << s.size() - 2 << s[s.size() - 1] << std::endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int modPow(long long a, long long n, long long p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

int main()
{
    string s;
    cin >> s;

    ll n = s.size();

    ll l = 0;
    ll r = 0;
    ll M,m;
    ll ans = 0;

    rep(i,n-1){
        if(s[i] == '>' && s[i+1] == '<'){
            r++;
            M = max(l,r);
            m = min(l,r);
            ans+=(M*(M+1)/2 + m*(m-1)/2);
            l = 0;
            r = 0;
            continue;
        }
        if(s[i] == '<') l++;
        else r++;
    }

    if(s[n-1] == '<') l++;
    else r++;

    M = max(l,r);
    m = min(l,r);
    ans+=(M*(M+1)/2 + m*(m-1)/2);

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

Measured memory_bytes: 900
class Dice:
    def __init__(self,num):
        self.num = num.copy()
        
    def east(self):
        temp = self.num.copy()
        self.num[1-1] = temp[4-1]
        self.num[4-1] = temp[6-1]
        self.num[6-1] = temp[3-1]
        self.num[3-1] = temp[1-1]

    def north(self):
        temp = self.num.copy()
        self.num[1-1] = temp[2-1]
        self.num[2-1] = temp[6-1]
        self.num[6-1] = temp[5-1]
        self.num[5-1] = temp[1-1]

    def south(self):
        temp = self.num.copy()
        self.num[1-1] = temp[5-1]
        self.num[5-1] = temp[6-1]
        self.num[6-1] = temp[2-1]
        self.num[2-1] = temp[1-1]

    def west(self):
        temp = self.num.copy()
        self.num[1-1] = temp[3-1]
        self.num[3-1] = temp[6-1]
        self.num[6-1] = temp[4-1]
        self.num[4-1] = temp[1-1]

    def right(self):
        temp = self.num.copy()
        self.num[2-1] = temp[4-1]
        self.num[4-1] = temp[5-1]
        self.num[5-1] = temp[3-1]
        self.num[3-1] = temp[2-1]

    def same(self,dice):
        for _ in range(20):
            self.north()
            for _ in range(20):
                self.east()
                for _ in range(20):
                    self.right()
                    if self.num == dice: return True
        return False

diff = True
n = int(input())
dices = []
for _ in range(n):  dices.append(Dice(list(map(int,input().split()))))
for i in dices[1:]: diff = diff and not(dices[0].same(i.num))
if diff: print("Yes")
else: print("No")
            
    



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

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod	%1000000007
#define FOR(I,N) for(I=0;I<N;++I)

int main()
{
	ll n,k,j,i,f;
	cin>>n;
	ll a[n];
	ll dp[n][n];
	FOR(i,n)
	{
		cin>>a[i];
		dp[i][i]=a[i];
	}
	for(k=1;k<n;++k)
	for(j=k;j<n;++j)
	{
		i=j-k;
		dp[i][j]= max((a[i]-dp[i+1][j]), (a[j]-dp[i][j-1]));
	}
	cout<<dp[0][n-1];
}

Measured memory_bytes: 70528
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 200005;
const ll mod = 10;
const ll INF = 0x3f3f3f3f;
const double eps = 1e-9;

char s[maxn];

int main()
{
    scanf("%s",s);
    int len=strlen(s);
    for(int i=0;i<len-1;i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}

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

int main()
{
	int N;
	string s, t;
	cin >> N >> s >> t;

	int ans = N * 2;
	for( int i = 0; i < N; i++ ) {
		string sub = s.substr( i, N - i );
		if( sub == t.substr( 0, N - i ) ) {
			ans = i + N;
			break;
		}
	}

	cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  vector<int64_t> l(n+1);
  for(int i=0;i<=n;i++){
    if(i==0) l.at(i)=2LL;
    else if(i==1) l.at(i)=1LL;
    else l.at(i)=l.at(i-1)+l.at(i-2);
  }
  printf("%lld\n",l.at(n));
}

Measured memory_bytes: 256
import sys

def check_prime(n):
    for i in range(2, n):
        if n%i == 0:
            return False
    return True

for line in sys.stdin:
    ans = ''
    for i in range(int(line)-1, 1, -1):
        c = check_prime(i)
        if c == True:
            ans += str(i)
            break
    for i in range(int(line)+1, int(line)*2+1):
        c = check_prime(i)
        if c == True:
            ans += ' '
            ans += str(i)
            break
    print(ans)



Measured memory_bytes: 5592
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	A, B, C = map(int, input().split(" "))
	
	ans = 0;
	aa = max(A, B, C)
	ans += aa * 10
	
	print(ans + A + B + C - max(A, B, C))
		
	
if __name__ == "__main__":
	main()


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

int data[101];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	while(cin >> n){
		data[n]++;
	}

	int m = 0;
	for(int i = 1; i <= 100; ++i){
		m = max(data[i], m);
	}

	for(int i = 1; i <= 100; ++i){
		if(data[i] == m){
			cout << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll a[2][n];rep(i,0,1)rep(j,0,n-1)cin>>a[i][j];
    ll ans=0;
    rep(i,0,n-1){
        ans+=max(0,a[0][i]-a[1][i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define MOD 1000000007
 
int main(){
    int N; cin >> N;
    int H[N]; rep(i,N) cin >> H[i];

    bool flag[N-1]; rep(i,N) flag[i] = false;
    rep(i,N-1) if(H[i] >= H[i+1]) flag[i] = true;
    int cnt = 0; int mx = 0;
    rep(i,N-1){
        if(flag[i]) cnt++;
        else{
            if(cnt >= mx) mx = cnt;
            cnt=0;
        }
    }
    if(mx <= cnt) mx = cnt;
    cout << mx;

}


Measured memory_bytes: 768
use std::io;

fn work() -> &'static str {
  let mut line = String::new();
  io::stdin().read_line(&mut line).expect("");
  line = "".to_string();
  io::stdin().read_line(&mut line).expect("");
  let v: Vec<i32> = line.split_whitespace().map(|x| x.parse::<i32>().expect("")).collect();

  let mut i = 0;
  let mut c = 0;
  for x in v {
    i = i + 1;
    if x != i {
      c = c + 1;
    }
  }

  if c == 0 || c == 2 {
    return "YES";
  }
  return "NO";
}

fn main() {
  print!("{}\n", work());
}


Measured memory_bytes: 4352
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'


using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

const double PI = acos((double)-1);
const double eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

int n, m, q;

int kek[11];

const int N = 51;

int a[N], b[N], c[N], d[N];

ll ans = 0;

void gen(int i = 0, int last = 1) {
	if (i == n) {
		ll su = 0;
		for (int i = 0; i < q; i++) {
			if (kek[b[i]] - kek[a[i]] == c[i])
				su += d[i];
		}
		ans = max(ans, su);
	}
	else {
		for (int j = last; j <= m; j++) {
			kek[i] = j;
			gen(i + 1, j);
		}
	}
}


void solve() {
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}
	gen();
	cout << ans << endl;
	return;
}

Measured memory_bytes: 3628
n = int(input())
monsters = list(map(int, input().split()))

mm = 0
while len(monsters) != 1:
    monsters.sort()
    mm = monsters[0]
    monsters = list(map(lambda x:x % mm, monsters))
    monsters[0] = mm
    monsters = list(filter(lambda x:x != 0, monsters))
print(mm)


Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll h[N+1];
    ll i;
    for (i=1;i<=N;i++){
      cin >> h[i];
    }
    h[0]=h[1];
    ll dp[N];
    dp[0] = dp[1] = 0;
    for(i=2;i<=N;i++){
      dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      if(dp[i]>dp[i-2]+abs(h[i]-h[i-2]))dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
    }
    cout << dp[N];
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = [int(i) - 1 for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]


lastEatIdx = -999
ans = 0
for eatIdx in A:
    ans += B[eatIdx]
    if eatIdx == lastEatIdx + 1:
        ans += C[lastEatIdx]
    lastEatIdx = eatIdx

print(ans)


Measured memory_bytes: 3060
n, k = gets.to_s.split.map{|t| t.to_i }
v    = gets.to_s.split.map{|t| t.to_i }

rev = v.reverse

s_a = 0
ans = 0
(n+1).times do |a|
  
  s_a += v[a-1] if a > 0
  s = s_a
  [n-a+1, k-a+1].min.times do |b|
    s += rev[b-1] if b > 0
    q = v[0, a] + rev[0, b]
    q.sort!
    rem_k = [a+b, k-a-b].min
    toridasu = 0
    rem_k.times{|i| q[i] < 0 ? (toridasu += q[i]) : break }
    ans = s - toridasu if ans < s - toridasu
  end
end

puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

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

	if (a + b > 9) cout << "error" << endl;
	else cout << a + b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    vl ss,ns;
    rep(i,7) {
        ss.push_back(pow(6,i));
        ns.push_back(pow(9,i));
    }
    ll n;cin>>n;
    int ans =INF;
    rep(i,n+1){
        ll sp=i,np=n-i;
        int sum =0;
        ll sn=ss[6];
        while(sn>1){
            sum+=sp/sn;
            sp%=sn;
            sn/=6;
        }
        sum+=sp;
        
        ll nn=ns[6];
        while(nn>1){
            sum+=np/nn;
            np%=nn;
            nn/=9;
        }
        
        sum+=np;
        ans=min(ans,sum);
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3972
#include<iostream>
using namespace std;
long long T,H,W;
long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	cin>>T;
	for(int i=0;i<T;i++){
		cin>>H>>W;
		int B=gcd(H,W);
		H/=B;W/=B;
		if((H+W)%2==1){cout<<"1 1"<<endl;}
		else{cout<<(H*W+1)/2<<' '<<(H*W-1)/2<<endl;}
	}
	return 0;
}

Measured memory_bytes: 3048
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int h, w;
string s[101];

int main() {
  cin >> h >> w;
  rep(i, h) cin >> s[i];

  solve();

  return 0;
}

void solve() {

  rep(i, h) {
    cout << s[i] << endl << s[i] << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    string s;cin >> s;
    if(*s.rbegin()=='s')s+="es";
    else s+='s';
    cout << s <<endl;
}

Measured memory_bytes: 3624
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, m, d;
  cin >> n >> m >> d;

  double rec;

  if(d == 0) rec = (m - 1) / (double) n;
  else rec = 2 * (n - d) / (double) n * (m - 1) / (double) n;

  cout << std::fixed << std::setprecision(8) << rec << endl;

  return 0;

}


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

using namespace std;
int32_t main()
{  int k,a,b;
cin >> k >> a >> b;
bool poss=false;
for(int i=a; i<=b; i++)
{ if(i%k==0)
{ poss=true;
break;
}
}
if(poss)
{ cout << "OK" << endl;
}
else
{

    cout << "NG" << endl;
}

    return 0;
}


Measured memory_bytes: 3548
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<cstdint>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
int main(){
      ll N;
      cin>>N;
      ll A[N];
      rep0(i,N) cin>>A[i];
      ll S=0;
      rep0(i,N) S+=A[i];
      if(S%((N*(N+1))/2)){
            cout<<"NO"<<endl;
            return 0;
      }
      S/=((N*(N+1))/2);
      bool ok=true;
      rep0(i,N){
            if((A[i%N]-A[(i+1)%N]+S)%N){
                  ok=false;
                  break;
            }
            ll b=(A[i%N]-A[(i+1)%N]+S)/N;
            if(b<0){
                  ok=false;
                  break;
            }
      }
      //rep0(i,N) cout<<b[i]<<" ";
      //cout<<endl;
      cout<<((ok)?"YES":"NO")<<endl;
      return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, P;
	cin >> N >> P;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	ll odd = 0;
	REP(i, N) if(A[i]%2==1) odd++;
	if(odd==0 && P==1){
		cout << 0 << endl;
		return 0;
	}
	ll res = 1;
	REP(i, N-odd) res *= 2;
	REP(i, odd-1) res *= 2;
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 5e4+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
//#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n;
    cin>>n;
    map<int,ll> mp;
    ll arr[n];
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        arr[i]=x;
        mp[x]++;
    }
    ll ans=0;
    for(auto x: mp){
        ll temp=x.second;
        ans=ans+(temp*(temp-1))/2;
    }
    for(int i=0;i<n;i++){
        ll temp=mp[arr[i]];
        cout<<ans-(temp*(temp-1))/2+((temp-1)*(temp-2))/2<<endl;
    }
}

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

typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

void solve(){
	
}

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin>>n;
    string s; cin>>s;
    int cr, cw;
    cr = count(all(s), 'R');
    cw = count(all(s), 'W');
    if (cr == n || cw == n){
        cout<<0<<'\n';
        return 0;
    }
    int l,r;
    r = n-1;
    
    int ans = 0;
    for (l = 0; l<n && l<r; l++){
        if (s[l] == 'W'){ //not good
            while(s[r] == 'W' && l<r){
                r--;
            }
            if (l<r){
                swap(s[l], s[r]);
                r--;
                ++ans;
            }
        }
    }
    cout<<ans<<'\n';
	return 0;
}
/*
NARCO
*/


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

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (ll)a * (ll)b / (ll)euclid(a, b);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    cin >> n;
    vec(a,n);
    vector<int> b;
    input(a,n);
    REP(i,n){
        b.push_back(a[i]);
        Sort(b);
        int tmp = b.size();
        REP(j,n){
            if(j<tmp){
                cout << b[j];
            }
            else{
                cout << a[j];
            }
            if(j != n-1){
                cout << " ";
            }
        }
        cout << endl;
    }

    


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

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



Measured memory_bytes: 3096
#include<stdio.h>
#include <cmath>
#include<string.h>
#include <iostream>
#include <algorithm>
using namespace std;
int op(int x) {
    if (x == 0) {
        return 1;
    }
    if (x == 1) {
        return -1;
    }
}
string ans(int bit) {
    if (bit == 0) {
        return "+";
    }
    if (bit == 1) {
        return "-";
    }
}
int main() {
    string s; cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    int t;
    int bit;
    for(bit=0;bit < (1<<4);bit++) {
        t = a + b*op((bit >> 1) & 1) + c*op((bit >> 2) & 1) + d*op((bit >> 3) & 1);
        if (t == 7) {
            cout << a << ans((bit >> 1) & 1) << b << ans((bit >> 2) & 1) << c << ans((bit >> 3) & 1) << d << "=" << 7 << endl;
            break;
        }
    }
    
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


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

    int use = max(h,w);
    int now = 0;
    int ans = 0;
    while(now < n) {
        now += use;
        ans++;
    }

    cout << ans << endl;
    return 0;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int N,L,K,T;
  L = 0;
  K = 0;
  T = 0;
  cin >> N;
  vector<int> a(N);
  vector<int> b;
  rep(i,N){
  cin >> a.at(i);
    if(a.at(i) != 2)
      T++;
  }
  while(L < N){
    if(T == N){
     cout << "-1" << endl;
      break;
    }   
    if(L == N-1){
    cout << "-1" << endl;
      break;
    }
   b.push_back(a.at(K));
    if(b.at(L) == 2){
      cout << L+1 << endl;
     break;
    }
   K = b.at(L)-1;
    L++;
  }
 
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(M);
  vector<int> d(M);
  for(int i=0; i<N; i++) cin >> a.at(i) >> b.at(i);
  for(int i=0; i<M; i++) cin >> c.at(i) >> d.at(i);
  for(int i=0; i<N; i++){
    int ans=0;
    int dist = 400000001;
    for(int j=0; j<M; j++){
      int diss = abs(a.at(i)-c.at(j)) + abs(b.at(i)-d.at(j));
      if(dist>diss){
        dist=diss;
        ans=j+1;
      }
    }
    cout << ans << endl; 
  }

}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin –2147483648
#define llmax 9223372036854775807
#define llmin -9223372036854775808
using namespace std;

int n, t, a1, a2;
ll cnt;

int main(){
	cin >> n >> t;
	cnt = t;
	a1 = 0;
	lp(n) {
		cin >> a2;
		cnt += t;
		if (a2 - a1 < t)cnt -= t + a1 - a2;
		a1 = a2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
   double q;
   while(scanf("%lf", &q)!= EOF && q != -1) {
       double x, a;      
       x=q/2;      
           while(1){
               if(fabs(x*x*x-q)<0.00001*q) break;
               x=x-((x*x*x-q)/(3*x*x));
               x = x;
           }          
           printf("%.7f\n",x);    
           }    
               
       return 0; 
}



Measured memory_bytes: 2032
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
int main(){
  int n;
  scanf("%d",&n);
  long h[100000];
  for(int i=0;i<n;i++){
    scanf("%ld",&h[i]);
  }
  for(int i=n-2;i>=0;i--){
    if(h[i] > h[i+1]){
      h[i] -= 1;
    }
  }
  int flag = 0;
  for(int i=0;i<n-1;i++){
    if(h[i] > h[i+1]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 896
#include <iostream>

typedef long long ll;

int main()
{
  ll n;
  std::cin >> n;

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ll a, b;
    std::cin >> a >> b;
    ans += b - a + 1;
  }

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

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  READ(S);

  // output
  WRITE_N(S[1] == 'B' ? "ARC" : "ABC");

  return 0;
}


Measured memory_bytes: 3640
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.01 00:26:09
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    ll a,b;cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3636