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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

ll P[500005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    Combination cmb(M + 5);
    ll ans = cmb.get(M, N);
    REP(i, N) {
        ans = (ans * (i + 1)) % MOD;
    }
    P[1] = P[0] = 1;
    REP(i, N + 2) {
        P[i + 1] = (P[i] * (i + 1)) % MOD;
    }

    ll b = ans;
    REP(i, N) {
        ll p = cmb.get(N, i + 1);
        p = (p * cmb.get(M - (i + 1), N - (i + 1))) % MOD;
        p = (p * P[N - (i + 1)]) % MOD;

        if (i % 2 == 0)
            b = (b + MOD - p) % MOD;
        else
            b = (b + p) % MOD;
    }

    ans = (ans * b) % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14792
#!/usr/bin/env python3
import sys
import math

def solve(H: int):
    D = int(math.log2(H)) + 1
    cnt = 0
    for d in range(D):
        cnt += 2 ** d
    print(cnt)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    vector<int> a(3);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[0]>>a[1]>>a[2];
        sort(a.begin(),a.end());
        if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3004
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        String str = "";
      	System.out.println(new StringBuilder(detectChar(a, str)).reverse().toString());
    }

	public static String detectChar(long a, String b) {
        a--;  
      	String c = b + returnChar(a%26);
      	a /= 26;
        if (a > 0) {
          return detectChar(a, c);
        } else {
          return c;
        }
	}

	public static char returnChar(long a) {
      	return (char)('a' + a % 26);
	}
}

Measured memory_bytes: 39392
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[3030];
int main(){
    int n;cin>>n;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    dp[0]=1;
    rep(i,n-1){
        if(s[i]=='<'){
            rep(j,i+1)(dp[j+1]+=dp[j])%=mod;
            rep(j,i+1)dp[i+1-j]=dp[i-j];
            dp[0]=0;
        }
        else {
            rep(j,i+1)(dp[i-j]+=dp[i-j+1])%=mod;
        }
    }
    ll ans=0;
    rep(i,n+1)ans+=dp[i];
    cout<<ans%mod<<endl;

    return 0;
}

Measured memory_bytes: 256
/*
problem's name:
statue:
writer:Chris
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const ll INF=20050208;
/*------------main part------------*/



ll num[1000005];
int main()
{
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>num[i];
		num[i]-=i+1;
	}
	sort(num,num+n);
	ll b=num[n/2];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		sum+=abs(num[i]-b);
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF ((2e9)+1)
using namespace std;
int A[2000020],H;

