akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std; 
inline int read(){
	int sum=0,fushu=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') fushu=-fushu;
		c=getchar();
	}
	while(isdigit(c)){
		sum=sum*10+(c^48);
		c=getchar();
	}
	return sum*fushu;
}
void write(int x){//只能输出非负整数！！！比赛的时候看清楚！！！ 
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
inline void writeln(int x){
	write(x);
	putchar('\n');
}
int const maxn=1e5+5;
int n,m,father[maxn];
int find(int x){
	if(father[x]!=x) father[x]=find(father[x]);
	return father[x];
}
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++)
	  father[i]=i;
	for(int i=1;i<=m;i++){
		int x=read(),y=read(),z=read();
	    int r1=find(x),r2=find(y);
	    if(r1!=r2) father[r1]=r2; 
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	  if(find(i)==i) ans++;
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1152
# ord を hash にすると、ハックされにくくなるが、1/MODくらいの確率で0を引く。
class RollingHash:

    __slots__ = ["root", "mod", "hs", "pw"]

    def __init__(self, string, root, mod):
        self.root = root
        self.mod = mod
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            self.hs[i + 1] = (self.hs[i] * self.root + ord(string[i])) % self.mod
            self.pw[i + 1] = self.pw[i] * self.root % self.mod

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % self.mod

    def __getitem__(self, index):
        "RH[l:r] is equivalent to RH.get_hash(l, r)"
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0


# 正直、RollingHashと速度はあまり変わらない。なんで？
RHMOD = (1 << 61) - 1
class RollingHashMOD61:
    """
    MOD == 2 ** 61 - 1
    参考: https://qiita.com/keymoon/items/11fac5627672a6d6a9f6
    """

    __slots__ = ["root", "hs", "pw"]

    def __init__(self, string, root):
        self.root = root
        self.hs = [0] * (len(string) + 1)
        self.pw = [1] * (len(string) + 1)
        for i in range(len(string)):
            tmp = self.hs[i] * self.root + ord(string[i])
            self.hs[i + 1] = (tmp >> 61) + (tmp & RHMOD)
            tmp = self.pw[i] * self.root
            self.pw[i + 1] = (tmp >> 61) + (tmp & RHMOD)

    def get_hash(self, l, r):
        "get the hash of s[l:r] (0 <= l <= r <= len(s))"
        return (self.hs[r] - self.hs[l] * self.pw[r - l]) % RHMOD

    def __getitem__(self, index):
        if isinstance(index, slice):
            return self.get_hash(index.start, index.stop)
        else:
            return 0
        
def whosaysapun():
    import random 
    N = int(input())
    S = input()

    MOD = 2 ** 61 - 1
    root = random.randint(1000, 2000)

    rh = RollingHashMOD61(S, root)

    ok = 0
    ng = N
    while ng - ok > 1:
        mid = (ok + ng) // 2
        hashes = dict()
        flg = False
        for i in range(N - mid + 1):
            hashofsub = rh[i:i+mid]
            if hashofsub in hashes:
                if i >= hashes[hashofsub] + mid:
                    flg = True
                    break
            else:
                hashes[hashofsub] = i
        
        if flg:
            ok = mid
        else:
            ng = mid

    print(ok)

# mods = [
#     6435805146278881223, 
#     7427449777901196481, 
#     1638624619723308673, 
#     2288514702228148349,
#     3583235820855855041
# ]

    

if __name__ == "__main__":
    whosaysapun()


Measured memory_bytes: 84828
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pdi = pair<double, int>;

int N, K;
vector<int> h;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		int tmph;
		cin >> tmph;
		h.push_back(tmph);
	}
	sort(ALL(h));
	int beauty = 1000000001;
	for (int i = 0; i <= N - K; i++)
	{
		beauty = min(beauty, h[K - 1 + i] - h[i]);
	}
	cout << beauty << endl;
	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> used(100010), tp;
