akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;

class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!size_arr[ap] > size_arr[bp])swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll n, d, in1, in2;
		string s;
		cin >> s >> d;
		reverse(s.begin(), s.end());
		ll dp[s.size()+12][d+5][2];
        rep(i, 0, s.size()+1){
				rep(k, 0, d){
                    dp[i][k][0] = dp[i][k][1] = 0;
				}
			}
        dp[0][0][1]++, dp[0][0][0]++;
		rep(i, 0, s.size()){
			rep(j, 0, 10){
				rep(k, 0, d){
					if(s[i] - '0' > j)dp[i+1][(k+j)%d][1] += dp[i][k][0], dp[i+1][(k+j)%d][1] %= mod;
					if(s[i] - '0' == j)dp[i+1][(k+j)%d][1] += dp[i][k][1], dp[i+1][(k+j)%d][1] %= mod;
					dp[i+1][(k+j)%d][0] += dp[i][k][0], dp[i+1][(k+j)%d][0] %= mod;
				}
			}
		}
        cout << (dp[s.size()][0][1]-1+mod)%mod << endl;
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

Measured memory_bytes: 16768
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, M;
    cin >> N >> M;

    map<ll, ll> mp;

    FOR(i, 0, N){
        ll K;
        cin >> K;
        FOR(j, 0, K){
            ll a;
            cin >> a;
            mp[a]++;
        }
    }

    ll count = 0;
    for(auto p : mp){
        if(p.second==N){
            count++;
        }
    }

    p(count);
    
    return 0;
}

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

void solve() {
    int N;
    cin >> N;
    int P[N];
    int m = N + 1;
    int x = 0;
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
        m = min(m, P[i]);
        if (m == P[i]) x++;
    }
    cout << x << endl;
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

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

const long long INF = 1LL << 60;
const int MAX_V = pow(10, 3) * 100 + 1;

