akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N, C; cin >> N >> C;
    pair<ll, ll> sushi[N + 2];
    sushi[0] = mp(0, 0);
    sushi[N + 1] = mp(C, 0);
    rep(i, N) cin >> sushi[i + 1].first >> sushi[i + 1].second;
    ll maxv[N + 1], revmaxv[N + 1];
    maxv[0] = 0;
    rep(i, N) maxv[i + 1] = maxv[i] + sushi[i + 1].second - (sushi[i + 1].first - sushi[i].first);
    rep(i, N) maxv[i + 1] = max(maxv[i + 1], maxv[i]);
    revmaxv[0] = 0;
    rep(i, N) revmaxv[i + 1] = revmaxv[i] + sushi[N - i].second - ((C - sushi[N - i].first) - (C - sushi[N + 1 - i].first));
    rep(i, N) revmaxv[i + 1] = max(revmaxv[i + 1], revmaxv[i]);
    ll ans = 0;
    rep(i, N + 1) {
        ans = max(ans, maxv[i] + revmaxv[N - i] - sushi[i].first);
    }
    rep(i, N + 1) {
        ans = max(ans, revmaxv[i] + maxv[N - i] - (C - sushi[N + 1 - i].first));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  double x = (a + b) / 2.0;
  int t = x;
  if ((a + b) % 2 == 0){
    cout << t << endl;}
  else{
    cout << t + 1 << endl;}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    long double den = 0;
    for (int i = 0; i < n; ++ i) {
        long double x;
        cin >> x;
        den += 1.0 / x;
    }
    cout << fixed << setprecision(10) << (1.0 / den);
    
}

Measured memory_bytes: 256
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}
template<typename T>
struct BIT{
    std::vector<T> li;
    int size;
    BIT (int n){
        li=std::vector<T>(n+1,0);
        size=n;
    }
    T sum (int i){
        int s=0;
        while(i>0){
            s+=li[i];
            i-=i & -i;
        }
        return s;
    }
    void add(int i,T x){
        while(i<=size){
            li[i]+=x;
            i+=i & -i;
        }
    }
};

using namespace std;