vector<vector<ll>> G(100010);
/*
void dfs(ll v){
    if(used[v]) return;
    used[v] = 1;
    for(auto& u:G[v]){
        dfs(u);
    }
    tp.push_back(v);
}*/

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> rc(N),deg(N);
    ll a,b;
    rep(i,N-1+M){
        cin >> a >> b;
        a--;b--;
        rc[b]++;
        G[a].push_back(b); 
        deg[b]++;
    }
    ll root;
    rep(i,N){
        if(rc[i] == 0){
            root = i;
            break;
        }
    }
    queue<ll> que;
    vector<ll> par(N,-1);
    que.push(root);
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            deg[u]--;
            if(deg[u] == 0){
                par[u] = v;
                que.push(u);
            }
        }
    }
    rep(i,N){
        cout << par[i]+1 << endl;
    }
    /*dfs(root);
    vector<ll> v(N);
    rep(i,N){
        v[tp[i]] = i;
    }
    //PR(v,N);
    vector<ll> ans(N,-1);
    rep(i,N){
        for(auto& u:G[i]){
            if(v[i] > v[u]){
                //cout << u+ << endl;
                ans[i] = u;
                break;
            }
        }
    }
    rep(i,N){
        cout << ans[i]+1 << endl;
    }
    /*queue<ll> que;
    que.push(root);
    prev[root] = -1;
    used[root] = 1;*/
    /*
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            if(used[u] != 0){
                G[prev[u]].erase(lower_bound(G[prev[u]].begin(),G[prev[u]].end(),u));
                prev[u] = v;
                que.push(u);
                continue;
            }
            used[u] = 1;
            prev[u] = v;
            que.push(u);
        }
    }*/
    /*rep(i,N){
        cout << prev[i]+1 << endl;
    }*/
}

Measured memory_bytes: 11876
#include <iostream>
#include <map>
#include <utility>
using namespace std;

const int MAX_N = 2 * 100000 + 5;

class uni{
public:

	int par[MAX_N]; // 親
	int rank[MAX_N]; // 木の深さ 

