akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep2(i, j, n) for (LL i = j; i <= n; ++i)
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define boost cin.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(), x.end()

using namespace std;

const int N = 2111;

int n, k, a, b;
vector <int> v[N];

int ans;
int siz[N];
int dp[N][N]; // dp[i][j] = ile minimalnie musze usunac zeby srednica byla <= j
int dp2[N];

void dfs(int u, int p) {
	siz[u] = 1;
	rep(i, 0, n) dp[u][i] = 0;
	for (auto it : v[u]) {
		if (it == p) continue;
		dfs(it, u);
		siz[u] += siz[it];
		
		rep(i, 0, n) dp2[i] = n;
		
		rep(ja, 0, n) {
			dp2[ja] = min(dp2[ja], dp[u][ja] + dp[it][min(ja, k - ja)]);
			dp2[ja] = min(dp2[ja], dp[it][ja] + dp[u][min(ja, k - ja)]);
		}
		
		rep(i, 0, n) dp[u][i] = dp2[i];
		rep(i, 1, n) dp[u][i] = min(dp[u][i], dp[u][i - 1]);		
	}
	ans = min(ans, dp[u][k] + (n - siz[u]));
	per(i, 0, n - 1) dp[u][i + 1] = dp[u][i];
	dp[u][0] = siz[u];
}				
		

int main() {		
	scanf ("%d%d", &n, &k);
	rep(i, 1, n - 1) {
		scanf ("%d%d", &a, &b);
		v[a].pb(b);
		v[b].pb(a);
	}
	ans = n;
	dfs(1, 0);
	printf ("%d\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 17024
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// 与えられたx, y, pに対して、x^i=y(mod p)を満たす最小の正の整数iを返す
// 存在しない場合は-1
// O(√p log(p))
ll modlog(ll x, ll y, ll p) {
    ll H = sqrt(p) + 1;
    pair<ll, ll> baby[H];
    for(ll b = 0, xby = y; b < H; b++, xby = (xby * x) % p) {
        baby[b] = make_pair(xby, b);
    }
    sort(baby, baby + H);
    ll xH = 1;
    for(int i = 0; i < H; ++i) {
        xH = (xH * x) % p;
    }
    for(ll a = 1, xaH = xH; a <= H; a++, xaH = (xaH * xH) % p) {
        auto it = lower_bound(baby, baby + H, make_pair(xaH + 1, 0LL));
        if(it == baby) {
            continue;
        }
        it--;
        if(it->first == xaH) {
            return a * H - it->second;
        }
    }
    return -1;
}

ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    if(k % 7 == 0) {
        k /= 7;
    }
    ll ans = modlog(10, 1, 9 * k);
    if(pow_mod(10, ans, 9 * k) == 1) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;

int main(){
	cin>>n>>k;
	if((n+1)/2>=k) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInt()

    var ans = false
    for (i in 1..9) {
        for (j in 1..9) {
            if (i * j == n) ans = true
        }
    }
    if (ans) println("Yes") else println("No")
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


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

int main(){
  int N,Ncandy,buf;
  cin >> N >> Ncandy;

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());

  int remain_candy= Ncandy;
  int ans= 0;
  for(auto elem:data){
    if(remain_candy >= elem){
      remain_candy-= elem;
      ans++;
    }
    else{
      remain_candy= 0;
      break;
    }
  }
  if(remain_candy > 0){ ans--; }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int n, m;
	cin >> n >> m;
	dump((n-1) * (m-1))
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) cin >> a.at(i).at(j);
  }
  for (int i=0; i<H+2; i++) {
    if (i==0||i==H+1) {
      for (int j=0; j<W+2; j++) {
        if (j!=W+1) cout << "#";
        else cout << "#" << endl;
      }
    }
    else {
      for (int j=0; j<W+2; j++) {
        if (j==0) cout << "#";
        else if (j==W+1) cout << "#" << endl;
        else cout << a.at(i-1).at(j-1);
      }
    }
  }
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
if A_list[0] == 0:
    print(0)
else:
    ans = 1

    for a in A_list:
        ans *= a

        if ans > 10 ** 18:
            ans = -1
            break

    print(ans)


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

using namespace std;

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    for ( int i = 0; i < n; i++ ){
        string s;
        cin >> s;
        mp[s]++;
    }
    int ans = mp.size();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19220
import java.util.*;
public class Main{

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            
            if(x==0 && y==0) break;
            else{
                StringBuilder result = new StringBuilder();
                result.append(Math.min(x,y))
                .append(" ")
                .append(Math.max(x,y));
                System.out.println(result);
            }
        }
    }
}