int main(){
	int n,q;
	string s;
	cin >> n >> s >> q;
	vector<BIT<int>> da(26, BIT<int>(n));
	rip(i,n,0){
		da[s[i]-'a'].add(i+1,1);
	}
	vector<int> ans(0);
	int t;
	rip(i,q,0){
		cin >> t;
		if(t == 1){
			int j;
			char c;
			cin >> j >> c;
			j--;
			da[s[j]-'a'].add(j+1,-1);
			da[c-'a'].add(j+1,1);
			s[j] = c;
		}
		else{
			int ret = 0;
			int l,r;cin >> l >> r;
			rip(k,26,0){
				if(da[k].sum(r)-da[k].sum(l-1)){
					ret++;
				}
			}
			ans.push_back(ret);
		}
	}
	rip(i,ans.size(),0) printf("%d\n",ans[i]);
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

struct UnionFind{
    vector<long long int> par; //par[i] : iの親の番号
    vector<long long int> rnk; //root[i] : iの木のランク

   //コンストラクタ
    UnionFind(long long int n): par(n), rnk(n){
        //木の初期化
        for(long long int i = 0; i < n; i++){
            par[i] = i;
            rnk[i] = 1;
        }
    }

   //データxが属する木の根を再帰で取得
   long long int root(long long int x){
       if(par[x] == x){
           return x;
       }else{
           return par[x] = root(par[x]);
       }
   }

   //xとyが同じ木に属しているかを判定
   bool same(long long int x, long long int y){
       return root(x) == root(y);
   }

   //xとyの木を併合
   void unite(long long int x, long long int y){
       long long int rx = root(x); //xの根
       long long int ry = root(y); //yの根
       if(rx == ry) return; //根が同じならそのまま

       if(rnk[rx] < rnk[ry]){
           par[rx] = ry;
       }else{
           par[ry] =rx;
           if(rnk[rx] == rnk[ry]) rnk[rx]++;
       }
   }
};

int main(){
    long long n, m, l;
    cin >> n >> m >> l;
    vector<long long> p(n);

    long long i;
    /*for(i = 0; i < n; i++){
        cin >> p[i];
    }*/

    UnionFind road(n);
    UnionFind train(n);
    
    long long x, y;
    for(i = 0; i < m; i++){
        cin >> x >> y;
        road.unite(x-1, y-1);
    }

    for(i = 0; i < l; i++){
        cin >> x >> y;
        train.unite(x-1, y-1);
    }

    map<pair<long long, long long>, long long> mp;
    for(i = 0; i < n; i++) {
        mp[make_pair(road.root(i), train.root(i))] += 1;
    }
    for(i = 0; i < n; i++) {
        if(i!=n-1) {
            cout << mp[make_pair(road.root(i), train.root(i))] << " ";
        } else {
            cout << mp[make_pair(road.root(i), train.root(i))] << endl;;
        }
    }
}

Measured memory_bytes: 20608
import sys
input = sys.stdin.readline
import random
getr = random.randint

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	D = int(input())  # days
	vC = [0,]+linput()     # decrine rate
	
	#sumC = sum(vC)
	
	# satis (d,i)
	mS = [[0,]+linput() for _ in [0,]*D]
	
	
	vL = [-1,]*(26+1)   # last day of Type
	
	#day = -1
	res = 0      # manzoku
	vR = []
	vT = []
	rapp = vR.append
	tapp = vT.append
	
	#day = -1
	res = 0      # manzoku
	vR = []
	rapp = vR.append

	def get_scoreA(vtt):
		res = 0
		for d in range(D): #[0,364] day
			t = vtt[d] ## sample output
			vS = mS[d]
			Sdt = vS[t]
			res += Sdt
		
			vL[t] = d
			C = sum(c*(d-l) for c,l in zip(vC,vL))
			res -= C
		
			#rapp(res) ##
		return res

	## sample output
	#vT = [int(input()) for _ in [0,]*D] ## for p.C
	MR = 5050
	
	for m in range(MR):
		vTtmp = []
		for d in range(D):
			vTtmp.append(getr(1,26))
		resTmp = get_scoreA(vTtmp)
		if resTmp>res:
			res = resTmp
			rapp(res)
			vT = [t for t in vTtmp]
	
	#sT = "No Yes".split()
	#print(sT[res])
	#print(res)
	print(*vT, sep='\n')
	print(*vR, file=sys.stderr)
	#print(sum(vR), file=sys.stderr)

if __name__ == "__main__":
	main()


Measured memory_bytes: 82552
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,d,n,k,ac,pn,pn1,m,J;
    	cin>>n>>m;
    	pair<ll,string> p[m]; string s;
    	d=0; ac=0; pn=0; j=1; l=1; pn1=0;
    	rep(i,0,m)
    	{
    		cin>>k>>s;
    		p[i]={k,s};
		}
		map<ll,pii> mm;
		rep(i,0,m)
		{
			if(p[i].S=="WA")
			{
				if(mm[p[i].F].F==0)
				{
					mm[p[i].F].S+=1;
				}
			}
			else
			{
				if(mm[p[i].F].F==0)
				{
					ac++;
					mm[p[i].F].F=1;
					pn+=mm[p[i].F].S;
				}
			}
		}
		
		cout<<ac<<" "<<pn;
    }
	return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int A, B;

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

    int ans = -1;
    for (int i = 1; i <= 1009; ++i) {
        if ((int)(i * 0.08) == A && (int)(i / 10) == B) {
            ans = i;
            break;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, k;
ll a[100005];
ll v[100005];
ll cnt;

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    while(k--)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        if(a[t1] <= a[t2]) v[t1] = true;
        if(a[t2] <= a[t1]) v[t2] = true;
    }
    for(ll i = 1; i <= n; i++)
    {
        cnt += (!v[i]);
    }
    printf("%lld\n", cnt);
    return 0;
}


Measured memory_bytes: 5384
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());


