akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N, T;
        {int[] a = r.ii(); N = a[0]; T = a[1];}
        int[] t = r.ii();
        long sum = T;
        for(int i = 0, t1, t2 = 0; i < N-1; i++){
            t1 = t2;
            t2 = t[i+1];
            int interval = t2-t1;
            sum += T < interval ? T : interval;     
        }
        println(sum);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

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

using namespace std;

int nbWeights, maxWeight;

int dp[2][100001];

int main(){
    for (int i = 0; i < 2; i++){
        for (int a = 0; a < 100001; a++){
            dp[i][a] = 1e9 + 1;
        }
    }

    cin >> nbWeights >> maxWeight;

    dp[0][0] = 0;

    for (int i = 1; i <= nbWeights; i++){
        int weight, value;
        cin >> weight >> value;

        for (int v = 0; v <= 100000; v++){
            dp[i%2][v] = min(dp[i%2][v], dp[(i+1)%2][v]);
            if (v - value >= 0 && dp[(i+1)%2][v-value] + weight <= maxWeight){
                dp[i%2][v] = min(dp[i%2][v], dp[(i+1)%2][v-value] + weight);
            }
        }
    }

    for (int v = 100000; v >= 0; v--){
        if (dp[nbWeights%2][v] != 1e9 + 1){
            cout << v;
            break;
        }
    }

}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
char S[505];
int dp[505][505];
int dfs(int r,int l)
{
	int i,R=0;
	if(dp[r][l]!=-1)return dp[r][l];
	if(l-r<0)return 1;
	if(l-r<2)return 0;
	if(S[r]!='m'||S[l]!='w')return 0;
	for(i=r+1;i<l;i++)
		if(S[i]=='e')
			R|=dfs(r+1,i-1)&dfs(i+1,l-1);
	return dp[r][l]=R;
}
int main()
{
	scanf("%s",S);
	memset(dp,-1,sizeof(dp));
	printf("%s\n",dfs(0,strlen(S)-1)?"Cat":"Rabbit");
	return 0;
}

Measured memory_bytes: 1532
a, b, c = map(int, input().split())
if a == b == c and a%2 == 0:
  print(-1)
elif a%2 or b%2 or c%2:
  print(0)
else:
  ans = 0
  while a%2 == b%2 == c%2 == 0:
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    ans += 1
  print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int K;
    char S[100];

    scanf("%d", &K);
    
    int i;
    for(i = 0; i < 100; i++) {
        S[i] = 0;
    }
    
    scanf("%s", S);
    
    int count = 0;
    i = 0;
    while(S[i] != 0){
        count++;
        i++;
    }
    
    if(K < count) {
        for(i = 0; i < K; i++) {
            printf("%c", S[i]);
        }
        printf("...");
    } else {
        printf("%s", S);
    }

    return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long LL;
