akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

Int comb[50][50];

int main() {
  comb[0][0] = 1;
  for (int i = 1; i < 50; ++i) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
    }
  }

  vector<pair<Int, int>> X;
  for (int n = 1; n <= 40; ++n) {
    for (int k = 1; n + k <= 40; ++k) {
      for (int m = 0; m <= 40; ++m) {
        Int r = 0;
        for (int a = 2; a <= n + k; a += 2) {
          r += comb[n + k][a];
        }
        for (int b = 2; b <= m; b += 2) {
          r += comb[m][b];
        }
        for (int a = 1; a <= min(n, k); ++a) {
          for (int b = 1; b <= m / 2; ++b) {
            r += (comb[n][a] * comb[m / 2][b]) * (comb[k][a] * comb[m - m / 2][b]);
          }
        }
        if (r > 1000000000000LL) {
          break;
        }
        X.emplace_back(r, -((n + k + m) * 1000000 + n * 10000 + k * 100 + m));
      }
    }
  }
  sort(X.begin(), X.end());

  Int N = lin();
  int A = 1;
  vector<int> ans;
  while (N > 0) {
    auto it = upper_bound(X.begin(), X.end(), make_pair(N, INF));
    --it;

    N -= it->first;
    int n = -it->second % 1000000 / 10000, k = -it->second % 10000 / 100, m = -it->second % 100;
    for (int i = 0; i < n; ++i) {
      ans.push_back(A);
    }
    for (int i = 0; i < m / 2; ++i) {
      ans.push_back(A + 1);
    }
    for (int i = 0; i < k; ++i) {
      ans.push_back(A);
    }
    for (int i = 0; i < m - m / 2; ++i) {
      ans.push_back(A + 1);
    }
    A += 2;
  }

  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d%c", ans[i], i+1 == ans.size() ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int x,y,s;
	int a[1005],b[1005],ans=0;
	while(true){
		cin>>x>>y>>s;
		if(x+y+s==0) return 0;
		for(int i=1;i<s;i++){
			a[i] = i;
			for(int j=1;j<s;j++){
				b[i] = j;
				if((a[i]*100+a[i]*x)/100 + (b[i]*100+x*b[i])/100 == s) break;
				if(j==s-1){
					a[i]=0;
					b[i]=0;
				}
			}
			//cout<<i<<endl;
			//cout<<a[i]<<" "<<b[i]<<endl;
		}
		for(int i=1;i<s;i++){
			ans=max(ans,(a[i]*100+a[i]*y)/100+(b[i]*100+y*b[i])/100);		
		}
		cout<<ans<<endl;
		ans=0;
	}
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, t;
    cin >> n >> t;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int res = t;
    for (Int i = 0; i < n - 1; i++) {
        res += min(t, a[i + 1] - a[i]);
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main()
{
	while(1)
	{
		int n;
		int up=1,front=2,right=3;
		scanf("%d",&n);
		int ans=1;
		if(n==0) break;
		for(int i=0;i<n;i++)
		{
			string query;
			cin>>query;
			int up_=up,front_=front,right_=right;
			if(query=="North")
			{
				up=front_,front=7-up_,right=right_;
			}
			else if(query=="East")
			{
				up=7-right_,front=front_,right=up_;
			}
			else if(query=="West")
			{
				up=right_,front=front_,right=7-up_;
			}
			else if(query=="South")
			{
				up=7-front_,front=up_,right=right_;
			}
			else if(query=="Right")
			{
				up=up_,front=right_,right=7-front_;
			}
			else if(query=="Left")
			{
				up=up_,front=7-right_,right=front_;
			}
			ans+=up;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll N; cin >> N;
    vector<ll> h;
    REP(i, N){
        ll h_i; cin >> h_i;
        h.PB(h_i);
        }
    vector<ll> dp(N, INF);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    REP(i, N){
        if (i == 0 || i == 1){
            continue;
        }
        dp[i] = min(dp[i - 2] + abs(h[i-2] - h[i]), dp[i - 1] + abs(h[i-1] - h[i]));
        // cout << dp[i] << endl;
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 4960
#!/usr/bin/env python3
import sys


def solve(N: int, L: int):
    a = tuple(range(L, L+N))
    return sum(a) - min(a, key=abs)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    print(solve(N, L))

if __name__ == '__main__':
    main()


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

int n;
int a, b;
int p1, p2, p3;

int main()
{
    scanf("%d", &n);
    scanf("%d %d", &a, &b);
    for (int i = 0; i < n; i++) {
        int p; scanf("%d", &p);
        if (p <= a) p1++;
        else if (p <= b) p2++;
        else p3++;
    }
    printf("%d\n", min(min(p1, p2), p3));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<P> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i].second >> v[i].first;
    }
    sort(v.begin(), v.end());
    ll now = 0;
    for (int i = 0; i < N; i++) {
        ll now_a = v[i].second;
        ll now_b = v[i].first;
        if (now + now_a <= now_b) {
            now += now_a;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
 
#define db(x) cout << "> " << #x << ": " << x << endl;
 
const int N = 200100;
using namespace std;
 
int pos[N];
long long pre_sum[N];
 
inline bool desc(const int &a, const int &b) { return (a > b); }
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	long long x;
	cin >> n >> x;
	
	for(int i = 1; i <= n; i++)
		cin >> pos[i];
	
	sort(pos +1, pos +n +1, desc);
	
	for(int i = 1; i <= n; i++)
		pre_sum[i] = pre_sum[i -1] +pos[i];
	
	long long res = (1ll << 62);
	for(int trips = 1; trips <= n; trips++)
	{
		// cost to pickup and drop
		long long curr_res = 1ll *n *x +1ll *trips *x;
		
		int multiplier = 5;
		int l = 1, r = min(trips +trips, n);
		
		while(l <= n)
		{
			curr_res += 1ll *multiplier *(pre_sum[r] -pre_sum[l -1]);
			multiplier += 2;
			
			// Avoid possible overflow?
			if(curr_res > res)
				break;
					
			l = r +1;
			r = min(r +trips, n);
		}
		
		res = min(res, curr_res);
	}
	
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input! {
        n: i64,
        m: i64,
    }
    println!("{}", ((n - 2) * (m - 2)).abs());
}


Measured memory_bytes: 4352
#include <cassert>
#include <cstdio>
using namespace std;

const int B = 1 << 7;
const int sz = 201010 / B * B;

int a[sz];
int b[sz];

int main() {
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        scanf("%d", a + i);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", b + i);
    }
    int ans = 0;
    if(N & 1) {
        for(int i = 0; i < N; i++) {
            ans ^= a[i];
            ans ^= b[i];
        }
    }
    for(int i = 0; i < sz; i += B) {
        for(int j = 0; j < sz; j += B) {
            int lim_i = i + B;
            int lim_j = j + B;
            for(int ii = i; ii < lim_i; ii++) {
                for(int jj = j; jj < lim_j; jj++) {
                    ans ^= (a[ii] + b[jj]);
                }
            }
        }
    }
    printf("%d\n", ans);
}

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

int main() {
  int n;
  std::cin >> n;
  int a, odd = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a;
    if (a % 2 == 1) {
      odd++;
    }
  }
  if (odd % 2 == 0) {
    std::cout << "YES" << std::endl;
  }
  else {
    std::cout << "NO" << std::endl;
  }
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

n, q = map(int, input().split())
tmp = list(map(int, input().split()))
color = [-1]
for v in tmp:
    color.append(v)
qry = [None]*q
ans = [0]*q
p = 0
for _ in ans:
    l, r = map(int, input().split())
    qry[p] = [l-1, r, p]
    p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 1
bit = Bit(n)
for l, r, i in qry:
    if last_update_idx < r+1:
        st = set()
        for j in range(last_update_idx, r+1):
            if not color[j] in st and color[j] in dic:
                bit.add(dic[color[j]], -1)
            dic[color[j]] = j
            st.add(color[j])
        for v in st:
            bit.add(dic[v], 1)
        last_update_idx = r+1
    ans[i] = bit.sum(r) - bit.sum(l)
for v in ans:
    print(v)


Measured memory_bytes: 225464
#include<cstdio>
#include<cfloat>
#include<cmath>
#include<vector>
#include<queue>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;

const int MAX_N = 1001;
const double EPS = 1e-6;

typedef pair<double, int>P;	//<distance, index>
vector<vector<P> >edge(MAX_N);

#define Square(x) ((x)*(x))

double Distance(int x1, int x2, int y1, int y2)
{
	return sqrt((double)Square(x1-x2)+Square(y1-y2));
}

vector<int> Solve(int s, int g)
{
	//_CNXg@ÅA¸_s©ç¼ÌSÄÌ¸_ÜÅKvÈÅZ£ðßé
	double dist[MAX_N];	//dist[i] := ¸_iÉ½Çè­ÜÅÉKvÈÅZ£
	fill(dist, dist+MAX_N, DBL_MAX);

	typedef pair<double, int> P;	//<»Ì¸_ÜÅÌ£,¡¢é¸_>
	priority_queue<P, vector<P>, greater<P> >q;
	q.push(P(0,s));
	while(!q.empty())
	{
		P p(q.top());
		q.pop();

		double d = p.first;
		int id = p.second;
		if(dist[id] <= d)
			continue;
		dist[id] = d;

		for(int i=0; i<edge[id].size(); ++i)
			q.push(P(d+edge[id][i].first, edge[id][i].second));
	}

	//Bs\Å é
	if(dist[g] == DBL_MAX)
		return vector<int>();

	//oHðAS[©çX^[gÖü¯ÄAtÉ³
	vector<int> res;
	res.push_back(g);
	for(int id=g; id!=s; )
	{
		for(int i=0; i<edge[id].size(); ++i)
		{
			if( (dist[edge[id][i].second]+edge[id][i].first - dist[id]) < EPS )
			{
				id = edge[id][i].second;
				res.push_back(id);
				break;
			}
		}
	}
	return res;
}

int main()
{
	int n,b,x[MAX_N],y[MAX_N],m,s,g;
	int i,j;
	vector<int>id;
	while(scanf("%d",&n),n)
	{
		id.clear();
		for(i=0; i<n; ++i)
			edge[i].clear();
		for(i=0; i<n; ++i)
		{
			scanf("%d",&b);
			scanf("%d%d",&x[b],&y[b]);
			id.push_back(b);
		}
		
		//Ú®Â\È¸_¯mÉÓð\é
		for(i=0; i<id.size(); ++i)
		{
			for(j=i+1; j<id.size(); ++j)
			{
				int i1 = id[i];
				int i2 = id[j];
				double distance = Distance(x[i1],x[i2],y[i1],y[i2]);
				if( distance<=50 )
				{
					edge[i1].push_back(P(distance,i2));
					edge[i2].push_back(P(distance,i1));
				}
			}
		}

		vector<int> res;
		scanf("%d",&m);
		while(m--)
		{
			scanf("%d%d",&s,&g);
			res = Solve(s,g);
			if(res.empty())
				puts("NA");
			else
			{
				for(int i=res.size()-1; i>=0; --i)
					printf("%d%c",res[i], (i?' ':'\n'));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int y,z;
	cin>>y>>z;
	if(y>z)
	{
		int temp=y;
		y=z;
		z=temp;
	}
	int ans = (z-y-1)*(z-y)/2;
	ans-=y;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  int min, mid, max;
  min = a[0];
  mid = a[1];
  max = a[2];
  int cnt = 0;
  cnt = max - mid;
  min += cnt;
  mid += cnt;
  if((max % 2) == (min % 2)){
    cnt += (max-min)/2;
  }else{
    cnt += ((max+1) - min)/2 + 1;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
string = str(input())
n = int(input())
conversion = [input().split() for i in range(n)]

for conv in conversion:
    func = conv[0]
    if func == "replace":
        a, b, p = int(conv[1]), int(conv[2])+1, conv[3]
        string = string[:a] + p + string[b:]
    else:
        a, b = int(conv[1]), int(conv[2]) + 1
        if func == "print":
            print(string[a:b])
        else:
            string = string.replace(string[a:b], string[a:b][::-1])



Measured memory_bytes: 5628
import java.util.Scanner;

public class Main {

	private static final int MAX = 10000000;
	private static final long[] fac = new long[MAX];
	private static final long[] finv = new long[MAX];
	private static final long[] inv = new long[MAX];
	private static final int MOD = 1_000_000_007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		int a=2*x-y,b=2*y-x;

		if(a<0||b<0||a%3+b%3>0) {
			System.out.println(0);
			return;
		}
		a/=3;
		b/=3;
		COMinit();
		System.out.println(COM(a+b,Math.min(a,b)));

	}

	private static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[0] = inv[1] = 1;
		for(int i = 2;i < MAX;i++) {
			fac[i] = fac[i-1] * i %MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] %MOD;
		}
	}
	private static long COM(int n,int k) {
		if(n < k) {
			return 0;
		}
		if(n < 0 || k < 0) {
			return 0;
		}
		return fac[n] * (finv[k] * finv[n-k] % MOD)%MOD;
	}
}


Measured memory_bytes: 258388
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long n, x, y;
    cin >> n >> x >> y;

    x--;
    y--;

    vector<long long> result(n ,0);

    for(long long i = 0; i < n; i++){
        for(long long j = i+1; j < n; j++){
            long long k = min(abs(i-j), abs(i-x)+1+abs(y-j));
            result[k]++;
        }
    }

    for(long long k = 1; k < n; k++){
        cout << result[k] << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
S = list(input())
T = list(input())
A = []
count = 0

for x in range(0, len(S)-len(T)+1):
    for y in range(0, len(T)):
        if(S[x+y] != T[y]):
            count += 1
        else:
            pass
    A.append(count)
    count = 0

print(min(A))

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

using namespace std;

int n;

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		int cnt=1;
		for(int i=2;i*i<=n;i++){
			if(n%i==0){
				cnt+=i;
				if(n/i!=i)cnt+=n/i;
			}
		}
		if(n==1)cnt=0;
		if(cnt<n)puts("deficient number");
		if(cnt==n)puts("perfect number");
		if(cnt>n)puts("abundant number");
	}
	return 0;
}

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

int main() {
    long long N;
    long long A[5];
    cin>>N;
    for(int i=0;i<5;i++)cin>>A[i];
    long long min=A[0];
    for(int i=1;i<5;i++){
        if(min>A[i])min=A[i];
    }
    if(min>=N){
        cout<<5<<endl;
        return 0;
    }
    long long ans=5;
    N-=min;
    ans+=N/min;
    if(N%min>0)ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	string s; cin >> s;
	int ans = (int)1e9;
	for (char c = 'a'; c <= 'z'; c++) {
		int cnt = 0, tmp = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != c)tmp++;
			else { cnt = max(cnt, tmp); tmp = 0; }
		}
		cnt = max(cnt, tmp);
		ans = min(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int sum1=0,sum2=0,sum3=0,sum4=0;
  for(int i=0;i<6;i++){
    int a;
    cin>>a;
    if(a==1)sum1++;
    if(a==2)sum2++;
    if(a==3)sum3++;
    if(a==4)sum4++;
  }
  if(sum1*sum2*sum3*sum4==4){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
  
}

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

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  set<int> nums;
  for(int i = a; i <= min(b, a + k - 1); i++){
    nums.insert(i);
  }
  for(int i = max(a, b - k + 1); i <= b; i++){
    nums.insert(i);
  }
  for(auto itr = nums.begin(); itr != nums.end(); itr++){
    cout << *itr << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;

const int N = 5000;
int n, m;
map<string, int> a;
int x[N], vstd[N];

typedef pair<int, int> P;

typedef struct edge_def {
  int from; int to; int cost;
  edge_def(int _from, int _to, int _cost) {
   from = _from; to = _to; cost =_cost;
  }
} edge;

vector<edge> es[N];

int dijkstra(int s) {
  priority_queue<P,vector<P>, greater<P> > q;
  
  int cnt = 1;
  int mx  = x[s];

  vstd[s] = 1;
  q.push(P(0, s));
  while(q.size()) {
    P p = q.top(); q.pop();
    int v = p.second;
    for (int i=0; i<(int)es[v].size(); i++) {
      edge e = es[v][i];
      if (!vstd[e.to]) {
        mx = min(mx, x[e.to]);
        q.push(P(0, e.to));
        vstd[e.to] = 1;
        cnt++;
      }
    }
  }
  return mx * cnt;
}

int main() {
  int i;
  for (i=0; i<N; i++) es[i].clear();
  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    string s; int v;
    cin >> s >> v;
    a[s] = i;
    x[i] = v;
  }
  
  scanf("%d ", &m);
  for (i=0; i<m;i++) {
    string f, t;
    cin >> f >> t;
    int fidx = a[f];
    int tidx = a[t];
    es[fidx].push_back(edge(fidx, tidx, 0));
    es[tidx].push_back(edge(tidx, fidx, 0));
  }
  
  memset(vstd, 0, sizeof(vstd));
  int res = 0;
  for (i=0; i<n; i++)
    if (!vstd[i]) res += dijkstra(i);
 
  printf("%d\n", res);

  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#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...);
}
#define ll long long
const ll mod = 998244353;
const int N = 2e5 + 15;
ll fact[N], ifact[N];

template <typename T> T mod_pow(T a, T b, T m) {
	T ans = 1;
	while(b) {
        if(b&1)ans=(ans*a)%m;
        a=(a*a)%m;
        b=b/2;
    }
    return ans;
}
template <typename T> T mod_inv (T a, T m) {
	return mod_pow(a, m - 2, m);
}
template <typename T> T mod_div (T a, T b, T m) {
	return a * mod_inv(b, m) % m;
}
ll nCr(int n, int r) {
	ll ans = fact[n];
	ans = (ans * ifact[n-r]) % mod;
	ans = (ans * ifact[r]) % mod;
	return ans;
}
int main(){
	fact[0] = 1;
	ifact[0] = mod_inv(fact[0], mod);
	for (int i = 1; i < N; ++i) {
		fact[i] = (i*fact[i-1])%mod;
		ifact[i] = mod_inv(fact[i], mod);
	}
	int n, m, k;
	cin >> n >> m >> k;
	ll ans = 0;
	for (int p = n - k; p <= n; ++p) {
		ll cur = nCr(n - 1, p - 1)*m;
		cur %= mod;
		cur *= mod_pow(m - 1ll, p - 1ll, mod);
		cur %= mod;
		ans += cur;
		ans %= mod;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 6776
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;


int main(void){
    int x;
    cin >> x;
    if (x>=30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3616
import numpy as np
from collections import Counter

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.arange(N) + 1

s = A + B
m = B - A

s_ct = Counter(s)
m_ct = Counter(m)

ans = 0
for i in s_ct:
    ans += s_ct[i] * m_ct[i]

print(ans)




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

int main(){
	int N;
	double ans = 0.0, A;
	cin >> N;
	for(int i = 1; i <= N; ++i){
		cin >> A;
		ans += 1.0 / A;
	}
	ans = 1.0 / ans;
	cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 3772
from collections import deque
K = int(input())
que = deque([1,2,3,4,5,6,7,8,9])

for i in range(K):
    v = que.popleft()
    if v%10!=0:
        que.append(10*v+v%10-1)
    que.append(10*v+v%10)
    if v%10!=9:
        que.append(10*v+v%10+1)
print(v)

Measured memory_bytes: 11908
#include <stdio.h>

int main()
{
    int cnt, a, b, c, max;
    int i = 0;
    
    scanf("%d",&cnt);
    
    for (i; i < cnt; i++) {
	    scanf("%d %d %d",&a,&b,&c);

        max = a;
        if(b > max) max = b;
        if(c > max) max = c;
    
        if (max == a) {
            if (a*a == b*b+c*c) {
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        } else if (max == b) {
            if (b*b == a*a+c*c) {
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        } else {
            if (c*c == a*a+b*b) {
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 580
S=input()
A=int(S[:2])
B=int(S[2:])

if 1<=A<=12 and 1<=B<=12:
    print("AMBIGUOUS")

elif 1<=A<=12:
    print("MMYY")
elif 1<=B<=12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<cstdio>
#define MN 200000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,a[MN+5],b[MN+5];
int Solve(int x)
{
	for(int i=1;i<n<<1;++i) b[i]=a[i]>=x;
	if(b[n]==b[n-1]||b[n]==b[n+1]) return b[n];
	int l=0,r=n*2;
	for(int i=n-2;i;--i) if(b[i]==b[i+1]) {l=i;break;} 
	for(int i=n+2;i<n<<1;++i) if(b[i]==b[i-1]){r=i;break;}
	if(l==0&&r==n*2) return b[n]^(~n&1);
	else return (n-l<=r-n)?b[l]:b[r]; 
}
int main()
{
	n=read();if(n==2) return 0*puts("2");
	for(int i=1;i<n<<1;++i) a[i]=read();
	int l=1,r=2*n-1,mid,res;
	while(l<=r)
	{
		mid=l+r>>1;
		if(Solve(mid)) res=mid,l=mid+1;
		else r=mid-1;
	}
	cout<<res;
	return 0;
}



Measured memory_bytes: 1792
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut sum = vec![0; n + 1];
    let mut ans = vec![];
    for i in (2..n + 1).rev() {
        if (sum[i] & 1) ^ v[i - 1] == 1 {
            ans.push(i);
            sum[1] += 1;
            let mut j = 2;
            while j * j < i {
                if i % j == 0 {
                    sum[j] += 1;
                    sum[i / j] += 1;
                }
                j += 1;
            }
            if j * j == i {
                sum[j] += 1;
            }
        }
    }
    if (sum[1] & 1) ^ v[0] == 1 {
        ans.push(1);
    }
    println!("{}", ans.len());
    if ans.len() == 0 {
        return;
    }
    print!("{}", ans[0]);
    for &a in &ans[1..] {
        println!(" {}", a);
    }
    println!("");
}


Measured memory_bytes: 9340
def dif (s,t):
    ans=0
    for i in range(len(s)):
        if s[i]!=t[i]:
            ans+=1
    return ans
s=input()
t=input()
k=len(t)
ans=99999999999999999
for i in range(len(s)-k+1):
    a=s[i:i+k]
    b=dif(a,t)
    ans=min(ans,b)
print (ans)

Measured memory_bytes: 9064
import sys
from heapq import heapify, heappop
from bisect import bisect_left, bisect_right, insort_left
read=sys.stdin.read
readline=sys.stdin.readline

def main():
    n=int(readline())
    t,v=(list(map(int,l.split())) for l in read().splitlines())
    vi=[(x,i+1) for i,x in enumerate(v)]
    x=[0]*(n+2)
    y=[0]*(n+1)
    x[0]=0
    y[0]=0
    y[-1]=0
    for i in range(1,n+1):
        x[i]=x[i-1]+t[i-1]
    x[n+1]=x[n]
    heapify(vi)
    ans=0
    v=[0]+v+[0]
    memo=[0,n+1]
    while vi:
        e=heappop(vi)
        insort_left(memo,e[1])
        idx=bisect_left(memo,e[1])
        _i=memo[idx-1]
        i_=memo[idx+1]
        i=memo[idx]
        sx=x[_i]
        gx=x[i_-1]
        sy=y[_i]
        gy=y[i_-1]
        h=e[0]
        y[i]=min(h,gx-x[i]+gy,x[i]-sx+sy)
        y[i-1]=min(h,gx-x[i-1]+gy,x[i-1]-sx+sy)
        dw=gx-sx
        dh=abs(gy-sy)
        be=max(0,dw-(2*max(v[_i],v[i_])-sy-gy))
        ht=min(h-v[_i],h-v[i_],be/2)
        te=max(0,be-2*ht)
        ans+=(te+be)*ht/2
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll k;cin>>k;
    ll ans=0;
    REP(i,1,k+1)REP(j,1,k+1)REP(t,1,k+1)ans+=gcd(i,gcd(j,t));
    out(ans);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
typedef complex<double> base;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double
 
#define x first
#define y second
 
int block=700;
bool cmp(pair<pair<int,int>,int> p, pair<pair<int,int>,int> q) {
    if (p.first.first / block != q.first.first / block)
        return p < q;
    return (p.first.first / block & 1) ? 
        (p.first.second < q.first.second) : (p.first.second > q.first.second);
}
 
int clrs[1000007];
int32_t main() 
{
    IOS
    int n,qq;
    cin>>n>>qq;
    int arr[n+2]={};
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    vector<pair<pair<int,int>,int>>v;
    for(int i=0;i<qq;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({{a,b},i});
    }
    sort(v.begin(),v.end(),cmp);
    int ans[qq+2]={};
    int cur_l = 1;
    int cur_r = 0;
    int sum=0;
    for(auto q:v)
    {
        while (cur_l > q.x.x) 
        {
            cur_l--;
            clrs[arr[cur_l]]++;
            if(clrs[arr[cur_l]]==1)
                sum++;
        }
        while (cur_r < q.x.y) 
        {
            cur_r++;
            clrs[arr[cur_r]]++;
            if(clrs[arr[cur_r]]==1)
                sum++;
        }
        while (cur_l < q.x.x) 
        {
            clrs[arr[cur_l]]--;
            if(clrs[arr[cur_l]]==0)
                sum--;
            cur_l++;
        }
        while (cur_r > q.x.y) 
        {
            clrs[arr[cur_r]]--;
            if(clrs[arr[cur_r]]==0)
                sum--;
            cur_r--;
        }
        ans[q.y] = sum;
    }
    for(int i=0;i<qq;i++)
        cout<<ans[i]<<endl;
}   

Measured memory_bytes: 27384
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N,K;
	scanf("%d %d", &N,&K);
	int *h = new int[N];
	for (int i = 0; i < N; i++) scanf("%d", h + i);
	int res = 0;
	for (int i = 0; i < N; i++) {
		if (h[i] >= K)res++;
	}
	printf("%d", res);
	return 0;
}

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

int main()
{
  string o,e,ans="";

  cin >> o;
  cin >> e;

  for (int i=0;i<o.length();i++) {
    ans+=o[i];
    if (i<e.length()) {
      ans+=e[i];
    }
  }

  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;

int main(){
    int N;
    int K;
    cin >> N >> K;
    vector<ll> list(N+5);
    ll sum = 0;
    rep(i,N){
        ll tmp;
        cin >> tmp;
        list.push_back(tmp);
    }
    sort(list.begin(),list.end(),greater<ll>());
    for (int i = K; i < list.size(); i++){
        sum += list[i];
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X.at(i);
  
  int ans = 1000000000;
  for (int i = 0; i <= N - K; i++) {
    int D = X.at(i + K - 1) - X.at(i) + min(abs(X.at(i + K - 1)), abs(X.at(i)));
    ans = min(ans, D);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

typedef struct{
  vector<int> edge;
  int index=0;
  int num=0;
}vertex;
vector<vertex>G;
int N;
int ind=0;

bool comp(vertex &l, vertex &r){
  if(l.edge.size() == r.edge.size()) return l.index > r.index;
  return l.edge.size() > r.edge.size();
}
bool comp2(vertex &l, vertex &r){
  return l.index < r.index;
}

ll bfs(int cur,vector<int> &c){
  queue<int> que;
  que.push(cur);
  ll ans = 0;
  while(!que.empty()){
    int v = que.front();que.pop();
    G[v].num = c[ind];
    ind++;
    int i;REP(i,G[v].edge.size()){
      if(G[G[v].edge[i]].num != 0) ans += G[v].num;
      else que.push(G[v].edge[i]);
    }
  }
  return ans;
}

int main(void){
  cin >> N;
  G.resize(N);
  vector<int> c(N);
  ll ans = 0;
  int index = 0;
  int i;REP(i,N-1){
    int f,t;
    cin >> f >> t;
    f--;t--;
    G[f].edge.push_back(t);
    G[t].edge.push_back(f);
  }
  REP(i,N){
    cin >> c[i];
    G[i].index = i;
    if(G[i].edge.size() > G[index].edge.size())index = i;
  }
  sort(c.begin(),c.end(),greater<int>());
  ans = bfs(index,c);

  cout << ans << endl;
  REP(i,N) cout << G[i].num << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,x=0,a=0,b=0,z=0;
    cin>>n;
    vector<char> s(n),t(n);
    rep(i,n) cin>>s[i],t[i]=s[i];
    while(x!=s.size()){
        x=s.size();
        rep(i,s.size()-1){
          if(s.size()==2&&s[0]=='('&&s[1]==')'){z=1;break;}
          if(s[i]=='('&&s[i+1]==')') s.erase(s.begin()+i,s.begin()+i+2);
        }
    }
  if(z) rep(i,t.size()) cout<<t[i];
  else{
    rep(i,s.size()){
        if(s[i]==')') a++;
        else b++;
    }
    rep(i,a) cout<<"(";
    rep(i,t.size()) cout<<t[i];
    rep(i,b) cout<<")";
  }
}

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

int solve(int E)
{
    int ans=E;
    int x;
    for(int z=0;z*z*z<=E;z++)
       for(int y=0;y*y<=E-z*z*z;y++)
       {
           x=E-y*y-z*z*z;
           ans=min(ans,x+y+z);
       }
    return ans;
}

int main()
{
    int E;
    while(cin >> E && E>0)
         cout << solve(E) << endl;
}


Measured memory_bytes: 3116
#include<cstdio>
int abs(int x) {
	return (x>0)?x:-x;
}
int n,k;
int gcd(int a,int b) {
	return (b==0)?a:gcd(b,a%b);
}
int main()
{
	int x,G;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&x);
		if(i==1) G=abs(x-k);
		else G=gcd(G,abs(x-k));
	}
	printf("%d",G);
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define N 100000

int CanLay(int n, int k, int m, int weight[]);

int main(){
  
  int i,n,k;
  int weight[N];
  int l,m,r;
  
  scanf("%d %d",&n,&k);
  
  for(i=0;i<n;i++){
    scanf("%d",&weight[i]);
  }
  
  l = 0;
  r = 10000*n/k;
  
  while(1){
    m = (l + r) / 2;
    if(l == m) break;
    if(CanLay(n, k, m, weight)) r = m;      
    else l = m;
  }
  printf("%d\n", r);
  
  return 0;
}


int CanLay(int n, int k, int m, int weight[]){
  
  int i;
  int sum = 0;
  int num = 1;
  
  for(i = 0; i < n; i++){
    if(weight[i] > m) return 0;
    sum += weight[i];
    if(sum > m){
      sum = weight[i];
      num++;
    }
  }
  if(num <= k) return 1;
  
  else return 0;
}

Measured memory_bytes: 988
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef vector<xy_t> polygon;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<string, int> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

bool ok(char a, char b){
	if(a == '(' && b == ')') return true;
	if(a == ')' && b == '(') return true;
	if(a == '{' && b == '}') return true;
	if(a == '}' && b == '{') return true;
	if(a == '[' && b == ']') return true;
	if(a == ']' && b == '[') return true;
	return false;
}

int main(){
	string s,s2;
	cin >> s;
	int c, m, ind, l, r;
	int res = 0;
	int n = s.size();
	for(int i = 0; i < (1 << n); i++){
		s2.clear();
		for(int j = 0; j < n; j++){
			if(i & ( 1<< j)) s2.push_back(s[j]);
		}
		c = 0;
		m = s2.size();
		ind = 0;
		
		while(ind < m && s2[ind] != 'w') ind++;
		if(ind == m) continue;
		l = ind - 1;
		r = ind + 1;
		c = 1;
		if(l >= 0 && s2[l] == 'i' && r < m && s2[r]) c+=2;
		if(c < 3) continue;
		else{
			l--;
			r++;
			while(l >= 0 && r < m && ok(s2[l], s2[r])){
				l--;
				r++;
				c += 2;
			}
			res = max(res, c);
		}
	}
	cout << res << endl;
	return 0;
}

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

using namespace std;

long long dfs(int curr, const string& S, int lastSepIndex, int accum) {
    if (curr == S.size()) {
        return accum + atoll(S.substr(lastSepIndex, S.size() - lastSepIndex).c_str());
    }

    long long skip = dfs(curr + 1, S, lastSepIndex, accum);
    if (curr > 0) {
        long long take = dfs(curr + 1, S, curr, accum + atoll(S.substr(lastSepIndex, curr - lastSepIndex).c_str()));
        return take + skip;
    }
    else {
        return skip;
    }
}

void Main() {
    string S;
    cin >> S;

    long long ans = dfs(0, S, 0, 0);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
N=int(input())
P=[[int(i) for i in input().split()] for  _ in range(N)]
arm=[[p[0]-p[1], p[0]+p[1]] for p in P]
s_arm=sorted(arm, key=lambda x: x[1])

#tは最後に選んだ仕事の終了時間
ans = 0
t = -10**9
for i in range(N):
    if (t <= s_arm[i][0]):
        ans+=1
        t = s_arm[i][1]
print(ans)

Measured memory_bytes: 76248
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl as(N+1, 0), bs(N+1, 0), cs(N+1,0);
    REP(i, N){
        cin >> as[i+1] >> bs[i+1] >> cs[i+1];
    }
    vvl dp(3, vl(N+1, 0));
    dp[0][1] = as[1]; dp[1][1] = bs[1]; dp[2][1] = cs[1];
    FOR(i, 2, N+1){
        dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + as[i];
        dp[1][i] = max(dp[2][i-1], dp[0][i-1]) + bs[i];
        dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + cs[i];
    }
    cout << max(dp[0][N], max(dp[1][N], dp[2][N])) << endstr;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdint>

using i64 = std::int64_t;

constexpr i64 Mod = 1e9 + 7;

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

	i64 ans = 0;
	i64 acc = 0;
	for (int i = 0; i < n; ++i) {
		i64 a;
		std::cin >> a;

		(ans += (a * acc) % Mod) %= Mod;
		(acc += a) %= Mod;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 3620
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b 
# s = input()


N = int(input())
p = list(map(int, input().split()))

r = p[:]
r.sort()

cnt = 0
for i in range(N):
    if r[i] != p[i]:
        cnt += 1
if cnt <= 2:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str;
	cin>>str;
	int c=0;
	for(int i=0; i<str.length(); i++) {
		if(str[i]=='C') {
			c=1;
		}
		if(str[i]=='F'&&c==1) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
//
//  main.cpp
//  rough
//
//  Created by abhishek kumar on 30/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

#include <iostream>
#include<vector>
using namespace std;

typedef long long int ll;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s,t;
    cin>>s;
    cin>>t;
    ll n=s.length(),m=t.length();
    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));
    
    for(auto i=1;i<=n;i++)
    {
        for(auto j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    ll i=n,j=m;
    string result;
    while(i>0 && j >0)
    {
        if(s[i-1]==t[j-1])
        {
            result.insert(result.begin(), s[i-1]);
            i--;j--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }
    
   // reverse(result.begin(),result.end());
    cout<<result;
    
    return 0;
}

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

int countSame(std::string a, std::string b) {
	int count = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a.at(i) != b.at(i)) {
			count++;
		}
	}

	return count;
}

int main()
{
	std::string input;
	std::cin >> input;

	std::cout << countSame("CODEFESTIVAL2016", input) << std::endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

data Shop = Shop Integer Integer

takeDrinks :: Integer -> Integer -> [Shop] -> Integer
takeDrinks costAll needed ((Shop cost stock):rest)
  | needed <= stock = costAll + needed * cost
  | otherwise       = takeDrinks (costAll + cost * stock) (needed - stock) rest

main :: IO ()
main = do
  [shops, needs] <- (map read . words) <$> getLine
  shopData <- replicateM shops getLine
  let shops = (map (\[c, a] -> Shop c a) . map (map read) . map words) shopData
  let sortedShops = sortBy (\ (Shop ca _) (Shop cb _) -> compare ca cb) shops
  printf "%d\n" (takeDrinks 0 (toInteger needs) sortedShops)

Measured memory_bytes: 121212
#入力する数値
a, b, c, d, e = list(map(int, input().split()))
#print(a, b, c, d, e)
lists = []
lists.append(a)
lists.append(b)
lists.append(c)
lists.append(d)
lists.append(e)

n = lists.index(0)
#print(lists)
ans = print(n + 1)

Measured memory_bytes: 9124