akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        //long n = 1000000000000001L;
        long n = sc.nextLong();
        char[] alp = "zabcdefghijklmnopqrstuvwxy".toCharArray();
        String ans = "";
        if(n <= 26){
            int index = (int)(n%26);
            System.out.println(alp[index]);
        }else{
            long pow = 1;
            while(n / pow > 0){
                long i = (n/pow)%26;
                int index = (int)i;
                ans = alp[index] + ans;
                n -= pow;
                pow *= 26L;
            }
            System.out.println(ans);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25356
//残る連結成分のmax-costの辺に注目する。辺eがmax-costの辺になる条件を考えて、塗りつぶしの問題にする。これはO(NlogN)。
//あとはコストが大きい辺から見ていって, 連結成分の「辺」を塗りつぶしていくと、同じ頂点を2回見なくてよくなるのでO(N)。
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

struct Edge {
	int from, to, cost;
	bool filled;
	
	Edge() {
		this->filled = false;
	}
	Edge(int from, int to, int cost) {
		this->from = from;
		this->to = to;
		this->cost = cost;
		this->filled = false;
	}
	bool operator<(Edge &r) {
		return cost < r.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct UF {
	int par[100000];
	int sum[100000];
	
	void init(int n, int x[]) {
		int i;
		for (i = 0; i < n; i++) {
			par[i] = i;
			sum[i] = x[i];
		}
	}
	
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	int vsum(int x) {
		return sum[root(x)];
	}
	
	void unit(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			par[x] = y;
			sum[y] += sum[x];
		}
	}
};

int n, m;
int x[100000];
Graph g;
Edge edges[100000];
bool is_max[100000];
bool visit[100000];

void dfs(int v, int c) {
	if (visit[v]) return;
	visit[v] = true;
	
	int i;
	for (i = 0; i < g[v].size(); i++) {
		Edge& e = g[v][i];
		if (!e.filled && e.cost <= c) {
			//cout << "fill(" << e.from + 1 << ", " << e.to + 1 << ", " << e.cost << ")" << endl;
			e.filled = true;
			dfs(e.to, c);
		}
	}
}

signed main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, n) cin >> x[i];
	
	g.resize(n);
	rep(i, m) {
		int a, b, y;
		cin >> a >> b >> y;
		a--; b--;
		edges[i] = Edge(a, b, y);
		g[a].push_back(Edge(a, b, y));
		g[b].push_back(Edge(b, a, y));
	}
	sort(edges, edges + m);
	
	static UF uf;
	
	uf.init(n, x);
	rep(i, m) {
		uf.unit(edges[i].from, edges[i].to);
		if (uf.vsum(edges[i].to) >= edges[i].cost) {
			is_max[i] = true;
		}
	}
	
	for (i = m - 1; i >= 0; i--) {
		if (is_max[i]) {
			//cout << edges[i].from + 1 << ", " << edges[i].to + 1 << ", " << edges[i].cost << endl;
			dfs(edges[i].from, edges[i].cost);
		}
	}
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < g[i].size(); j++) {
			if (!g[i][j].filled) {
				ans++;
			}
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 19968
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i = a; i < b; i++)
#define fst first
#define snd second
#define ll long long
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int>
#define piii pair<int, pii>
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define mp make_pair

using namespace std;

const int N_MAX = 200005;
ll A[N_MAX],B[N_MAX],SA[N_MAX],SB[N_MAX];

int main(){
    int N,M;
    ll K;
    cin>>N>>M>>K;
    fore(i,1,N+1) cin>>A[i];
    fore(i,1,M+1) cin>>B[i];
    SA[0]=0;
    fore(i,1,N+1) SA[i]=SA[i-1]+A[i];
    SB[0]=0;
    fore(i,1,M+1) SB[i]=SB[i-1]+B[i];
    int ans = 0;
    fore(i,0,N+1){
        ll tr = K-SA[i];
        if(tr<0) continue;
        int l=0,r=M;
        while(l<r){
            int mid = l+(r-l+1)/2;
            if(SB[mid]<=tr) l=mid;
            else r=mid-1;
        }
        ans = max(ans,i+l);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;

    ll sum = 0;
    int len = S.size();
    for ( int i = 0; i < (1<<(len-1)); i++ ) {
        string t;
        t.push_back(S[0]);
        for ( int j = 0; j < len-1; j++ ) {
            if ( (i >> j) & 1 ) {
                sum += stoll(t);
                t = "";
            }
            t.push_back(S[j+1]);
        }
        sum += stoll(t);
    }
   
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,sum,num;
  cin >> A >> B;
  sum = 0;
  num = A;
  for (int i=0; i<B-A+1 ; i++){
    if (num%10 == num/10000 && num/1000%10 == num/10%10){
      sum ++;
      num ++;
    }
    else{
      num ++;
      continue;
    }
  }
  cout << sum << endl;  
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (x, y) = (v[0], v[1]);
    let big_int = 1000_000_000i64 + 7;
    if (x + y) % 3 != 0 {
        println!("0");
        return;
    }

    let diff = max(x, y) - min(x, y);
    if min(x, y) < diff || (min(x, y) - diff) % 3 != 0 {
        println!("0");
        return;
    }
    let same = (min(x, y) - diff) / 3;

    let fact7 = ModFactorial::new((2 * same + diff) as i64, big_int);
    let fact7 = fact7.fact;
    let inv_fact7 = (0..fact7.len())
        .map(|x| mod_inverse(fact7[x as usize], big_int))
        .collect::<Vec<_>>();
    let binom7 = ModBinominal::new((2 * same + diff) as i64, big_int, &fact7, &inv_fact7);
    println!("{}", binom7.bin[same]);
}

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

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

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b == 0 {
        *x = 1;
        *y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    }
    return d;
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x: i64 = 0;
    let mut y: i64 = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}

