akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int count(int x, int y, int ConstructionX[40], int ConstructionY[40], int ConstructionN, int maxX, int maxY);


int main() {
	int mapnum = 1;
	int x[5], y[5];
	int ConstructionN[5];
	int ConstructionX[5][40], ConstructionY[5][40];

	cin >> x[0] >> y[0];

	for (int j = 0; j < 5; j++) {
		cin >> ConstructionN[j];

		for (int i = 0; i < ConstructionN[j]; i++) {
			cin >> ConstructionX[j][i] >> ConstructionY[j][i];
		}

		cin >> x[j + 1] >> y[j + 1];

		if (x[j+1] == 0 || y[j+1] == 0) {
			break; 
		}
		else {
			mapnum++;
		}
	}

	for (int i = 0; i < mapnum; i++) {
		cout << count(1, 1, ConstructionX[i], ConstructionY[i], ConstructionN[i], x[i], y[i]) << endl;
	}

	return 0;
}

int count(int x, int y, int ConstructionX[40], int ConstructionY[40], int ConstructionN, int maxX, int maxY) {
	int counttemp = 0;

	for (int i = 0; i < ConstructionN; i++) {
		if (x == ConstructionX[i] && y == ConstructionY[i]) return 0;
	}

	if (x == maxX && y == maxY) return 1;

	if (x != maxX) counttemp += count(x + 1, y, ConstructionX, ConstructionY, ConstructionN , maxX, maxY);
	if (y != maxY) counttemp += count(x, y + 1, ConstructionX, ConstructionY, ConstructionN ,maxX, maxY);

	return counttemp;
}


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

char s[100010];

int main(void){
    long N;
    char color;
    cin >> N;
    cin >> s;

    color = s[0];
    int ans = 1;
    for(int i=1;i<N;i++){
        if(color != s[i]){
            ans++;
            color = s[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
long long n,a,b,ans,x[233333];
int main(){
    scanf("%d%d%d",&n,&a,&b);
    for(int i=1;i<=n;i++)scanf("%d",&x[i]);
    for(int i=1;i<n;i++)ans+=std::min(b,a*(x[i+1]-x[i]));
    printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){

    int N,M; cin>>N>>M;
    vector<int> A(N);

    int sum=0;
    for (int i = 0; i < M; ++i) {
        cin>>A[i];
        sum+=A[i];
    }
    if(N<sum){
        cout<<-1<<endl;
    }else{
        cout<<N-sum<<endl;
    }


}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

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

    n = n % k;
    ll ans1 = abs(n-k);
    cout << min(ans1, n) << endl;

    return 0;
}


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

using ll = unsigned long long;
using namespace std;

int main(void) {
    int a,b,c,d,e,k;

    cin >> a >> b >> c >> d >> e >> k;

    if (e-a>k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
    return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50
ll fact[100002];
ll inv[100002];

ll mod(ll n, ll p, ll r)
{
    if(p == 0)
    {
        return 1;
    }
    else if (p%2 == 0)
    {
        ll y = mod(n, p/2, r);
        return (y*y)%r;
    }
    else
    {
        return (mod(n, p-1, r)*n%r)%r;
    }
}

void init(ll n)
{
    fact[0] = 1;
    fact[1] = 1;

    for(int i = 2; i <= n+1; ++i)
    {
        fact[i] = (fact[i-1]*i)%1000000007;
    }

    inv[n+1] = mod(fact[n+1], 1000000005, 1000000007);

    for(ll i = n; i >= 0; --i)
    {
        inv[i] = ((i+1)*inv[i+1])%1000000007;
    }

}

ll ncr(ll n, ll r)
{
    ll ret = 1;
    ret *= fact[n];
    ret = (inv[n-r] * ret)%1000000007;
    ret = (inv[r] * ret)%1000000007;

    return ret;
}


int main()
{
    ll n;
    cin >> n;
    init(n);
    map<int, int> mp;
    vi data(n+1);
    int f;
    int first, second;
    for(int i = 0; i < n + 1; ++i)
    {
        cin >> data[i];
        mp[data[i]]++;
        if(mp[data[i]] == 2)
        {
            f = data[i];
            second = n - i;
        }
    }

    for(int i = 0; i < n + 1; ++i)
    {
        if(data[i] == f)
        {
            first = i;
            break;
        }
    }

    ll ans;
    cout << n << endl;
    for(int k = 2; k <= n+1; ++k)
    {
        ans = ncr(n+1, k);
        if(first + second >= k-1)
        {
            ans -= ncr(first + second, k-1);
        }
        if(ans < 0)
        {
            ans += 1000000007;
        }
        ans %= 1000000007;
        cout << ans << endl;
    }

}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int K;
	cin>>K;
	string S;
	cin>>S;
	if(S.size()<=K)
	    cout<<S<<"\n";
	else
	    cout<<S.substr(0,K)+"..."<<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int a, b;
   cin >> a >> b;
   if(a<2*b) out(0);
   else out(a-2*b);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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);
        AAISing_2019_B solver = new AAISing_2019_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAISing_2019_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            int one = 0, two = 0, three = 0;
            int p;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                p = in.nextInt();
                if (p <= a) {
                    one++;
                } else if (a < p && p <= b) {
                    two++;
                } else if (b < p) {
                    three++;
                }
            }

            out.print(Math.min(Math.min(one, two), three));


        }

    }
}