void maxHeapify(int i){
  int l=i*2;
  int r=i*2+1;
  int largest;
  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  
  if(r<=H&&A[r]>A[largest]) largest=r;
  
  if(largest!=i) {
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

void heapIncreaseKey(int i,int key){
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i/=2;
  }
}

void insert(int k){
  H++;
  A[H]=-INF;
  heapIncreaseKey(H,k);  
}

int extract(){
  int res=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(1);
  return res;
}


int main(){
  while(1){
    int a;
    char str[10];
    scanf("%s",str);
    if(str[0]=='i')scanf("%d",&a),insert(a);
    else if(str[1]=='x')cout <<extract()<<endl;
    else break;
  }
  return 0;
}

Measured memory_bytes: 5300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

int D;
vector<int> c(26);
vector<vector<int>> s;
vector<int> spa(26,0);//経過日数
vector<int> t;
vector<set<int>> schedule(26);//各コンテストが何日目に開催されるか
ll contest(int day,int x){//day日にコンテストxを開催した時の満足度の増加量 1-indexed
    ll now=s.at(day-1).at(x-1);
    rep(i,26){
        if(i==x-1){
            spa.at(i)=0;
            continue;
        }
        spa.at(i)++;
        now-=spa.at(i)*c.at(i);
    }
    return now;
}

int main() {
    std::chrono::system_clock::time_point  start, end; // 型は auto で可
 start = std::chrono::system_clock::now();

    cin>>D;
    rep(i,26)cin>>c.at(i);
    s.resize(D,vector<int>(26));
    rep(i,D)rep(j,26){cin>>s.at(i).at(j);}
    t.resize(D);

    //rep(i,D)cin>>t.at(i);
    /*rep(i,D){
        t.at(i)=rand()%26+1;
    }*/
    /*rep(i,D){
        rep(j,26){
            if(s.at(i).at(j)>s.at(i).at(t.at(i))){
                t.at(i)=j;
            }
        }
        t.at(i)++;
    }*/

    ll ans=0;
    rep(i,D){
        int h=0;
        rep(j,26){
            if(s.at(i).at(j)+c.at(j)*spa.at(j)>s.at(i).at(h)+c.at(h)*spa.at(h)){
                h=j;
            }
        }
        t.at(i)=h+1;
        ans+=contest(i+1,t.at(i));
        //cout<<ans<<endl;問題A用
    }
    //改善前のansを求める

    rep(i,26){
        schedule.at(i).insert(0);
    }
    rep(i,D){
        schedule.at(t.at(i)-1).insert(i+1);
    }
    rep(i,26){
        schedule.at(i).insert(D+1);
    }

    double elapsed;
    
    while(elapsed<1800){//時間が許す限り
        int d,q;
        //cin>>d>>q;
        d=rand()%D+1;
        q=rand()%26+1;
        ll oldans=ans;

        int x=t.at(d-1);
        t.at(d-1)=q;
        int bx,nx;
        auto p=lower_bound(schedule.at(x-1).begin(),schedule.at(x-1).end(),d);
        p--;
        bx=*p;
        p++;p++;
        nx=*p;
        schedule.at(x-1).erase(d);
        int bq,nq;
        auto itr=lower_bound(schedule.at(q-1).begin(),schedule.at(q-1).end(),d);
        nq=*itr;
        itr--;
        bq=*itr;
        schedule.at(q-1).insert(d);
        ans+=s.at(d-1).at(q-1)-s.at(d-1).at(x-1);
        ans+=(d-bq)*(nq-d)*c.at(q-1);
        ans-=(d-bx)*(nx-d)*c.at(x-1);
        //cout<<ans<<endl;
        if(ans<oldans){
            schedule.at(x-1).insert(d);
            schedule.at(q-1).erase(d);
            ans=oldans;
        }
        end = std::chrono::system_clock::now();  // 計測終了時間
        elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    }
    rep(i,D){
        cout<<t.at(i)<<endl;
    }
}

Measured memory_bytes: 3892
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)
#define Inf 2147483647
#define llInf 9223372036854775807

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	UnionFind Uni(n);
	vint fre(n, 0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		Uni.connect(a-1, b-1);
		fre[a - 1]++;
		fre[b - 1]++;
	}
	vint vec(n,0);
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		if (Uni.root(a - 1) == Uni.root(b - 1)) {
			vec[a - 1]++;
			vec[b - 1]++;
		}
	}
	rep(i, n) {
		cout << Uni.size(i) - vec[i] - 1 -fre[i]<< endl;
	}
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 2e5 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

int n , a[105];

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	scanf("%d" , &n);
	for(int i = 0 ; i < n ; ++i)
		scanf("%d" , a + i);
	sort(a , a + n);
	int cnt = 0;
	for(int i = 0 ; i < n ; ++i){
		for(int j = i+1 ; j < n ; ++j){
			for(int k = j+1 ; k < n ; ++k){
				if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i] && a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
					cnt++;
			}
		}
	}
	printf("%d\n" , cnt);
	
	
    return 0;
}




Measured memory_bytes: 3828
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		
		PriorityQueue<String> list = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.next());
		}
		
		for (int i = 0; i < n; i++) {
			System.out.print(list.poll());
		}
	}
}

Measured memory_bytes: 23764
class Buildings
  attr_accessor :building
  def initialize(builds=4,floor=3,room=10)
    @building = Array.new(builds){Array.new(floor){[0]*room}}
  end

  def change_number(data)
    b,f,r,v = data
    @building[b-1][f-1][r-1] += v
  end

  def puts_result
    building.each_with_index do |build,idx|
      build.each do |floor|
        print " "
        puts floor.join(" ")
      end
      puts "#"*20 if idx != building.length-1
    end
  end
