akhauriyash/Code-Regression huggingface dataset:
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e5 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int dpd[MAX],fake[MAX];
    int lmt;
    void self_add(int &a,int b)
    {
        a+=b;
        if(a>=MOD)a-=MOD;
    }

    void self_sub(int &a,int b)
    {
        a-=b;
        if(a<0)a+=MOD;
    }
    void solve()
    {
        cin>>n>>k;
        dpd[0]=1;
        fo(i,0,n)
        {
            cin>>lmt;
            // deb(lmt)
            mem(fake,0);
            rfo(used,k,0)
            {
                int tmp=dpd[used];
                l=used+1;
                r=used+min(lmt,k-used);
                if(l<=r)
                {
                    self_add(fake[l],tmp);
                    if(r+1<=k)
                    self_sub(fake[r+1],tmp);  
                }
                
            }

            int prefix_sum=0;
            fo(j,0,k+1)
            {
                self_add(prefix_sum,fake[j]);
                self_add(dpd[j],prefix_sum);

            }
        }
        // fo(i,0,k+1)
        // cout<<dpd[i]<<endl;
        // deb(k)
        cout<<dpd[k]<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 2560
//#include <bits/stdc++.h>/*
#include <unordered_map>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <iterator>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <complex>
#include <cassert>
#include <random>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <deque>
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <ctime>
#include <list>
#include <map>
#include <set>
//*/
 
#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;
 
template<class T> ostream &operator<<(ostream &os, const pair<T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const pair<const T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const array<T,3> &p){
	return os<<"("<<p[0]<<","<<p[1]<<","<<p[2]<<")";}
template<class T> ostream &operator<<(ostream &os, const vector<T> &p){
	for(auto x: p) os<<x<<' '; return os;}
#define dbug(x) cerr<<">>>> "<<#x<<" = "<<x<<endl
#define _ <<", "<<
#define FOR(X,L,R) for(int X=L;X<R;X++)
#define FI(I,X) for(auto I=(X).begin();I!=(X).end();I++)
#define print(X) {cerr<<"{ ";FI(I,X)cerr<<*I<<' ';cerr<<"}"<<endl;}
#define mset(V,X) memset(V,X,sizeof(V))
#define all(X) (X).begin(),(X).end()
#define upperb(V,X) (int)(upper_bound(all(V),(X))-V.begin())
#define lowerb(V,X) (int)(lower_bound(all(V),(X))-V.begin())
 
const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9+7;
const int INF = 0x3f3f3f3f, SZ = 2e5+20;

int n;
int v[100010][3];
int dp[100010][3];
int pd(int i, int j){
	if(dp[i][j] != -1) return dp[i][j];
	dp[i][j] = 0;
	FOR(k,0,3) if(k!=j){
		dp[i][j] = max(dp[i][j], pd(i-1,k)+v[i][j] );
	}
	return dp[i][j];
}
 
int32_t main(){
	ios::sync_with_stdio(false);cin.tie(0);
	
	mset(dp,-1);
	cin>>n;
	FOR(i,0,n) cin>>v[i][0]>>v[i][1]>>v[i][2];
	dp[0][0] = v[0][0];
	dp[0][1] = v[0][1];
	dp[0][2] = v[0][2];
	cout<<max( pd(n-1,0) , max( pd(n-1,1) , pd(n-1,2) ) )<<endl;
 
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c);
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000
#define PI acos(-1.0)

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

#define scan(x)      do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;
ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=0, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    //scan(n);
    cin>>n;
    ll A[n];
    f0(i,n)
    {
        cin>>A[i];
    }
    f1(i,n-1)
    {
       if(A[i-1]<A[i])
       {
           cnt=0;
       }
       else
       {
           cnt++;
           maxx=max(maxx,cnt);
       }
    }
    cout<<maxx<<endl;
    return 0;
}