const LL N = 2e5 + 10;
const LL p = 1e9 + 7;
LL n, k;
LL res;

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

	for (; k <= n + 1; k++) {
		res = (res + (n - k + 1) * k + 1) % p;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

const int maxn = 3e4;
int u[maxn], v[maxn], r[maxn];
double w[maxn];
int p[maxn], a[maxn], b[maxn];

int find(int x) {return p[x] == x ? x : p[x] = find(p[x]);}

bool cmp(int x, int y){
	return w[x] > w[y];
}

double calc(int x1, int x2, int y1, int y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(int argc, char const *argv[])
{
	// freopen("in.txt", "r", stdin);
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%d%d", &a[i], &b[i]);
	}
	double ans = 0;
	for(int i = 0; i < m; i++){
		scanf("%d%d", &u[i], &v[i]);
		w[i] = calc(a[u[i]], a[v[i]], b[u[i]], b[v[i]]);
		r[i] = i;
		ans += w[i];
		// printf("%lf\n", w[i]);
	}
	// printf("%lf\n", ans);
	for(int i = 1; i <= n; i++) p[i] = i;
	sort(r, r+m, cmp);
	for(int i = 0; i < m; i++){
		int k = r[i];
		if(find(u[k]) == find(v[k])) continue;
		p[find(v[k])] = find(u[k]);
		ans -= w[k];
		// printf("%lf\n", w[k]);
	}
	printf("%lf\n", ans);
	return 0;
}



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

int n, m;
vector<string> dp;
vector<bool> flag;
vector<int> b = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector<int> a(10, -1);

string mymax(const string a, const string b){
	if(a.size() < b.size()) return b;
	if(a.size() > b.size()) return a;
	return max(a, b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=0; i<m; ++i){
		int t; cin >> t;
		a[b[t]] = max(a[b[t]], t);
	}
	dp.resize(n+1, "");
	flag.resize(n+1, false);
	flag[0] = true;
	for(int i=1; i<=n; ++i)
		for(int j=2; j<=7&&i-j>=0; ++j)
			if(a[j] != -1 && flag[i-j]){
				dp[i] = mymax(dp[i], dp[i-j] + to_string(a[j]));
				flag[i] = true;
			}
	cout << dp[n] << "\n";
}

Measured memory_bytes: 32000
#include "bits/stdc++.h"
using namespace std;
const int MAXN=1e5+1,OO=0x3f3f3f3f;
typedef  long long ll;
int main(){
    ll a,b; cin>>a>>b;
 ll gd=__gcd(a,b),ans=0;
 for(ll i=2;i*i<=gd;i++){
     if(!(gd%i))ans++;
     while(gd%i==0)
         gd/=i;
 }
 if(gd>1)ans++;
 cout<<++ans;
}

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

using namespace std;

string slowo;
long long int dp[3003][3003];
long long int n,i,j;

int main()
{
	cin >> n >> slowo;
	dp[0][0]=1;
	for(i=1;i<n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(slowo[i-1]=='<'){
                dp[i][j]=(dp[i-1][0]-dp[i-1][j]+1000000007)%1000000007;
			}
			else{
                dp[i][j]=dp[i-1][j];
			}
		}
		for(j=i;j>=0;j--){
            dp[i][j]=(dp[i][j]+dp[i][j+1])%1000000007;
		}
	}
	cout << dp[n-1][0];
}


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

int n;
string s[100010];
map<string, int > cnt;

void solve(){
    long long ans=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s[i];
        sort(s[i].begin(), s[i].end());
        //cout<<s[i]<<endl;
        ans+=cnt[s[i]];
        cnt[s[i]]+=1;
    }
    cout<<ans<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 18176
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String[] S = new String[101];
		String[] ss = new String[N];
		int[] P = new int[101];
		for( int i=0; i<N; i++ ){
			String str = sc.next();
			int a = sc.nextInt();
			S[a] = str;
			P[a] = i+1;
			ss[i] = str;
		}
		Arrays.sort(ss);
		for( int i=0; i<N; i++ ){
			for( int k=100; k>=0; k-- ){
				if( ss[i].equals(S[k]) && !(S[k].equals("A")) ){
					S[k] = "A";
					System.out.println(P[k]);
					break;
				}
			}			
		}
	}
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = -INFL;
    chmax(ans, a*c);
    chmax(ans, a*d);
    chmax(ans, b*d);
    chmax(ans, b*c);
    cout << ans << endl;
}

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

const int LIM(1000000007);
int n, m;
long long dp[3001][3001][2];