int main()
{
	IOS;
	ll k,i,j,c=0,cs=0,t,n;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// double n,m;
		cin>>n;
		for(i=2;i*i<=n;i++)
		{
			if(n%i==0)
			{
				k=0;
				while(n%i==0)
				{
					n/=i;
					k++;
				}
				c+=((sqrt(1+8*k)-1)/2);
			}
		}
		if(n>1) c++;
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

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

int main()
{
 int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 int k;
  cin >> k;
  cout << a[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string N;

	cin >> N;

	if (N[0] == N[1] && N[1] == N[2])
		cout << "Yes" << endl;
	else if (N[1] == N[2] && N[2] == N[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,cnt=1,ans=0,sz;
  string s;
  vector<ll> v;
  cin >> n >> k >> s;
  for(int i=1;i<n;i++){
    if(s[i-1]!=s[i]){
      v.push_back(cnt);
      ans += cnt-1;
      cnt=0;
    }
    cnt++;
  }
  ans += cnt-1;
  v.push_back(cnt);
  sz = v.size();
  while(sz>2&&k>0){
    sz -= 2;
    k--;
    ans += 2;
  }
  if(sz==2&&k!=0){
    ans++;
    sz = 1;
    k--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[200005];
int main()
{
	string a,b;
	cin>>a>>b;
	int ans=0;
	for (int i = 0; i < a.size(); i++)
	{
		if(a[i]!=b[i]) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3904
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N;
    cin >> N;

    int score[2] = {0};
    for (int q = 0; q < N; ++q) {
        string S[2];
        for (int i = 0; i < 2; ++i) {
            cin >> S[i];
        }

        if (S[0] > S[1]) {
            score[0] += 3;
        } else if (S[0] == S[1]) {
            score[0]++;
            score[1]++;
        } else {
            score[1] += 3;
        }
    }

    cout << score[0] << " " << score[1] << endl;
    return 0;
}



Measured memory_bytes: 3200
r,g,b,n=map(int,input().split())

ans=0
for i in range(n//r+1):
    for j in range(n//g+1):
        if (n-(i*r+j*g))%b==0 and (n-(i*r+j*g))>=0:
            #print(n-(i*r+j*g))
            ans+=1
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int N,X;
int A[111111];

signed main(){
    cin>>N>>X;
    int g=0;
    rep(i,N){
        cin>>A[i];
        A[i]-=X;
        A[i]=abs(A[i]);
        g=gcd(g,A[i]);
    }
    cout<<g<<endl;
}


Measured memory_bytes: 1024
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new aoj1237().doIt();
    }
    class aoj1237{	
    	int  W = 0,H = 0;
    	int map[][] = new int[8][8];
    	int hpm[][] = new int[8][8];
    	int deepm[][] = new int[8][8];
    	int result = 10000;
    	int mx[] = {0,1,0,-1};
    	int my[] = {1,0,-1,0};
    	int gx = 0,gy = 0;
    	void dfs(int x,int y,int hp,int deep){
//    		System.out.println(x+" "+y+" "+deep+" "+hp);
    		hpm[y][x] = hp;
    		deepm[y][x]= deep;
    		if(map[y][x] == 3){
    			result = Math.min(result, deep);
    		}else if(hp > 1){
    			for(int i = 0;i < 4;i++){
    				if(mx[i] + x >= 0 && mx[i] + x < W &&
    						my[i] + y >= 0 && my[i] + y < H){
    					if(hpm[my[i]+y][mx[i]+x] > hp && deepm[my[i]+y][mx[i]+x] < deep)continue;
    					if(map[my[i]+y][mx[i]+x] == 1)dfs(mx[i]+x,my[i]+y,hp-1,deep+1);
    					else if(map[my[i]+y][mx[i]+x] == 3)dfs(mx[i]+x,my[i]+y,hp-1,deep+1);
    					else if(map[my[i]+y][mx[i]+x] == 4){
    						map[my[i]+y][mx[i]+x] = 1;
    						dfs(mx[i]+x,my[i]+y,6,deep+1);
    						map[my[i]+y][mx[i]+x] = 4;
    					}
    				}
    			}
    		}
    	}
    	void check(){
    		for(int i = 0;i < H;i++){
				for(int j = 0;j < W;j++){
					System.out.print(hpm[i][j]+" ");
				}
				System.out.println();
    		}
    	}
    	void doIt(){
    		while(true){
    			W = sc.nextInt();
    			H = sc.nextInt();
    			int x = 0,y = 0;
    			if(W + H == 0)break;
    			for(int i = 0;i < H;i++){
    				for(int j = 0;j < W;j++){
    					map[i][j] = sc.nextInt();
    					hpm[i][j] = 0;
    					deepm[i][j] = 10000;
    					if(map[i][j] == 2){
    						x = j;y = i;
    					}else if(map[i][j] == 3){
    						gx = j;gy = i;
    					}
//    					System.out.print(map[i][j]);
    				}
//    				System.out.println();
    			}
    			result = 10000;
    			int ok = 10000;
    			dfs(x,y,6,0);
//    			check();
    			if(result == 10000)System.out.println(-1);
    			else System.out.println(result);
    		}
    	}
    }
}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}



int solve(){
	int n;cin>>n;
	set<int>s1,s2,s3,s4;
	int x,y;cin>>x>>y;
	s1.insert(-x-y);
	s2.insert(-x+y);
	s3.insert(x-y);
	s4.insert(x+y);
	int mx=0;
	rep(i,2,n+1){
		int x,y;cin>>x>>y;
		int d=x+y+*s1.rbegin();
		maxs(d,-x-y+*s4.rbegin());
		maxs(d,-x+y+*s3.rbegin());
		maxs(d,x-y+*s2.rbegin());
		maxs(mx,d);
		s1.insert(-x-y);
		s2.insert(-x+y);
		s3.insert(x-y);
		s4.insert(x+y);
	} 
	cout<<mx<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 41112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }
    static long GCD(long x,long y)
    {
        if (y == 0) return x;
        return GCD(y, x % y);
    }

    static long LCM(long x,long y)
    {
        return x * y / GCD(x, y);
    }

    static int keta(int x)
    {
        string s = x.ToString();
        return s[s.Length - 1]-'0';
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int[] x=new int[5];
         x[0] = sc.intarr[0];
         x[1] = sc.intarr[0];
         x[2] = sc.intarr[0];
         x[3] = sc.intarr[0];
         x[4] = sc.intarr[0];

        int[] x2=new int[5];
        int xi = 0;
        for(int i = 0; i < 5; ++i)
        {
            x2[i] = keta(x[i]);
            if (x2[i] == 0) xi++;
        }
        if (xi >= 5) xi = 4;

        Array.Sort(x2, x);
        int ans = x[xi];
        for(int i = 0; i < 5; ++i)
        {
            if (i != xi)
            {
                ans += x[i] - keta(x[i]);
                if (keta(x[i]) != 0)
                {
                    ans += 10;
                }
            }

        }
        wr.wri(ans);





    }


}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 11348
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int X= keyboard.nextInt();
		int ans = 8;
		
		if(X<=599) {
			ans = 8;
		}else if(X<=799) {
			ans =7;
		}else if(X<=999) {
			ans =6;
		}else if(X<=1199) {
			ans =5;
		}else if(X<=1399) {
			ans =4;
		}else if(X<=1599) {
			ans =3;
		}else if(X<=1799) {
			ans =2;
		}else {
			ans =1;
		}
		
		System.out.println(ans);
		keyboard.close();	
		
	}
}

Measured memory_bytes: 35728
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int n = b - a;
        int bb = ((n + 1) * n) / 2;
        System.out.println(bb - b);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
 
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll a,b,c,d;
    cin >>a>>b>>c>>d;
    ll ans=b;
    ll l=c/gcd(c,d)*d;
    ans-=b/c;
    ans-=b/d;
    ans+=b/l;

    a=a-1;
    ll ans2=a;
    ans2-=a/c;
    ans2-=a/d;
    ans2+=a/l;
    
    cout << ans-ans2;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(S: str, T: str, A: int, B: int, U: str):
    return f"{A-(S==U)} {B-(T==U)}"


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    print(f'{solve(S, T, A, B, U)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75296
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
    ll aa[5];
    ll k;
  
    ll Q,N;
    string S;
    cin>>aa[0]>>aa[1]>>aa[2]>>aa[3]>>aa[4]>>k;

    // for(i=0;i<5;i++){
    //     for(j=1;j=4-i;j++){
    //         if(abs(aa[i]-aa[i+j])>k){
    //             cout<<":("<<endl;
    //             return 0;
    //         }
    //     }
    // }

// for(i=0;i<Q;i++){
//     cin>>a[i]>>b[i];
//     scanf("%d", &a);
//     scanf("%d", &b);
//     printf("%d\n",a[i]);
// }
if(aa[4]-aa[0]>k){
    cout<<":("<<endl;
}else{
    cout << "Yay!" << endl;
}
return 0;
}

Measured memory_bytes: 256
//AOJ GRL_4_B

#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

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

vector<int> toporogical_sort(const vector<vector<int> > g){
	int n = g.size();
	vector<int> in_degree(n,0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[i].size(); j++){
			in_degree[g[i][j]]++;
		}
	}

	vector<int> res;
	stack<int> S;
	for(int i = 0; i < n; i++){
		if(in_degree[i]==0) S.push(i);
	}

	while(!S.empty()){
		int p = S.top();
		S.pop();
		res.push_back(p);
		for(int i = 0; i < g[p].size(); i++){
			in_degree[g[p][i]]--;
			if(in_degree[g[p][i]]==0) S.push(g[p][i]);
		}
	}

	return res;
}

vector<ll> dijkstra(const vector<vector<P> > g,const int r){
	int n = g.size();
	vector<ll> res(n,INF);
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,r));
	res[r]=0;
	while(!que.empty()){
		P x = que.top();que.pop();
		for(int i = 0; i < g[x.second].size(); i++){
			if(res[g[x.second][i].second] > x.first + g[x.second][i].first){
				res[g[x.second][i].second] = x.first + g[x.second][i].first;
				// g[x.second][i].first = x.first + g[x.second][i].first;
				que.push(P(res[g[x.second][i].second],g[x.second][i].second));
			}
		}
	}

	return res;
}

