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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, K, ans=1e18;

	cin >> N >> K;

	ans = N;
	N = (N % K);
	chmin(ans, N);
	N = abs(N - K);
	chmin(ans, N);
	N = abs(N - K);
	chmin(ans, N);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from statistics import *
from collections import *
from operator import itemgetter
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b = na()
ans = 0
for i in range(a, b+1):
    s = str(i)
    if s == s[::-1]:
        ans += 1
print(ans)

Measured memory_bytes: 5276
import collections

n = int(input())

array = [int(x) for x in input().split()]

count = collections.Counter(array)
count_values = list(count.values())
if count_values.count(1) >= len(count_values) - 1:
    print(0)
else:
    count = list(sorted(count.items(), key=lambda x: x[0], reverse=True))
    res_count = []
    for i in count:
        if i[1] != 1:
            res_count.append(i)
    if res_count[0][1] >= 4:
        print(res_count[0][0] ** 2)
    else:
        print(res_count[0][0] * res_count[1][0])


Measured memory_bytes: 23204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int n=a/d;
    if(a%d!=0)
    {
        n++;
    }
    int m=c/b;
    if(c%b!=0)
    {
        m++;
    }
    if(m>n)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    



    return 0;
}

Measured memory_bytes: 3588
process.stdin.on("data",function(c){
	(c+"").trim().split("\n").some(function(n,m,h){
		n=n.split(" "),m=+n[1],n=+n[0];
		var g=function(m,n,t){
			m<n&&(t=n,n=m,m=t);
			while(n=m%(m=n));
			return m;
		};
		console.log(h=g(n,m),n*m/h);
	});
}).resume();

Measured memory_bytes: 7912
#include <stdio.h>
int main(){
  int n,out,count=0;
  scanf("%d %d",&n,&out);
  int a[n],sum=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum=sum+a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]>=(sum+(4*out)-1)/(4*out)){
      count++;
    }else{
    }
  }
  if(count>=out){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

	if (d < a || b < c) {
		cout << '0' << endl;
		return 0;
	}

	if (a < c) {
		s = c;
	}
	else {
		s = a;
	}

	if (b < d) {
		e = b;
	}
	else {
		e = d;
	}

	cout << e - s << endl;
}

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

int main()
{
  int N, K;
  int x[110000];
  int res=INF;
  cin >> N >> K;
  rep(i,N) cin >> x[i];

  rep(i,N-K+1){
    int total = 0;
    int r=i+K-1;
    if(x[i]<0 && x[r]>0){
      if(abs(x[i]) > abs(x[r]))
        total = abs(x[i]) + 2*abs(x[r]);
      else
        total = 2*abs(x[i]) + abs(x[r]);
    }
    else
      total = max(abs(x[i]), abs(x[r]));
    res = min(total, res);
  }

  cout << res << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> g {
    {1, 3, 5, 7, 8, 10, 12},
    {4, 6, 9, 11},
    {2}
};

int find(int x)
{
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j] == x) return i;
    }
  }
}