struct ModFactorial {
    fact: Vec<i64>,
}

// returns n! under mod m
impl ModFactorial {
    fn new(n: i64, m: i64) -> ModFactorial {
        let mut fact = vec![1; n as usize + 1];
        for i in 2..fact.len() {
            fact[i] = (i as i64 * fact[i - 1]) % m;
        }
        ModFactorial { fact: fact }
    }
}

// returns bin[i] = nCi under mod m
struct ModBinominal {
    bin: Vec<i64>,
}

impl ModBinominal {
    fn new(n: i64, m: i64, fact: &Vec<i64>, inv_fact: &Vec<i64>) -> ModBinominal {
        let mut bin = vec![1; n as usize + 1];
        if n == 0 {
            return ModBinominal { bin: bin };
        }
        for i in 1..n + 1 {
            let a2 = inv_fact[i as usize] % m;
            let a3 = inv_fact[(n - i) as usize] % m;
            bin[i as usize] = fact[n as usize] * ((a2 * a3) % m) % m;
        }
        ModBinominal { bin: bin }
    }
}


Measured memory_bytes: 22780
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/
int n, m, a, b,x,y;
vector<int>v1;
vector<int>v2;
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		if (a == 1)v1.push_back(b), x++;
		if (b == n)v2.push_back(a), y++;
	}
	if (x == 0 || y == 0) {
		cout << "IMPOSSIBLE" << endl;
		goto end;
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	x = 0, y = 0;
	while (x <= v1.size() && y <= v2.size()) {
		if (v1[x] == v2[y]) {
			cout << "POSSIBLE" << endl;
			goto end;
		}
		if (v1[x] < v2[y])x++;
		else y++;
	}
	cout << "IMPOSSIBLE" << endl;
end:;
	system("PAUSE");
	return 0;
}



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