int main()
{
	int V,E,r;
	cin>>V>>E>>r;
	vector<vector<P> > g(V,vector<P>());
	for(int i = 0; i < E; i++){
		int a,b,d;
		cin>>a>>b>>d;
		g[a].push_back(P(d,b));
	}

	vector<ll> shortest_path = dijkstra(g,r);
	for(int i = 0; i < shortest_path.size(); i++){
		if(shortest_path[i]==INF) cout << "INF"<<endl;
		else cout << shortest_path[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 30856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
// #define int long long ;
int main()
{
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[3][n];
    //dp[0]=max(a[0],max(b[0],c[0]));
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    for(ll i=1;i<n;i++)
    {
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
        
    }
    ll ans=max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
    cout<<ans<<endl;
    
}

Measured memory_bytes: 4864
#include<stdio.h>
int main(){
  int N;
  int X[100] = {};
  int P;
  int S = 0;
  int E1,E2,E3;
  int i,j,k;

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

  for(j=0;j<N;j++){
    S += X[j];
  }

  P = S/N;
  E1 = 0;
  E2 = 0;
  E3 = 0;

  for(k=0;k<N;k++){
    E1 += (X[k]-P)*(X[k]-P);
    //E2 += (X[k]-(P+1))*(X[k]-(P+1));
    E3 += (X[k]-(P+1))*(X[k]-(P+1));
  }

  if(E1<E3){
    printf("%d",E1);
  }
  if(E3<E1){
    printf("%d",E3);
  }
  if(E1==E3){
    printf("%d",E1);
  }
  /*if(E2<E3 && E2<E1){
    printf("%d",E2);
  }
  if(E3<E1 && E3<E2){
    printf("%d",E3);
  }*/
  //printf("%d",E1);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long ll;

template <typename T>
T gcd(T a, T b)
{
    return a ? gcd(b % a, a) : b;
}

template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

ll calcNum(const ll a, const ll b, const ll c)
{
    return a - (a / b) - (a / c) + (a / lcm(b, c));
}

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

    ll ans = calcNum(B, C, D) - calcNum(A - 1, C, D);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int d[200000+2];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &d[i]);
	
	int maxv = d[1]-d[0];	// 2 <= n < 200000
	int minv = d[0];		// Store a mininum value and get diff value with next value after next mininum
	for (int i = 1; i < n; i++) {
		maxv = (d[i]-minv > maxv)?(d[i]-minv):maxv;
		minv = (minv > d[i])?d[i]:minv;
	}	//	local save history value
	
	printf("%d\n", maxv);
	
	return 0;
}

Measured memory_bytes: 3364
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(true) {
			int tmp = s.nextInt();
			//int m = Integer.parseInt(tmp);
			if(tmp == 0)
				break;
			solve(tmp, tmp, "");
		}
	}

	public static void solve(int squareCnt, int maxPutCnt, String history) {
		if(squareCnt == 0) {
			System.out.println(history.trim());
			return;
		}

		for(int i = maxPutCnt ; i >= 1 ; i--) {
			if(i <= squareCnt)
			solve(squareCnt-i, i, history + i+" ");
		}
	}
}