end

buildings = Buildings.new
n = gets.to_i
n.times {buildings.change_number(gets.split.map(&:to_i))}
buildings.puts_result



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

using namespace std;

int main(int argc, char*argv[])
{
	int N;
	cin >> N;
	vector<int> a(N+1);
	for (int i = 1; i<=N; ++i)
		cin >> a[i];
	long dp [N+1][N+1];
	
	for(int width = 1; width <= N; ++width)
		for (int start = 1 ; (start + width-1) <=N; ++start)
		{
			if(width == 1)
				dp[start] [start+width-1] = a[start];
			else
			{
				dp[start] [start+width-1] = max(a[start] - dp[start+1][start+width-1] , a[start+width-1]-dp[start] [start+width-2]);
			}
			
		}
	cout << dp[1][N];	
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	double l;
	cin >> l;

	double a = l / 3.0;

	printf("%7.10f\n", a*a*a);

	return 0;

}



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

int main() {

	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	int s = 0;
	for (int i = 0; i < N; i++) s ^= a[i];
	for (int i = 0; i < N; i++) {
		int ans = a[i] ^ s;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

bool ispali(const std::string& s) {
    auto t = s;
    std::reverse(t.begin(), t.end());
    return s == t;
}

void solve() {
    std::string s;
    std::cin >> s;
    int n = s.length();

    std::cout
        << (ispali(s) &&
                    ispali(s.substr(0, n / 2)) &&
                    ispali(s.substr(n / 2 + 1))
                ? "Yes"
                : "No")
        << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var abc = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var a = abc[0];
        var b = abc[1];
        var c = abc[2];
        Console.WriteLine(c > a + b && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
    }
}


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

constexpr int inf = 1e9;

struct edge {
    int u, v, cost, type;
    bool operator<(const edge& other) const {
        return cost < other.cost;
    }
};

class union_find {
public:
    union_find(int n) : par(n, -1) {}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

private:
    vector<int> par;
};

int main() {
    int n, m, k;
    while(cin >> n >> m >> k, n) {
        vector<edge> es;
        for(int i = 0; i < m; ++i) {
            int u, v, w; char l;
            cin >> u >> v >> w >> l;
            es.push_back(edge{u - 1, v - 1, w, l == 'B'});
        }

        int ans = inf;
        for(int offset = -100; offset <= 100; ++offset) {
            auto tes = es;
            for(auto& e : tes) {
                if(e.type == 0) {
                    e.cost += offset;
                }
            }
            sort(begin(tes), end(tes),
                 [](auto const& e1, auto const& e2) {
                     return e1.cost < e2.cost || (e1.cost == e2.cost && e1.type < e2.type);
                 });
            int cnt1 = 0;
            int connect = 0;
            {
                union_find uf(n);
                for(auto& e : tes) {
                    if(uf.unite(e.u, e.v)) {
                        connect += 1;
                        cnt1 += e.type == 0;
                    }
                }
            }

            int cost = -offset * k;
            int cnt2 = 0;
            sort(begin(tes), end(tes),
                 [](auto const& e1, auto const& e2) {
                     return e1.cost < e2.cost || (e1.cost == e2.cost && e1.type > e2.type);
                 });
            {
                union_find uf(n);
                for(auto& e : tes) {
                    if(uf.unite(e.u, e.v)) {
                        cost += e.cost;
                        cnt2 += e.type == 0;
                    }
                }
            }
            if(cnt2 <= k && k <= cnt1 && connect == n - 1) {
                ans = min(ans, cost);
            }
        }

        cout << (ans == inf ? -1 : ans) << endl;
    }
}



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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int A = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == '1') {
      A++;
    } else {
      A--;
    }
  }
  cout << N - abs(A) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()
#define Pi P<int,int>
#define elif else if


signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(a%2==0&&b%2==0||a%2==1&&b%2==1)
    cout<<(b-a)/2<<endl;
  else{
    cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;
  }
}


Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