Measured memory_bytes: 1024
N=int(input())
ans=[]
for i in range(N):
 t,x,y=map(int, input().split())
 if t<x+y:
  ans.append('No')
 elif (t%2==0 and (x+y)%2==1):
  ans.append('No')
 elif (t%2==1 and (x+y)%2==0):
  ans.append('No')
 else:
  ans.append('Yes')
if 'No' in ans:
 print('No')
else:
 print('Yes')

Measured memory_bytes: 3868
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
#define ll long long
#define fi first
#define se second
#define inf (999999999)
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int a[100000];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; a[i]--;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == inf)continue;
		if (a[a[i]] == i) {
			a[a[i]] = inf;
			a[i] = inf;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	int n=0, a[200] = {}, cnt=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	while (1) {
		int i = 0;
		for (; i < n; i++) {
			if (a[i] % 2) { break; }//奇数
			a[i] = a[i] / 2;
		}
		if (i == n) {
			cnt++;
		}
		else break;
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include <numeric>
#include<string>
using ll = long long;
using namespace std;
# define maxn 50
# define maxm 50

int main() {
  int a,A[4];
  cin>>a;
  A[0]=a/1000,A[1]=(a-A[0]*1000)/100,A[2]=(a-A[0]*1000-A[1]*100)/10,A[3]=(a-A[0]*1000-A[1]*100-A[2]*10);
  for (int bit(0);bit<(1<<3);bit++){
    int sum=A[0];
    string S;
    for (int i(0);i<3;i++){
      if (bit & (1<<i)){ //ibit目に1が立っていればここに来る
        sum+=A[i+1];
        S+="+";
      }else{
        sum-=A[i+1];
        S+="-";
      }
    }
    if(sum==7){
      cout<<A[0];
      for (int i(0);i<3;i++){
        cout << S[i]<<A[i+1];
      }
      cout<<"=7";
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

vector<ll> primes, totient, sumdiv, bigdiv;
vector<bool> prime;
void Sieve(ll n)
{
	prime.assign(n+1, 1);
	prime[1] = false;
	for(ll i = 2; i <= n; i++)
	{
		if(prime[i])
		{
			primes.pb(i);
			for(ll j = i*i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
}
void getpf(vector<ii>& pf, ll n)
{
	for(ll i = 0; primes[i]*primes[i] <= n; i++)
	{
		int cnt = 0;
		while(n%primes[i]==0)
		{
			n/=primes[i]; cnt++;
		}
		if(cnt>0) pf.pb(ii(primes[i], cnt));
	}
	if(n>1)
	{
		pf.pb(ii(n, 1));
	}
}

const bool DEBUG = 0;
const int MAXN = 1000005;

int n;
ll a[MAXN];
bool used[MAXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n) cin>>a[i];
	
	ll g=0;
	forn(i,0,n) g=__gcd(a[i],g);
	
	
	bool ok=0;
	Sieve(1e3+100);
	forn(i,0,n)
	{
		if(ok) break;
		vii pf; getpf(pf,a[i]);
		for(ii tmp: pf)
		{
			ll x=tmp.F;
			if(used[x])
			{
				ok=1; break;
			}
			used[x]=1;
		}
	}
	
	if(!ok) cout<<"pairwise coprime\n";
	
	else if(g==1) cout<<"setwise coprime\n";
	else cout<<"not coprime\n";
	
	return 0;
}


Measured memory_bytes: 11432
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cassert>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define fore(e, u, v) for (int p = e(u), v = e[p].y; p; v = e[p = e[p].nxt].y)
#define ri rd<int>
using namespace std;
const int maxN = 2e5 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n;

struct vec {
	static const int maxE = maxN << 1;
	int g[maxN], te, rt;
	struct edge {int y, nxt;} e[maxE << 1];
	vec() { te = 1; }
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { if (x == -1) { rt = y; return; } push(x, y), push(y, x); }
	inline int& operator () (int x) { return g[x]; }
	inline edge& operator [] (int x) { return e[x]; }
}T[2];

namespace way1 {
	int deg[maxN], rr[maxN];
	bool vis[maxN]; int kd[maxN];
	vec e;

	void dfs(int x, int fa, int id) {
		++deg[x + id]; int las = 0;
		fore (T[id == n], x, y) if (y != fa) {
			++deg[x + id];
			dfs(y, x, id);
			assert(rr[y] != 0);
			if (las) { e.link(las, rr[y]), las = 0; }
			else las = rr[y];
		}
		rr[x] = las ? las : x;
	}

	void col(int x, int c) {
		vis[x] = 1; kd[x] = c;
		fore (e, x, y)
			if (!vis[y]) col(y, -c);
			else assert(kd[x] == -kd[y]);
	}
	
	void main() {
		dfs(T[0].rt, 0, 0);
		dfs(T[1].rt, 0, n);
		e.link(rr[T[0].rt], rr[n + T[1].rt]);
		
		rep (i, 1, n) if ((deg[i] & 1) != (deg[i + n] & 1)) {
			puts("IMPOSSIBLE");
			return;
		}

		puts("POSSIBLE");
		rep (i, 1, n) if (!vis[i]) {
			if (!e.g[i]) kd[i] = 0, vis[i] = 1;
			else col(i, 1);
		}
		
		rep (i, 1, n) printf("%d%c", kd[i], " \n"[i == n]);
	}
}

namespace way2 {
	int deg[maxN], kd[maxN];
	int q[maxN << 2], tt;
	bool use[maxN << 2];
	vec e;

	void dfs(int x, int fa, int id) {
		++deg[x + id];
		fore (T[id == n], x, y) if (y != fa) {
			++deg[x + id];
			e.link(x + id, y + id);
			dfs(y, x, id);
		}
	}

	void euler(int x) {
		while (e.g[x]) {
			while (use[e.g[x]]) e.g[x] = e[e.g[x]].nxt;
			if (e.g[x]) {
				int p = e.g[x], y = e[p].y;
				e.g[x] = e[p].nxt;
				use[p] = use[p^1] = 1;
				euler(y);
				q[++tt] = y;
			}
		}
	}
	
	void main() {
		dfs(T[0].rt, 0, 0);
		dfs(T[1].rt, 0, n);
		e.link(0, T[0].rt), e.link(0, n + T[1].rt);

		rep (i, 1, n) if ((deg[i] & 1) != (deg[i + n] & 1)) {
			puts("IMPOSSIBLE");
			return;
		}
		rep (i, 1, n) if (deg[i] & 1) e.link(i, i + n);

		puts("POSSIBLE");
		euler(0); q[++tt] = 0;
		For (i, 1, tt) {
			if (q[i] <= n && q[i+1] > n) kd[q[i]] = -1;
			else if (q[i] > n && q[i+1] <= n) kd[q[i+1]] = 1;
		}
		rep (i, 1, n) printf("%d%c", kd[i], " \n"[i == n]);
	}
}

int main() {

	n = ri();
	rep (i, 1, n) T[0].link(ri(), i);
	rep (i, 1, n) T[1].link(ri(), i);
	
	way1::main();
	//way2::main();

	return 0;
}

Measured memory_bytes: 17664
no = gets.to_i
arr = Array.new(no){
    gets.to_i
}



def insSort(arr, no, g)
    (g...no).each { |i|
        v = arr[i]
        j = i-g
        while j >= 0 && arr[j] > v
            arr[j+g] = arr[j]
            j=j-g
            $cnt += 1
        end

        arr[j+g] = v
    }
end

def shellSort(arr, no)
    g = 1
    while g < no/3
        g = 3*g + 1
    end

    while g > 0
        insSort(arr, no, g)
        $garr << g
        g = (g-1)/3
    end
end

$cnt=0
$m = 0
$garr = []

shellSort(arr, no)
$m = $garr.size

puts $m
puts $garr * ' '
puts $cnt
puts arr

Measured memory_bytes: 13916
from sys import stdin 
n,a,b = map(int,stdin.readline().split())
aa = map(int,stdin.readline().split())
aa.sort()
aa.reverse()
di = {}
fa = [1]
for i in xrange(1,100):
    fa.append(i*fa[-1])
def ncr(n,r):
    return fa[n]/(fa[r]*fa[n-r])
for i in aa:
    di[i] = di.get(i,0) + 1 
def ways(m):
    b = aa[:m]
    co = b.count(b[-1])
    ll = aa.count(b[-1])
    return sum(b),ncr(ll,co)

num = 0 
den = 1
ans = 0 
for i in xrange(a,b+1):
    nn,ww = ways(i)
    dd = i 
    if nn * den > dd * num:
        num = nn 
        den = dd 
        ans = ww 
    elif nn * den == dd * num:
        ans += ww 
print "%.10f"%((num*1.0)/den)
print ans 
    
    
    

Measured memory_bytes: 2696
import sys
sys.setrecursionlimit(10**7)

n,x,y = map(int,input().split())

dst = [0] * n

#print(dst)

for i in range(1,n+1):
    for j in range(i+1,n+1):
        kyori = min(j-i,abs(x-i)+abs(y-j)+1)
        dst[kyori] += 1
        #print(i,j,kyori)
        
for i in range(n-1):
    print(dst[i+1])
#print(dst)

Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int a[100001];
int n;
int pow1(int a,int n)
{
	if(n==0) return 1;
	int x=pow1(a,n/2);
	long long ans=(long long)x*x%mod;
	if(n%2==1) ans=ans*a%mod;
	return ans;
}
bool check()
{
	sort(a+1,a+n+1);
	if(a[1]==0)
	for(int i=2;i<=n;)
	{
		if(a[i]!=a[i+1])
		return false;
		i+=2;
	}
	else
	{
		for(int i=1;i<=n;)
		{
			if(a[i]!=a[i+1])
			return false;
			i+=2;
		}
		
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==0)
		flag++;
	}
	if(flag==2||n%2==0&&flag>0||!check())
	printf("0\n");
	else 
	{
		if(flag==1)
		{
			n=n-1;
			n/=2;
		}
		else
		n/=2;
		int ans=pow1(2,n);
		printf("%d\n",ans);
	}
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

ll P[1005][1005];
ll dp[1005][1005];

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    Combination cmb(N + 5);

    memset(P, 0, sizeof(P));
    for (ll i = A; i <= B; ++i) {
        P[i][0] = 1;
        for (ll j = 1; j <= D; ++j) {
            if (i * j > N)
                break;
            P[i][j] = ((P[i][j - 1] * cmb.get(i * j, i) % MOD) * cmb.modpow(j)) % MOD;
        }
    }

    memset(dp, 0, sizeof(dp));
    dp[A - 1][0] = 1;
    for (ll i = A; i <= B; ++i) {
        for (ll j = N; j >= 0; --j) {
            dp[i][j] = dp[i - 1][j];
            for (ll n = C; n <= D; ++n) {
                ll m = j - i * n;
                if (m < 0)
                    break;
                dp[i][j] += ((dp[i - 1][m] * cmb.get(N - m, i * n)) % MOD) * P[i][n];
                dp[i][j] %= MOD;
            }
        }
    }

    cout << dp[B][N] << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define sz(v) (v).size()
// #define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
bool desc_sort(const int & lhs,const int & rhs)
{
    return lhs>rhs;
}
bool desc_pii_sort(const pii & lhs , const pii & rhs)
{
    return lhs>rhs;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.F = lhs.S;
    a.S = lhs.F;
    b.F = rhs.S;
    b.S = rhs.F;
    return a<b;
}
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 TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
#else
    #define trace(...)
#endif


// #define int long long
#define modd 1000000007



inline ll fast_expo(ll base,ll power,ll modulo=modd){
    base%=modulo;
    if (base<0LL) base+=modulo;
    ll x=base,cnt=power,ans=1LL;
    while(cnt){
        if (cnt&1LL) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1LL;
    }
    // int tmp=ans;
    return ans;
}
inline ll inv(ll base,ll modulo=modd){
    return fast_expo(base,modulo-2LL,modulo);
}

ll dp[2001][2001];

ll sum[2001];

signed main()
{
    #ifdef _SUBLIME
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    fio;
    int s;
    cin>>s;
    sum[0]=1;
    sum[1]=0;
    sum[2]=0;
    sum[3]=1;
    dp[3][3]=1;
    for(int i=4;i<=s;i++)
    {
        for(int j=3;j<=i;j++)
        {
            dp[i][j] = sum[i-j];
            sum[i] = (sum[i]+dp[i][j])%modd;
        }
    }
    d1(sum[s]);
    return 0;
}

Measured memory_bytes: 26148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;
const ll MAX = ll(1e10) * 300 + 10;
ll dp[310][int(1e3+10)];
ll A[int(1e6) + 1];
ll S[int(1e6) + 1];
ll S2[int(1e6) + 1];

vector<pair<ll, ll> > P;

ll N, M;

int main()
{
    cin >> N >> M;
    S[0] = 0;
    rep(i, N + 1){
        if (i == 0){
            S[0] = 0;
        } else {
            cin >> A[i];
            S[i] = (A[i] + S[i - 1]);
            //fprintf(stderr, "%d, %d = %d + %d - %d\n", i, S[i], A[i], S[i-1], i);
        }
        S2[i] = (S[i] + M - i)%M;
        
        P.push_back(make_pair(S2[i], i));
    }
    

    sort(P.begin(), P.end());
    //for (int i = 0;i < N + 1; i++){
    //    fprintf(stderr, "%d, %d, %d\n", i, P[i].first, P[i].second);
    //}
    ll ans = 0;
    int s = 0, t = 0;
    for (int i = 0; i <= N; i++){
        ans += t - s;
        //fprintf(stderr, "hoge %d: s = %d(%d, %d), t = %d, ans = %d\n", 
        //    i, s, P[s].first, P[s].second, t, ans);
        
        if (P[i].first == P[i + 1].first){
            while(s <= t && P[s].second + M <= P[i + 1].second){
                s++;
            }
            t++;
        } else {
            s = t = i + 1;
        }
 
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 15728
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
   
    for (int i = 0; i < N; i++)
    {
    
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}



Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int a,b,c,d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	bool sw = true;
	while(a>0 && c>0)
	{
		if(sw)
		{
			c = c - b;
			sw =false;
		}
		else
		{
			a = a - d;
			sw = true;
		}
	}
	if(a>0)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 3768
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String r = sc.next();
		
		if (n >= r.length()) {
		    System.out.println(r);
		} else {
		    String result = r.substring(0, n);
		    System.out.println(result + "...");
		}
		
		
    }
}



Measured memory_bytes: 38476
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int r, g, b;
    cin >> r >> g >> b;
    r *= 100;
    g *= 10;
    int val = r+g+b;
    if (val % 4 == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int n, m, x;
    cin >> n >> x;
    vector<int> v;
    
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> m;
        sum += m;
        v.push_back(m);
    }
    
    sort(v.begin(), v.end());
    
    cout << n + (x-sum)/v[0] << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    string s; cin >> s;
    int n = (int)s.size();
    set<char> st;
    for(auto e : s) st.insert(e);
    
    cout << (n == st.size() ? "yes" : "no") << endl; 
    
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations
import sys

N = int(input())
A = [[] for _ in range(N + 1)]
B = [[] for _ in range(N + 1)]
C = [[] for _ in range(N + 1)]
num_hint = []
# hint_dict = {}
for i in range(1, N + 1):
    num_i = int(input())
    num_hint.append(num_i)
    for j in range(num_i):
        x, y = map(int, input().split())
        A[i].append((x, y))
        if y == 1:
            B[i].append(x)
        if y == 0:
            C[i].append(x)
        # if hint_dict.get(x) is None:
        #     hint_dict[x] = {0: [], 1: []}
        #     hint_dict[x][y].append(i)
        # else:
        #     hint_dict[x][y].append(i)

for i in range(N + 1, 0, -1):
    for combi in combinations(range(1, N + 1), i):
        remain = set(range(1, N + 1)) - set(combi)
        s = set()
        t = set()
        hint_dict = {}
        for j in combi:
            s |= set(B[j])
            t |= set(C[j])
            for x, y in A[j]:
                if hint_dict.get(x) is None:
                    hint_dict[x] = {0: [], 1: []}
                    hint_dict[x][y].append(i)
                else:
                    hint_dict[x][y].append(i)
        good1 = True
        for value in hint_dict.values():
            if len(value[0]) != 0 and len(value[1]) != 0:
                good1 = False
                break
        good2 = True
        if len(s & remain) != 0:
            good2 = False
        good3 = True
        if len(t & set(combi)) != 0:
            good3 = False
        if good1 and good2 and good3:
            print(i)
            sys.exit()
print(0)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int ans=1;
  int now=a[0];
  rep(i,n-1){
    if(now==2){
      break;
    }
    if(i==n-2){
      ans=-1;
      break;
    }
    ans++;
    now=a[now-1];
  }
  cout(ans);
  return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    int d[k];
    for(int i = 0; i < k; i++) {
        cin >> d[i];
    }

    for(int ref = n; ref <= 10*n; ref++) {
        int tref=ref;
        int dign=log10(ref)+1;
        int e[dign];
        for(int i = 0; i < dign; i++) {
            e[dign-1-i]=tref%10;
            tref/=10;
        }
        bool jud=true;
        for(int i = 0; i < dign; i++) {
            for(int j = 0; j < k; j++) {
                if(e[i]==d[j]) jud=false;
            }
        }
        if(jud){
            cout << ref << "\n";
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 512
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

llong fib(llong n, vector<llong> &dp){
    if(dp[n]!=0){
        return dp[n];
    }
    if(n==1 || n==0){
        return 1;
    }
    
    return dp[n]=fib(n-1, dp)+fib(n-2, dp);
}

int main(){
    vector<llong> dp(1000, 0);
    llong n;
    cin >> n;
    cout << fib(n, dp) << endl; 
    return 0;
}



Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << fixed << setprecision(4) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << fixed << setprecision(4) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ull gcd(ull a, ull b){while(true){ull k = a % b;if(k == 0)return b;a = b;b = k;}}
ull comb(ull n, ull m){ull p=1;m=min(m,n-m);for(ull i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    int n;
    while(true){
        unordered_map<int,int> m;
        read(n);
        if(n==0)break;
        pair<int,int> res(0,0);
        rep(i,n){
            int a;
            read(a);
            int &t=m[a];
            t++;
            res=max(res,pair<int,int>(t,a));
        }
        if(res.first>n/2)write(res.second);
        else write("NO COLOR");
    }
    return 0;
}

Measured memory_bytes: 4336
n=gets.to_i
dp=Array.new(3,0)
pastdp=gets.split.map &:to_i
(n-1).times do
  dp=gets.split.map &:to_i
  0.upto(2) do |i|
    max=0
    0.upto(2) do |j|
      if i!=j && max < pastdp[j] 
        max=pastdp[j]
      end
    end
    dp[i] += max
  end
  pastdp=dp
end

unless dp.max==0
puts dp.max
else
  puts pastdp.max
end





Measured memory_bytes: 1788
//file_name:ABC46_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,k;
    scanf("%d%d",&n,&k);


    ll ans = k*pow(k-1,n-1);

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



Measured memory_bytes: 256
N,X=map(int,input().split())
li=list(map(int,input().split()))

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

if X not in li:
    li.append(X)
li=sorted(li)
distance=[]

for i in range(len(li)-1):
    distance.append(li[i+1]-li[i])

answer=1
if N==1:
    answer=distance[0]
else:
    element = gcd(distance[0], distance[1])
    if N==2:answer=element
    else:
        for i in range(2,N):
            element=gcd(element,distance[i])
        answer=element

print(answer)

Measured memory_bytes: 64408
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int best = INT_MAX;
    string s;
    cin >> s;
    for(int i = 0; i < s.size()- 2; i++)
    {
        string tmp = "";
        tmp += s[i];
        tmp += s[i + 1];
        tmp += s[i + 2];
        best = min(best, abs(stoi(tmp) - 753));
    }
    cout << best;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(max({a,b,c}) == a){
    cout << a*10+b+c << endl;
  }else if(max({a,b,c}) == b){
    cout << b*10+a+c << endl;
  }else if(max({a,b,c}) == c){
    cout << c*10+b+a << endl;
  }
}

Measured memory_bytes: 256
#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;

struct RMQ{
	using T = int;
	T operator()(const T &a, const T &b) { return min(a,b); };
	static constexpr T identity() { return INT_MAX; }
};

template<class Monoid>
class rangeUpdateQuery{
	private:
		using T = typename Monoid::T;
		Monoid op;
		const int n;
		vector<T> dat, lazy;
		int query(int a, int b, int k, int l, int r){
			evaluate(k);

			if(b <= l || r <= a) return op.identity();
			else if(a <= l && r <= b) return dat[k];
			else{
				int vl = query(a, b, k * 2, l, (l + r) / 2);
				int vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
				return op(vl, vr);
			}
		}
		inline void evaluate(int k){
			if(lazy[k] == op.identity()) return;
			dat[k] = lazy[k];
			if(k < n){
				lazy[2 * k] = lazy[k];
				lazy[2 * k + 1] = lazy[k];
			}
			lazy[k] = op.identity();
		}
		inline void propTo(int k){
			dat[k] = op(dat[2 * k], dat[2 * k + 1]);
		}
		void update(int a, int b, int k, int l, int r, int x){
			evaluate(k);
			if(r <= a || b <= l) return;
			if(a <= l && r <= b){
				lazy[k] = x;
				evaluate(k);
			}else if(l < b && a < r){
				update(a, b, k * 2, l, (l + r) / 2, x);
				update(a, b, k * 2 + 1, (l + r) / 2, r, x);
				propTo(k);
				evaluate(k);
			}
		}
		int power(int n){
			int res = 1;
			while(n >= res) res*=2;
			return res;
		}
	public:
		rangeUpdateQuery(int n) : n(power(n)), dat(4 * n, op.identity()), lazy(4 * n, op.identity()) {}
		rangeUpdateQuery(const vector<T> &v) : n(v.size()), dat(4 * n), lazy(4 * n, op.identity()){
			copy(begin(v), end(v), begin(dat) + n);
			for(int i = n - 1; i > 0; i--) propTo(i);
		}
		int query(int a, int b){ return query(a,b,1,0,n); }
		void update(int s, int t, int x){ update(s, t, 1, 0, n, x); }
		int get(int a){ return query(a, a + 1); };
		void out(int n){
			rep(i,n + 1){ cout << get(i) << ' '; }
			cout << endl;
			//rep(i,n){ range(j,i,n){ cout << i << ' ' << j + 1 << ' ' << query(i + 0,j + 1) << endl; } }
		}
		void out(){
			rep(i,n * 2){
				cout << i << " " << dat[i + 1] <<endl;
			}
		}
};

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

	rangeUpdateQuery<RMQ> seg(n);
	rep(i,q){
		int com;
		cin >> com;
		if(not com){
			int s, t, x;
			cin >> s >> t >> x;
			//cout << s << ' ' << t << endl;
			seg.update(s + 1, t + 2, x);
		}else{
			int s, t;
			cin >> s >> t;
			cout << seg.query(s + 1, t + 2) << endl;
		}
		//seg.out(n);
	}
	//seg.out();
}



Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,W,w[107],v[107];
long long f[107][307];
int main()
{
	n=read(),W=read();
	for (int i=1;i<=n;i++)
	{
		w[i]=read();
		if (i>1) w[i]-=w[1];
		v[i]=read();
	}
	int r=w[1];
	w[1]=0;
	memset(f,0,sizeof(f));
	for (int i=1;i<=n;i++)
	{
		for (int j=i;j;j--)
			for (int k=3*n;k>=0;k--)
			{
				if (k>0) f[j][k]=max(f[j][k],f[j][k-1]);
				if (k>=w[i]&&j>0) f[j][k]=max(f[j][k],f[j-1][k-w[i]]+v[i]);
			}
	}
	long long ans=0;
	for (int i=0;i<=n;i++)
		if (W-1LL*i*r>=0) 
		{
			ans=max(ans,f[i][min(3LL*n,W-1LL*i*r)]);
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    string s,a="1",b="0";
    cin>>s;
    long long n=s.size(),ansa=0,ansb=0;
    f(i,1,n){
        if(i%2==1){
            a+='0';
            b+='1';
        }
        else{
            b+='0';
            a+='1';
        }
    }
    f(i,0,n){
        if(s[i]!=a[i]){
            ansa++;
        }
        else if(s[i]!=b[i]){
            ansb++;
        }
    }
    cout<<min(ansa,ansb)<<endl;
    return 0;
}


Measured memory_bytes: 3956
#include <cstdio>
#include <algorithm>

int n;
int A[100001];
long long int S[100002];

int main(){
  scanf("%d", &n);
  long long int sum = 0;
  for(int i = 0; i <= n; ++i) scanf("%d", A+i), sum += A[i];
  for(int i = n; i >= 0; --i){
    S[i] = S[i+1] + A[i];
  }

  long long int ans = 0;
  long long int l = 1;
  int i;
  for(i = 0; i <= n; ++i){
    if(l < A[i]) break;
    ans += l;
    l -= A[i];
    l = std::min(2*l, S[i+1]);
  }

  if(i <= n) puts("-1");
  else printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 2896
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#include<functional>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

void dfs(ll depth,ll index, vl &nextButton, vb &pushButton){
	if (index == 1){
		cout << depth << endl;
		exit(0);
	}if (pushButton[index]) return;
	pushButton[index] = true;
	dfs(depth + 1, nextButton[index], nextButton, pushButton);
}

int main(){
	ll n, m; cin >> n >> m;
	if (abs(n - m) >= 2){
		cout << 0 << endl;
		return 0;
	}
	ll mod = 1e9 + 7;
	if (abs(n - m) == 1){
		ll maxi = max(n, m);
		ll mini = min(n, m);
		ll ans = maxi;
		nrep(i,1, mini+1){
			ans = ((((ll)i*i) % mod)*ans) % mod;
		}cout << ans%mod << endl;
		return 0;
	}
	else{
		ll ans = 1;
		nrep(i, 1, n + 1){
			ans = ((((ll)i*i) % mod)*ans) % mod;
		}cout << (ans*2)%mod << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl        '\n'
#define pi          2*acos(0.0)
#define pb(a)       push_back(a)
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define mod         1000000007
#define inf         1000000000000000001
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define all(x)      (x).begin(), (x).end()
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


ull f(ull n, ull d) {
    if(n == -1)
        return 0;
    return n / d + 1;
}

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    ull a, b, x;
    cin >> a >> b >> x;
    cout << (f(b,x)) - f((a-1), x ) << endl;

    return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var H = items[0];
            var A = items[1];

            var answer = 0;
            while(true)
            {
                answer++;
                H -= A;
                if (H <= 0)
                {
                    break;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int s;
    cin >> s;
    int n = 1e6 + 1;

    map<int, int> mp;

    mp[s] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (mp[s] == 2)
        {
            OP(i);
            return 0;
        }
        if (s & 1)
        {
            mp[3 * s + 1]++;
            s = 3 * s + 1;
        }
        else
        {
            mp[s / 2]++;
            s = s / 2;
        }
    }
    return 0;
}

Measured memory_bytes: 256