Measured memory_bytes: 37328
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int ans=700;
	cin>>s;
	if(s[0]=='o') ans=ans+100;
	if(s[1]=='o') ans=ans+100;
	if(s[2]=='o') ans=ans+100;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n,*a=map(int,open(0).read().split())
cur=1
ans=a[0]-1
a[0]=1
for x in a:
	if x<=cur:
		pass
	elif x==cur+1:
		cur=x
	else:
		ans+=0--(x-cur-1)//(cur+1)
print(ans)

Measured memory_bytes: 14332
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 512

#define ldouble long double
using namespace std;

long long INF = 1e9;

const int N = 300031;

long long n,m,fact[N];

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	fact[0]=1;
	for (int i=1;i<N;i++)
	{
		fact[i]=fact[i-1]*i%bs;
	}

	cin>>n>>m;
	if (abs(n-m)>1)
	{
		cout<<0<<endl;
		return 0;
	}

	long long ans=fact[n]*fact[m];
	ans%=bs;
	if (n==m)
		ans*=2;
	cout<<ans%bs<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 3196
#!/usr/bin/env python
# coding: utf-8

# In[1]:


from collections import deque


# In[30]:


def main():
    H,W = map(int, input().split())
    ch,cw = map(int, input().split())
    dh,dw = map(int, input().split())
    s = ["#"*(W+4)]
    s.append("#"*(W+4))
    for i in range(H):
        s.append("##"+input()+"##")
    s.append("#"*(W+4))
    s.append("#"*(W+4))
    
    ans = [[-1]*(W+4) for _ in range(H+4)]
    for i in range(H+4):
        for j in range(W+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ch += 1; cw += 1
    dh += 1; dw += 1
    ans[ch][cw] = 0
    
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    magic = [
        [-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],\
        [-1,-2],[-1,-1],[-1,0],[-1,1],[-1,2],\
        [0,-2],[0,-1],[0,0],[0,1],[0,2],\
        [1,-2],[1,-1],[1,0],[1,1],[1,2],\
        [2,-2],[2,-1],[2,0],[2,1],[2,2]
        ]
    
    mylist = deque([[ch,cw]])
    mylist2 = deque([])
    while len(mylist) > 0:
        x,y = mylist.popleft()
        mylist2.append([x,y])
        for p,q in move:
            v1,v2 = x+p,y+q
            if ans[v1][v2] == -1:
                mylist.append([v1,v2])
                ans[v1][v2] = ans[x][y]
        if len(mylist) == 0:
            while len(mylist2) > 0:
                x2,y2 = mylist2.popleft()
                for v1,v2 in magic:
                    i,j = x2+v1,y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        mylist.append([i,j])
    print(ans[dh][dw])

if __name__ == "__main__":
    main()


# In[31]:


# H,W = map(int, input().split())
# ch,cw = map(int, input().split())
# dh,dw = map(int, input().split())
# s = ["#"*(W+4)]
# s.append("#"*(W+4))
# for i in range(H):
#     s.append("##"+input()+"##")
# s.append("#"*(W+4))
# s.append("#"*(W+4))


# In[32]:


# ans = [[-1]*(W+4) for _ in range(H+4)]
# for i in range(H+4):
#     for j in range(W+4):
#         if s[i][j] == "#":
#             ans[i][j] = -2
# ch += 1; cw += 1
# dh += 1; dw += 1
# ans[ch][cw] = 0


# In[33]:


# move = [[-1,0],[1,0],[0,-1],[0,1]]
# magic = [
#     [-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],\
#     [-1,-2],[-1,-1],[-1,0],[-1,1],[-1,2],\
#     [0,-2],[0,-1],[0,0],[0,1],[0,2],\
#     [1,-2],[1,-1],[1,0],[1,1],[1,2],\
#     [2,-2],[2,-1],[2,0],[2,1],[2,2]
#     ]


# In[34]:


# mylist = deque([[ch,cw]])
# mylist2 = deque([])
# while len(mylist) > 0:
#     x,y = mylist.popleft()
#     mylist2.append([x,y])
#     for p,q in move:
#         v1,v2 = x+p,y+q
#         if ans[v1][v2] == -1:
#             mylist.append([v1,v2])
#             ans[v1][v2] = ans[x][y]
#     if len(mylist) == 0:
#         while len(mylist2) > 0:
#             x2,y2 = mylist2.popleft()
#             for v1,v2 in magic:
#                 i,j = x2+v1,y2+v2
#                 if ans[i][j] == -1:
#                     ans[i][j] = ans[x2][y2]+1
#                     mylist.append([i,j])
# print(ans[dh][dw])


# In[ ]:






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

int main(){
    string s;
    cin>>s;
    if (s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout<<"Yes"<<endl;
    else if (s[0]==s[3]&&s[1]==s[2]&&s[0]!=s[1]) cout<<"Yes"<<endl;
    else if (s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(deque<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N;
	cin >> N;

	deque<string> board;
	inputVector(board, N);

	bool ok[310];
	rep(i, N) ok[i] = true;
	rep(y, N) rep(x, N) {
		rep(i, N) {
			int tx = (N - i + y) % N;
			int ty = (x + i + N) % N;
			if (board[y][x] != board[ty][tx]) {
				ok[i] = false;
			}
		}
	}

	int ret = 0;
	rep(i, N) ret += ok[i];
	ret *= N;
	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
typedef long long ll;
int n,i,u,v,sz[N];
vector<int>e[N];
ll f[N],ds,ans=1ll<<60;
char c[N];
ll getd(int x,int fa,int d){
	ll ans=c[x]=='1'?d:0;
	for(int v:e[x])if(v!=fa)ans+=getd(v,x,d+1);
	return ans;
}
void getf(int x,int fa,int d){
	f[x]=sz[x]=0;
	for(int v:e[x])if(v!=fa)getf(v,x,d+1),
		f[x]=f[x]<f[v]?f[v]-f[x]:f[x]-f[v],sz[x]+=sz[v];
	if(c[x]=='1')++sz[x];f[x]+=sz[x];
}
int main(){
	scanf("%d%s",&n,c+1);
	for(i=1;i<n;++i)scanf("%d%d",&u,&v),e[u].push_back(v),e[v].push_back(u);
	for(i=1;i<=n;++i){
		ll mx=0,id=0,zz;ds=0;
		for(int v:e[i]){
			ds+=zz=getd(v,i,1);
			if(zz>mx)mx=zz,id=v;
		}
		if(ds&1)continue;
		if(mx>ds-mx){
			getf(id,i,1);
			if(f[id]>ds-mx)continue;
		}
		ans=min(ans,ds/2);
	}
	if(ans==1ll<<60)ans=-1;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
	long long A[100005];
	long long n, x;
	scanf("%lld %lld", &n, &x);
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		long long  aux;
		scanf("%lld", &aux);
		A[i] = aux;
	}
	for (int i = 0; i < n; i++) {
    	if (A[i] > x) {
    		ans += A[i] - x;
    	 	A[i] = x;
    	}
    	if (i && A[i] + A[i - 1] > x) {
    		ans += A[i] + A[i-1] - x;
    		A[i] -= A[i] + A[i-1] - x;
    	}
    }	
	cout << ans;
}

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

const int N = 1e5 + 5;
int ans[N];
int h[N];
int main(){
    int n;
    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>h[i];
    ans[0]=0;
    ans[1] = abs(h[0]-h[1]);
    for(int i = 2; i < n ; i++){
        ans[i] = min(abs(h[i]-h[i-2])+ans[i-2],abs(h[i]-h[i-1])+ans[i-1]);
    }
    cout<<ans[n-1];


}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		
		Arrays.setAll(a, i -> sc.nextInt());
		Arrays.sort(a);
		
		int Alice = 0;
		int Bob = 0;
		int turn = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (turn == 0) {
				Alice += a[i];
			} else {
				Bob += a[i];
			}
			turn ^= 1;
		}
		
		int ans = Alice - Bob;
		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 27092
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int> a, pair<int,int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	llint n;
	cin >> n;
	for (llint i = 1; i <= 3500; i++) {
		for (llint j = 1; j <= 3500; j++) {
			llint a = n * i * j, b = 4 * i * j - n * (i + j);
			if (b == 0)continue;
			if (a < 0 || b < 0)continue;
			if (a % b == 0) {
				cout << i << " " << j << " " << a / b << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
p = input()
isYes = False

for start in range(0, len(s)):
    if s[start] == p[0]:
        i = start
        j = 0
        while j < len(p):
            if s[i] != p[j]:
                break
            i += 1
            if i == len(s):
                i = 0
            j += 1
        else:
            print("Yes")
            exit(0)
if not isYes:
    print("No")



Measured memory_bytes: 5560
import sys 
try:
	sys.stdin = open('input.txt', 'r') 
	sys.stdout = open('output.txt', 'w')
except:
	pass
# input = sys.stdin.readline
for tt in range(1):
	a = input()
	b = input()
	if a==b[:-1]:
		print("Yes")
	else:
		print("No")
	

Measured memory_bytes: 9040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if (b == 1) {
			System.out.println(0);
			return;
		}
		int ans = 1;
		int x = a;
		while (x < b) {
			x += a - 1;
			ans++;
		}
		System.out.println(ans);
	}
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007; 

ll modpow(ll a, ll b){
  ll ans = 1;
  while(b){
    if(b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}

vll inv(200005, 1);
void cominit(){
  rep(i, 2, 200005) inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
}

ll comb(ll n, ll k){
  ll ans = 1;
  rep(i, 0, k)ans = ans * (n - i) % mod * inv.at(i + 1) % mod;
  return ans;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  cominit();
  ll ans = modpow(2, n) - 1 - comb(n, a) - comb(n, b);
  cout << (mod + ans % mod) % mod << endl;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
l=[0]*60
r=[0]*60
for i in range(n):
	x=format(a[i],'b').zfill(60)
	for j in range(60):
		if x[j]=='0':
			l[j]+=1
		else:
			r[j]+=1
#print(l,r)
ans=0
for i in range(60):
	ans+=l[i]*r[i]*(2**(59-i))
print(ans%(10**9+7))

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

int main(){
  string s;
  cin >> s;
  int n = s.length();
  int r=0;
  int l=0;
  int ans[n];
  rep(i,n) ans[i]=0;
  rep(i,n){
    //cout << r << l << endl;
    if(s[i]=='R'){
      l=0;
      r++;
    }else if(l==0){
      ans[i-1] += r/2+r%2;
      ans[i] += r/2+1;
      r = 0;
      l = 1;
    }else{
      l++;
      ans[i-l+l%2] += 1;
    }
  }
  rep(i,n)cout << ans[i] << ' ';
  cout << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())

li_a = list(map(int, input().split()))

result = -1
for t in range(min(li_a), max(li_a) + 1):
    sum = 0
    for a in li_a:
        sum += (a - t)**2
    if result < 0:
        result = sum
    else:
        result = min(result, sum)

print(result)


Measured memory_bytes: 2940
from itertools import product
from operator import mul
def main():
    n = int(input())
    f = [tuple(map(int, input().split())) for _ in range(n)]
    p = [tuple(map(int, input().split())) for _ in range(n)]

    patterns = tuple(product([0,1], repeat=10))
    results = []
    for pate in patterns:
        if sum(pate) == 0:
            continue
        r = 0
        for i1, fe in enumerate(f):
            r += p[i1][sum(tuple(map(mul, pate, fe)))]
        results.append(r)
    print(max(results))
if __name__ == '__main__':
    main()

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n;
  cin >> n;
  ll a[n];
  for(int i = 0 ; i < n ; i ++ )
    cin >> a[i];
  if(a[0] > 0){
  	cout << "-1\n";
    return 0;
  }
  for(int i = 1 ; i < n ; i ++ ){
    if(a[i] - a[i - 1] > 1){
      cout << "-1\n";
      return 0;
    }
  }
  ll res = a[0];
  set<int> tt;
  for(int i = n - 1; i >= 0 ; i -- ){
    if(!tt.count(a[i] - i)){
      res += a[i];
      tt.insert(a[i] - i);
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */





int main() {
    


    string s;
    cin>>s;
    int sum=0;
    rep(i,s.size())sum+=s[i]-'0';
    Yn(sum%9==0);
}


Measured memory_bytes: 3724
console.log((args=>{
  const [X,K,D] = args.trim().split` `.map(v=>parseInt(v));
  const x = Math.abs(X);
  if ( x / K > D ) return x - K*D;
  const d = K - Math.floor(x/D);
  return d&1 ? D-x%D : x%D;
})(require('fs').readFileSync('/dev/stdin','utf8')));


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  int n;
  string s;
  cin >> n >> s;

  int cnt = 0;
  int l = 0;
  rep(i, 0, n){
    if(s[i] == '('){
      if(cnt < 0){
        l -= cnt;
        cnt = 1;
      }else{
        cnt++;
      }
    }else{
      cnt--;
    }
  }

  if(cnt < 0){
    l -= cnt;
    cnt = 0;
  }

  rep(i, 0, l) cout << "(";
  cout << s;
  rep(i, 0, cnt) cout << ")";
  cout << endl;

  return 0;
}



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


int main() {
    vector<char> s(3);
    for (int i = 0; i < 3; i++) {
        cin >> s.at(i);
    }
    if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R') {
    cout << 3 << endl;
    }
    else if (s.at(0) == 'R' && s.at(1) == 'R') {
        cout << 2 << endl;
    }
    else if (s.at(1) == 'R' && s.at(2) == 'R') {
        cout << 2 << endl;
    }
    else if (s.at(0) == 'R' && s.at(1) == 'S' && s.at(2) == 'R') {
        cout << 1 << endl;
    }
    else if (s.at(0) == 'R' && s.at(1) == 'S' && s.at(2) == 'S') {
        cout << 1 << endl;
    }
    else if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'S') {
        cout << 1 << endl;
    }
    else if (s.at(0) == 'S' && s.at(1) == 'S' && s.at(2) == 'R') {
        cout << 1 << endl;
    }
    else cout << 0 << endl;

    return 0;
}


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

void show(vector<ll>& vc)
{
    for(auto it:vc)cout<<it<<" ";
    cout<<endl;
}
#define M 300014



/**
int marked[M/64 + 2];

#define on(x) (marked[x/64] & (1<<((x%64)/2)))
#define mark(x)  marked[x/64] |= (1<<((x%64)/2))

void bitwiseSieve() {
  for (int i = 3; i * i <=M; i += 2) {
    if (!on(i)) {
      for (int j = i * i; j <= M; j += i + i) {
        mark(j);
      }
    }
  }
}

bool isPrime(int num) {
  return num > 1 && (num == 2 || ((num & 1) && !on(num)));
}
**/


/**
vector<ll>phi(M+2);
bool p[M+2];

void euler_phi(void)
{

    for(ll i=0;i<=M;i++)phi[i]=i;
    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;
    phi[1] = 0;

    for(ll i=2; i<=M; i++)
    {

        if(!p[i])
        {

            for(ll j=i; j<=M; j+=i)
            {
                p[j]=1;
                phi[j]/=i;
                phi[j]*=(i-1);

            }
            p[i]=0;
        }
    }


}
//**/


/**
bool p[M+2];
vector<ll>prime;
void seive(void)
{

    memset(p,0,sizeof p);
    p[1]=1;
    p[0]=1;

    for(ll i=4; i<=M; i+=2)
    {
        p[i]=1;

    }

    for(ll i=3; i*i<=M; i+=2)
    {

        if(!p[i])
        {

            for(ll j=i*i; j<=M; j+=2*i)
            {
                p[j]=1;

            }
        }
    }

    prime.push_back(2);
    for(ll i=3; i<=M; i+=2)prime.push_back(i);
}
//**/


/**
ll dx[] = {-1,-1,0,-1,1,0,1,1};
ll dy[] = {-1,0,-1,1,-1,1,0,1};
**/


typedef pair<ll, ll> pii;
#define x first
#define y second


pii extendedEuclid(ll a, ll b)   // returns x, y | ax + by = gcd(a,b)
{
    if(b == 0) return pii(1, 0);
    else
    {
        pii d = extendedEuclid(b, a % b);
        return pii(d.y, d.x - d.y * (a / b));
    }
}

ll modularInverse(ll a, ll n)
{
    pii ret = extendedEuclid(a, n);
    return ((ret.x % n) + n) % n;
}
//**/


/**
ll bigmod(ll a, ll b, ll c)
{
    if(b==0)return 1;
    if(b%2)
    {
        ll p = bigmod(a,b-1,c);
        return (a*p)%c;
    }
    else
    {
        ll p = bigmod(a,b/2,c);
        return (p*p)%c;
    }
}
//**/

ll arr[200002];
ll mod = 1000000007;


ll ncr(ll n, ll r)
{
    ll ans = arr[n];
    ans*=modularInverse(arr[r],mod);
    ans%=mod;
    ans*=modularInverse(arr[n-r],mod);
    ans%=mod;
    return ans;
}


void solve(ll t)
{


   ll n,m,a,b;
   cin>>n>>m>>a>>b;
   ll x = n-a;
   ll y = b+1;
   ll ans=0;
   for( ; x>0 && y<=m ; x--,y++)
   {

       ll i=x;
       ll j=y;
       ll dx = n-x;
       ll dy = m-y;
       i--;
       j--;
       ans+= (ncr(i+j,i)*ncr(dx+dy,dx))%mod;
       ans%=mod;


   }

   cout<<ans<<endl;





}


int main()
{
//     freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);

    /**seive();        //**/
    /** euler_phi();    //**/
    /** show(phi);      //**/
    /** bitwiseSieve(); //**/

    arr[0]=1;
    for(ll i=1;i<=200000;i++)
    {
        arr[i]=arr[i-1];
        arr[i]*=i;
        arr[i]%=mod;
    }



    ll t=1;
    //scanf("%lld",&t);
    ll T=t;



    while(t--)
    {


        solve(T-t);

    }
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n], s = 0, r[n], ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }
    for (int i = 1; i * i <= s; i++) {
        if (s % i)
            continue;
        int vs[2] = {i, s / i};
        for (int x: vs) {
            int p = 0, m = 0;
            for (int j = 0; j < n; j++) {
                r[j] = a[j] % x;
                p += x - r[j];
            }
            sort(r, r + n);
            for (int j = 0; j < n; j++) {
                m += r[j];
                p -= x - r[j];
                if (m == p) {
                    if (p <= k)
                        ans = max(ans, x);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

vector<P> func(ll N){
    vector<P> res;
    ll n = N;
    for(ll i=2; i*i<=N; i++){
        if(n%i!=0) continue;
        P p = P(i, 0);
        while(n%i==0){
            p.second++;
            n/=i;
        }
        res.emplace_back(p);
    }
    if(n>1) res.emplace_back(P(n, 1));
    return res;
}
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    long long a, b;

    cin >> a >> b;
    vector<P> fa = func(a), fb = func(b);
    fa.emplace_back(P(1, 1));
    fb.emplace_back(P(1, 1));
    set<ll> sa, res;
    for(auto &x: fa){
        sa.insert(x.first);
    }
    for(auto &x: fb){
        if(sa.count(x.first)) res.insert(x.first);
    }
    cout << res.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
int n, x, d;
struct segment{
    ll l, r;
    bool operator < (const segment & x ) const{
        return l == x.l ? r < x.r : l < x.l;
    }
};
unordered_map<int, vector<segment>> ss;

int main(){
    scanf("%d %d %d", &n, &x, &d);
    ///if(d == 0) ?
    if(d == 0){
        ///(x = 0 and d = 0) 1
        /// x x x x x x x x x x (n) tokens
        /// 2 1 0
        /// 1 1
        /// 0 1 2
        /// x 0 -> (n * (n + 1)) /2
        return !printf("%lld\n", x == 0 ? 1LL : n + 1);
    }
    auto calc = [&] (int x){
        return 1LL * x * (x + 1) / 2;
    };
    /// for each chosen k numbers
    for(int k = 0 ;k <= n ; k ++){
        int res = 1LL * k * x % d;
        ll nd = 1LL * k * x / d; // 2
        ll lft = calc(k - 1); // 2
        ll rgh = calc(n - 1) - calc(n - 1 - k); // 5
        lft += nd;
        rgh += nd;
      //  fprintf(stderr, "%d %d %lld %lld\n", k , res, lft, rgh);
        ss[res].push_back({lft, rgh});
    }
    ll ans = 0;
    for(auto &it : ss){
        auto a = it.second;
        sort(a.begin(), a.end());
        ll cL = a[0].l, cR = a[0].r;
        for(int i = 1 ;i < (int)a.size() ; i ++){
            if(a[i].l > cR){
                ans += (cR - cL + 1);
                cL = a[i].l;
                cR = a[i].r;
                continue;
            }
            cR = max(cR, a[i].r);
        }
        ans += cR - cL + 1;
    }
    printf("%lld\n", ans);
}


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

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    int K, S;
    int X, Y, Z;

    cin >> K >> S;

    int ans = 0;

    for(int i = 0; i <= min(K, S); i++) {
        for(int j = 0; j <= min(K, S); j++) {
            if(S - i - j >= 0 && S - i - j <= K) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def calculate(n):
    if n % 2 == 1:
        return 0
    s1 = n // 10
    index = 1
    s2 = 0
    while (5 ** index) <= s1:
        s2 += (s1 // (5 ** index))
        index += 1
    return s1 + s2
print(calculate(int(input())))

Measured memory_bytes: 9044
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            char[] s = IChars();

            long[] lens = new long[n];
            long ans = 0;

            for(int haba=1;haba<n;haba++){
                for(int i=0;i<n-haba;i++){
                    if(s[i]==s[i+haba]){
                        if(i<i+haba-lens[haba]){
                            lens[haba] ++;
                            if(lens[haba]>ans)ans=lens[haba];
                        }else{
                            break;
                        }
                    }else{
                        lens[haba] = 0;
                    }
                }
            }
            WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13228
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_N = 2000;

int N, Z, W;
int a[MAX_N];

int main()
{
  scanf( "%d%d%d", &N, &Z, &W );
  rep( i, N )
    scanf( "%d", a+i );

  printf( "%d\n", N==1?abs(a[N-1]-W):std::max( abs(a[N-1]-W), abs(a[N-2]-a[N-1]) ) );

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    
    int p = 0;
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        p += i;
        ans.push_back(i);
        if (n <= p) break;
    }
    
    int d = p - n;
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] != d) cout << ans[i] << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 384
f=lambda s,h,w,a,q:s[h+1][w]+s[h][w+1]-s[h][w]+a[h][w]*q
g=lambda s,y1,x1,y2,x2:s[y2][x2]-s[y2][x1-1]-s[y1-1][x2]+s[y1-1][x1-1]
H,W,N=map(int,raw_input().split())
a=[map(int,raw_input()) for _ in [0]*H]
s,s1,s2=[ [[0]*(W+1) for _ in [0]*-~H] for _ in [0]*3 ]
for h in range(H):
	for w in range(W):
		s[h+1][w+1]=f(s,h,w,a,1)
		s1[h+1][w+1]=f(s1,h,w,a,w+1<W and a[h][w+1])
		s2[h+1][w+1]=f(s2,h,w,a,h+1<H and a[h+1][w])
for _ in [0]*N:
	y1,x1,y2,x2=map(int,raw_input().split())
	print g(s,y1,x1,y2,x2)-g(s1,y1,x1,y2,x2-1)-g(s2,y1,x1,y2-1,x2)

Measured memory_bytes: 165156
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) 
{
    if (b < a) { //! make sure a <= b
        T tmp = b;
        b = a;
        a = tmp;
    }

    T r = b % a;
    while (r) {
        b = a;
        a = r;
        r = b % a;
    }

    return a;
}

//! return lcm of a and b
template<typename T>
T lcm(T a, T b) 
{
    return a * b / gcd<T>(a, b);
}

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

    LL A, B;
    cin >> A >> B;

    LL ans = lcm(A, B);



    cout << ans << endl;

    return 0;
}


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

int main() {

    int n, a;
    scanf("%d%d", &n, &a);

    if (n % 500 == 0) {
        printf("Yes");
    } else {
        int num=n/500;
        n-=num*500;
        if(n<=a){
            printf("Yes");
        }else{
            printf("No");
        }
    }


    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#include<vector>
using namespace std;
int a[1000000];
int b[1000000];
int main() {
	int N;
	cin >> N;
	long long int sum = 0;
	for (int i = 0; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		if(b[i] <= a[i]) {
			sum = sum + b[i];
			b[i] = 0;
		}else{
			sum = sum + a[i];
			b[i] = b[i] - a[i];
		}
		if (b[i] >= a[i + 1]) {
			sum = sum +a[i+1];
			a[i + 1] = 0;
		}
		else {
			sum = sum + b[i];
			a[i + 1] = a[i + 1] - b[i];
		}
	}
	cout << sum;
}


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

int n;
int v[5010];
map<int, int> mp;
int dp[5010][5010];
int dfs(int i, int j) {
	if(dp[i][j]) return dp[i][j];
	if(mp.count(v[i] - (v[j] - v[i]))) {
		int k = mp[v[i] - (v[j] - v[i])];
		int ret = dfs(k, i);
		return (dp[i][j] = max(dp[i][j], ret + 1));
	} else {
		return (dp[i][j] = 2);
	}
}

int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> v[i];
	sort(v, v + n);
	for(int i = 0; i < n; ++i) {
		mp[v[i]] = i;
	}
	int ans = 2;
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			ans = max(ans, dfs(i, j));
		}	
	}
	cout << ans << '\n';
	return 0;
}



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

const int maxn=1e5+7;

char s[maxn];

int main()
{
	int i,j;
	scanf("%s",s);
	int n=strlen(s);
	if(n%2==0)
	{
		if(s[0]==s[n-1])
		  printf("First");
		else printf("Second");
	}
	else
	{
		if(s[0]==s[n-1])
		  printf("Second");
		else printf("First");
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> a(100009,0);
    rep(i,n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    
    int ans = 0;
    rep(i,100001) {
        ans = max(ans, a[i] + a[i+2] + a[i+1]);
    }

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


Measured memory_bytes: 640