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

bool checkInputParameter(const int param)
{
    if ( !(0 <= param) || !(param <= 100)) {
        return false;
    }
    
    return true;
}

void compareParameter(const int a, const int b, const int c)
{
    if (a < b && b < c) {
        std::cout << "Yes" << std::endl;
        return;
    }

    std::cout << "No" << std::endl;
}

int main(int argc, char* argv[])
{
    int a,b,c;
    
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    
    if ( (checkInputParameter(a) == false)
      || (checkInputParameter(b) == false)
      || (checkInputParameter(c) == false))
        goto END;

    compareParameter(a, b, c);

END:
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define ll long long
char s[300005];

int main()
{
    scanf("%s",s);
    int l=strlen(s);
    int x=l-2;
    if(s[0]==s[l-1])
    {
        if(x%2==0) printf("First");
        else printf("Second");
    }
    else
    {
        if(x%2==1) printf("First");
        else printf("Second");
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long ll;
int main(){

  ll ans = -1e9;

  int N;
  cin >> N;
  vector<vector<int>> F;

  for(int i = 0;i < N;i++){
    vector<int> f(10);
    for(int i = 0;i < 10;i++)cin >> f[i];
    F.push_back(f);
  }

  vector<vector<int>> P;
  for(int i = 0;i < N;i++){
    vector<int> p(11);
    for(int i = 0;i < 11;i++)cin >> p[i];
    P.push_back(p);
  }

  for(int i = 0;i < (1 << 10);i++){
    vector<int> open;
    bool flag = false;
    for(int j = 0;j < 10;j++){
      if((i >> j) & 1){
        open.push_back(1);
        flag = true;
      }
      else open.push_back(0);
    }

    if(!flag)continue;

    vector<int> cnt;
    for(int i = 0;i < N;i++){
      int now_cnt = 0;
      for(int j = 0;j < 10;j++){
        if(open[j] == F[i][j] && open[j] == 1)now_cnt++;
      }
      cnt.push_back(now_cnt);
    }

    ll now_cost = 0;
    for(int i = 0;i < N;i++)now_cost += P[i][cnt[i]];

    ans = max(now_cost,ans);


  }

  cout << ans << endl;


}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *L = map(int, read().split())

L.sort()
ans = 0

for i in range(1,N-1):
    upper = N-1
    for j in reversed(range(0,i)):
        sum = L[i] + L[j]

        if upper == N :
            upper = N-1

        while upper > i and sum <= L[upper]:
            upper -= 1
        ans += upper-i

print(ans)




Measured memory_bytes: 3188
#include <stdio.h>

int main() {
	int i, N, T, t[200000], sum = 0;

	scanf("%d %d", &N, &T);
	scanf("%d", &t[0]);

	for (i = 1; i < N; i++) {
		scanf("%d", &t[i]);
		if(t[i] - t[i - 1] > T) sum = sum + T;
		else sum = sum + (t[i] - t[i - 1]);
	}

	printf("%d\n", sum + T);

	return 0;
}

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

int main() {
#ifdef LOCAL_DEFINE
  // freopen("data.in", "rt", stdin);
  // freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	const int inf = 1e9;
	vector<int> dp(n, inf);
	dp[0] = 0, dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << '\n';

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int x=-1;
    for(int k=1; k<=100000; ++k){
        if(n==(ll)k*(k-1)/2){
            x=k;
            cout<<"Yes"<<endl;
            cout<<k<<endl;
            break;
        }
    }
    if(x==-1){cout<<"No"<<endl; return 0;}
    vector<vector<int>>ans(x);
    int num=1;
    for(int i=0; i<x; ++i){
        for(int j=i+1; j<x; ++j){
            ans[i].push_back(num);
            ans[j].push_back(num);
            num++;
        }
    }
    rep(i,x){
        cout<<ans[i].size()<<" ";
        rep(j,x-1){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=3.14159265358979323846;
int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double kakuA = (PI * (h + (m / 60)))/6;
    double kakuB = PI * m / 30;
    double thita = abs(kakuA - kakuB);

    double ans = a*a + b*b - 2*a*b*cos(thita);
    ans = sqrt(ans);
    cout << fixed << setprecision(10);
    cout << ans;

    return 0;
}

Measured memory_bytes: 4228
// AOJ 1089: Strawberry Cake
// 2017.12.18 bal4u@uu

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

#define N 1000
#define D 0.01
#define EPS 1e-8

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } LINE;

PP a[21]; int n;

int dcmp(double x)
{
	if (fabs(x) < EPS) return 0;
	return x < 0 ? -1 : 1;
}

double cross(double ax, double ay, double bx, double by) { return ax*by - ay*bx; }

void lineIntersection(PP *p, LINE *a, PP *vs, PP *ve)
{
    double a1, a2;

	a1 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->s.x - vs->x, a->s.y - vs->y);
	a2 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->e.x - vs->x, a->e.y - vs->y);
	p->x = (a->s.x*a2 - a->e.x*a1) / (a2-a1);
	p->y = (a->s.y*a2 - a->e.y*a1) / (a2-a1);
}

int convex_cut(LINE *u, int n, PP *p, PP *po)
{
	int i, d1, d2, top = 0;

    for (i = 0; i < n; i++) {
        d1 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
						p[i].x - u->s.x, p[i].y - u->s.y));
        d2 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
				      p[i+1].x - u->s.x, p[i+1].y - u->s.y));
        if (d1 >= 0) po[top++] = p[i];
        if (d1*d2 < 0) lineIntersection(po + top++, u, p+i, p+i+1);
    }
	po[top] = po[0];
