akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

// verify : https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_A
template<class Monoid> struct SegmentTree {
private:
    using Func = std::function<Monoid(Monoid, Monoid)>;
    Func F;
    Monoid UNITY;
    int n;
    std::vector<Monoid> node;
public:
    SegmentTree() {}


    SegmentTree(int m, const Monoid &val, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        n = 1; while (n < m) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        if (val != UNITY) {
            for (int i = 0; i < m; i++) node[i] = val;
            build();
        }
    }

    SegmentTree(const std::vector<Monoid>& v, const Func f, const Monoid &unity) {
        F = f;
        UNITY = unity;
        int sz = v.size();
        n = 1; while (n < sz) n <<= 1;
        node.resize(n * 2 - 1, UNITY);
        for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
        build();
    }

    // 最後に build が必要
    void set(int k, const Monoid &x) {
        node[n + k - 1] = x;
    }

    void build() {
        for (int i = n - 2; i >= 0; i--) node[i] = F(node[2 * i + 1], node[2 * i + 2]);
    }

    void update_query(int x, const Monoid &val) {
        if (x >= n || x < 0) return;
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) >> 1;
            node[x] = F(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    // [a,b)
    Monoid get_query(int a, int b) {
        Monoid L = UNITY, R = UNITY;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) L = F(L, node[a++ - 1]);
            if (b & 1) R = F(node[--b - 1], R);
        }
        return F(L, R);
    }

    Monoid operator[](int x)const {
        return node[n + x - 1];
    }

    int size() {
        return n;
    }

    void print() {
        for (int i = 0; i < n; i++) {
            std::cout << i << "\t: " << node[n + i - 1] << std::endl;
        }
    }
};

