akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------
vector<int>du(200001,1e9);
vector<int>dv(200001,1e9);
int now1=0;
int now2=0;
int color1[100001];
int color2[100001];
void dfs1(const vector<vector<int>>& g,int s){
    //cout<<1<<endl;
    if(color1[s])return;
    chmin(du[s],now1);
    color1[s]=1;
    if(g[s].size()==0){
        return;
    }
    for(int i=0;i<g[s].size();i++){
        if(color1[g[s][i]])continue;
        now1++;
        dfs1(g,g[s][i]);
        now1--;
    }
}
void dfs2(const vector<vector<int>>& g,int s){
    if(color2[s])return;
    chmin(dv[s],now2);
    color2[s]=1;
    if(g[s].size()==0){
        return;
    }
    for(int i=0;i<g[s].size();i++){
        if(color2[g[s][i]])continue;
        now2++;
        dfs2(g,g[s][i]);
        now2--;
    }
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,u,v;
    cin>>n>>u>>v;
    u--;v--;
    vector<vector<int>>g(n);
    for(int i=0;i<n-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    
    dfs1(g,u);
    dfs2(g,v);
    int ans=0;
    for(int i=0;i<n;i++){
        if(du[i]>dv[i])continue;
        else
            chmax(ans,dv[i]-1);
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 10624
#include<stdio.h>
char is_prime[1000000];
int sum_prime[1000000];
int main() {
  int x, y;
  for (x = 0; x < 1000000; x ++) is_prime[x] = 1;
  is_prime[0] = 0; is_prime[1] = 0;
  for (x = 2; x < 1000; x ++) {
    if (is_prime[x] != 0) {
      for (y = x * x; y < 1000000; y += x) {
	is_prime[y] = 0;
      }
    }
  }
  for (x = 1; x < 1000000; x ++) {
    sum_prime[x] = sum_prime[x - 1] + is_prime[x];
  }
  while (scanf("%d", &x) != EOF) {
    printf("%d\n", sum_prime[x]);
  }
  return 0;
}

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = false;
            UInt64 retint = 0;
            string retstr = string.Empty;
            var ins = Console.ReadLine().Split(' ');
            var num = ins.Select(x => c2i(x)).ToList();

            var ins2 = Console.ReadLine().Split(' ');
            List<UInt64> enemyeach = ins2.Select(x => (UInt64)c2i(x)).ToList();
            enemyeach.Sort();
            var enemy = num[0];
            var killcount = num[1];

            for (int i = 0; i < enemy - killcount;i++ )
            {
                retint += enemyeach[i];
            }

            Console.WriteLine(retint);
            //Console.ReadLine();
        }
            
        static int c2i(string c) { return int.Parse(c); }
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a,b,c,k;

int main(){
    cin >> a >> b >> c >> k;
    if(a > b)swap(a,b);
    if(b > c)swap(b,c);
    ll ans = a + b;
    rep(i,k)c *= 2;
    cout << ans + c << endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;
    REP(i, k) {
        if(a+i<=b) s.insert(a+i);
        if(b-i>=a) s.insert(b-i);
    }
    
    for(auto x : s) {
        cout << x << endl;
    }

    return 0;
}


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

int N;
vector<int> L;
vector<int> A; // A, B, C

int main() {
  cin.tie(nullptr);
	ios::sync_with_stdio(false);
  
    cin >> N;
    A.resize(3);
    for (int i = 0; i < 3; ++i) cin >> A[i];
    L.resize(N);
    for (int i = 0; i < N; ++i) cin >> L[i];

    int res = 1<<29;
    vector<int> bit(3);
    for (bit[0] = 1; bit[0] < (1<<N); ++bit[0]) { // 0 は含めない
        for (bit[1] = 1; bit[1] < (1<<N); ++bit[1]) { // 0 は含めない
            // 共通要素あったらダメ
            if (bit[1] & bit[0]) continue;
            for (bit[2] = 1; bit[2] < (1<<N); ++bit[2]) { // 0 は含めない
                // 共通要素があったらダメ
                if (bit[2] & bit[0]) continue;
                if (bit[2] & bit[1]) continue;
                
                // sums: A〜C に選んだ竹の長さの合計、nums: A〜C に選んだ竹の本数
                vector<int> sums(3, 0), nums(3, 0);
                for (int i = 0; i < N; ++i) {
                    for (int j = 0; j < 3; ++j) {
                        if (bit[j] & (1<<i)) {
                            sums[j] += L[i];
                            nums[j]++;
                        }
                    }
                }

                // score を求める
                int score = 0;
                for (int i = 0; i < 3; ++i) {
                    score += abs(sums[i] - A[i]); // +1, -1 のコスト
                    score += (nums[i] - 1) * 10; // 合体のコスト
                }
                res = min(res, score);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 380
a,b,c,d = map(int, input().split(" "))
n = 1
while a > 0 and c > 0:
    if n % 2 == 1:
        c = c - b
    else:
        a = a - d
    n += 1

if a <= 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;cin>>a>>b;
  if(a.size()>b.size())cout<<"GREATER"<<endl;
  else if(a.size()<b.size())cout<<"LESS"<<endl;
  else if(a==b)cout<<"EQUAL"<<endl;
  else{
    for(int i=0;i<a.size();i++){
      if(a.at(i)>b.at(i)){
        cout<<"GREATER"<<endl;
        break;
      }
      else if(a.at(i)<b.at(i)){
        cout<<"LESS"<<endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll h,w,H,W;
    cin >> H >> W >> h >> w;
    cout << (H-h) * (W-w) << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace UOA_PCKWU_1044
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input;
            while ( (input = Console.ReadLine().Split(' '))[1] != "X")
            {
                if (input[1] == "X") break;
                Console.WriteLine(NamingConvention.Convert(input[0], input[1]));
            }
        }
    }

    static class NamingConvention
    {
        public static string Convert(string value, string type)
        {
            if (!value.Contains('_'))
            {
                List<string> strs = value.Select(c => c.ToString()).ToList();
                strs[0] = strs[0].ToLower();
                value = strs.Select(s => char.IsUpper(s.First()) ? "_" + s.ToLower() : s).Aggregate((all, next) => all += next);
            }
            if (type == "D") return value;
            value = value.Split('_').Select(s => CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s)).Aggregate((all, next) => all += next);
            if (type == "U") return value;
            if (type == "L") return char.ToLower(value[0]) + value.Remove(0,1);
            throw new Exception();
        }
    }
}



Measured memory_bytes: 20484
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you KILLING me, pleASE...

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())

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

const ll maxn=1e5+10, mod=1e9+7, inf=1e18;

ll n;

ll p(ll i){ return n+i; }

int main(){
	
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	
	cin>>n;

	ll x=n; while(x%2==0) x/=2; if(x==1) return cout<<"No\n", 0;

	cout<<"Yes\n";
	cout<<"1 2\n";
	cout<<"2 3\n";
	cout<<3<<' '<<p(1)<<"\n";
	cout<<p(1)<<' '<<p(2)<<"\n";
	cout<<p(2)<<' '<<p(3)<<"\n";
		
	for(int i=4;i<n;i+=2){
		cout<<i<<' '<<i+1<<"\n";
		cout<<i+1<<' '<<1<<"\n";
		cout<<p(1)<<' '<<p(i)<<"\n";
		cout<<p(i)<<' '<<p(i+1)<<"\n";
	}

	if(n%2==0) cout<<n<<' '<<n-1<<"\n", cout<<p(n^(n-2))<<' '<<p(n)<<"\n";

	return 0;
}






















Measured memory_bytes: 2560
package main

import (
	"fmt"
	"unicode/utf8"
	"strings"
)

func main(){
	var s string
	fmt.Scan(&s)
	l := utf8.RuneCountInString(s)
	sl := make([]string,l)
	sl = strings.Split(s,"")
	var w int
	fmt.Scan(&w)
	for i:= 0; i < len(sl); i += w{
		fmt.Print(sl[i])
	}
}

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

using namespace std;
int H, W;
const int INF = 1000000000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool valid(int x, int w) {
    return 0 <= x && x < w;
}
int bfs(int sx, int sy, int gx, int gy, const vector<vector<int>>& ver, const vector<vector<int>>& hol) {
    int dist[50][50] = {};
    REP(y, H) REP(x, W) dist[y][x] = INF;
    dist[sy][sx] = 0;
    queue<int> qx, qy;
    qx.push(sx);
    qy.push(sy);
    while(!qx.empty()){
        int x = qx.front(); qx.pop();
        int y = qy.front(); qy.pop();
        REP(r, 4) {
            int nx = x + dx[r];
            int ny = y + dy[r];
            if(!valid(nx, W)) continue;
            if(!valid(ny, H)) continue;
            if(r % 2 == 0 && hol[y][x + (r == 0 ? 0 : -1)] == 1) continue;
            if(r % 2 == 1 && ver[y + (r == 1 ? 0 : -1)][x] == 1) continue;
            if(dist[ny][nx] > dist[y][x] + 1) {
                dist[ny][nx] = dist[y][x] + 1;
                qx.push(nx);
                qy.push(ny);
            }
        }
    }
    return dist[gy][gx];
}

int main(){
    while(cin >> H >> W && H > 0) {
        vector<vector<int>> ver(H - 1, vector<int>(W));
        vector<vector<int>> hol(H, vector<int>(W - 1));
        REP(y, H) {
            REP(x, W - 1) cin >> hol[y][x];
            if(y < H - 1) {
                REP(x, W) cin >> ver[y][x];
            }
        }

        int lb = 0, ub = 1000;

        while(ub - lb > 1) {
            int L = (lb + ub) / 2;

            queue<int> qx, qy;
            qx.push(0); qy.push(0);

            int dist[50][50] = {};
            REP(y, H) REP(x, W) dist[y][x] = INF;

            dist[0][0] = 0;
            while(!qx.empty()){
                int x = qx.front(); qx.pop();
                int y = qy.front(); qy.pop();
                REP(r, 4) {
                    int nx = x + dx[r];
                    int ny = y + dy[r];
                    if(!valid(nx, W)) continue;
                    if(!valid(ny, H)) continue;

                    int& target = (r % 2 == 0 ? hol[y][x + (r == 0 ? 0 : -1)] : ver[y + (r == 1 ? 0 : -1)][x]);
                    if(r % 2 == 0 && hol[y][x + (r == 0 ? 0 : -1)] == 1){
                        assert(target == 1);
                        continue;
                    }
                    if(r % 2 == 1 && ver[y + (r == 1 ? 0 : -1)][x] == 1){
                        assert(target == 1);
                        continue;
                    }

                    target = 1;
                    int res = bfs(x, y, W - 1, H - 1, ver, hol);
                    target = 0;

                    if(res + dist[y][x] > L) continue;

                    if(dist[ny][nx] > dist[y][x] + 1) {
                        dist[ny][nx] = dist[y][x] + 1;
                        qx.push(nx);
                        qy.push(ny);
                    }
                }
            }


            if(dist[H - 1][W - 1] <= L) {
                ub = L;
            } else {
                lb = L;
            }
        }

        if(ub == 1000) ub = -1;

        cout << ub << endl;
    }
    return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define MAXN 100000
#define MOD 1000000007
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int N, pA[MAXN+5], pB[MAXN+5], fx[MAXN+5], fy[MAXN+5]; ll S[MAXN+5], A, B, px, py, xi, yi; 
int main()
{
	N = read(), A = read(), B = read(), A<=B?:A^=B^=A^=B;
	for(rint i = 1; i <= N; S[i++] = read()); fx[0] = fy[0] = 1;
	for(rint i = 1, pa = 1, pb = 1; i <= N; pA[i] = pa-1, pB[i] = pb-1, i++)
		{for(; S[pa]+A <= S[i]; pa++); for(; S[pb]+B <= S[i]; pb++);}
	for(rint i = 2; i <= N; i++)
	{
		xi = fy[min(i-2,pA[i])], yi = fx[min(i-2,pB[i])];
		if(pA[i] < i-1){memset(fx+px,0,i-px-1<<2); px = i-1;}
		if(pB[i] < i-1){memset(fy+py,0,i-py-1<<2); py = i-1;}
		fx[i-1] += fx[i-2], fx[i-1]<MOD?:fx[i-1]-=MOD, fx[i-1] += xi, fx[i-1]<MOD?:fx[i-1]-=MOD;
		fy[i-1] += fy[i-2], fy[i-1]<MOD?:fy[i-1]-=MOD, fy[i-1] += yi, fy[i-1]<MOD?:fy[i-1]-=MOD;
	}	printf("%d\n",(fx[N-1]+fy[N-1])%MOD); return 0;
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li n;

        cin>>n;

        li ans=1e18;

        for(li i=1;i*i<=n;i++)
        {
            if(n%i==0)
            {
                ans=min(ans,i+n/i-2);
            }
        }

        cout<<ans;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b, m; cin >> a >> b >> m;
  vector<int> ai(a), bj(b), aisorted(a), bjsorted(b);
  for(int i = 0; i < a; i++) {
    cin >> ai.at(i);
    aisorted.at(i) = ai.at(i);
  }
  for(int i = 0; i < b; i++) {
    cin >> bj.at(i);
    bjsorted.at(i) = bj.at(i);
  }
  sort(aisorted.begin(), aisorted.end());
  sort(bjsorted.begin(), bjsorted.end());
  
  vector<int> x(m), y(m), c(m);
  for(int i = 0; i < m; i++) {
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  
  set<int> allmin;
  allmin.insert(aisorted.at(0) + bjsorted.at(0));
  for(int i = 0; i < m; i++) {
    int eachmin;
    eachmin = ai.at(x.at(i)-1) + bj.at(y.at(i)-1) - c.at(i);
    allmin.insert(eachmin);
  }
  cout << *begin(allmin) << endl;
}

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int diff = a - b;
    if(k % 2) diff *= -1;
    cout << diff << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int n, t[100010], x[100010], y[100010];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> t[i] >> x[i] >> y[i];

    bool flg = true;
    for (int i = 1; i <= n; i++) {
        int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if (dist > t[i] - t[i-1]) {
            flg = false;
            break;
        }
        if (dist % 2 != (t[i] - t[i-1]) % 2) {
            flg = false;
            break;
        }
    }
    if (flg) puts("Yes");
    else puts("No");
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

using P = pair<int, int>;

VV<int> g;
VV<int> near;
VV<V<P>> top2; //(id, length)

V<P> buf;
void unique(V<P>& v) {
    sort(v.begin(), v.end(), [&](P a, P b) {
        if (a.first != b.first) return a.first < b.first;
        return a.second > b.second;
    });
    v.erase(unique(v.begin(), v.end(), [&](P a, P b) {
        return a.first == b.first;
    }), v.end());
    sort(v.begin(), v.end(), [&](P a, P b) {
        return a.second > b.second;
    });
    if (v.size() > 2) v.resize(2);
}

void dfs(int p, int b, int rt, int cr, int ndp) {
    near[rt][p] = cr;
    top2[rt][p].insert(top2[rt][p].end(), buf.begin(), buf.end());
    unique(top2[rt][p]);

    buf.push_back({cr, ndp});
    unique(buf);

    for (int d: g[p]) {
        if (d == b) continue;
        dfs(d, p, rt, cr, ndp + 1);
    }
}

VV<int> to_id;

VV<bool> vis;
VV<bool> dp;

bool solve(int p, int bp, int q, int bq) {
    int id1 = to_id[p][bp], id2 = to_id[q][bq];
    if (vis[id1][id2]) return dp[id1][id2];
    vis[id1][id2] = true;

    int da = -1, db = -1;
    for (auto pi: top2[p][near[p][q]]) {
        if (pi.first == bp) continue;
        da = max(da, pi.second);
    }
    for (auto pi: top2[q][p]) {
        if (pi.first == bq) continue;
        db = max(db, pi.second);
    }
    if (da > db) return dp[id1][id2] = true;
    if (near[p][q] == q) return dp[id1][id2] = false;
    return dp[id1][id2] = !solve(q, bq, near[p][q], p);
}

int main() {
    int n;
    cin >> n;
    g = VV<int>(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    near = VV<int>(n, V<int>(n, -1));
    top2 = VV<V<P>>(n, VV<P>(n));
    for (int s = 0; s < n; s++) {
        buf.clear();
        for (int d: g[s]) {
            dfs(d, s, s, d, 1);
        }
        for (int i = 0; i < n; i++) {
            reverse(g[i].begin(), g[i].end());
        }
        buf.clear();
        for (int d: g[s]) {
            dfs(d, s, s, d, 1);
        }
    }

    to_id = VV<int>(n, V<int>(n + 1, -1));
    int idc = 0;
    for (int i = 0; i < n; i++) {
        for (int j: g[i]) {
            to_id[i][j] = idc++;
        }
        to_id[i][n] = idc++;
    }

    vis = VV<bool>(idc, V<bool>(idc));
    dp = VV<bool>(idc, V<bool>(idc));

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            ans += solve(i, n, j, n);
        }
    }

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



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


int main(){
    int a,b;
    cin >> a >> b;
    int x = min(a,b);
    int y = max(a,b);
    rep(i,y){
        cout << x;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

long gcd(long a, long b) {
	while (b != 0) {
		long a_tmp = a;
		a = b;
		b = a_tmp % b;
	}
	return a;
}
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}

void solve() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	const char* ret = (a1 + a2 + a3 >= 22) ? "bust" : "win";
	cout << ret << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 888
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
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); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int I[303], U[303], A[303], P[303];
int shozo[303];

int main(){
    while(cin >> n && n){
        REP(i, 303)shozo[i] = 0;
        vector<pair<pair<int, int>, pair<int, int>>> v;
        REP(i, n){
            cin >> I[i] >> U[i] >> A[i] >> P[i];
            v.emplace_back(make_pair(make_pair(-A[i], P[i]), make_pair(I[i], i)));
        }
        sort(ALL(v));
        int idx = 0;
        REP(i, n){
            int team = v[i].second.second;
            if(idx < 10){
                if(shozo[U[team]] < 3){
                    cout << I[team] << endl;
                    shozo[U[team]]++;
                    idx++;
                }
            }else if(idx < 20){
                if(shozo[U[team]] < 2){
                    cout << I[team] << endl;
                    shozo[U[team]]++;
                    idx++;
                }
            }else if(idx < 26){
                if(shozo[U[team]] < 1){
                    cout << I[team] << endl;
                    shozo[U[team]]++;
                    idx++;
                }
            }
        }
    }
}


Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void) {
  int num;
  scanf("%d",&num);
  int work[num];
  int i;
  for (i = 0; i < num;++i) {
	  work[i] = 0;
  }
	  for (i = 1; i < num; ++i)
	  {
		  int ptr;
		  scanf("%d", &ptr);
		  work[ptr - 1] = work[ptr - 1] + 1;
	  }
  for(i = 0;i < num;++i) {
    if(i < num -1) {
    	printf("%d\n",work[i]);
    }
    else {
      printf("%d",work[i]);
    }
  }
return 0;
}

Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
inline bool chkmax(ll &x,ll y){return (x<y)?(x=y,1):0;}
const int maxn=1000+10;
const ll inf=1e18;
ll dp[maxn];
int a[maxn],pre[maxn];
int Ans[maxn];
int main(){
	int n=read();
	REP(i,1,n){
		a[i]=read();
		dp[i]=a[i];
	}
	REP(i,3,n)
		for(int j=i-2;j>=1;j-=2)
			if(chkmax(dp[i],dp[j]+a[i]))
				pre[i]=j;
	ll ans=-inf;
	int num,tmp=0;
	REP(i,1,n) if(chkmax(ans,dp[i])) num=i;
	printf("%lld\n",ans);
	if(ans<0){
		REP(i,1,n) if(a[i]==ans){
			printf("%d\n",n-1);
			DREP(j,n,i+1) printf("%d\n",j);
			REP(j,1,i-1) printf("%d\n",1);
			putchar('\n');
			return 0;
		}
	}
	DREP(i,n,num+1) Ans[++tmp]=i;
	while(num>1){
		for(int i=num-2;i>pre[num];i-=2) Ans[++tmp]=i;
		Ans[++tmp]=pre[num]+1;
		num=pre[num];
	}
	printf("%d\n",tmp);
	REP(i,1,tmp) printf("%d\n",Ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>

int main() {
ll n,sum=0; cin>>n;
vl s(n);
rep(i,n){
    cin>>s[i];
    sum+=s[i];
}
if(sum%10!=0){
    cout<<sum<<endl;
    return 0;
}
sort(s.begin(),s.end());
rep(i,n){
    if(s[i]%10!=0){
        sum-=s[i];
        cout<<sum<<endl;
        return 0;
    }
}
    cout<<0<<endl;
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define MOD 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
int a,b;
cin>>a>>b;
cout<<(a*3+b)/2<<endl;
return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::iter::Iterator;


fn main() {
    input!{
        a:i32,
        s:String,
    }

    if a < 3200 {
        println!("red")
    }else{
        println!("{}", s)
    }
}


Measured memory_bytes: 4352
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#v=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a = []
for i in range(n):
    a.append([int(i) for i in input().split()])
p = -1
a.sort()
while k>0:
    p+=1
    k-=a[p][1]
print(a[p][0])

Measured memory_bytes: 31672
pub 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()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let mut d: Vec<u32> = vec![0];
    let vv: Vec<u32> = read_vec();
    for v in vv {
        d.push(v);
    }
    d.sort();
    for i in 0..n + 1 {
        if i % 2 == 1 {
            d[i] = 24 - d[i];
        }
    }
    d.push(24);
    d.sort();

    let mut ans = 24;
    for i in 0..n + 1 {
        let tmp = d[i + 1] - d[i];
        if tmp < ans {
            ans = tmp;
        }
    }

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


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

#define mod 1000000007

#define rep(i, n) for(int i=1; i<=n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
    cin >> N;

    int ans = 0;

    rep(i, N)
        if(1 <= i && i <= 9 || 100 <= i && i <= 999 || 10000 <= i && i <= 99999)
            ans++;

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

Measured memory_bytes: 256
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var first = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = first[0];
            List<int> tmpList = new List<int>();
            var L = first[1];            
            for (int i = 0; i < N; i++)
            {
                tmpList.Add(L + i);
            }
            var except = tmpList.Select(x => Math.Abs(x)).Min();
            int result = 0;
            foreach (var item in tmpList)
            {
                if (item == except || item == -except)
                {
                    continue;
                }
                result += item;
            }
            Console.Write(result);
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC129.B();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }   
    H[0]--;
    for (int i = 0; i < N-1; i++) {
        if(H[i] >= H[i+1] + 1){
            No();
            return 0;
        }
        else if(H[i] == H[i+1]){
            continue;
        }
        else{
            H[i+1]--;
        }        
    }
    Yes();
}

Measured memory_bytes: 3708
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let readln () = read_line () |> split_on_char ' ' |> List.map int_of_string

let solve n q =
  let s = Array.init n (fun i -> i) in
  let rec find u =
    if u = s.(u) then u
    else begin
      s.(u) <- find s.(u);
      s.(u)
    end in
  for _ = 0 to q - 1 do
    match readln () with
    | n :: x :: y :: _ ->
      if n = 0 then s.(find x) <- find y
      else Printf.printf "%d\n" (if find x = find y then 1 else 0)
    | _ -> assert false
  done

let () =
  match readln () with
  | [n; q] -> solve n q
  | _ -> assert false

Measured memory_bytes: 4616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

bool isprime(int p){
  if(p == 1) return false;
  for(int i = 2; i < p; ++i){
    if(p % i == 0) return false;
  }
  return true;
}

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

  for(int i = 6; i <= 55555 && n > 0; i += 5){

    if(isprime(i)){
      cout << i <<" ";
      n--;
    }
  }
  cout << endl;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    
    int count = 0;
    for (int i = 0; i < N; i++){
        int h;
        cin >> h;
        if (h >= K){
            count++;
        }
    }
    cout << count << endl;
}


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

using namespace std;

int main()
{
	string str;
	cin >> str;
	int i,j,k;
	i = 0;
	int ans = 0;
	while(i < str.size() - 1 && str.size() >= 2)
	{
		if(str[i] != str[i+1])
		{
			ans += 2;
			string next = "";
			if(i > 0)
				next+= str.substr(0,i);
			if(i+2 < str.size())
				next+= str.substr(i+2);
			str = next;
			if(i > 0)
				i--;
		}
		else
		{
			++i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 680
#include <cmath>
#include <iostream>
#include <vector>
const int INF = 1010101010;
using namespace std;

void chmin(int &a, int b) {
  if (a > b) a = b;
}

int N, A, B, C;
vector<int> L;

int rec(int i, int a, int b, int c) {
  if (i == N) {
    if (a == 0 || b == 0 || c == 0) return INF;
    return abs(a - A) + abs(b - B) + abs(c - C);
  }

  int res = rec(i + 1, a, b, c);

  chmin(res, rec(i + 1, a + L[i], b, c) + (a ? 10 : 0));
  chmin(res, rec(i + 1, a, b + L[i], c) + (b ? 10 : 0));
  chmin(res, rec(i + 1, a, b, c + L[i]) + (c ? 10 : 0));

  return res;
}

int main() {
  
  cin >> N >> A >> B >> C;
  L.resize(N);
  for (int i = 0; i < N; ++i) cin >> L[i];

  cout << rec(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
intxt = input().split()
a = int(intxt[0])
b = int(intxt[1])
c = int(intxt[2])
d = int(intxt[3])

def gcd(x, y):
    if x < y:
        tmp = x
        x = y
        y = tmp
    while True:
        if x % y == 0:
            break
        x %= y
        tmp = x
        x = y
        y = tmp
    return y

lcd = c * d // gcd(c, d)

devided_c = b // c
devided_c -= (a - 1) // c
devided_d = b // d
devided_d -= (a - 1) // d
devided_cd = b // lcd
devided_cd -= (a - 1) // lcd

ans = (b - a + 1) - (devided_c + devided_d - devided_cd)
print(ans)

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

int main(){
	string str,str2;
	cin >> str;
	int n,a,b;
	cin >> n;
	for(int i=0;i<n;i++){
		string cm;
		cin >> cm >> a >> b;
		if(cm=="print"){
			cout << str.substr(a,b-a+1) << endl;
		}else if(cm=="reverse"){
			for(int i=a,j=b;i<j;i++,j--){
				swap(str[i],str[j]);
			}
		}else if(cm=="replace"){
			cin >> str2;
			for(int i=a;i<=b;i++){
				str[i]=str2[i-a];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

#define rep(i, n) for (int i = 0; i < (n); ++i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP

void	Main()
{
	int	n;
	cin >> n;

	double	sum;
	sum = 0;
	vector<int> V(n);
	rep(i, n)
	{
		int	x;
		cin >> x;
		sum += x;
		V.at(i) = x;
	}
	double	middle;
	middle = sum / 2.0;
	sum = V.at(0);
	double	distance;
	for (int i = 1; i < n; i++)
	{
		sum += V.at(i);
		if (sum > middle)
		{
			distance = min(abs(sum - middle), abs(sum - V.at(i) - middle));
			break ;
		}
	}
	cout << (int)(distance * 2.0) << endl;


}
// END

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


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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef long long int lli; 
 
int main(){
    
    AndIamIronMan;
	string s;
	cin>>s;
  	if(s=="ABC"){
    	cout<<"ARC";
    }
  	else{
    	cout<<"ABC";
    }
	
	return 0;
}

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

void solve(void)
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];
    vector<int> a(n);
    a[0] = b[0];
    a[n - 1] = b[n - 2];
    for (int i = 1; i < n - 1; ++i)
        a[i] = min(b[i - 1], b[i]);
    int ans = accumulate(a.begin(), a.end(), 0);
    cout << ans << endl;
}
int main(void) { solve(); }


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(int K, string S) {
  if (S.length() <= K) {
    cout << S << endl;
    return;
  } else {
    cout << S.substr(0, K) << "..." << endl;
    return;
  }
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  int K;
  string S;
  cin >> K >> S;

  solve(K, S);

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
int prime[123457*2];
bool is_prime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return n!=1;
}
int main(){
	prime[1]=0;
	for(int i=2;i<=123456*2;i++){
		if(is_prime(i)){
			prime[i]=prime[i-1]+1;
		}else prime[i]=prime[i-1];
	}
	int n;
	while(cin>>n,n){
		cout<<prime[2*n]-prime[n]<<endl;
	}
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  if(sum%(n*(n+1)/2)!=0) {
    cout << "NO" << endl;
    return 0;
  }
  ll k = sum/(n*(n+1)/2);
  vector<ll> b(n);
  rep(i,n) b[i]=a[(i+1)%n]-a[i%n];
  ll c=0;
  rep(i,n) {
    b[i]-=k;
    if(b[i]>0||(-b[i])%n!=0) {
      cout << "NO" << endl;
      return 0;
    }
    c+=-b[i]/n;
  }
  if(c==k) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'

int main() {

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

  // ll t; cin>>t; 
   {
    ll n;
    cin>>n;

    if(n%10==3)
    cout<<"bon";

    else
    if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
    cout<<"pon";

    else
    cout<<"hon";
   }

  


    return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[1000001], invf[1000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(x<y) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
	ll n, h, d; cin>>n>>h>>d;
	ll s[2000020];
	fac(n);
	s[0]=0;
	for(int i=1; i<=n; i++) s[i]=(s[i-1]+f[i])%MOD;
	ll dp[2000020];
	dp[0]=f[n];
	ll dps[2000020];
	dps[0]=0, dps[1]=dp[0];
	for(int i=1; i<h; i++){
		dp[i]=(dps[i]-dps[max(0ll, i-d)]+MOD)*s[n]%MOD;
		dps[i+1]=(dps[i]+dp[i])%MOD;
	}
	cout<<(dps[h]-dps[h-d]+MOD)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 35968
n,m = map(int, input().split())

def get_div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

divs = get_div(m)
divs.reverse()
mx = m//n

for d in divs:
    if d<=mx:
        print(d)
        exit()

Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1000000000

int main(){
	int n;cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;i++){cin>>d[i];}
	sort(d.begin(),d.end());

	cout<<d[n/2]-d[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int i,n,k,a[55],ans=0;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
  for(i=0 ;i<k ;i++){
    ans=ans+a[i];
   }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B;
    string U, S, T;
    cin >> S >> T >> A >> B >> U;
    if (U == S)
        A--;
    else
        B--;
    cout << A << " " << B << endl;
    return 0;
};

Measured memory_bytes: 256
n = int(input())
s = input()

ab = ['A', 'B', 'C', 'D', 'E', 'F', 'G',
      'H', 'I', 'J', 'K', 'L', 'M', 'N',
      'O', 'P', 'Q', 'R', 'S', 'T', 'U',
      'V', 'W', 'X', 'Y', 'Z']

ret = ''
for ss in s:
    ret = ret + ab[(ab.index(ss) + n) % 26]
print(ret)

Measured memory_bytes: 3064