#if 0
printf("convex_cut %d\n", top);
for (i = 0; i < top; i++) printf("[%d] (%lf,%lf)\n", i+1, po[i].x, po[i].y);
#endif
	return top;
}

#if 0
double area(int n, PP *p)
{
	int i;
    double s = 0;

    for (i = 1; i < n-1; i++) {
        s += cross(p[i].x-p[0].x, p[i].y-p[0].y, p[i+1].x-p[0].x, p[i+1].y-p[0].y);
    }
    return fabs(s) / 2;
}
#endif

double area(int n, PP *pp)
{
   int i;
   double s;

   for (s = 0, i = 0; i < n; i++) {
      s += (pp[i].x - pp[i+1].x) * (pp[i].y + pp[i+1].y);
   }
   return fabs(s)/2;
}

double calc(double x, double s)
{
	int k;
	PP b[30];

	LINE u;
	u.s.x = u.s.y = 0;
	u.e.x = 128*cos(x), u.e.y = 128*sin(x);
	k = convex_cut(&u, n, a, b);
	return area(k, b) / s;
}

int main()
{
	int i, x, y;
	double s, s1, s2, l, r, m;

	while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) {
			scanf("%d%d", &x, &y);
			a[i].x = x, a[i].y = y;
		}
		a[n] = a[0];
		s = area(n, a);

		l = 0, r = D, s1 = calc(0, s);
		for ( ; ; l+=D, r+=D, s1 = s2) {
			s2 = calc(r, s);
			if (s1 <= 0.5 && s2 >= 0.5) {
				i = N; while (i--) {
					m = (l+r)/2;
					if (calc(m, s) <= 0.5) l = m; else r = m;
				}
				break;
			}
		}
		printf("%.15lf %.15lf\n", 128*cos(m), 128*sin(m));
	}
	return 0;
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
    FAST
    long double d,t,s;
    cin>>d>>t>>s;
    long double ans = d/s;
    if(ans <= t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3740
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    ans = 0
    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

    if A > B:
        ans += A
        A -= 1
    else:
        ans += B
        B -= 1

    return ans


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


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


void solve(long long A, long long B, long long C){
    vector<long long> abc = {A,B,C};
    sort(abc.begin(), abc.end());
    long long d1l = abc[2]-abc[1], d2l=abc[2]-abc[0];
    double d1 = (double)d1l, d2 = (double)d2l, ans;

    if(d1l%2==0 && d2l%2==0) ans=min(d1/2+d2/2, d1+(d2-d1)/2);
    else if(d1l%2==0 && d2l%2==1) ans=min(d1/2+ceil(d2/2)+1, d1+ceil((d2-d1)/2)+1);
    else if(d1l%2==1 && d2l%2==0) ans=min(d2/2+ceil(d1/2)+1, d1+ceil((d2-d1)/2)+1);
    else ans=min(floor(d1/2)+floor(d2/2)+1, d1+(d2-d1)/2);
    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
for i in range(n-1):
  if s[i]!=s[n-2-i]:
    print(-1)
    exit()
if s[-1]=="1" or s[0]=="0":
  print(-1)
  exit()
G=[]
p=n-1
for i in range(n-1)[::-1]:
  G.append([i+1,p+1])
  if s[i]=="1":
    p=i
for i in range(n-1):
  print(G[i][0],G[i][1])
      

Measured memory_bytes: 56864
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=3e5+5;

ll dp[N][21];

int main()
{ 

IOS;

ll n;cin>>n;

vl a(n+1);

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

sort(a.begin()+1,a.end());

ll md=a[n/2];

ll ans1=0,ans2=0;

for(int i=1;i<=n;i++)
{
  ans1+=abs(a[n/2]-a[i]);
  ans2+=abs(a[n/2+1]-a[i]);
}

cout<<min(ans1,ans2)<<endl;

return 0;
 
}



Measured memory_bytes: 4764
function main(input) {
  var S = input[0];
  var K = input[1]-0;
  var olen = 0;
  var ans = 1;
  for(var i=0;i<S.length;i++){
    if(S[i]=="1") olen++;
    else {ans=S[i];break;};
  }
  if(olen>=K) console.log(1);
  else{
    console.log(ans);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

using namespace std;

int main()
{
    vector<int> vec(3);
    int k;
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
    cin >> k;
    for (int i = 0; i < k; i++) {
        if (vec.at(0) < vec.at(1) && vec.at(1) < vec.at(2)) {
            vec.at(2) *= 2;
        } else if (vec.at(1) < vec.at(2)) {
            vec.at(1) *= 2;
        } else {
            vec.at(2) *= 2;
        }
    }

    if (vec.at(0) < vec.at(1) && vec.at(1) < vec.at(2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3536
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,m,k;
cin >> n >> m >> k;
vector<ll> a(n + 1,0),b(m + 1,0);
rep(i,n){
    ll A;
    cin >> A;
    a[i + 1] = a[i] + A;
}
rep(i,m){
    ll B;
    cin >> B;
    b[i + 1] = b[i] + B;
}
ll ans = 0;
rep(i,n + 1){
    if(a[i] <= k) {
        auto Iter = upper_bound(b.begin(), b.end(), k - a[i]);
        ans = max(i - 1 +  (Iter - b.begin()),ans);
    }
}
cout << ans << endl;
}

Measured memory_bytes: 6384
# coding: utf-8
# Your code here!
s=list(input())

a=0
z=len(s)-1
count=0

while a<z:
    if s[a]==s[z]:
        a+=1
        z-=1
    else:
        if s[a]=="x":
            a+=1
            count+=1
        elif s[z]=="x":
            z-=1
            count+=1
        else:
            print(-1)
            exit()
    
print(count)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
vector<int>G[N];
int main(){
    int n;
    cin>>n;
    int a[n+2];

    for(int i=2;i<=n;i++) cin>>a[i],G[a[i]].push_back(i);
    for(int i=1;i<=n;i++) cout<<G[i].size()<<endl;
    return 0;
}



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

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

  if (a-b >= 0) {
    cout << "delicious" << endl;
  } else if (a-b < 0 && abs(a-b) <= x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main() {
    int N, K, L; cin >> N >> K >> L;
    UnionFind road(N);
    UnionFind train(N);


    for(int i=0; i<K; i++){
        int p, q; cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }
    
    for(int i=0; i<L; i++){
        int r, l; cin >> r >> l;
        r--; l--;
        train.unite(r, l);
    }
    
    map<PII, int> M;
    for(int i=0; i<N; i++)
        M[PII(road.root(i), train.root(i))]++;
    
    for(int i=0; i<N; i++)
        cout << M[PII(road.root(i), train.root(i))] << " ";
    
    cout << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n;
vl x;
ll ans = INF;

int main(){
  cin >> n;
  x = vl(5);
  for(ll i = 0;i < 5;i++) cin >> x[i];
  ll y = *min_element(x.begin(),x.end());
  cout << (n+y-1)/y+4 << endl;

}


Measured memory_bytes: 256
n,m=map(int,input().split())
A=[[] for i in range(n)]

for i in range(m):
    j,k=map(int,input().split())
    A[j-1].append(k-1)
    A[k-1].append(j-1)
for i in range(len(A[0])):
    if n-1 in A[A[0][i]]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 38396
from itertools import product

def read():
    s = int(input())
    return s,


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def solve(s):
    a = s
    count = [0] * 5
    i = 1
    while True:
        if a in [1, 2, 4]:
            count[a] += 1
            if count[a] == 2:
                break
        a = f(a)
        i += 1
    return i

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, d, a[N], dp[N];

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    scanf("%d %d",&n ,&d);
    int koru = d+d+1;
    int ans = n/koru;
    if(n % koru != 0)
      ans++;
    printf("%d\n", ans );
    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dp[5100];

void func(long long N, long long P, std::vector<long long> A){
    dp[0]=1;

    REP(i,0,N){
        for(lli j=5099;j>=0;j--){
            if(dp[j])dp[j+A[i]] += dp[j];
        }
    }
    lli ans = 0;

    REP(i,0,5099){
        if(i%2==P)ans += dp[i];
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long P;
    scanf("%lld",&P);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, P, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class DisjointSet {
    public:
        DisjointSet(int n) : N(n), pars(n, -1), sz(n) {

        }


        int find(int x) {
            return pars[x] < 0 ? x : (pars[x] = find(pars[x]));
        }

        bool unite(int x, int y) {
            x = find(x), y = find(y);
            if (x == y) {
                return false;
            }
            --sz;
            if (pars[x] < pars[y]) {
                swap(x, y);
            }
            pars[y] += pars[x];
            pars[x] = y;
            return true;
        }

        int size() { return sz; }
        int count(int x) {
             return -pars[find(x)];
        }

    private:
        int N;
        int sz;
        vector<int> pars;
};


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> edges;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        edges.emplace_back(u, v);
    }

    DisjointSet ds(n);
    vector<long long> res(m, 0);

    for (int i = m - 1; i >= 0; --i) {
        int u = edges[i].first, v = edges[i].second;

        u = ds.find(u), v = ds.find(v);
        if (u != v) {
            res[i] = ds.count(u) * 1LL * ds.count(v);
            ds.unite(u, v);
        }
    }
    for (int i = 1; i < m; ++i) {
        res[i] += res[i - 1];
    }

    for (int i = 0; i < m; ++i) {
        cout << res[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,x;
vector<ll> a;

int main(){
    cin >> N >> x;
    a.resize(N);
    rep(i,N){
        cin >> a[i];
    }

    ll ans = 0;
    if(a[0] > x){
        ans += a[0] - x;
        a[0] = x;
    }

    for(int i=1;i<N;i++){
        int sum = a[i-1] + a[i];
        if(sum > x){
            a[i] -= sum-x;
            ans += sum-x;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, 0, n){
        int tmp = a[i] - (i == 0 ? 0 : a[i - 1]);
        if(tmp % 2) ans ^= n - i;
    }
    if(ans == 0) cout << "second" << endl;
    else cout << "first" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  if(S[0] == 'S') cout << "Cloudy" << endl;
  else if(S[0] == 'C') cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  
  return 0;
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    string s; cin >> s;
    s[5]=' '; s[13]=' ';
    cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long ans=0ll,n;
	scanf("%lld",&n);
	for(long long i=1ll;i<=n;i++){
		if(i%3ll==0ll||i%5ll==0ll) continue;
		ans+=i;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1688
import sys
input = sys.stdin.readline
def calc(A, B, C, K):
    sum = 0
    if K>A:
        sum += A
        K = K-A
    else:
        sum = K
        return sum
    if K>B:
        K = K - B
    else:
        return sum
    sum = sum - K
    return sum


def main():
    A, B, C, K = map(int, input().split())
    sum = calc(A,B,C,K)
    print(sum)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N, M, K, A, B):
    na = 0
    A = [0] + A
    for i in range(1, len(A)):
        A[i] += A[i - 1]
        if A[i] > K:
            break
        na += 1
    nb = 0
    B = [0] + B
    for i in range(1, len(B)):
        B[i] += B[i - 1]
        if B[i] > K:
            break
        nb += 1
    ans = nb
    t = nb
    for i in range(1, na + 1):
        for j in range(t, -1, -1):
            if A[i] + B[j] <= K:
                ans = max(ans, i + j)
                t = j
                break
    return ans


(N, M, K) = tuple([int(s) for s in input().split()])
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]
print(calc(N,M,K,A,B))

Measured memory_bytes: 111940
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static long[][] dp;
    static int ind=1;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    Integer[] A=new Integer[n];
	    Integer[] B=new Integer[n];
	    Integer[] C=new Integer[n];

        for (int i=0; i< n;i++) {
        	A[i]=gi();
        }
        for (int i=0; i< n;i++) {
        	B[i]=gi();
        }
        for (int i=0; i< n;i++) {
        	C[i]=gi();
        }

        Arrays.parallelSort(A, Collections.reverseOrder());
        Arrays.parallelSort(B, Collections.reverseOrder());
        Arrays.parallelSort(C, Collections.reverseOrder());
        long ans=0;
        long[] abb =new long[n];
        long[] bbc =new long[n];

        for (int i=0; i<n;i++) {
        	int l=-1;
        	int r=n;
        	int b=B[i];
        	while(r-l>1) {
        		int ind=(l+r)/2;
        		if(C[ind]<=b) {
        			r=ind;
        		} else {
        			l=ind;
        		}

        	}
        	bbc[i]=r;
        	if(i!=0)bbc[i]+=bbc[i-1];
        }

        for (int i=0; i<n;i++) {
        	int l=-1;
        	int r=n;
        	int a=A[i];
        	while(r-l>1) {
        		int ind=(l+r)/2;
        		if(B[ind]<=a) {
        			r=ind;
        		} else {
        			l=ind;
        		}
        	}
        	if(l>=0) ans+=bbc[l];
        }

        System.out.println(ans);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll t = 0 , n, cons = 1e18, c[MAXX], ans = 1, mx, a[MAXX], b[MAXX] ;

signed main()
{
    FAST;
    cin >> n;
    ll s = 0;
    bool flag = true;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        if(!a[i])
            s++;
    }
    if(s){
        cout << "0" << endl;
        return 0;
    }
    sort(a , a + n);
    ans = 1;
    for(ll i = 0; i < n; i++){
        ans *= a[i];
    if(ans < 0 || ans > 1000000000000000000)
        flag = false;
    }
    ll p = ans;
    for(ll i = 0; i < n; i++){
        p /= a[i];
    }
    if(flag && (p == 1)){
        cout << ans << endl;
    }
    else
        cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 4448
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	}
}



Measured memory_bytes: 21844
import sys
k = int(input())

if k%2 == 0 or k%5 ==0:
    print(-1)
else:
    a = 7%k
    if a == 0:
        print(1)
    else:
        for i in range(2, 10000000):
            a = (10*a+7)%k
            if a == 0:
                print(i)
                sys.exit()
        print(-1)
    


Measured memory_bytes: 9044
import math

N = int(input()) - 1
answer = ''
length = 0

for i in range(1, 12):
    num = 26 ** i # 1 ~ 11
    if N // num < 1:
        length = i
        break
    N -= num

for i in range(length):
    num = 26 ** (length - (i + 1))
    chara = chr(97 + N // num)
    answer += chara
    N -= num * (N // num)
print(answer)

Measured memory_bytes: 9052
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tolower(c) char(c+0x20)
#define toupper(c) char(c-0x20)
#define chartoll(c) ll(c) - ll('0')

const ll MAX_N = 100000;

int main(void){
    ll A, B;
    cin >> A >> B;
    

    cout << max({A+B,A-B,A*B}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  long long int sum=0;
  map<int,int>m;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    m[a[i]]++;
    sum+=a[i];  
  }
  
  int q;
  cin>>q;
  int x,y;
  while(q--)
  {
    cin>>x>>y;
    long long int count = m[x];
    if(x>0)
    {
      m[x]=0;
      m[y]=m[y]+count;
      sum = (sum-(x*count)+(count*y));
      cout<< sum<<endl;
    }
    else
      cout<<sum<<endl;
  }
}


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

#define INF 100000

using namespace std;

int solve2(int n, int r, vector<int> root, vector< vector<int> > &l, vector< vector<int> > &s){
  
  //DP????????????dp[i][j]
  //0????????????i???????????????????????????i?????????????????????????????£?????¨????????????j???????????????0??????i???????????§??????????????¢
  vector< vector<int> > dp;
  dp.resize(r);
  for(int i = 0; i < r; i++) dp[i].resize(n);

  for(int i = 0; i < r; i++){
	for(int j = 0; j < n; j++){
	  if( i == 0  && j == root[0]) dp[i][j] = 0;
	  else dp[i][j] = INF;
	}
  }

  for(int i = 1; i < r; i++){
	for(int j = 0; j < n; j++){//i???????????§???????????????????????¨??????????????????
	  for(int k = 0; k < n; k++){//k : i-1???????????§???????????????????????¨??????????????????
		if(j != k) dp[i][j] = min( dp[i][j], dp[i-1][k] + l[root[i-1]][k] + s[k][j] + l[j][root[i]] );
		else dp[i][j] = min( dp[i][j], dp[i-1][j] + l[root[i-1]][root[i]] );
	  }
	}
  }

  int ans = INF;
  for(int i = 0; i < n; i++){
	ans = min( ans, dp[r-1][i] );
  }
  return ans;
}

void solve1(int n, vector< vector<int> > &l, vector< vector<int> > &s){

 //??????????????¨??????????????????????????¢????????????????±???????
  for(int k = 0; k < n; k++){
	for(int i = 0; i < n; i++){
	  for(int j = 0; j < n; j++){
		l[i][j] = min(l[i][j], l[i][k] + l[k][j]);
		s[i][j] = min(s[i][j], s[i][k] + s[k][j]);
	  }
	}
  }

}

int main(){

  while(1){

	int n, m;
	cin >> n >> m;

	if(n == 0 && m == 0) return 0;

	vector< vector<int> > l, s;
	l.resize(n);
	for(int i = 0; i < n; i++) l[i].resize(n);
	s.resize(n);
	for(int i = 0; i < n; i++) s[i].resize(n);

	for(int i = 0; i < n; i++){
	  for(int j = 0; j < n; j++){
	    if(i == j){
		  l[i][j] = 0;
		  s[i][j] = 0;
		}
		else{
		  l[i][j] = INF;
		  s[i][j] = INF;
		}
	  }
	}

	int x, y, t;
	char sl;

	for(int i = 0; i < m; i++){
	  cin >> x >> y >> t >> sl;
	  if(sl == 'L'){
		l[x-1][y-1] = t;
		l[y-1][x-1] = t;
	  }
	  else{
		s[x-1][y-1] = t;
		s[y-1][x-1] = t;
	  }
	}

	solve1(n, l, s); //??????????????¨??????????????????????????¢????????????????±???????

	int r;
	cin >> r;

	vector<int> root;
	for(int i = 0; i < r; i++){
	  int area;
	  cin >> area;
	  root.push_back(area-1);
	} 

	cout << solve2(n, r, root, l, s) << endl; //????????¨??????????????????????????¢????±???????

  }

  return 0;
}

Measured memory_bytes: 2320
program prob3
    implicit none
    integer(8)::a,b,c,i,tmp
    read(*,*) a,b,c

    tmp = 0
    do i = 1, 1000
        tmp = tmp + a
        if(mod(tmp,b) == c) then
            write(*,'(a)') "YES"
            stop
        end if
    end do
    write(*,'(a)') "NO"
    stop
end program

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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================乱数================*/
/*====================================*/



void init(){
	input();
	return;
}


void output(int ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int main(){
	init();

	int ans[500];

	for(int i = 0;i < n;i++){
		ans[i] = i % 26; 
	}


	output(ans);

	return 0;
}

Measured memory_bytes: 3872
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// -------------------------------------------------------------------------------------

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

  int g = max(a, b);
  int l = min(a, b);

  if(l + w > g) cout << 0 << endl;
  else cout << g - (l + w) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int n, ans = 0;
	cin >> n;
	int lr[n][2];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> lr[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		ans += (lr[i][1] - lr[i][0] + 1);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define                   pi acos(-1)


int main () {
   ll n,r;
   cin>>n>>r;
   ll ans;
   if(n<=10)
    ans=100*(10-n)+r;
   else
    ans=r;
   cout<<ans<<endl;
    End;
}
/* pray for me
All is well
*/





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



int main() {
   int n;
   cin >> n;
   int m = n % 100 % 10;
   if ((m == 2) || (m==4) || (m==5) || (m==7) || (m == 9)) {
      cout << "hon" << endl;
   }
   else if ((m==0)||(m==1)||(m==6)||(m==8)) {
      cout << "pon" << endl;
   }
   else cout << "bon" << endl;
   return 0;
}

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

int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
        for(int i=0;i<s.length();i++)
        {
            int l=(int)s[i];
            l=l+n;
            if(l>90)
            {
                l=65+(l-90)-1;
            }
            s[i]=(char)l;
        }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  if(N%2==0) cout<<N<<endl;
  else cout<<2*N<<endl;
}



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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<ll>k(n),cnt(300000);

    rep(i,n){
        cin>>k[i];
        cnt[k[i]]++;
    }

    ll ans=0;

    rep(i,300000){
        ll K=cnt[i];
        ans+=K*(K-1)/2;
    }

    rep(i,n){
        cout<<ans-(cnt[k[i]]-1)<<endl;
    }

}


Measured memory_bytes: 7224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A[33] = {0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A[K] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N];
//??\??¶????????°??¶???
int d[N];
//??\??¶???????????¶???
int f[N];
//??¶???
int tt;

//??¨???????????°?????°?????±?????????????´¢
void dfs_visit(int u){
    int v;
    //??£??¨???????????°
    color[u]=GRAY;
    //??¶????????°
    d[u]=++tt;
    for(v=0;v<n;v++)
        if(M[u][v]&&color[v]==WHITE)
            dfs_visit(v);
    //????????????
    color[u]=BLACK;
    f[u]=++tt;
}

void dfs(){
    //????§????
    for(int u=0;u<n;u++)
        color[u]=WHITE;
    tt=0;

    for(int u=0;u<n;u++)
        //??\????????????u?????????????????±?????????????´¢
        if(color[u]==WHITE)
            dfs_visit(u);
    for(int u=0;u<n;u++)
        printf("%d %d %d\n",u+1,d[u],f[u]);
}

int main(){
    int u,v,k;

    scanf("%d",&n);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;

    for(int i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(int j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v]=1;
        }
    }

    dfs();
}

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

int main() {
    ll a, b, c, k, ans;
    cin >> a >> b >> c >> k;
    if (k % 2 == 0) {
        ans = a - b;
    } else {
        ans = b - a;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int l[10], v1, v2;
  int len;

  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF){
    len = 0;
    for (int i = 0; i < 10; i++){
      len += l[i];
    }
    double t = (double)len / (v1 + v2);
    double d = (double)v1 * t;
    len = 0;
    for (int i = 0; i < 10; i++){
      len += l[i];
      if (d <= len){
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1208
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = TEN(6);
int n;
string s[MAX_N];

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> s[i];

    vec<pii> pos, neg;
    forn(i, n) {
        int cur = 0;
        int mn = 0;
        for (char c : s[i]) {
            if (c == '(') {
                cur++;
            } else {
                cur--;
            }
            chmin(mn, cur);
        }
        if (cur >= 0) {
            pos.emplace_back(mn, cur);
        } else {
            neg.emplace_back(mn - cur, -cur);
        }
    }

    sort(all(pos), greater<pii>());
    sort(all(neg), greater<pii>());

    int cur1 = 0;
    for (auto [mn, end] : pos) {
        if (cur1 + mn < 0) {
            cout << "No\n";
            return 0;
        }

        cur1 += end;
    }

    int cur2 = 0;
    for (auto [mn, end] : neg) {
        if (cur2 + mn < 0) {
            cout << "No\n";
            return 0;
        }

        cur2 += end;
    }

    cout << (cur1 == cur2 ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 42476
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

using namespace std;

const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};

int Read()
{
	char c;
	c=getchar();

	int tsqua=0;

	while(c!=' '&&c!='\n')
	{
		tsqua=(((tsqua<<1)<<1)<<1)+(tsqua<<1)+(int)(c-'0');

		c=getchar();
	}

	return tsqua;
}

typedef long long ll;

int a,b;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>a>>b;
	
	cout<<max(max(a+b,a-b),a*b);
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

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

int main() {
    ll N ; cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) {
        cin >> A.at(i);
        if (i == 0) B[i] = A[i];
        else B[i] = B[i-1] + A[i];
    }

    ll all = B[N-1];
    ll mi = 1LL << 62;
    rep(i,N-1) {
        mi = min(mi, abs(B[i] - (all - B[i])));
    }
    cout << mi << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <string>
#include <cmath>
#include <cstdio>
#define FOR(I,A,B) for(int I =(A);I<(B);++I)
#define FORE(I,B) for(int I =1;I<=(B);++I)
#define REP(I,A) FOR(I,0,A)
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int INF=1<<30;
using namespace std;
typedef pair<int,int> pr;
typedef tuple<int,int,int> ti;
typedef vector<pr> VP;
typedef vector<VP> VVP;
int DP[300][3];
int main() {
	int n,m,a,b,c;
	
	while(cin>> n >> m && n){
	VVP v(n+1);
	REP(i,300)
		REP(j,3)
			DP[i][j]=INF;
	REP(i,m){
		cin >> a >> b >> c;
		v[a].push_back(pr(c,b));
		v[b].push_back(pr(c,a));
	}
	priority_queue<ti> pq;
	DP[1][0]=0;
	pq.push(ti(0,0,1));
	while(!pq.empty()){
		int c=get<0>(pq.top()),t=get<1>(pq.top()),p=get<2>(pq.top());
		pq.pop();
		if(c!=DP[p][t])
		continue;
		REP(i,v[p].size()){
			int ne=v[p][i].second,co=v[p][i].first;
			if(t%2){
				if(DP[ne][t+1]>c){
					DP[ne][t+1]=c;
					pq.push(ti(DP[ne][t+1],t+1,ne));
				}
			}
			else{
				if(DP[ne][t]>c+co){
					DP[ne][t]=c+co;
					pq.push(ti(DP[ne][t],t,ne));
				}
			}
			if(t==0){
				if(DP[ne][1]>c){
					DP[ne][1]=c;
					pq.push(ti(DP[ne][1],1,ne));	
				}
			}
		}
	}
	cout << min(DP[n][0],DP[n][2]) << endl;
	// your code goes here
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		double r,s,l;

	    try (Scanner sc = new Scanner(System.in)) {
	    	r = sc.nextDouble();
	    }

	    s = r*r*Math.PI;
	    l = 2*r*Math.PI;

	    System.out.println(String.format("%.6f %.6f",s, l));
	}

}


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

int main() {
    int temp, minimum = 10, ans = 0;
    rep(i, 5) {
        cin >> temp;
        ans += 10 * ((temp + 9) / 10);
        if(temp % 10 != 0) minimum = min(temp % 10, minimum);
    }
    if(minimum != 10) ans -= 10 - minimum;
    cout << ans << endl;
}

Measured memory_bytes: 256