akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    a = ii()
    print(a * 2 * math.pi)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int minC = INF;
    for (int i = -100; i <= 100; i++) {
        int tmp = 0;
        for (int ai : a) tmp += (ai - i) * (ai - i);
        minC = min(minC, tmp);
    }
    cout << minC << '\n';
}


Measured memory_bytes: 256
#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 = 1e15;

#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()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll A[MAX_N + 1];
    ll answer = 0;

    cin >> N;
    rep(i, N) cin >> A[i];
    A[N] = INF;
    sort(A, A + N + 1);

    ll cnt = 0;
    rep(i, N){
        if (A[i] == A[i + 1]) cnt ++;
        else {answer += (cnt + 1) % 2; cnt = 0;}
    }

    cout << answer << endl;

    return 0;
}


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

using namespace std;

int N,M,Res;
vector<int> p,Count;
vector< vector<int> > s;

void dfs(int ind) {
	if (ind == N) {
		for (int i = 0; i < M; ++i) {
			if (Count[i]%2 != p[i]) {
				return;
			}
		}
		++Res;
		return;
	}

	dfs(ind+1);
	for (int i = 0; i < s[ind].size(); ++i) {
		++Count[s[ind][i]];
	}
	dfs(ind+1);
	for (int i = 0; i < s[ind].size(); ++i) {
		--Count[s[ind][i]];
	}
	return;
}

int main(void) {
	cin >> N >> M;
	s = vector< vector<int> >(N);
	for (int i = 0; i < M; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int temp;
			cin >> temp;
			s[temp-1].push_back(i);
		}
	}
	p = vector<int>(M);
	for (int i = 0; i < M; ++i) {
		cin >> p[i];
	}
	Res = 0;
	Count = vector<int>(M,0);
	dfs(0);
	cout << Res << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    n, r = map(int, input().split())
    if n >= 10:
        print(r)
        return
    ans = r + 100*(10-n)
    print(ans)
    

main()

Measured memory_bytes: 5076
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string sun ="Sunny",c="Cloudy",r="Rainy";
	string s;
	cin>>s;
	if(s==sun)cout<<c<<endl;
	else if(s==c)cout<<r<<endl;
	else cout<<sun<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main() {
	int n, k;
	cin >> n >> k;
	cout << (n-1+k-2)/(k-1) << endl;
}


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

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

	ll X,K,D;
	ll i,k;
	ll ans=0;
	ll ctr=0;

	cin >> X >> K >> D;

	X=abs(X);
	ctr=K;

	if(X/D <= K){
		ctr-=(X/D);
		X-=D*(X/D);
	}else{
		X-=D*K;
		ctr=0;
	}

	//cout << X << " " << ctr << endl;

	if(abs(X)>abs(X+D)){
		X+=D;
		ctr++;
	}

	//cout << X << " " << ctr << endl;

	if(ctr>0){
		if(X<=0 && ctr%2) X+=D;
		else if(X>0 && ctr%2) X-=D;
	}
	cout << abs(X) << endl;

	return 0;
}



Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	int sum=700;
	FDS(i,3){
		if(s.at(i)=='o'){
			sum+=100;
		}
	}
	cout<<sum<<endl;
}

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

int main(void) {
	int n, q, com, b, e, i;
	scanf("%d", &n);
	vector<int> v(n);
	for (i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d %d %d", &com, &b, &e);
		if (com == 0) {
			cout << *min_element(v.begin() + b, v.begin() + e) << endl;
		} else {
			cout << *max_element(v.begin() + b, v.begin() + e) << endl;
		}
	}
}


Measured memory_bytes: 3244
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int INF=1000000;

int main() {
	int n,t[100001],x[100001],y[100001];
	cin>>n;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=1;i<=n;++i){
		cin>>t[i]>>x[i]>>y[i];
	}
	bool b=false;
	for(int i=1;i<=n;++i){
		if(t[i]-t[i-1]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1])){
			b=true;
			break;
		}
		if((t[i]-t[i-1]-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]))%2>0){
			b=true;
			break;
		}
	}
	if(b)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 1408
N, Y = gets.chomp.split(" ").map(&:to_i)
0.upto(N) do |i|
  0.upto(N-i) do |j|
    k = N - i - j
    sum = 10000*i + 5000*j + 1000*k
    if sum == Y
      puts "#{i} #{j} #{k}"
      exit
    end
  end
end
puts "-1 -1 -1"

