akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 1; ll z = 0, o = 1;
vl flag, color, D; vector<vpll> path;
map<ll, ll> primeFactorize(ll n, map<ll, ll>& PF) {
	while (n % 2 == 0) {
		PF[2]++;
		n /= 2;
	}
	for (ll p = 3; p * p <= n; p += 2) {
		while (n % p == 0) {
			PF[p]++;
			n /= p;
		}
	}
	if (n != 1) {
		PF[n]++;
	}
	return PF;
}
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin >> N >> M;
	map<ll, ll> PF;
	COMinit(N + 10000);
	primeFactorize(M, PF);
	for (auto x : PF) {
		ll P = x.second;
		//debug(ans);
		(ans *= COM(P + N - 1, N - 1)) %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 2944
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353

def main():
    N = int(input())
    D = [int(c) for c in input().split()]

    if D[0] != 0:
        print(0)
        sys.exit()

    for i in range(1, N):
        if D[i] >= N or D[i] == 0:
            print(0)
            sys.exit()

    dist_nums = {}
    for i in range(N):
        if dist_nums.get(D[i]) is None:
            dist_nums[D[i]] = 1
        else:
            dist_nums[D[i]] += 1

    ans = 1
    num = 1
    dist_nums = sorted(dist_nums.items(), key=lambda x: x[0]) # [(0, 1), (1, 2), (2, 1)]
    for i in range(1, len(dist_nums)):
        if dist_nums[i][0] == i:
            ans *= dist_nums[i - 1][1] ** dist_nums[i][1]
            num += dist_nums[i][1]
        else:
            break

    if num != N:
        print(0)
    else:
        print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 66092
function Main(N) {
  var M = 0;
for(var i = 1;i<10;i++){
  if(Number.isInteger(N / i)){
    if((N/i)< 10){
      M = 1;

    }

  }
}
if(M == 1 && N<=81){
  console.log("Yes");
}else{
  console.log("No");
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int n,a[200010],c[200010];
struct tree
{
	int Min0,Min1,pos0,pos1,l,r,tag;
}t[800010];
int Get(int x) {int an=0;for (;x;x-=x&(-x)) an+=c[x];return an;}
void Add(int x) {for (;x<=n;x+=x&(-x)) c[x]++;}
void Updata(int p)
{
	if (t[p*2].Min0<t[p*2+1].Min0) t[p].pos0=t[p*2].pos0,t[p].Min0=t[p*2].Min0;
	  else t[p].pos0=t[p*2+1].pos0,t[p].Min0=t[p*2+1].Min0;
	if (t[p*2].Min1<t[p*2+1].Min1) t[p].pos1=t[p*2].pos1,t[p].Min1=t[p*2].Min1;
	  else t[p].pos1=t[p*2+1].pos1,t[p].Min1=t[p*2+1].Min1;
}
void Build(int p,int l,int r)
{
	t[p].l=l;t[p].r=r;t[p].Min0=t[p].Min1=1e9;t[p].tag=0;
	if (l==r) {
		if (l&1) t[p].Min1=a[l],t[p].pos1=l;
		  else t[p].Min0=a[l],t[p].pos0=l;
		return;
	}
	int mid=(l+r)>>1;
	Build(p*2,l,mid);
	Build(p*2+1,mid+1,r);
	Updata(p);
}
void Pass(int p)
{
	if (t[p].tag==0) return;
	swap(t[p*2].Min0,t[p*2].Min1);swap(t[p*2].pos0,t[p*2].pos1);
	swap(t[p*2+1].Min0,t[p*2+1].Min1);swap(t[p*2+1].pos0,t[p*2+1].pos1);
	t[p*2].tag^=1;t[p*2+1].tag^=1;
	t[p].tag=0;
}
int Query(int p,int l,int r)
{
	if (t[p].l==l&&t[p].r==r) return t[p].pos0;
	Pass(p);
	int mid=(t[p].l+t[p].r)>>1;
	if (r<=mid) return Query(p*2,l,r);
	  else if (l>mid) return Query(p*2+1,l,r);
	int p1=Query(p*2,l,mid),p2=Query(p*2+1,mid+1,r);
	if (a[p1]<a[p2]) return p1;
	else return p2;
}
void Modify(int p,int l,int r)
{
	if (t[p].l==l&&t[p].r==r) {
		swap(t[p].Min0,t[p].Min1);
		swap(t[p].pos0,t[p].pos1);
		t[p].tag^=1;
		return;
	}
	Pass(p);
	int mid=(t[p].l+t[p].r)>>1;
	if (r<=mid) Modify(p*2,l,r);
	  else if (l>mid) Modify(p*2+1,l,r);
	    else Modify(p*2,l,mid),Modify(p*2+1,mid+1,r);
	Updata(p);
}
void Change(int p,int x)
{
	if (t[p].l==x&&t[p].r==x) {
		t[p].Min0=t[p].Min1=1e9;
		t[p].pos0=t[p].pos1=0;
		return ;
	}
	Pass(p);
	int mid=(t[p].l+t[p].r)>>1;
	if (x<=mid) Change(p*2,x);
	else Change(p*2+1,x);
	Updata(p);
}
int main()
{
	scanf("%d",&n);
	a[0]=1e9;
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	Build(1,1,n);
	for (int i=1;i<=n/2;i++) {
		int x=t[1].pos1;
		int l=x+1,r=n;
		int s=Get(x);
		while (l+1<r) {
			int mid=(l+r)>>1;
			if (Get(mid)-s) r=mid;
			else l=mid;
		}
		int y;
		if (Get(l)-s) y=Query(1,x+1,l-1);else if (Get(r)-s) y=Query(1,x+1,r-1);
		else y=Query(1,x+1,r);
		printf("%d %d ",a[x],a[y]);
		if (x<y-1) Modify(1,x+1,y-1);
		Change(1,x);
		Change(1,y);
		Add(x);Add(y);
	}
}

Measured memory_bytes: 20864
n,x,y = list(map(int, input().split()))

ans = [0]*(n)
for i in range(n-1):
    for j in range(i+1, n):
        #r1 = min(j-i, (abs(x-i-1) + 1 +  abs(y-j-1) ), (abs(y-i-1) + 1 +  abs(x-j-1) ) )
        r1 = min(j - i, (abs(x - i - 1) + 1 + abs(y - j - 1)))
        ans[r1] += 1

for i in ans[1:]:
    print(i)

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

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

typedef pair<int,int> intpair;

int main(){
	
	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,k,q;
    cin>>n>>k>>q;

    vector<intpair> myVec;

    ll x;
    for(int i=0;i<n;i++){
    	cin>>x;
    	myVec.push_back({x,i});
    }

    sort(myVec.begin(), myVec.end());

    int ans=INT_MAX;
    for(int i=0;i<n;i++){
    	set<ll> indexesToAvoid;
    	ordered_set taken;

    	for(int j=0;j<i;j++){
    		indexesToAvoid.insert(myVec[j].second);
    	}
    	// cerr<<i<<" "<<indexesToAvoid.size()<<endl;

    	int currPointer=i;
    	int mymax=myVec[currPointer].first;
    	int mymin=INT_MAX;

    	int takenCount=0;
    	while(currPointer<n && takenCount<q){
    		int currIndex = myVec[currPointer].second;
    		auto nextOne = indexesToAvoid.upper_bound(currIndex);

    		auto prevOne = nextOne;
    		if(indexesToAvoid.size()>0){
    			prevOne=prev(prevOne);
    		}

    		int nextInd,prevInd;
    		if(nextOne == indexesToAvoid.end()){
    			nextInd = n;
    		}
    		else{
    			nextInd = *nextOne;
    		}

    		if(nextOne == indexesToAvoid.begin() || indexesToAvoid.size()==0){
    			prevInd=-1;
    		}
    		else{
    			prevInd = *prevOne;
    		}

    		// currIndex-=taken.order_of_key(currIndex);
    		nextInd-=taken.order_of_key(nextInd);
    		prevInd-=taken.order_of_key(prevInd);

    		// cerr<<nextInd<<" "<<prevInd<<endl;
    		// if(i==5){
    		// 	cerr<<nextInd<<" "<<prevInd<<" "<<indexesToAvoid.size()<<endl;
    		// }
    		if(nextInd-prevInd-1 >= k){
    			takenCount++;
    			taken.insert(currIndex);
    			mymax=myVec[currPointer].first;
    			mymin=min(mymin,myVec[currPointer].first);
    		}
    		currPointer++;
    	}


    	if(takenCount==q){
    		// cerr<<i<<" "<<mymax<<" "<<mymin<<" "<<mymax-mymin<<" "<<endl;
    		ans=min(ans,mymax-mymin);
    	}
    	else{
    		break;
    	}
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define SZ(x) x.size()
#define pii pair<int,int>
#define ll long long
using namespace std;
int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int ans = 0;
    while(n > 0) {
        n /= k;
        ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 256
#include<cstdio>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;

const int N = 5e5 + 5;

int T,n,m,x,y;
int fi[N],to[N * 2],nt[N * 2],tot,bz[N];
int fa[N],ans[N],siz[N];

void link(int x,int y){
	nt[++tot] = fi[x],to[tot] = y,fi[x] = tot;
}

void cl(){
	fo(i,1,n)	bz[i] = fi[i] = ans[i] = siz[i] = 0;
	tot = 1;
}

void dg(int x,int la){
	bz[x] = 1;
	for(int i = fi[x]; i; i = nt[i]) if(!bz[to[i]]){
		ans[i / 2] = (i & 1);
		siz[to[i]] ^= 1;
		dg(to[i],i);
		siz[x] ^= siz[to[i]];
	} else if(i != (la ^ 1)){
		ans[i / 2] = !(i & 1);
		siz[to[i]] ^= 1;
	}
	if(siz[x]) ans[la / 2] ^= 1;
}

#include "vector";
using namespace std;

int main(){
	//for(scanf("%d",&T); T; T--){
		cl();
		scanf("%d %d",&n,&m);
		vector<pair<int,int>>ed;
		fo(i,1,m){
			scanf("%d %d",&x,&y);
			ed.push_back({x,y});
			link(x,y); link(y,x);
		}
		if(m & 1){
			printf("-1\n"); return 0;
		}
		dg(1,0);
		fo(i,1,m){
			printf("%d %d\n",(ans[i]?ed[i-1].first:ed[i-1].second)
				   ,(ans[i]?ed[i-1].second:ed[i-1].first));
		}
	//}
}

//sub-EOF


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


using namespace std;



int main(void) {

	int a, b, c, d;

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	a = a - c;
	b = b - d;

	a = a*b;

	if (a >= 0) {
		cout << a;
	}

	return 0;

}

Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-2):
  if l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]:
    print('Yes')
    exit()
print('No')
               

Measured memory_bytes: 9216
#include <iostream>

long long x;

using namespace std;
long long n, m, g[500000];

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		g[i] = 1;
	}
	for (int i = 0; i < m; i++)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int x;
			cin >> x;
			x--;
			g[x] = 0;
		}
	}
	int s = 0;
	for (int i = 0; i < n; i++) s += g[i];
	cout << s;
}

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

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

    if(k==1)
        return cout<<0, 0;
    //n-balls
    //k-balls

    n-=k;

    int e = 1;
    e+=n;
    //n--;

    cout<<e-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x, k, d;
    cin >> x >> k >> d;
    // lli y = x + k * d;
    lli f1 = x / d;
    lli f2 = f1 - 1;
    lli f3 = f1 + 1;
    // cout << f1 << endl;
    lli k1 = (k - f1) / 2;
    lli k2 = (k - f2) / 2;
    lli k3 = (k - f3) / 2;

    lli ans = 1e18;
    k1 = min(k1, k);
    lli ff = 0;
    k1 = max(k1, ff);
    k2 = max(k2, ff);
    k3 = max(k3, ff);
    k2 = min(k2, k);
    k3 = min(k3, k);

    f1 = abs(x + (k - 2 * k1) * d);
    ans = min(f1, ans);
    f1 = abs(x - (k - 2 * k1) * d);
    ans = min(f1, ans);
    f2 = abs(x + (k - 2 * k2) * d);
    ans = min(f2, ans);
    f2 = abs(x - (k - 2 * k2) * d);
    ans = min(f2, ans);
    f3 = abs(x + (k - 2 * k3) * d);
    // cout << f3 << endl;
    ans = min(f3, ans);
    f3 = abs(x - (k - 2 * k3) * d);
    // cout << f3 << endl;
    ans = min(f3, ans);
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vector<int> a(n);
		int ans=0;

		for(int i=0;i<n;i++)
		{
			scanf("%d", &a[i]);
		}
		sort(a.begin(), a.end());
		int a_min=a[0];
		int a_max=a.back();

		if(a_max==a_min)
		{
			// real=a[0]   real=a[0]+1
			if(a_min*2<=n || a_min==n-1) ans=1;
		}
		if(a_max==a_min+1)
		{
			int single=0;
			for(int i=0;a[i]==a_min;i++)
				single++;
			if(a_max>single && single+2*(a_max-single)<=n) ans=1;
		}

		printf("%s\n", ans?"Yes":"No");
	}

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){
    int N, W; cin >> N >> W;
    vector<Int> v(110), w(110);
    rep1(i, N) cin >> w[i] >> v[i];

    // dp[i][j]: 品物iまで，重さjまででの最大価値
    vector<vector<Int>> dp(110, vector<Int>(100010, 0));

    rep1(i, N){
        rep1(j, W){
            if(j < w[i]){
                dp[i][j] = dp[i-1][j];
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;




    
}

Measured memory_bytes: 87296
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORX(i, a, b, x) for (int i = (a); i <= (b); i+=x)
#define debug(x) cerr << #x << " is= " << x << endl; //use for debugging
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 5] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
 
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vov        vector<vector<int>> 
#define pr         pair<ll,ll>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).size())
#define cut(x) {cout<<x<<"\n"; return;}
#define setprec(x) cout << fixed << showpoint << setprecision(8)<<x<<endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl "\n"
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//*s.find_by_order() ->returns an iterator to the k-th largest element (counting from zero);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
//sort(a+1,a+n+1,[](ll x,ll y){return abs(x)>abs(y);});
//sort(v.begin(), v.end(), greater<int>()); 
const int N=2e5+5;
string s[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};
string s1;
void solve()
{
 FOR(i,0,6)
 if(s[i]==s1) cut(7-i);
}
int main()
{
  fast_io;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  cin>>s1;
  solve();
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,S;
    cin >> N >> S;
    vec<int> A(N);
    for(auto& x:A) cin >> x;
    vec<mint> dp(S+1);
    dp[0] = 1;
    for(int i=0;i<N;i++){
        vec<mint> ndp(S+1);
        for(int j=0;j<=S;j++){
            ndp[j] += dp[j]*2;
            if(j+A[i]<=S) ndp[j+A[i]] += dp[j];
        }
        dp.swap(ndp);
    }
    cout << dp[S] << "\n";
}

Measured memory_bytes: 3668
(defun solve (N arr)
  (let (tmp)
       (loop for i from (1- N) downto 0
             with sum = 0
             do (push sum tmp)
             if (eq (aref arr i) #\E) do (incf sum))
       (loop for x across arr with sum = 0
             for y in tmp
             minimize (+ y sum)
             if (eq x #\W) do (incf sum))))

(princ (solve (read) (concatenate 'vector (read-line))))

Measured memory_bytes: 14696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
struct Edge{
	int to,next;
}e[MAXN];
int head[MAXN],n,cnt,rk[MAXN];
inline void insert(int u,int v)
{
	e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
}
void dfs(int x)
{
	vector<int>t;
	for(int i=head[x];i;i=e[i].next){
		int v=e[i].to;
		dfs(v);
		t.push_back(rk[v]);
	}
	sort(t.begin(),t.end(),greater<int>());
	for(int i=0;i<t.size();++i)
		rk[x]=max(rk[x],i+1+t[i]);
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i){
		int fa;
		scanf("%d",&fa);
		insert(fa,i);
	}
	dfs(1);
	cout<<rk[1]<<endl;
	return 0;
}


Measured memory_bytes: 9600
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
#include <deque>
#include <queue>
#include <tuple>
using namespace std;

#define prec(i) cout << fixed << setprecision(i)

void output_yn(bool isYes) {
	if (isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

long long _lcm(long long a, long long b)
{
	return (((a * b) % MOD) * modinv(_gcd(a, b))) % MOD;
}

long long ncr(long long n, long long r) {
	long long sum = 1;
	for (long long i = r + 1; i <= n; i++)
		sum *= i;

	return sum;
}




int main()
{
	int d, t, s;
	cin >> d >> t >> s;

	output_yn(d <= t* s);

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;
using namespace std;

ll dp[100000][13] = {};
int main()
{
  ll amari[6] = {1, 10, 9, 12, 3, 4};
  string s;
  cin >> s;

  if (s[s.length() - 1] == '?')
  {
    REP(j, 10)
    {
      dp[0][j] = 1;
    }
  }
  else
  {
    int now = atoi(s.substr(s.length() - 1, 1).c_str());
    dp[0][now] = 1;
  }

  FOR(i, 1, s.length())
  {
    if (s[s.length() - 1 - i] == '?')
    {
      REP(j, 10)
      {
        ll res = (j * amari[i % 6]) % 13;
        REP(k, 13)
        {
          dp[i][(k + res) % 13] = (dp[i][(k + res) % 13] + dp[i - 1][k]) % MOD;
        }
      }
    }
    else
    {
      int now = (atoi(s.substr(s.length() - 1 - i, 1).c_str()) * amari[i % 6]) % 13;
      REP(k, 13)
      {
        dp[i][(k + now) % 13] = (dp[i][(k + now) % 13] + dp[i - 1][k]) % MOD;
      }
    }
  }
  cout << dp[s.length() - 1][5] << endl;
}


Measured memory_bytes: 10624
#include <iostream>
using namespace std;
int main(){  
	int n,i,j;
	cin >> n;
	int c[n],s[n],f[n];
	for(i=0;i<n-1;i++)
		cin >> c[i] >> s[i] >> f[i];
	for(i=0;i<n-1;i++){
		int t=s[i];
		for(j=i;j<n-1;j++){
			if(t<s[j]) t=s[j];
			if(t%f[j]!=0) t+=f[j]-t%f[j];
			t+=c[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
S = str(input())
l = []
l2 = []
l3 = []
N = len(S)
A = N - 1
B = N + 2
l_rev = []
l2_rev = []
l3_rev = []
for i in range(N):
    l.append(S[i])

for i in range(A // 2):
    l2.append(S[i])

for i in range((B // 2) , N):
    l3.append(S[i])
l_rev = l[::-1]
l2_rev = l2[::-1]
l3_rev = l3[::-1]
"""
print(l2)
print(l3)
"""
if l == l_rev and l2 == l2_rev and l3 == l3_rev:
    print("Yes")
else:
    print("No") 

Measured memory_bytes: 3064
antennas = 5.times.map{gets.chomp.to_i}
k = gets.chomp.to_i

(0..3).each do |i|
  (i+1..4).each do |j|
    if antennas[j] - antennas[i] > k
      puts ':('
      exit
    end
  end
end
puts 'Yay!'


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#define RT(x) rt[x],1,n
#define lson ls[u],l,md
#define rson rs[u],md+1,r
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(u) for(int i=hd[u],v;v=e[i].v,i;i=e[i].n)
using namespace std;
const int N=200200,TO=N*40;
int n,m,fl,u,v,cnt;
int hd[N],fa[N],mx[N],se[N],fd[N],rt[N],ans[N],f[N],g[N];
int ls[TO],rs[TO],s[2][TO];
struct edge{int n,v;}e[N<<1];
void add(int u,int v){e[++fl]=(edge){hd[u],v};hd[u]=fl;}
void dfs1(int u,int w){
	if(mx[u]==fa[u]) w=u;fd[u]=w;
	REP(u)if(v!=fa[u]){
		fa[v]=u;mx[v]=mx[u],se[v]=se[u];
		if(v>mx[u]) mx[v]=v,se[v]=mx[u];
		else if(v>se[u]) se[v]=v;
		dfs1(v,v==mx[v]?v:w);
	}
}
void ins(int&u,int l,int r,int x,int k){
	if(!u) u=++cnt;s[k][u]++;
	if(l==r) return;
	int md=(l+r)>>1;
	x<=md?ins(lson,x,k):ins(rson,x,k);
}
int  ask(int&u,int l,int r,int x,int k){
	if(l==r) return s[k][u];
	int md=(l+r)>>1;
	return x<=md?ask(lson,x,k):ask(rson,x,k);
}
int mrg(int u,int l,int r,int v){
	if(!u||!v) return u|v;
	s[0][u]+=s[0][v];
	s[1][u]+=s[1][v];
	if(l==r) return u;
	int md=(l+r)>>1;
	ls[u]=mrg(lson,ls[v]);
	rs[u]=mrg(rson,rs[v]);
	return u;
}
void dfs2(int u){
	ins(RT(u),mx[u],0);ins(RT(u),se[u],1);
	REP(u)if(v!=fa[u]) dfs2(v),rt[u]=mrg(RT(u),rt[v]);
	if(mx[u]==fa[u]) f[u]=ask(RT(u),mx[u],0),g[u]=ask(RT(u),se[fa[u]],1);
	if(mx[u]==u) g[u]=ask(RT(u),se[u],1);
}
void dfs3(int u){
	if(u==mx[u]) ans[u]=g[u]+ans[fa[u]];
	else if(u>1) ans[u]=g[mx[u]]-g[fd[u]]+f[fd[u]]+ans[fa[mx[u]]];
	REP(u)if(v!=fa[u]) dfs3(v);
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs1(1,0);dfs2(1);dfs3(1);
	//FOR(i,1,n) cout<<f[i]<<' '<<g[i]<<' '<<mx[i]<<'\n';
	FOR(i,2,n) cout<<ans[i]<<' ';cout<<'\n';
}

Measured memory_bytes: 129792
#include<iostream>
using namespace std;
long long k,a,b;
int main(){
	cin>>k>>a>>b;
	if(b>=a/k*k+k||a==a/k*k||b==a/k*k+k) cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
	return 0;
} 

Measured memory_bytes: 3592
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
char s[555555];
int main()
{
	scanf("%s",s);
	ll tmp=0,sm=0;
	int n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]=='W')
			++tmp,sm+=(ll)i+1LL;
	printf("%lld\n",(ll)sm-tmp*(tmp+1LL)/2LL);
	return 0;
}

Measured memory_bytes: 384
/*
	Auther:_Destiny
	time:2020.5.17
*/

#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;


int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

int n;

signed main() {
    n = read();
    n = n % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) puts("hon");
    if (n == 0 || n == 1 || n == 6 || n == 8) puts("pon");
    if (n == 3) puts("bon");
}   

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

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var H = int.Parse(inputs[0]);
        var W = int.Parse(inputs[1]);

        inputs = Console.ReadLine().Split(' ');
        var h = int.Parse(inputs[0]);
        var w = int.Parse(inputs[1]);

        var mat = new int[H, W];
        for(int row = 0; row < h; row++)
        {
            for(int col = 0; col < W; col++)
            {
                mat[row, col] = 1;
            }
        }

        for(int col = 0; col < w; col++)
        {
            for(int row = 0; row < H; row++)
            {
                mat[row, col] = 1;
            }
        }

        int count = 0;
        for(int row = 0; row < H; row++)
        {
            for(int col = 0; col < W; col++)
            {
                if (mat[row, col] == 0) count++;
            }
        }

        Console.WriteLine(count);
    }

}



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

int main() {
  
  int count = 0;
  
  for (int i = 0; i < 4; i++) {
    char e;
    cin >> e;
    
    if (e == '+') {
      count++;
    } else {
      count--;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(a)]
for i in range(a):
    A[i].append(sum(A[i]))
bottom = [0]*(b+1)
for j in range(b+1):
    for i in range(a):
        bottom[j] += A[i][j]
for i in range(a):
    print(*A[i])
print(*bottom)


Measured memory_bytes: 6228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
 
int main()
{
 
  ll n, k;
  cin >> n >> k;
 
  ll total = 0;
  for (ll i = k; i < n + 1; i++)
  {
    ll max = (n + n - i + 1) * i / 2;
    ll min = (i - 1) * i / 2;
    ll val = max - min + 1;
 
    total += val;
    //total %= MOD;
  }
 
  if (total < 0)
    total += MOD;
 
  total += 1;
  total %= MOD;
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
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;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,X,T; cin >> N >> X >> T;
    cout << (N+X-1)/X*T << endl;
    return 0;
}


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

int main(void){
    list<int> l;
    list<int>::iterator it = l.end();

    int q;
    cin >> q;

    for(int i=0; i<q; i++){
        int query_num;
        cin >> query_num;
        if(query_num == 0){
            int x;
            cin >> x;
            it = l.insert(it,x);
        }
        else if(query_num == 1){
            int d;
            cin >> d;
            advance(it,d);
        }
        else if(query_num == 2){
            it = l.erase(it);
        }
    }

    for(it=l.begin(); it!=l.end(); it++){
        cout << *it << "\n";
    }
    return 0;
}


Measured memory_bytes: 18536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>h(N+2);
  for(int i=1;i<=N;i++)
    cin>>h.at(i);
  h.at(0)=0;
  h.at(N+1)=0;
  int Max=0;
  for(int i=1;i<=N;i++)
    if(Max<=h.at(i))
      Max=h.at(i);
  int ans=0;
  for(int i=0;i<Max;i++){
  int sum=0;
    for(int j=0;j<=N;j++){
    if((h.at(j)<=0 && 0<h.at(j+1)) || (0<h.at(j) && h.at(j+1)<=0))
      sum++;
    }ans+=sum/2;
    for(int k=0;k<=N+1;k++)
      h.at(k)--;
  
  }cout<<ans<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
def solve(string):
    n, k, *x = map(int, string.split())
    x = sorted(x)
    diff = [
        _x1 - _x0 + min(abs(_x0), abs(_x1)) if _x0 <= 0 <= _x1 else max(abs(_x0), abs(_x1))
        for _x0, _x1 in zip(x, x[k - 1:])
    ]
    return str(min(diff))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 67352
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>



int main() {
	int n; std::cin >> n;
	std::vector<std::vector<int>> tree(n);
	for (auto i = 1; i < n; ++i) {
		int a, b; std::cin >> a >> b; --a; --b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	std::vector<int> prev(n, -1); prev[0] = 0;
	std::vector<int> parity(n, -1); parity[0] = 1;
	std::stack<int> stack; stack.push(0);
	while (!stack.empty()) {
		const auto top = stack.top(); stack.pop();
		for (const auto next : tree[top]) if (parity[next] == -1) {
			prev[next] = top;
			parity[next] = 3 - parity[top];
			stack.push(next);
		}
	}
	const int one_count = std::count(parity.begin(), parity.end(), 1);
	const int two_count = n - one_count;
	std::vector<int> result;
	int one_rest = (n + 2) / 3;
	int two_rest = (n + 1) / 3;
	int zero_rest = n / 3;
	if (one_count > n / 3 && two_count > n / 3) {
		if (one_count < two_count) {
			for (auto& p : parity) p = 3 - p;
		}
		for (auto i = 0; i < n; ++i) {
			if (parity[i] == 1) {
				if (one_rest > 0) {
					result.push_back(one_rest * 3 - 2);
					--one_rest;
				}
				else {
					result.push_back(zero_rest * 3);
					--zero_rest;
				}
			}
			else {
				if (two_rest > 0) {
					result.push_back(two_rest * 3 - 1);
					--two_rest;
				}
				else  {
					result.push_back(zero_rest * 3);
					--zero_rest;
				}
			}
		}
	}
	else if (one_count < two_count) {
		for (const auto p : parity) {
			if (p == 1) {
				result.push_back(zero_rest * 3);
				--zero_rest;
			}
			else {
				if (one_rest > 0) {
					result.push_back(one_rest * 3 - 2);
					--one_rest;
				}
				else if (two_rest > 0) {
					result.push_back(two_rest * 3 - 1);
					--two_rest;
				}
				else {
					result.push_back(zero_rest * 3);
					--zero_rest;
				}
			}
		}
	}
	else {
		for (const auto p : parity) {
			if (p == 2) {
				result.push_back(zero_rest * 3);
				--zero_rest;
			}
			else {
				if (one_rest > 0) {
					result.push_back(one_rest * 3 - 2);
					--one_rest;
				}
				else if (two_rest > 0) {
					result.push_back(two_rest * 3 - 1);
					--two_rest;
				}
				else {
					result.push_back(zero_rest * 3);
					--zero_rest;
				}
			}
		}
	}
	for (auto i = 0; i < n; ++i) {
		if (i != 0) std::cout << ' ';
		std::cout << result[i];
	}
	std::cout << '\n';
}

Measured memory_bytes: 16752
/************************************************************
	> File Name: a.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Wed 18 Dec 2019 02:07:04 PM CST
************************************************************/

#pragma GCC optimize(2)
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
//#include <unordered_map>
#define lowbit(x) (x&-x)
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXM = 2e5+5;
const int MOD = 1e9+7;
const int dir[4][2] = {1,0,-1,0,0,1,0,-1};
const double PI = acos(-1.0);
const double EXP = 1e-8;
int main(void){
	int a, b, c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+c>=22)
		printf("bust\n");
	else
		printf("win\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    long a;
    long b;
    long c;
    long k;
    long ans;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        a = sc.nextLong();
        b = sc.nextLong();
        c = sc.nextLong();
        k = sc.nextLong();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        if (a < k) {
            ans = a;
            k -= a;                
        } else {
            ans = k;
            k = 0;
        }
        if (b < k && k > 0) {
            k -= b;
        } else {
            k = 0;
        }
        if (k > 0) {
            ans -= k;
        }
        System.out.println(ans);
    }
}

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

int find_par(vector<int> &par, int ver){
    if(par[ver] == ver)return ver;
    return par[ver] = find_par(par,par[ver]);
}
void make(vector<int> &par,int x,int y){
    int px = find_par(par, x);
    int py = find_par(par, y);
    par[px] = py;
}
int main(){

    int n,m;
    cin>>n>>m;
    vector<int> par(n+1);
    for(int i=0; i <= n;i++)par[i] = i;
    while(m--){
        int x,y;
        cin>>x>>y;
        make(par, x, y);
    }
    map<int, int> mp;
    for(int i=1;i<=n;i++){
        mp[find_par(par, i)]++;
    }
    int ans = -1;
    for(auto it:mp){
        ans = max(ans, it.second);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13512
x, n = map(int, input().split())
p = [int(x) for x in input().split()]
seen = set(p)
offset = 0
while True:
    val1, val2 = x + offset, x - offset
    if val2 not in seen:
        print(val2)
        break
    if val1 not in seen:
        print(val1)
        break
    offset += 1

Measured memory_bytes: 61892
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int d[N];
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d, d + N);
  int mid = N / 2;
  cout << d[mid] - d[mid - 1] << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define debug(x) cout << " > " << #x << ':' << x << endl;
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 500010

void solve(){
    ll n, m;
    
    cin >> n >> m;
    vec<int> v(n);
    for(auto &i:v) cin >> i;
    
    int top = 1e9+1;
    int bot = 0;
    
    while(top - bot > 1){
        int mid = (top + bot) / 2;
        ll cnt = 0;
        
        for(auto i:v)
            cnt += (i-1) / mid;
        
        if(cnt <= m) top = mid;
        else         bot = mid;
    }
    
    cout << top << endl;
}

int main(){
//    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}



Measured memory_bytes: 3976
# 最大公約数：ユークリッドの互除法
import sys

def gcd(x, y):
    return y if not x%y else gcd(y, x%y)

def get_input():
    data = []
    for line in sys.stdin:
        a, b = [int(i) for i in line.split()]
        data.append((a,b))
    return data


data = get_input()

for x,y in data:
    GCD = gcd(x,y)
    LCM = x*y // GCD
    print(GCD, LCM)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const int INF = 1000000000;

int main() {
    int h, w;
    cin >> h >> w;
    queue<P> que;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if (c == '#') {
                que.push(P(i, j));
                dist.at(i).at(j) = 0;
            }
        }
    }

    int maximum = 0;
    const int dx[] = {1, 0, -1, 0};
    const int dy[] = {0, 1, 0,  -1};
    while (!que.empty()) {
        P p = que.front(); que.pop();
        for (int i = 0; i < 4; i++) {
            int nx = p.second + dx[i], ny = p.first + dy[i];
            if (0 <= nx && nx < w && 0 <= ny && ny < h && dist.at(ny).at(nx) == INF) {
                que.push(P(ny, nx));
                dist.at(ny).at(nx) = dist.at(p.first).at(p.second) + 1;
                maximum = max(maximum, dist.at(ny).at(nx));
            }
        }
    }
    
    cout << maximum << endl;
}   

Measured memory_bytes: 12432
// at_dp_a.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<algorithm>
#define FOR(i,a) for(int i=0;i<a;i++)
#define INF 0x3f3f3f3f
using namespace std;

int main()
{
	//dp[a] represents minimum to get to a
	int dp[100001]; int n; cin >> n;
	int value[100001];
	FOR(i, n)cin >> value[i];
	
	FOR(i, n) {
		dp[i] = INF;
		if (i == 0)dp[i] = 0;
		if (i > 0) {
			dp[i] = min(dp[i], dp[i - 1] + abs(value[i] - value[i - 1]));
		}
		if (i > 1) {
			dp[i] = min(dp[i], dp[i - 2] + abs(value[i] - value[i - 2]));
		}
	}
	cout << dp[n - 1] << "\n";
}


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

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define FR(i, l, r) for(int i = (l); i <= (r); i++)
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <pll> vll;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
template <typename T> inline void out(T x) { cout << x; }

/*********** TEMPLATE ENDS HERE *************/

stack <int> s;

main()
{
	int a;
	cin >> a;
	if(a == 0)
		return cout << 0, 0;
	while(a)
	{
		int r = a % -2;
		a /= -2;
		if(r < 0)
			r += 2, a++;
		s.push(r);
	}
	
	while(!s.empty())
		cout << s.top(), s.pop();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read(), M = read();
    int L = 1, R = N;
    for (int i = 0; i < M; i++) {
        L = max(L, (int)read());
        R = min(R, (int)read());
    }
    printf("%d\n", max(R - L + 1, 0));
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int main() {
  int r, D;
  vector<int> x(11);
  cin >> r >> D >> x[0];

  for (int i = 0; i < 10; i++) {
    x[i+1] = r * x[i] - D;
    cout << x[i+1] << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>

int main(void){
    int N, C[510] = {}, S[510] = {}, F[510] = {};
    scanf("%d", &N);
    for (int i = 1; i <= N-1; ++i)
    {
        scanf("%d %d %d", C+i, S+i, F+i);
    }
    
    for (int i = 1; i <= N; ++i)
    {
        int T = 0;
        for (int j = i; j < N; ++j)
        {
            T = (std::max(T-S[j], 0) + F[j]-1) / F[j] * F[j] + S[j] + C[j];
        }
        printf("%d\n", T);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

void solve()
{
	for(int i = 1; i < 10; ++i)
	{
		for(int j = 1; j < 10; ++j)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}

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

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

string s;
string t;

bool dfs(int k, int e, int b) {
	if (k > s.size() or !e) {
		return 1;
	}
	for (int i = (k<s.size() and e) ? s[k]-'a' : 0; i<26; i++) if (!((b>>i)&1)) {
		if (dfs(k+1, e and i == (s[k]-'a'), b|(1<<i))) {
			t.push_back((char)(i+'a'));
			return 1;
		}
	}
	return 0;
}

int main()
{
	cin >> s;

	if (!dfs(0, 1, 0)) cout << "-1";
	else {
		reverse(t.begin(), t.end());
		cout << t;
	}
}


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

int main() {
    int N; cin >> N;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        if ((i+1) % 2 == 0) continue;
        else {
            if (x % 2 != 0) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3564
INF = 10 ** 9

def dfs(a, b, c, k)
  
  if k == N
    return INF if [a, b, c].min == 0
    return (A-a).abs + (B-b).abs + (C-c).abs - 10 * 3
  end
  
  x = dfs(a+L[k], b, c, k+1) + 10
  y = dfs(a, b+L[k], c, k+1) + 10
  z = dfs(a, b, c+L[k], k+1) + 10
  w = dfs(a, b, c, k+1)
  
  [x, y, z, w].compact.min
end

N, A, B, C = gets.split.map(&:to_i)

L = Array.new(N)
N.times{ |i| L[i] = gets.to_i }

p dfs(0, 0, 0, 0)


Measured memory_bytes: 1916
n = int(input())
w = [input()  for _ in range(n)]



def solve(n,ls):
    if n == 0:
        return "Yes"
    else:
        if ls[n-1][-1] == ls[n][0]:
            return solve(n-1,ls)
        else:
            return "No"


flg = solve(n-1,w)
if flg == "No":
    pass
else:
    if not len(w) == len(list(set(w))):
        flg ="No"

print(flg)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int D, N;
    cin >> D >> N;
    if (N == 100) N++;
    int ans = pow(100,D) * N;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  char ch;

  while(1)
    {
    scanf("%c",&ch);

    if(ch=='\n')break;

    if('a'<=ch&&ch<='z'){
      ch=ch-32;
    }else if(ch>='A'&&ch<='Z'){
      ch=ch+32;
    }
    
    printf("%c",ch);
  }
puts("");
  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    string correct = "CODEFESTIVAL2016";
    int cnt = 0;
    rep(i, correct.size()) {
        if (S[i] != correct[i]) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256