int main()
{
	long long ans(0ll);
	
	scanf("%d%d", &n, &m);
	dp[0][0][1] = 1ll;
	for (int i = 1; i <= n; ++i)
		dp[0][i][0] = 1ll;
	for (int i = 1; i <= m; ++i) {
		dp[i][0][1] = dp[i - 1][0][1] + dp[i - 1][1][0] + dp[i - 1][1][1];
		dp[i][1][0] = n == 1 ? 0ll : dp[i - 1][1][0] + dp[i - 1][2][0];
		dp[i][1][1] = dp[i - 1][0][1] + dp[i - 1][1][0] + (dp[i - 1][1][1] << (n != 1)) + dp[i - 1][2][1];
		for (int j = 2; j < n; ++j) {
			dp[i][j][0] = dp[i - 1][j - 1][0] + (dp[i - 1][j][0] << 1) + dp[i - 1][j + 1][0];
			dp[i][j][1] = dp[i - 1][j - 1][1] + (dp[i - 1][j][1] << 1) + dp[i - 1][j + 1][1];
		}
		if (n != 1) {
			dp[i][n][0] = dp[i - 1][n - 1][0] + dp[i - 1][n][0];
			dp[i][n][1] = dp[i - 1][n - 1][1] + dp[i - 1][n][1];
		}
		for (int j = 0; j <= n; ++j) {
			dp[i][j][0] >= LIM && (dp[i][j][0] %= LIM);
			dp[i][j][1] >= LIM && (dp[i][j][1] %= LIM);
		}
	}
	for (int i = 0; i <= n; ++i) {
		ans += dp[m][i][1];
		ans >= LIM && (ans -= LIM);
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 140928
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] head = br.readLine().split(" ");
    int n = Integer.parseInt(head[0]);
    int p = Integer.parseInt(head[1]);
    String s = br.readLine();
    br.close();

    int[] s_num = new int[n];
    for(int i = 0; i < n; i++){
      s_num[i] = s.charAt(i) - '0';
    }

    long answer = 0;
    if(p == 2 || p == 5){
      for(int i = 0; i < n; i++){
        if(s_num[i] % p == 0){
          answer += i + 1;
        }
      }
    } else {
      int[] count_of_remain = new int[p];
      Arrays.fill(count_of_remain, 0);
      count_of_remain[0] = 1;
      int pow = 0;
      int num = 0;
      for(int i = n - 1; i >= 0; i--){
        num = num + (s_num[i] * modpow(10, pow, p));
        num = num % p;
        answer += count_of_remain[num];
        count_of_remain[num]++;
        pow++;
      }
    }
    System.out.println(answer);
  }

  static int modpow(int a, int n, int mod){
    int res = 1;
    while(n > 0){
      if((n & 1) == 1){
        res = res * a % mod;
      }
      a = a * a % mod;
      n >>= 1;
    }
    return res;
  }
}


Measured memory_bytes: 37480
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			return;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			return;
		}
	}
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3652
S = gets.chomp

sum1 = 0
sum2 = 0

S.size.times do |i|
  if i.even?
    # 0, 2, 4..
    sum1 += 1 if S[i] == '1'
    sum2 += 1 if S[i] == '0'
  else
    sum1 += 1 if S[i] == '0'
    sum2 += 1 if S[i] == '1'
  end
end

if sum1 > sum2
  puts sum2
else
  puts sum1
end

Measured memory_bytes: 3964
N,T=map(int,input().split())
cmin = None
for i in range(N):
    c,t=map(int,input().split())
    if t > T :
        pass
    else :
        if not cmin :
            cmin = c
        elif c < cmin :
            cmin = c
    

if not cmin :
    print("TLE")
else:
    print(cmin)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int []a = new int[n];

		for (int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}

		int xor = a[0];
		for (int i=1; i<n; i++){

			xor ^= a[i];
		}

		StringBuffer sb = new StringBuffer();
		for (int i=0; i<n; i++){

			if (i > 0) {
				sb.append(" ");
			}
			sb.append(xor ^ a[i]);
		}
		System.out.println(sb.toString());
	}

}

Measured memory_bytes: 60620
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

const INF = math.MaxInt64