using namespace std;
int main()
{
    long n, m, i,  f1=1, f2=1;
    cin>> n>> m;

    if(n<=1)
        f1=0;

    else
    {
        for(i=n; i>n-2; i--)
        {
            f1= f1* i;
        }

    }
    if(m<=1)
        f2=0;

    else
    {
        for(i=m; i>m-2; i--)
        {
            f2= f2* i;
        }

    }
    cout<< (f1+f2)/2<< endl;

    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> p(m);
  for(int i=0; i<m; i++) cin >> p[i].first >> p[i].second;
  for(int i=0; i<1000; i++){
    int keta = 1;
    vector<int> d(1,i%10);
    int ii = i/10;
    while(ii){
      keta++;
      d.push_back(ii%10);
      ii/=10;
    }
    if(n!=keta) continue;
    bool boo = true;
    reverse(d.begin(),d.end());
    for(int j=0; j<m; j++){
      if(p[j].second != d[p[j].first-1]) boo = false;
    }
    if(boo){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
// AOJ 2151: Brave Princess Revisited
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int t, n, m; } QUE;
QUE que[20001]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

int deq(int *n, int *m)
{
	if (qsize == 0) return 0;
	*n = que[0].n, *m = que[0].m;
	que[0] = que[--qsize];
	min_heapify(0);
	return 1;
}

void enq(int t, int n, int m)
{
	int i, min;

	i = qsize++;
	que[i].t = t, que[i].n = n, que[i].m = m;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

typedef struct { int len, to[101], d[101], e[101]; } TBL;
TBL tbl[101];
int node[101][101]; int size;

int search(int start, int goal, int l)
{
	int s, m, i, k, e, p, ans;
	TBL *tp;

	qsize = 0;
	memset(node, 0x33, sizeof(node));
	node[start][l] = 0; enq(0, start, l);
	ans = 0x7fffff;
	while(deq(&s, &m)) {
		p = node[s][m];
		if (s == goal) {
			if (p < ans) ans = p;
			continue;
		}

		for (tp = tbl + s, i = 0; i < tp->len; i++) {
			e = tp->to[i];

			k = p + tp->e[i];
			if (k < node[e][m]) node[e][m] = k, enq(node[e][m], e, m);

			k = m - tp->d[i];
			if (tp->d[i] <= m && p < node[e][k]) node[e][k] = p, enq(node[e][k], e, k);
		}
	}
	return ans;
}

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, l, a, b, d, e, i;
	TBL *tp;

	while (fgets(p=buf, 30, stdin) && *p != '0') {
		n = getint(), p++, m = getint(), p++, l = getint();
		memset(tbl, 0, sizeof(tbl));
		while (m--) {
			fgets(p=buf, 30, stdin);
			a = getint()-1, p++, b = getint()-1, p++, d = getint(), p++, e = getint();
			tp = tbl+a, i = tp->len;
			tp->to[i] = b, tp->d[i] = d, tp->e[i] = e, tp->len++;
			tp = tbl+b, i = tp->len;
			tp->to[i] = a, tp->d[i] = d, tp->e[i] = e, tp->len++;
		}
		size = n;
		printf("%d\n", search(0, n-1, l));
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int T[N];
    int s = 0;
    rep(i, N){
        cin>>T[i];
        s += T[i];
    }
    
    int M; cin >> M;
    int P, X;
    int ans;
    rep(i, M){
        ans = s;
        cin >> P >> X;
        ans -= T[P-1];
        ans += X;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define MAXN ((int)1e3+5)
#define MOD ((int)1e9 + 7) 
#define ll long long
#define _ << " " <<
#define TRACE(x) cout << #x << " = " << x << endl;
#define pb push_back
#define MP make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vii vector<pi>
#define all(x) x.begin(), x.end()

int n,m,t,k;
char d[MAXN][MAXN];
int ct[MAXN][MAXN];
void read();

void add_self(int& a,int b);

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	read();
	ct[0][0] = 1;

	for (int i = 1; i < n; ++i)
		if(d[i][0]) ct[i][0] = ct[i-1][0];
		else ct[i][0] = 0;

	for (int i = 1; i < m; ++i)
		if(d[0][i]) ct[0][i] = ct[0][i-1];
		else ct[0][i] = 0;	

	for (int i = 1; i < n; ++i)
	{
		for (int j = 1; j < m; ++j)
			if(d[i][j])
			{
				add_self(ct[i][j], ct[i-1][j]);
				add_self(ct[i][j], ct[i][j-1]);
			}
	}

	cout << ct[n-1][m-1] << endl;

	return 0;
}

void add_self(int& a,int b){
	a += b;
	if(a > MOD)
		a -= MOD;
}

void read(){
	cin >> n >> m;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			char c;
			cin >> c; 
			if(c == '#')
			{
				d[i][j] = 0;
				ct[i][j] = 0;
			}
			else
				d[i][j] = 1;
		}
}

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

double p[3005];
double dp[3005][3005];
int n;
int main(){
	
	cin >> n;
	
	for(int i=1;i<=n;i++)
	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]+=1.0*dp[i][j]*p[i+1];
			dp[i+1][j]+=1.0*dp[i][j]*(1.0-p[i+1]);
		}
	}
	
	double ans=0;
	for(int i=(n+1)/2;i<=n;i++)
		ans+=dp[n][i];
		
	printf("%.12lf\n", ans);
	
	return 0;
}
	


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

mod = 998244353
NUM = 3*(10**5)
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]

for i in range( 2, NUM + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inv.append( ( -inv[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inv[-1]) % mod )

def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

ans=0
for i in range(k+1):
    ret1 = m * pow(m-1,n-i-1,mod)
    ret2 = comb(n-1,i,mod)
    ans+=ret1*ret2
    ans%=mod

print(ans)

Measured memory_bytes: 132048
//#include "bits/stdc++.h"
#include<iostream>
using namespace std;
#define int int64_t
#define mp make_pair
#define f first
#define s second
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22)
        cout<<"bust\n";
    else
        cout<<"win\n";
    return 0;
}