Measured memory_bytes: 1788
l = list(str(input()))
l1 = [l[0], l[1]]
l2 = [l[2], l[3]]

a = int(''.join(l1))
b = int(''.join(l2))

if (1 <= a and a <= 12) and (1 <= b and b <= 12):
  print('AMBIGUOUS')
elif (0 <= a and a <= 99) and (1 <= b and b <= 12):
  print('YYMM')
elif (1 <= a and a <= 12) and (0 <= b and b <= 99):
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 3064
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL A,B;
	cin >> A >> B;
	if( abs(A-B) > 1 ){
		cout << 0 << endl;
		return;
	}
	if( A == B ){
		LL res = 1;
		for(LL i=1;i<=A;++i){
			res *= i;
			res %= MOD;
		}
		res = (res*res)%MOD;
		res = (res*2)%MOD;
		cout << res << endl;
		return;
	}else{
		LL ans = 1;
		LL res = 1;
		for(LL i=1;i<=A;++i){
			res *= i;
			res %= MOD;
		}
		ans = res;

		res = 1;
		for(LL i=1;i<=B;++i){
			res *= i;
			res %= MOD;
		}
		ans = (ans * res ) %MOD;
		cout << ans << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

#define MAXQUEUE 100000

struct Process {
	char name[10];
	int time;
};



int main() {
	int N, q;
	int totalTime = 0;
	struct Process queue[MAXQUEUE];
	int beginP, endP;
	scanf("%d %d", &N, &q);
	for (int i = 0; i < N; i++) {
		scanf("%s %d", queue[i].name, &queue[i].time);
	}
	beginP = 0; endP = N;
	while (endP - beginP) {
		if (queue[beginP].time <= q) {
			totalTime += queue[beginP].time;
			printf("%s %d\n", queue[beginP].name, totalTime);
			if (beginP == MAXQUEUE - 1)beginP = 0;
			else beginP = beginP + 1;
		}
		else {

			queue[beginP].time -= q;
			queue[endP] = queue[beginP];
			endP = (endP + 1) % MAXQUEUE; beginP = (beginP + 1) % MAXQUEUE;
			totalTime += q;
		}
	}

	return 0;
}


Measured memory_bytes: 4300
#include <bits/stdc++.h>
#define pb push_back
#define sc1(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sc3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)

using namespace std;

typedef long long int ll;

int main()
{
    string str;
    cin>>str;
    ll ok=1;
    for(ll i=0;i<str.size();i++)
    {
        if(i%2==0&&str[i]!='h')
        {
            ok=0;
            break;
        }
        if(i%2==1&&str[i]!='i')
        {
            ok=0;
            break;
        }
    }
    if(str.size()%2)
    {
        ok=0;
    }
    if(ok)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
typedef long long int ll;
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];


int main(){
  ll n,T; cin >>n>>T;
  vector<int> t(n);
  cinf(n,t);
  ll ans=T*n;
  for(int i=0;i<n-1;i++){
    if(t[i+1]-t[i]<T){
      ans-=(T-t[i+1]+t[i]);
    }
  }
  cout << ans << endl;
}


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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> ans(n, 1);
	for (ll i = 0; i < k; ++i) {
		ll d;
		cin >> d;
		for (ll j = 0; j < d; ++j) {
			ll a;
			cin >> a;
			ans[a - 1] = 0;
		}
	}
	cout << accumulate(ans.begin(), ans.end(), 0ll) << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int l,r,i,sum=0;
  for(i=0;i<n;i++){
    scanf("%d%d",&l,&r);
    sum+=r-l+1;
  }
  if(sum>=100000) sum=100000;
  printf("%d",sum);
  return 0;
}

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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;