func main() {
	sc.Split(bufio.ScanWords)
	n, k := readInt(), readInt()

	h := make([]int, n)
	dp := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = readInt()
	}
	dp[0] = 0
	for i := 1; i < n; i++ {
		cost := INF
		for j := k; j > 0; j-- {
			if i-j >= 0 {
				cost = min(cost, dp[i-j]+abs(h[i]-h[i-j]))
				dp[i] = cost
			}
		}
	}
	fmt.Println(dp[n-1])
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;

    cout << N * N * N << endl;


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    ll ans=0;
    rep(i,n){
        ll tmp;
        cin>>tmp;
        ans += tmp-1;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using ll=long long;
#define endl "\n"
#define F(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ALL(v) v.begin(),v.end()
void solve(){
    
    ll n,cnt=0;
    cin>>n;
    ll A[n];
    F(i,n)  cin>>A[i];

    rep(i,1,n-1){
        ll chk=0;
        if(A[i]<A[i-1] && A[i]<A[i+1]) chk=1;
        if(A[i]>A[i-1] && A[i]>A[i+1]) chk=1;

        if(!chk)                       cnt++;
    }

    cout<<cnt;
}
signed main(){
    fast;
     
    solve();
 
    return 0;
}


Measured memory_bytes: 256
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/
 
 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
 int gcd(int a,int b){
 	if(b==0) return a;
 	return gcd(b,a%b);
 }
 

signed main()
{
 
    fast;
    int n,m;
    cin >> n ;
    readarr(a,n-1);
    vi c(n+1);
    loop(i,n-1) c[a[i]]++;
    loop(i,n) cout<<c[i+1]<<endl;
    return 0;
}

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

public class Main {
	public static void main(String args[])throws IOException {
		//BufferedReader??§??????????????????input??????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String str;
		str = br.readLine();
		char c;
		
		//??????????????????????????????
		for(int count=0;count<str.length();count++){
			c = str.charAt(count);
			// ??§???????????¨???true
			if (Character.isUpperCase(c)) {
				//?°????????????????
				//String???????????´???????°????????????????
				sb.append(String.valueOf(c).toLowerCase());
			} else {
				//??§???????????????
				//String???????????´????????§???????????????
				sb.append(String.valueOf(c).toUpperCase());
			}
		}
		System.out.println(new String(sb));
	}
}

Measured memory_bytes: 24796
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    if( (s[0] == s[1] and s[1] == s[2]) || (s[1] == s[2] and s[2] == s[3]) ){
        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 sc = new Scanner(System.in);

		while(sc.hasNext()) {

			int height = Integer.parseInt(sc.next());
			int width  = Integer.parseInt(sc.next());

			if(height == 0 && width == 0) {
				break;
			}

			for(int i = 0; i< height;i++) {

				for(int j = 0; j <width;j++) {

					if((j+i) %2 == 0) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}

				}
				System.out.println();
			}

			System.out.println();



		}


		sc.close();
	}

}


Measured memory_bytes: 34704
#include <inttypes.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t K, X;
    intmax_t ans = 0;

    scanf("%jd%jd", &K, &X);

    if (500 * K >= X)
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int n2 = N / 2;
		int n3 = N / 3;
		int amari = N % 3;
		if (amari == 0) {
			System.out.println(N / 3);
		} else if (amari == 1) {
			System.out.println(N / 3);
		} else if (amari == 2) {
			System.out.println(N / 3);
		}
	}
}

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

int main(){

	bool is_prime[1000000];
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<1000000;i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_prime[j]=false;
			}
		}
	}

	int n_prime[1000000];
	
	int cnt=0;
	for(int i=0;i<1000000;i++){
		if(is_prime[i]){
			cnt++;
		}
		n_prime[i]=cnt;
	}
	
	while(true){
	int n;
	cin>>n;
	
	if(cin.eof())
		break;
	
	cout<<n_prime[n]<<endl;
	}

	return 0;
}

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