Measured memory_bytes: 44436
n=int(input())
x = [int(i) for i in input().split()]
x = sorted([[x[i], i] for i in range(n)])
#print(x)
ans = [0]*n
for i in range(n):
  if i < n//2:
    ans[x[i][1]] = x[n//2][0]
  else:
    ans[x[i][1]] = x[n//2-1][0]
for i in range(n):
  print(ans[i])

Measured memory_bytes: 43988
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    sort(p.begin(),p.end());
    int sum=0;
    rep(i,K) sum+=p[i];
    cout << sum << endl;
    return 0;
}





Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Class_
{
	void Test()
	{
		var N = A_Int_()[0];

		var c = N * 800;
		var d = N / 15 * 200;
		
		Console.WriteLine(c-d);

	}

	static void Main(string[] args)
  {
    new Class_().Test();
  }

  #region

  string S_String_()
  {
    return Console.ReadLine();
  }

	//
	string[] A_String_()
  {
    return Console.ReadLine().Split();
  }

  int[] A_Int_(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

	//
	int[] A_Int_()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int n = 100005;
vector<vector<int>> tree(n,vector<int>());
vector<int> h(n);

bool good(int i){
    if(tree[i].size() ==0){
        return true;
    }
    bool res = true;
    for(int j:tree[i]){
        if(h[j] >= h[i]){
            res = false;
            break;
        }
    }
    return res;
}

int main(){
    int m;
    cin >> n >> m;
    rep(i,n){
        cin >> h[i];
    }
    rep(i,m){
        int a,b;
        cin >> a>> b;
        --a;--b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    int cnt = 0;
    rep(i,n){
        if(good(i)) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 8804
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=310,M=100010;
bool w[N][N];
int s1[N],s2[N];
struct Dat {
    int x,y,z;
} g[N],v[M];
inline int gi() {
    int x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x;
}
int main() {
    int A,B,cnt=0,n=0,m=0;
    cin>>A>>B;
    for(int i=0;i<=100;i++) {
	s1[i]=++n,s2[i]=++n;
	if(i) {
	    v[++m]=(Dat){s1[i-1],s1[i],-1};
	    v[++m]=(Dat){s2[i],s2[i-1],-2};
	}
    }
    for(int i=1;i<=A;i++)
	for(int j=1;j<=B;j++) g[++cnt]=(Dat){i,j,gi()};
    for(int i=1;i<=cnt;i++) {
	int x=g[i].x,y=g[i].y,z=g[i].z;
	for(int p=0;p*x<=z;p++)
	    for(int q=0;p*x+q*y<=z;q++) {
		int c=z-p*x-q*y;
		bool flg=1;
		for(int j=1;j<=cnt;j++) {
		    int X=g[j].x,Y=g[j].y;
		    if(p*X+q*Y+c<g[j].z) {flg=0;break;}
		}
		if(flg) {
		    if(!w[s1[p]][s2[q]])
			w[s1[p]][s2[q]]=1,v[++m]=(Dat){s1[p],s2[q],c};
		    goto ed;
		}
	    }
	return puts("Impossible"),0;
    ed:;
    }
    puts("Possible");
    cout<<n<<' '<<m<<endl;
    for(int i=1;i<=m;i++) {
	printf("%d %d ",v[i].x,v[i].y);
	if(v[i].z==-1) puts("X");
	else if(v[i].z==-2) puts("Y");
	else printf("%d\n",v[i].z);
    }
    cout<<1<<' '<<2;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = set()

flag = True
for i in range(N):
    S = input()
    if S in s:
        flag = False
    if i > 0 and S[0] != prev:
        flag = False
    s.add(S)
    prev = S[-1]
if flag:
    print("Yes")
else:
    print("No")


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

int main(){
    string s;
    cin >>s;
    int count=0;
    int ma=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')count++;
        else{ma=max(count,ma);
        count=0;
        }
    }
    ma=max(count,ma);
    cout << ma << endl;
}

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

template<class T> inline bool chmax(T& a, T b){
  if (a < b) { a = b; return true; } return false;
}
ll INF = 1LL<<60;

ll dp[100010] = {0};

int
main(void)
{
  int n; cin >> n;
  int m; cin >> m;
  bool not_broken[n + 1];
  repe(i, 0, n){
    not_broken[i] = true;
  }

  rep(i, 0, m){
    int tmp; cin >> tmp;
    not_broken[tmp] = false;
  } 

  dp[0] = 1;
  if(not_broken[1]) dp[1] = 1;

  repe(i, 2, n){
    if(not_broken[i - 1]) dp[i] += dp[i - 1];
    if(not_broken[i - 2]) dp[i] += dp[i - 2];
    dp[i] %= 1000000007;
  }

  cout << dp[n] << endl;

  return 0;
}

Measured memory_bytes: 4488
H, W = [int(x) for x in input().split()]
N = int(input())
a = [0] + [int(x) for x in input().split()]

ans = [[0 for _ in range(W)] for _ in range(H)]
c = 1  # 色
n = 0  # c色で塗られた数
for i in range(H):
    if i % 2 == 0:
        start = 0
        end = W
        by = 1
    else:
        start = W - 1
        end = -1
        by = -1
    for j in range(start, end, by):
        ans[i][j] = c
        n += 1
        if n >= a[c]:
            c += 1
            n = 0

for i in range(H):
    print(*ans[i])

Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

#define edge edge<int>
#define edges edges<int>
#define graph graph<int>
#define matrix matrix<int>

////////////////////////////////////////////////////////////////////

int k,n,a[210000],r[210000];map<int,int> mp;queue<int> que;


signed main(){
  cin>>n>>k;rep(i,n)cin>>a[i];
  repd(i,1,n+1)r[i] = r[i-1] + a[i-1];
  rep(i,n+1){
    (r[i] -= i) %= k;
  }
  int ans = 0;
  rep(i,n+1){
    ans += mp[r[i]];
    mp[r[i]]++;
    que.push(r[i]);
    if(que.size() >= k){
      mp[que.front()]--;
      que.pop();
    }
  }
  cout << ans << endl;
} 


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

int main() {
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  for (int i = 0; i < N; ++i)
    cin >> x[i];

  int X = A;
  for (int i = 0; i < N; ++i)
    X = max(x[i], X);

  static long long dp[51][51][50 * 50 + 51] = {};
  dp[0][0][0] = 1;
  for (int j = 0; j < N; ++j) {
    for (int k = 0; k < N; ++k) {
      for (int s = 0; s < N * X; ++s) {
        dp[j + 1][k + 1][s + x[j]] = dp[j][k][s];
        dp[j + 1][k][s] += dp[j][k][s];
      }
    }
  }

  long long ans = 0;
  for (int k = 1; k <= N; ++k)
    ans += dp[N][k][k * A];

  cout << ans << endl;
}

Measured memory_bytes: 51072
n, l = map(int, input().split())

ans = 0

if l<=0<=l+n-1:
    for i in range(n):
        ans += l+i
    print(ans)

elif l<0:
    for i in range(n-1):
        ans += l+i
    print(ans)

else:
    for i in range(n-1):
        ans += l+i+1
    print(ans)

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;

vector<int> gf[N], gb[N];
int p[N];

int find(int v){
	return (p[v] < 0)?v:(p[v] = find(p[v]));
}

void combine(int u, int v){
	u = find(u), v = find(v);
	if(u == v)return;
	if(p[u] > p[v])swap(u, v);
	p[u] += p[v];
	p[v] = u;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m, k;
	cin>>n>>m>>k;
	memset(p, -1, sizeof(p));
	for(int i = 0; i < m; i++){
		int u, v;
		cin>>u>>v;
		gf[u].push_back(v);
		gf[v].push_back(u);
		combine(u, v);
	}
	for(int i = 0; i < k; i++){
		int u, v;
		cin>>u>>v;
		gb[u].push_back(v);
		gb[v].push_back(u);
	}
	for(int i = 1; i <= n; i++){
		int ans = -p[find(i)] - 1 - gf[i].size();
		for(auto u : gb[i]){
			if(find(u) == find(i))ans--;
		}
		cout<<ans<<" ";
	}

	return 0;
}

Measured memory_bytes: 12280
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 924844033
using namespace std;
namespace ywy{
	inline int get(){
		int n=0;char c;while((c=getchar())||23333){
			if(c>='0'&&c<='9')break;if(c=='-')goto s;
		}n=c-'0';while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
		}s:while((c=getchar())||23333){
			if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
		}
	}
	void print(ll num){
		if(num>=10)print(num/10);putchar(num%10+'0');
	}
	inline ll mi(int a,int b){
		ll ans=1,tmp=a;while(b){
			if(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;
		}return(ans);
	}int hudie[524288];
	inline void ntt(int n,ll *f,ll g){
		for(register int i=0;i<n;i++)if(i<hudie[i])swap(f[i],f[hudie[i]]);
		for(register int bit=2;bit<=n;bit<<=1){
			ll dk=mi(g,(p-1)/bit);for(register int i=0;i<n;i+=bit){
				ll dwg=1;for(register int j=i;j<i+(bit>>1);j++){
					ll cjr=(f[j+(bit>>1)]*dwg)%p;f[j+(bit>>1)]=(f[j]+p-cjr)%p;f[j]=(f[j]+cjr)%p;dwg=(dwg*dk)%p;
				}
			}
		}
	}ll a[524288],b[524288];
	typedef struct _b{
		int dest;int nxt;
	}bian;bian memchi[1000001];int gn=1,heads[200001],cnt[200001];
	inline void add(int s,int t){
		memchi[gn].dest=t;memchi[gn].nxt=heads[s];heads[s]=gn;gn++;
	}int size[200001];ll jc[200001],jcny[200001];
	inline ll cnm(int n,int m){
		if(n<m)return(0);ll cjr=jc[n];cjr*=jcny[m];cjr%=p;cjr*=jcny[n-m];return(cjr%p);
	}
	void dfs(int pt,int baba){
		size[pt]=1;for(register int i=heads[pt];i;i=memchi[i].nxt){
			if(memchi[i].dest==baba)continue;dfs(memchi[i].dest,pt);size[pt]+=size[memchi[i].dest];
		}if(baba)cnt[size[pt]]++;
	}ll ans[200001];int ltt[200001];
	void ywymain(){
		int n=get();for(register int i=1;i<n;i++){
			int s=get(),t=get();add(s,t);add(t,s);
		}jc[0]=1;for(register int i=1;i<=n;i++)jc[i]=(jc[i-1]*i)%p;jcny[n]=mi(jc[n],p-2);
		for(register int i=n-1;i>=0;i--)jcny[i]=(jcny[i+1]*(i+1))%p;dfs(1,0);
		for(register int i=1;i<=n;i++)ans[i]=(n*cnm(n,i))%p;for(register int i=0;i<=n;i++){
			a[i]=(jc[i]*cnt[i])%p;b[i]=jcny[n-i];
		}int k=1;while(k<=n+n)k<<=1;for(register int i=0;i<k;i++)hudie[i]=(hudie[i>>1]>>1)|((i&1)?(k>>1):0);
		ntt(k,a,5);ntt(k,b,5);for(register int i=0;i<k;i++)a[i]=(a[i]*b[i])%p;ntt(k,a,mi(5,p-2));
		ll inv=mi(k,p-2);for(register int i=0;i<k;i++)a[i]=(a[i]*inv)%p;for(register int i=1;i<=n;i++){
			ans[i]-=jcny[i]*a[n+i];ans[i]%=p;ans[i]+=p;ans[i]%=p;
		}memset(a,0,sizeof(a));memset(b,0,sizeof(b));for(register int i=2;i<=n;i++)ltt[n-size[i]]++;
		for(register int i=0;i<=n;i++){
			a[i]=(jc[i]*ltt[i])%p;b[i]=jcny[n-i];
		}
		ntt(k,a,5);ntt(k,b,5);for(register int i=0;i<k;i++)a[i]=(a[i]*b[i])%p;ntt(k,a,mi(5,p-2));
		for(register int i=0;i<k;i++)a[i]=(a[i]*inv)%p;for(register int i=1;i<=n;i++){
			ans[i]-=jcny[i]*a[n+i];ans[i]%=p;ans[i]+=p;ans[i]%=p;
			print(ans[i]);putchar('\n');
		}
	}
}
int main(){
	ywy::ywymain();return(0);
}

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

int N;
vector<int> d;

int main() {
    cin >> N; d.resize(N);
    for (int i=0; i<N; i++) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = d[N/2] - d[N/2-1];
    cout << ans << endl;
}

Measured memory_bytes: 640
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x=parseInt(readline())
    if x<1200
        println("ABC")
    else
        println("ARC")
    end
end
main()

Measured memory_bytes: 109768
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}


int solve(){
  vector<int> d;  // distance
  vector<int> p;  // parent

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

  // input
  bool nr[n] = {};/*{{{*/
  int a[n+m-1]  = {};
  int b[n+m-1] = {};
  auto g = vector<vector<int>>(n);
  auto r = vector<set<int>>(n);

  rep(i, n+m-1){
    cin>>a[i]>>b[i]; a[i]--;b[i]--;
    nr[b[i]] = 1;
    g[a[i]].pb(b[i]);
    r[b[i]].insert(a[i]);
  }

  int root;
  rep(i, n){ if (nr[i]==false) root = i; }
  dump(root);
  /*}}}*/

  d = vector<int>(n, -1);
  p = vector<int>(n, -1);
  d[root] = 0;
  p[root] = -1;
  stack<int> S;
  S.push(root);
  while (!S.empty()){
    int node = S.top(); S.pop();
    for (auto c : g[node]){
      r[c].erase(node);
      if (sz(r[c])==0){
        d[c] = d[node] + 1;
        p[c] = node;
        S.push(c);
      }
    }
  }

  dump(d);
  dump(p);

  for(auto tmp : p){
    cout << tmp + 1 << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 18944
use std::io::*;

fn read<T: std::str::FromStr>(i: &mut StdinLock) -> T {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn reads<T: std::str::FromStr>(i: &mut StdinLock) -> Vec<T> {
    let mut s = String::new();
    i.by_ref().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    // initialize stdin
    let sin = std::io::stdin();
    let mut sin = sin.lock();
    let sin = &mut sin;

    let _n: usize = read(sin);
    let ax: Vec<i64> = reads(sin);

    let ans: i64 = ax.into_iter().map(|x| x - 1).sum();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
bool second(ll x,ll y,ll z){
    if(z>=y){
        if(y>x)return true;
        else return false;
    }else{
        if(y<=x)return true;
        else return false;
    }
}
int main(void){
    ll n;
    cin>>n;
    ll p[n];
    rep(0,i,n)cin>>p[i];
    ll ans=0;
    rep(0,i,n-2)if(second(p[i],p[i+1],p[i+2]))++ans;
    cout<<ans<<endl;
}


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

int main() {
  int k, n;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans++;
    i += k - 1;
    if (i < n - 1) i--;
  }
  cout << ans << endl;

  return 0;
}

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

int main(void){
    string s;
    cin>>s;
    map<char,bool> mp;
    for(char c:s){
        mp[c] = true;
    }
    rep(i,26){
        if(!mp['a'+i]){
            printf("%c\n",'a'+i);
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
c = [list(map(int, input().split())) for _ in range(3)]
a1 = 0
b1 = c[0][0]
a2 = c[1][0] - b1
a3 = c[2][0] - b1
b2 = c[1][1] - a2
b3 = c[2][2] - a3
A = [a1, a2, a3]
B = [b1, b2, b3]

for i in range(3):
    for j in range(3):
        if c[i][j] != A[i]+B[j]:
            print("No")
            exit(0)

print("Yes")

Measured memory_bytes: 61988