Measured memory_bytes: 23124
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 0
        if A2[j] == i:
            A2[j] = 0
        if A3[j] == i:
            A3[j] = 0

flag = False
A = [A1,A2,A3]
for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    sum_ = 0
    for j in range(3):
        sum_ += A[j][i]
    if sum_ == 0:
        flag = True

if A1[0] + A2[1] + A3[2] == 0:
    flag = True
if A1[2] + A2[1] + A3[0] == 0:
    flag = True
print('Yes' if flag else 'No')

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin >> s;
    if (s.size() < 26) {
        set<char> seen;
        for (char c: s) {
            seen.insert(c);
        }
        for (char c = 'a'; c <= 'z'; c++) {
            if (!seen.count(c)) {
                s += c;
                cout << s << '\n';
                return 0;
            }
        }
    }
    else {
        set<char> seen;
        for (int i = s.size() - 1; i >= 0; i--) {
            seen.insert(s[i]);
            if (seen.upper_bound(s[i]) != seen.end()) {
                auto it = seen.upper_bound(s[i]);
                string res = s.substr(0,i) + *it;
                cout << res << '\n';
                return 0;
            }
        }
        cout << -1 << endl;
    }
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
static class Program{
	static int mod;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.La;
		mod=(int)s[3];
		long[][] b=new long[][]{new long[]{0},new long[]{s[2]%mod},new long[]{s[1]%mod}};
		long k=0,m=0,p=1;
		for(int i = 1;m<s[0];i++) {
			p*=10;
			k=(p-s[1])/s[2]+((p-s[1])%s[2]==0?0:1);
			k=Min(k,s[0]);
			if(k<1){continue;}
			long[][] g=new long[][]{new long[]{(p%mod),0,1},new long[]{0,1,0},new long[]{0,1,1}};
			b=Mp(b,g,k-m);
			m=k;
		}
		Console.WriteLine("{0}",b[0][0]);
	}
	static long[][] Mp(long[][] r,long[][] x,long e){
		while(e>0){
			if((e&1)>0){r=Mm(x,r);}
			x=Mm(x,x);
			e>>=1;
		}
		return r;
	}
	static long[][] Mm(long[][] a,long[][] b){
		long[][] q=new long[a.Length][];
		for(int j=0;j<a.Length;j++){
			q[j]=new long [b[0].Length];
			for(int i=0;i<b[0].Length;i++){
				for(int k=0;k<a.Length;k++){q[j][i]=(q[j][i]+a[j][k]*b[k][i])%mod;}
			}
		}
		return q;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int n, k;
vector<ll> xs, ys, zs;//?????¨????????§?¨?
map<ll, ll> zipx, zipy, zipz;//<???, ??§??????>
map<ll, ll> unzipx, unzipy, unzipz;//<??§??????, ???>
int num[100][100][100];//???????¨?????????\??????

int main(void){
	cin >> n >> k;
	ll x1[51], x2[51], y1[51], y2[51], z1[51], z2[51];//?????????????????§?¨?
	rep(i, n){
		cin >> x1[i] >> y1[i] >> z1[i];
		cin >> x2[i] >> y2[i] >> z2[i];
		xs.push_back(x1[i]); xs.push_back(x2[i]);
		ys.push_back(y1[i]); ys.push_back(y2[i]);
		zs.push_back(z1[i]); zs.push_back(z2[i]);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(),xs.end()), xs.end());//???????¶????
	sort(ys.begin(), ys.end());
	ys.erase(unique(ys.begin(), ys.end()), ys.end());
	sort(zs.begin(), zs.end());
	zs.erase(unique(zs.begin(), zs.end()), zs.end());

	rep(i, xs.size()){
		zipx[i] = xs[i];
		unzipx[xs[i]] = i;
	}
	rep(i, ys.size()){
		zipy[i] = ys[i];
		unzipy[ys[i]] = i;
	}
	rep(i, zs.size()){
		zipz[i] = zs[i];
		unzipz[zs[i]] = i;
	}

	memset(num, 0, sizeof(num));
	for (int i = 0; i < n; ++i){
		for (int x = unzipx[x1[i]]; x < unzipx[x2[i]]; ++x){
			for (int y = unzipy[y1[i]]; y < unzipy[y2[i]]; ++y){
				for (int z = unzipz[z1[i]]; z < unzipz[z2[i]]; ++z){
					num[x][y][z]++;
				}
			}
		}
	}

	ll ans = 0;
	rep(x, 100)rep(y, 100)rep(z, 100){
		if(num[x][y][z] >= k){
			ans += ((zipx[x + 1] - zipx[x]) * (zipy[y + 1] - zipy[y]) * (zipz[z + 1] - zipz[z]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5172
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    H, W = Scanner.map_int()
    S = Scanner.string_list(H)
    cnt = defaultdict(int)
    for line in S:
        for c in line:
            cnt[c] += 1
    if H % 2 == 0 and W % 2 == 0:
        for c in cnt.values():
            if c % 4 != 0:
                return False
        return True
    t1 = 0
    t2 = 0
    for c in cnt.values():
        if c % 2 == 1:
            t1 += 1
        elif c % 4 == 2:
            t2 += 1
    if H % 2 == 1 and W % 2 == 1:
        if t1 != 1:
            return False
        if t2 <= (H - 1) // 2 + (W - 1) // 2:
            return True
        return False
    else:
        if t1 != 0:
            return False
        if H % 2 == 1:
            if t2 <= W // 2:
                return True
            return False
        else:
            if t2 <= H // 2:
                return True
            return False


def main():
    # sys.stdin = open("sample.txt")
    print('YNeos'[not solve()::2])


if __name__ == "__main__":
    main()


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

int main(){
  int n;
  cin>>n;
  vector<int>x(n);
  for(int i=0;i<n;i++){
  cin>>x.at(i);
  }
  sort(x.begin(),x.end());
  int y=0;
  for(int j=0;j<n-2;j++){
  for(int k=j+1;k<n-1;k++){
  for(int l=k+1;l<n;l++){
  if(x.at(j)+x.at(k)>x.at(l)){
  y++;
  }
  }
  }
  }
  cout<<y<<endl;
}

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

int main() {
  int n;
  cin>>n;
  int l[n];
  for(int i=0; i<n; i++) cin>>l[i];

  if(n==1 || n==2) {
    cout<<0<<endl;
    return 0;
  }

  int ans = 0;
  for(int i=0; i<n-2; i++) {
    for(int j=i+1; j<n-1; j++) {
      for(int k=j+1; k<n; k++) {
        if(l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k] && l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i]) {
          ans++;
        }
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int ans;
  int count=0;
  for(int i=min(a,b);i>0;i--){
    if(count==k){break;} 
    else if(a%i==0&&b%i==0){count++; if(count==k){ans=i;}}
    else{continue;}
  }
  cout<<ans;
}


Measured memory_bytes: 256
H,W,K=gets.split.map(&:to_i)
x1,y1,x2,y2=gets.split.map(&:to_i)
c=[?@*(W+2)]+H.times.map{?@+gets.chop+?@}+[?@*(W+2)]

d=Array.new(H+2){Array.new(W+2){-1}}
d[x1][y1]=0
q=[[x1,y1]]
until q.empty?
  x,y=q.shift
  (x+1).upto(x+K) do |nx|
    break if c[nx][y]==?@
    if d[nx][y]==-1
      d[nx][y]=d[x][y]+1
      q<<[nx,y]
    else
      break if d[nx][y]<d[x][y]+1
    end
  end
  (x-1).downto(x-K) do |nx|
    break if c[nx][y]==?@
    if d[nx][y]==-1
      d[nx][y]=d[x][y]+1
      q<<[nx,y]
    else
      break if d[nx][y]<d[x][y]+1
    end
  end
  (y+1).upto(y+K) do |ny|
    break if c[x][ny]==?@
    if d[x][ny]==-1
      d[x][ny]=d[x][y]+1
      q<<[x,ny]
    else
      break if d[x][ny]<d[x][y]+1
    end
  end
  (y-1).downto(y-K) do |ny|
    break if c[x][ny]==?@
    if d[x][ny]==-1
      d[x][ny]=d[x][y]+1
      q<<[x,ny]
    else
      break if d[x][ny]<d[x][y]+1
    end
  end
end
p d[x2][y2]


Measured memory_bytes: 43960
/* 
从第左上角第一个点开始染色，相邻不同色，染法唯一
那么一个点的四周与他不同色，我们另这个点比四周都大，那么这个点权值可以使lcm(四周的点权值)+1
于是我们就得到了一种构造方案，染色后对一种颜色的点进行赋值，然后另一种颜色的点取lcm
可是....直接这样瞎构造会爆掉1e15
对于一种染色点，可以按照i + j和i - j分为两类,每一类乘上一个相同的质数
对于当前格子的价值就是从左上角到右下角，和从右上角到左下角穿过他的第k素数乘积
这样构造的lcm最大就是四个素数(prime[n],prime[n - 1],prime[2 * n],prime[2 * n - 1])的乘积
不会超过1e15 
*/ 
#include<cstdio> 
#include<cctype> 
#include<cstring> 
#include<algorithm> 
#define gc getchar() 
#define pc putchar
#define LL long long
inline int read() { 
	int x = 0,f = 1; 
	char c = getchar(); 
	while(c < '0' || c > '9') c = gc; 
	while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = getchar(); 
	return x * f; 
}
void print(LL x) { 
	if(x < 0) { 
		pc('-'); 
		x = -x; 
	} 
	if(x >= 10) print(x / 10); 
	pc(x % 10 + '0'); 
} 
const int maxn = 20007; 
int n; 
int prime[maxn]; 
bool vis[maxn]; 
void pre(int lim = 10000) {  
	for(int cnt = 0,i = 2;i <= lim;++ i) { 
		if(!vis[i]) prime[++ cnt] = i; 
		for(int j = 1;j <= cnt && prime[j] * i <= lim;++ j) { 
			vis[i * prime[j]] = 1; 
			if(i % prime[j] == 0) break; 
		} 
	} 
} 
LL a[507][507]; 
LL gcd(LL x,LL y) { 
	return y == 0 ? x : gcd(y,x % y); 
} 
LL lcm(LL x,LL y) {
	return x / gcd(x,y) * y; 
} 
int main() { 
	n = read(); 
	pre(); 
	if(n == 2) {
		pc('4');pc(' ');pc('7');pc('\n'); 
		print(23);pc(' '); print(10); pc('\n');	
		return 0;  
	} 
	for(int i = 0;i <= n + 1;++ i) 
		for(int j = 0;j <= n + 1;++ j) 
				a[i][j] = 1; 
	for(int i = 1;i <= n;++ i) 
		for(int j = 1;j <= n;++ j) { 
			if((j & 1) == (i & 1)) { 
				a[i][j] = prime[(i + j) / 2] * prime[(i + n + 1 - j) / 2 + n]; 	
				a[i + 1][j] = lcm(a[i + 1][j],a[i][j]); 
				a[i - 1][j] = lcm(a[i - 1][j],a[i][j]); 
				a[i][j + 1] = lcm(a[i][j + 1],a[i][j]); 
				a[i][j - 1] = lcm(a[i][j - 1],a[i][j]); 
			} 
		} 
	for(int i = 1;i <= n;++ i) 
		for(int j = 1;j <= n;++ j) 
			if((i & 1) == (j & 1)); 
			else a[i][j] ++; 
	for(int i = 1;i <= n;++ i,pc('\n')) 
		for(int j = 1;j <= n;++ j) 
			print(a[i][j]),pc(' '); 
	return 0; 
} 

Measured memory_bytes: 5120
#include <stdio.h>

class Dice3{
public:
	Dice3(){
		number = new int[6];
		checkTable = new int[101];
		for(int i = 0; i < 101; i++) checkTable[i] = -1;
	};
	~Dice3(){
		delete[] number;
		delete[] checkTable;
	};

	void setLabel(int index,int num){
		number[index] = num;
		checkTable[num] = index;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isValidMember(int inputed[]){
		for(int i = 0; i < 6; i++)
		{
			if(checkTable[inputed[i]] == -1)
				return false;
		}
		return true;
	}
	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* checkTable;
};

int main(){
	Dice3 dice3;
	int tmp,inputed[6];
	for(int i = 0; i < 6; i++){
		scanf("%d",&tmp);
		dice3.setLabel(i,tmp);
	}
	for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);

	if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}



Measured memory_bytes: 2696
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const double EPS = 1e-9;

#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
  double x;
  double y;

  Point(double x = 0.0, double y = 0.0) {
    this->x = x;
    this->y = y;
  }

  Point operator+(Point p) { return Point(x + p.x, y + p.y); }

  Point operator-(Point p) { return Point(x - p.x, y - p.y); }

  Point operator*(double a) { return Point(a * x, a * y); }

  Point operator/(double a) { return Point(x / a, y / a); }

  double norm() { return x * x + y * y; }

  double abs() { return sqrt(norm()); }

  bool operator<(const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator==(const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

typedef Point Vector;
struct Segment {
  Point p1, p2;
};

typedef Segment Line;

double dot(const Vector &a, const Vector &b) {
  return a.x * b.x + a.y * b.y;
}

double cross(const Vector &a, const Vector &b) {
  return a.x * b.y - a.y * b.x;
}

class Circle {
public:
  Point c;
  double r;

  Circle(Point c = Point(), double r = 0.0) {
    this->c = c;
    this->r = r;
  }
};

typedef vector <Point> Polygon;

bool isOrthogonal(const Vector &a, const Vector &b) {
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
  return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(const Vector &a, const Vector &b) {
  return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
  return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
  return equals(cross(s1.p2 - s2.p1, s2.p2 - s2.p1), 0.0);
}

// 直線の直行・平行判定
int main() {
  int Q;
  cin >> Q;

  int x0, x1, x2, x3;
  int y0, y1, y2, y3;
  for (int i = 0; i < Q; ++i) {
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    Point p1(x0, y0);
    Point p2(x1, y1);
    Point p3(x2, y2);
    Point p4(x3, y3);

    if (isOrthogonal(p1, p2, p3, p4)) {
      cout << 1 << endl;
    } else if (isParallel(p1, p2, p3, p4)) {
      cout << 2 << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int const inf = 1e9 + 7;
int n, W, v[101], w[101], dp[101][1100000];

// dp[i][j] = max(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1])

int main(){
    cin >> n >> W;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 0; i < 101; i++)
        for(int j = 0; j < 1100000; j++)
            dp[i][j] = inf;
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        //for(int j = 0; j < 1100000; j++)dp[i][j] = inf;
        for(int j = 0; j < 1100000; j++){
            dp[i][j] = dp[i-1][j];
            if(j - v[i-1] >= 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
            }
        }
    }
    int mmax = 0;
    for(int i = 0; i < 1100000; i++){
        if(dp[n][i] <= W)mmax = i;
        //cout << dp[n][i]  << ' ';
    }
    cout << mmax << endl;
    return 0;
}

Measured memory_bytes: 434304
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;

int main() 
{
	string s;
	cin >> s;
	int i = 0;
	for ( i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L')
				break;
		}
		else
		{
			if (s[i] == 'R')
				break;
		}
		
	}
	if (i < s.length())
		cout << "No";
	else
		cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    int k,s;
    ll ans =0;
    cin>>k>>s;

    for(int x=0;x<=k;x++)
    {
        for(int y=0;y<=k;y++)
        {
            int z = s-x-y;
            if(z>=0&&z<=k) ans ++;
        }
    }

    cout<<ans<<endl;


}

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

int n; string s;
vector<int>O, I;
bool ok(int t) {
	if (I.size() < t || O.size() < t)return false;
	int p = n - 1;
	rep(i, t) {
		p = min(p - 1, O[i] - 1);
		while (0 <= p && (s[p] == 'O' || (s[p] == 'I'&&p >= I[t - 1])))p--;
		if (p < 0)return false;
	}
	return true;
}
int main() {
	cin >> n >> s;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'I')I.push_back(i);
		if (s[i] == 'O'&&O.size() < I.size())O.push_back(i);
	}
	int l = 0, r = n / 3;
	while (l != r) {
		int t = (l + r) / 2;
		if (r - l == 1)t = r;
		if (ok(t))l = t;
		else r = t - 1;
	}
	printf("%d\n", l);
}

Measured memory_bytes: 10176
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n)
	fmt.Scan(&s)
	if n%2 != 0 {
		fmt.Print("No")
	} else if s[0:n/2] == s[n/2:n] {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}


Measured memory_bytes: 1768
#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 dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  string s; ll k; cin >> s >> k;
  
  char x = '1';
  
  rep(i,min(k,100LL)){
    if(s[i] != '1'){
      x = s[i];
      break;
    }
  }
  
  cout << x << endl;


}

Measured memory_bytes: 256
use std::collections::BTreeMap;

fn main()
{
    let ns = {
        let mut vec = Vec::new();
        let mut s = String::new();
        loop {
            s.clear();
            match std::io::stdin().read_line(&mut s) {
                Ok(0) => break, // EOF
                Ok(_) => vec.push(s.trim_right().parse::<i32>().unwrap()),
                Err(e) => println!("{}", e),
            }
        }
        vec
    };

    let mut map_count: BTreeMap<i32, usize> = BTreeMap::new();
    for n in ns {
        *map_count.entry(n).or_insert(0) += 1;
    }

    let max_value = map_count.values().max().unwrap();

    for (key, value) in &map_count {
        if value != max_value {
            continue;
        }
        println!("{}", key);
    }
}


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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによる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 << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元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;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();
  vector<ll> as;
  rep(i, N){
    as.push_back(il());
  }

  sort(begin_end(as));
  reverse(begin_end(as));

  // 1人目は絶対0
  ll ans = 0;

  // 2人目が入る
  ans += as[0];

  if (N==2){
    cout << ans << endl;
    return 0;
  }

  // 3~N人目が入る
  bool hitotsume = true;
  ll idx = 1;
  REP(i, 3, N+1){
    if (hitotsume){
      ans += as[idx];
      hitotsume = false;
    }
    else{
      ans += as[idx];
      hitotsume = true;
      idx++;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 5368
from collections import Counter
N=int(input())
v=list(map(int,input().split()))

odd=v[0::2]
even=v[1::2]

o=Counter(odd).most_common(2)
e=Counter(even).most_common(2)

o.append((0,0))
e.append((0,0))

if o[0][0]==e[0][0]:
    ans=min(N-o[0][1]-e[1][1],N-e[0][1]-o[1][1])
else:
    ans=N-o[0][1]-e[0][1]
print(ans)



"""
ans=N
for o_l in o:
    for e_l in e:
        if o_l[0]!=e_l[0]:
            ans=min(ans,N-o_l[1]-e_l[1])
print(ans)
"""



Measured memory_bytes: 15972
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		boolean flg = true;
		int count = 0;
		for(int i = 0; i < 2;i++){
			if(s[i].equals(s[i+1])){
				count++;
			} else {
				
			}
		}
		if(count != 2){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main(){
	int t;
	cin>>t;
	long long result=0;
	for(int i=1;i<=t;i++){
		if(i%3==0 || i%5==0) continue;
		else result+=i;
	}
	cout<<result<<"\n";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    int tot=0;
    rep(i,n) {
        cin >> a[i];
        tot+=a[i];
    }
    
    sort(a.begin(),a.end(),greater<>());
    if (a[m-1] >= tot/(4.0*m)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

struct BIT {
	vector<int> bit;
	int n;
	BIT(int x) {
		bit.resize(x + 1, 0);
		n = x;
	}
	void add(int x, int y) {
		while (x <= n) {
			bit[x] += y;
			x += x & -x;
		}
	}
	int sum(int x) {
		int res = 0;
		while (x > 0) {
			res += bit[x];
			x -= x & -x;
		}
		return res;
	}
};

int N,A[100005];
struct info{
	int type,ind,x;
	bool operator<(const info&a)const{
		if(x!=a.x)return x>a.x;
		return type<a.type;
	}
	info(int type,int ind,int x):type(type),ind(ind),x(x){}
};
int ans[100005];
vector<info>q;
signed main(){
	cin>>N;
	int now=0;
	rep(i,N){
		cin>>A[i];
		q.emplace_back(0,i,A[i]);
		if(now<A[i]){
			q.emplace_back(1,i,now);
			now=A[i];
		}
	}
	sort(all(q));
	BIT bit(N),bit2(N);
	int memo=0;
	for(info i:q){
		if(!i.type){
			bit.add(i.ind+1,i.x);bit2.add(i.ind+1,1);
		}
		else {
			int p=bit.sum(N)-bit.sum(i.ind);
			int q=bit2.sum(N)-bit2.sum(i.ind);
			ans[i.ind]=p-i.x*q-memo;
			memo+=ans[i.ind];
		}
	}
	rep(i,N)cout<<ans[i]<<endl;
}


Measured memory_bytes: 10348
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define all(a) (a.begin(),a.end())
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e10 ;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  ll t = 1 ;
  //cin>>t ;
  while(t--)
  {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for( ll i = 0 ; i<n ; i++ ) cin>>a[i];
    sort(a.begin(),a.end()) ;
    ll ans = 0 ;
    for( ll i = 0 ; i<k ; i++ ) ans+=a[i];
    cout<<ans;
  }
  return 0;

}


Measured memory_bytes: 3636
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

N=2*10**5+10

n=I()
a=LI()
m=[0]*N
ans=0
for i in a:
    m[i]+=1
for i in m:
    ans+=i*(i-1)//2

for i in a:
    print(ans-(m[i]-1))


Measured memory_bytes: 77004
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);

		String sA = in.next();
		String sB = in.next();
		
		if(sA.length() == sB.length()){
			int comp = sA.compareTo(sB);
			System.out.println(comp == 0 ? "EQUAL" : (comp > 0 ? "GREATER" : "LESS"));
		}else{
			System.out.println(sA.length() > sB.length() ? "GREATER" : "LESS");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <set>

int main() {
    long long n, t;
    std::cin >> n;
    std::vector<long long> b(n);
    for (long long i = 0; i < n; i++) {
        std::cin >> t;
        b[t - 1] = i;
    }

    long long ret = 0, pret;
    std::set<long long> s;

    s.insert(-1);
    s.insert(n);

    for (long long i = 0; i < n; i++) {
        auto it = s.lower_bound(b[i]);
        pret = ((*it) - b[i]);
        it--;
        ret += pret * (b[i] - (*it)) * (i+1);
        s.insert(b[i]);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 11136
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <time.h>
using namespace std;

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
//#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const LL mod = 1000000007;
const LL MAX = 200047;

int A[MAX], X[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	FOR(i, 1, n + 1)
	{
		cin >> A[i];
		X[i] = A[i];
	}
	sort(X + 1, X + n + 1);
	FOR(i, 1, n + 1)
	{
		int j = lower_bound(X + 1, X + n + 1, A[i]) - X;
		if (n / 2 < j)
			cout << X[n / 2] << '\n';
		else
			cout << X[n / 2 + 1] << '\n';
	}
	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  int res = 0;
  
  for(int i=1;i<=N;i++){
    if(i<10) res++;
    if(i<1000 && i>99) res++;
    if(i<100000 && i>9999) res++;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
_ = input()
slime = list(map(int,input().split()))
tmp = 0
con = 1
li = []
for s in slime:
    if tmp == s:
        con += 1
    else:
        if con != 1:
            li.append(con)
            con = 1
    tmp = s
else:
    if con != 1:
        li.append(con)
print(sum([l//2 for l in li]))

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

int len[5] = {5, 7, 5, 7, 7};
string N;
long long dp[21][10010][3][3]; // digit, last4, clear, smaller

bool judge(int n) {
  if ( (n/100) != 51) return false;
  if (n % 10 != 3) return false;
  return true;
}

int main() {
  while (cin >> N) {
    memset(dp, 0, sizeof(dp));
    dp[0][0][0][0] = 1;
    for (int i = 0; i <= N.size(); ++i) {
      for (int j = 0; j <= 9999; ++j) {
        for (int k = 0; k < 10; ++k) {
          int nj = (j % 1000) * 10 + k;

          // smaller -> smaller
          {
            // clear -> clear
            dp[i+1][nj][1][1] += dp[i][j][1][1];

            // nonclear -> 
            if (judge(nj)) dp[i+1][nj][1][1] += dp[i][j][0][1];
            else dp[i+1][nj][0][1] += dp[i][j][0][1];
          }

          // same -> smaller
          if (k < (int)(N[i] - '0')) {
            // clear -> clear
            dp[i+1][nj][1][1] += dp[i][j][1][0];

            // nonclear ->
            if (judge(nj)) dp[i+1][nj][1][1] += dp[i][j][0][0];
            else dp[i+1][nj][0][1] += dp[i][j][0][0];
          }

          // same -> same
          if (k == (int)(N[i] - '0')) {
            // clear -> clear
            dp[i+1][nj][1][0] += dp[i][j][1][0];

            // nonclear ->
            if (judge(nj)) dp[i+1][nj][1][0] += dp[i][j][0][0];
            else dp[i+1][nj][0][0] += dp[i][j][0][0];
          }
          
        }
      }
    }

    long long res = 0;
    for (int j = 0; j <= 9999; ++j) {
      for (int smaller = 0; smaller < 2; ++smaller) {
        res += dp[N.size()][j][1][smaller];
      }
    }

    cout << res << endl;
  }
}



Measured memory_bytes: 17996
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n = read::<i32>();
  let m = read::<i32>();
  let x = read::<i32>();
  let y = read::<i32>();

  let mut y_v = vec![];
  let mut x_v = vec![];

  for _ in 0..n {
    let x_i = read::<i32>();
    x_v.push(x_i)
  }

  for _ in 0..m {
    let y_i = read::<i32>();
    y_v.push(y_i)
  }


  let y_v_min = y_v.iter().min().unwrap();
  let x_v_max = x_v.iter().max().unwrap();

  let mut z_v = vec![];
  for i in x + 1..y + 1 {
    z_v.push(i as i32)
  }

  let mut ok = false;

  for z_i in z_v {
    if z_i <= *y_v_min && z_i > *x_v_max {
      ok = true;
      break;
    }
  }

  if ok {
    println!("No War");
  } else {
    println!("War");
  }
}



Measured memory_bytes: 4352