vector<int> precompute(const int& n) {
// Time Complexity: O(N)
// Space Complexity: O(N)
vector<bool> is_c(n+1);
vector<int> g(n + 1);
vector<int> p;
g[1] = 1;
for (int i = 2; i <= n; ++i) {
  //cout << i << endl;
  if (!is_c[i]) {
  p.push_back(i);
  g[i] = 2;
    int k = i;
    while ((long long)k * i<= n) {
      g[k * i] = g[k] + 1;
      k *= i;
    }
  }
  for (int j = 0; j < p.size() && p[j] * i <= n; ++j) {
    is_c[i * p[j]] = true;
    // for mobius function:
    // g[i] * (i % p[j] ? g[p[j]] : 0)
    if (i % p[j]) g[i * p[j]] = g[i] * g[p[j]];
    else {
      int x = i;
      while (x % p[j] == 0) x /= p[j];
      g[i * p[j]] = g[x] * g[i * p[j] / x];
    }
    if (i % p[j] == 0) break;
   }
}
return g;
}

int main() {
  int n;
  cin >> n;
  auto t = precompute(n);
  //for (int i: t) cout << i << ' ';
  long long ans(0);
  for (long long i = 1; i <= n; ++i) ans += i * t[i];
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

//1~xのxorを計算
ll xorr(ll x){
    ll tmp=(x+1)/2;
    if(x%2==0){
        if(tmp%2==0) return x;
        else return 1^x;
    }
    else{
        if(tmp%2==0) return 0;
        else return 1;
    }
}

int main(){
	ll A,B; cin>>A>>B;
    
	printf("%lld",xorr(B)^xorr(A-1));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<string, vector<string>, less<string> > QUE_string;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<char, vector<char>, less<char> > QUE_char;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int MAX = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N);
  vector<vector<int>> vec(MAX, vector<int>());
  //map<int, QUE_int> mp;
  //map<int, int> mp;
  QUE_int can_work_que;//i日目にやってよい仕事の報酬を入れていく(考え方としては最終日にやる仕事から考えていくよ)
  for(int i=0; i<N; i++){
    //cin >> A.at(i) >> B.at(i);
    int a, b;
    cin >> a >> b;
    vec.at(a).emplace_back(b);
    //mp[a].emplace(b);
    //if(mp[a]<b) mp[a] = b;
  }
  
  //ちゃんと取得できたか確認
  /*for(int i=0; i<5; i++){
    cout << "i: " << i << " : " ;
    for(int j=0; j<vec.at(i).size(); j++){
      cout << vec.at(i).at(j) << " ";
    }
    cout << endl;
  }*/
  
  //答えを求める
  int ans = 0;
  for(int i=1; i<=M; i++){//1~M日目までループ
    //cout << "vec.at("<< i<<").size():  " <<vec.at(i).size() <<  endl;
    for(int j=0; j<vec.at(i).size(); j++){
      //cout << " i: " << i << " j: " << j << endl;
      can_work_que.push(vec.at(i).at(j));//やってよい仕事を入れていく(考え方としては最終日にやる仕事から考えていくよ)
    }
    //cout << " i: " << i << endl;
    if(can_work_que.empty()) continue;//これやらんと終了コード139になるよ
    ans += can_work_que.top();//i日目にやってよい仕事の中の最大の報酬をやる    
    //cout << "get!!: " <<can_work_que.top() << " ans: " << ans << endl;
    can_work_que.pop();//やった仕事は二度とやれないので削除
  }
  cout << ans << endl;
}



Measured memory_bytes: 6400
#include <stdio.h>
int main(void){
    int temp[31],temp1;
    int i,w,n,a,b;
    
    for(i=1;i<=30;i++) temp[i]=i;
    
    scanf("%d %d",&w,&n);
    for(i=0;i<n;i++){
        scanf("%d,%d",&a,&b);
        temp1=temp[a];
        temp[a]=temp[b];
        temp[b]=temp1;
    }
    for(i=1;i<=w;i++){
        printf("%d\n",temp[i]);
    }
    return(0);
}



Measured memory_bytes: 2032
import Data.List

main = interact $ show . sol . read

sol :: Int -> Int
sol = sum . map (f . length) . group . pf

f n = truncate $ sqrt (2*fromIntegral n+0.25)-0.5

pf 1 = []
pf n = factor n primes