signed main(){
	int n;
	cin >> n;
	int mass[n];
	for(int i =0;i<n;i++) cin >> mass[i];
	int s = 0;
	for(int i = 0;i<n;i++){
        for(int z = i+1;z<n;z++){
            s += mass[i]*mass[z];
        }
	}
	cout << s;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> as(n+1);
    vector<int> bs(n);
    for (int i = 0; i < n+1; ++i) {
        cin >> as[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> bs[i];
    }

    long long int cnt = 0;
    for(int i = 0; i < n; i++) {
        if (as[i] <= bs[i]) { // kill all
            cnt += as[i];
            bs[i] -= as[i];
            as[i] = 0;
        } else { // cant kill all, do his best
            cnt += bs[i];
            as[i] -= bs[i];
            bs[i] = 0;
        }

        // next city
        if (as[i+1] <= bs[i]) { // kill all
            cnt += as[i+1];
            bs[i] -= as[i+1];
            as[i+1] = 0;
        } else { // cant kill all, do his best
            cnt += bs[i];
            as[i+1] -= bs[i];
            bs[i] = 0;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll N, M, R;
vector<ll> v;
ll dist[201][201];
void WF(){
    REP(k,0,N){
        REP(i,0,N){
            if(dist[i][k] == inf) continue;
            REP(j,0,N){
                if(dist[k][j] == inf) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main() {
    cin>>N>>M>>R;
    REP(i, 0, R){
        ll r;
        cin>>r;
        r--;
        v.push_back(r);
    }
    REP(i, 0, N){
        REP(j, 0, N) {
            if(i==j) dist[i][j]=0;
            else dist[i][j]=inf;
        }
    }
    REP(i, 0, M){
        int a, b, c;
        cin>>a>>b>>c;
        a--; b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    sort(v.begin(), v.end());
    WF();

    ll ans=inf;
    do{
        ll sum=0;
        REP(i, 0, R-1){
            sum+=dist[v[i]][v[i+1]];
        }
        ans=min(ans, sum);
    } while(next_permutation(v.begin(), v.end()));

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    //解説AC   
  int main(){
      string s;
      cin>>s;
      map<char,lint> mp;
      rep(i,s.size()){
          mp[s[i]]++;
      }
    lint ans=s.size()*(s.size()-1)/2+1;
    for(auto x:mp){
        ans-=((x.second)*(x.second-1)/2);
    }
    cout<<ans<<endl;
  }
  
     


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, x, t;
    scanf("%d%d%d", &n, &x, &t);
    printf("%d\n", t * div_ceil(n, x));
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


signed main(){
  int n;
  cin>>n;
  vector<int> a;
  a.push_back(1);
  int b=6,c=9;
  while(b<100005){
    a.push_back(b);
    b*=6;
  }
  while(c<100005){
    a.push_back(c);
    c*=9;
  }

  vector<int> d(200005,INF);
  d[0]=0;
  rep(i,n+1){
    if(d[i]!=INF){
      rep(j,a.size()){
        cmin(d[i+a[j]],d[i]+1);
      }
    }
  }
  cout<<d[n]<<endl;
 return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include <vector>
#include<string>
#include<map>

using namespace std;

bool b[100009];
int a[100009];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        b[i] = true;
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        if (a[x - 1] < a[y - 1]) {
            b[x - 1] = false;
        } else if (a[x - 1] > a[y - 1]) {
            b[y - 1] = false;
        } else {
            b[x - 1] = b[y - 1] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (b[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;



int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	cin >> n;
	int k = n % 10;
	if (n % 10 == 3) {
		cout << "bon" << endl;
	}
	else if (k == 0 || k == 1 || k == 6 || k == 8) {
		cout << "pon" << endl;
	}
	else {
		cout << "hon" << endl;
	}
}

Measured memory_bytes: 3528
# AOJ ITP2_2_C: Priority Queue
# Python3 2018.6.24 bal4u

import heapq
n, q = map(int, input().split())
Q = [[] for i in range(n)]
for i in range(q):
	a = input().split()
	t = int(a[1])
	if   a[0] == '0': heapq.heappush(Q[t], -int(a[2]))       # insert
	elif a[0] == '1' and Q[t]: print(-Q[t][0])      # getMax
	elif a[0] == '2' and Q[t]: heapq.heappop(Q[t])  # deleteMax


Measured memory_bytes: 13172
n = int(input())
*h, = map(int, input().split())
for i in range(0, n-1):
    if h[i+1] - h[i] >= 1:
        h[i+1] -= 1
count = 0
for i in range(0, n-1):
    if h[i] <= h[i+1]:
        count += 1
    else:
        break
if count == n - 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;


int main(void) {
	
	int n;
	int point = 0;
	int total = INF;
	int a[201] = {};

	cin >> n;
	FOR(i, 1, n) {
		point = 0;
		cin >> a[i];
		while (a[i] % 2 == 0&&a[i]>=2) {
			a[i] /= 2;
			point++;
		}
		if (point < total) {
			total = point;
		}
	}

	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
n = len(s)
ans = 0
data = [0 for _ in range(2019)]
now = 0
data[0] = 1
q = [1]
x = 1
for i in range(n):
    x *= 10
    x %= 2019
    q.append(x)

for i,x in enumerate(s):
    now += int(x)*q[i]
    now %= 2019
    data[now] += 1
    #print(now)

for i in range(2019):
    ans += data[i]*(data[i]-1)//2

print(ans)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


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

  int n;
  cin >> n;
  cout << n * 800 - (n/15) * 200 << endl;
}


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

int main(){
    long long h,m;
    long long masu;

        cin >> h;
        cin >> m;
 
        masu = (h*m + 2 - 1) / 2;

        if((h == 1)||(m == 1)){
            masu = 1;
        }

        cout << masu << endl;
}

Measured memory_bytes: 256
kk = list(map(int, input().split()))
a = kk[0] - (kk[0] % kk[1])
b = a / kk[1]

if (kk[0] % kk[1]) == 0:
  answer = b * kk[2]
else:
  answer = (b + 1) * kk[2]
print(int(answer))

Measured memory_bytes: 9136
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = ni();
        String S = ns();

        int[] white = new int[N + 1];
        int[] black = new int[N + 1];
        for (int i = 1; i <= S.length(); i++) {
            black[i] = black[i-1];
            white[i] = white[i-1];

            if (S.charAt(i - 1) == '#') {
                black[i]++;
            } else {
                white[i]++;
            }
        }

        int cnt = 1000000;
        for(int i = 0; i <= N; i++){
            int tmpCnt = black[i] + (white[N] - white[i]);
            cnt = Math.min(tmpCnt, cnt);
        }

        out.println(cnt);
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

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

struct edge {int to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
//static const int INF = 2147483647;
//static const int INf = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define itn int
#define scnaf scanf
#define reutnr return
#define scamf scanf
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll

VI palindrome;

bool rullonz = false;
int counter = 0;

void palindrome_check(){
    for(int i=0;i<palindrome.size()/2;i++){
        if(palindrome[i] != palindrome[palindrome.size()-i-1]){
            if(palindrome[i]!=-1 && palindrome[palindrome.size()-i-1]!=-1){
                rullonz = true;
                return;
            } else {
                if(palindrome[palindrome.size()-i-1]==-1){
                    palindrome.insert(palindrome.begin()+i,-1);
                } else {
                    palindrome.insert(palindrome.end()-i,-1);
                }
                counter++;
            }
        }
    }
}

signed main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='x') palindrome.pb(-1);
        else palindrome.pb(s[i]-'a');
    }

    palindrome_check();

    if(rullonz) puts("-1");
    else printf("%d\n",counter);

    return 0;
}

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

long long int MOD = 1000000007;
long long int MAX = 510000;

vector<long long int> fac(MAX), finv(MAX), inv(MAX);

void COMinit() {
  fac.at(0) = 1;
  fac.at(1) = 1;
  finv.at(0) = 1;
  finv.at(1) = 1;
  inv.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fac.at(i) = fac.at(i - 1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
  }
}

int main() {
  long long int N, M;
  cin >> N >> M;
  COMinit();
  long long int ans = 0;
  for (int K = 0; K <= N; K++) {
    long long int A = fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
    long long int B = fac.at(M) * finv.at(M - K) % MOD;
    long long int C = fac.at(M - K) * finv.at(M - N) % MOD;
    long long int D = (A * B % MOD) * (C * C % MOD) % MOD;
    if (K % 2 != 0) D *=  -1;
    ans = (ans + D) % MOD;
  }
  if (ans < 0) ans += MOD;
  cout << ans << endl;
}

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

int main(void){
    int n;
    cin >> n;
    if(n%2){
        cout << "No" << endl;
        exit(0);
    }
    char *s;
    s = new char[n];
    cin >> s;
    for(int i=0;i<n/2;i++){
        if(s[i] != s[i+n/2]){
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

  double n;
  cin>>n;
  double m=0;
  FOR(i,1,n+1){
    if(i%2) m++;
  }

  cout<<m/n<<endl;


}

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

using namespace std;

vector<int> v[200010];
set<int> s;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n, m, a, b;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i < v[1].size(); i++) {
        s.insert(v[1][i]);
    }
    for(int i = 0; i < v[n].size(); i++) {
        if(s.count(v[n][i]))
            ans = 1;
    }

    if(ans)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";


	return 0;
}


Measured memory_bytes: 16624
N = int(input())
A = [0 for _ in range(100001)]
a = list(map(int,input().split()))
ans = 0
for i in a:
  A[i] += 1
  ans += i
Q = int(input())
for i in range(Q):
  B,C = map(int,input().split())
  ans += (C -B) * A[B]
  A[C] += A[B]
  A[B] = 0
  print(ans)
  

Measured memory_bytes: 22076
#include<cstdio>
int main(){for(int n,a,c,r,t;c=0,r=scanf("%d",&n),n;printf("%d\n",r))for(char d[]="123456",s[9];n--;r+=*d-48)scanf("%s",s),*s%6-4?a=(*s-78?*s%5-1:0)+c&3,a+=a/2?2-a%2*2:1,t=*d,*d=d[a],d[a]=d[5],d[5]=d[5-a],d[5-a]=t:c+=*s+3;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int T,n,k,l,r;
long long ans;
vector<pair<int,int>>a,b;
multiset<int>s;
void sol(vector<pair<int,int>>&v)
{
	sort(v.begin(),v.end());
	s.clear();
	for(auto x:v)
	{
		s.insert(x.second);
		ans+=x.second;
		while(s.size()>x.first)
		{
			ans-=*s.begin();
			s.erase(s.begin());
		}
	}
}
int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		ans=0;
		a.clear(),b.clear();
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d%d",&k,&l,&r);
			if(l>r)
				a.emplace_back(k,l-r);
			else if(l<r)
				b.emplace_back(n-k,r-l);
			ans+=min(l,r);
		}
		sol(a),sol(b);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 9528
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (int i=0; i<n; i++) in(a[i])
#define viin(a, n) for (int i=0; i<n; i++) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (int i=0; i<n; i++)
#define foris(i, a, b) for (int i=a; i<b; i++)
#define ford(i, n) for (int i=n-1; i>=0; i--)
#define fords(i, a, b) for (int i=a; i>=b; i--)
#define forr(i, a) for (auto i : a)
const int mod = (int)(1e9) + 7;
//endregion

int n, q, a, b, ps[200005], visited[200005];
vi arr[200005];

void dfs(int v, int av) {
    visited[v] = 1;
    ps[v] += av;
    forr (i, arr[v]) {
        if (!visited[i]) dfs(i, ps[v]);
    }
}

int main() {
    in2(n, q);
    fori (i, n-1) {
        in2(a, b);
        arr[a].emplace_back(b);
        arr[b].emplace_back(a);
    }
    fori (i, q) {
        in2(a, b);
        ps[a] += b;
    }
    dfs(1, 0);
    foris (i, 1, n+1) outs(ps[i]);
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); } } initCpp;

signed main() {
  while (true) {
    i64 n;
    cin >> n;
    if (n == 0) break;
    vector<i64> HP(n);
    i64 hpm = 0;
    REP(i, n) {
      cin >> HP[i];
      hpm = max(hpm, HP[i]);
    }
    i64 m;
    cin >> m;
    vector<i64> MP(m);
    vector<bool> Single(m);
    vector<i64> Damage(m);
    REP(i, m) {
      cin.ignore(numeric_limits<streamsize>::max(), ' ');
      string target;
      cin >> MP[i] >> target >> Damage[i];
      Single[i] = target == "Single";
    }
    vector<i64> A(hpm + 1, inf<i32>);
    vector<i64> B(hpm + 1, inf<i32>);
    A[0] = 0;
    B[0] = 0;
    REP(d, hpm + 1) {
      REP(k, m) {
        if (Single[k]) {
          A[d] = min(A[d], (d - Damage[k] < 0 ? 0 : A[d - Damage[k]]) + MP[k]);
        } else {
          B[d] = min(B[d], (d - Damage[k] < 0 ? 0 : B[d - Damage[k]]) + MP[k]);
        }
      }
    }
    i64 ans = inf<i64>;
    REP(d, hpm + 1) {
      i64 sum = 0;
      REP(i, n) {
        sum += HP[i] - d < 0 ? 0 : A[HP[i] - d];
        sum = min(sum, inf<i64>);
      }
      sum += B[d];
      ans = min(ans, sum);
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 4520
#include<iostream>
using namespace std;
int main() {
    
    int n = 0;
    
    cin >> n;
    
    int array[n];
    
    for (int h = 0; h < n; h ++) {
        
        cin >> array[h];
        
    }
    
    for (int i = 0; i < n; i ++) {
        
        int v = array[i];
        
        int j = i-1;
        
        while((j >= 0) && (array[j] > v)) {
            
            array[j+1] = array[j];
            
            j -= 1;
            
        }
        
        
        
        array[j+1] = v;
        
        
        for (int k = 0; k < n; k ++) {
            
            if (k == n-1) {
                
                cout << array[k] << endl;
                
            } else {
                
                cout << array[k] << " ";
                
            }
            
        }
        
        
        
    }
    
    return 0;
    
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#define M 1046527
#define L 14
#define ll long long

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

ll getKey(char str[]) {
    ll sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

int insert(char str[]) {
    ll key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (!strcmp(H[h], str)) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int find(char str[]) {
    ll key, i, h;
    key = getKey(str);
    for (i = 0;; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (!strcmp(H[h], str)) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            return 0;
        }
    }
    return 0;
}

int main(void) {
    int i, n, j;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 16056
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n,t =ma()
AB = []
am = 0
for i in range(n):
    a,b = ma()
    AB.append((a,b))
    am = max(am,a)

dp1 = [[0]*t for i in range(n+1)] #dp1[i][j] 0~i種類までで時間jまでに食べきれる最高スコア
for i in range(n):
    a,b = AB[i]
    #print(a,b)
    for j in range(t-1,-1,-1):
        dp1[i][j] = dp1[i-1][j]
        if j+a<t:
            dp1[i][j+a] = max(dp1[i-1][j]+b,dp1[i][j+a])

dp2 = [[0]*t for i in range(n+1)] ##dp2[i][j] i~n-1種類までで時間jまでに食べきれる最高スコア

for i in range(n):
    a,b = AB[n-i-1]
    for j in range(t-1,-1,-1):
        dp2[n-i-1][j] = dp2[n-i][j]
        if j+a<t:
            dp2[n-i-1][j+a] = max(dp2[n-i][j]+b,dp2[n-i-1][j+a])

tmp=0
for i in range(n):
    for j in range(t):
        tmp = max(tmp,AB[i][1] + dp1[i-1][j] +dp2[i+1][t-1-j])
print(tmp)


Measured memory_bytes: 212080
<?php
fscanf(STDIN,"%d %d %d", $a, $b, $C);
$C = deg2rad($C);
$S = $a * $b * sin($C) / 2;
$h = 2 * $S / $a;
$line_c = sqrt($a*$a + $b*$b - 2*$a*$b*cos($C));
$L = $a + $b + $line_c;
printf("%f%s%f%s%f%s", $S, PHP_EOL, $L, PHP_EOL, $h, PHP_EOL);

Measured memory_bytes: 15328
using System;
using System.Collections.Generic;
using System.Linq;
using UnionFind;

struct City
{
    public int id { get; private set; }
    public int x { get; private set; }
    public int y { get; private set; }

    public City(int id, int x, int y)
    {
        this.id = id;
        this.x = x;
        this.y = y;
    }
}

struct Edge
{
    public int a { get; private set; }
    public int b { get; private set; }
    public long cost { get; private set; }

    public Edge(int a, int b, long cost)
    {
        this.a = a;
        this.b = b;
        this.cost = cost;
    }
}

class Program
{
    static int N;
    static List<City> cities;
    static List<Edge> es;

    static void Main()
    {
        /* 入力の受け取り、変数の初期化 */
        N = int.Parse(Console.ReadLine());
        cities = new List<City>();
        for (int i = 0; i < N; i++)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            cities.Add(new City(i, input[0], input[1]));
        }
        es = new List<Edge>();

        /* 街をx順にソートし、隣街との間に辺を張る */
        cities.Sort((a, b) => a.x - b.x);
        for (int i = 0; i < N - 1; i++)
        {
            int s = cities[i].id;
            int g = cities[i + 1].id;
            long l = Math.Abs(cities[i].x - cities[i + 1].x);
            es.Add(new Edge(s, g, l));
        }

        /* 街をy順にソートし、隣街との間に辺を張る */
        cities.Sort((a, b) => a.y - b.y);
        for (int i = 0; i < N - 1; i++)
        {
            int s = cities[i].id;
            int g = cities[i + 1].id;
            long l = Math.Abs(cities[i].y - cities[i + 1].y);
            es.Add(new Edge(s, g, l));
        }

        /* クラスカル法で答えを求める */
        Console.WriteLine(Kruskal());
    }

    /* グラフesに対し、クラスカル法で最小全域木を求め、総コストを返す */
    static long Kruskal()
    {
        es.Sort((a, b) => (a.cost > b.cost) ? 1 : (a.cost == b.cost) ? 0 : -1);

        UF uf = new UF(N);
        long min_cost = 0;

        foreach (var e in es)
        {
            if (!uf.Same(e.a, e.b))
            {
                min_cost += e.cost;
                uf.Unite(e.a, e.b);
            }
        }

        return min_cost;
    }
}

namespace UnionFind
{
    class UF
    {
        private int[] 親; //親[i] : iの親の番号

        public UF(int N) //コンストラクタ、すべてが根として初期化
        {
            親 = new int[N];
            for (int i = 0; i < N; i++)
                親[i] = i;
        }

        public int Root(int x) //xの属する木の根を返す
        {
            if (親[x] == x) return x;
            return 親[x] = Root(親[x]);
        }

        public void Unite(int x, int y) //xとyの木を統合
        {
            int rx = Root(x);
            int ry = Root(y);
            if (rx == ry) return;
            親[rx] = ry;
        }

        public bool Same(int x, int y) //xとyが同じ木に属するかどうかを返す
        {
            return Root(x) == Root(y);
        }
    }
}

Measured memory_bytes: 28060
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    REP(h, 1, 3500) {
        REP(n, 1, 3500) {
            if((4*h*n - N*(n + h)) <= 0) continue;
            if(N * h * n % (4*h*n - N*(n + h)) != 0) continue;
            int w = N*h*n/(4*h*n - N*(n + h));
            if(w <= 0) continue;
            cout << h << " " << n << " " << w << endl;
            return 0;
        }
    }


    return 0;
}
// 4/N = 1/h + 1/n + 1/w
// 4hnw/N = (nw + hw + hn)
// 4hnw = N(nw + hw + hn)
// 4hnw - Nw(n + h) = Nhn
// w(4hn - N(n + h)) = Nhn

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.List
import           Data.Bits

input :: IO [Int]
input = do
    d <- (fst . fromJust) . BS.readInt <$> BS.getLine
    map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine

process :: [Int] -> Integer
process = foldr ((.|.) . shift 1) (0 :: Integer)

main :: IO ()
main = do
    [n,k] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
    ass <- replicateM k input
    putStr $ show $ result n ass
    where
        hammingWeight ass = popCount $ convoluton (map process ass)
        result n ass = n - hammingWeight ass
        convoluton = foldl (.|.) (0::Integer)


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(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

int n, k;

int main() {
    fastio();

    cin >> n >> k;

    int ans = 0;
    forn(i, n) {
        int x;
        cin >> x;
        ans += min(x, abs(k - x));
    }

    cout << ans * 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct team{int ac,pen,id;};
bool comp(const team &l, const team &r){
	if(l.ac!=r.ac) return l.ac>r.ac;
	if(l.pen!=r.pen) return l.pen<r.pen;
	return l.id<r.id;
}
int main(){
	while(true){
		int t,p,r;
		scanf("%d%d%d",&t,&p,&r);
		if(t==0) break;
		int wa[50][10]={},pen[50]={},ac[50]={};
		rep(i,r){
			int ti,pi,tim;
			string mm;
			cin >> ti >> pi >> tim >> mm;
			ti--,pi--;
			if(mm[0]=='C'){
				ac[ti]++;
				pen[ti]+=tim+wa[ti][pi]*1200;
			}else{
				wa[ti][pi]++;
			}
		}
		team vc[50];
		rep(i,t) vc[i].ac=ac[i],vc[i].pen=pen[i],vc[i].id=i;
		sort(vc,vc+t,comp);
		rep(i,t) printf("%d %d %d\n",vc[i].id+1,vc[i].ac,vc[i].pen);
	}
	return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double dd;
const int MOD = 1e9 + 7;

int div(int n) { 
  int cnt = 0; 
  for (int i = 1; i*i <= n; i++) { 
      if (n % i == 0) { 
        if (n / i == i) 
            cnt++; 
        else  
            cnt = cnt + 2; 
      } 
  } 
  return cnt; 
} 

void solve(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int a = n-i;
    ans += (div(a));
  }
  cout << ans << endl;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1, tt = 0;
  //cin >> t;
  while(t--){
    //tt++;
    //cout << "Case #" << t << ": ";
    solve();
  }
  return 0;
}


Measured memory_bytes: 3648