ll a[N], b[N], c[N];
int tree[8 * N];

bool check(int val, int n);
void update(int i, int l, int r, int p, int x);
int query(int i, int l, int r, int ql, int qr);

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b + 1, b + 1 + n);
	int l = 1, r = n - 1;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check(b[mid], n)) {
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	cout << b[r + 1] << endl;
}

bool check(int val, int n) {
	memset(tree, 0, sizeof(tree));
	for (int i = 1; i <= n; ++i) {
		if (a[i] <= val) {
			c[i] = -1;
		} else {
			c[i] = 1;
		}
	}
	ll l_val = 0, total = (ll(n) * (n - 1)) / 2 + n;
	ll sum = 0;
	update(1, -n, n, 0, 1);
	for (int i = 1; i <= n; ++i) {
		// cout << "doing tree stuff" << endl;
		sum += c[i];
		update(1, -n, n, sum, 1);
		// cout << "half done" << endl;
		l_val += query(1, -n, n, sum + 1, n);
		// cout << "done" << endl;
	}
	return l_val > total - l_val;
}

void update(int i, int l, int r, int p, int x) {
	// cout << i << ' ' << l << ' ' << r << ' ' << p << ' ' << x << endl;
	tree[i] += x;
	if (l == r) {
		return;
	} else {
		int mid = (l + r + 2 * N) / 2 - N, lc = 2 * i, rc = lc + 1;
		if (p <= mid) {
			update(lc, l, mid, p, x);
		} else {
			update(rc, mid + 1, r, p, x);
		}
	}
}

int query(int i, int l, int r, int ql, int qr) {
	if (l > qr or ql > r) {
		return 0;
	} else if (ql <= l and r <= qr) {
		return tree[i];
	} else {
		int mid = (l + r + 2 * N) / 2 - N, lc = 2 * i, rc = lc + 1;
		return query(lc, l, mid, ql, qr) + query(rc, mid + 1, r, ql, qr);
	}
}

Measured memory_bytes: 5760
# # Educational DP Contest C
N = int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * 3 for _ in range(N)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1, N):
    dp[i][0] = max(dp[i-1][1] + abc[i][0], dp[i-1][2] + abc[i][0])
    dp[i][1] = max(dp[i-1][0] + abc[i][1], dp[i-1][2] + abc[i][1])
    dp[i][2] = max(dp[i-1][0] + abc[i][2], dp[i-1][1] + abc[i][2])

print(max(dp[N-1]))

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

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

    static class BannedK {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] k = new int[n];

            HashMap<Integer, Integer> counter = new HashMap<>();
            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                counter.put(a, counter.getOrDefault(a, 0) + 1);
                k[i] = a;
            }

            long result = 0;
            for (Integer key : counter.keySet()) {
                long anum = counter.get(key);
                result += anum * (anum - 1) / 2;
            }

            for (int i = 0; i < n; i++) {
                int a = k[i];
                int anum = counter.get(a);
                long before = anum * (anum - 1) / 2;
                long after = (anum - 1) * (anum - 2) / 2;
                out.println(result - before + after);
            }
        }

    }
}



Measured memory_bytes: 69668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
using namespace std;

const long long B=1000000000000000009LL;
const long long P=1000000000000000031LL;

vector<long long> gen_hash(const string &s){
	vector<long long> hash(s.size());
	long long c=0;
	for(int i=0;i<s.size();i++){
		c=(c*(__int128_t)B+s[i])%P;
		hash[i]=c;
	}
	return hash;
}
long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=(__int128_t)z*x%mod;
		x=(__int128_t)x*x%mod;
	}
	return z;
}

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

	string s;
	cin>>s;
	vector<long long> v=gen_hash(s);

	//int T;
	//for(cin>>T;T--;){
		string q;
		cin>>q;
		long long hash=gen_hash(q)[q.size()-1];
		long long Brev=pow_binary_mod(B,q.size(),P);
		vector<long long> r;
		int i=q.size()-1;
		for(;i<s.size();i++){
			if(v[i]==((i==q.size()-1?0:v[i-q.size()])*(__int128_t)Brev+hash)%P){
				r.push_back(i-q.size()+1);
			}
		}
		if(!r.empty()){
			for(int i=0;i<r.size();i++)printf("%d\n",r[i]);
			//puts("1");
		}else{
			//puts("0");
		}
	//}
}

