akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

const int NIL = -1;
const int MAX = 2147483647;
const int NUM = 10000000;
clock_t START, END;
bool debug = false;

struct Node {
	int x1, y1, x2, y2;
};

Node rectangle[NUM];
vector<Node> Q;

void cut(int x1, int  y1, int x2, int y2)
{
	int k1, k2, k3, k4;
	Node S;
	int i = 0, _size = Q.size();
	for (vector<Node>::iterator it = Q.begin(); i < _size && !Q.empty();) {
		it = Q.begin() + i;
		if (x2 <= it->x1 || x1 >= it->x2 || y2 <= it->y1 || y1 >= it->y2) {
			i++;
			continue;
		}
		else {
			k1 = max(x1, it->x1);
			k2 = min(x2, it->x2);
			if (it->x1 < k1) {
				S.x1 = it->x1;
				S.y1 = it->y1;
				S.x2 = k1;
				S.y2 = it->y2;
				Q.push_back(S);
			}
			it = Q.begin() + i;
			if (it->x2 > k2) {
				S.x1 = k2;
				S.y1 = it->y1;
				S.x2 = it->x2;
				S.y2 = it->y2;
				Q.push_back(S);
			}
			it = Q.begin() + i;
			k3 = max(y1, it->y1);
			k4 = min(y2, it->y2);
			if (it->y1 < k3) {
				S.x1 = k1;
				S.y1 = it->y1;
				S.x2 = k2;
				S.y2 = k3;
				Q.push_back(S);
			}
			it = Q.begin() + i;
			if (it->y2 > k4) {
				S.x1 = k1;
				S.y1 = k4;
				S.x2 = k2;
				S.y2 = it->y2;
				Q.push_back(S);
			}
			Q.erase(Q.begin() + i);
			_size--;
		}
	}
	S.x1 = x1;
	S.x2 = x2;
	S.y1 = y1;
	S.y2 = y2;
	Q.push_back(S);
}

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in20.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int N, x1, y1, x2, y2;
	ll sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		cut(x1, y1, x2, y2);
	}
	for (vector<Node>::iterator it = Q.begin(); it != Q.end(); it++) {
		sum += static_cast<ll>((it->x2 - it->x1)) * static_cast<ll>((it->y2 - it->y1));
	}
	printf("%lld\n", sum);
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


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

