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

typedef long long ll;
typedef pair<int,ll> P;
ll const INF = 1e18;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<ll> l(100010,-INF),u(100010,INF);
vector<bool> used(100010,false);
vector<P> G[100010];

void dfs(int i,int p,int d,ll w) {
    used[i] = true;
    for (P& j : G[i]) if (j.first != p) {
        int x = j.first;
        ll y = j.second;
        if (!used[x]) dfs(x,i,d^1,y-w);
        if (d) {
            if (l[x] != -INF) {
                if (l[x] != -y+w+1) {
                    l[x] = INF;
                    u[x] = -1;
                }
            } else l[x] = -y+w+1;
        } else {
            if (u[x] != INF) {
                if (u[x] != y-w-1) {
                    l[x] = INF;
                    u[x] = -1;
                }
            } else u[x] = y-w-1;
        }
    }
}

int main() {
    int n,m;
    cin >> n >> m;
    for (int i = 0;i < m;++i) {
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        G[u].push_back(P(v,w));
        G[v].push_back(P(u,w));
    }
    dfs(0,-1,0,0);
    ll mn = 1,mx = 1e18;
    bool f = false;
    for (int i = 0;i < n;++i) {
        if (-INF < l[i] && l[i] < INF && 0 < u[i] && u[i] < INF) {
            if (f) {
                if (mn*2 != l[i]+u[i]) {
                    cout << 0 << endl;
                    return 0;
                }
            } else {
                if ((l[i]+u[i])&1 || mn > u[i] || mx < l[i]) {
                    cout << 0 << endl;
                    return 0;
                }
                f = true;
                mn = mx = (l[i]+u[i])/2;
            }
        } else {
            mn = max(l[i],mn);
            mx = min(u[i],mx);
        }
        if (mn > mx || l[i] > u[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << mx-mn+1 << endl;
    return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> length(2 * N);
	for (int i = 0; i < 2 * N; i++) {
		cin >> length.at(i);
	}
	sort(length.begin(), length.end());
	int sum = 0;


	for (int i = 0; i < length.size(); i += 2) {
		sum += length.at(i);
	}

	cout << sum << endl;
}

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

using namespace std;
typedef long long ll;
//typedef vector<pair<ll.ll>> pii;
int main()
{
    ll h;
    cin>>h;
    ll cnt=0;
    ll str=1;
    while(h>1)
    {
        h=h/2;
        cnt+=str;
        str=2*str;
    }
    cout<<str+cnt;
    

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[100000];
  int n;
  char temp;
  int i,j;
  int num;
  
  
  scanf("%d",&n);
  scanf("%s",&s);
  
  num = n;
  
  for (i=0;i<n-1;i++){
    temp = s[i];
    for (j=1;;j++){
      if(i+j >= n){
        i = n;
        break;
      }
      if (temp == s[i+j]){
        num -= 1;
      }else{
        i += j-1;
        break;
      }
    }
  }
    
   printf("%d",num);
   return 0; 
}
        

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

#define BUFF_SIZE 1024
char buffer[4 * 1024 * 1024];
int pos = 0;
int end = 0;

int mygetchar(){
  if(pos == end){
    end = read(0, buffer, sizeof(buffer));
    pos = 0;
  }
  return buffer[pos++];
}

__attribute__((always_inline)) int getInt(){
  int ret = 0, c;
  c = mygetchar();
  while(!isdigit(c)) c = mygetchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = mygetchar();
  }
  return ret;
}

#define mask (0x7F)
int cnt[mask];

int main(){
  int n, i;
  while(n = getInt()){
    const int n2 = n / 2;
    memset(cnt, 0, sizeof(cnt));

    for(i = 0; i < n; i++){
      int a = getInt();

      if(++cnt[a & mask] > n2){
	printf("%d\n", a);
	for(++i; i < n; i++)
	  getInt();
	goto end;
      }
    }

    puts("NO COLOR");

  end:;
  }
  return 0;
}

Measured memory_bytes: 4452
#include <iostream>
#include <vector>
#include <utility>
#include <string>
using namespace std;
typedef int64_t I;
typedef vector<I> vI;
typedef pair<I, I> II;
typedef vector<II> vII;
typedef vector<vII> vvII;

I gcd(I a, I b) {
  while (b != 0) {
    I q = a / b, nb = a % b;
    a = b;
    b = nb;
  }
  return a;
}

int main() {
  I n; cin >> n;
  I r = 0;
  for (I i = 1; i <= n; i++) {
    for (I j = 1; j <= n; j++) {
      I ij = gcd(i, j);
      for (I k = 1; k <= n; k++) {
        r += gcd(ij, k);
      }
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,A[100010],ans[100010] = {0};
vector<P> v;
int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		v.push_back({A[i],i});
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	v.push_back({0,1e9});
	ll mi = 1e9;
	for(int i=0;i<N;i++){
		mi = min(mi,v[i].second);
		ans[mi] += (i+1)*(v[i].first-v[i+1].first);
	}
	for(int i=1;i<=N;i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 4336
// AOJ 2583: JAG-channel
// 2017.10.6 bal4u@uu

#include <stdio.h>

char s[1002][2000];

int main()
{
	int n, i, j, k;
	char *p;

	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) {
			scanf("%s", s[i]);
			p = s[i]; while (*p == '.') *p++ = ' ';
			if (--p >= s[i]) {
				*p = '+', k = p - s[i];
				for (j = i-1; j >= 0; j--)
					if (s[j][k] != ' ') break;
					else s[j][k] = '|';
			}
		}
		for (i = 0; i < n; i++) puts(s[i]);
	}
    return 0;
}

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

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

    int ans = 0;
    int n = s.size();
    rep (i, n)
        if (s[i] != t[i])
            ans++;

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


Measured memory_bytes: 3856
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    ll num = min(K, A);
    ans += num;
    K -= num;
    num = min(K, B);
    K -= num;
    num = min(K, C);
    ans -= num;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/11/20 21:59:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll INF = 1e13;

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

  int n,k; cin>>n>>k;
  vector<int> H(n); for (auto& h:H) cin>>h;
  H.insert(H.begin(), 0);
  vector<vector<ll>> dp(k+1, vector<ll>(n+1, INF));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    vector<vector<ll>> nxt(k+1, vector<ll>(n+1, INF));
    for (int t = min(k, i-1); t >= 0; t--) {
      for (int j = i-1; j >= 0; j--) {
        if (t < k)
          nxt[t+1][j] = min(nxt[t+1][j], dp[t][j]);
        nxt[t][i] = min(nxt[t][i], dp[t][j]+max(H[i]-H[j], 0));
      }
    }
    dp = nxt;
  }
  ll ans = INF;
  for (int i = 0; i <= k; i++) {
    ans = min(ans, *min_element(dp[i].begin(), dp[i].end()));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1764
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    if s == 'ABC': print('ARC')
    else: print('ABC')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9368
#include<bits/stdc++.h> 
#include<stdio.h>
using namespace std; 
int main(){

	long long int n,ans=0;
	cin >> n;
	int t=n/500;
	if(t!=0){

		ans = ans + 1000 * (t);
		n = n%500;
	}

	int j = n/5;
	if(j!=0){

		ans = ans + 5 * (j);
	}

	cout << ans;
	/*string s;
	cin >>s;
	if(s.compare(2,1,s,3,1)==0&& s.compare(4,1,s,5,1)==0) cout << "Yes";
		else cout << "No";*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int MX = 100005, mod = 1000000007;
int n;
ll x[MX], fac, f, s, res;

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> x[i];

	s = f = 1, fac = 1;
	for (int i = 1; i < n; i++) {
		(res += f * (x[i + 1] - x[i])) %= mod;
		(f = (s + i + 1) * pot(i + 1, mod - 2)) %= mod;
		(s += f) %= mod;
		(fac *= i) %= mod;
	}

	(res *= fac) %= mod;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import chain

s = [
    '100 100\n',
    '12 12\n',
    '13 13\n',
    '14 14\n',
    '12 112\n',
    '13 113\n',
    '14 114\n',
    '12 1212\n',
    '13 1213\n',
    '14 1214\n',
    '12 12312\n',
    '13 12313\n',
    '14 12314\n',
    '2 15\n',
    '3 16\n',
    '4 17\n',
    '2 155\n',
    '2 177\n',
    '2 2\n',
    '3 3\n',
    '4 4\n',
    '2 5\n',
    '3 6\n',
    '4 7\n',
    '2 55\n',
    '2 77\n',
    '2 99',
]

def main():
    s = sys.stdin.readlines()
    # print(s)

    n, m = map(int, s[0].split())
    table = [list(chain([i], list(map(int, py.split())))) for i, py in zip(range(m), s[1:])]

    # print('table1')
    # print(table)

    table.sort(key=lambda x: x[2])
    table.sort(key=lambda x: x[1])

    # print('table2')
    # print(table)

    _i = table[0][0]
    _p = table[0][1]
    count = 1
    result = [[_i, _p, count]]

    for i, p, _ in table[1:]:
        if p == _p:
            count += 1
        else:
            count = 1
            _p = p
        result.append([i, p, count])

    # print('result')
    # print(result)

    result.sort(key=lambda x: x[0])
    print('\n'.join([str(p).rjust(6, '0') + str(count).rjust(6, '0') for _, p, count in result]))


if __name__ == '__main__':
    main()

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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;
int arr[MAXN];
int t[5*MAXN],lazy[5*MAXN],clazy[5*MAXN];

int doit(int a,int b){
	return (a+b);
}

void build(int start,int end,int index=1){
	if(start==end){
		t[index]=0;
		return ;
	}
	int mid = start+end >> 1;
	build(start,mid,index << 1);
	build(mid+1,end,index<<1|1);
	t[index] = doit(t[index<<1], t[index<<1|1]);
}

void propagate(int start,int end,int index){
	t[index] = (end-start+1)*lazy[index];
	// bcz leaf not hv childs
	if(start!=end){
		clazy[index<<1] = clazy[index<<1|1] = 1;
		lazy[index<<1] = lazy[index];
		lazy[index<<1|1] = lazy[index];
	}
	clazy[index]=0;
}

int Query(int start,int end,int l,int r,int index=1){

	if(clazy[index]==1){
		propagate(start,end,index);
	}
	// out range
	if(r<start or end<l){
		return 0;
	}
	// in Raange
	if( l<=start and end<=r){
		return t[index];
	}
	int mid = start+end >>1;
	return doit(Query(start,mid,l,r,index<<1), Query(mid+1,end,l,r,index<<1|1));
}

void pUpdate(int start,int end,int point,int val,int index=1){
	if(start==end){
		t[index]=val;
		return ;
	}
	int mid = start+end>>1;
	if(point <= mid){
		pUpdate(start,mid,point,val,index<<1);
	}
	else{
		pUpdate(mid+1,end,point,val,index<<1|1);
	}
	t[index] = doit(t[index <<  1] , t[index << 1 | 1]);
}


void rangeUpdate(int start,int end,int l,int r,int val,int index){
	if(clazy[index]==1){
		propagate(start,end,index);
	}
	if(l>end or r<start){
		return;
	}
	// in range
	if(l<=start and end<=r){
		clazy[index]=1;
		lazy[index]=val;
		propagate(start,end,index);
		return;
	}
	int mid = start+end>>1;
	rangeUpdate(start,mid,l,r,val,index<<1);
	rangeUpdate(mid+1,end,l,r,val,index<<1|1);
	t[index] = doit(t[index<<1],t[index<<1|1]);
}




signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin>>n>>m;
	memset(lazy,2,sizeof lazy);
	// fill(lazy,lazy+5*MAXN,2000);
	build(0,n-1);
	for(int i=1; i<=m; i++){
		int q; cin>>q;
		if(q==1){
			int s,t; cin>>s>>t;
			cout<<Query(0,n-1,s,t,1); br;
		}
		else{
			int s,t,x; cin>>s>>t>>x;
			rangeUpdate(0,n-1,s,t,x,1);
		}
	}	

}


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

int main() {
  int N;
  cin >> N;
  vector<int>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  int result=0;
  for(int i=0;i<N;i++){
    if(i%2==0) result+=data.at(i);
    else result-=data.at(i);
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

int n, m;
int a[100000];
ll d[100002];

int main(){
    cin >> n >> m;
    rep(i, n){
        cin >> a[i];
        --a[i];
    }

    ll s = 0;
    rep(i, n - 1){
        int p = a[i];
        int q = a[i + 1];
        if(p < q){
            s += q - p;
            d[p + 2] -= 1;
            d[q + 1] += q - p;
            d[q + 2] -= q - p - 1;
        }
        else{
            s += q + 1;
            d[0] -= 1;
            d[q + 1] += m + q - p;
            d[q + 2] -= m + q - p - 1;
            d[p + 2] -= 1;
        }
    }
    rep(i, m - 1){
        d[i + 1] += d[i];
    }
    d[0] = s;
    rep(i, m - 1){
        d[i + 1] += d[i];
    }
    cout << *min_element(d, d + m) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include<unordered_map>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <cstdio>
#include <cstdlib>
#include <complex>
#define ll long long
#define  point complex<double>
#define  pi acos(-1)
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define arr2dof vector  vector<vector<int>>dp(N,vector<int>(2, inf));
using namespace std;
const ll N = 2e5 + 5, mod = 1e9 + 7, inff = -1e12, inf = 1e9 + 7;
const double ep = 0.0000000001;
//const double pi = 3.14159265359;

double dot(point a, point b) {
	return  (conj(a)*b).real();
}
double cross(point a, point b) {
	return  (conj(a)*b).imag();
}
double angle(point a, point b)
{
	double dt = dot(a, b);
	dt /= abs(a);
	dt /= abs(b);
	return acos(dt) * 180.0 / pi;
}

bool isrightangel(int ind) {//90 degree
	vector<point>v;
	return(angle(v[ind] - v[(ind + 1) % 3], v[ind] - v[(ind + 2) % 3]) == 90);//bshof hal eldot producty3ny fe
	//dl3en 3moden 3ashn yb2a right trinagle
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	ll ans = fp(base, exp / 2);
	ans = (ans * ans) % mod;
	if (exp % 2 != 0)
		ans = (ans * (base % mod)) % mod;
	return ans;
}

void calcFacAndInv(ll n)
{
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
	return (fact[n] * inv[n - r]) % mod;
}
		
		int GCD(int a, int b) {
			if (b == 0)
				return a;
			else
				return GCD(b, a%b);
		}
		int LCM(int a, int b) {
			return (a*b) / GCD(a, b);
		}
		

		
int main() {
	ios
		int n,k, arr[100005];
	cin >> n>>k;
	int m = 0;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	n--;
	k--;
	cout << (n / k)+(n%k!=0);
	return 0;


}


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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
	int n,k,temp;
	cin>>n>>k;
	UMP(int,int) mapping,check;
	for(int i=1;i<n+1;i++){
		cin>>temp;
		mapping[i] = temp;
	}
	
	if(k<= n){
		int current = mapping[1];
		rep(i,1,k){
			current = mapping[current];
		}
		cout<<current;
		return 0;
	}
	
	int current = 1,counter = 0;
	check[1]++;
	rep(i,0,k+1){
		if(check[mapping[current]])
			break;
		else{
			current = mapping[current];
			check[current]++;
			counter++;
		}
	}
	
	k-=(counter+1);
	//cout<<counter+1<<" ";
	current = mapping[current];
	int start = current;
	check[current]++;
	counter = 0;
	while(check[mapping[current]] != 2){
			counter++;
			current = mapping[current];
			check[current]++;
	}
	
	current = mapping[current];
	int size = counter+1;
	k = k%size;
	//cout<<k<<" "<<size;
	
	current = start;
	rep(i,0,k){
		current = mapping[current];
	}
	cout<<current;
    
    return 0;
}


Measured memory_bytes: 18556
def ri():
    return int(input())


def rii():
    return [int(v) for v in input().split()]


def solve():
    N = ri()
    ans = 0
    for a in range(1, N):
        b = 1
        while b * a < N:
            ans += 1
            b += 1
    print(ans)


if __name__ == "__main__":
    solve()

Measured memory_bytes: 9100
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
    if( *(long long*)a - *(long long*)b < 0 )
        return -1;
    if( *(long long*)a - *(long long*)b > 0 )
        return 1;
    return 0;
}

int main (void)
{
    long long N, A[(int)1e5];
    long long i, ans = 0, bsb, sbs;

    scanf("%lld", &N);

    for (i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }

    qsort(A, N, sizeof(long long), compare);

    if (N % 2) {
        for (i = 0; i < ((N - 3) / 2); i++) ans += -2 * A[i];
        sbs  = -1 * A[i]; bsb  = -2 * A[i++];
        sbs += -1 * A[i]; bsb +=  1 * A[i++];
        sbs +=  2 * A[i]; bsb +=  1 * A[i++];
        ans += (sbs > bsb) ? sbs : bsb;
        for (;i < N; i++) ans += 2 * A[i];
    } else {
        for (i = 0; i < ((N - 2) / 2); i++) ans += -2 * A[i];
        ans += -1 * A[i++];
        ans +=  1 * A[i++];
        for (;i < N; i++) ans += (2 * A[i]);
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<vector>
#include<limits>
#include<numeric>
using namespace std;
long long n;
int main()
{
    while(scanf("%lld",&n) && n!=0)
    {
    	for(long long s=50000;s>=1;s--)
    	{
    		long long i=2*n+s-s*s;
    		i/=2*s;
    		if(s*(s-1+2*i)==2*n && s>0 && i>0)
    		{
    			printf("%lld %lld\n",i,s);
    			break;
    		}
    	}
    }
	return 0;
}


Measured memory_bytes: 3224
using System.Text;
using static System.Math;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var tab = new List<int>();
        var tp = new List<int>();
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = int.Parse(line[1]);
            var g = int.Parse(line[2]);
            for (int j = a; j <= b; j++)
            {
                tab.Add(j);
                tp.Add(g);
            }
        }
        tab.Add(0); tp.Add(0);
        var L = tab.ToArray();
        var good = tp.ToArray();
        var m = int.Parse(Console.ReadLine().Trim());
        var q = new int[m];
        var qmax = 0;
        for (int i = 0; i < m; i++)
        {
            var w = int.Parse(Console.ReadLine().Trim());
            q[i] = w;
            qmax = Max(qmax, w);
        }
        var LL = L.Length;

        var dp = new int[LL + 1, qmax + 1];
        for (int i = 0; i < LL; i++)
            for (int j = 0; j <= qmax; j++)
                if (j < L[i]) dp[i + 1, j] = dp[i, j];
                else dp[i + 1, j] = Max(dp[i, j], dp[i + 1, j - L[i]] + good[i]);
        var ans = new int[m];
        for (int i = 0; i < m; i++)
        {
            var tw = dp[LL, q[i]];
            if (tw == 0) { Console.WriteLine(-1); goto exit; }
            else ans[i] = tw;
        }
        var sb = new StringBuilder();
        foreach (var x in ans) sb.Append(string.Format("{0}\n", x));
        Console.Write(sb);
        exit:;
    }
    public static void readData(int[] good, int[] L)
    {
        for (int i = 0; i < good.Length - 1; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            good[i] = int.Parse(line2[0]);
            L[i] = int.Parse(line2[1]);
        }
    }
}


Measured memory_bytes: 255632
#include<iostream>
using namespace std;
 
int gcd(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(y>0){
    int r=x%y;
    x=y;
    y=r;
  }
  return x;
}
 
int main(){
  int x,y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
 
  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
  int N;
  while(1){
    cin>>N;
    if(N==0){
      break;
    }
    VE V;
    FOR(i,0,N){
      string S;
      cin>>S;
      V.PB((int)S.size());
    }
    FOR(i,0,N){
      int sum=0;
      int now=i;
      while(sum<5){
        sum+=V[now];
        now++;
      }
      if(sum!=5){
        continue;
      }
      while(sum<12){
        sum+=V[now];
        now++;
      }
      if(sum!=12){
        continue;
      }
      while(sum<17){
        sum+=V[now];
        now++;
      }
      if(sum!=17){
        continue;
      }
      while(sum<24){
        sum+=V[now];
        now++;
      }
      if(sum!=24){
        continue;
      }
      while(sum<31){
        sum+=V[now];
        now++;
      }
      if(sum==31){
        cout<<i+1<<endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  string s;
  cin >> s;
  string ans = "Yes";
  rep(i, s.size()) {
    if (i % 2 == 0) {
      if (s[i] == 'R') continue;
      if (s[i] == 'U') continue;
      if (s[i] == 'D') continue;
      ans = "No";
    } else {
      if (s[i] == 'L') continue;
      if (s[i] == 'U') continue;
      if (s[i] == 'D') continue;
      ans = "No";
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int H, N; cin >>H>>N;
    vi A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vvi dp(N+1, vi(H+1, INT_MAX));    
    dp[0][0]=0;

    rep1(i, N+1) {
        rep(j, H+1) {
            // D3(i,j, dp[i][j]);
            if (dp[i-1][j] != INT_MAX) dp[i][j] = dp[i-1][j];
            if (j >= A[i-1]) {
                if (dp[i-1][j-A[i-1]] != INT_MAX)
                    chmin(dp[i][j], dp[i-1][j-A[i-1]] + B[i-1]);
                if (dp[i  ][j-A[i-1]] != INT_MAX)
                    chmin(dp[i][j], dp[i ][j-A[i-1]] + B[i-1]);
                
            }
            if (j == H) {
                // int mi = INT_MAX;
                int s = max(0, j-A[i-1]+1);
                int e = j-1;
                for (int k = s; k <= e; k++)
                    if (dp[i-1][k] != INT_MAX)
                        chmin(dp[i][j], dp[i  ][k] + B[i-1]);
                for (int k = s; k <= e; k++)
                    if (dp[i  ][k] != INT_MAX)
                        chmin(dp[i][j], dp[i  ][k] + B[i-1]);
            }
        }
    }

    int ans = dp[N][H];

    // rep(i, dp.size()) {
    //     rep(j,dp[i].size()) {
    //         cout << setw(3) << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << ans << endl;
}


Measured memory_bytes: 39552
#include<bits/stdc++.h>
using namespace std;
int n;
char s[200];
int main()
{
	cin>>n>>s;
	int R=0,B=0;
	for(int i=0;i<n;i++)
		if(s[i]=='R')R++;
		else B++;
	puts(R>B?"Yes":"No");
}


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

int main() {
    int n, x, y, z; cin >> n >> x >> y >> z;
    const int m = x + y + z;
    int trans[m][11];
    for (int d = 1; d <= 10; d++) {
        for (int j = 0; j < x; j++)
            if (j + d <= x) trans[j][d] = j + d;
            else trans[j][d] = 0;
        for (int j = x; j < x+y; j++)
            if (j + d <= x + y) trans[j][d] = j + d;
            else trans[j][d] = 0;
        for (int j = x+y; j < m; j++)
            if (j + d <= m) trans[j][d] = j + d;
            else trans[j][d] = 0;
    }

    int trans2[1<<m][11];
    for (int d = 1; d <= 10; d++) {
        for (int s = 1; s < 1<<m; s++) {
            int t = 1;
            for (int i = 0; i < m; i++) {
                if ((s>>i)&1) {
                    if (trans[i][d] < m) t |= 1 << trans[i][d];
                }
            }
            trans2[s][d] = t;
        }
    }

    long long dp[2][1<<m];
    int prev = 0, cur = 1;
    memset(dp, 0, sizeof dp);
    dp[prev][1] = 1;
    long long ans = 0;
    const int M = 1000000007;
    long long res = 1, inv10 = 700000005;
    for (int i = 0; i < n; i++) res = res * 10 % M;
    for (int i = 0; i < n; i++) {
        res = res * inv10 % M;
        fill(dp[cur], dp[cur]+(1<<m), 0);
        for (int s = 1; s < 1<<m; s++)
            for (int d = 1; d <= 10; d++) {
                if (d >= m) dp[cur][1] += dp[prev][s];
                else if (x + y <= m - d && ((s >> (m - d)) & 1))
                    ans += dp[prev][s] * res % M;
                else dp[cur][trans2[s][d]] += dp[prev][s];
            }
        for (int s = 1; s < 1<<m; s++) dp[cur][s] %= M;
        swap(prev, cur);
    }
    cout << ans % M << endl;
}


Measured memory_bytes: 7936
import sys
input = sys.stdin.buffer.readline

def main():
    N,K = map(int,input().split())
    a = [0] + list(map(int,input().split())) + [0]
    
    for i in range(K):
        imos = [0]*(N+2)
        for j in range(1,N+1):
            num = a[j]
            imos[max(j-num,0)] += 1
            imos[min(j+num+1,N+1)] -= 1
        for j in range(N+1):
            imos[j+1] = imos[j]+imos[j+1]
        imos[0] = 0
        a = imos
        if sum(a[1:N+1]) == N**2:
            break
    
    print(*a[1:N+1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 167672
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x;
    if(a%x==0)cout << b/x-a/x+1 << "\n";
    else cout << b/x-a/x << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char str[10],max_str[100][10];
  int i,j,k,max=0,cnt=0;
  scanf("%s",str);
  for(i=0;i<strlen(str);i++){
    if((str[i]!='A'&&str[i]!='C')&&(str[i]!='G'&&str[i]!='T')){
        continue;
    }
    cnt=0;
    for(j=i,k=0;j<strlen(str);j++,k++){
      if((str[j]!='A'&&str[j]!='C')&&(str[j]!='G'&&str[j]!='T')){
        break;
      }else{
      	cnt++;
      }
    }
    if(cnt>max){
      max=cnt;
    }
  }
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;
fn cost(xs: &[i32]) -> usize {
    let f = xs[0];
    let l = xs[xs.len()-1];

    if f < 0 && l > 0 {
        let len = l - f + cmp::min(l.abs(), f.abs());
        // println!("{:?} {}", xs, len);
        return len as usize;
    } else if f > 0 {
        return l as usize;
    } else {
        return (f * -1) as usize;
        // println!("{:?} {}", xs, f * -1);
    }
}

fn main() {
    input!{
        n: i32,
        k: i32,
        xs: [i32; n]
    }
    // println!("{:?}", xs);

    let mut min = 0;
    for i in 0..(xs.len()-k as usize + 1) {
        let e = i + k as usize;
        if min == 0 {
            min = cost(&xs[i..e]);
        } else {
            min = cmp::min(cost(&xs[i..e]), min);
        }
    }
    println!("{:?}", min);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x, a, b; cin >> x >> a >> b; string s;
  if(b - a <= 0) s = "delicious";
  else if(b - a <= x) s = "safe";
  else s = "dangerous";
  cout << s << endl;
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BROTN {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        string s;
        cin >> s;
        REP(i, s.size()) {
            s[i] += N;
            if (s[i] > 'Z') {
                s[i] = s[i] - 'Z' + 'A' - 1;
            }
        }
        cout << s << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BROTN solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
 
typedef int ll;
 
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'
 
typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;
 
const int mod=1e9+7;
 
int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}
 
void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}
 
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}
 
ll main() {
	// freopen("Task.in", "r", stdin);freopen("Task.out", "w", stdout);
	string s;
	cin>>s;

	int ret=0;
	for (int i=0; i<sz(s); i++) {
		ret+=(s[i]-'0');
		ret%=9;
	}
	if(ret)	cout<<"No\n";
	else	cout<<"Yes\n";
}

Measured memory_bytes: 3756
object Main {
	def check(board: Array[Char]) : Char = {
		val list = List((0,1,2), (0,3,6), (0,4,8), (2,4,6), (3,4,5), (6,7,8), (1,4,7), (2,5,8))
		for(l <- list){
			if(board(l._1) == board(l._2) && board(l._1) == board(l._3)){
			  if(board(l._1) == 'o') return 'o'
			  else if(board(l._1) == 'x') return 'x'
			}
		}
		return 'd'
	}
    def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        while(sc.hasNext){
            val board = sc.next.toCharArray
            println(check(board))
        }
    }
}

Measured memory_bytes: 44888
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main(){
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if(e - a <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
  int n; cin >> n;
  vector<int> A(100010);
  rep(i, n){
      int a; cin >> a;
      A[a]++; A[a+1]++; if(a!=0) A[a-1]++;
  }
  int mx = -1;
  rep(i, 100001){
      mx = max(mx, A[i]);
  }   
  cout << mx << ln;
}

Measured memory_bytes: 640
s=input()
ans=0
s=s[:-1]
for i in range(len(s)):
    if len(s)%2==0:
        if s[:len(s)//2]==s[len(s)//2:]:
            ans=max(len(s),ans)
            
        else:
            s=s[:-2]
    else:
        s=s[:-1]
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
ll n;
double dp[301][301][301];
double solve(ll one, ll two, ll three){
    if(one < 0 || two < 0 || three < 0){
        return 0;
    }
    if(one == 0 && two == 0 && three == 0){
        return 0;
    }
    if(dp[one][two][three] > 0){
        return dp[one][two][three];
    }
    ll total = one + two + three;
    double ans = n + one*solve(one-1,two,three) + two*solve(one+1,two-1,three) + three*solve(one,two+1,three-1);
    ans/=total;
    return dp[one][two][three] = ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    ll one=0, two=0, three=0;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        if(x == 1){
            one++;
        }
        else if(x == 2){
            two++;
        }
        else if(x == 3){
            three++;
        }
    }
    cout<<fixed<<setprecision(10)<<solve(one,two,three)<<"\n";
}
    
    


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

int main() {
  string N;
  cin >> N;
  N = '0' + N;
  int n = N.size();
  int ans = 0;
  for (int i = n-1; i >= 0; i--) {
    int ni = N[i] - '0';
    if (ni < 5 || (ni == 5 && N[i-1] - '0' < 5)) {
      ans += ni;
    } else {
      ans += 10 - ni;
      N[i-1]++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2308
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int64, n)

	m := map[int64]int64{}
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
		m[aa[i]] = m[aa[i]] + 1
	}
	var ans int64
	for _, c := range m {
		ans += c * (c - 1) / 2
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, ans-m[aa[i]]+1)
	}
}


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

void divisor_calc(int n, int ii, vector<vector<int>> &d)
{
    for (int i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            d[ii].push_back(i);
            if(i * i != n)d[ii].push_back(n / i);
        }
    }
    sort(d[ii].begin(), d[ii].end());
    return;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mapa;
    vector<vector<int>> divisor(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(!mapa.count(a[i]))
        {
            mapa[a[i]] = 1;
        }
        else
        {
            mapa[a[i]]++;
        }
        
    }
    sort(a.begin(), a.end());
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        int searchv = a[i];
        if(mapa[searchv] != 1)
        {
            while (i < n && a[i] == searchv)i++;
            if(i == n)break;
            else
            {
                i--;
                continue;
            }
        }
        divisor_calc(a[i], i, divisor);
        //cout << a[i] << ":";
        //for (int j = 0; j < (int)divisor.at(i).size(); j++)cout << divisor[i][j] << " ";
        //cout << endl;

        bool ansp = true;
        for (int j = 0; j < (int)divisor.at(i).size() - 1; j++)
        {
            bool iter = binary_search(a.begin(), a.end(), divisor[i][j]);
            if(iter)ansp = false;
        }
        if(ansp)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 35244
import itertools
import math

N = int(raw_input());
S = raw_input().strip()

def good(s):
    if len(s) % 2 == 1:
        return False
    
    n = len(s) / 2
    return all(s[i] == s[i+n] for i in range(n))

print "Yes" if good(S) else "No"


Measured memory_bytes: 27884
#pragma gcc optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s, t; cin >> s >> t;
    int ans = t.size();
    for (int i = 0; i < s.size() - t.size() + 1; ++i) {
        int cur = 0;
        for (int j = 0; j < t.size(); ++j) {
            if (s[i + j] != t[j]) ++cur;
        }
        ans = min(ans, cur);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3644
//APJ ALDS1_1_C
#include <stdio.h>

int prime (int x) {
	int i;
	if ((x != 2) && (x % 2 == 0)) {
		return 0;
	}else if (x == 2) {
		return 1;
	}

	if (x < 2) {
		return 0;
	}

	for (i = 3; i * i <= x; i += 2) {
		if (x % i == 0) {
			return 0;
		}
	}

	return 1;
}

int main () {
	int a,m,count = 0,n;
	scanf("%d", &n);

	for (a = 0; a < n; a++) {
		scanf("%d", &m);
		if (prime(m) == 1) {
			count++;
		}
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 2116
n = int(input())
a = []
xy = []
for i in range(n):
    a.append(int(input()))
    xy.append([])
    for j in range(a[i]):
        xy[i].append(list(map(int, input().split())))
# print(xy)

ans = 0
for i in range(1<<n):   #全部分集合について
    flug = True
    honest_num = 0
    for j in range(n):  #すべての人について
        if i & (1<<j):      #正直者のみ証言を考える
            honest_num += 1
            for k in range(a[j]):   #全証言について
                x = xy[j][k][0]
                y = xy[j][k][1]
                # print((i>>(x-1)) & 1 != y, (i>>(x-1)) & 1, bin(1<<(x-1)), x, y)
                if (i>>(x-1)) & 1 != y: #証言とデータが不一致
                    flug = False
                    # break
    # print(bin(i), flug)
    if flug:
        if honest_num > ans:
            ans = honest_num
print(ans)

Measured memory_bytes: 3064
import numpy as np
from numba import njit
 

@njit
def f(A):
    N = len(A)
    cnt = 0
    
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                cnt += (A[k] < A[i] + A[j])
    return cnt


N = int(input())
A = np.int32(input().split())
A.sort()
print(f(A))


Measured memory_bytes: 110348
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define mod 1000000007


int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll red=0;
  rep(i,n){
    if(s[i]=='R')red++;
  }
  if(red>n-red)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n - 2) {
        if (s.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3640