factor n (p:ps) 
  | p*p > n      = [n]
  | n `mod` p==0 = p:factor (n `div` p) (p:ps)
  | otherwise    = factor n ps 

primes = sm++lg
  where
  1:p:cs  = roll $ foldl g (1,[1]) sm
  sm      = [2,3,5,7]
  lg      = p:filter pr cs
  pr n    = all ((>0) . (n `mod`)) $ takeWhile (\p -> p*p <= n) lg

roll (n,rs) = [n*k+r | k <- [0..], r <- rs]

g (n,rs) p = (p*n,[r2 | k <- [0..(p-1)], r <- rs, let r2 = n*k+r, r2 `mod` p>0])


Measured memory_bytes: 26444
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto K = s[1];
    real ans = 0;

    foreach (i; 1..N+1) {
        long x = i;
        int tmp = 0;
        while (x < K) {
            x *= 2;
            tmp += 1;
        }
        ans += 1.0L / (1L << tmp) / N;
    }

    writefln("%.15f", ans);
}


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

int main(){
    string s;
    cin >> s;
    bool flag;
    flag = true;
    rep(i,s.size()){
        if(s[0]!=s[i]) flag=false;
    }
    if (!flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;
typedef long long ll;


vector<ll> getPrimes(ll size) {
  bool isPrime[size];
  for (ll i = 0; i < size; i++) isPrime[i] = true;
  for (ll i = 2; i < size; i++) {
    if (isPrime[i]) {
      for (ll j = 2; j * i < size; j++) {
        isPrime[i * j] = false;
      }
    }
  }
  vector<ll> primes;
  for (ll i = 2; i < size; i++) {
    if (isPrime[i]) {
      primes.push_back(i);
    }
  }
  return primes;
}

vector<ll> factorize(ll n, vector<ll> &primes) {
  vector<ll> factors;
  for (ll prime : primes) {
    while (n % prime == 0) {
      n /= prime;
      factors.push_back(prime);
    }
    if (n == 1) {
      break;
    }
    if (prime * prime > n) {
      factors.push_back(n);
      break;
    }
  }
  return factors;
}

int main() {
  ll n; cin >> n;
  vector<ll> primes = getPrimes((ll)sqrt(n + 2) * 2);
  cout << n << ':'; for (ll i : factorize(n, primes)) cout << ' ' << i;
  cout << endl;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

ll n, k; mint dp[110][110000];
mint sdp[110000];
ll num[110000];

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

    ll cnt = 0;
    for(ll i = 1; i <= n; cnt++) {
        ll j = n / i;
        if (i <= j) num[cnt] = 1, i++;
        else num[cnt] = n/j - i + 1, i = n/j + 1;
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    rep(i, 0, k) {
        memset(sdp, 0, sizeof(sdp));
        rep(j, 0, cnt+1) sdp[j+1] = sdp[j] + dp[i][j];
        rep(j, 0, cnt) dp[i+1][j] = sdp[cnt - j] * mint(num[j]);
    }

    mint ans = 0;
    rep(j, 0, cnt+1) ans += dp[k][j];
    cout << ans << endl;
}

Measured memory_bytes: 96128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main(){

    int n;
    int a[10000];

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    int cnt;

    for(int i=0; i<n; i++){
        for(; a[i] % 2 == 0; cnt++){
            a[i] /= 2;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back

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


int main()
{
    Phuong_;
    int n,m;
    cin >> n >> m;
    vector<bool> a(n+1,false);
    vector<int> w(n+1,0);
    int ac=0,wa=0;
    while (m--)
    {
        int u; string s;
        cin >> u;
        cin >> s;
        if (a[u]) continue;
        if (s=="AC")
        {
            a[u]=true;
            ac++;
            wa+=w[u];
        } else if (s=="WA") w[u]++;
    }
    cout << ac << ' ' << wa;
    return 0;
}



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

int main() {
  string S;
  cin >> S;
 char a = S[0];
   char b = S[1];
   char c = S[2];
  if(a=='R' && b=='R' && c=='R'){
    cout << 3<<endl;
 }
  else if(a=='R' && b=='R' || b=='R' && c=='R'){
    cout << 2<<endl;
  }
  else if(a=='S' && b=='S' && c=='S'){
    cout<<0<<endl;
  }
  else{
    cout << 1<< endl;
  }
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> inputs(m);
	for (int i = 0; i < m; ++i)
	{
		int input;
		cin >> inputs[i];
	}

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

	vector<int> diffs(m - 1);
	for (int i = 0; i < m - 1; ++i)
	{
		diffs[i] = inputs[i+1] - inputs[i];
	}

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

	int count = 0;
	for (int i = 0; i < (m-1)-(n-1); ++i)
	{
		count += diffs[i];
	}
	cout << count << endl;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARegistration solver = new ARegistration();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARegistration {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String t = in.next();

            if (t.startsWith(s) && t.length() - s.length() == 1) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 25516
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
LL n,s;

inline bool f(LL b,LL n) {
    LL res=0;
    while (n>=b) {
        res+=n%b;
        n/=b;
    }
    if (b>n) res+=n;
    return res==s;
}
int main() {
    while (~scanf("%lld%lld",&n,&s)) {
        if (s==n) {
            printf("%lld\n", n+1);
            continue;
        }
        if (s>n) {
            puts("-1");
            continue;
        }
        LL t=sqrt(n);
        bool flag=false;
        // b<=sqrt(n)
        for (LL i=2;i<=t;i++)
            if (f(i,n)) {
                printf("%lld\n", i);
                flag=true;
                break;
            }
        if (flag) continue;

        // b>sqrt(n) b进制下只有两位
        // n=pb+q  s=p+q
        // n-s=p(b-1) => b=(n-s)/p+1
        LL ans=1e12;
        for (LL p=1;p*p<=n-s;p++) {
            if ((n-s)%p==0) {
                LL b=(n-s)/p+1;
                if (f(b,n)) {
                    flag=true;
                    ans=min(ans,b);
                }
            }
        }
        if (!flag) puts("-1");
        else printf("%lld\n", ans);
    }
    return 0;
}


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

int main()
{
    int m;
    int ini, fund, ny, n, max;
    int f, charge, i, interest, final;
    double rate;

    cin >> m;
    while(m--) {
	cin >> ini;
	cin >> ny;
	cin >> n;
	max = 0;
	while (n--) {

	    cin >> f >> rate >> charge;
	    interest = 0;
	    fund = ini;
	    for (i = 0; i < ny; i++) {
		if (f) {
		    fund += fund * rate - charge;
		} else {
		    interest += fund * rate;
		    fund -= charge;
		}
	    }
	    if (f) {
		final = fund;
	    } else {
		final = fund + interest;
	    }
	    if (max < final)
		max = final;
	}
	cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#define taskname "MST"
#include<bits/stdc++.h>
#define ll  long long
#define ld  long double
#define ull unsigned long long
#define fi  first
#define se  second
using namespace std;
typedef pair<ll,ll> LL;
const ll base   = 31;
const ll mod    = 123456789;
const ll limit  = 1e6 +  69;
const ll inf    = round(1e17) + 69;
int n;
string a[] = {"AC" , "WA" ,"TLE" , "RE" };
int dem[4];

void Input ()
{
   cin>>n;
   while ( n-- )
   {
       string s;
       cin>>s;
       if ( s == a[0])dem[0]++;
        if ( s == a[1])dem[1]++;
         if ( s == a[2])dem[2]++;
          if ( s == a[3])dem[3]++;
   }
}


void Sol()
{
   for ( int i = 0 ; i < 4 ; i ++)
   {
       cout<<a[i]<<" x "<<dem[i]<<endl;
   }
}

int main()
{
   //if (fopen(taskname".INP", "r"))
    //{
      //  freopen(taskname".INP","r",stdin);
      //  freopen(taskname".OUT","w",stdout);
    //}
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    Input();
    Sol();
}


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

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    D = {}
    for a in A:
        if a in D:
            D[a]+=1
        else:
            D[a]=1
    ret = 0
    for d in D:
        ret += D[d]*(D[d]-1)//2
    for a in A:
        print(ret - D[a]*(D[a]-1)//2 + (D[a]-1)*(D[a]-2)//2 )


if __name__ == '__main__':
    main()

Measured memory_bytes: 25916
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }if(b>c){
        swap(b,c);
    }if(a>b){
        swap(a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)
		cout<<"Balanced";
	else if(a+b>c+d)
		cout<<"Left";
	else
		cout<<"Right";
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,m,id[101010],l[101010],bf[101010];
vector<int>g[101010];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		g[x].push_back(y);
		id[y]++;
	}
	fill(bf,bf+n,-1);
	stack<int>s;
	for(int i=0;i<n;i++)
	{
		if(id[i]==0)
		{
			s.push(i);
		}
	}
	while(s.size())
	{
		int p=s.top();
		s.pop();
		for(int i=0;i<g[p].size();i++)
		{
			int to=g[p][i];
			if(l[p]+1>l[to])
			{
				l[to]=l[p]+1;
			}
			id[to]--;
			if(!id[to])
			{
				s.push(to);
			}
		}
	}
	cout<<*max_element(l,l+n)<<endl;
	return 0;
}

Measured memory_bytes: 6912
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars
    }

    //let wonder = &small[..];

    let mut target_char = 'a';
    let mut size = MAX;
    for c in SMALL {
        let mut appear = false;
        let mut max_long = 0;
        let mut long = 0;
        for i in 0..s.len() {
            if &s[i] != c {
                long += 1;
            } else {
                appear = true;
                max_long = cmp::max(max_long, long);
                long = 0;
            }
        }

        max_long = cmp::max(max_long, long);

        if appear && max_long < size {
            target_char = *c;
            size = max_long;
        }
    }

    //println!("{} {}", target_char, size);

    println!("{}", size);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;
const SMALL: &'static [char] = &[
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];

// @〜でsnippet


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end(), greater<int>());

  int sum = 1;
  for (int i = 1; i < N; i++) {
    if (d.at(i) < d.at(i - 1)) {
      sum++;
    }
  }

  cout << sum << '\n';
}


Measured memory_bytes: 256
/*input

*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;	

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	string s;
	cin >> s;
	int sum = 0;
	rep(i, s.size()) sum += s[i]-'0';
	if(sum%9) cout << "No";
	else cout << "Yes";
	return 0;	
}

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

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

  int c, t, ans = 1001;
  for (int i = 0; i < N; i++) {
    cin >> c >> t;
    if (t <= T) {
      ans = min(c, ans);
    }
  }
  if (ans <= 1000) {
    cout << ans << endl;
  } else {
    cout << "TLE" << endl;
  }
}

Measured memory_bytes: 256
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var args = new int[2];
            args[0] = int.Parse(Console.ReadLine());
            args[1] = int.Parse(Console.ReadLine());

            Console.WriteLine(1 + ((int.Parse(Console.ReadLine()) - 1) / (args.Max())));

        }

    }

}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

using namespace std;

int parity_comb(int n, int r)
{
	int cnt = bitset<32>(n ^ r ^ (n - r)).count();
	return cnt == 0 ? 1 : 0;
}

int solve(int N, vector<int>& a)
{
	int p = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] == 1) {
			p += parity_comb(N - 1, i);
		}
	}
	if (p & 1) {
		return 1;
	}
	for (int i = 0; i < N; ++i) {
		if (a[i] == 1) {
			return 0;
		}
	}

	p = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] == 2) {
			p += parity_comb(N - 1, i);
		}
	}
	return 2 * (p & 1);

}


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

	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		a[i] = s[i] - '1';
	}
	
	cout << solve(N, a) << endl;
}


Measured memory_bytes: 5252