int main(){
	int n;
	string s;

	cin>>n;
	cin>>s;

	if(n%2 != 0){
		cout<<"No";
		return 0;
	}
	for(int i=0; i<n/2; i++){
		if(s[i] != s[i+n/2]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<long int, long int>

struct edge{long int to, cost;};
vector<edge> G[100000];
long int n, Q, k;
long int a, b, c;
long int x[100000];
long int y[100000];


int main(){
    cin >> n;
    rep(i, n - 1){
        cin >> a >> b >> c;
        a--; b--;
        edge g;
        g.to = a;
        g.cost = c;
        G[b].push_back(g);
        g.to = b;
        G[a].push_back(g); 
    }
    cin >> Q >> k;
    k--;
    rep(i, Q){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    // kからの距離
    long int d[n];
    rep(i, n) d[i] = -1;
    d[k] = 0;
    queue<P> q;
    q.push(P(k, 0));
    while(q.size() > 0){
        P p = q.front();
        q.pop();
        long int e = p.first;
        long int dis = p.second;
        for (int i = 0; i < G[e].size(); i++){
            if (d[G[e][i].to] == -1){
                d[G[e][i].to] = dis + G[e][i].cost;
                q.push(P(G[e][i].to, dis + G[e][i].cost));
            }
        }
    }
    // rep(i, n) cout << d[i] << " ";
    // cout << endl;
    rep(i, Q){
        cout << d[x[i]] + d[y[i]] << endl;
    }
}

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

int main() {
	int W,H,x,y,r;
	cin >>W>>H>>x>>y>>r;
	if(x>=r && y>=r && x<=W-r && y<=H-r) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i] = nextInt()
		c[i] = nextInt()
	}

	dp := make([][3]int, n)
	dp[0][0] = a[0]
	dp[0][1] = b[0]
	dp[0][2] = c[0]
	for i := 1; i < n; i++ {
		dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i])
		dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i])
		dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i])
	}

	fmt.Println(max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])))
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 8256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,dept=100000;
    cin >> n;
    for(int i=0;i<n;i++){
        dept=dept*1.05;
        if((dept%1000)>0){
            dept=(dept/1000+1)*1000;
        }
    }
    cout << dept << endl;
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[31];
inline ll dfs(int l,int r,int xl,int xr) {
    if (r-l<=1) return 0;
    ll ans=1e18;
    for (int i=l+1;i<=r-1;i++)
        ans=min(ans,dfs(l,i,xl,xl+xr)+dfs(i,r,xl+xr,xr)+a[i]*(xl+xr));
    return ans;
}
int main() {
    int n; cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    cout<<a[1]+a[n]+dfs(1,n,1,1)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	my_io();
	int n, h, w;
	cin >> n >> h >> w;
	vector<pair<int, int>>v(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i].first >> v[i].second;
		if (v[i].first >= h && v[i].second >= w) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

bool prime[1100000];
int mazen[1100][1100];
int dp[1100][1100];
int n, m;
int num;
int hen;
bool flag;
int jx, iy;
int si, sj;

void makemaze(int x, int y){
    REP(i, hen) {
        num++;
        if (num > n) {
            flag = false; break;
        }

        iy += y;
        jx += x;
        mazen[iy][jx] = num;
        if (num == m) {si = iy; sj = jx;}
    }
}

int main() {
    REP(i, 1100000) prime[i] = true;
    prime[0] = false; prime[1] = false;
    for(int i=2; i<1100000; i++) {
        if (prime[i]) {
            for(int j=2; j<1100000/i; j++) {
                prime[i*j] = false;
            }
        }
    }

    while(true) {
        cin >> n >> m;
        if (n==0) break;

        int sq;
        REP(i, 1100) {
            if ((2*i+1)*(2*i+1) >= n) {
                sq = 2*i+1; break;
            }
        }

        // initial index
        jx = (sq+1)/2 - 1;
        iy = jx;

        REP(i, sq+3) {
            REP(j, sq+3) {
                dp[i][j] = -1;
                mazen[i][j] = -1;
            }
        }

        mazen[iy][jx] = 1;
        if (m==1) {
            si = iy; sj = jx;
        }

        hen = 1;
        num = 1;
        flag = true;
        int x1, y1, x2, y2;
        while(flag) {
            if (hen % 2 == 1) {
                x1=1; y1=0;
                x2=0; y2=-1;
            } else {
                x1=-1; y1=0;
                x2=0; y2=1;
            }
            
            makemaze(x1, y1);
            makemaze(x2, y2);
            hen++;
        }

        dp[si][sj] = 0;
        int output = 0;
        int last;
        if (prime[mazen[si][sj]]) {
            dp[si][sj]++;
            output = 1;
            last = mazen[si][sj];
        }
        
        for(int i=si; i<sq; i++) {
            REP(j, sq) {
                if (dp[i][j]<0 || mazen[i][j]<0) continue;
                REP(k, 3) {
                    int mv = k-1;
                    if (j+mv < 0 || mazen[i+1][j+mv]<0) continue;

                    dp[i+1][j+mv] = max(dp[i+1][j+mv], dp[i][j]);
                }
            }

            REP(j, sq) {
                if (dp[i+1][j] >= 0 && prime[mazen[i+1][j]]) {
                    dp[i+1][j]++;

                    // output
                    if (dp[i+1][j] > output) {
                        last = mazen[i+1][j];
                        output = dp[i+1][j];
                    }
                    if (dp[i+1][j] == output) {
                        last = max(last, mazen[i+1][j]);
                    }
                }
            }
        }

        if (output == 0) {
             cout << "0 0" << endl;
        } else {
             cout << output << " " << last << endl;
        }
    }
}




Measured memory_bytes: 12776
#include<bits/stdc++.h>
using namespace std;
bool a[31];
int k;

int main(){
    for(int y=1;y<29;y++){
        cin>>k;
        a[k]=true;
    }
    for(int y=1;y<31;y++){
        if(a[y]==false){cout<<y<<endl;}
    }

}

Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>
int m[101][101];
int *p;
int n;
int matrixChainOrder(){
  int i,l,j,k,q;
  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=100000000;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=m[i][j] < q ? m[i][j] : q;
}
}
}
  return m[1][n];
}
int main(){
  int i,m,min;
  scanf("%d",&n);
  p=malloc((n+1)*sizeof(p));
  scanf("%d",&p[0]);
  scanf("%d",&p[1]);
  for(i=2;i<=n;i++){
    scanf("%d",&m);
    scanf("%d",&p[i]);
}
  min=matrixChainOrder();
  printf("%d\n",min);
  return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update> ordered_multiset;

#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
// int MOD=998244353;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<int> vi; typedef pair<int,int> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int cmp(const ii& p1, const ii& p2) {
	return (p1.ss>p2.ss);
}

