akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  int n;
  
  cin>>n;
  
  if(n%2==1)
  {
    n=n+1;
  }
  n=n/2;
  
  cout<<n<<endl;

  return 0;
}

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


int main(){
    ll n;
    cin >> n;

    vector<ll> a(n+1, 0);
    vector<ll> b(n+1, 0);

    for(ll i = 1; i <= n; i++){
        cin >> a[i];
        if(i % 2 == 0){
            b[1] -= a[i];
        }else{
            b[1] += a[i];
        }
    }

    for(ll i = 2; i <= n; i++){
        b[i] = 2 * (a[i-1] - b[i-1] / 2);
    }

    for(ll i = 1; i <= n; i++){
        if(i != 1) cout << ' ';
        cout << b[i];
    }
    cout << endl;

    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  if (s.at(s.size() - 1) == 's') s += "es";
  else s += "s";
  
  cout << s << '\n';
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
vector<ll> A{1,0,-1,0};
vector<ll> B{0,1,0,-1};
vector<ll> C{-2,-1,0,1,2};
vector<ll> D{-2,-1,0,1,2};

 
int main() {
  ll H,W;
  cin>>H>>W;
  ll Ch,Cw,Dh,Dw;
  cin>>Ch>>Cw>>Dh>>Dw;
  Ch--;
  Cw--;
  Dh--;
  Dw--;
  vector<string> vec(H);
  for(ll i=0;i<H;i++) {
cin>>vec[i];
  }
  ll INF=10000007;
  vector<vector<ll>> dist(H,vector<ll>(W,INF));
  deque<pair<ll,ll>> S;
  dist[Ch][Cw]=0;
  S.push_front(make_pair(Ch,Cw));
  while(!S.empty()) {
ll nh=S.front().first;
    ll nw=S.front().second;
    S.pop_front();
    
   for(ll i=0;i<4;i++) {
ll kh=nh+A[i];
     ll kw=nw+B[i];
     if(kw<0||kw>W-1||kh<0||kh>H-1) {
continue;
     }
     if(vec[kh][kw]=='#') {
continue;
     }
     if(dist[nh][nw]>=dist[kh][kw]) {
continue;
     }
     
     dist[kh][kw]=dist[nh][nw];
     S.push_front(make_pair(kh,kw));
   }
    
    for(ll i=0;i<5;i++) {
for(ll j=0;j<5;j++) {
  
if(abs(C[i])+abs(D[j])<2) {
continue;
}
  ll kh=nh+C[i];
  ll kw=nw+D[j];
     if(kw<0||kw>W-1||kh<0||kh>H-1) {
continue;
     }
     if(vec[kh][kw]=='#') {
continue;
     }
     if(dist[kh][kw]!=INF) {
continue;
     }
  dist[kh][kw]=dist[nh][nw]+1;
  S.push_back(make_pair(kh,kw));
}
    }
  }
  
  if(dist[Dh][Dw]==INF) {
cout<<-1<<endl;
  }
  else {
cout<<dist[Dh][Dw]<<endl;
  }

}
    
    
    
     
    
  
  
  
  
  
  
  
  
  

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

struct Card{char suit; int value; };

void bubble(struct Card A[], int N){
    for (int i=0; i<N; i++){
        for (int j=N-1; j > i; j--){
            if (A[j].value < A[j-1].value) swap(A[j], A[j-1]);
        }
    }
}

void selection(struct Card A[], int N){
    for ( int i=0; i<N-1; i++){
        int minj = i;
        for (int j=i; j<N; j++){
            if (A[j].value < A[minj].value) minj = j;
        }
        swap(A[minj], A[i]);
    }
}

void print(struct Card A[], int N){
    for (int i=0; i<N; i++){
        if (i>0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}


bool isStable(struct Card C1[], struct Card C2[], int N){
    for (int i=0; i<N; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    for (int i=0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
X = int(input())

N = X/100 #個数

Xn = X%100
#print("Xn="+str(Xn))
n = 0

N5 = int(Xn/5)
#print("N5="+str(N5))
N4 = int(Xn%5/4)
#print("N4="+str(N4))
N3 = int((Xn-N5*5-N4*4)/3)
#print("N3="+str(N3))
N2 = int((Xn-N5*5-N4*4-N3*3)/2)
#print("N2="+str(N2))
N1 = Xn-N5*5-N4*4-N3*3-N2*2

#print(N1)

if N5+N4+N3+N2+N1>N:
    print("0")
else:
    print("1")





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

struct SegmentTree{
private:
  vector<long long> node;
  int n;
public:
  SegmentTree(int sz){
    n = 1;
    while(n < sz) n *= 2;
    node.resize(2*n-1,0);
  }
  void add(int idx, long long x){
    idx += n-1;
    node[idx] += x;
    while(idx > 0){
      idx = (idx-1)/2;
      node[idx] = max(node[idx*2+2],node[idx*2+1]);
    }
  }
  long long getmax(int a, int b, int t=0, int l=0, int r=-1){
    if(r < 0) r = n;
    if(b <= l or a >= r) return 0;
    if(a <= l and b >= r) return node[t];
    long long vl = getmax(a,b,2*t+1,l,(l+r)/2);
    long long vr = getmax(a,b,2*t+2,(l+r)/2,r);
    return max(vl,vr);
  }
};

int main(){
  int N;
  cin >> N;
  vector<long long> H(N), A(N);
  for(int i = 0; i < N; ++i) cin >> H[i];
  for(int i = 0; i < N; ++i) cin >> A[i];
  SegmentTree st(N+1);
  for(int i = 0; i < N; ++i){
    long long m = st.getmax(0,H[i]);
    st.add(H[i],A[i]+m);
  }
  cout << st.getmax(0,N+1) << endl;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
const int N = 3e3 + 10;
ll n, mod, g[N][N], f[N], s[N], fac[N], inv[N], ans;

ll qpow(ll a, ll b, ll mod) {
    ll ret = 1;
    for (; b; b >>= 1) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
    } return ret;
}

ll C(ll n, ll m) {
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
    cin >> n >> mod;
    fac[0] = inv[0] = inv[1] = 1;
    rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
    rep(i, 2, n) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    rep(i, 2, n) inv[i] = inv[i] * inv[i - 1] % mod;
    rep(i, 0, n) {
        g[i][0] = 1;
        ll t1 = qpow(2, n - i, mod), t2 = qpow(2, n - i, mod - 1), cur = 1;
        rep(j, 0, i) {
            if (j) g[i][j] = (g[i - 1][j - 1] + (j + 1) * g[i - 1][j] % mod) % mod;
            (f[i] += g[i][j] * cur % mod) %= mod;
            (cur *= t1) %= mod;
        }
        (ans += (i & 1 ? -1ll : 1ll) * qpow(2, t2, mod) * C(n, i) % mod * f[i] % mod + mod) %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 50008
N, M = map(int, input().split()) # Nはスイッチの数、Mは電球の数
lights = [[0] * N for _ in range(M)]
for i in range(M): 
    temp = list(map(int, input().split())) # 0番目はスイッチの個数、1番目以降はスイッチを示す
    k = temp[0]
    switches = temp[1:]
    for j in range(k):
        lights[i][switches[j]-1] = 1
P = list(map(int, input().split())) # 個数を2で割ったあまりが要素と等しい場合に点灯する

answer_count = 0
for i in range(2**N):
    flag = True
    for k in range(M):
        count = 0
        for j in range(N):
            if (i >> j) & 1:
                count += lights[k][j]
        if count % 2 != P[k]:
            flag = False
            break
    if flag:
        answer_count += 1

print(answer_count)

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	char c;
	cin >> c;

	switch (c) {
	case 'A':
		cout << "T" << endl;
		break;
	case 'T':
		cout << "A" << endl;
		break;
	case 'C':
		cout << "G" << endl;
		break;
	case 'G':
		cout << "C" << endl;
		break;
	}

	return 0;
}


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


int main() {
  // ここにプログラムを追記
  long long  n;
  cin >> n ;
  long long  ans;
  ans = 0;
  for (int i = 1; i <= n; i++)
  {
    if (i % 15 == 0) {
     continue;
    }
    else if (i % 3 == 0)
    {
      continue;
    }
    else if (i % 5 == 0)
    {
      continue;
    }
    else
    //cout << i << endl;
      ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int cnt = 0;
	int Z = S.size();
	rep(i, Z) {
		if (S[i] == 'o') {
			cnt++;
		}
	}
	if (cnt + 15 - Z >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


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

const int _ = 2e5 + 7; int N , fa[_] , sz[_];
struct thing{int x , y , id;}now[_];
int find(int x){return fa[x] == x ? x : (fa[x] = find(fa[x]));}
void merge(int p , int q){fa[find(p)] = find(q);}
map < int , int > pos;

int main(){
	cin >> N; for(int i = 1 ; i <= N ; ++i){cin >> now[i].x >> now[i].y; now[i].id = i;}
	for(int i = 1 ; i <= N ; ++i) fa[i] = i;
	sort(now + 1 , now + N + 1 , [&](thing p , thing q){return p.x > q.x;});
	for(int i = 1 ; i <= N ; ++i){
		auto p = pos.lower_bound(now[i].y); int mxy = now[i].y;
		while(p != pos.end()){merge(now[i].id , p->second); mxy = p->first; pos.erase(p++);}
		pos[mxy] = now[i].id;
	}
	for(int i = 1 ; i <= N ; ++i) ++sz[find(i)];
	for(int i = 1 ; i <= N ; ++i) cout << sz[find(i)] << endl;
	return 0;
}

Measured memory_bytes: 7680
package main

import "fmt"

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m, &x, &y)

	xMax := x
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)

		if xMax < tmp {
			xMax = tmp
		}
	}

	yMin := y
	for i := 0; i < m; i++ {
		var tmp int
		fmt.Scan(&tmp)

		if yMin > tmp {
			yMin = tmp
		}
	}

	if xMax < yMin {
		fmt.Println("No War")
		return
	}
	fmt.Println("War")
}


Measured memory_bytes: 512
N=int(input())
inl=list(map(lambda x: int(x)*2,input().split()))
vs=list(map(int,input().split()))

sumtime = sum(inl)

limits = [0]
for i, t in enumerate(inl):
    for _ in range(t):
        limits.append(vs[i])

resv = [0]
for i in range(1, sumtime+1):
    resv.append(min(resv[-1]+0.5, limits[i]))

resv[sumtime] = 0
for i in reversed(range(1, sumtime+1)):
    resv[i-1] = min(resv[i]+0.5, resv[i-1], limits[i])

# print(limits)
# print(resv)
res = 0.0
for i in range(sumtime):
    res += (resv[i] + resv[i+1])*0.5

print(res*0.5)


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

using namespace std;

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

    int n,m;

    cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin>>A[i];

    cin>>m;
    vector<int> B(m);
    for(int i=0;i<m;i++) cin>>B[i];

    cout<<(A<B)<<endl;

    return 0;
}



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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int a;

void input() {
	cin>>a;
}

void solve() {
	cout<<a+a*a+a*a*a<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3628
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

const int N = 1e5+5;
vector<int> year[N];

int p[N], y[N];

int main(){
    // FILE *fp = freopen("out.txt", "w", stdout);
    // freopen("in.txt", "r", stdin);
    int n, m, i;
    while(scanf("%d%d", &n, &m) != EOF){
        for(i = 1; i <= n; i++)
            year[i].clear();
        for(i = 1; i <= m; i++){
            scanf("%d%d", &p[i], &y[i]);
            year[p[i]].push_back(y[i]);
        }
        for(i = 1; i <= n; i++)
            sort(year[i].begin(), year[i].end());
        for(i = 1; i <= m; i++)
            printf("%06d%06d\n", p[i], (int)(lower_bound(year[p[i]].begin(), year[p[i]].end(), y[i]) - year[p[i]].begin() + 1));
    }

    // fclose(fp);
    return 0;
}

Measured memory_bytes: 7808
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<bool> isL(2 * n);
	isL[0] = true;
	for(int i = 1; i < s.length() - 1; i++){
		if(s[i] == s[i - 1]){
			isL[i] = !isL[i - 1];
		} else {
			isL[i] = isL[i - 1];
		}
	}
	long long int lnum[200001] = {};
	long long int rnum[200001] = {};
	rnum[s.length() - 1] = 1;
	for(int i = s.length() - 2; i >= 0; i--){
		rnum[i] = rnum[i + 1];
		lnum[i] = lnum[i + 1];
		if(!isL[i]) rnum[i]++;
		else lnum[i]++;
	}
	if(rnum[0] != lnum[0] || s[0] == 'W' || s[s.length() - 1] == 'W'){
		cout << 0 << endl;
		return 0;
	}

	long long int ans = 1;
	for(int i = s.length() - 2; i >= 0; i--){
		if(!isL[i]) continue;
		ans = (ans * max((long long int)0, rnum[i] - lnum[i + 1])) % mod;
		// cout << i << " " << ans << endl;
	}

	for(int i = 1; i <= n; i++){
		ans = (ans * i) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3716
def main():
	x, n = map(int, input().split())
	arr = set(list(map(int, input().split())))
	for d in range(0, 1000):
		for m in range(-1, 2, 2):
			y = x + m * d
			if y not in arr:
				print(y)
				return

main()

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define sf(i,s) for(i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define inf 1e18
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tr(v,i) for(typeof(v).begin() i = v.begin(); i != v.end(); i++)
#define pre(v,x) (v.find(x) != v.end())
#define vpre(v,x) (find(all(v),x) != v.end())
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    else
    {
        ll t = power(a, b / 2);
        if (b % 2 == 0)
            return t*t;
        else
            return t*t*a;
    }
}
void solve()
{
    ll x;
 cin>>x;
 if(x>=30)
    cout<<"Yes\n";
 else
    cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

lint fac[510000],finv[510000],inv[510000];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<510000;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;
  }
}
lint COM(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
lint facdiv(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%MOD;
}

int main(void){
    COMinit();
    lint S;
    cin >> S;
    lint ans=0;
    for(int i=1;i<=2000;i++){
        if(S-3*i<0) break;
        lint rem=S-3*i;
        ans=(ans+COM(rem+i-1,rem))%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long int n,k,ans=1000000000;
    cin>>n>>k;
    
    int h[n];
    
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    
    sort(h,h+n);
    
    for(int j=0;j<n-k+1;j++){
        if(h[j+k-1]-h[j]<ans){
            ans=h[j+k-1]-h[j];
        }
    }
    
    cout<<ans;
    
    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, T;
int A[100010];
int dif[100010];

int main() {
   cin >> N >> T;
   rep (i, N) {
      cin >> A[i];
   }

   map<int, int> m;
   int Min = 1e9+10;
   repp (i, 0, N) {
      if (A[i] - Min > 0) {
         m[A[i]-Min]++;
      }
      Min = min(Min, A[i]);
   }

   cout << m.rbegin()->second << endl;

   return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        int date = Integer.parseInt(String.join("", S.split("/")));

        if (date <= 20190430) {
            System.out.println("Heisei");
        } else {
            System.out.println("TBD");
        }
    }
}


Measured memory_bytes: 23764
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
use ::std::cmp::*;
use std::intrinsics::transmute;

fn main() {
    let n: usize = read();
    let w: usize = read();
    let mut weight = vec![0; n];
    let mut v = vec![0; n];
    for i in 0..n {
        let mut W: i64 = read();
        let mut V: i64 = read();
        weight[i] = W;
        v[i] = V;
    }
    let mut dp: Vec<Vec<i64>> = vec![vec![0; w + 1]; n + 1];
    for i in 0..n {
        for j in 0..w + 1 {
            if j as i64 - weight[i] >= 0 {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i] as usize] + v[i]);
            }
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
        }
    }
    println!("{}", dp[n][w]);
}


Measured memory_bytes: 81212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#include<vector>
#include<set>
#include<list>
#include<ctime>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))

using namespace std;

#define MaxN 5005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1e9+7;
const int eps = 1e-8;
#define bug cout << 88888888 << endl;
int N;
LL K;
LL node[MaxN];
int main()
{
    while(~scanf("%d%lld", &N, &K))
    {
        LL sum = 0;
        for(int i=1;i<=N;i++)
        {
            scanf("%lld", node+i);
        }
        sort(node+1, node+1+N);
        for(int i=1;i<=N;i++)
        {
            if(sum<K)
            {
                sum += node[i];
            }
            else break;
        }
        if(sum<K) 
        {
            printf("%d\n", N);
            continue;
        }
        LL* it = (upper_bound(node+1,node+1+N, K));
        it -=1;
        int ans = 0;

        for(int i=1;i<=N;i++)
        {
            if(sum>=K)
            {
                sum -= node[i];
            }

            if(sum<K)
            {
                ans = i-1;
                break;
            }
        }
        LL* low = it;
        LL* high = it;
        int lim = ans;
        while( low!= node+lim )
        {
            int cnt = 0;
            for(LL* i = low;i<=high;i++)
            {
                cnt += *i;
            }
            while(cnt>=K)
            {
                cnt -= *high;
                high--;
            }
            //cout << cnt << endl;
            for(int i=ans;i>0;i--)
            {
                if(cnt+node[i]>=K) ans --;
            }
            if(ans==0) break;
            low--;
        }
        printf("%d\n", ans);

    }
}


Measured memory_bytes: 256
from sys import stdin
S = stdin.readline().rstrip()
s1 = S[0]
if S[0] == S[1]:
    s2 = S[2]
else:
    s2 = S[1]
if S.count(s1) == 2 and S.count(s2) == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

def Com(n, k):
    p, q = 1, 1
    for i in range(n-k+1, n+1):
        p *= i
    for i in range(2, k+1):
        q *= i
    return p//q

N, P = map(int, input().split())
A = list(map(int, input().split()))
o = 0
for x in A:
    if x % 2:
        o += 1
e = N-o
if P == 0:
    ans = int(pow(2, e))
    t = 1
    for i in range(2, o+1):
        if i % 2 == 0:
            t += Com(o, i)
    print(ans*t)
else:
    if o == 0:
        print(0)
    else:
        ans = int(pow(2, e))
        t = 0
        for i in range(1, o+1):
            if i % 2:
                t += Com(o, i)
        print(ans*t)


Measured memory_bytes: 3444
from sys import stdin

r, g, b, n = map(int, stdin.readline().rstrip().split())
count = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g <= n:
            if (n - (i * r + j * g)) % b == 0:
                # print(i, j, int((n - (i * r + j * i)) / b))
                count += 1
print(count)

Measured memory_bytes: 41196
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
string S;
ll l, a[500001];
ll ans; 
int main()
{
	cin>>S;
	S= " " +S;
    l = S.length() - 1;
    for(int i=1;i<=l;i++) (S[i] == '<') ? (a[i+1] = a[i] + 1) : (a[i+1]);
    for(int i=l;i>=1;i--) (S[i] == '>') ? (a[i] = max(a[i], a[i+1]+1)) : (a[i]);
    for(int i=1;i<=l+1;i++) ans += a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4760
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	string left="qazwsxedcrfvtgb";
	string right="yhnujmikolp";
	while(1){
		string s; cin >>s;
		if(s=="#")break;
		bool a=false;
		bool b=false;
		int cnt=0;
		for(int i=0;i<s.size();i++){
			bool c=false;
			for(int j=0;j<11;j++){
				if(s[i]==right[j]){
					b=true;
					if(a==true){
						cnt++;
						a=false;
					}
					c=true;
				}
			}
			if(c==false){
				a=true;
				if(b==true){
					cnt++;
					b=false;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main(){
    ll n;
    cin >>n;
    ll mn=INFll;
    for (int i = 0; i < 5; ++i) {
        ll a;cin >>a;
        mn=min(mn,a);
    }
    ll ans=4+(n-1)/mn+1;
    cout <<ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int main(void){
	int n=nextint();
	long ans=0;
	for(int i=1; i<n; i++){
		ans += (n-1)/i;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 1608
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    candies = sorted(list(map(int, input().split())))

    first = sum(candies[:2])
    second = candies[2]

    if first == second:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 2940
N = int(input())
S = [input() for i in range(N)]
 
c0 = 0
c1 = 0
c2 = 0
c3 = 0
 
for i in range(N):
  if S[i] == 'AC':
    c0 += 1
  elif S[i] == 'WA':
    c1 += 1
  elif S[i] == 'TLE':
    c2 += 1
  elif S[i] == 'RE':
    c3 += 1
 
print('AC x %d' %c0)
print('WA x %d' %c1)
print('TLE x %d' %c2)
print('RE x %d' %c3)

Measured memory_bytes: 16184
loop = int(input())
streak = 0
verify = False
for i in range(loop):
    diceArr = input().split()
    if diceArr[0] == diceArr[1]:
        streak+=1
        if streak==3:
            verify = True
    else:
        streak=0
if verify:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int a[110];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int i;
        int sum=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        sort(a+1,a+1+n);
        if(sum%10)
        {
//            cout<<"yes"<<endl;
            cout<<sum<<endl;
        }
        else
        {
            int ans=0;
            for(i=1;i<=n;i++)
            {
                if(a[i]%10)
                {
                    ans+=a[i];
                    break;
                }
            }
            if(i==n+1) sum=0;
            else sum-=ans;
            cout<<sum<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void read(T& x)
{
	char c = getchar(); T p = 1, n = 0;
	while(c < '0' || c > '9') {if(c == '-') p = -1; c = getchar();}
	while(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}
	x = p * n;
}
template<class T,class U>void read(T&x,U&y){read(x),read(y);}
template<class T,class U,class V>void read(T&x,U&y,V&z){read(x),read(y),read(z);}
const long long maxn = 1e5 + 5, maxc = 1e14 + 5;
long long sum[maxn], sum2[maxn], x[maxn], v[maxn], opt[maxn], opt2[maxn];
int main()
{
	int n; long long c; read(n, c);
	for(int i = 1; i <= n; ++i)
		read(x[i], v[i]);
	long long ret = 0, pos = 0, ret2 = 0, pos2 = 0;
	for(int i = 1; i <= n; ++i) 
	{
		sum[i] += sum[i - 1] - x[i] + x[i - 1] + v[i];
		opt[i] = opt[i - 1];
		if(sum[i] > opt[i]) opt[i] = sum[i], pos = i;
	}
	x[n + 1] = c;
	for(int i = n; i; --i) 
	{
		sum2[i] += sum2[i + 1] - x[i + 1] + x[i] + v[i];
		opt2[i] = opt2[i + 1];
		if(sum2[i] > opt2[i]) opt2[i] = sum2[i], pos2 = i;
	}
	long long ans = 0;
	for(int i = 1; i <= n; ++i)
	{
		ans = max(ans, max(sum[i], sum[i] - x[i] + opt2[i + 1]));
	}
	for(int i = n; i; --i)
	{
		ans = max(ans, max(sum2[i], sum2[i] - (c - x[i]) + opt[i - 1]));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992
n=int(input())
A=list(map(int,input().split()))
flag=True
if n%2==0:
    if 0 in A or len(set(A))!=n//2:flag=False
else:
    if A.count(0)!=1 or len(set(A))!=(n+1)//2:
        flag=False
if flag:
    print(2**(n//2)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 14004
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N=2e5+5;
int n,b[N],m,sum;
vector<int>vec[N];
int d[N<<2],tag[N<<2];
void build(int l,int r,int o){
	if(l==r)d[o]=0x3fffffff;else{
		const int mid=l+r>>1;
		build(l,mid,o<<1),build(mid+1,r,o<<1|1);
		d[o]=0x3fffffff;
	}
}
void pushdown(int o){
	int&x=tag[o];
	tag[o<<1]+=x,tag[o<<1|1]+=x;
	d[o<<1]+=x,d[o<<1|1]+=x,x=0;
}
void modify(int l,int r,int o,const int&pos,const int&val){
	if(l==r)d[o]=min(d[o],val);else{
		if(tag[o])pushdown(o);
		const int mid=l+r>>1;
		if(pos<=mid)modify(l,mid,o<<1,pos,val);else modify(mid+1,r,o<<1|1,pos,val);
		d[o]=min(d[o<<1],d[o<<1|1]);
	}
}
void modify(int l,int r,int o,const int&L,const int&R,const int&val){
	if(L<=l&&r<=R){
		d[o]+=val,tag[o]+=val;
	}else{
		pushdown(o);
		const int mid=l+r>>1;
		if(L<=mid)modify(l,mid,o<<1,L,R,val);
		if(mid<R)modify(mid+1,r,o<<1|1,L,R,val);
		d[o]=min(d[o<<1],d[o<<1|1]);
	}
}
int query(int l,int r,int o,const int&L,const int&R){
	if(L<=l&&r<=R)return d[o];
	pushdown(o);
	const int mid=l+r>>1;
	if(L<=mid&&mid<R)return min(query(l,mid,o<<1,L,R),query(mid+1,r,o<<1|1,L,R));
	if(L<=mid)return query(l,mid,o<<1,L,R);
	return query(mid+1,r,o<<1|1,L,R);
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>b[i],sum+=!b[i];
	for(cin>>m;m--;){
		int l,r;
		cin>>l>>r;
		vec[l].push_back(r);
	}
	build(0,n,1);
	modify(0,n,1,0,0);
	for(int i=1;i<=n;++i){
		for(int y:vec[i])modify(0,n,1,y,query(0,n,1,0,y));
		modify(0,n,1,0,i-1,b[i]?1:-1);
	}
	printf("%d\n",query(0,n,1,0,n)+sum);
	return 0;
}

Measured memory_bytes: 16000
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
     int a = sc.nextInt();
     int b = sc.nextInt();
     int c = sc.nextInt();
     int d = sc.nextInt();
     int deltaAB = Math.abs(a - b);
     int deltaBC = Math.abs(b - c);
     int deltaCA = Math.abs(c - a);
     if ((deltaAB <= d && deltaBC <= d) || deltaCA <= d) {
       System.out.println("Yes");
     } else {
       System.out.println("No");
     }
  }
}

Measured memory_bytes: 23124
#include<iostream>

int main(void){
	int H, W;
	
	while(1){
		std::cin >> H >> W;
		
		if (H == 0 && W ==0) break;
		
		for (int i = 1; i <= H; i++) {
			if (i % 2 == 1){
				for (int j = 1; j <= W;  j++) {
					if (j % 2 == 1) std::cout << '#';
					else std::cout << '.';
				}
			}
			else {
				for (int j = 1; j <= W;  j++) {
					if (j % 2 == 1) std::cout << '.';
					else std::cout << '#';
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//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(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N;
	cin >> N;
	
	ll a;
	vector<ll> counts(N);
	for (ll i = 0; i < N; ++i) {
		cin >> a;
		++counts[--a];
	}
	sort(counts.begin(), counts.end());

	vector<ll> dists(N);
	for (ll i = 0; i < N; ++i) {
		dists[i] = distance(lower_bound(counts.begin(), counts.end(), i + 1), counts.end());
	}

	vector<ll> fs(N);
	ll f = 0;
	for (ll i = 0; i < N; ++i) {
		f += dists[i];
		fs[i] = f / (i + 1);
	}

	vector<ll> results(N);
	for (ll k = N, i = 0; k > 0; --k) {
		while (i < N) {
			if (fs[i] < k) {
				results[k - 1] = i;
				break;
			}
			else {
				++i;
			}
		}
	}
	results[0] = N;

	for (ll i = 0; i < N; ++i) {
		cout << results[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 10240
#include <iostream>

int main() {
  int r, c, sum = 0;
  std::cin >> r >> c;
  int table[c][r];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      std::cin >> table[j][i];
    }
  }
  for (int i = 0; i < r; i++) {
    int x = 0;
    for (int j = 0; j < c; j++) {
      std::cout << table[j][i] << " ";
      x += table[j][i];
    }
    std::cout << x << std::endl;
    sum += x;
  }
  for (int i = 0; i < c; i++) {
    int x = 0;
    for (int j = 0; j < r; j++) {
      x += table[i][j];
    }
    std::cout << x << " ";
  }
  std::cout << sum << std::endl;
  return 0;
}



Measured memory_bytes: 3072
from collections import defaultdict
import bisect

S = input()
T = input()

d = defaultdict(list)

for i, s in enumerate(S, 1):
    d[s].append(i)

ans = 0
cnt = 0

for t in T:
    c = d[t]
    if len(c)==0:
        print(-1)
        quit()
    if c[-1] <= ans:
        ans = c[0]
        cnt += 1
    else:
        ans = c[bisect.bisect_right(c, ans)]
        
print(len(S)*cnt + ans)
        

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

typedef long long ll;
ll n, m, mod = 1e9+7;
vector<ll> x, y;

ll f(vector<ll> &v){
	int p = v.size()-1;
	vector<ll> a(p, 0), b(p, 0);
	a[0] = v[0];
	b[0] = v[0];
	for(int i=1; i<p; ++i){
		b[i] = b[i-1] + (i+1)*v[i];
		b[i] %= mod;
		a[i] = a[i-1] + b[i];
		a[i] %= mod;
	}
//	for(int i=0; i<p; ++i)
//		cout << i << " " << a[i] << " " << b[i] << "\n";
	return a[p-1];
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	x.resize(n);
	y.resize(m);
	for(int i=0; i<n; ++i) cin >> x[i];
	for(int i=0; i<m; ++i) cin >> y[i];
	for(int i=0; i<n-1; ++i) x[i] = x[i+1] - x[i];
	for(int i=0; i<m-1; ++i) y[i] = y[i+1] - y[i];
	cout << f(x) * f(y) % mod << "\n";
}

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

int main() {
  int a = 0, b = 0;
  cin >> a >> b;
  
  if((a * b)%2 == 0) {
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}






Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;

ll solve() {
    ll N;
    cin >> N;
    vector<ll> p(N+1);
    for ( int i = 2; i <= N; i++ ) {
        p[i] = 1;
    }
    for ( int i = 2; i <= N; i++ ) {
        for ( int j = 2; i * j <= N; j++ ) {
            p[i*j] = 0;
        }
    }
    ll ans = 1;
    for ( int i = 2; i <= N; i++ ) {
        if ( p[i] == 1 ) {
            ll pp = i;
            ll np = 0;
            for ( ll q = pp; q <= N; q*=pp ) {
                np += N/q;
                np %= MOD;
            }
            ans *= np + 1;
            ans %= MOD;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  string w;
  cin >> w;

  unordered_map<char, int> cnt;

  for (char c : w) {
    if (cnt.count(c)) {
      ++cnt[c];
    } else {
      cnt[c] = 1;
    }
  }

  string ans = "Yes";
  for (char c : w) {
    // cerr << cnt[c] << " ";
    if (cnt[c] % 2 == 1) {
      ans = "No";
      break;
    }
  }
  // cerr << '\n';

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pair<char,int> a,pair<char,int> b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
bool f=true;

void Main(){
  string s;
  cin>>s;
  int n = s.length();
  for (int p = 0; p < (n); p++)
  {
    if(s[p] !=s[n-1-p] ) f=false;
  }
  // cout<<s<<endl;

  string s1 = s.substr(0,(n/2));
  n = s1.length();
  for (int p = 0; p < (n); p++)
  {
    if(s1[p] !=s1[n-1-p] ) f=false;
  }
  // cout<<s1<<endl;
 
  string s2 = s.substr((s.length()+1)/2,(s.length()/2));
  n = s2.length();
  for (int p = 0; p < (n); p++)
  {
    if(s2[p] !=s2[n-1-p] ) f=false;
  }
  // cout<<s2<<endl;

  if(f)cout<<"Yes";
  else cout<<"No";  
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    static final int MODULUS = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static String solve(int[] a) {
        int[] result = new int[a.length];
        int c = 1;
        for (int i = 0; i < a.length; ++i) {
            c = divideMod(multiplyMod(c, a.length - i), i + 1);
            result[i] = c;
        }

        int betweenCount = computeBetweenCount(a);
        c = 1;
        for (int k = 1; k <= a.length - betweenCount; ++k) {
            result[k - 1] = subtractMod(result[k - 1], c);

            c = divideMod(multiplyMod(c, a.length - betweenCount - k - 1), k);
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining("\n"));
    }

    static int computeBetweenCount(int[] a) {
        Map<Integer, Integer> valueToIndex = new HashMap<>();
        for (int i = 0;; ++i) {
            if (valueToIndex.containsKey(a[i])) {
                return i - valueToIndex.get(a[i]) - 1;
            }

            valueToIndex.put(a[i], i);
        }
    }

    static int subtractMod(int x, int y) {
        return ((x - y) % MODULUS + MODULUS) % MODULUS;
    }

    static int multiplyMod(int x, int y) {
        return (int) ((long) x * y % MODULUS);
    }

    static int divideMod(int x, int y) {
        return multiplyMod(x, BigInteger.valueOf(y).modInverse(BigInteger.valueOf(MODULUS)).intValue());
    }
}

Measured memory_bytes: 100292
#include <stdio.h>
#include <stdlib.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

const int inf = 1 << 30;
int a, b, c;
int n;
int lll[5];
int ll[5];
int l[10];


int solve(int pos)
{
    if (pos >= n) {
        int res = 0;
        for (int i = 0; i < 3; i++) {
            if (ll[i] == 0) {
                res = inf;
            }
            else {
                res += abs(ll[i] - lll[i]);
            }
        }

        return res;
    }

    int res = inf;
    for (int i = 0; i < 4; i++) {
 
        if (ll[i] == 0 || i == 3) {
            ll[i] = l[pos];
            res = min(solve(pos + 1), res);
        }
        else {
            ll[i] += l[pos];
            res = min(solve(pos + 1) + 10, res);
        }
        ll[i] -= l[pos];
    }

    return res;
}

int main()
{
    scanf("%d %d %d %d", &n, lll, lll + 1, lll + 2);
    for (int i = 0; i < n; i++) {
        scanf("%d", l + i);
    }

    printf("%d\n", solve(0));

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
  string s, t;
  cin >> s >> t;
  int n, m;
  n = s.size(), m = t.size();
  vector<vector<int>> sp(26);
  REP(i, n) sp[s[i] - 'a'].push_back(i);
  REP(i, n) sp[s[i] - 'a'].push_back(i+n);
  ll ans = 0;
  int p = 0;
  REP(i, m) {
    int c = t[i] - 'a';
    if (sp[c].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    p = *lower_bound(ALL(sp[c]), p) + 1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
int main(){
	LL a=read(),b=read(),c=read();
	LL ans=0;
	LL d=min(c,a);
	ans+=d;
	a-=d,c-=d;
	if (c==0){
		ans+=b;
	}
	else {
		LL d=min(c,b);
		ans+=d<<1;
		b-=d,c-=d;
		if (b>0)
			ans+=b;
		else if (c>0)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256