int main()
{
    int N;
    long long W;
    cin >> N >> W;

    vector<long long> w(N), v(N);
    rep(i, N)
    {
        cin >> w[i] >> v[i];
    }

    vector<vector<long long>> dp(N + 1, vector<long long>(MAX_V + 1, INF));

    dp[0][0] = 0;

    rep(i, N)
    {
        rep(j, MAX_V)
        {
            if (j - v[i] >= 0)
            {
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }

            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    long long res = 0;
    rep(j, MAX_V)
    {
        if (dp[N][j] <= W)
        {
            res = j;
        }
    }
    cout << res << endl;
}


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

int main(){
  int N,num;
  cin>>N;
  int tmp,ans;
  tmp=0;
  num=0;
  ans=0;
  for(int i=0;i<N;++i){
    cin>>tmp;
    num=max(tmp,num);
    ans+=tmp;
  }
  ans=ans-num/2;
    cout<<ans;
    return 0;
  }



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
int main(){
    int m, d;
    cin >> m >> d;
    ll ans = 0;
    for(int i = 4; i <= m; i++){
        for(int j = 11; j <= d; j++){
            int d_10 = j / 10;
            int d_1 = j % 10;
            if (d_10 >= 2 && d_1 >= 2 && d_10 * d_1 == i) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  
  S=input()
  T=input()
  
  check=False
  ind=[]
  for i,l in enumerate(S):
    if i+len(T)>len(S):
      break
    for j,m in enumerate(T):
      if S[i+j]==m or S[i+j]=="?":
        check=True
      else:
        check=False
        break
    if check==True:
      ind.append(i)
  
  word=[]
  for i in ind:
    w=(S[:i]+T+S[i+len(T):]).replace("?","a")
    word.append(w)
  word.sort()
  
  if len(word)==0:
    print("UNRESTORABLE")
  else:
    print(word[0])

if __name__=="__main__":
  main()

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine((N - H + 1) * (N - W + 1));
	}
	int N;
	int H,W;
	public Sol(){
		N = ri();
		H = ri();
		W = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
  int a,b,c,x,count=0;
  cin >> a >> b >> c >> x;
  r(i,a+1){
    r(j,b+1){
      r(k,c+1){
        if(500*i+100*j+50*k==x)count++;
      }
    }
  }
  cout <<count << endl;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 2e5+10;

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;

	ll ans = 0;
	ll b[MAX_N]={0};
	for (int i = 0; i < s.size(); ++i) {
		b[i+1] = b[i];
		if (s[i]=='B') b[i+1]++;
	}
	for (int i = 0; i < s.size(); ++i){
		if (s[i]=='W') {
			ans += b[i];
		}
	}

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

Measured memory_bytes: 2180
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
const long long MOD=1e9+7;
long long n,m;
long long fact(long long x){
	long long ans=1LL;
	for(int i=2;i<=x;++i){
		ans=ans*i;
		ans%=MOD;
	}
	return ans;
}
int main(){
	cin>>n>>m;
	if(abs(n-m)>1){
		puts("0");
		return 0;
	}
	if(n==m) cout<<((long long)2LL*fact(n)*fact(m))%MOD<<endl;
	else cout<<((long long)fact(n)*fact(m))%MOD<<endl;
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
import numpy as np

mod=10**9+7

def mat(list):
    return reduce(lambda a,b: a*b%mod, list)


N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = np.array(sorted(A, key=abs, reverse=True))
A_pn = A < 0
if N == np.count_nonzero(A_pn):
    if K % 2 == 0:
        print(mat(A[:K]))
    else:
        print(mat(A[-K:]))
elif np.count_nonzero(A_pn[:K]) % 2 == 0:
    print(mat(A[:K]))
elif N==K:
    print(mat(A))
else:
    negative_all = np.where(A_pn)[0]
    negative_rest = np.count_nonzero(negative_all>=K)
    if negative_rest == 0:
        # 負の数が残っていない
        A[negative_all[-1]] = A[K]
        print(mat(A[:K]))
    elif negative_rest == N-K:
        # 正の数が残っていない
        last_positive = np.where(A_pn[:K]==False)[0][-1]
        A[last_positive] = A[K]
        print(mat(A[:K]))
    elif len(negative_all)-negative_rest==K:
        # 負の数しか選択されていない
        last_negative = negative_all[negative_all<K][-1]
        next_positive = np.where(A_pn==False)[0][0]
        A[last_negative] = A[next_positive]
        print(mat(A[:K]))
    else:
        last_negative = negative_all[negative_all<K][-1]
        next_negative = negative_all[negative_all>=K][0]
        positive_all = np.where(A_pn==False)[0]
        last_positive = positive_all[positive_all<K][-1]
        next_positive = positive_all[positive_all>=K][0]
        if A[last_negative]*A[next_negative] > A[last_positive]*A[next_positive]:
            A[last_positive] = A[next_negative]
        else:
            A[last_negative] = A[next_positive]
        print(mat(A[:K]))


Measured memory_bytes: 50228
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int pow(int n){

        int ans = 1;
        for(int i=0;i<n;i++){
            ans *= 10;
        }
    return ans;

}

int main()
{
    long long N,K;
    cin >> N >> K;

    if(N<=K){
        cout << 0 << endl;
        return 0;
    }

    vector<long long> H;
    long long input;

    rep(i,N){
        cin >> input;
        H.push_back(input);
    }

    std::sort(H.begin(), H.end());

    long long ans = 0;

    rep(i,N-K){
        ans =  ans + H[i];
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 2420
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool invalid(int x){
  return x < 0 || 10000 <= x;
}

int main(){
  string s;
  while(cin >> s){
    int R1 = 0, R2 = 0, R3 = '+';
    REP(i, s.size()){
      if(isdigit(s[i])){
        R2 = R2 * 10 + s[i] - '0';
        if(invalid(R2)) {
          R1 = -1;
          goto OUTPUT;
        }
      }else{
        if(R3 == '+'){
          R1 += R2;
        }else if(R3 == '-'){
          R1 -= R2;
        }else if(R3 == '*'){
          R1 *= R2;
        }
        R2 = 0;
        R3 = s[i];
        if(invalid(R1)) goto OUTPUT;
      }
    }
OUTPUT:
    if(invalid(R1)) cout << "E" << endl;
    else cout << R1 << endl;
  }
  return 0;
}

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

#define ll long long
#define pll pair<ll,ll> 

ll M[3003][3003];
void dfs(string s,string w,ll n,ll  m,string ans){
	if(n==0 || m==0){
		reverse(ans.begin(), ans.end());
		cout<<ans;
		exit(0);
		return ;
	}
	if(s[n-1]==w[m-1])
		dfs(s,w,n-1,m-1,ans+s[n-1]);
	else{
		if(M[n-1][m]==M[n][m])
			dfs(s,w,n-1,m,ans);
		else if(M[n][m-1]==M[n][m])
			dfs(s,w,n,m-1,ans);
		else{
			dfs(s,w,n-1,m, ans);
			dfs(s,w,n,m-1, ans);
		}
	}
}
	
int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s, w;
	cin>>s>>w;
	ll n=s.size();
	ll m=w.size();
	memset(M,0,sizeof M);
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			if(s[i-1]==w[j-1])
				M[i][j]=1+M[i-1][j-1];
			else M[i][j]=max(M[i-1][j], M[i][j-1]);
		}
	}

	dfs(s,w,n, m,"");
	cout<<M[n][m];
	int flag=1;


}


Measured memory_bytes: 107256
n = int(input())
l = list(map(int, input().split()))

p = min(l)
q = max(l)

ms = []
for i in range(p, q+1):
  m = 0
  for j in range(n):
    m += (l[j]-i)**2
  ms.append(m)
print(min(ms))
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int mod = -1e9-7;
int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n ; cin >> n;
	int cnt = 0;
	vpll v;
	for(int i = 0;i < n; ++i){
		int x , l; cin >> x >> l;
		v.pb(mp(x+l , x-l));
	}
	sort(all(v));
	int prev = mod;
	for(int i = 0;i < v.size() ; ++i){
		if(v[i].S >= prev){
			++cnt;
			prev = v[i].F;
		}
	}
	cout << cnt << endl;






	return 0;
}


Measured memory_bytes: 2420
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
//#define int unsigned long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

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

const int MOD = 998244353;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


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

	string S, T; cin >> S >> T;
	if (S.size() > T.size()) {
		T += " ";
	}
	REP(i, S.size()) {
		cout << S[i] << T[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int par[100001],sa[100001],sum[100001];

int find(int x){
  if(par[x]==x)return x;
  int px=par[x];
  find(par[x]);
  sa[x]+=sa[px];
  return par[x]=par[px];
}

void unite(int x,int y,int c){
  int px=find(x),py=find(y);
  if(px==py)return;
  sa[py]=c+sa[x]-sa[y];
  par[py]=px;
  return;
}

void IN(){
  int a,b,c;
  cin>>a>>b>>c;
  sum[a]+=c;
  sum[b]+=c;
  unite(a,b,c-sum[b]+sum[a]);
}

void COMP(){
  int a,b;
  cin>>a>>b;
  if(find(a)!=find(b)) cout <<"WARNING"<<endl;
  else cout << (sa[b]+sum[b])-(sa[a]+sum[a])<<endl;
}

int main(){
  int n,q;
  cin>>n>>q;
  for(int i=0;i<=n;i++) par[i]=i;
  while(q--){
    string str;
    cin>>str;
    if(str=="IN")IN();
    else COMP();
  }
  return 0;
}

Measured memory_bytes: 2388
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int m,n,k;
int ans,B[N],C[N],a[N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&B[i]);
	for (int i=1;i<n;i++) scanf("%d",&C[i+1]);
	ans+=B[a[1]];
	for (int i=2;i<=n;i++)
	{
		ans+=B[a[i]];
		if (a[i]-1==a[i-1]) ans+=C[a[i]];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N];
int main() {
	int n, t;
	cin >> n >> t;
	for (int j = 0; j < n; ++j)
		cin >> a[j];
	sort(a, a + n);
	a[n++] = 2e9 + 1;
	int res = 0;
	for (int j = 1; j < n; ++j)
		res += min(a[j] - a[j - 1], t);
	cout << res << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=10000+10;
int n;
ll a[N];
int main() {
    while(~scanf("%d",&n)){
        ll x;
        ll n1=0,n2=0;
        for(int i=0;i<n;i++){
            scanf("%lld",&a[i]);
        }
        for(int i=0;i<n;i++){
            scanf("%lld",&x);
            if(x>a[i]){
                if((x-a[i])%2==1){n2++;n1+=((x+1)-a[i])/2;}
                else {n1+=(x-a[i])/2;}
            }
            else {
                n2+=(a[i]-x);
            }

        }

        if(n1>=n2) printf("Yes\n");
        else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 384
S = [input() for _ in range(3)]
idx = 0
while len(S[idx]) > 0:
    card = S[idx][0]
    S[idx] = S[idx][1:]
    if card == 'a':
        idx = 0
    elif card == 'b':
        idx = 1
    else:
        idx = 2
if idx == 0:
    print('A')
elif idx == 1:
    print('B')
else:
    print('C')


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int DMAX=100000+5;
const int MOD=1000000000+7;
template<class T> inline void read(T &x){
	x=0;
	T f=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-'){
			f=-1;
		}
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){
		x=x*10+(ch-'0');
		ch=getchar();
	}
	x*=f;
}
ll n;
ll f[15][15];
ll cnt=0;
ll l,r,p;
vector<ll> v;
ll power(ll a,ll b){
	ll ans=1;
	for(int i=1;i<=b;i++){
		ans=ans*a;
	}
	return ans;
}
void DFS(ll len,ll last,ll now){
	if(len==l+1){
		v.pb(now);
		return ;
	}
	if(last==0){
		DFS(len+1,0,now*10+0);
		DFS(len+1,1,now*10+1);
	}
	else if(last==9){
		DFS(len+1,9,now*10+9);
		DFS(len+1,8,now*10+8);
	}
		else{
			DFS(len+1,last-1,now*10+(last-1));
			DFS(len+1,last,now*10+(last));
			DFS(len+1,last+1,now*10+(last+1));
		}
}
int main(){
	read(n);
	if(n<=9){
		cout<<n<<endl;
		return 0;
	}
	n-=9;
	for(int i=1;i<=9;i++){
		f[1][i]=1;
	}
	f[1][0]=0;
	for(int i=2;;i++){
		ll pol=0;
		for(int j=0;j<=9;j++){
			if(j==0){
				f[i][j]=f[i-1][j]+f[i-1][j+1];
				pol+=f[i][j];
				continue;
			}
			if(j==9){
				f[i][j]=f[i-1][j]+f[i-1][j-1];
				pol+=f[i][j];
				continue;
			}
			f[i][j]=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1];
//			cout<<pol<<" ";
			pol+=f[i][j];
		}
		// cout<<endl;
		// cout<<cnt<<" "<<pol+9<<" ";
		if(cnt<n && cnt+pol>=n){
			l=i;
			p=n-cnt;
			break;
		}
		cnt+=pol;
	}
	// ll poy=0;
	// for(int i=1;i<=10;i++){
	// 	ll add=0;
	// 	for(int j=0;j<=9;j++){
	// 		add+=f[i][j];
	// 		cout<<f[i][j]<<" ";
	// 	}
	// 	cout<<add;
	// 	poy+=add;
	// 	cout<<" "<<poy<<" ";
	// 	cout<<endl;
	// }
	// cout<<l<<" "<<p<<endl;
	for(int i=1;i<=9;i++){
		DFS(2,i,i);
	}
	sort(v.begin(),v.end());
//	 for(int i=0;i<v.size();i++){
//	 	cout<<v[i]<<" ";
//	 }
	cout<<v[p-1]<<endl;
	return 0;
}


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

int main() {
  int N, A;

  cin >> N;
  cin >> A;
  
  N = N % 500;
  
  if(N <= A){
  	cout << "Yes" << endl;
  }
  if(N > A) {
  	cout << "No" << endl;
  }

}

Measured memory_bytes: 256
using System;

namespace ITP1_2_D
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split(' ');
			int w = int.Parse(vs[0]);
			int h = int.Parse(vs[1]);
			int x = int.Parse(vs[2]);
			int y = int.Parse(vs[3]);
			int r = int.Parse(vs[4]);

			do {
				if(x - r < 0) {
					break;
				}

				if(y - r < 0) {
					break;
				}

				if(x + r > w) {
					break;
				}

				if(y + r > h) {
					break;
				}

				Console.WriteLine("Yes");
				return;
			}
			while(false);

			Console.WriteLine("No");
		}
	}
}



Measured memory_bytes: 18008
#include<bits/stdc++.h>
using namespace std;
bool b[510][510],c[510][510];
char a;
int i,j,k,n,m;
int main() {
	cin>>n>>m;
	for(i=1; i<=n; i++)
		for(j=1; j<=m; j++) {
			cin>>a;
			if(a=='#')b[i][j]=true,c[i][j]=true;
		}
	for(i=1; i<=n; i++)
		for(j=1; j<=m; j++) {
			if(i==1||(i%2==1&&j!=m)||(i!=n&&j==1))b[i][j]=true;
			if(i==n&&i%2==0||(i%2==0&&j!=1)||(i!=1&&j==m))c[i][j]=true;
		}
	for(i=1; i<=n; i++) {
		for(j=1; j<=m; j++)
			if(b[i][j])printf("#");
			else printf(".");
		printf("\n");
	}
	printf("\n");
	for(i=1; i<=n; i++) {
		for(j=1; j<=m; j++)
			if(c[i][j])printf("#");
			else printf(".");
		printf("\n");
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)
 
int main() {
  int b, ans = 0;
  bool ku = 0;
  long long n, a;
  string s = "No";
  cin >> n;
  a = n + 10;
  //vector<int> v(n), c(n);
  for(int i = 1; i <= sqrt(n) + 1; i++) {
    if(n % i == 0 && (i + n / i) < a + 2) a = (i + n / i) - 2;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))


indx = a.index(min(a))
i = (indx-1) + (n-indx)

if i % (k-1) == 0:
    print(int(i/(k-1)))
else:
    print(int(i/(k-1))+1)


Measured memory_bytes: 13880
import java.io.*;
import java.util.*;

public class Main {

	static class BitsetLong {

		static final int LOG = 6;
		static final int SIZE = 1 << LOG;
		static final int MASK = SIZE - 1;

		private long[] data;
		
		int n;

		public BitsetLong(int n) {
			this.n = n;
			data = new long[(n >> LOG) + 2];
		}

		void set(int i) {
			data[i >> LOG] |= 1L << (i & MASK);
		}

		void unset(int i) {
			data[i >> LOG] &= ~(1L << (i & MASK));
		}

		void flip(int i) {
			data[i >> LOG] ^= 1L << (i & MASK);
		}

		int get(int i) {
			return (int) ((data[i >> LOG] >>> (i & MASK)) & 1);
		}

		/**
		 * pads with zeroes if end of word is outside of range
		 */
		long getWord(int i) {
			
			if (i <= -SIZE || i >= n) {
				return 0;
			}
			
			int rem = i & MASK;
			int idx = i >> LOG;
			
			if (i < 0) {
				return (data[idx + 1] & ((1L << rem) - 1)) << (SIZE - rem);
			}

			if (rem == 0) {
				return data[idx];
			}

			long head = data[idx] >>> rem;
			long tail = data[idx + 1] & ((1L << rem) - 1);

			return head | (tail << (SIZE - rem));
		}
	}

	int solve(int[] a) {
		int sum = 0;
		
		BitsetLong cur = new BitsetLong(sum + 1);
		cur.set(0);
		
		for (int x : a) {
			sum += x;
			
			BitsetLong now = new BitsetLong(sum + 1);
			for (int i = 0; i < now.data.length; i++) {
				now.data[i] = cur.getWord(i << BitsetLong.LOG) | cur.getWord((i << BitsetLong.LOG) - x);  
			}
			cur = now;
		}
		
		int seek = (sum + 1) / 2;
		while (cur.get(seek) == 0) {
			seek++;
		}
		return seek;
	}

	void submit() {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}

		out.println(solve(a));
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {
		int n = 2000;
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = n;
		}
		out.println(solve(a));
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
//		 test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 149448
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <utility>
#include <functional>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n; cin>>n;
    int m=0;
    int c[200002];
    ll dp[200002]={};
    for(int i=0; i<n; i++){
        int c1; cin>>c1;
        if(m>0 && c[m-1]==c1) continue;
        c[m]=c1;
        m++;
    }
    ll dp0=1;
    for(int i=0; i<m; i++){
        dp[c[i]]+=dp0; dp[c[i]]%=MOD;
        dp0=dp[c[i]];
    }
    cout<<dp0<<endl;
    return 0;
}

Measured memory_bytes: 2560
//标准库排序
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	
	sort(A,A+n);
	
	for(int i=0;i<n-1;i++)
		cout<<A[i]<<" ";
	cout<<A[n-1]<<endl;
		
	return 0;
} 


Measured memory_bytes: 10904
#include <bits/stdc++.h>
using namespace std;
#define Maxn 10007
#define inf 100000007
int h,n,a[Maxn],b[Maxn];
int f[1007][Maxn];
int main()
{
    scanf("%d%d",&h,&n);
    for (int i=1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]);
    for (int i=0;i<=n;i++)
        for (int j=0;j<=h;j++)
            f[i][j]=inf;
    f[0][0]=0;
    for (int i=1;i<=n;i++)
        for (int j=0;j<=h;j++)
            f[i][j]=min(f[i-1][j],f[i][max(j-a[i],0)]+b[i]);
    printf("%d\n",f[n][h]);
    return 0;
}

Measured memory_bytes: 39424
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
  int i,j;
  for(i=1;i<=9;i++) 
    for(j=1;j<=9;j++)
      printf("%dx%d=%d\n",i,j,i*j);

  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
  int w,h,n,x[101],y[101],a[101],cnt=0;
  bool sq[101][101]={};
  cin >> w >> h >> n;
  rep(i,0,n){
    cin >> x[i] >> y[i] >> a[i];
  }
  rep(i,0,n){
    if(a[i]==1){
      rep(j,0,h){
        rep(k,0,x[i]){
          sq[j][k] = true;
        }
      }
    }else if(a[i]==2){
      rep(j,0,h){
        rep(k,x[i],w){
          sq[j][k] = true;
        }
      }
    }else if(a[i]==3){
      rep(j,0,y[i]){
        rep(k,0,w){
          sq[j][k] = true;
        }
      }
    }else{
      rep(j,y[i],h){
        rep(k,0,w){
          sq[j][k] = true;
        }
      }
    }
  }

  rep(i,0,h){
    rep(j,0,w){
      if(sq[i][j]==0) cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int occur[N];

int main(){
    AC
    int n;
    ll sum = 0;
    cin>>n;
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        sum+=x;
        occur[x]++;
    }

    int q;
    cin>>q;
    for(int i=0; i<q; i++){
        int a, b;
        cin>>a>>b;
        int diff = b-a;
        sum+=(ll)diff*occur[a];
        occur[b]+=occur[a];
        occur[a] = 0;
        cout<<sum<<nl;
    }
}

Measured memory_bytes: 4060
import java.util.*

fun main(args: Array<String>){

    var N = readLine()!!.toInt()
    var ans = 1L
    var base = LongArray(N+1){0}

    for(i in 2 until N+1){
        var tmpN = i
        for(j in 2 until i+1){
            while(tmpN % j == 0){
                tmpN /= j
                base[j]++
            }
        }
    }

    for(i in 1 until N+1){

            ans *= (base[i] +1)
            ans %= (1000000007).toLong()

    }
    println(ans)




}

Measured memory_bytes: 34424
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod    1000000007
#define PI 2*acos(0.0)


int32_t main()
{
    io;
    ll n;
    cin>>n;
    int i = 1;
    while(n - ceil(pow(26, i)) > 0)
    {
        n -= ceil(pow(26, i));
        i++;
    }
    n--;
    string ans(i, 'o');
    for(; i >= 1; i--)
    {
        ans[i-1] = char('a' + n%26);
        n/= 26;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <string.h>
using namespace std;
char temp[2000000];

void next1(char *s)
{
    int mm=strlen(s);
    s[mm]='a';
    s[mm+1]='\0';
    //cout<<s<<endl;
}
void next2(char *s)
{
    int mm=strlen(s);
    if(mm!=0){
    if(s[mm-1]<'z')
        s[mm-1]++;
    else
    {
        s[mm-1]='\0';
        if(mm-2>=0)
        s[mm-2]++;
    }}
    //cout<<s<<endl;
}

int main()
{
    char in[5005];
    int k;
    cin>>in>>k;
    temp[0]='a';
    temp[1]='\0';
    int flag=0;
    while(1)
    {
        if(strstr(in,temp))
        {
            flag++;
            if(flag==k)break;
            next1(temp);
        }
        else
        {
            next2(temp);
        }
    }
    cout<<temp<<endl;
}


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    while(true) {
        val (h, w) = readLine()!!.split(" ").map(String::toInt)
        if (h == 0 && w == 0) break
        for (i in 1..h) {
            for (j in 1..w) {
                print("#")
            }
            println("")
        }
        println("")
    }
}


Measured memory_bytes: 33648
import java.util.*;

class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n==0) break;

	    int[] dp = new int[n + 1];
	    dp[0] = 1;
	    for(int i=0; i<n; i++){
		for(int j=1; j<=3; j++){
		    if(i+j<=n) dp[i+j] += dp[i];
		}
	    }
	    int day = dp[n]/10 + ((dp[n]%10==0) ? 0 : 1);
	    System.out.println(day/365 + ((day%365==0) ? 0 : 1));
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 17188
#include<iostream>

using namespace std;
int num1,num2,num3,n,ans;
string s;

int main(){
	cin>>n;
	num1=num2=num3=ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		int len = s.length();
		if(s[0]=='B'&&s[len-1]=='A') num3++;
		else if(s[0]=='B') num2++;
		else if(s[len-1]=='A') num1++;
		for(int j=0;j<len;j++){
			if(j&&s[j]=='B'&&s[j-1]=='A') ans++;
		}
	}
//	cout<<num1<<" "<<num2<<" "<<num3<<endl;
	int temp=min(num1,num2);
	if(num1==0&&num2==0) ans=ans+max(num3-1,0);
	else if(num1==0) ans+=num3;
	else if(num2==0) ans+=num3;
	else ans=(ans+temp+num3);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<28
#define MAX_V 500
struct edge { int to,cap,rev; };
 
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
 
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
 
void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> que;
  level[s]=0;
  que.push(s);
  while(!que.empty()){
    int v=que.front();que.pop();
    for(int i=0;i<G[v].size();i++){
      edge &e = G[v][i];
      if(e.cap>0&&level[e.to]<0){
    level[e.to]=level[v]+1;
    que.push(e.to);
      }
    }
  }
}
 
int dfs(int v,int t,int f){
  if(v==t) return f;
  for(int &i=iter[v];i<G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d>0){
    e.cap-=d;
    G[e.to][e.rev].cap+=d;
    return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s,int t){
  int flow=0;
  for(;;){
    bfs(s);
    if(level[t]<0) return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,INF))>0){
      flow+=f;
    }
  }
}
 