	uni(int n){
		for(int i = 0; i < n; i++){
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x){
		if (par[x] == x){
			return x;
		} else {
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		} else {
			par[y] = x;
			if(rank[x] == rank[y])
				rank[x]++;
		}
	}

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

void solve(){
	int N, K, L;
	map<pair<int, int>,int> count;
	cin >> N >> K >> L;

	uni a(N);
	uni b(N);

	for(int i = 0; i < K; i++){
		int p,q;
		cin >> p >> q;
		a.unite(p-1, q-1);
	}

	for(int i = 0; i < L; i++){
		int p,q;
		cin >> p >> q;
		b.unite(p-1, q-1);
	}

	for(int i = 0; i < N; i++){
		count[make_pair(a.find(i), b.find(i))]++;
	}

	for(int i = 0; i < N; i++){
		cout<< count[make_pair(a.find(i), b.find(i))];
		if(i != N-1){
			cout << " ";
		}else{
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 15232
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
using namespace std;
typedef long long int ll;

int main() {
    ll N,H,W;
    scanf("%lld%lld%lld",&N,&H,&W);
    ll A[N];
    ll B[N];
    for (ll i=0; i<N;i++){
        scanf("%lld%lld",&A[i],&B[i]);
    }
    ll ans=0;
    for (ll i=0;i<N;i++){
        if (A[i] >= H && B[i] >= W) ans += 1;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<vector<vector<vector<ll>>>> vvvvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;

int main() {
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << 7 <<endl;
  }
  if(S == "SAT"){
    cout << 1 <<endl;
  }
  if(S == "MON"){
    cout << 6 <<endl;
  }  
  if(S == "TUE"){
    cout << 5 <<endl;
  }
  if(S == "WED"){
    cout << 4 <<endl;
  }
   if(S == "THU"){
    cout << 3 <<endl;
  }
   if(S == "FRI"){
    cout << 2 <<endl;
  }
}


Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct vec
{
    double x, y;
    vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
    vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
    vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
    vec operator * (const double& t) const {return vec(x*t, y*t);}
    vec operator / (const double& t) const {return vec(x/t, y/t);}
    const double len2 () const {return x*x + y*y;}
    const double len () const {return sqrt(len2());}
    vec norm() const {return *this/len();}
    vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
    double t = crs(p1-p0, v1) / crs(v0, v1);
    return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
    return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[100005];

int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%lf%lf", &pot[i].x, &pot[i].y);
    random_shuffle(pot+1, pot+n+1);
    vec o;
    double r2 = 0;
    for(int i=1; i<=n; i++)
    {
        if((pot[i]-o).len2() > r2)
        {
            o = pot[i], r2 = 0;
            for(int j=1; j<i; j++)
            {
                if((pot[j]-o).len2() > r2)
                {
                    o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                    for(int k=1; k<j; k++)
                    {
                        if((pot[k]-o).len2() > r2)
                        {
                            o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf", sqrt(r2));
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int ord2(ll n){
    int res=0;
    while(n%2==0){
        res++;
        n /= 2;
    }
    return res;
}

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b && b==c && a%2==0) cout << -1 << endl;
    else if(a==b && b==c && a%2==1) cout << 0 << endl;
    else cout << min(ord2(a+b),min(ord2(b+c),ord2(c+a))) << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    string s; cin>>s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    int sa,sb;
    cin >> s;
    sa = 10*(s[0]-'0')+s[1]-'0';
    sb = 10*(s[2]-'0')+s[3]-'0';
    if( 0<sa&&sa<=12){
        if( 0<sb&&sb<=12){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }
    }else{ 
        if( 0<sb&&sb<=12){
            cout<<"YYMM"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<deque>
#include<string>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;

int main(){
	long long int x, y; cin >> x >> y;
	long long int count = 0;
	for (long long int i = 1;;) {
		if (x*i <= y) {
			i *= 2;
			count++;
		}
		else { cout << count << endl; break; }
	}

	return 0;
}

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

int main(){
  int a,b,n;
  cin >> a >> b >> n;
  for(int i=0;i<n;i++){
    if(i%2==0){
      a=a/2;
      b+=a;
    }
    else{
      b/=2;
      a+=b;
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,p[N<<1];
double ans;
int main(){
	int i,j;
	scanf("%d",&n);n<<=1;
	for(i=0;i<n;++i) scanf("%d",&p[i]);
	sort(p,p+n);
	for(i=1;i<n;++i){
		ans+=(double)p[i]*(double)i/(double)(n-1);
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include <functional>
#include<cmath>
#include<map>
using namespace std;


int main(){
	int n;
	while(cin>>n,n){
		while(n--){
	int a,b,c,d,e,f,g,h;
	cin>>a>>b>>c>>d>>e>>f>>g>>h;
	int w=0,x=0,y=0,z=0;
	w=(a*e)-(b*f)-(c*g)-(d*h);
	x=b*e+a*f+c*h-d*g;
	y=a*g+c*e+d*f-b*h;
	z=a*h+d*e+b*g-c*f;
	cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
	}
	}
}

Measured memory_bytes: 1160
// Problem : Multiple Clocks
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc070_c
// Memory Limit : 262 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define lll __int128;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
#define isin(mp, key) ((mp).find(key) != (mp).end())
#define pb push_back
#define fi first
#define se second
#define tos(x) string(1, x)
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 2000000003
#define INFL 2000000000000000003ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testc   \
    int tcc;    \
    cin >> tcc; \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
#define int ll

signed main() {
	fast_io;
	int n; cin>>n; vl v(n); in(v);
	int l=1;
	lp(i,0,n) l=lcm(l,v[i]);
	cout<<l;
}
// code!=think
// least efficient code to get ac


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

void foutput(int aa, int bb) {
	for (int i = 0; i < aa; i++){
		if (i == 0 || i == aa - 1) {
			for (int n = 0; n < bb; n++){
				cout << "#";
			}
		}else {
			cout << "#";
			for (int m = 0; m < bb-2; m++){
				cout << ".";
			}
			cout << "#";
		}
		cout << endl;
	}
}

int main() {
	int frame[2][10000];
	int a, b ,length;
	for (int i = 0; ; i++){
		cin >> a >> b;
		if (a==0||b==0){
			length = i;
			break;
		}
		frame[0][i] = a;
		frame[1][i] = b;
	}
	for (int i = 0; i < length; i++){
		foutput(frame[0][i],frame[1][i]);
		cout << endl;
	}
	cin >> length;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    lli n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k)
    {
        cout<<n*x<<endl;
    }
    else
    {
        cout<<k*x+(n-k)*y<<endl;
    }
}


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

int main(){

    ll a,b;
    cin >> a >> b;

    if(a%2==0&&b%2==0){
        if(((b-1-a+1)/2)%2==1){
            cout << (1^b) << endl;
        }else{
            cout << b << endl;
        }
    }else if(a%2==0){
        if(((b-a+1)/2)%2==1){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }else if(b%2==0){
        if(((b-1-(a+1)+1)/2)%2==1){
            cout << (1^a^b) << endl;
        }else{
            cout << (a^b) << endl;
        }
    }else{
        if(((b-(a+1)+1)/2)%2==1){
            cout << (1^a) << endl;
        }else{
            cout << (a) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
//Be Name Khoda
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma optimize O3
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int LL;
typedef LL ll;
typedef long double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=1e5+5,LG=32,SM=600+5,inf=1e18+5;
ll mod=1e9+7;


ll n,m,k;
ll rfog[M];
 
void fog(const ll f[M],const ll g[M])
{
    For(i,0,n)
        rfog[i]=f[g[i]];
}

void fil(ll a[M],const ll b[M])
{
    For(i,0,n)
        a[i]=b[i];       
}

ll jay[M];
ll x[M];
ll res[M];
ll z[M];
ll z2[M];

int main()
{
    cin >> n;
    For(i,0,n)
        cin >> x[i];
    cin >> m >> k;
    iota(jay,jay+n-1,0);
    For(i,0,m)
    {
        ll x;
        cin >> x;
        swap(jay[x-2],jay[x-1]);
    }
    n--;
    //For(i,0,n) { ER(i); ER(jay[i]); }
    iota(res,res+n,0);
    /*For(i,0,k)
    {
        fog(res,jay);
        fil(res,rfog);
        For(i,0,n) { cout << res[i] << ' '; }
        cout << '\n';
    }*/
    // power jaygasht
    {
        iota(res,res+n,0);
        fil(z,jay);
        For(i,0,64)
        {
            if ((k>>i)&1)
            {
                fog(res,z);
                fil(res,rfog);
            }
            fog(z,z);
            fil(z,rfog);
        }
    }//*/
    n++;
    ll pos=x[0];
    cout << pos << '\n';
    For(i,1,n)
    {
        pos+=x[res[i-1]+1]-x[res[i-1]];
        cout << pos << '\n';
    }
}    


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


int gcd(int a, int b) {
    if (b==0) return a;
    else gcd(b, a%b);
}


int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i) cin >> A[i];
    int ans = A[0];
    for (int i = 1;i < A.size(); ++i) {
        ans = gcd(ans, A[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var l = 0
    var u = N

    println(0)
    System.out.flush()
    val s = readLine()!!
    if (s == "Vacant") {
        return
    }

    while(true) {
        val c = (l + u) / 2
        println(c)
        System.out.flush()

        val t = readLine()!!

        when {
            t == "Vacant" -> return
            (s == t && c % 2 == 0) || (s != t && c % 2 != 0) -> l = c + 1
            else -> u = c
        }
    }
}


Measured memory_bytes: 32224
A = []
for i in range(5):
  str = input()
  A.append( int(str) )

min = 9
num = 0
for i in range(len(A)):
    if min > A[i]%10 and A[i] % 10 != 0:
      min = A[i]%10
      num = i
      
ans = 0
for i in range(5):
  if i != num:
    ans = ans + int((A[i]+9)/10) * 10
ans = ans + A[num]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int, int, int> Tiii;

int main() {
    int H, W; cin >> H >> W;
    vector<string> grids(H);
    for (int i = 0; i < H; i++) cin >> grids[i];
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grids[i][j] == '.') {
                vector<vector<bool>> added(H, vector<bool>(W, false));
                queue<Tiii> q;
                q.push(Tiii(i, j, 0));
                added[i][j] = true;

                while (!q.empty()) {
                    int h, w, d; tie(h, w, d) = q.front();
                    q.pop();
                    ans = max(ans, d);
                    if (h != 0 && grids[h-1][w] == '.' && !added[h-1][w]) {
                        q.push(Tiii(h-1, w, d+1));
                        added[h-1][w] = true;
                    }
                    if (h != H-1 && grids[h+1][w] == '.' && !added[h+1][w]) {
                        q.push(Tiii(h+1, w, d+1));
                        added[h+1][w] = true;
                    }
                    if (w != 0 && grids[h][w-1] == '.' &&!added[h][w-1]) {
                        q.push(Tiii(h, w-1, d+1));
                        added[h][w-1] = true;
                    }
                    if (w != W-1 && grids[h][w+1] == '.' && !added[h][w+1]) {
                        q.push(Tiii(h, w+1, d+1));
                        added[h][w+1] = true;
                    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ios>
#include <iomanip>

using namespace std;
typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    if (N >= M)
    {
        cout << 0;
        return 0;
    }
    vector<int> X;
    int temp;
    for (int i = 0; i < M; i++)
    {
        cin >> temp;
        X.push_back(temp);
    }
    sort(X.begin(), X.end());
    vector<int> list;
    ll ans = 0;
    for (int i = 0; i < M - 1; i++)
    {
        list.push_back(X[i + 1] - X[i]);
        ans += X[i + 1] - X[i];
    }
    sort(list.begin(), list.end());
    for (int i = 0; i < N - 1; i++)
    {
        ans -= list[M - 2 - i];
    }
    cout << ans;
    // system("pause");
}

Measured memory_bytes: 1400
// Author: Wenxing Mei
//   File: c.cpp
//   Date: 2019-04-05 10:01
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define per(i, b, a) for (int i = (int)b; i >= (int)a; --i)
#define repv(ele, cont) for (auto &ele : cont)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<ll> vll;
// END OF TEMPLATE

int n, a, b, c;
int l[1000];

int dfs(int idx, int la, int lb, int lc, int gc) {
    if (idx == n) {
        if (!la || !lb || !lc) return 1e9;
        return abs(a - la) + abs(b - lb) + abs(c - lc) + 10 * (gc - 3);
    }
    int ret = 1e9;
    ret = min(ret, dfs(idx + 1, la + l[idx], lb, lc, gc + 1));
    ret = min(ret, dfs(idx + 1, la, lb + l[idx], lc, gc + 1));
    ret = min(ret, dfs(idx + 1, la, lb, lc + l[idx], gc + 1));
    ret = min(ret, dfs(idx + 1, la, lb, lc, gc));
    return ret;
};

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    cin >> n >> a >> b >> c;
    rep(i, 0, n) cin >> l[i];
    cout << dfs(0, 0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String result = "NO";
		int[] a = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
		int count1 = 0;
		int count2 = 0;
		for(int i : a) {
			if(i == 5) {
				count1++;
			} else if (i == 7) {
				count2++;
			} 
		}
		if (count1 == 2 && count2 == 1)	result = "YES";
		System.out.println(result);
		}
		
	}




Measured memory_bytes: 35688
N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])

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

int main() {
	int s;
	cin >> s;
	int s1 = s,ns = 0;
	while(s1 > 0)
	{
		ns += s1 % 10;
		s1 /= 10;
	}
	string k = "No";
	if(s % ns == 0)
	{
		k = "Yes";
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [a,b]=tss(2)
  let c=Number(a+b)
  to(Number.isInteger(Math.sqrt(c))?'Yes':'No')
}
main()


Measured memory_bytes: 7372
#include <stdio.h>
#define M 10000
#define NIL -1

typedef struct{
  int p,l,r;
}Node;

Node T[M];
int n;

void preOrder(int u)
{
  if(u == NIL)return;
  printf(" %d",u);
  preOrder(T[u].l);
  preOrder(T[u].r);
}

void inOrder(int u){
  if(u == NIL)return;
  inOrder(T[u].l);
  printf(" %d", u);
  inOrder(T[u].r);
}
void postOrder(int u){
  if(u == NIL)return;
  postOrder(T[u].l);
  postOrder(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i = 0; i <n;i++)
    {
      T[i].p =NIL;
    }
  for(i = 0;i<n;i++)
    {
      scanf("%d %d %d",&v,&l,&r);
      T[v].l = l;
      T[v].r = r;
      if(l != NIL) T[l].p = v;
      if(r != NIL) T[r].p = v;
    }
  for(i = 0; i < n;i++)
    {
    if(T[i].p == NIL)root = i;
    }
  printf("Preorder\n");
  preOrder(root);
  printf("\n");
  printf("Inorder\n");
  inOrder(root);
  printf("\n");
  printf("Postorder\n");
  postOrder(root);
  printf("\n");


  return 0;
}


  
  

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
     int a,b;
     cin >> a >> b;
     cout << max(a+b, max(a-b, a*b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  auto solve = [&]() -> int {
    int head = 0, tail = N - 1;
    int cost = 0;
    for (;;) {
      while (head < tail && S[head] == 'R') {
        ++head;
      }
      if (head == tail) break;
      while (tail > head && S[tail] == 'W') {
        --tail;
      }
      if (head == tail) break;
      assert(head < tail);
      swap(S[head], S[tail]);
      ++cost;
      DEBUG(cost, S);
    }

    return cost;
  };
  cout << solve() << endl;
}


Measured memory_bytes: 3736
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	//#define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	string s; cin >> s;
	int idx = 0;
	int64_t ans = 0;
	for (int i = 0; i < int(s.size()); ++i) {
		if (s[i] == 'A') {
			++idx;
		} else if (s[i] == 'B' && s[i+1] == 'C') {
			ans += idx;
			++i;
		} else {
			idx = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	for sc.Scan() {
		inputs := strings.Split(sc.Text(), " ")
		mid, _ := strconv.Atoi(inputs[0])
		end, _ := strconv.Atoi(inputs[1])
		re, _ := strconv.Atoi(inputs[2])

		if mid == -1 && end == -1 && re == -1 {
			break
		} else if mid == -1 || end == -1 {
			fmt.Println("F")
		} else if mid+end >= 80 {
			fmt.Println("A")
		} else if mid+end >= 65 {
			fmt.Println("B")
		} else if mid+end >= 50 {
			fmt.Println("C")
		} else if mid+end >= 30 {
			if re >= 50 {
				fmt.Println("C")
			} else {
				fmt.Println("D")
			}
		} else {
			fmt.Println("F")
		}
	}
}



Measured memory_bytes: 1096
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int L[2222], R[2222], tmp[2222], n;

string A, B;

bool cmp(int x, int y) {
    return L[x] < L[y];
}

int calc(int x) {
    L[n] = x;
    int t = 0;
    for(int i = 0; i < n; i++) if(B[n + x + i] != A[i]) tmp[t++] = i;
    tmp[t++] = n;
    sort(tmp, tmp + t, cmp);
    int mx = x, ans = max(0 - L[tmp[0]], 0) * 2 + x;
    for(int i = 1; i < t; i++) {
        mx = max(mx, R[tmp[i - 1]]);
        ans = min(ans, (max(0 - L[tmp[i]], 0) * 2 + max(mx - x, 0) * 2) + x);
    }
    return ans + t - 1;
}

int Solve() {
    int ans = 1e9;
    for(int i = 0; i < n; i++) {
        for(L[i] = 0; ; L[i]--) if(B[L[i] + i + n] == '1') break;
        for(R[i] = 0; ; R[i]++) if(B[R[i] + i + n] == '1') break;
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) if(B[n + i + j] == '1') L[j] = i;
        for(int j = 0; j < n; j++) while(B[n + j + R[j]] != '1') R[j]++;
        ans = min(ans, calc(i));
    }
    return ans;
}

int main() {
    cin >> A >> B;
    n = A.size();
    int flag = 0;
    for(int i = 0; i < n; i++) if(B[i] == '1') flag = 1;
    if(!flag) {
        for(int i = 0; i < n; i++) if(A[i] == '1') {
            puts("-1");
            return 0;
        }
        puts("0");
        return 0;
    }
    B = B + B + B + B;
    int ans = Solve();
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    printf("%d\n", min(ans, Solve()));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define arrAll(x, n) (x, x + n)
#define trav(a, x) for (auto &a : x)
#define rall(x) x.rbegin(), x.rend()
#define endl "\n"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int mod = 1e9 + 7;
const int N = 1e6 + 5;

void solve() {
    string s, t; cin >> s >> t;
    int s_len = s.size(), t_len = t.size();
    int ans = INT_MAX;
    for (int i = 0; i < s_len - t_len + 1; i++) {
        int remchar = 0;
        for (int j = 0; j < t_len; j++) {
            if (t[j] != s[i+j])
                remchar++;
        }
        ans = min(ans, remchar);
    }
    cout << ans << endl;
    return;
}

int main() {
  
    FIO
    solve();
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
AB = np.array(sys.stdin.read().split(), dtype=np.int64)

T = AB.cumsum()[::2] % 86400

# 10801個の連番の集計結果の最大値

T_cnt = np.bincount(T, minlength=86400)

T_cnt = np.concatenate([T_cnt]*3)

arr = T_cnt.cumsum()
answer = (arr[10801:] - arr[:-10801]).max()
print(answer)

Measured memory_bytes: 32352
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <complex>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)
typedef vector<int> VI;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
#define X real()
#define Y imag()

void print(P p) {
  cout << setprecision(8) << p.X << " " << setprecision(8) << p.Y << endl;
}

void koch(int n, P p1, P p2) {
  if (n == 0) return;
  P s = p1 + (p2-p1)*(1/3.0);
  P t = p1 + (p2-p1)*(2/3.0);
  P st = t - s;
  P u = s + st * polar(1.0, M_PI / 3);

  koch(n-1, p1, s);
  print(s);
  koch(n-1, s, u);
  print(u);
  koch(n-1, u, t);
  print(t);
  koch(n-1, t, p2);
}

int main() {
	int n;
  cin >> n;
  P p1(0,0);
  P p2(100,0);
  print(p1);
  koch(n, p1, p2);
  print(p2);

  return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> table(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> table.at(i).at(j);
    }
  }
  
  vector<bool> flagH(H,false);
  vector<bool> flagW(W,false);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(table.at(i).at(j)=='#'){
        flagH.at(i)=true;
        flagW.at(j)=true;
      }
    }
  }
  
    for(int i=0;i<H;i++){
      if(flagH.at(i)){
        for(int j=0;j<W;j++){
          if(flagW.at(j))
            cout << table.at(i).at(j);
        }
      }
      cout << endl;
    } 
   
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int[] lasts = new int[26+1];
        Arrays.fill(lasts, 1);
        int[] c = new int[26+1];
        for(int i = 1;i<=26;i++){
            c[i] = sc.nextInt();
        }

        int[][] s = new int[d+1][26+1];
        for(int i = 1;i<=d;i++){
            int maxx = 1;
            int va = -999999;
            for(int j = 1;j<=26;j++){ 
                s[i][j] = sc.nextInt();
                if(va < s[i][j] / lasts[j]) {
                    maxx = j;
                    va = s[i][j] / lasts[j];
                }
            }
            System.out.println(maxx);
            lasts[maxx] = i;
        }
    }
}


Measured memory_bytes: 46560
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int a[100005];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int l=2,r=2;
	for(int i=n;i>=1;i--)
	{
		int mn,mx;
		if(l%a[i]==0)mn=l/a[i];
		else mn=l/a[i]+1;
		mx=r/a[i];
		if(mn>mx)return puts("-1"),0;
		l=mn*a[i];r=(mx+1)*a[i]-1;
	}
	cout<<l<<' '<<r<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(i) for i in input().split()]
mn_list = []
sunuke = a[0]
araiguma = sum(a[1:])
res = abs(sunuke-araiguma)
for i in range(1,n-1):
    sunuke += a[i]
    araiguma -= a[i]
    res = min(res,abs(sunuke-araiguma))
print(res)

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

int main () {
    int N;
    int X;
    scanf("%d", &N);
    scanf("%d", &X);

    int *L = malloc((N + 1) * sizeof(int));
    int ans = 0;
    int *D = malloc((N + 1) * sizeof(int));
    D[1] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &L[i]);
        if (i >= 2) {
            D[i] += D[i-1] + L[i-1];
            if (D[i] > X){
                ans = i - 1;
                printf("%d\n", ans);
                return 0;
            }
        }
    }
    if ((D[N] + L[N]) > X)
        ans = N;
    else
        ans = N + 1;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = 1e9+7;
const ll INF = (ll)1e18+1;

int n, m;
vector<int> a(100001);

void solve(ll &ans, int m)
{
    ll ps=0;
    for(int i=0; i<n; i++)
    {
        ll c=ps+a[i];
        if(i%2==m)
        {
            if(c<=0)
            {
                ps=1;
                ans+=abs(1-c);
            }
            else
            {
                ps+=a[i];
            }
        }
        else
        {
            if(c>=0)
            {
                ps=-1;
                ans+=abs(-1-c);
            }
            else
            {
                ps+=a[i];
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("A.txt", "r", stdin);
    #endif
    cin >> n;
    ll ps=0, ans=0;
    for(int i=0; i<n; i++)
        cin >> a[i];
    ll x=0, y=0;
    solve(x, 1);
    solve(y, 0);
    cout << min(x, y);
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        public static long C(long n, long k)
        {
            long bunbo = 1;
            long bunsi = 1;
            for (long i = n - k; i <= n; i++)
                bunsi *= i;
            for (long i = 1; i <= n - k; i++)
                bunbo *= i;
            return bunsi / bunbo;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var input = Reads();
            var n = input[0];
            var k = input[1];
            var s = input[2];
            if (s - (n - k) <= 0)
            {
                for (int i = 1; i <= n; i++)
                {
                    if (i <= k) Console.Write("{0} ", s);
                    else if (i <= n) Console.Write("{0} ",s+1);
                }
            }
            else
            {
                for (int i = 1; i <= n; i++)
                {
                    if (i <= k) Console.Write("{0} ", s);
                    else if (i < n) Console.Write("1 ");
                    else Console.Write(1);
                }
            }


      


            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 17868
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;
ll myp(ll a, ll b) {
  if (b == 0) { return 1; }
  if (b % 2 == 1) {
	  return a * myp(a, b - 1) % mod;
	} else {
	  ll c = myp(a, b / 2);
	  return c * c % mod;
	}
}

ll inv(ll a) {
  return myp(a, mod - 2);
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector <ll> a(n);
  REP(i, n) {
	cin >> a[i];
  }
  sort(all(a));
  vector <ll> fact(n + 1, 1);
  REP1(i, n) {
	fact[i] = fact[i - 1] * i % mod;
  }
  ll ans = 0;
  for (int j = k - 1; j < n; j++) {
	  ll tmp = fact[j] * inv(fact[k - 1]) % mod;
	  tmp = tmp * inv(fact[j - k + 1]) % mod;
	  tmp = tmp * a[j] % mod;
	  ans = (ans + tmp) % mod;
	}
  for (int j = 0; j <= n - k; j++) {
	  ll tmp = fact[n - j - 1] * inv(fact[k - 1]) % mod;
	  tmp = tmp * inv(fact[n - j - k]) % mod;
	  tmp = tmp * a[j] % mod;
	  ans = (ans - tmp + mod) % mod;
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
<?php
[$H, $W, $M] = fscanf(STDIN, "%d%d%d");

$h_list = array_fill(1,$H,0);
$w_list = array_fill(1,$W,0);
$all_list = array_fill(1,$H,[]);

for($i=0;$i<$M;$i++){
    [$h, $w] = fscanf(STDIN, "%d%d");
    $h_list[$h]++;
    $w_list[$w]++;
    $all_list[$h][$w] = 1;
}

$h_max = 0;
$h_max_list = [];
foreach($h_list as $key => $value){
    if($value > $h_max){
        $h_max_list = [];
        $h_max_list[] = $key;
        $h_max = $value;
    }elseif($value === $h_max){
        $h_max_list[] = $key;
    }
}

$w_max = 0;
$w_max_list = [];
foreach($w_list as $key => $value){
    if($value > $w_max){
        $w_max_list = [];
        $w_max_list[] = $key;
        $w_max = $value;
    }elseif($value === $w_max){
        $w_max_list[] = $key;
    }
}

foreach($h_max_list as $hvalue){
    foreach($w_max_list as $wvalue){
        if(!isset($all_list[$hvalue][$wvalue])){
            echo $w_max + $h_max;
            exit;
        }
    }
}
echo $w_max + $h_max - 1;

Measured memory_bytes: 181400
#include<iostream>
using namespace std;
int main(){
    int N, K, ans=0;

    cin >> N >> K;
    int A[N];

    for(int i=0; i< N ; i++){
        cin >> A[i];
    }

    if ((N -1) % (K - 1) == 0 ){
        ans = (N - 1) / (K - 1);
    }else {
        ans = (N - 1) / (K - 1) + 1;
    }

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

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

int main()
{
    char s[11];
    int a,i=1;

    scanf("%s",s);

    a=abs(753-((s[0]-48)*100+(s[1]-48)*10+(s[2]-48)));

    while(s[i+2]!='\0'){
        if(a>abs(753-((s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48)))){
            a=abs(753-((s[i]-48)*100+(s[i+1]-48)*10+(s[i+2]-48)));
        }
        i++;
    }

    printf("%d\n",a);

    return 0;
}

Measured memory_bytes: 128
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	string s;
	scans(s);
	printf("%d\n", 700 + ((s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o')) * 100);
	
	Please AC;
}


Measured memory_bytes: 888