Measured memory_bytes: 256
class DualSegmentTree():

    def __init__(self, n, op, e):
        self.n = n
        self.op = op
        self.e = e
        self.depth = (self.n - 1).bit_length()
        self.size = 1 << self.depth
        self.lazy = [self.e] * ((self.size << 1) + 1)

    def update(self, l, r, x):
        l += self.size
        r += self.size
        self.propagate(l)
        self.propagate(r-1)
        while l < r:
            if r&1:
                r -= 1              # 半開区間なので先に引いてる
                self.lazy[r] = self.op(x, self.lazy[r])
            if l&1:
                self.lazy[l] = self.op(x, self.lazy[l])
                l += 1
            l = l // 2
            r = r // 2

    def propagate(self, i):
        for k in range(self.depth,0,-1):
            x = i>>k
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)+1] = self.op(self.lazy[x], self.lazy[(x<<1)+1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e

    def get(self, i):
        i += self.size
        self.propagate(i)
        return self.lazy[i]

    def __getitem__(self, i):
        return self.get(i)

    def __iter__(self):
        for x in range(1, self.size):
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)+1] = self.op(self.lazy[x], self.lazy[(x<<1)+1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e
        for a in self.lazy[self.size:self.size+self.n]:
            yield a

    def __str__(self):
        for x in range(1, self.size):
            if self.lazy[x] == self.e:
                continue
            self.lazy[(x<<1)+1] = self.op(self.lazy[x], self.lazy[(x<<1)+1])
            self.lazy[x<<1] = self.op(self.lazy[x], self.lazy[x<<1])
            self.lazy[x] = self.e
        return str(self.lazy[self.size:self.size + self.n])

##################################################################################################################
import sys
from bisect import *
input = sys.stdin.readline

N, Q = map(int, input().split())

e = -1
op = lambda x, y: x if x != e else y
st = DualSegmentTree(Q, op, e)

Qu = [list(map(int, input().split())) for _ in range(N)]
Qu.sort(key=lambda x:x[2], reverse=True)

D = [int(input()) for _ in range(Q)]

for q in Qu:
    S, T, X = q
    L = bisect_left(D,S-X)
    R = bisect_left(D,T-X)
    st.update(L, R, X)
print(*st, sep="\n")


Measured memory_bytes: 146208
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	char ch=getchar();int f=0;x=0;
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005,inf=1e9+99;
struct node{
	int level,mx;
	vi pre,suf;			//pre[i] 前缀至少有 i + 1 个的右端点数量
	node(int _x=inf){
		level=_x,mx=1;
		if(_x>=0)pre=suf={1};
	}
	void Assert(){
		assert(pre.size()==mx&&pre[mx-1]);
		assert(suf.size()==mx&&suf[mx-1]);
	}
}stk[N],emp;
int a[N],n,L,top;
ll ans;

node merge(node a[],int n){
/*
	puts("==================\nmerge: ");
	rep(i,1,n){
		printf("a[%d] = {%d, %d, { ",i,a[i].level,a[i].mx);
		for(auto x:a[i].pre)printf("%d ",x);
		printf("}, { ");
		for(auto x:a[i].suf)printf("%d ",x);
		puts("}}");
	}
	ll las=ans;
*/
	static int sum[N],tot[N];
	rep(i,1,n)sum[i]=sum[i-1]+a[i].mx;
	if(sum[n]<L)return emp;
	tot[n+1]=0;
	per(i,n,1)tot[i]=tot[i+1]+a[i].pre[0];
	for(int l=1,r=1,q=1;r<=n;l++)
		per(i,a[l].mx,1){
			while(l==r)r++,q=1;
			while(r<=n&&i+sum[r-1]-sum[l]+q<L){
				q++;
				if(q<=a[r].mx)continue;
				r++,q=1;
			}
			if(r<=n){
				int A=a[l].suf[i-1]-(i<a[l].mx?a[l].suf[i]:0);
				int B=a[r].pre[q-1]+tot[r+1];
//				printf("# %d %d   %d %d   %d\n",l,r,i,q,A*B);
				ans+=(ll)A*B;
			}
		}
	node res(-1);
	res.level=a[1].level+1;
	res.mx=sum[n]/L;
	res.pre.resize(res.mx);
	res.suf.resize(res.mx);
	for(int i=1,cnt=0;i<=n;i++)
		rep(j,1,a[i].mx)
			if(++cnt>=L){
				int tmp=a[i].pre[j-1]-(j<a[i].mx?a[i].pre[j]:0);
				res.pre[cnt/L-1]+=tmp;
			}
	for(int i=n,cnt=0;i>=1;i--)
		rep(j,1,a[i].mx)
			if(++cnt>=L){
				int tmp=a[i].suf[j-1]-(j<a[i].mx?a[i].suf[j]:0);
				res.suf[cnt/L-1]+=tmp;
			}
	per(i,res.mx-1,1){
		res.pre[i-1]+=res.pre[i];
		res.suf[i-1]+=res.suf[i];
	}
/*
	ll now=ans;
	printf("res = %lld\n",now-las);
	printf("ret = {%d, %d, { ",res.level,res.mx);
	for(auto x:res.pre)printf("%d ",x);
	printf("}, { ");
	for(auto x:res.suf)printf("%d ",x);
	puts("}}");
*/
	return res;
}

int main(){
	read(n),read(L),ans=n;
	rep(i,1,n)read(a[i]);
	a[n+1]=inf;
	rep(i,1,n){
		stk[++top]=node(a[i]);
		int flag=0;
		while(flag&&stk[top].level<inf||stk[top].level<a[i+1]){
			int cur=top;
			while(cur&&stk[cur].level==stk[top].level)
				cur--;
			stk[cur+1]=merge(stk+cur,top-cur);
			top=cur+1;
			stk[top].Assert();
			if(stk[top].level==inf)flag=1,top--;
		}
		if(flag)stk[++top].level=inf;
	}
	cout<<ans<<endl;
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char x, y;
  cin >> x >> y;
  if(x == y)cout << '=' << endl;
  else if(x > y) cout << '>' << endl;
  else cout << '<' << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b, h;
	std::cin >> a >> b >> h;
	std::cout << (a + b)*h / 2 << std::endl;
}

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

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

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){
	
	int a, b, x;
	cin >> x >> a >> b;
	x -= a;
	pr(x%b);

	return 0;
}

Measured memory_bytes: 256
import sys
N, M, K = list(map(int, input().split()))

A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_accum = [0] * (N+1)
b_accum = [0] * (M+1)

for i in range(len(A)):
    a_accum[i+1] = a_accum[i] + A[i]

for j in range(len(B)):
    b_accum[j+1] = b_accum[j] + B[j]


best = 0
j = len(B)
for i in range(len(a_accum)):

    if a_accum[i] > K:
        break

    while b_accum[j] + a_accum[i] > K:
        j -= 1

    best = max(best, i+j)

print(best)


Measured memory_bytes: 111172
#include<bits/stdc++.h>
using namespace std;
int a[3][105],dp[3][105],n;
int main()
{
    cin>>n;
    for(int i=1;i<=2;i++)
    {
        for(int j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }

    dp[1][1]=a[1][1];
    for(int i=1;i<=2;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=a[i][j]+max(dp[i][j-1],dp[i-1][j]);
        }
    }

    printf("%d\n",dp[2][n]);
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
"""Boxes and Candies

@author: Liz
@modified: 12-04-2016

"""


def readline(): return list(map(int, input().split()))

N, x = readline()
candies = readline()


def solve():

    count = 0

    for i in range(N - 1):

        stc = candies[i] + candies[i + 1]
        if stc > x:
            count += stc - x
            candies[i] += min(0, candies[i + 1] - (stc - x))
            candies[i + 1] = max(0, candies[i + 1] - (stc - x))

    return count

print(solve())


Measured memory_bytes: 14180
#include <iostream>
#include <math.h>
using namespace std; 
int main(void){
    string T;
  	cin >> T;
  		std::string t = "?";
 	while( T.find(t) != std::string::npos ){
		auto pos = T.find(t);
		auto len = t.length();
		if (pos != std::string::npos) {
  		T.replace(pos, len, "D");
		}
    }
  cout << T;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  cout << (n+m)*(n+m-1)/2-n*m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n = 0;  //地点の個数
    int t = 0;  //基準温度
    int a = 0;  //求める温度
    int h[1001] = {0};  //各地点の標高
    double th[1001] = {0};   //各地の平均気温
    double tmin = 10000;
    int ans = 0;
    cin >> n >> t >> a;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    for (int j = 0; j < n; ++j) {
        th[j] = t - h[j] * 0.006;
    }
    for (int k = 0; k < n; ++k) {
        double fmin = 0;
        fmin = th[k] - a;
        if(fmin < 0) fmin = fmin * -1;
        if(fmin <= tmin){
            tmin = fmin;
            ans = k + 1;
        }
    }
    cout << ans;
    return 0;
}

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

using P = pair<ll,ll>;
#define v first
#define w second

// v/w 高い順
bool comp1(P a, P b){
    return a.v*b.w > b.v*a.w;
}

// v高い順（vが同じならw軽い方優先）
bool comp(P a, P b){
    return a.v == b.v ? a.w < b.w : a.v > b.v;
}

int main(void){
    ll N,W;
    cin>>N>>W;
    vector<P> a(N);
    rep(i,N){
        ll v,w;
        cin>>v>>w;
        a[i] = {v,w};
    }
    sort(all(a),comp1);
    vector<P> dp = {{0,0}};

    rep(i,N){
        vector<P> tmp;
        for(auto& s : dp){
            tmp.push_back(s);
            tmp.push_back({s.v + a[i].v, s.w + a[i].w});
        }

        sort(all(tmp),comp);
        dp.clear();
        ll w_border = W+1;
        for(auto& s : tmp){
            if( w_border > s.w){
                w_border = s.w;
                dp.push_back(s);
            }
        }
        assert(dp.size() <= N*N*2);
    }
    cout<<dp[0].v<<endl;
    return 0;
}



Measured memory_bytes: 3220
#include<iostream>
using namespace std;
int main(){
  int a[100]={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;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }


int main(){
    ll n,a,b;
    cin >> n >>  a >> b;
    cout << min(a,b) << " " << max(a+b-n,0LL) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  rep(i,N) cin >> V[i];
  rep(i,N) cin >> C[i];
  int ans = 0;
  rep(i,N) {
    if (V[i] - C[i] > 0) ans += V[i] - C[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			String[] l = new String[n];
			int[] p = new int[n];
			int[] a = new int[n];
			int[] b = new int[n];
			int[] c = new int[n];
			int[] d = new int[n];
			int[] e = new int[n];
			int[] f = new int[n];
			int[] s = new int[n];
			int[] m = new int[n];
			for (int i = 0; i < n; i++) {
				l[i] = sc.next();
				p[i] = sc.nextInt();
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
				c[i] = sc.nextInt();
				d[i] = sc.nextInt();
				e[i] = sc.nextInt();
				f[i] = sc.nextInt();
				s[i] = sc.nextInt();
				m[i] = sc.nextInt();
			}
			int[] bef = new int[n];
			int[] aft = new int[n];
			for (int i = 0; i < n; i++) {
				bef[i] = a[i] + b[i] + c[i];
				aft[i] = d[i] + e[i];
			}
			int[] time = new int[n];
			int[] amount = new int[n];
			for (int i = 0; i < n; i++) {
				time[i] = bef[i] + m[i] * aft[i];
				amount[i] = m[i] * f[i] * s[i] - p[i];
			}
			double[] per = new double[n];
			for (int i = 0; i < n; i++)
				per[i] = (double) amount[i] / (double) time[i];
			int[] rank = new int[n];
			for (int i = 0; i < n; i++)
				rank[i] = 1;
			for (int i = 0; i < n; i++)
				for (int j = i + 1; j < n; j++) {
					if (per[i] > per[j])
						rank[j]++;
					if (per[i] < per[j])
						rank[i]++;
					if (per[i] == per[j]) {
						if (l[i].compareTo(l[j]) < 0)
							rank[j]++;
						if (l[i].compareTo(l[j]) > 0)
							rank[i]++;
					}
				}
			for (int i = 1; i < n + 1; i++)
				for (int j = 0; j < n; j++)
					if (rank[j] == i)
						System.out.println(l[j]);
			System.out.println("#");
		}
		sc.close();
	}
}

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

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

  for (int i = 0; i < m; i++) {
    int x; cin >> x;
    n -= x;
  }

  if (n < 0) {
    cout << -1 << endl;
  } else {
    cout << n << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	a, b := scanInt(), scanInt()
	if a <= 5 {
		fmt.Println(0)
		return
	} else if a <= 12 {
		fmt.Println(b / 2)
		return
	}
	fmt.Println(b)
}


Measured memory_bytes: 640
N=int(input())
to = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = [int(x) for x in input().split()]
    u -= 1
    v -= 1
    to[u].append([v, w])
    to[v].append([u, w])
ans = [-1] * N
ans[0] = 0
q = [0]
while(len(q) != 0):
    v = q.pop()
    for u, w in to[v]:
        if (ans[u] != -1): continue
        ans[u] = (ans[v]+w) % 2
        q.append(u)
for v in ans:
    print(v)


Measured memory_bytes: 82208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int bridge[51][51] = {0};
int visited[51];

void dfs(int n) {
  visited[n] = 1;
  rep(i, 1, 51) {
    if ( visited[i] ) continue;
    if ( bridge[i][n] == 0 ) continue;
    dfs(i);
  }
}

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

  int a[51], b[51];
  rep(i, 0, M) {
    scanf("%d %d", &a[i], &b[i]);
    bridge[a[i]][b[i]] = bridge[b[i]][a[i]] = 1;
  }

  int ans = 0;
  rep(i, 0, M) {
    bridge[a[i]][b[i]] = bridge[b[i]][a[i]] = 0;
    rep(j, 1, 51) visited[j] = 0;
    dfs(1);
    int ok = 1;
    rep(j, 1, N+1) {
      if ( visited[j] ) continue;
      ok = 0;
      break;
    }
    if ( ok == 0 ) ans++;
    bridge[a[i]][b[i]] = bridge[b[i]][a[i]] = 1;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
def main():
    MOD = 10**9 + 7
    n, a, b = map(int, input().split())
    
    def cmb(n, r):
        if n-r<r:
            r = n-r
        
        X, Y = (1, 1)
        for i in range(r):
            X = X*(n-i)%MOD
            Y = Y*(i+1)%MOD
        return X*pow(Y, MOD-2, MOD)
    
    base = pow(2, n, MOD)-1
    base -= cmb(n, a)
    base -= cmb(n, b)
    base %= MOD
    print(base)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
N=int(input())
X=[int(i) for i in input().split()]
#sum(Xi*Xi)-2sum(Xi)*P+N*P*P
A=sum([i*i for i in X])
B=sum(X)
ans=10**15
for P in range(101):
    tmp=A-2*B*P+N*P*P
    ans=min(ans,tmp)
print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<utility>
using namespace std;
int main() {

	int a, b;
	int result;

	cin >> a >> b;

	if (b>a)swap(a, b);

	while (a%b != 0) {
		int temp = a;
		a = b;
		b = temp%b;
		if (b>a)swap(a, b);
	}
	cout << b << endl;
	
	return 0;
}


Measured memory_bytes: 3120
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int mask[10] = {};
    int p[10] = {};
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;++i)
    {
        int k;
        int _mask = 0;
        cin >> k;
        for(int j=0;j<k;++j)
        {
            int tmp;
            cin >> tmp;
            _mask |= 1 << (tmp - 1);
        }
        mask[i] = _mask;
    }

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

    int ret = 0;
    for(int i=0;i<(1<<n);++i)
    {
        bool ok = true;
        for(int j=0;j<m;++j)
        {
            int lit = i & mask[j];
            int litCount = 0;
            while(lit > 0)
            {
                litCount += lit & 1;
                lit >>= 1;
            }
            if ((litCount % 2) != p[j])
            {
                ok = false;
                break;
            }
        }

        if (ok)
        {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main()
{
    string n;
  cin >>n;
  n=n[n.size()-1]=='3'?"bon":n[n.size()-1]=='0'||n[n.size()-1]=='1'||n[n.size()-1]=='6'||n[n.size()-1]=='8'?"pon":"hon";
    cout << n;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll b[4][4];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a, b;
	cin >> a >> b;
	a = a + b;
	stringstream e(a);
	ll x;
	e >> x;
	ll rad = sqrt(x);
	if (rad * rad == x)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<int> t(N), x(N), y(N);
	rep(i, 0, N) {
		cin >> t[i];
		cin >> x[i];
		cin >> y[i];
	}

	bool flag = true;
	if ((t[0] - x[0] - y[0]) % 2 != 0 || t[0] - x[0] - y[0] < 0)flag = false;
	else {
		rep(i, 1, N) {
			int T = t[i] - t[i - 1];
			int X = abs(x[i - 1] - x[i]);
			int Y = abs(y[i - 1] - y[i]);
			if ((T - X - Y) % 2 == 1 || T - X - Y < 0) {
				flag = false;
				break;
			}
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <string.h>
#include <set>

#define ll long long
#define pb push_back
//#define for(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()

using namespace std;

int main(void)
{
    ll a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    printf("%lld %lld %lld",c,a,b);
}


Measured memory_bytes: 256
/* ***********************************************
Author        :Winmer
Created Time  :2018年04月20日 星期五 21时58分44秒
File Name     :vj_lbq_sjjg_a.cpp
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
long long n,k,sum;
int main(){
    while(cin>>n>>k){
    sum=0;
        for(int i=k+1;i<=n;i++){
            sum+=(i-k)*(n/i);
            if(n%i>=k)sum+=(n%i)-k+1;
            if(k==0)sum--;
        }
        //if(k==0){sum-=n/;}
        //sum-=n-k+1;
        //sum+=n-k+1;
        cout<<sum<<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;

int n, a, b, c;
int l[8];
int ans = INT_MAX;

void solve(int cnt, int mp, int s, int t, int u){
  if(cnt == n){
    if(s!=0 && t!=0 && u!=0){
      ans = min(ans, mp+abs(s-a)+abs(t-b)+abs(u-c));
    }
    return;
  }
  solve(cnt+1, mp, s, t, u);
  if(s==0) solve(cnt+1, mp, s+l[cnt], t, u);
  if(s!=0) solve(cnt+1, mp+10, s+l[cnt], t, u);
  if(t==0) solve(cnt+1, mp, s, t+l[cnt], u);
  if(t!=0) solve(cnt+1, mp+10, s, t+l[cnt], u);
  if(u==0) solve(cnt+1, mp, s, t, u+l[cnt]);
  if(u!=0) solve(cnt+1, mp+10, s, t, u+l[cnt]);
  return;
}

int main(){
  cin >> n >> a >> b >> c;
  rep(i, n) cin >> l[i];
  solve(0, 0, 0, 0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i];
  }
  int lans = l[0];
  int rans = r[0];
  for (int i = 1; i < m; i++) {
    if (lans > r[i] || rans < l[i]) {
      cout << 0 << endl;
      return 0;
    }
    lans = max(lans, l[i]);
    rans = min(rans, r[i]);
  }

  cout << rans - lans + 1 << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int a, b, c;cin>>a>>b>>c;
  if(a==b)cout<<c<<endl;
  else if(b==c)cout<<a<<endl;
  else cout<<b<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var points = new int[2];
            for(var i = 0; i < n; ++i)
            {
                var a = Console.ReadLine().Split(' ');
                if(a[0] == a[1])
                {
                    points[0]++;
                    points[1]++;
                    continue;
                }
                var b = a.ToList(); b.Sort();
                if (a.SequenceEqual(b))
                    points[1] += 3;
                else
                    points[0] += 3;
            }
            Console.WriteLine($"{points[0]} {points[1]}");
        }
    }
}


Measured memory_bytes: 19108
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

r, g, b = map(int, readline().split())

print('YES' if (100 * r + g * 10 + b) % 4 == 0 else 'NO')


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=100010;
int a[N],b[N],ld,d[N];
int main(){
	int n=read(),ans=0;
	ll suma=0,sumb=0;
	for (int i=1;i<=n;++i) a[i]=read(),suma+=a[i];
	for (int i=1;i<=n;++i) b[i]=read(),sumb+=b[i];
	if (suma<sumb){
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;++i){
		if (a[i]<b[i]) ++ans;
		if (a[i]>b[i]) d[++ld]=a[i]-b[i],++ans;
	}
	sort(d+1,d+ld+1);
	suma-=sumb;
	for (int i=1;i<=ld;++i){
		if (suma<d[i]) break;
		suma-=d[i],--ans;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b<=0){
    cout<<"No"<<endl;
    return 0;
  }else{
    if(a*a+b*b+c*c-2*(a*b+b*c+c*a)>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll t(n+1, 0), x(n+1, 0), y(n+1, 0);
    repr(i, 1, n+1){
        cin >> t[i] >> x[i] >> y[i];
    }
    repr(i, 1, n+1){
        ll need = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        ll time = t[i]-t[i-1];
        if(!(need <= time && (time-need)%2 == 0)){
            pr(0);
        }
    }
    pr(1);
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] argv) {
        Scanner scanner = new Scanner(System.in);

        String line = scanner.nextLine();

        boolean strongPalindrome = false;
        if (isPalindrome(line)) {
            if (isPalindrome(line.substring(0, (line.length() - 1 )/ 2))){
                strongPalindrome = true;
            }
        }

        System.out.println(strongPalindrome ? "Yes" : "No");

    }

    private static boolean isPalindrome(String s) {
        String reverse = new StringBuilder(s).reverse().toString();
        return s.equals(reverse);
    }
}

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

int main(int, char**) {
        int A, B;
        std::cin >> A >> B;
        for (int i=1; i<=1000; i++) {
                int a = int(i * 0.08);
                int b = int(i * 0.1);
                if (a==A && b==B) {
                        std::cout << i << std::endl;
                        return 0;
                }
        }
        std::cout << "-1" << std::endl;
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    if(p+q <= p+r && p+q <= q+r) {
        printf("%d\n",p+q);
    }else if(p+r <= p+q && p+r <= q+r) {
        printf("%d\n",p+r);
    }else if(q+r <= p+q && q+r <= p+r) {
        printf("%d\n",q+r);
    }
    return 0;
}



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

using namespace std;

void update_cnt(int &cnt_max, int &cnt_tmp);
void compare_cnt(int &cnt_max, int &cnt_tmp);

int main()
{

	int cnt = 0;
	int cnt_R = 0;
	
	std::string buf;
	std::cin >> buf;

	for (int i = 0; i < buf.length(); i++)
	{
		if ('R' == buf[i])
		{
			cnt_R++;
			update_cnt(cnt, cnt_R);
		}
		else if('S' == buf[i] )
		{
			compare_cnt(cnt, cnt_R);
		}
		else
		{
			compare_cnt(cnt, cnt_R);
		}
	}

	std::cout << cnt << std::endl;
	return 0;

}

void update_cnt(int &cnt_max, int &cnt_tmp)
{
	if (cnt_max < cnt_tmp)
	{
		cnt_max = cnt_tmp;
	}
}

void compare_cnt(int &cnt_max, int &cnt_tmp)
{
	if (cnt_max < cnt_tmp)
	{
		cnt_max = cnt_tmp;
	}
	cnt_tmp = 0;
}

Measured memory_bytes: 3552
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,str2;
    ll x;
    cin>>x;
    set<ll> s;
    while(1){
        a=s.size();
        s.insert(x);
        if(a==s.size()) {cout<<f+1<<endl;return 0;}
f++;

        if(x%2){
            x=3*x+1;
        }else{
            x=x/2;
        }
 //       cout<<x<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>

int main()
{
  char S[100000];
  int i,o_w=0,o_b=0,e_w=0,e_b=0, obew,oweb,N=0;
  scanf("%s",S);
  for(i=0;S[i] != '\0';i++){
    N++;
    /*printf("%c\n",S[i]);*/
    if(i%2==0){
      if(S[i]=='0'){
        e_b++;
      }else{
        e_w++;
      }
    }else{
      if(S[i]=='0'){
        o_b++;
      }else{
        o_w++;
      }
    }
  }
  
  oweb = (N+1)/2 - o_b + N/2 - e_w;
  obew = (N+1)/2 - o_w + N/2 - e_b;
  /*printf("%d %d %d %d %d\n",N,o_b,o_w,e_b,e_w);*/
  if(oweb<obew){
    printf("%d",oweb);
  }else{
    printf("%d",obew);
  }
  
  return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[100000],n,m,t,p;
int main(){
	cin>>n>>m>>t;
	for(int i=0;i<n;i++){cin>>p;a[p-m]++;a[p+m]--;}
	for(int i=1;i<t;i++)a[i]+=a[i-1];
	int cnt=0;for(int i=0;i<t;i++){if(a[i]==0)cnt++;}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3088