int main(){
  int v,e,a,b,c,i;
  cin>>v>>e;
  for(i=0;i<e;i++){
    cin>>a>>b>>c;
    add_edge(a,b,c);
  }
  cout << max_flow(0,v-1) << endl;
  return 0;
}

Measured memory_bytes: 3200
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

q = deque([1])
visited = [False] * (n+1)
d = [0] * (n+1)

while q:
    now = q.popleft()
    visited[now] = True
    for i in graph[now]:
        if visited[i]:
            pass
        else:
            q.append(i)
            d[i] = d[now] + 1
if d[n] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 42364
#include <iostream>
auto max = [](auto a, auto b){
             if (a>b) return a;
             else return b;
           };

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

  long int minv=1'000'000'00000, maxv=1-1'000'000'000;
  int r;

  for (int i=0; i<n; i++)
    {
      std::cin >> r;
      maxv = max(maxv, r-minv);
      if (r < minv)
        minv = r;
    }

  std::cout << maxv <<std::endl;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) { cin >> a[i]; }
  int s = 0;
  int c = 0;
  rep(i, n) { s += a[i]; }
  rep(i, n) {
    if (4 * m * a[i] >= s) {
      c++;
    }
  }
  if (c >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
x,y=list(map(int,input().split()))
c=input()
l=list(map(int,c.split()))
s=sum(l)
t=s*(1/(4*y))
l.sort()
c=0
for i in l:
  if i>=t:
    c+=1
if c>=y:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
vector<int>v[100005];
vector<int>vis(100005),dis(100005),in(100005);
int n,m,mx=0;
void dfs(int u)
{
  vis[u]=1;
  for(int x: v[u])
  {
    dis[x]=max(dis[x],dis[u]+1);
    in[x]--;
    if(!in[x] && !vis[x])
      dfs(x);
    mx=max(mx,dis[x]);
  }
  
}
void solve()
{
  int i,j;
  cin>>n>>m;
  rep(i,0,m)
  {
    int x,y;
    cin>>x>>y;
    v[x].pb(y);
    in[y]++;
  }
  for(i=1;i<=n;i++)
  {
    if(!vis[i] && in[i]==0)
      dfs(i);
  }
  cout<<mx;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 12800
N,M = map(int, input().split())
LR = list()
al = 0
ar = 0
for i in range(M):
    LR.append( list(map(int,input().split())) )
    L = LR[i][0]
    R = LR[i][1]
    if i == 0:
        al = L
        ar = R
    if al < L:
        al = L
    if ar > R:
        ar = R
    if ar < L or al > R:
        print(0)
        exit()
print(ar-al+1)

Measured memory_bytes: 89416
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc132_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var count = new Dictionary<char, int>();
            for (int i = 0; i < s.Length; i++)
            {
                if (count.ContainsKey(s[i]))
                {
                    count[s[i]] += 1;
                }
                else
                {
                    count.Add(s[i], 1);
                }
            }
            var answer = count.Count == 2 && count.Values.FirstOrDefault() == 2;
            Console.WriteLine($"{(answer ? "Yes" : "No")}");
        }
    }
}


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