Measured memory_bytes: 19408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define fi first
#define se second

vector<int> g[100005];
int n, k, ans = LONG_MAX;

vector<pair<int,int> > e;

int dfs(int u,int p,int dep){
	if(dep == 0) return 1;
	int res = 1;
	for(int v: g[u]) if(v != p)
		res += dfs(v, u, dep - 1);
	return res;
}

signed main(){
	cin >> n >> k;
	for(int i = 1 ; i < n ; i ++){
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
		e.push_back({u, v});
	}

	for(pair<int,int> p: e){
		ans = min(ans, n - dfs(p.fi, p.se, k / 2) - dfs(p.se, p.fi, (k / 2) - (k % 2 == 0)));
		ans = min(ans, n - dfs(p.se, p.fi, k / 2) - dfs(p.fi, p.se, (k / 2) - (k % 2 == 0)));
	}
	cout << ans;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int p[110];
int main()
{
	int n;
	cin>>n;
	int MIN=0x3f3f3f3f;
	int MAX=-1;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
		MIN=min(MIN,p[i]);
		MAX=max(MAX,p[i]);
	}
	int ans=0x3f3f3f3f;
	for(int i=MIN;i<=MAX;i++)
	{
		int sum=0;
		for(int j=1;j<=n;j++)
		{
            sum+=(p[j]-i)*(p[j]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 100000

struct str{
    int in;
    int sf;
};

bool cmp(str a, str b) {
    if (a.sf < b.sf)
        return 1;
    else if(a.sf == b.sf)
        return a.in < b.in;
    return 0;

}

str v[maxn + 2];
int main() {
    int n, m, rez = 1;
    fscanf(stdin,"%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        fscanf(stdin, "%d%d", &v[i].in, &v[i].sf);
    }
    std::sort(&v[1], &v[m+1], cmp);

    int a = v[1].in, b = v[1].sf;
    for (int i = 2; i <= m; i++) {
        if (v[i].in >= b) {
            rez++;
            a = v[i].in;
            b = v[i].sf;
        }
        else {
            a = v[i].in;
        }
    }
  fprintf(stdout, "%d", rez);
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a,b,c,k; cin>>a>>b>>c>>k;
    if(a>=k)
        cout<<k<<"\n";
    else if(a+b>=k)
        cout<<a<<"\n";
    else
    {
        cout<<(k-a-b)*(-1)+a<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3652
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<usize>();
    let x = n * (n-1) / 2;
    println!("{}", x);
}

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

using LL = long long;

int main () {
	LL n, a, b, ans; cin >> n >> a >> b;
    ans = min (n-a, b-1);
    if ((b-a)%2==0) ans = min (ans, (b-a)/2);
    else {
      	// goto 1
        LL res = a-1, nowa = 1, nowb = b-(a-1);
        res = res + (b-a) / 2 + 1;
        ans = min (ans, res);
        // goto n
        res = n-b, nowb = n, nowa = a+(n-b);
        res = res + (b-a) / 2 + 1;
        ans = min (ans, res);
    }
  	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

ac = 0
wa = dict()

done = dict()

for i in range(M):
    p, S = input().split()
    if p in done:
        continue
    if S == "AC":
        ac+= 1
        done[p] = True
    else:
        if p not in wa:
            wa[p] = 0
        wa[p] += 1

_wa = 0
for x in wa:
    if x in done:
        _wa += wa[x]

print(ac, _wa)

Measured memory_bytes: 17108
#include<iostream>
using namespace std;
int main(){
    char c;
    cin>>c;
    if(c=='A')
        cout<<'T'<<endl;
    else if(c=='T') cout<<'A'<<endl;
    else if(c=='C') cout<<'G'<<endl;
    else if(c=='G') cout<<'C'<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 510
using namespace std;
int x[N],a[N*N],id[N],od[N];
bool cmp(int i,int j){
	return x[i]<x[j];
}
int main(){
	int n,nxt=1;
	queue<int> must,pad;
	bool gg=false;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i]);
		id[i]=i;
	}
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++) od[id[i]]=i;
	for(int i=1;i<=n;i++){
		for(int j=0;j<id[i]-1;j++){
			must.push(id[i]);
		}
	}
	for(int i=1;i<=n*n;i++){
		if(i==x[id[nxt]]){
			if(!must.empty()&&id[nxt]>1&&od[must.front()]<=nxt){
				gg=true;
				break;
			}
			a[i]=id[nxt];
			for(int j=0;j<n-id[nxt];j++){
				pad.push(id[nxt]);
			}
			nxt++;
		}
		else if(!must.empty()){
			a[i]=must.front();
			must.pop();
		}
		else if(!pad.empty()){
			a[i]=pad.front();
			pad.pop();
		}
		else{
			gg=true;
			break;
		}
	}
	if(gg) puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=n*n;i++){
			if(i>1) putchar(' ');
			printf("%d",a[i]);
		}
		puts("");
	}
	return 0;
}

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

//a = 97, z = 122

int ascii(char ch){
    int x = ch;
    return 123-x;
}

int main() {
    string S; cin >> S;
    int K; cin >> K;
    for(int i = 0; i < S.size(); i++){
        int x = ascii(S[i]);
        //cout << " " << S[i] << " " << x <<" " <<  K << endl;
        if(S[i] == 'a') continue;
        if(x <= K) {
            S[i] = 'a';
            K-=x;
            
        }
        else continue;
    }
    if(K != 0){
        int las = S[S.size()-1];
        las += K%26;
        S[S.size()-1] = las; 
    }
    cout << S << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

template<class T>T gcd(T a, T b){if(a<b){a^=b;b^=a;a^=b;}return b?gcd(b,a%b):a;}
template<class T>T lcm(T a, T b){return a/gcd(a,b)*b;}

int N,X;
int x[100000];

int main(){
    cin>>N>>X;
    rep(i,N) cin>>x[i];

    int ans=0;
    rep(i,N){
        x[i]=abs(x[i]-X);
        ans=gcd(ans,x[i]);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 640
// GRL_1_C
#include <iostream>
#include <vector>
#include <queue>
#define N   100000000000000
using namespace std;

struct edge{
	int adj;
	int dis;
};

int main(){
	int V, E, s, t, d, x, count;
	vector<vector<edge> > A;
	vector<vector<long long> > distance;
	bool pos = true;
	edge e;

	cin>>V>>E;

	A.resize(V);
	distance.resize(V);
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(i != j)
				distance[i].push_back(N);
			else
				distance[i].push_back(0);
		}
	}

	for(int j=0;j<E;j++){
		cin>>s>>t>>d;
		e.adj = t;
		e.dis = d;
		A[s].push_back(e);
	}
	
	for(int r=0;r<V;r++){
		count = 0;
		queue<int> ver;
		ver.push(r);

		while(count<=V){
			queue<int> vern;
			while(!ver.empty()){
				x = ver.front();
				for(int i=0;i<A[x].size();i++){
					if(distance[r][A[x][i].adj] > distance[r][x] + A[x][i].dis){
						distance[r][A[x][i].adj] = distance[r][x] + A[x][i].dis;
						vern.push(A[x][i].adj);
					}
				}
				ver.pop();
			}
			if(vern.empty()) break;
			ver = vern;
			count++;
		}
		if(count > V)
			pos = false;
	}

	if(!pos){
		cout<<"NEGATIVE CYCLE"<<endl;
	}else{
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				if(j != 0) cout<<" ";
				if(distance[i][j] >= N)
					cout<<"INF";
				else
					cout<<distance[i][j];
			}
			cout<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1364
def main() -> None:
    n = int(input())
    T, A = map(int, input().split())
    H = input().split()

    min = None
    for i in range(n):
        tempture = T - int(H[i]) * 0.006
        # print(tempture)
        if min is None:
            pos = i + 1
            min = abs(A - tempture)
        elif min > abs(A - tempture):
            pos = i + 1
            min = abs(A - tempture)
    print(int(pos))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
	private	static	BufferedReader	br = null;
	private	static	int[]			at = { 0x0000004F, 0x00000057, 0x0000005B, 0x0000005D, 0x0000005E, 0x0000002F, 0x00000037, 0x0000003B, 0x0000003D, 0x0000003E };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		String  stdin = null;
		boolean	first = true;
		int[]	map   = new int[5];

		while ((stdin = parseStdin()) != null) {
//			int		i = 0;
			int	l = stdin.length();

			Arrays.fill(map, at[0]);
			for (int i = 0; i < l; i++) {
				map[4-i] = at[stdin.codePointAt(l-i-1)-'0'];
			}

			if (!first) {
				System.out.println("");
			} else {
				first = false;
			}

			for (int i = 6; i >= 5; i--) {
				int		b = 1 << i;
				String	o = "";
				for (int j = 0; j < 5; j++) {
					o += ((map[j] & b) > 0) ? "*" : " "; 
				}
				System.out.println(o);
			}

			System.out.println("=====");

			for (int i = 4; i >= 0; i--) {
				int		b = 1 << i;
				String	o = "";
				for (int j = 0; j < 5; j++) {
					o += ((map[j] & b) > 0) ? "*" : " "; 
				}
				System.out.println(o);
			}
		}
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 34072
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
crs = list(cr.most_common())
cb = collections.Counter(blue)
cbs = list(cb.most_common())

result =[]

for i in range(len(cbs)):
  for j in range(len(crs)):
    if cbs[i][0]==crs[j][0]:
      result.append(crs[j][1]-cbs[i][1])
    else:
      flag = False
      count = 0
      for k in range(len(cbs)):
        if cbs[k].count(crs[j][0]) == 0:
          count+=1
      if count == len(cbs):
        result.append(crs[j][1])
        flag = False
        count = 0

if max(result)>0:
  print(max(result))
else:
  print(0)


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

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());


    ll lb = -1, ub = 1e13;
    while(ub - lb > 1){
        ll m = (lb + ub) / 2;
        ll cnt = 0;
        bool flag = 1;
        rep(i, 0, N){
            if(m < A[i] * F[i]){
                cnt += (A[i] * F[i] - m + F[i] - 1) / F[i];
            }
            if(cnt > K){
                flag = 0;
                break;
            }
        }
        if(flag) ub = m;
        else lb = m;
    }
    cout << ub << endl;
}

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

using  namespace std;

int main(){
    int N, M, ans, L, R;
    int maxL=-10000, minR=100000000;
    cin >> N >> M;
    
    for(int i=0;i<M;i++){
        cin >> L;
        cin >> R;
        maxL = max(L, maxL);
        minR = min(R, minR);
    }
    ans = minR-maxL+1;
    if(ans<0){
        ans=0;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct UnionFind {
    vector<int> par;

    //正の場合、親を表す
    //負の場合、根で数値は連結成分のサイズ
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) {
            return x;
        } else {
            return par[x] = root(par[x]); //経路圧縮
        }
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); //小さい方を大きい方にくっつけるため

        par[x] += par[y];
        par[y] = x;

        return true;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {

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

    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind tree(n);

    for (int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y;
        --x; --y;
        tree.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (tree.same(p[i], i)) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
n,x=map(int,input().split())
xl=list(map(int,input().split()))
for i in range(n):
    xl[i]=abs(xl[i]-x)
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

while len(xl)>1:
    xl[0]=gcd(xl[0],xl[1])
    del xl[1]
    
print(xl[0])


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


#define INFTY 1000000001

int comp = 0;
int *L, *R;

void merge(int *A, const int left, const int mid, const int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) {
        L[i] = A[left+i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid+i];
    }
    L[n1] = INFTY;
    R[n2] = INFTY;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
            comp++;
        }
        else {
            A[k] = R[j];
            j++;
            comp++;
        }
    }
}

void merge_sort(int *A, const int left, const int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
    return;
}

int main (void) {

    int n;

    scanf("%d", &n);
    int* A = new int[n];
    L = new int[n];
    R = new int[n];

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    merge_sort(A, 0, n);

    for (int i = 0; i < n; i++) {
        printf("%d", A[i]);
        if (i == n-1) printf("\n");
        else printf(" ");
    }
    printf("%d\n", comp);
}



Measured memory_bytes: 6548
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong a,b;
    cin >> a >> b;
    if(a-b*2 > 0) cout << a-b*2 << endl;
    else cout << "0" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N, X, Y = map(int, read().split())

dist = []
for i in range(1, N + 1):
    x = np.arange(1, N + 1)
    # 直接
    d1 = np.abs(x - i)
    # i -> X -> Y -> x
    d2 = np.abs(i - X) + np.abs(Y - x) + 1
    # i -> Y -> X -> x
    d3 = np.abs(i - Y) + np.abs(X - x) + 1
    d = np.minimum(np.minimum(d1, d2), d3)
    dist.append(d)

dist = np.concatenate(dist)
count = np.bincount(dist, minlength=N)
print('\n'.join((count[1:] // 2).astype(str)))


Measured memory_bytes: 75260
#include<stdio.h>
#include<string.h>

#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail +1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a,int b){ return a < b ? a : b;}

int main(){
  int elaps = 0, c;
  int i,q;
  P u;

  scanf("%d %d",&n,&q);
  
  
  for(i = 1; i <= n; i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll h1, m1, h2, m2, k;
  scanf("%lld %lld %lld %lld %lld", &h1, &m1, &h2, &m2, &k);

  ll t1 = h1 * 60 + m1;
  ll t2 = h2 * 60 + m2;

  ll o = t2 - t1;
  ll a = (o - k);

  if (a < 0) {
    a = 0;
  }

  cout << a << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  a.at(n-1) /= 2;
  
  int sum = 0;
  
  for(int i=0; i<n; i++)
    sum += a.at(i);
  
  cout << sum << endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    string s;cin>>s;
    int n = SIZE(s);

    VI c(n);
    if(s[n-1] == 'W'){
        c[n-1] = 1;
    }

    PER(i,n-1){
        c[i] = c[i+1];
        if(s[i] == 'W'){
            c[i] ++;
        }
        //dump(i)
        //dump(c[i])
    }

    LL result = 0;
    REP(i,n){
        if(s[i] == 'B'){
            result += c[i];
        }
    }

    cout<<result<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct node {
    ll y, l, r;
    bool isadd;

    bool operator<(const node& a) {
        return y < a.y;
    }
};

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

    ll tc = 1;
    while(1) {
        ll n;
        cin >> n;
        if(!n) break;
        vector<node> v;
        REP(i, n) {
            double x, y, r;
            cin >> x >> y >> r;
            ll xx = x*100, yy = y*100, rr = r*100;
            v.push_back({yy-rr+20000, xx-rr+20000, xx+rr+20000, true});
            v.push_back({yy+rr+20000, xx-rr+20000, xx+rr+20000, false});
        }
        sort(ALL(v));

        vector<int> now(40001);
        ll prev = 0, width = 0, ans = 0;
        REP(i, v.size()) {
            // (y座標のdiff) * width
            ans += (v[i].y - prev) * width;
            // cout << "y:" << v[i].y << " prev:" << prev << " width:" << width << " ans:" << ans << endl;
            prev = v[i].y;
            // widthの計算
            // cout << "l:" << v[i].l << " r:" << v[i].r << " isadd:" << v[i].isadd << endl;
            if(v[i].isadd) FOR(x, v[i].l, v[i].r) now[x]++;
            else FOR(x, v[i].l, v[i].r) now[x]--;
            // cout << now << endl;
            width = 0;
            REP(x, 40001) width += (now[x]>0);
        }

        cout << tc << " " << fixed << setprecision(2) << ans/10000.0 << endl;
        tc++;
    }

    return 0;
}



Measured memory_bytes: 3424