int main()
{
  int x, y;
  cin >> x >> y;
  if (find(x) == find(y)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        StringBuilder sb = new StringBuilder();
        while(t>0){
            t--;
            sb.append("ACL");
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 27060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  int64_t x=A+B;//一周の個数
  int64_t Ans;
  if(A==0){
    Ans=0;
  }
  else if(N%x<=A){
    Ans=N%x+(N/x)*A;
  }else{
 Ans=N/x*A+A;
  }
  cout<<Ans<<endl;
  
}

Measured memory_bytes: 256
n, k, *a = map(int, open(0).read().split())

for _ in range(k):
    b = [0] * -~n
    for i in range(len(a)):
        b[max(0, i - a[i])] += 1
        b[min(n, i + a[i] + 1)] -= 1
    for i in range(n):
        b[i + 1] += b[i]

    if all(x == n for x in b[:n]):
        print(*b[:n])
        exit()
    a = b
print(*a[:n])

Measured memory_bytes: 219348
//0060

#include<stdio.h>
int main(void)
{
	const int N = 10 + 1;
	int my1, my2, enemy1;
	int i, s;
	while( scanf("%d %d %d", &my1, &my2, &enemy1) == 3)
	{
		bool isUsed[N] = {false};
		isUsed[my1] = isUsed[my2] = isUsed[enemy1] = true;
		s = my1+my2;
		int count = 0;
		for(i = 1; i < N; i++)
		{
			if(!isUsed[i] && s+i <= 20)
			{
				count++;
			}
		}
		//©¦ÄÈ¢ÌÍSÅ7ÈÌÅA4Â Á½ç50ð´¦é
		puts( count>=4 ? "YES" : "NO");
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	if (len%2!=0)
	{
		cout<<"No";
		return 0;
	}
	for (int i=0;i<len-1;i+=2)
		if (s[i]!='h'||s[i+1]!='i')
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
} 

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n,m;
  cin >> n >> m;
  int a[n];
  rep(i,n) cin >> a[i];
  for(int k=1;k<=m;k++){
    rep(i,n){
      if(i<n-1){
        if(a[i]%k>a[i+1]%k){
          swap(a[i],a[i+1]);
        }
      }
    }
  }
  rep(i,n){
    cout << a[i] << endl;
  }
 
}



Measured memory_bytes: 3148
// C - Colorful Leaderboard

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	set<int> color;
	int any_color = 0;

	int a;
	for (int i=0; i<N; i++) {
		cin >> a;

		if (a <= 399) color.insert(1);
		else if (a <= 799) color.insert(2);
		else if (a <= 1199) color.insert(3);
		else if (a <= 1599) color.insert(4);
		else if (a <= 1999) color.insert(5);
		else if (a <= 2399) color.insert(6);
		else if (a <= 2799) color.insert(7);
		else if (a <= 3199) color.insert(8);
		else any_color++;
	}

	int ans1 = color.size() == 0 ? 1 : color.size();
	int ans2 = color.size() + any_color;

	cout << ans1 << " " << ans2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b&&b < c) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
    private static void debug(List<Integer> al){
        for(int xx : al) System.out.print(xx+" ");
        System.out.println();
    }
    private static void debug(int arr[]){
        for(int xx : arr) System.out.print(xx+" ");
        System.out.println();
    }
    private static void solver(InputReader sc, PrintWriter out) throws Exception {

        int x = sc.nextInt();
        if(x>=30) out.println("Yes");
        else out.println("No");
    }

    private static int lcm(int a, int b) {

        return (a * b) / gcd(a, b);
    }

    private static int gcd(int a, int b) {

        if (b == 0)
            return a;

        return gcd(b, a % b);
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

class Pair {
    int x, y;

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

class Tuple implements Comparable<Tuple> {
    int x, y, z;

    public Tuple(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public int compareTo(Tuple t) {
        if (this.z == t.z) {
            if (this.y == t.y) {
                return t.x - this.x;
            } else return t.y - this.y;
        } else
            return this.z - t.z;
    }


}

Measured memory_bytes: 32876
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >>N;
  
  int count = 0;
  //A x B + C = N
  //A x B = N - C
 
  for (int a = 1; a <= N; a++) {
    for (int b = 1; b <= N; b++) {
        
		if(a*b <= N-1){
          count++;
        }else{
        break;
        }
    }
  }
 
 
  cout << count<<endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int a = 0, b = 1000;
	REP(i, 0, 3) {
		int tmp;
		cin >> tmp;
		a = max(a, tmp);
		b = min(b, tmp);
	}
	cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        String s = sc.next();

        if (a < 3200) {
        	s = "red";
        }

        System.out.println(s);

    }

}


Measured memory_bytes: 22612
N=int(input())
dic={}
dic['AC']=0
dic['WA']=0
dic['TLE']=0
dic['RE']=0


for i in range (N):
    _=input()
    dic[_]+=1


print('AC x {0}'.format(dic['AC']))
print('WA x {0}'.format(dic['WA']))
print('TLE x {0}'.format(dic['TLE']))
print('RE x {0}'.format(dic['RE']))


Measured memory_bytes: 9200
using System;

namespace abc080_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int x = 0;
            for (int i = 0; i < s.Length; i++)
            {
                x += int.Parse(s[i].ToString());
            }
            Console.WriteLine(int.Parse(s) % x == 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

struct edge
{
    int v,w,nxt;
}e[400050];

int head[100050],ecnt;

void adde(int u,int v,int w)
{
    e[++ecnt].v = v;
    e[ecnt].w = w;
    e[ecnt].nxt = head[u];
    head[u] = ecnt;
}

int N,M;
int l[200050],r[200050];
int d[200050];
long long dist[100005];
queue<int> que;
bool vis[100050],inq[100050];

bool spfa(int st)
{
    que.push(st);
    inq[st] = true;
    dist[st] = 0;
    long long curmax = 0,curmin = 0;
    while(!que.empty())
    {
        int u = que.front();
        que.pop();
        for(int i = head[u];i;i = e[i].nxt)
        {
            int v = e[i].v;
            if(dist[v] == 12345678987654321)
            {
                dist[v] = dist[u] + e[i].w;
                curmax = max(curmax,dist[v]);
                curmin = min(curmin,dist[v]);
                if(curmax - curmin > 1000000000)
                    return false;
                vis[v] = 1;
                if(!inq[v])
                    que.push(v);
            }
            else if(dist[v] != dist[u] + e[i].w)
                return false;
        }
        inq[u] = false;
    }
    return true;
}

int main()
{
    for(int i = 1;i <= 100000; ++ i)
        dist[i] = 12345678987654321;
    scanf("%d%d",&N,&M);
    for(int i = 1;i <= M; ++ i)
    {
        scanf("%d%d%d",&l[i],&r[i],&d[i]);
        adde(l[i],r[i],d[i]);
        adde(r[i],l[i],-d[i]);
    }
    for(int i = 1;i <= N; ++ i)
    {
        if(!vis[i])
        {
            vis[i] = 1;bool l = spfa(i);
            if(!l)
            {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 9088
S = list(input())

odd = ('R','U','D')
even = ('L','U','D')

for i in range(len(S)):
    if (i + 1) % 2 == 0:
        if S[i] not in even:
            print('No')
            exit()
    else:
        if S[i] not in odd:
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//    long mod = 1000000000+7;
    int cnt2 = 0;
    ArrayList<Integer>[] graph;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
        out.println(main.solve());
        out.flush();
    }
    long solve() throws IOException {
        int n = sc.nextInt(), mod = sc.nextInt();
        char[] s = sc.next().toCharArray();
        if(mod==2||mod==5) return helper(n,s,mod);
        // otherwise, the real thing
        int[] power = new int[n+1];
        power[0] = 1;
        for(int i=1;i<=n;i++) power[i] = power[i-1]*10%mod;
        int[] rec = new int[mod];
        rec[0] = 1;
        int prev = 0;
        long ans = 0;
        for(int i=n-1;i>=0;i--){
            int cur = s[i]-'0';
            prev += cur*power[n-i-1]%mod;
            prev %= mod;
            ans += rec[prev];
            rec[prev] ++;
        }
        return ans;
    }
    long helper(int n, char[] a, int mod){
        long ans = 0;
        for(int i=0;i<n;i++){
            int num = a[i]-'0';
            if(num%mod==0){
                ans += i+1;
            }
        }
        return ans;
    }

}

Measured memory_bytes: 28460
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
ans=0
for i in range(N):
  if A[i]>=B[i]:
    ans+=B[i]
  else:
    ans+=A[i]
    if A[i+1]>=B[i]-A[i]:
      ans+=B[i]-A[i]
      A[i+1]-=B[i]-A[i]
    else:
      ans+=A[i+1]
      A[i+1]=0
print(ans)

Measured memory_bytes: 81892
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    for (int x = 1; x <= b; x++) {
        if ((a * x) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
A = [*map(int, input().split())]
for i in range(k):
    B = [0]*(n+1)
    for j in range(n):
        l = max(0, j - A[j])
        r = min(n, j + A[j] + 1)
        B[l] += 1; B[r] -= 1
    for j in range(n-1): B[j+1] += B[j]
    B.pop()
    if A == B: break
    A = B
print(*A, sep=' ')


Measured memory_bytes: 163292
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

int n, m, w[200010], a[200010];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  REPE(i, 1, n) w[i] = i;
  REP(i, m) {
    int x;
    scanf("%d", &x);
    w[x] = -i;
  }
  REP(i, n) a[i] = i + 1;
  sort(a, a + n, [](int x, int y) { return w[x] < w[y]; });
  REP(i, n) printf("%d\n", a[i]);
  return 0;
}

Measured memory_bytes: 4804
unittest
{
	assert( [ "a" ].parse.expand.solve == "vowel" );
	assert( [ "z" ].parse.expand.solve == "consonant" );
	assert( [ "s" ].parse.expand.solve == "consonant" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto c = input.front;
	return tuple( c );
}

auto solve( string c )
{
	if( c == "a" || c == "e" || c == "i" || c == "o" || c == "u" ) return "vowel";
	else                                                           return "consonant";
}


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

int main(){
  int x,y;cin >> x >> y;
  int ans = -1;
  if(x<=y){
    if(ans==-1){
      ans = y - x;
    }else{
      ans = min(ans,y-x);
    }
  }
  if(-x<=y){
    if(ans==-1){
      ans = y + x+1;
    }else{
      ans = min(ans,y+x+1);
    }
  }
  if(x<=-y){
    if(ans==-1){
      ans = -y - x+1;
    }else{
      ans = min(ans,-y-x+1);
    }
  }
  if(-x<=-y){
    if(ans==-1){
      ans = -y + x+2;
    }else{
      ans = min(ans,-y+x+2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
	int n,m,i,b,a[10000];
	b=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&a[i]);
		b=b+a[i];
	}
	if(b==n) printf("0\n");
	else if(b>n) printf("-1\n");
	else printf("%d\n",n-b);
	return 0;
}

Measured memory_bytes: 1704
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int n, k;
    cin >> n;
    cin >> k;
    vector<int> x(n);
    REP(i, n) cin >> x[i];
    int sum = 0;
    REP(i, n) {
        sum += min(x[i], k-x[i])*2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long MaxTall = 0;

            long Res = 0;

            for (int i = 0; i < N; i++)
            {
                if (MaxTall > A[i])
                {
                    Res += MaxTall - A[i];
                }
                else
                {
                    MaxTall = A[i];
                }
            }

            Console.WriteLine(Res);
        }
    }
}


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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    double ans;
    if(n&1) ans = n/2 +1;
    else ans = n/2;
    cout<<fixed<<setprecision(10)<<ans/n<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n";
#define ll long long 
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define satyam ios_base::sync_with_stdio(false);
#define mishra cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
	satyam mishra
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	  int n;cin>>n;
	  int a,b,c;cin>>a>>b>>c;
	  int dp[3]={a,b,c};
	  int newdp[3]={0};
	  int nn=n-1;
	 
	  while(nn--)
	  {
	  	 int cost[3];
	  	for(int i=0;i<3;i++)
	  	{
	  		cin>>cost[i];
	  	}
	  	for(int i=0;i<3;i++)
	  	{
	  		for(int j=0;j<3;j++)
	  		{
	  			if(i!=j)
	  			{
	  				newdp[j]=max(newdp[j],cost[j]+dp[i]);
	  			}
	  		}
	  	}
	  	for(int i=0;i<3;i++)
	  	{
	  		dp[i]=newdp[i];
	  	}
	  }
	  cout<<max(dp[0],max(dp[1],dp[2]));
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int n; cin>>n;
    n = n%10;
    if(n == 3) cout<<"bon"<<endl;
    else if(n==0 or n==1 or n==6 or n==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll N;
    scanf("%lld", &N);
    ll n=N, ans=1e15;
    for(ll i=2; i*i<=n; i++) if(n%i==0) chmin(ans, i + N/i);
    if(n>1) chmin(ans, n + N/n);
    printf("%lld\n", ans-2);
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    string ans;
    int sum = 0;
    rep(i, n) {
        if(s[i] == '(') {
            sum++;
        } else {
            sum--;
        }
        if(sum < 0) {
            ans += '(';
            sum = 0;
        }
    }
    ans += s;
    rep(i, sum) {
        ans += ')';
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def diff(S, T):
    len_t = len(T)
    len_s = len(S)
    ret = 0
    for i in range(0, len_t):
        if S[i] == T[i]:
            ret += 1
    return (ret)


def main():
    S = input()
    T = input()
    len_t = len(T)
    len_s = len(S)
    max_diff = 0
    for i in range(0, len_s - len_t + 1):
        max_diff = max(max_diff, diff(S[i::], T))
    print(len_t - max_diff)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9144
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    long ans = 0;
    boolean odd = false;
    for(int i = 0; i < N; i++){
      int a = Integer.parseInt(sc.nextLine());
      
      if(a % 2 == 0){
        ans += (a / 2);
        if(!odd || a == 0){
          odd = false;
        }  
      }else{
        if(odd){
          ans += ((a+1) / 2);
          odd = false;
        }else{
          ans += (a / 2);
          odd = true;
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 93872
#include <stdio.h>

int main(void) {
int a,b,r,p1=0,p2=0;
char c[101],d[101];
scanf("%d",&a);
for(b=0;b<a;b++){
  scanf("%s %s",c,d);
for(r=0;;r++){
  if(c[r]>d[r]){
   p1+=3;
   break;}
  else if(c[r]<d[r]){
   p2+=3;
   break;}
  else if(c[r]+d[r]==0){
    p1++;
    p2++;
    break;}}}
  printf("%d %d\n",p1,p2);
  return 0;  
}


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

using namespace std;

int main() {

    int x[6];

    for (int i = 1; i <= 5; i++) {
        cin >> x[i];
    }

    for(int i = 1; i <= 5; i++) {
        if(x[i] == 0) {
            cout << i << endl;
        }
    }

    return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define maxn 100005

signed main()
{
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<bool> s;
    int ans = 0;
    int count = 0;
    for (int i = 1; i < S.length(); i++)
    {
        if (S[i] == S[i - 1])
        {
            ans++;
            continue;
        }
        count++;
    }
    count++;
    count = count / 2 + count % 2;
    if (count > K)
    {
        cout << ans + 2 * K << endl;
    }
    else
    {
        count *= 2;
        if (S[0] != S[S.length() - 1])
        {
            count--;
        }
        else
        {
            count -= 2;
        }
        cout << ans + count << endl;
    }
}


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


vector<int> A,B;

void init(){
  A.clear();
  B.clear();
}

void input(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    A.push_back(tmp);
  }
  for(int i=0;i<m;i++){
    int tmp;
    cin>>tmp;
    B.push_back(tmp);
  }
}

int vote(int v){
  for(int i=0;i<A.size();i++){
    if(A[i]<=v){
      return i;
    }
  }
  return -1;
}

int solve(){
  input();
  vector<int> ans(A.size(),0);
  for(int i=0;i<B.size();i++){
    ans[vote(B[i])]++;
  }
  
  //for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl;
  
  int res=-1,X=0;
  for(int i=0;i<ans.size();i++){
    if(X<ans[i]){
      X=ans[i];
      res=i;
    }
  }
  //cout<<X<<" "<<res<<endl;
  return res+1;
}


int main(){
  init();
  cout<<solve()<<endl;
}

Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
         
        int n = scanner.nextInt();
        int[] a = new int[n];
         
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
         
        scanner.close();
         
        int cnt = 0;
         
        int m;
        for (m = 0; (n >> m) > 0; m++);
        int[] g = new int[m];
        for (int i = 0; i < m; g[i] = (1 << (m - i - 1)), i++);
         
        for (int k = 0; k < m; k++) {
            for (int i = g[k]; i < n; i++) {
                int v = a[i];
                int j = i - g[k];
                 
                while (j >= 0 && a[j] > v) {
                    a[j + g[k]] = a[j];
                    j -= g[k];
                    cnt ++;
                }
                a[j + g[k]] = v;
            }
        }
         
        System.out.println(m);
        for (int i = 0; i < m - 1; i++) {
            System.out.print(g[i] + " ");
        }
        System.out.println(g[m - 1]);
         
        System.out.println(cnt);
         
        for (int i = 0; i < n; i++) {
            System.out.println(a[i]);
        }
    }
} 


Measured memory_bytes: 299220
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        char a = s.charAt(2);
        char b = s.charAt(3);
        char c = s.charAt(4);
        char d = s.charAt(5);
        if(a == b && c == d){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }
}

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

int main(){
    string S;
    int a,b=0;
    cin >> S;
    for (a = 0; a < S.size();a++){
      
        if(a%2==0){
            if(S.at(a) == 'R' || S.at(a) == 'U'||S.at(a) == 'D'){
                b++;
        }else{
            break;
            }
        }else if(a%2==1){
            if(S.at(a) =='L' || S.at(a) == 'U' || S.at(a) == 'D'){
                b++;
            }else{
            break;
        }

            }
    }
            if(b==S.size()){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = min(a * n, b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
int EditDistance(string s1,string s2){
    int n=s1.size();
    int m=s2.size();
    int dp[n+1][m+1];
 
    for(int i=0;i<n+1;i++){
        dp[i][0]=i;
    }
    for (int j=0;j<m+1;j++){
        dp[0][j]=j;
    }
 
    for (int i=1;i<n+1;i++){
        for (int j=1;j<m+1;j++){
            if(s1[i-1]==s2[j-1]){
                dp[i][j]=min( min(dp[i-1][j] +1, dp[i][j-1]+1) , dp[i-1][j-1]);
            }else{
                dp[i][j]=min( min(dp[i-1][j] +1, dp[i][j-1]+1) , dp[i-1][j-1]+1);
            }
        }
    }
    return dp[n][m];
}
 
int main(){
    string s1,s2;
    cin >> s1 >> s2;
 
    cout << EditDistance(s1,s2) << endl;
}


Measured memory_bytes: 7140
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
    cin >> A.at(i);
}
for (int i = 0; i < N; i++) {
    if(A[i]%2==0){
        if(A[i]%3!=0 && A[i]%5!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
}
cout<<"APPROVED"<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

int main(){
  int n;
  cin>>n;
  int cnt;
  REP(i,n){
    int temp;
    cin>>temp;
    if(i==0){
      cnt=temp;
    }else{
      cnt^=temp;
    }
  }
  if(cnt==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long A, B;
    std::cin >> A >> B;
    if (A % 2 != B % 2)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (A + B) / 2 << endl;
    }
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    py = []
    pyn = [1] * n
    for i in range(m):
        p, y = list(map(int, input().rstrip('\n').split()))
        py.append([p, y, i])
    py.sort()
    for i in range(len(py)):
        py[i][1] = pyn[py[i][0]-1]
        pyn[py[i][0] - 1] += 1
    py.sort(key=lambda x: x[2])
    for p, y, i in py:
        l = ["0"] * (6 - len(str(p)))
        l.append(str(p))
        l.append("0" * (6 - len(str(y))))
        l.append(str(y))
        print("".join(l))



if __name__ == '__main__':
    slove()


Measured memory_bytes: 64988
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vec vector
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n;
	string s;
	ll count[3] = { 0,0,0 };

	cin >> n >> s;

	if (n >= 3200)
		cout << s;
	else
		cout << "red";
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    ll n=sz(s);
    // ll dp[sz(s)+1][2];
    vector<vector<ll>> dp(sz(s),vector<ll>(2,0));
    dp[n-1][0]=s[n-1]-'0';
    dp[n-1][1]=11-s[n-1]+'0';
    rrep(i,n-2,0){
        dp[i][0]=min(dp[i+1][0]+s[i]-'0',dp[i+1][1]+s[i]-'0');
        dp[i][1]=min(dp[i+1][0]+11-s[i]+'0',dp[i+1][1]+11-s[i]+'0'-2);
    }
    // cout<<dp[0][0]<<" "<<dp[0][1]<<endl;
    cout<<min(dp[0][0],dp[0][1]);
    // rrep(i,sz(s)-1,0){

    // }
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 55964
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    string s;
    int start,gool;
    cin>>s;
    for(int i=0; i<s.size();i++){
    if(s[i]=='A'){
        start=i;
        break;
        }
        }
    for(int j=s.size()-1; j>=0; j--){
        if(s[j]=='Z'){
        gool=j;
        break;
    }
     
      }   
cout<<gool-start+1<<endl;
}

Measured memory_bytes: 640
N = int(input())

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

    return divisors

ans = make_divisors(N)
ans.sort()

while len(ans)>2:
    ans = ans[1:-1]
if len(ans)==1:
    if ans[0]<=9:
        print("Yes")
    else:
        print("No")
else:
    if ans[1]<=9:
        print("Yes")
    else:
        print("No")

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

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	ll y; cin >> y;

	rep(i, n + 1)rep(j, n + 1) {
		if (i + j > n) continue;
		int k = n - (i + j);
		ll sum = 10000 * i + 5000 * j + 1000 * k;
		if (sum == y) {
			printf("%d %d %d\n", i, j, k);
			return 0;
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

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



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int k=n/2,mx=n-1,mn=0;
    ll ans=0;

    rep(i,n-1){
        if(i%2==1){
            ans+=abs(a[k]-a[mx]);
            k=mx;
            mx--;
        }
        else{
            ans+=abs(a[k]-a[mn]);
            k=mn;
            mn++;
        }
    }

    if(n%2==1){
        ll ans2=0;
        int k=n/2,mx=n-1,mn=0;
        rep(i,n-1){
        if(i%2==0){
            ans2+=abs(a[k]-a[mx]);
            k=mx;
            mx--;
        }
        else{
            ans2+=abs(a[k]-a[mn]);
            k=mn;
            mn++;
        }
    }
    ans=max(ans,ans2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


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

	if (n < b) {
		cout << (a * n) / b - a * (n / b) << endl;
	}
	else {
		n = b - 1;
		cout << (a * n) / b - a * (n / b) << endl;
	}
}


Measured memory_bytes: 3620
#include <iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
typedef long long ll;
using namespace std;
int main() {
	ll N;
	cin >> N;
	ll p[N];
	ll sum[N];
	ll ans = 100000000000;
	for (ll i = 0; i < N; ++i) {
		cin >> p[i];
		sum[i] = 0;
      while(p[i]%2==0){
			sum[i]++;
        p[i]=p[i]/2;
      }
        }

	for (ll i = 0; i < N; ++i) {
		ans = min(sum[i], ans);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  std::map<ll, ll> mp;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    mp[va[i]]++;
  }

  ll all_cnt = 0LL;
  for (auto p : mp) {
    all_cnt += p.second * (p.second - 1) / 2;
  }

  for (ll i = 0; i < N; i++) {
    print(all_cnt - mp[va[i]] + 1);
  }

  return;
}

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



Measured memory_bytes: 12032
# _*_ coding:utf-8 _*_
#  Atcoder_Beginner_Contest047-B
#  TODO https://atcoder.jp/contests/abc047/tasks/abc047_b

def solveProblem(XLine,YLine,PointCounter):
	graphPaper = [[1 for _ in range(0,YLine,+1)] for _ in range(0,XLine,+1)]
	xplot = list()
	yplot = list()
	processSelect = list()
	for _ in range(0,PointCounter,+1):
		xplotEach,yplotEach,processSelectEach = map(int,input().strip().split(' '))
		xplot.append(xplotEach)
		yplot.append(yplotEach)
		processSelect.append(processSelectEach)

	for i in range(0,PointCounter,+1):
		if processSelect[i]==1:
			xrange = range(0,xplot[i],+1)
			yrange = range(0,YLine,+1)
		elif processSelect[i]==2:
			xrange = range(xplot[i],XLine,+1)
			yrange = range(0,YLine,+1)
		elif processSelect[i]==3:
			xrange = range(0,XLine,+1)
			yrange = range(0,yplot[i],+1)
		elif processSelect[i]==4:
			xrange = range(0,XLine,+1)
			yrange = range(yplot[i],YLine,+1)
		for x in xrange:
			for y in yrange:
				graphPaper[x][y]=0
	menseki=0
	for x in range(0,XLine,+1):
		for y in range(0,YLine,+1):
			if graphPaper[x][y]==1:
				menseki = menseki + 1
	answer = menseki
	return answer


if __name__ == '__main__':
	W,H,N = map(int,input().strip().split(' '))
	solution = solveProblem(W,H,N)
	print("{}".format(solution))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<string>
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define mod (ll)(1e9+7)
#define nax (ll)(1e5 + 10)
#define INFL LLONG_MAX
#define NINFL LLONG_MIN
#define INF INT_MAX
#define disp(a,n,arr) for(int i=a;i<(ll)n;i++) cout << arr[i] << " "; cout << "\n";
#define check cout << "Working\n";
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define vb vector<bool>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a) a.begin(),a.end()
using namespace std;
vl adj[nax];
vb vis(nax,false);

void dfs(ll v){
	vis[v] = true;
	for(auto u:adj[v]){
		if(!vis[u]){
			dfs(u);
		}
	}
}



int main() {
	FIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		ll n,m;
		cin >> n >> m;
		
		for(int i=0;i<m;i++){
			ll a,b,c;
			cin >> a >> b >> c;
			adj[a].pb(b);
			adj[b].pb(a);
		}
		ll ans = 0;
		for(int i=1;i<=n;i++){
			if(!vis[i]){
				ans++;
				dfs(i);
			}
		}
		cout << ans << "\n";
	}	


	return 0;
}


Measured memory_bytes: 12268
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])
    
r = n
ls = sorted(ls, key=lambda item: item[1])
for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      r -=1
        
print(r)

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

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

    if ((a <= b && b <= a + w) || (a <= b + w && b + w <= a + w)) {
        cout << 0 << endl;
        return 0;
    }
    
    cout << min(abs(b - (a + w)), abs(a - (b + w))) << endl;
}   

Measured memory_bytes: 256
#[test]
fn test_solve() {
   assert_eq!(solve("<>>\n"), "3\n");
   assert_eq!(solve("<>>><<><<<<<>>><\n"), "28\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let s: Vec<char> = sc.get().chars().collect();
    let n = s.len() + 1;
    let mut a = vec![0; n];
    
    for i in 0..n-1 {
        if s[i] == '<' {
            a[i+1] = a[i] + 1;
        }
    }
    for i in (0..n-1).rev() {
        if s[i] == '>' {
            a[i] = std::cmp::max(a[i], a[i+1] + 1);
        }
    }

    let sum: usize = a.iter().sum();

    format!("{}\n", sum)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 10492
import java.util.Arrays;
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            max = Math.max(max, tmp);
            min = Math.min(min, tmp);
        }
        System.out.println(max - min);
    }
}

Measured memory_bytes: 23892