int main()
{
    int a;
    std::string s;
    std::cin >> a >> s;
    if (a >= 3200) {
        std::cout << s << std::endl;
    } else {
        std::cout << "red" << std::endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i <N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int scoreA = 0;
  int scoreB = 0;
  
  for (int i = 0; i < N; i += 2)
    scoreA += a[i];
  for (int i = 1; i < N; i += 2)
    scoreB += a[i];
  
  cout << scoreA - scoreB <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef pair<uint32_t,uint32_t> P;

int bitSearchReverse(uint32_t x){
    if(x==0)return -1;
    return 31-__builtin_clz(x);
}
struct RadixHeap{
    vector<P>v[33];
    uint32_t last,sz;
    RadixHeap(){
        last=sz=0;
    }
    void push(P p){
        assert(last<=p.first);
        sz++;
        v[bitSearchReverse(p.first^last)+1].push_back({p.first,p.second});
    }
    P top(){
        return pop(false);
    }
    P pop(bool f=true){
        assert(sz);
        if(!v[0].size()){
            int i=1;
            while(!v[i].size())++i;
            last=min_element(v[i].begin(),v[i].end())->first;
            for(P p:v[i])v[bitSearchReverse(p.first^last)+1].push_back(p);
            v[i].clear();
        }
        P r=v[0].back();
        if(f){
            sz--;
            v[0].pop_back();
        }
        return r;
    }
    int size(){
        return sz;
    }
    bool empty(){
        return sz==0;
    }
    void clear(){
        last=sz=0;
        for(auto a:v)a.clear();
    }
};
struct Graph{
    Graph(int n):E(n),d(n){}
    vector<vector<P>>E;
    vector<uint32_t>d;
    void add_edge(int a,int b,uint32_t c){
        E[a].emplace_back(b,c);
    }
    void dijkstra(int s){
        RadixHeap H;
        fill(d.begin(),d.end(),INF);
        H.push({d[s]=0,s});
        while(H.size()){
            P e=H.top();H.pop();
            if(e.first>d[e.second])continue;
            for(P& a:E[e.second]){
                uint32_t x=a.first,y=a.second+e.first;
                if(y<d[x])d[x]=y,H.push({y,x});
            }
        }
    }
};

main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    Graph G(N);
    for(int i=0;i<N;++i){
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;++j){
            int v,c;
            cin>>v>>c;
            G.add_edge(u,v,c);
        }
    }
    G.dijkstra(0);
    for(int i=0;i<N;++i)
        cout<<i<<' '<<G.d[i]<<endl;
}