signed main(void)
{
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i = 0;i < n; i++)
		cin>>a[i];
	sort(all(a));
	for(int i = 0; i < n-1; i++) {
		if(a[i]==a[i+1]) {
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	time();
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

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

int N,M;

int main(){
    cin>>N>>M;
    vi num(N,1);
    vector<bool> ok(N,false);
    ok[0]=true;
    rep(i,M){
        int x,y;cin>>x>>y;
        x--,y--;
        if(ok[x]){
            if(num[x]>1){
                ok[y]=true;
            }else{
                ok[y]=true;
                ok[x]=false;
            }
        }
        num[y]++;
        num[x]--;
    }
    int ans=0;
    rep(i,N) if(ok[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=b;i>=a;i--)
#define N 2000500
using namespace std;
int n,m,fa[N],vis[N],D[N],C[N];
int gf(int x) {return fa[x]==x?x:fa[x]=gf(fa[x]);}
inline ll read()
{
    ll 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 main() 
{
    n = read(), m = read();
	For(i,1,1000)fa[i] = i;
    For(i,1,n)
	{
        int x, y,a,b,c,d;
        a = read(), b = read(), c = read(), d = read();
        x=!c?a:-c; x+=500;
        y=!d?-b:d; y+=500;
        fa[ gf(x) ] = gf(y);
        D[x]++, D[y]--, vis[x] = 1;
    }
    int flag = 1;
	For(i,1,499)D[i]>0 ? flag=0 :0;
	For(i,501,1000)D[i]<0 ? flag=0 :0;
	For(i,1,1000)vis[gf(i)] |= vis[i];
    For(i,1,1000) if (D[i]) C[gf(i)] = 1;
    For(i,1,1000) if (fa[i]==i && !C[i] && vis[i]) flag = 0;
    puts(flag?"YES":"NO");
    return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    vector<unsigned long> v(K + 1);
    unsigned long ans{0};
    for(unsigned long i{K}; i > 0; --i){
        if(!v[K / i]){
            v[K / i] = modpow(K / i, N);
            for(unsigned long j{2 * i}; j <= K; j += i)v[K / i] += MOD - v[K / j];
        }
        ans += i * (v[K / i] %= MOD) % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4000
n,k = map(int,input().split())
A = list(map(int,input().split()))
sub = [0]*n
city = 0
all = []
roop = []
while sub[city] != 2:
  if sub[city] == 0:
    all.append(city+1)
  else:
    roop.append(city+1)
  sub[city] += 1
  city = A[city] -1
if len(all) > k:
  print(all[k])
else:
  print(roop[(k-(len(all)-len(roop)))%len(roop)])

Measured memory_bytes: 105324
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
vll dp(100005,-1);
vll a[100005];
ll solve(ll num)
{
    if(dp[num]!=-1)
        return dp[num];
    ll temp=0;
    for(ll i=0;i<a[num].size();i++)
    {
        temp=max(temp,solve(a[num][i])+1);
    }
    dp[num]=temp;
    return dp[num];
}
int main()
{
    fast();
    ll n,m,x,y,i,ans=0;
    cin>>n>>m;

    rep(i,m)
    {
        cin>>x>>y;
        x--;y--;
        a[x].eb(y);
    }
    for(i=0;i<n;i++)
    {
        ans=max(ans,solve(i));
    }
    cout<<ans;
    exit(0);
}

Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
static const int MAX_V = 50;

//Graph Element
struct E {
	E(int t, int f) {
		to = t;
		from = f;
	}
	E(int t, int f, int c) {
		to = t;
		from = f;
		cost = c;
	}
	int to;
	int from;
	int cost;
	bool visited;
	bool use;
};
struct V {
	vector<E*> edge;
	bool visited;
};
V G[MAX_V];
/////////////////////////////////////////////

//dfs
int ans = 0;
int VS, ES;
void dfs(int n) {
	rep(i, 0, G[n].edge.size()) {
		if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
			G[G[n].edge[i]->to].visited = true;
			dfs(G[n].edge[i]->to);
		}
	}
}

int main() {
	cin >> VS >> ES;

	rep(i, 0, ES)
	{
		int s, t; cin >> s >> t;
		G[s].edge.push_back(new E(t, s));
		G[t].edge.push_back(new E(s, t));
	}

	///////////////////////////////////////////////////////////

	//Edge all false
	repe(i, 1, VS) rep(j, 0, G[i].edge.size()) {
		//Edge all visited false;
		repe(k, 1, VS) rep(l, 0, G[k].edge.size()) G[k].edge[l]->use = true;
		repe(k, 1, VS) G[k].visited = false;

		G[i].edge[j]->use = false;

		//DFS
		G[1].visited = true;
		dfs(1);

		bool ok = true;
		repe(k, 1, VS)  ok &= G[k].visited;
		if (!ok)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#define mxn 1000010
#define LL long long
#define mid ((l+r)>>1)
#define pii pair<int,int> 
#define fr first
#define sc second
#define mp make_pair
using namespace std;
int n,sl,fh,ans,a[mxn],tr[mxn];
pii p[mxn];
LL K;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int i) {for(;i<=n;i+=(i&-i)) tr[i]++;}
int qry(int i) {int res=0; for(;i;i-=(i&-i)) res+=tr[i]; return res;}
bool check(int x)
{
	int s=0;LL cnt=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i]<=x) s++;
		else s--;
		p[i]=mp(s,i);
		tr[i]=0;
		if(s>=1) cnt++;
	}
	sort(p+1,p+n+1);
	for(int l=1,i=1;i<=n;++i)
	{
		for(;l<=n&&p[l].fr<=p[i].fr-1;upd(p[l].sc),l++);
		cnt+=qry(p[i].sc);
	}
	return cnt>=K;
}
int main()
{
	n=rd();K=1ll*n*(n+1)/4+1;
	for(int i=1;i<=n;++i) a[i]=rd();
	for(int l=1,r=1e9;l<=r;)
	{
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string a, b, c; cin >> a >> b >> c;
  if (a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
x, y = map(int, input().split())

g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
judge = []
for index, g in enumerate([g1, g2, g3]):
    if x in g:
        judge.append(index)
    if y in g:
        judge.append(index)
if len(set(judge)) == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n = int(input())
Cards = [[0 for i in range(13)]  for j in range(4)]

for i in range(n):
    Mark,Number = input().split()
    if Mark == "S":
        Cards[0][int(Number) - 1] = 1
    elif Mark == "H":
        Cards[1][int(Number) - 1] = 1
    elif Mark == "C":
        Cards[2][int(Number) - 1] = 1
    elif Mark == "D":
        Cards[3][int(Number) - 1] = 1

for x in range(4):
    for y in range(13):
        if Cards[x][y] == 0:
            if x == 0:
                print("S",y+1)
            elif x == 1:
                print("H",y+1)
            elif x == 2:
                print("C", y + 1)
            elif x == 3:
                print("D", y + 1)

Measured memory_bytes: 7752
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a >= b && a>= c){
            System.out.println(10*a+b+c);
        }else if(b >= a && b>= c){
            System.out.println(10*b+a+c);
        }else if(a == b&& a == c){
            System.out.println(10*a+b+c);
        }else{
            System.out.println(10*c+a+b);
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,i;
	while(cin>>n>>i)
	{
		cout<<n+1-i<<endl;	
	} 
	return 0;
}


Measured memory_bytes: 256
def calc(a):
    smallest = a * (a - 1) // 2
    largest = smallest + a * (n - a + 1)
    return largest -smallest + 1

n, k = map(int, input().split())
mod = 10 ** 9 + 7
ans = 0

for a in range(k, n + 2):
    ans += calc(a)
    ans %= mod

print(ans)    


Measured memory_bytes: 9184
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.stream.Collectors;


public class Main {

    public static int gcd(int n,int m){
        return (m==0)?n:gcd(m,n%m);
    }
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);

        long n=cin.nextLong();
        long m=cin.nextLong();
        if(n==1||m==1){
            System.out.println("1");
        }
        else{
            if(n*m%2==1){
            System.out.println(n*m/2+1);
            }
            else{
                System.out.println(n*m/2);
            }
        }
    }

}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif

#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
void stat();
constexpr ll mod = 1000000000 + 7;

int main()
{
	int a,pp;cin>>a>>pp;
	cout<<(((a*3)+pp)/2)<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){

#ifdef local
	rep(i,2){
	std::cout<<"local enable"<<std::endl;}
#endif
#ifdef hacks
	rep(i,2){
	std::cout<<"boost enable"<<std::endl;}
#endif
}


Measured memory_bytes: 3628
n = int(input())
a = [ [int(s),i]  for i,s in enumerate(input().split())]
b = [ [int(s),i]  for i,s in enumerate(input().split())]
a.sort(reverse=True)
b.sort(reverse=True)

go = [-1] * n

b_ind = 0
ans = 'No'
for a_ind, (j,j_ind) in enumerate(a):
    while(b[b_ind][0] >= j ):
        b_ind += 1

        if(b_ind == n)&(a_ind < n-1):
            print('Yes')
            exit()

        if(b_ind == n):
            break

    if(b_ind == a_ind):
        print('No')
        exit()

    if(b_ind > a_ind+1):
        ans = 'Yes'

    go[j_ind] = b[a_ind][1]


now = 0
cnt = 0
for _ in range(n-1):
    now = go[now]
    cnt += 1
    if(now==0):
        print('Yes')
        exit()

print(ans)

Measured memory_bytes: 110004
n = int(input())
lis = list(map(int,input().split()))
li = [0]
ans = set()
for i in range(n):
  li.append(li[-1] + lis[i])
cou = 0
num = 0
nu = 0
li.sort()
for i in range(1,n+1):
  if li[i] == li[i-1]:
    nu += 1
    cou += nu
  else:
    nu = 0
    num = 0
if nu != 0:
  cou += num
print(cou)

Measured memory_bytes: 26000
#include<stdio.h>
#include<string.h>
int main () {
	char ring[202];
	char ringText[101];
	char seachText[202];
	scanf("%s" , ringText);
	scanf("%s" , seachText);
	strcpy(ring , ringText);
	strcat(ring , ringText);
	
	if ((strstr(ring , seachText)) != NULL) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 540
N=int(input())
print(0)
S0 = input()[0]
if S0=="V":exit()
print(N-1)
if input()[0]=="V":exit()

l,r=0,N-1
while r-l>1:
    med=(r+l)//2
    print(med)
    S1=input()[0]
    if S1=="V":
        exit()
    elif (med%2==0 and S1==S0) or (med%2==1 and S1!=S0):
        l=med
    else:
        r=med
print(r)


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

int main() {
  int N;
  cin >> N;
  string str;
  for(int i=0;i<N;i++){
    cin >> str;
    if(str == "Y"){
      cout << "Four" << endl;
    return 0;
    }
  }
  cout << "Three" << endl;
    
}


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

int main() {
    int N;
    int X[200000];
    int Y[200000];
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> X[i];
        Y[i] = X[i];
    }
    
    
    sort(Y,Y+N);

    //cout << X[0] << X[1] << X[2] << X[3] <<  endl;
    //cout << Y[0] << Y[1] << Y[2] << Y[3] << endl;

    for (int i=0;i<N;i++){
        if (X[i]<=Y[N/2-1]){
            cout << Y[N/2] << endl;
        }else{
            cout << Y[N/2-1] << endl;
        }
    }
}

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

 int main() {
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;
  int x;
  int y;

  x = (A + D - 1) / D ;
  y = (C + B - 1) / B ;
 if(x >= y){
  cout << "Yes" << endl;
 }
 else {
  cout << "No" << endl;
 }
}



Measured memory_bytes: 3620
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]

ans = 0
ck = 0

for i in range(n):
  if p[i][0] == p[i][1]:
    ans += 1
    if ans == 3:
      ck = 1
      print("Yes")
      break
  else:
    ans = 0
    
if ck == 0:
  print("No")

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

int main(){
  int n;
  cin >> n;
  long total=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0&&i%15!=0) total+=i;
  }
  cout << total << endl;
}

Measured memory_bytes: 3624
import java.util.*

private data class Work(val start: Int, val end: Int, val dist: Int)
private data class Position(val pos: Int, val index: Int)

fun main(args: Array<String>) {

    /**
     * 同等のデータ構造, ロジックを実装しているが TLE で通らない,, java と kotlin の速度差?? どう分析するべきか
     * WAをあえて出すと実行時間を出力できる
     */
    val (n, q) = readLine()!!.split(" ").map { it.toInt() }

    // 工事を格納 O(N)
    var workList = mutableListOf<Work>()

    for (i in 0 until n) {
        val (s, t, x) = readLine()!!.split(" ").map { it.toInt() }

        // 切り上げ，切り捨てをして閉区間で考える
        var start = Math.ceil(s - 0.5 - x).toInt()
        var end = Math.floor(t - 0.5 - x).toInt()

        workList.add(Work(start, end, x))
    }

    // 工事を距離が近い順にソート O(NlogN)
    workList.sortBy { it.dist }

    // スタート地点を配列に保持する（最初からソートされて渡されるのでソートの必要なし） O(N)
    // スタート地点の中で，ある工事区間に含まれるものを取り出し，配列から削除,
    var posSet = TreeSet<Position> { a, b -> a.pos - b.pos } // Comparator をラムダ式で渡す
    for (i in 0 until q) {
        posSet.add(Position(readLine()!!.toInt(), i))
    }


    // 答えにはデフォルトで -1 を設定 (選ばれなかったものは工事に合わない = -1 )
    val ans = IntArray(q) { -1 }


    for (work in workList) {

        // work.start よりも大きな開始地点を持つ posList 内の 最初の要素を指す イテレータを取得
        // O(logN)
        val comp = Position(work.start, -1)
        var position = posSet.ceiling(comp)

        // 工事に含まれる位置にいる posList の要素を取得し，削除
        while (position != null) {
            if (position.pos > work.end) {
                break
            }

            // O(logN)
            posSet.remove(position)

            // O(1)
            ans[position.index] = work.dist

            position = posSet.ceiling(comp)
        }
    }

    println(ans.joinToString("\n"))
//    for (a in ans) {
//        println(a)
//    }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= 0;i--)
#define _dep(i,j,N) for(int i = (N); i>= 0;i--)
#define ALL(x) x.begin(),x.end()
#define LL long long
#define ULL unsigned LL
#define PB push_back


int main()
{
    int N,K;
    cin >> N >> K;
    if((N+1)/2 >= K) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<int,int>> V(N),V2(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y;
    x--;y--;
    V[x] = make_pair(y,i);
    V2[y] = make_pair(x,i);
  }
  
  set<pair<int,int>> S;
  S.insert(V[0]);
  dsu D(N);
  for(int i=1;i<N;i++){
    pair<int,int> p = *begin(S);
    if(V[i].first>p.first) D.merge(V[i].second,p.second);
    S.insert(V[i]);
  }
  
  set<pair<int,int>> S2;
  S2.insert(V2[0]);
  for(int i=1;i<N;i++){
    pair<int,int> p = *begin(S2);
    if(V2[i].first>p.first) D.merge(V2[i].second,p.second);
    S2.insert(V2[i]);
  }
  
  set<pair<int,int>> S3;
  S3.insert(V[N-1]);
  for(int i=N-2;i>=0;i--){
    pair<int,int> p = *rbegin(S3);
    if(V[i].first<p.first) D.merge(V[i].second,p.second);
    S3.insert(V[i]);
  }
  
  set<pair<int,int>> S4;
  S4.insert(V2[N-1]);
  for(int i=N-2;i>=0;i--){
    pair<int,int> p = *rbegin(S4);
    if(V2[i].first<p.first) D.merge(V2[i].second,p.second);
    S4.insert(V2[i]);
  }
  
  for(int i=0;i<N;i++) cout << D.size(i) << endl;
  return 0;
}


Measured memory_bytes: 44744
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A,B,C,K;
    cin>>A>>B>>C>>K;
long long r=0;
    if(K>=A)
    {
        r=r+A;
        K=K-A;
    }else
    {
        r=r+K;
        K=0;
    }

    if(K>=B)
    {
        K=K-B;
    }else
    {
        K=0;
    }

    if(K>=C)
    {
        r=r-C;
        K=K-C;
    }else
    {
        r=r-K;
        K=0;
    }
    cout<<r
;


}



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

int countDigit(double num)
{
    return log10(num) + 1;
}

int main()
{
    double a, b;
    while(cin >> a >> b)
    {
        cout << countDigit(a + b) << endl;
    }
    return EXIT_SUCCESS;
}

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

if k == 1:
    print(n ** 3)
elif k == 2:
    if n % 2 == 1:
        print((n//2+1)**3+(n//2)**3)
    else:
        print(((n//k)**3)*2)
elif k % 2 == 1:
    print((n//k)**3)
else:
    if n - k*(n//k) < k//2:
        print(((n // k) ** 3) * 2)
    else:
        print((n//k)**3+(n//k+1)**3)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {
  int a, b, c;
  cin>>a>>b>>c;
  if((a + b) % 60 == 0 && a < c){
    cout<<-1<<endl;
    return 0;
  }

  REP(k,0,10000){
    REP(i,0,10000){
      if((a + b)*i - 60*k <= c && c <= (a + b)*i + a - 60*k){
        cout<<c + 60*k<<endl;
        return 0;
      }
    }
  }

  cout<<-1<<endl;

  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; ++i)  cin >> a[i];
    vector<int> dp(K + 1, -1);
    dp[0] = 0;
    auto func = [&](auto&& self, int rest) -> int {
        if(dp[rest] != -1)  return dp[rest];
        int res = 1;
        for(int i = 0; i < N; ++i){
            if(rest >= a[i])    res &= self(self, rest - a[i]);
        }
        return dp[rest] = !res;
    };
    if(func(func, K))   cout << "First\n";
    else    cout << "Second\n";
}

Measured memory_bytes: 9760
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int dy[16] = { 0, 1, 0,-1, 1,-1, 1,-1, 0,-2, 0, 2};
const int dx[16] = { 1, 0,-1, 0, 1, 1,-1,-1, 2, 0,-2, 0};
int dir, y, x;
vector<vector<char>> m;
map<int,int> loop;

bool f = false;
int ans;

bool cond(int&, string&);
void expr(int&, string&);

void comm(int& p, string& com){
	if(com[p] == '^'){
		int ny = y + dy[dir];
		int nx = x + dx[dir];
		if(m[ny][nx] != '#'){
			x = nx;
			y = ny;
		}
	}else if(com[p] == '>'){
		(dir+=1) %= 4;
	}else if(com[p] == 'v'){
		int d = (dir + 2) % 4;
		int ny = y + dy[d];
		int nx = x + dx[d];
		if(m[ny][nx] != '#'){
			x = nx;
			y = ny;
		}
	}else if(com[p] == '<'){
		dir = (dir - 1 + 4) % 4;
	}else{
		assert(false);
	}

	ans++;
	p++;

	if(m[y][x] == 'g'){
		f = true;
	}
}

bool cond(int& p, string& com){
	bool rev = false;
	if(com[p] == '~'){
		rev = true;
		p++;
	}

	bool res;
	switch (com[p]) {
		case 'N':
			res = dir == 3;
			break;
		case 'E':
			res = dir == 0;
			break;
		case 'S':
			res = dir == 1;
			break;
		case 'W':
			res = dir == 2;
			break;
		case 'C':
			res = m[y + dy[dir]][x + dx[dir]] == '#';
			break;
		case 'T':
			res = true;
			break;
	}
	p++;
	return rev ^ res;
}

void nextEnd(int& p, string& com){
	int cnt = 1;
	while(cnt != 0){
		if(com[p] == '{' or com[p] == '[') cnt++;
		else if(com[p] == '}' or com[p] == ']') cnt--;
		p++;
	}
}

set<tuple<int,int,int,int>> s;
void expr(int& p, string& com){

	while(true){
	//cout << dir << endl;
	//cout << p << ' ' << com[p] << endl;
	//cout << y << ' ' << x << endl;
	////char a;
	//cin >> a;
		tuple<int,int,int,int> tup = tuple<int,int,int,int>(dir, y, x, p);
		if(s.count(tup)){
			f = true;
			return;
		}else{
			s.emplace(tup);
		}

		if(f) return;

		if(com[p] == '}'){
			p = loop[p];
		}else if(com[p] == ']'){
			p++;
		}else if(com[p] == '{' or com[p] == '['){
			p++;
			if(not cond(p, com)){
				nextEnd(p, com);
			}
		}else if(com[p] == '@'){
			break;
		}else if(m[y][x] == 'g'){
			f = true;
			return;
		}else{
			comm(p, com);
		}
	}
}

int main(){
	int h, w;
	cin >> h >> w;

	m = vector<vector<char>>(h, vector<char>(w));
	pair<int, int> s;
	rep(i,h){
		rep(j,w){
			cin >> m[i][j];
			if(m[i][j] == 's'){
				y = i;
				x = j;
			}
		}
	}
	dir = 3;

	string com;
	cin >> com;
	com += '@';

	stack<int> st;
	rep(i,com.size()){
		if(com[i] == '{'){
			st.emplace(i);
		}else if(com[i] == '}'){
			loop[i] = st.top(); st.pop();
		}
	}

	int p = 0;
	expr(p, com);
	if(m[y][x] == 'g') cout << ans << endl;
	else cout << -1 << endl;
}



Measured memory_bytes: 79156
#coding:UTF-8
def SS(N,A):
    count=0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j]<A[minj]:
                minj=j
        if i!=minj:
            count+=1
            swap=A[i]
            A[i]=A[minj]
            A[minj]=swap
    for i in range(len(A)):
        A[i]=str(A[i])
    print(" ".join(A))
    print(count)

if __name__=="__main__":
    N=int(input())
    a=input()
    A=a.split(" ")
    for i in range(len(A)):
        A[i]=int(A[i])
    SS(N,A)

Measured memory_bytes: 7752
function main()
  
  N = parse(Int,readline())
  
  ans = 10^12
  
  for i in 1:Int(round(sqrt(N)))
    
    if div(N,i)*i == N
      ans = min(ans,(div(N,i) + i - 2))
    end
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 111360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const ll mod = 1000000007;

ll comb[2100][2100] = {0};
ll cb(int a, int b){
    if(a < 0 || b < 0 || a < b) return 0;
    else return comb[a][b];
}


int main(){
    for(int i = 0; i < 2100; i++){
        for(int j = 0; j < 2100; j++){
            if(i == j || j == 0) comb[i][j] = 1;
            else if(j > i) comb[i][j] = 0;
            else comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % mod;
        }
    }
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        cout << comb[n-k+1][i] * comb[k-1][i-1] % mod << endl;
    }
    return 0;
}

Measured memory_bytes: 34688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a + b >= c) out("Yes");
    else out("No");
}



Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 02.08.2020 15:41:51
**/

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

int main() {

    long long int x,y;
    cin >> x >> y;

    long long int count=0;
    while(1){
        if(x==y) break;

        else if(x<y){
            if(abs(x)<abs(y)) {
                if(x>=0){
                    count+=y-x;
                    x+=y-x;
                }
                else{
                    count++;
                    x*=-1;
                }
            }
            else if(abs(x)==abs(y)){
                count++;
                x*=-1;
            }
            else{
                if(y>=0){
                    count+=abs(x)-y;
                    x+=abs(x)-y;
                }
                else{
                    count+=y-x;
                    x+=y-x;
                }
            }
        }
        else if(y<x){
            if(abs(x)>abs(y) || x<0){
                count++;
                x*=-1;
            }
            else if(abs(x)==abs(y)){
                count++;
                x*=-1;
            }
            else{
                count+=abs(y)-x;
                x+=abs(y)-x;
            }
        }
        //cout << x << ' ' << y << endl;
    }
    cout << count << endl;

    return 0;
}

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

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int N=0;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  int pin=0,count=0,i=0,j=0;
  int digit[3];
  
  for(int pin=0;pin<1000;pin++){
    digit[2] = pin%10;
    digit[1] =(pin/10)%10;
    digit[0] = pin/100;
    
    
    for(i=0,j=0;i<N && j<3 ;i++){
    	if(S[i] == '0' + digit[j]){
          j++;
        }
      if(j==3){
      	count++;
      }
    }
  }
  
  printf("%d",count);


 return 0;
}

Measured memory_bytes: 256
// Problem : B - Golden Coins
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int main() {
	int n = qread();
	int ans = 1000 * (n / 500);
	n %= 500;
	ans += 5 * (n / 5);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
void main()
{
    long n, m;
    rdVals(n, m);
    string s = rdStr;

    long[] lists;
    while (n > 0)
    {
        long ok;
        foreach_reverse (i; 1 .. m+1)
        {
            if (n - i < 0) continue;

            if (s[n-i] == '0')
            {
                lists ~= i;
                n -= i;
                ok = true;
                break;
            }
        }
        if (!ok)
        {
            writeln(-1);
            return;
        }
    }

    foreach_reverse (i, x; lists)
    {
        x.write;
        if (i == 0) writeln;
        else " ".write;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 1404
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<fstream>
#include<queue>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n, day;
	cin >> n >> day;
	auto compare = [](pair<int, int> lhs, pair<int, int> rhs) {
		return lhs.second < rhs.second; 
	};
	priority_queue <
		pair<int, int>,
		vector<pair<int, int>>,
		decltype(compare)
	> pq{ compare };
	VEP vep(n);
	REP(i, n) {
		cin >> vep[i].first>> vep[i].second;
	}
	sort(vep.begin(), vep.end());
	int now_idx = 0;
	llong ans=0;
	REP(d,day){
		while (now_idx < n && vep[now_idx].first <= d + 1) {
			pq.push(vep[now_idx]);
			now_idx++;
		}
		if (!pq.empty()) {
			ans += pq.top().second;
			pq.pop();
		}
	}
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b<a+c && a+b<b+c)
        cout<<a+b<<endl;
    else if(b+c<a+c)
        cout<<b+c<<endl;
    else
        cout<<a+c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
 
int main() {
    int A,B;
  cin >> A >> B;
  	int sum = 1;
	int count = 0;
	while(sum < B){
	 count++;
     sum += A-1;
    }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
 int K;
  scanf("%d",&K);
  
  char S[100];
  scanf("%s",S);
  
  if(strlen(S) <= K){
    printf("%s",S);
  }else{
    for(int i=0; i<K; i++){
      printf("%c",S[i]);
    }
    printf("...");
  }
}


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

namespace ABC127C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var LimitL = 1;
            var LimitR = nm[0];
            for(int i = 0; i < nm[1]; i++)
            {
                var lr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                LimitL = Math.Max(LimitL, lr[0]);
                LimitR = Math.Min(LimitR, lr[1]);
            }
            var result = LimitR - LimitL + 1;
            if (result < 0) { result = 0; }
            Console.WriteLine(result);
            
        }
    }
}


Measured memory_bytes: 17488
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
using namespace std;

int main(){
  int n, m;
  int c[20];
  while(cin >> n >> m){
    rep(i, 0, m)  cin >> c[i];
    vector<int> dp(100000, 100100100);
    dp[0] = 0;
    rep(i, 0, m){
      for(int j=0; c[i]+j<=n; j++){
        dp[c[i]+j] = min(dp[j]+1, dp[c[i]+j]);
      }
    }
    cout << dp[n] << endl;
  }
  return 0;
}



Measured memory_bytes: 3112