int main() {
    constexpr int INF = 1e9 + 6;
    int n, m; cin >> n >> m;
    string s; cin >> s;
    SegmentTree<int> seg(n + 1, INF, [](int a, int b) {return min(a, b); }, INF);
    seg.update_query(n, 0);
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '1') continue;
        int t = seg.get_query(i + 1, min(n + 1, i + m + 1));
        if (t == INF) break;
        seg.update_query(i, t + 1);
    }
    if (seg[0] == INF) {
        puts("-1");
        return 0;
    }
    vector<int> ans;
    int now = seg[0];
    int dist = 1;
    for (int i = 1; i <= n; i++) {
        if (seg[i] == now - 1) {
            ans.push_back(dist);
            now--;
            dist = 1;
        }
        else {
            dist++;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2168
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fac[n]*finv[r]*finv[n-r]%p

def perm(n,r,p):
  if (r < 0) or (n < r):
    return 0
  return fac[n]*finv[n-r]%p

N = 100000
MOD = pow(10,9)+7

fac = [-1]*(N+1); fac[0] = 1; fac[1] = 1 #階乗
finv = [-1]*(N+1); finv[0] = 1; finv[1] = 1 #階乗の逆元
inv = [-1]*(N+1); inv[0] = 0; inv[1] = 1 #逆元
for i in range(2,N+1):
  fac[i] = fac[i-1]*i%MOD
  inv[i] = MOD - inv[MOD%i]*(MOD//i)%MOD
  finv[i] = finv[i-1]*inv[i]%MOD

S = int(input())
if S <= 2:
  print(0);exit()

MAX = S//3
ans = 0
for keta in range(MAX+1):
  nokori = S - keta*3
  #print(keta,nokori)
  ans += cmb(nokori+keta-1,keta-1,MOD)
  ans %= MOD
print(ans%MOD)
  

Measured memory_bytes: 67636
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<int> G[210];
int N,maxi=-1;
char a;

int check(int start){
    int visited[N],now;
    rep(i,N){
        visited[i]=-1;
    }
    queue<int> q;
    q.push(start);
  	visited[start]=1;
    while(q.size()!=0){
        now = q.front();
        q.pop();
        for(int next:G[now]){
            if(visited[next]==-1){
                visited[next]=visited[now]+1;
                q.push(next);
            }
            else{
                if(visited[next]==(visited[now]-1)||visited[next]==(visited[now]+1))continue;
                else return -1;
            }
        }
    }
    return visited[now];

}

int main(){
    cin>>N;
    rep(i,N){
        rep(j,N){
            cin>>a;
            if(a=='1')G[i].push_back(j);
        }
    }
    rep(i,N){
        maxi = max(maxi,check(i));
    }
    out(maxi);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
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>;
 
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define sd(t)       scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii         cout << "hii" << endl
#define okay        cout << "okay" << endl
#define hey         cout << "hey" << endl
const int INF = 1e12;
const int MOD = 1e9+7;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.x << ' ' << v.y; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.x << "=>" << i.y << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
 
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("jjj.txt", "w", stdout);
    #endif
} 

void solve(){
    
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    int cnt = 0;

    while(b <= a){
        b = 2*b;
        cnt++;
    }

    while(c <= b){
        c = 2*c;
        cnt++;
    }

    // cout << cnt << endl;
    if(cnt > k){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}          

int32_t main(){
    fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
        // cout << "Case #" << i << ": ";
        solve();
    }
    starboy1299();
}

Measured memory_bytes: 3820
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

class Comb:
    def __init__(self,n,mo=10**9+7):
        self.fac=[0]*(n+1)
        self.inv=[1]*(n+1)
        self.fac[0]=1
        self.fact(n)
        for i in range(1,n+1):
            self.fac[i]=i*self.fac[i-1]%mo
            self.inv[n]*=i
            self.inv[n]%=mo
        self.inv[n]=pow(self.inv[n],mo-2,mo)
        for i in range(1,n):
            self.inv[n-i]=self.inv[n-i+1]*(n-i+1)%mo
        return
    
    def fact(self,n):
        return self.fac[n]
        
    def invf(self,n):
        return self.inv[n]

    def comb(self,x,y):
        if y<0 or y>x:
            return 0
        return self.fac[x]*self.inv[x-y]*self.inv[y]%mo

show_flg=False
show_flg=True

ans=0


n=I()
x=LI()

cm=Comb(n+20)

StrN=[0]*(n+10)
StrN[1]=1
StrN[0]=0
def St(n):
    if n==1:
        return 1
    if StrN[n]!=0:
        return StrN[n]
    else:
        #a(n+1)=(n+1)*a(n)+n!
        StrN[n]=(n)*St(n-1)+cm.fac[n-1]
        StrN[n]%=mo
        return StrN[n]



St(n)

Pat=[0]*(n+1)
for i in range(n):
    Pat[i]=StrN[i]*cm.fac[n-1]*cm.inv[i]%mo
#show('Pat',Pat)
#show('St',StrN)

for i in range(n-1):
    ans+=(x[i+1]-x[i])*Pat[i+1]
    ans%=mo

print(ans%mo)
#show(SSS)


Measured memory_bytes: 138620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int MOD = 1e9 + 7;
#define INF ((1<<30)-1)
#define LINF (1LL<<30)

int n;
vector<double> p;
double dp[3100][3100];
int main() {
    cin >> n;
    p.resize(n);
    rep(i,n) cin >> p[i];
    dp[0][0] = 1.0;

    for(int i = 0; i < n; i++){
        for (int j =0; j <= i; j++){
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }
    double ans = 0.0;
    for (int j = n/2 + 1;j <= n; j++) ans += dp[n][j];
    cout << fixed << setprecision(10) << ans << endl;

}

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

typedef struct node node_t;
typedef struct node{
    int16_t id;
    int16_t visited;
    int nextcnt;
    node_t *next[8];
} node_t;

int test(node_t * vertex, int nodeid, int visitcnt, int from);
int N,M;

int main(void) {
    int tmp;
    node_t *vertex;
    int a,b;
    int sum;

    cin >> N >> M;

    vertex = (node_t*)calloc(1, sizeof(node_t) * 8);
    for(int i=0;i<8;i++) {
        vertex[i].id = i;
    }

    for(int i=0;i<M;i++) {
        cin >> a >> b;
        vertex[a-1].next[vertex[a-1].nextcnt++] = &vertex[b-1];
        vertex[b-1].next[vertex[b-1].nextcnt++] = &vertex[a-1];
    }


    vertex[0].visited = 1;
    sum = test(vertex, 0, 1, -1);
    cout << sum << "\n";
    free(vertex);

    return 0;
}

int test(node_t * vertex, int nodeid, int visitcnt, int from) {
    int sum = 0;

// printf("debug %d->%d(%d)\n", from,nodeid, visitcnt);

    if((N - visitcnt) == 0) {
        sum = 1;
        return sum;
    }

    // 最初は必ず1から
    for(int i=0;i<vertex[nodeid].nextcnt;i++) {
        if(vertex[vertex[nodeid].next[i]->id].visited == 1){
            continue;
        }
        vertex[vertex[nodeid].next[i]->id].visited = 1;
        sum += test(vertex, vertex[nodeid].next[i]->id, visitcnt + 1, nodeid);
        vertex[vertex[nodeid].next[i]->id].visited = 0;
    }

    return sum;
}


Measured memory_bytes: 256
W,H,N=map(int,input().split())
R=[0,0,W,0,H]
for _ in[0]*N:
    *wh,a=map(int,input().split())
    R[a]=[min(R[a],wh[a//3]),max(R[a],wh[a//3])][a%2]
_,w,W,h,H=R
print((W-w)*(H-h)*(W>w)*(H>h))

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	int N, M, ans;
	scanf("%d %d", &N, &M);
	long a[N], b[N], c[M], d[M], i, j, range, tmp = 0;
	int point[N][M];
	for (i = 0; i < N; i++) {
		scanf("%ld %ld", &a[i], &b[i]);
	}
	for (i = 0; i < M; i++) {
		scanf("%ld %ld", &c[i], &d[i]);
	}
	
	for (i = 0; i < N; i++) {
		ans = 0;
		range = 0;
		for (j = 0; j < M; j++) {
			tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if(j == 0) {
				range = tmp;
				ans = j + 1;
			} else {
				if (range > tmp) {
					range = tmp;
					ans = j + 1;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
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 = (1LL << 60) - 1;
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
#define MAX_N 100100 * 3

ll n, a, b;
vector<ll> vi;
map<ll, ll> mll[2];

ll num[1000][1000];
void make_pascal(ll n) {
	num[0][0] = 1;
	rep(i, n) {
		rep(j, n) {
			if (i != 0)num[i][j] += num[i - 1][j];
			if (j != 0)num[i][j] += num[i][j - 1];
		}
	}
}

ll nCk_pas(ll n, ll k) {
	return num[n - k][k];
}

int main() {
	cin >> n >> a >> b;
	rep(i, n) {
		ll num;
		cin >> num;
		vi.push_back(num);
		mll[0][num]++;
	}
	sort(ALL(vi));
	reverse(ALL(vi));

	ll pre = -1;
	ll cnt = 0, bas = 0;
	double ans = 0;
	rep(i, a) {
		if (pre != vi[i]) {
			pre = vi[i];
			bas += cnt;
			cnt = 0;
		}
		cnt++;
		mll[1][vi[i]]++;
		ans += vi[i];
	}
	ans /= a;

	ll ub = 0;
	rep(i, n) {
		if (vi[0] == vi[i])ub++;
		else break;
	}

	make_pascal(100);
	ll k = nCk_pas(mll[0][vi[a]], cnt);
	FOR(i, a + 1, min(ub, b) + 1) {
		k += nCk_pas(mll[0][vi[a]], i);
	}
	printf("%.10lf\n", ans);
	if (k == 0)cout << 1 << endl;
	else cout << k << endl;
}


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

int main() {
    // 一年の秒数
    double score;
    double leate;
    
    cin >> score >> leate;

    // 以下のコメント/* */を消して追記する
    cout << ceil((score + leate) / 2) << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> p(N);
  
  for(int i=0; i<N; i++){
    string a;
    int b;
    cin >> a >> b;
	p.at(i) = make_tuple(a,-b,i+1);
  }
  
  sort(p.begin(),p.end());
  
  for(int i=0; i<N; i++){
    cout << get<2>(p.at(i)) << endl;
  }
  
}

Measured memory_bytes: 3640
h,w,K=map(int,input().split())
s=[list(input())for i in range(h)]
import numpy as np
s=np.array(s)
l=[]

for i in range(h):
    l.append(len(s[i][s[i]=="#"]))
for i in range(w):
    l.append(len(s[:,i][s[:,i]=="#"]))
ss=sum(l)//2
n=h+w
ans=0
for i in range(1<<n):
    tmp=ss
    for j in range(h):
        if i>>j&1:
            tmp-=l[j]
    for j in range(h,n):
        if i>>j&1:
            tmp-=l[j]
            for idx,k in enumerate(s[:,j-h]):
                if k=="#":
                    if i>>idx&1:
                        tmp+=1
    if tmp==K:
        ans+=1
print(ans)







Measured memory_bytes: 27192
### ABC133-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
A=IL()
l=0
r=A[-1]
m=(l+r)//2
sA=sum(A)
x0=0
while l<=r:
    x0=m
    xm=m
    sx=2*xm
    for i in range(n-1):
        xm=A[i]-xm
        sx+=2*xm
    if sA==sx:
        break
    elif sx<sA:
        l=m+1
        m=(l+r)//2
    else:
        r=m-1
        m=(l+r)//2
print(2*x0,end=" ")
xm=x0
for i in range(n-1):
    xm=A[i]-xm
    print(2*xm,end=" ")
print()

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

template<typename T, typename F>
struct Seg{
private:
    vector<T> node;
    int n;
    F f;
    T def;

public:
    Seg(int siz, T d, F f) : def(d), f(f) {
        n = 1;
        while(n < siz)  n *= 2;
        node.resize(2*n-1, def);
    }
    Seg(vector<T> v, T d, F f) : def(d), f(f){
        n = 1;
        while(n < v.size())  n *= 2;
        node.resize(2*n-1, def);
        for(int i = 0; i < v.size(); i++)   node[n-1+i] = v[i];
        for(int i = n-2; i >= 0; i--)   node[i] = f(node[2*i+1], node[2*i+2]);
    }

    void update(int x, T val){
        x += n-1;
        node[x] = val; /* ! */
        while(x){
            x = (x-1)/2;
            node[x] = f(node[2*x+1], node[2*x+2]);
        }
    }

    T query(int a, int b){
        int L = a+n-1, R = b+n-1;
        T lx = def, rx = def;
        while(L < R){
            if((R&1) == 0)  rx = f(node[--R], rx);
            if((L&1) == 0)  lx = f(lx, node[L++]);
            L >>= 1, R >>= 1;
        }
        return f(lx, rx);
    }
};

int main(){
    int n, k;
    cin >> n >> k;
    auto f = [](int a, int b){return max(a,b);};
    Seg<int, decltype(f)> seg(300001, 0, f);
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        seg.update(x, 1+seg.query(max(0,x-k), min(300001, x+k+1)));
    }
    cout << seg.query(0, 300001) << endl;
    return 0;
}

Measured memory_bytes: 7484
from itertools import permutations

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

x = sorted(p)
ab = []
for i, per in enumerate(permutations(x, n)):
    if per == p or per == q:
        ab.append(i) 

if len(ab) < 2:
    print(0)
else:
    print(abs(ab[0]-ab[1]))

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

int main() {
  char b,ans;

  cin >> b;

  if (b == 'A') {
    ans = 'T';
  }
  else if (b == 'C') {
    ans = 'G';
  }
  else if (b == 'G') {
    ans = 'C';
  }
  else {
    ans = 'A';
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input macros
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A1: [u64; N],
        A2: [u64; N],
    }
    let mut Ans = 0;
    for x in 0..N{
        let mut ans = 0;
        for i in 0..N{
            if i <= x{
                ans += A1[i];
            }
            if i >= x{
                ans += A2[i];
            }
        }
        Ans = max(Ans,ans);
    }
    println!("{}", Ans);
}


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

int main() {
  double d;
  while(cin>>d) {
    if(d < 0) break;
    int di = (int)d;
    if(di >= 1<<9) {
      cout<<"NA"<<endl;
      continue;
    }
    d *= 16;
    if(d - (int)d > 0) {
      cout<<"NA"<<endl;
      continue;
    }
    di = (int)d;
    string res = "";
    while(di > 0) {
      if(di%2) res = "1"+res;
      else res = "0"+res;
      di /= 2;
    }

    if(res.length() < 12) res = string(12-res.length(), '0') + res;
    for(int i=0; i<12; ++i) {
      cout<<res[i];
      if(i == 7) cout<<".";
    }
    cout<<endl;
  }
}

Measured memory_bytes: 0
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        for (int i = 0; i < n; i++) {
            StringBuilder sb1 = new StringBuilder();
            StringBuilder sb2 = new StringBuilder();
            String[] result = new String[10];
            int pos = 9; // 結果を順次格納していく、indexの把握

            String first = br.readLine();
            String second = br.readLine();

            if (first.length() > 80 || second.length() > 80) {
                System.out.println("overflow");
                continue;
            }

            for (int j = 0; j < 80 - first.length(); j++) {
                sb1.append("0");
            }
            sb1.append(first);

            for (int j = 0; j < 80 - second.length(); j++) {
                sb2.append("0");
            }
            sb2.append(second);

            // System.out.println("sb1 : " + sb1.toString());
            // System.out.println("sb2 : " + sb2.toString());

            int carry = 0;
            for (int j = 0; j < 10; j++) {
                int x = Integer.parseInt(sb1.toString().substring(sb1.length() - 8, sb1.length()));
                int y = Integer.parseInt(sb2.toString().substring(sb2.length() - 8, sb2.length()));

                sb1.delete(sb1.length() - 8, sb1.length());
                sb2.delete(sb2.length() - 8, sb2.length());

                String value = String.valueOf(x + y + carry);
                if (value.length() > 8) {
                    value = value.substring(1);
                }
                StringBuilder tmp = new StringBuilder();
                for (int k = 0; k < 8 - value.length(); k++) {
                    tmp.append("0");
                }
                tmp.append(value);
                result[pos] = tmp.toString();
                pos--;
                carry = (x + y + carry) / 100000000;
            }

            // display
            if (carry != 0) {
                System.out.println("overflow");
            } else {
                String x = "";
                for (String y : result)
                    x = x + y;
                int index = -1;
                while (index < 79 && x.charAt(++index) == '0');
                System.out.println(x.substring(index));
            }

        }
    }
}


Measured memory_bytes: 24352
// https://qiita.com/drken/items/dc53c683d6de8aeacf5a
#include <stdio.h>
#include <algorithm>

#define MAX_N 100010
#define A 0
#define B 1
#define C 2
#define OTHER 3
using namespace std;

int main(){
    int N_input;

    scanf("%d", &N_input);
    
    int day_hapiness[3];
    long long int hapiness[3][2] = {0, 0, 0};

    for(auto i=1; i<=N_input; i++){
        scanf("%d %d %d", &day_hapiness[A], &day_hapiness[B], &day_hapiness[C]);

        hapiness[A][1] = max(hapiness[B][0], hapiness[C][0]) + day_hapiness[A];
        hapiness[B][1] = max(hapiness[A][0], hapiness[C][0]) + day_hapiness[B];
        hapiness[C][1] = max(hapiness[B][0], hapiness[A][0]) + day_hapiness[C];

        hapiness[A][0] = hapiness[A][1];
        hapiness[B][0] = hapiness[B][1];
        hapiness[C][0] = hapiness[C][1];
    }

    printf("%lld", max(hapiness[A][1], max(hapiness[B][1], hapiness[C][1])));

    return(0);

}

Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"IMPOSSIBLE"<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//12:15~
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
bool solve(int n,int w,int d){
	if(n+w+d==0){return false;}
	vector<pair<int,int>>cakes;
	cakes.pub(mp(w,d));
	for(int i=0;i<n;i++){
		int p;cin>>p;p--;
		int tw=cakes[p].fir,td=cakes[p].sec;
		cakes.erase(cakes.begin()+p);
		int s;cin>>s;
		int syu=tw+td;
		s%=syu*2;
		if(s<tw){
			cakes.pub(min(mp(s,td),mp(tw-s,td)));
			cakes.pub(max(mp(s,td),mp(tw-s,td)));
		}
		else if(s<tw+td){
			cakes.pub(min(mp(tw,s-tw),mp(tw,td+tw-s)));
			cakes.pub(max(mp(tw,s-tw),mp(tw,td+tw-s)));
		}
		else if(s<tw+td+tw){
			s-=tw+td;
			cakes.pub(min(mp(s,td),mp(tw-s,td)));
			cakes.pub(max(mp(s,td),mp(tw-s,td)));
		}
		else{
			s-=tw+td;
			cakes.pub(min(mp(tw,s-tw),mp(tw,td+tw-s)));
			cakes.pub(max(mp(tw,s-tw),mp(tw,td+tw-s)));
		}
	}
	vector<int>las;
	for(auto it:cakes){las.pub(it.fir*it.sec);}
	sort(las.begin(),las.end());
	for(int i=0;i<(int)las.size()-1;i++){cout<<las[i]<<" ";}
	cout<<las.back()<<endl;
	return true;
}
int main(void){
	int n,w,d;
	while(cin>>n>>w>>d,solve(n,w,d)){}
	return 0;
}

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

using namespace std;

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size() > K) {
    S.erase(S.begin() + K, S.end());
    S.push_back('.');S.push_back('.');S.push_back('.');
  }
  cout << S << endl;
   return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
long long f(long long x) {
    if (x % 4 == 0) return x;
    if (x % 4 == 1) return 1;
    if (x % 4 == 2) return x ^ 1;
    return 0;
}
int main()
{
    long long A, B; cin >> A >> B;
    cout << (f(B) ^ f(A-1)) << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    return buf
}

fn main() {
  let line = gets();
  let mut it = line.split_whitespace().map(|x| x.parse::<i64>().unwrap());
  let (x, t) = (it.next().unwrap(), it.next().unwrap());
  let ans = cmp::max(0, x - t);
  println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int a,b,c,k;cin>>a>>b>>c>>k;
  int d=max(a,max(b,c));
  int e=d;
  for(int i=0;i<k;i++)
    d=d*2;
  cout<<d+a+b+c-e;
}

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

int main(){
  int N;

  cin >>N;

  if(N == 1){
    cout <<"Hello World"<<endl;
  }
  else{
    int A,B;
    cin >>A>>B;
    cout <<A+B<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

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

    ll now = 0;
    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        now += a;
        if(a == 0) {
            ans += now/2LL;
            now = 0;
        }
    }
    
    ans += now/2LL;
    
    cout << ans << endl;
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << A[K-1] << endl;
    
    return 0;
}


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

int main(){
    string sa,sb;
    cin >> sa >> sb;
    
    string s = sa + sb;
    int n = atoi(s.c_str());
    
    double d = (double)n;
    double q = sqrt(d);
    int    r = (int)q;
    double t = (double)r;
    
    if (abs(q-t) < 1e-4){
	cout << "Yes" << endl;
    }else{
	cout << "No" << endl;
    }
    
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vi>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define mod             1000000007
#define inf             1e18
#define deb(x)          cout << #x << "=" << x << '\n';
#define ps(x,y)         fixed<<setprecision(y)<<x
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

string s, t, lcs, temp, tempp;
int dp[3001][3001];

string getlcs(int i, int j) {
    if(i==-1||j==-1) return "";
    if(s[i]==t[j]) {
        temp = getlcs(i-1, j-1);
        tempp = s[i];
        temp.append(tempp);
        return temp;
    }
    if(dp[i+1][j+1]==dp[i+1][j]) {
        temp = getlcs(i, j-1);
        return temp;
    }
    if(dp[i+1][j+1]==dp[i][j+1]) {
        temp = getlcs(i-1, j);
        return temp;
    }

    return "";
}

void solve() {
    cin >> s >> t;

    for(int i = 0; i < s.length(); i++) {
        for(int j = 0; j < t.length(); j++) {
            if(i==0||j==0) dp[i][j] = 0;

            dp[i+1][j+1] = s[i]==t[j]?1+dp[i][j]: max(dp[i][j+1], dp[i+1][j]);
        }
    }
    int i=s.size(), j=t.size();

    lcs = getlcs(s.length()-1, t.length()-1);

    cout << lcs;
}

int32_t main() {
    FIO;
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 70912
#include <stdio.h>

int rec(int,int,int*,int);

int main(){
  int n,A[20],q,m,i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&m);
    puts(rec(0,m,A,n) ? "yes" : "no");
  }
  return 0;
}

int rec(int idx,int m,int *A,int n){
  int res = 0;
  if(m == 0){ return 1; }
  if(m < 0 || idx == n){ return 0; }
  res |= rec(idx+1,m-A[idx],A,n);
  res |= rec(idx+1,m,A,n);
  return res;
}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long a[100000+5]={0};
	for(int i=0;i<n;i++)
		cin>>a[i];
	int num=0;
	int i=0;
	while(i<n)
	{
		if(i==n-1)
		{num++;break;}
		if(a[i]<a[i+1])
		{
			int j;
			for(j=i;j<n;j++)
			{
				if(a[j]<=a[j+1])
					continue;
				else
					break;
			}
			num++;
			i=j+1;
		}
		else if(a[i]>a[i+1])
		{
			int j;
			for(j=i;j<n;j++)
			{
				if(a[j]>=a[j+1])
					continue;
				else
					break;
			}
			num++;
			i=j+1;
		}
		else if(a[i]==a[i+1])
		{
			i++;
		}
		else
		{
			num++;
			i++;
		}
	}
	cout<<num<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

int len,L,q,a,b,c,d;
void solve(){
	len=(max(a,b)+min(a,b))/(min(a,b)+1);
	int l=0,r=a+b+1;
	while(l<r){
		int z=(l+r)>>1;
		int aa=a-z/(len+1)*len-z%(len+1);
		int bb=b-z/(len+1);
		if(bb<=1ll*aa*len)l=z+1;else r=z;
	}
	L=l;
	Pr("L=%d\n",L);
	while(c<=d){
		if(c<=L)putchar((c-1)%(len+1)==len?'B':'A'),++c;
		else putchar((a+b+1-c)%(len+1)==0?'A':'B'),++c;
	}
	puts("");
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	scanf("%d",&q);
	while(q--){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	ll N, K;
	string S;
	cin >> N >> K >> S;

	vector<ll> line;
	//line.push_back(0);
	char pre = 'x';
	ll cnt = 0;
	rep(i, N) {
		if(i==0) {
			pre = S[0];
			cnt = 1;
			continue;
		}
		if(pre==S[i]) {
			cnt++;
		} else {
			line.push_back(cnt);
			cnt = 1;
			pre = S[i];
		}
	}
	line.push_back(cnt);

	ll sum = 0;
	rep(i, line.size()) sum += line[i]-1;

	// cout << sum << endl;

	sum += min((int)K*2, (int)(line.size()-1));

	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 1528
#include<iostream>
int main(){int a[7]={0,0,0,0,0,0,0};int i,k;while(std::cin>>i){if(i!=0){for(int j=0;j<i;j++)std::cin>>k,k>60?a[6]++:a[k/10]++;for(i=0;i<7;i++)std::cout<<a[i]<<"\n",a[i]=0;}}}

Measured memory_bytes: 860
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
	print(0)
elif ns != ns[::-1]:
	print(-1)
else:
	cnt = 0
	i = 0
	j = len(s)-1
	while(i<j):
		if s[i]=='x' and s[j]!='x':
			cnt += 1
			j += 1
		elif s[i]!='x' and s[j]=='x':
			cnt += 1
			i -= 1
		i += 1
		j -= 1
	print(cnt)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

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

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char a; cin >> a;
    int index = a-'a';
    if(0<=index && index<26){
        cout << 'a' << endl;
    }
    else{
        cout << 'A' << endl;
    }
}


Measured memory_bytes: 3652
n = int(input())
a = list(map(int,input().split()))
dp = [[0 for _ in range(n)] for _ in range(n)]
size = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
  size[i][i] = a[i]
for i in range(n-1):
  for j in range(1,n-i):
    size[i][i+j] = size[i][i+j-1]+a[i+j]
for i in range(1,n):
  for j in range(0,n-i):
    mn = float("inf")
    for k in range(i):
      if mn > dp[j][j+k] + dp[j+k+1][j+i]:
        mn = dp[j][j+k] + dp[j+k+1][j+i]
    dp[j][j+i] = mn+ size[j][j+i]
print(dp[0][n-1])
      

Measured memory_bytes: 45420
//Li Chao Segment Tree - trial
//dp(@)-Z
#include<stdio.h>
#define llinf 4154118101919364364

long long llmin(long long a,long long b){if(a<b){return a;}return b;}

//f(x) = (x-vertex)^2 + cv
typedef struct{
  long long vertex;
  long long cv;
}func;

long long fcalc(long long x,func f){
  return (x-f.vertex)*(x-f.vertex)+f.cv;
}

func li_chao[2097152];
long long ssize=1048576;

void sinit(){
  long long i;
  for(i=0;i<2097152;i++){
    li_chao[i].vertex=0;
    li_chao[i].cv=llinf;
  }
}

//add func f
//call:k=0,st=0,fi=0
void add(func f,long long k,long long st,long long fi){
  long long nst=fcalc(st,f),nfi=fcalc(fi-1,f);
  long long pst=fcalc(st,li_chao[k]),pfi=fcalc(fi-1,li_chao[k]);
  if(nst>=pst && nfi>=pfi){return;}
  if(nst<=pst && nfi<=pfi){
    li_chao[k]=f;
    return;
  }
  long long mid=(st+fi)/2;
  add(f,2*k+1,st,mid);
  add(f,2*k+2,mid,fi);
}

//get min f(x)
long long get(long long x){
  long long p=x+ssize-1,res=llinf;
  while(p>=0){
    res=llmin(fcalc(x,li_chao[p]),res);
    if(p==0){break;}
    p=(p-1)/2;
  }
  return res;
}

int main(){
  sinit();
  long long n,c,h[262144],i;
  func f;
  scanf("%lld%lld",&n,&c);
  for(i=0;i<n;i++){
    scanf("%lld",&h[i]);
    f.vertex=h[i];
    if(i==0){
      f.cv=c;
    }
    else{
      f.cv=get(h[i])+c;
    }
    add(f,0,0,ssize);
  }
  printf("%lld\n",get(h[n-1]));
}


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

const long long INF = 1000000001;

const long long MOD = 1000000009;

typedef long long ll;

const int max = 1000000; //配列の最大長

int main(void){
  int n,w;
  std::cin >> n >> w;

  int weight[n],value[n];
  for(int i=0; i<n; i++) std::cin >> weight[i] >> value[i];

  ll dp[n+1][w+1] = {};

  for(int i=0; i<n; i++){
    for(int sum_w=0; sum_w<=w; sum_w++){
      if(sum_w - weight[i] >= 0) dp[i+1][sum_w] = dp[i][sum_w - weight[i]] + value[i];
      dp[i+1][sum_w] = std::max(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }

  std::cout << dp[n][w] << std::endl;
  return 0;

}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;cin >> H >> W;
    int N; cin >> N;
    queue<int> que;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a; que.push(a);
    }
    vector<vector<int>> ans(H,vector<int>(W,0));
    //if(H<W)swap(H,W);
    int color = 0;
    int index = 0;
    while(!que.empty()){
        a = que.front(); que.pop();
        color++;
        //cout << index <<" "<< a << endl;
        int end = index + a;
        for(; index < end ; index++){
            //cout << "A" << index<< "<" << index + a << endl;
            //cout << index/W << " " << index % W << endl;
            if((index/W)%2==0)ans[index/W][index%W] = color;
            else ans[index/W][W - index%W - 1] = color;
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3640
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <cstdio>

using namespace std;

int main(){
	string S;
	cin>>S;
	int ans=0;
	char tmp=S[0];
	for(int i=0;i<S.size();i++){
		if(S[i]!=tmp){
			ans++;
			tmp=S[i];
		}
	}
	cout<<ans<<endl;
	return 0;	
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll TC, X[6];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	TC = 1;
	
	for (ll q = 1; q <= TC; q++) {
		
		for (ll i = 1; i <= 5; i++) {
			cin >> X[i];
			if (X[i] == 0) {
				cout << i << "\n";
				break;
			}
		}
	
	}
	
    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> p(n);
	rep(i,n){
		cin>>p[i].sc>>p[i].fs;
	}
	sort(all(p));

	ll cur=0;
	for(auto&c:p){
		ll t=cur+c.sc;
		if(t>c.fs){
			puta("No");
			return 0;
		}
		cur=t;
	}
	puta("Yes");
	return 0;
}

Measured memory_bytes: 3328
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int r;
    double pi = 3.14159;
    cin >> r;
    cout << r * 2 * pi;
}

Measured memory_bytes: 3788
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(in.readLine());
    int ans = 0;
    for(int i=x; i<10000000; i++) {
      boolean hantei = false;
      for(int j=2; j<i; j++) {
        if(i%j==0) {
          hantei = true;
          break;
        }
      }
      if(hantei == false) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 32524
//Kyokai no Kanata //
#include<bits/stdc++.h>

using namespace std;

typedef long long int LL;
typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
  const char* comma=strchr(names+1,',');
  cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...)
#endif
//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);
float  inf=std::numeric_limits<double>::infinity();
LL INF=std::numeric_limits<LL>::max();
LL powm(LL base,LL power, LL mod){
  LL ret=1;
  while(power){
    if(power&1) ret=(ret*base)%mod;
    base=(base*base)%mod;
    power>>=1;
  } return ret;
}
int main(){
  string s; cin>>s;
  if(s[0]!='A') return 0*puts("WA");
  int cnt=0;
  for(int i=2;i<s.size()-1;i++) cnt+=(s[i]=='C');
  if(cnt!=1) return 0*puts("WA");
  for(int i=1;i<s.size();i++)
   if((s[i]<'a' || s[i]>'z') && s[i]!='C') return 0*puts("WA");
  puts("AC"); 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3540