/***************************************

referred
https://github.com/yosupo06/Algorithm/blob/master/datastructure/buf/RadixHeap.h

****************************************/

Measured memory_bytes: 7868
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> a(n+1);
	vector<int> b(n+1);
	for (int i = 1; i <= n; i++){
		cin >> a[i];
	}

	for (int i = n; i >= 1; i--){
		int sum = 0;
		for (int j = 2*i; j <= n; j+=i){
			sum += b[j];
		}
		if (sum % 2 == a[i]){
			b[i] = 0;
		}else{
			b[i] = 1;
			ans++;
		}
	}
	cout << ans << endl;
	for (int i = 1; i <= n; i++){
		if (b[i] == 1) cout << i << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 2432
/******************************************
* nils sjoberg never died  *
* He hibernated *
* So did dinesh easwar *
******************************************/
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstdlib>
#include <iomanip>
 
using namespace std;
typedef vector< long long > vec;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define pb push_back
#define PB pop_back()
#define sqr(a) (((a) * (a)))
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define umap unordered_map
#define all(c) (c).begin(),(c).end()
#define newl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a; i>=b; i--)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define sz(a) int((a).size())
#define frev(n) for(ll i=n-1; i>=0, i--)
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define vecpresent(container, element) (find(all(container), element) != container.end())
#define N 1000000007
#define PI 3.1415926535897932384
#define F first
#define S second
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll binpow(ll a, ll b, ll m){
	a %= m;
	ll res = 1;
	while(b>0){
	if(b&1)
		res = res * a % m;
	a = a * a % m;
	b >>= 1;
	}
	return res;
}

ll binmul(ll a, ll b, ll m){
	b %= m;
	ll res = 0;
	while(a>0){
		if(a&1)
			res = res + b % m;
		b = b + b % m;
		a >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}

pii fib(int n){
	if(n==0)
		return {0, 1};
	auto p = fib(n >> 1);
	int c = p.first * (2*p.second - p.first);
	int d = p.first*p.first + p.second*p.second;
	if(n&1)
		return {d, c+d};
	else
		return {c, d};
}


 
void solve(){
	ll n; cin >> n;
	if(n<30) cout<<"No";
	else cout<<"Yes";

	
}



int main()
{
 	FAST
	ll test;
	test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	return 0;
}



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

int main(){
  string S;
  cin >> S;
  string T;
  T=S;
  if(S=="keyence"){
    cout << "YES" << endl;
    return 0;
  }
  for(int i=0;i<S.size();i++){
    for(int j=1;j<=S.size()-i;j++){
      S.erase(S.begin()+i,S.begin()+i+j);
      if(S=="keyence"){
        cout << "YES" << endl;
        return 0;
      }else{
        S=T;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256