akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < (1 << 4); i++) {
        string ans;
        if (i & (1 << 0)) ans += 'A';
        ans += "KIH";
        if (i & (1 << 1)) ans += 'A';
        ans += "B";
        if (i & (1 << 2)) ans += 'A';
        ans += "R";
        if (i & (1 << 3)) ans += 'A';
        if (ans == s) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin>>n>>x;
    int l[n];
    int sum =0;
    int ans =0;
    for(int i=0;i<n;i++){
        cin >> l[i];
        sum += l[i];
        if(sum<=x) ans++;
    }
    cout << ans+1 << endl;
}



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

int sum_function(int n){
	int sum = 0;
	while(n>0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main (){
	int N,A,B;
	cin >> N >> A >> B;
	int total = 0;
	for (int i = 1; i <= N; ++i){
		int sum = sum_function(i);
		if(sum >= A && sum <= B){
			total += i;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100010
#define INF 1e9
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
struct Info{int opt,l,r,x;}f[N*3];
struct seg{int ls,rs,su;}t[10000010];
int nf,q,p1,p2,q1,q2,ansn,ro,num;
bool comp(const Info &a,const Info &b){if (a.x==b.x) return a.opt<b.opt;return a.x<b.x;}
int pa(int x){if (x>=0) return x/2;return (x-1)/2;}
void add(int &nu,int l,int r,int we,int x){
	if (!nu) nu=++num;
	t[nu].su+=x;
	if (l!=r){
		int mid=pa(l+r);
		if (we<=mid) add(t[nu].ls,l,mid,we,x);
		else add(t[nu].rs,mid+1,r,we,x);
	}
}
int que(int nu,int l,int r,int nl,int nr){
	if (!nu) return 0;
	if (l==nl&&r==nr) return t[nu].su;
	int mid=pa(l+r);
	if (nl>mid)return que(t[nu].rs,mid+1,r,nl,nr);
	if (nr<=mid) return que(t[nu].ls,l,mid,nl,nr);
	return que(t[nu].ls,l,mid,nl,mid)+que(t[nu].rs,mid+1,r,mid+1,nr);
}
int main(){
	read(q);
	for (int i=1;i<=q;i++){
		read(p1);read(q1);read(p2);read(q2);
		if (p1==p2){
			if (q1>q2) swap(q1,q2);
			f[++nf].opt=1;f[nf].l=p1;f[nf].x=q1;
			f[++nf].opt=-1;f[nf].l=p1;f[nf].x=q2+1;
		}else{
			if (p1>p2) swap(p1,p2);
			f[++nf].opt=2;f[nf].l=p1;f[nf].r=p2;f[nf].x=q1;
		}
	}
	sort(f+1,f+nf+1,comp);
	for (int i=1;i<=nf;i++){
		if (f[i].opt==2)ansn+=que(ro,-INF,INF,f[i].l,f[i].r);
		else add(ro,-INF,INF,f[i].l,f[i].opt);
	}
	cout<<ansn<<endl;
	return 0;
}


Measured memory_bytes: 8468
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int)



int inv_mod(int a, int m)
{
	int b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	string s;
	cin >> s;
	bool f[4] = {false, false, false, false};
	REP(i, s.size()) {
		if (s[i] == 'N') f[0] = true;
		if (s[i] == 'S') f[1] = true;
		if (s[i] == 'E') f[2] = true;
		if (s[i] == 'W') f[3] = true;
	}

	cout << (f[0] == f[1] && f[2] == f[3] ? "Yes" : "No") << endl;

	
	return 0;
}

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

using namespace std;

const int N = 3E5 + 5;
int pe[N], pw[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    int cnte, cntw;
    cnte = cntw = 0;
    for(int i = 0; i < n; i ++) {
        s[i] == 'E' ? cnte ++ : cntw ++;
        pe[i] = cnte;
        pw[i] = cntw;
    }
    int res = INT_MAX;
    for(int i = 0; i < n; i ++) {
        int t = cnte - pe[i];
        if(i > 0)
            t += pw[i - 1];
        res = min(res, t);
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
   int x[3];
  
for(int i = 0;i<3;i++){
     
  cin >> x[i];
  

}
  
  sort(x, x + 3, greater<int>()); 
  
   int a;
  
 
   cin >> a;
  
  
  
  // cout << a << endl;
//  cout << x[0] << endl;
  
  int sum = x[1]+x[2];
  
  int num = x[0];
  
  for(int i = 0;i<a;i++){
     
    num = num*2;
   // cout << num << endl;
    
   
  

}
   sum = sum + num;
   cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define sz(a) (int)((a).size())
#define NoType ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair

typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//find_by_order(x) -> returns an iterator to the element at a given position
//order_of_key(x) -> returns the position of a given element

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pi;

const int mod = (int)1e9 + 7;
const int MAXN = 2e5+12;
//indexed_set s;

int n;

int main() {

    NoType;

    cin >> n;
    ll m[n + 1] = {0};

    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j+=i) {
            m[j]++;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ans += (i * m[i]);
    }

    cout << ans;

return 0;
}


Measured memory_bytes: 81716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

template< int mod >
struct ModInt {
  int x;
 
  ModInt() : x(0) {}
 
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
 
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
 
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
 
  ModInt operator-() const { return ModInt(-x); }
 
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
 
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
 
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
 
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
  bool operator==(const ModInt &p) const { return x == p.x; }
 
  bool operator!=(const ModInt &p) const { return x != p.x; }
 
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
 
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
 
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
 
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
 
  static int get_mod() { return mod; }
};
 
using modint = ModInt< mod >;

int main(){
    string l;cin>>l;
    int n=l.size();
    modint dp[n+1][2]={};
    dp[0][1]=1;
    rep(i,n){
        int now=l[i]-'0';
        dp[i+1][1]+=modint(now?2:1)*dp[i][1];
        if(now)dp[i+1][0]+=dp[i][1];
        dp[i+1][0]+=dp[i][0]*3;
    }
    cout<<dp[n][1]+dp[n][0]<<endl;
}

Measured memory_bytes: 1280
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;

int a[maxn], n, m, k;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	a[0] =  1, a[1] = 1;
	cin >> n >> m;
	while (m--)
		cin >> k, a[k] = -1;
	for (int i = 2; i <= n; i++) {
		if (a[i] == -1)
			continue;
		a[i] = (max(a[i - 1], 0) + max(a[i - 2], 0)) % mod;
	}
	cout << max(a[n], 0) << '\n';
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	int res = 0;
	for(int i = 0; i < 3; i++){
			if(s[i] == '1')res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
a,b = input().split()
A,B = input().split()
c = input()
a = str(a)
b = str(b)
A = int(A)
B = int(B)
c = str(c)
d = A - 1
D = B - 1
if c == a:
    print(d,B)
elif c == b:
    print(A,D)

Measured memory_bytes: 3060
a = gets.chomp.split("")
b = []
c = 0
d = a.uniq
d.length.times do
  if a.count(d[c]) % 2 == 0
    c += 1
    b.push("YES")
  else
    c += 1
    b.push("NO")
  end
end


if b.include?("NO")
  puts "No"
else
  puts "Yes"
end

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'
typedef long long ll;

const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const ll MXN = 1e18;


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

   int n; cin>>n;
   ll arr[n];
   int flg = 0;
   for (int i = 0; i < n; ++i)
   {
   	cin>>arr[i];
   	if(arr[i] == 0) flg = 1;
   }
   if(flg){
   	cout<<0<<endl;
   }
   else{
	   ll ans = 1;
	   for (int i = 0; i < n; ++i)
	    {
	    	ll prev = ans;
	    	ans *=arr[i];
	    	if(prev > ans or ans > MXN){
	    		ans = -1;
	    		break;
	    	}
	    }
	    cout<<ans<<endl; 
   }

   return 0;
}

Measured memory_bytes: 4436
n,m=map(int,input().split())
l=[0 for i in range(n+1)]
l[0]=1
l[1]=1
for i in range(m):
    a=int(input())
    l[a]=-1
#print(l)
mod=10**9+7
for i in range(2,n+1):
    if l[i]==-1:
        continue
    elif l[i-1]==-1 and l[i-2]==-1:
        l[i]=0
    elif l[i-1]==-1:
        l[i]=l[i-2]
    elif l[i-2]==-1:
        l[i]=l[i-1]
    else:
        l[i]=l[i-1]+l[i-2]
        l[i]%=mod
   
print(l[-1]%mod)

Measured memory_bytes: 7064
/*
g++ -std=c++11 -o2 -Wall ABC101A.cpp -o ./out/ABC101A.out
./out/ABC101A.out
*/

#include <bits/stdc++.h>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int ans = 0;
    string s;
    cin >> s;
    int n = s.size();
    for (int i; i < n; ++i) {
      char c = s[i];
      if (c == '+') ++ans;
      else --ans;
    }
    cout << ans << "\n";
}


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

using namespace std;
int main(){

    int n,a;
    vector<int>v(1,0); //要素数10 全てのがず0
    cin >> n;
    
    while(n--){
        cin >> a;
        v.push_back(a);//add的な意味
    }
    
    for(int j=1; j<v.size();j++){
        int key = v[j]; //j  = 1~size
        int i = j - 1;//一つ左
        
        while(i > 0 && v[i] > key){
            v[i+1] = v[i]; //左隣のほうが大きかった場合、左隣に現在の値を代入する
            i--;
        }
        v[i+1] = key;//whileから抜け出した場合、keyを代入する
        
        for(int j=1 ;j<v.size() ;j++){
            cout << (j==1?"":" ") << v[j];
        }
        cout << endl;
    }
}





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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) puts("Zero");
    else if (min(a, b) >= 0) puts("Positive");
    else if ((max(a, b) - min(a, b) + 1)%2) puts("Negative");
    else puts("Positive");
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
 
int main() {
	int number = 0;
	int train = 0;
	int taxi = 0;
 
	scanf("%d", &number);

	scanf("%d", &train);

	scanf("%d", &taxi);

 
	if (taxi > (number*train)) {
		printf("%d", (number*train));
	}
	else {
		printf("%d", taxi);
	}
 
 
	return 0;
}

Measured memory_bytes: 128
def resolve():
    n, m = map(int, input().split())
    arr = list(map(int, input().split()))
    lmt = sum(arr)*(1/(4*m))
    ans = []
    for i in arr:
        if i>=lmt:
            ans.append(i)
    if len(ans) >=m:
        print("Yes")
    else:
        print("No")

    
if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include <stdio.h>
#define NMAX 100001
#define qMAX 50000

int S[NMAX];
int T[qMAX];

int binarySearch(int n,int key) {
	int left = 0;
	int right = n;
	int mid;
	
	while (left < right) {
		mid = (left + right) / 2;
		if (S[mid] == key) {
			return 1;
		} else if (key < S[mid]) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	return 0;
}

int main(void)
{
	int n, i, j, q, cnt;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf(" %d", &S[i]);
	}

	scanf("%d", &q);
	for (i = 0; i < q; ++i) {
		scanf(" %d", &T[i]);
	}

	cnt = 0;
	for (i = 0; i < q; ++i) {
		cnt += binarySearch(n, T[i]);
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
#define MAX 100000
int parent(int i){ return i/2; }
int left(int i){ return 2*i; }
int right(int i){ return 2*i+1; }
int main(){
  int H,i,A[MAX+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H)printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1



Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
bool from[200000];
bool to[200000];
main(){
    int N,M,A,B;
    cin >> N >> M;
    for(int i = 0;i < M;i++){
        cin >> A >> B;
        A--;B--;
        if(A == 0 || B == 0)from[max(A,B)] = 1;
        if(A == N-1 || B == N-1)to[min(A,B)] = 1;
    }
    for(int i = 0;i < N;i++){
        if(from[i] && from[i] == to[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string a, b, c; cin >> a >> b >> c;

    if (a.back() == b.front() and b.back() == c.front()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main(){

    int N,D,X;
    cin >> N >> D >> X;
    int A[N];
    for(int i = 0;i<N;i++) cin >> A[i];

    int choco = X,d = D;

    for(int j = 0;j<N;j++){
        for(int i = D;i > 0;i -= A[j]) choco ++;
    }

    cout << choco << endl;
    

    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	int W,a,b; cin>>W>>a>>b;
	int ans=0;
	if(a<=b){
		ans = b - (a+W);
	}else{
		ans = a - (b+W);
	}

	if(ans<0){
		cout << 0 << endl;
	}else{
		cout << ans << endl;
	}
}


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

int main(){
    int n;
    cin >> n;
    vector <int> v;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    reverse(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        if (i == n-1) {
            cout << v[i] << endl;
        }
        else {
            cout << v[i] << " ";
        }
    }
}



Measured memory_bytes: 3088
n, k = map(int ,input().split(" "))

d = {}
for i in range(1, k+1):
    _ = input()
    A = map(int, input().split(" "))
    for a in A:
        tmp = d.get(a, [])
        tmp.append(i)
        d[a] = tmp

ans = 0
for i in range(1, n+1):
    if i not in d:
        ans = ans + 1

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
#define PI 3.14159265358979323846
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
using namespace std;

  
int main() {
  fast 
  string s;
  cin >> s;
  string s1 = "";
  string s2 = "";
  fr(i,0,s.size())
  {
       if(i%2==0)
       {
           pb(s1,'0');
           pb(s2,'1');
       }
       else
       {
           pb(s1,'1');
           pb(s2,'0');
       }
  } 
  ll cnt1=0;
  ll cnt2=0;
  fr(i,0,s.size())
  {
    if(s[i]!=s1[i])
    {
        cnt1++;
    }
    else
    {
        cnt2++;
    }
  }
  cout << min(cnt1,cnt2);
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int now = n;
    vector<int> ans;
    while (now != 0) {
        for (int i = max(0, now - m); i <= now; ++i) {
            if (i == now) {
                cout << -1 << endl;
                return;
            }
            if (s[i] == '1') continue;
            ans.eb(now - i);
            now = i;
            // cerr << i << endl;
            break;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
}


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

// 2つの整数の場合
long long GetGreatestCommonDivisor(long long a, long long b)
{
	long long m = a;
	long long n = b;
	long long temp;
	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main() {

    const int u = 1000005;
    ll n; cin >> n;
	vector<ll> c(u, 0);
	vector<ll> a(n);
    for (int i = 0; i < n; i++) {
		cin >> a[i];
		c[a[i]]++;
    }
	bool pairwise = true;
	for (int i = 2; i < u; i++) {
		int cnt = 0;
		for (int j = i; j < u; j += i) {
			cnt += c[j];
		}
		if (1 < cnt) {
			pairwise = false;
		}
	}
	if (pairwise) {
		cout << "pairwise coprime" << endl;
		return 0;
	}
	// 3つ以上の整数の場合
	long long gcd = a[0];
	for (int i = 1; i < n; i++) {
		gcd = GetGreatestCommonDivisor(gcd, a[i]);
	}
	if (gcd == 1) {
		cout << "setwise coprime" << endl;		
	}
	else {
		cout << "not coprime" << endl;
	}
    return 0;
}

Measured memory_bytes: 18744
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
  int i, j, n, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b);
  return 0;
}

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

using namespace std;

int main(){
	int n;
	string s;
	string ss;
	cin>>n;
	int j, c=0;
	cin>>s>>ss;
	for(int i=0;i<n;i++){
		if(s[i]==ss[0]){
			for(j=i;j<n;j++){
				if(s[j]==ss[j-i]) c++;
				else {
					c=0;
					break;
				}
			}
			if(j==n) break;
		}
	}
	cout<<2*n-c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using ll=long long int;

using P=std::pair<ll,ll>;

constexpr int MAX=2010;

int n;
P p[MAX];

ll dp[MAX][MAX];

int main() {

    std::cin>>n;

    for(int i=1;i<=n;++i){
        int a;
        std::cin>>a;
        p[i]=P(a,i);
    }

    std::sort(p+1,p+n+1,std::greater<>());

    for(ll i=1;i<=n;++i){
        dp[i][0]=dp[i-1][0]+p[i].first*(n+1-i-p[i].second);
        dp[0][i]=dp[0][i-1]+p[i].first*(p[i].second-i);
        //std::cerr<<dp[0][i]<<' ';
    }

    //std::cerr<<dp[1][0]<<' '<<dp[0][1]<<std::endl;

    for(ll i=1;i<=n-1;++i){
        for(ll j=1;j<=n-i;++j){
            dp[i][j]=std::max(dp[i-1][j]+p[i+j].first*(n+1-i-p[i+j].second),
                dp[i][j-1]+p[i+j].first*(p[i+j].second-j));
        }
    }

    std::cerr<<"DEBUG"<<std::endl;

    for(int i=0;i<n;++i)
        std::cerr<<dp[1][i]<<' ';
    std::cerr<<std::endl;

    ll ans=0;

    //std::cerr<<"DEBUG"<<std::endl;

    for(int i=0;i<=n;++i){
        ans=std::max(ans,dp[i][n-i]);
        //std::cerr<<dp[i][n-i]<<' ';
    }
    //std::cerr<<std::endl;

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 25872
// 2020-08-23 16:55:45
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll h, w, n;
  cin >> h >> w >> n;
  vector<ll> topleft;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    rep(i, 3) {
      ll na = a - i;
      if(0 <= na && na + 2 < h) {
        rep(j, 3) {
          ll nb = b - j;
          if(0 <= nb && nb + 2 < w) {
            topleft.push_back(na * w + nb);
          }
        }
      }
    }
  }
  sort(ALL(topleft));
  ll past = -1, cnt = 0;
  vector<ll> ans(10, 0);
  for(const auto c : topleft) {
    if(past < c) {
      if(cnt) ans[cnt]++;
      past = c;
      cnt = 1;
    } else {
      cnt++;
    }
  }
  ans[cnt]++;
  ans[0] = (h-2)*(w-2);
  REPC(i, 1, 9) ans[0] -= ans[i];
  rep(i, 10) cout << ans[i] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 11600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 998244353
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n;
int arr[100000+9];
ll dp[100000][2];
ll solve(int ind , int last) {
    if (ind+1 == n) {
        return 0;
    }
    if(dp[ind][last] != -1)
        return dp[ind][last];
    ll a = 1e10;
    if (ind + 1 < n)
        a = min(a, solve(ind + 1, 0) + abs(arr[ind] - arr[ind + 1]));
    if (ind + 2 < n) {
        a = min(a, solve(ind + 2, 1) + abs(arr[ind + 2] - arr[ind]));
    }
    return dp[ind][last] = a;
}
int main() {
    cin>>n;
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp,-1, sizeof(dp));
    cout<<solve(0,0);
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[3010][3010];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    string s; cin >> s;
    int rmax = -1; int curr = 0;
    int rsum = 0;
    dp[0][0] = 1;
    auto f = [&](void) {
        if (rmax < curr) {
            int x = s[curr] == '1';
            for (int i = 0; i <= n; i++) {
                dp[curr+1][i+x] = dp[curr][i];
            }
            rmax++, curr++; rsum += x;
        } else {
            for (int i = 0; i <= n; i++) {
                if (curr+1-(rmax+1-rsum) <= i+1 && i+1 <= rsum) {
                    dp[curr+1][i+1] += dp[curr][i];
                }
                if (curr+1-(rmax+1-rsum) <= i && i <= rsum) {
                    dp[curr+1][i] += dp[curr][i];
                }
                dp[curr+1][i] %= mod;
            }
            curr++;
        }
    };
    auto g = [&](int r) {
        while (rmax < r) {
            rmax++;
            rsum += s[rmax] == '1';
        }
    };
    map<int, int> c;
    for (int mi = 0; mi < m; mi++) {
        int l, r; cin >> l >> r; l--; r--;
        c[l] = max(c[l], r);
    }
    for (auto &iter: c) {
        int l = iter.first;
        int r = iter.second;
        while (curr < l) f();
        g(r);
    }
    while (curr < n) f();
    g(n);
    cout << dp[n][rsum] << "\n";
    return 0;
}

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


int main(){
  int N, Y;
  cin >> N;
  cin >> Y;
  int total = 0;
  for(int x = 0; x <= N; x++){
    for(int y = 0; y <= N-x; y++){
      	int z = N - x - y;
        total = x * 10000 + y * 5000 + z * 1000;
        if(total == Y && x + y + z == N) {
          cout << x << " " << y << " " << z << endl;
          return 0;
      }
    }    
  }
  
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector            as V
import           Data.Maybe
import           Text.Printf

main :: IO ()
main = do
  [a, b, t] <- map read . words <$> getLine
  print $ (t `div` a) * b


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int A, B, C; cin >> A >> B >> C;
    if (A + B + C >= 22) {
        cout << "bust\n";
    } else {
        cout << "win\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void dropink(int paper[10][10],int x, int y, int size)
{
	paper[x][y]++;
	if(x>0)paper[x-1][y]++;
	if(x<9)paper[x+1][y]++;
	if(y>0)paper[x][y-1]++;
	if(y<9)paper[x][y+1]++;

	if(size>1)
	{
		if(x>0&&y>0)paper[x-1][y-1]++;
		if(x<9&&y>0)paper[x+1][y-1]++;
		if(x>0&&y<9)paper[x-1][y+1]++;
		if(x<9&&y<9)paper[x+1][y+1]++;
	}
	if(size>2)
	{
		if(x>1)paper[x-2][y]++;
		if(x<8)paper[x+2][y]++;
		if(y>1)paper[x][y-2]++;
		if(y<8)paper[x][y+2]++;
	}
}

int main()
{
	int paper[10][10];
	int x,y,size,count=0,max=0;
	
	for(y=0;y<10;y++)
	{
		for(x=0;x<10;x++)
		{
			paper[x][y]=0;
		}
	}
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF)
	{
		dropink(paper,x,y,size);
	}

	for(y=0;y<10;y++)
	{
		for(x=0;x<10;x++)
		{
			if(paper[x][y]==0)
			{
				count++;
			}
			else
			{
				if(paper[x][y]>max)
				{
					max=paper[x][y];
				}
			}
		}
	}
	
	printf("%d\n%d\n",count,max);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
string N,Z;
int M;
getline(cin,N);
char c=' ';
for(int i=0;i<N.length();i++){
	if(i==0){
	N[i]=toupper(N[i]);
	M=1;
	cout<<N[i];}
	if(M==1){
		break;
	}
}
	for(int i=0;i<N.length();i++){
	if(N[i]==c){
	N[i+1]=toupper(N[i+1]);
cout<<N[i+1];}
}
}

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

using namespace std;

#define BUF_SIZE 1024

struct Node{
    int data;
    Node* prev;
    Node* next;
};

class ConnectedList{
public:
    ConnectedList(){
        motherNode = new Node();
        motherNode->data = -1;
        motherNode->prev = motherNode;
        motherNode->next = motherNode;
    };
    ~ConnectedList(){
        Node* tmpNode = motherNode->next;
        Node* nextNode;
        while(tmpNode != motherNode){
            nextNode = tmpNode->next;
            delete tmpNode;
            tmpNode = nextNode;
        }
        delete motherNode;
    };
    void insertNode(int x){
        Node* tmpNode = motherNode->next;
        motherNode->next = new Node();
        motherNode->next->data = x;
        motherNode->next->next = tmpNode;
        motherNode->next->prev = motherNode;
        tmpNode->prev = motherNode->next;
    };
    void deleteNode(int x){
        Node* tmpNode = motherNode->next;
        while(tmpNode != motherNode && tmpNode->data != x){
            tmpNode = tmpNode->next;
        }
        if(tmpNode != motherNode){
            tmpNode->prev->next = tmpNode->next;
            tmpNode->next->prev = tmpNode->prev;
            delete tmpNode;
        }
    };

    void deleteFirst(){
        Node* tmpNode = motherNode->next;
        motherNode->next = motherNode->next->next;
        motherNode->next->prev = motherNode;
        delete tmpNode;
    };

    void deleteLast(){
        Node* tmpNode = motherNode->prev;
        motherNode->prev = motherNode->prev->prev;
        motherNode->prev->next = motherNode;
        delete tmpNode;
    };

    void showList(){
        Node* tmpNode = motherNode->next;
        printf("%d",tmpNode->data);
        tmpNode = tmpNode->next;
        while(tmpNode != motherNode){
            printf(" %d",tmpNode->data);
            tmpNode = tmpNode->next;
        }
        printf("\n");
    }

private:
    Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));

    ConnectedList list;

    for(int i = 0; i < n; i++){

        buf[0] = '\0';
        fgets(buf,BUF_SIZE,stdin);

        if(buf[6] == 'F'){
            list.deleteFirst();
        }else if(buf[6] == 'L'){
            list.deleteLast();
        }else{
            int S = 0;

            if(buf[0] == 'i'){

                for(int i = 0; buf[i] != '\0';i++){
                    if(buf[i] >= '0' && buf[i] <= '9'){
                        S = 10*S + (buf[i] - '0');
                    }
                }
                list.insertNode(S);
            }else{
                for(int i = 0;buf[i] != '\0';i++){
                    if(buf[i] >= '0' && buf[i] <= '9'){
                        S = 10*S + (buf[i] - '0');
                    }
                }
                list.deleteNode(S);
            }
        }
    }
    list.showList();
}

Measured memory_bytes: 32404
#include <iostream>
#include <cmath>
#include <stack>

using namespace std;

struct rectangle { int height, pos; };

int main()
{
    int H,W;
    while(cin >> H >> W && H) {
        char f[H][W];
        for(int i = 0; i < H; i++) 
            for(int j = 0; j < W; j++) 
                cin >> f[i][j];

        //init
        int dp[H+1][W+1];
        for(int j = 0; j < W; j++) 
            dp[0][j] = (f[0][j] == '*') ? 0 : 1;
        
        //create histgram
        for(int j = 0; j < W; j++) 
            for(int i = 1; i < H; i++) 
                dp[i][j] = (f[i][j] == '*') ? 0 : dp[i-1][j] + 1;

        //search histgram
        int ans = 0;
        for(int i = 0; i < H; i++) {
            stack<rectangle> stk;
            dp[i][W] = 0;
            for(int j = 0; j <= W; j++) {
                int height = dp[i][j], pos = j;
                if(stk.empty()) {
                    stk.push((rectangle){height, pos});
                } else {
                    if(stk.top().height < height) {
                        stk.push((rectangle){height, pos});
                    } else {
                        rectangle r;
                        do {
                            r = stk.top();
                            stk.pop();
                            ans = max(ans, (pos - r.pos) * r.height);
                        } while(!stk.empty() && stk.top().height >= height);
                        stk.push((rectangle){height, r.pos});
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2132
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(unused_variables)]

use proconio::{input, fastout};
use std::cmp::{max, min};

#[fastout]
fn main() {
  input! {
    n: i32,
    a: i32,
    b: i32,
    s: String,
  }
  let mut x = 0;
  let mut y = 0;
  for c in s.chars() {
    if c == 'a' {
      if x < a + b {
        println!("Yes");
        x += 1;
      } else {
        println!("No");
      }
    } else if c == 'b' {
      if x < a + b && y < b {
        println!("Yes");
        x += 1;
        y += 1;
      } else {
        println!("No");
      }
    } else {
      println!("No");
    }
  }
}


Measured memory_bytes: 2396
#include<iostream>
using namespace std;
int main(){
	int n,i,j,a[100005],x,y,s=0;
	cin>>n;
	for(i=1;i<=100000;i++)a[i]=0;
	for(i=1;i<=n;i++){
		cin>>x>>y;
		for(j=x;j<=y;j++){
			a[j]=1;
		}
	}
	for(i=1;i<=100000;i++){
		if(a[i]==1)s=s+1;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
int main(){
    string S;
    int flag=0;

    cin>>S;
    double N;
    N=S.length();

    string Nb,Na;
    for (double i = 0; i < (N-1)/2; i++)
    {
        
        if(S[i]!=S[N-i-1]){
            flag=1;
            break;

        }
    }
    Nb=S.substr(0,(N-1)/2);
    
    
    Na=S.substr((N-1)/2+1);
    
    N=Nb.length();

    for (double i = 0; i < (N-1)/2; i++)
    {
        
        if(Nb[i]!=Nb[N-i-1]){
            flag=1;
            break;

        }
    }
    

    N=Na.length();

    for (double i = 0; i < (N-1)/2; i++)
    {
        
        if(Na[i]!=Na[N-i-1]){
            flag=1;
            break;

        }
    }
    if (flag==1)
    {
            cout<<"No";
    }else if (flag==0)
    {
        cout<<"Yes";
    }
    
    


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

























int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    REP(i, n){
        cin >> v[i];
    }
    ll ans = 0;
    for(ll i = 1; i <= k; i++){
        for(ll j = 0; j <= i; j++){
            for(ll l = 0; l <= i - j; l++){
                ll sum = 0;
                priority_queue<ll, vector<ll>, greater<ll>> que;
                for(ll m = 0; m < min(j, n); m++){
                    sum += v[m];
                    que.push(v[m]);
                }
                for(ll m = n - 1; m >= max(n - l, min(j, n)); m--){
                    sum += v[m];
                    que.push(v[m]);
                }
                ll c = 0;
                while(c < i - j - l && !que.empty() && que.top() < 0){
                    sum -= que.top();
                    que.pop();
                    c++;
                }
                // cerr << i << " " << j << " " << l << " " << ans << endl;
                ans = max(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

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

const int mod=1e9+7;

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

int re[10000][10000]={0};

int calc(int n,int m){
	if(m==0||m==n)	
		return 1;
	if(re[n][m]!=0)
		return re[n][m];
	return re[n][m]=calc(n-1,m)+calc(n-1,m-1)%mod;
}

signed main(){
	int s=read();
	int res=0;
	for(int i=1;i<=s/3;i++){
		res+=calc(s-2*i-1,i-1);
		res%=mod;
	}
	
	res%=mod;
	
	writeln(res);
}

Measured memory_bytes: 16664
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

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

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int m = 10 * (S[5] - '0');
	m += (S[6] - '0');
	//cerr << m << endl;
	if (m <= 4) {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2;
int a[16][16] = {};
int b[200010] = {};
VVI g(100010);
queue<int> que2;
int x[1<<16]={};
int dp[1<<16];
string s;

template<typename T>
struct Combination
{
    typedef std::vector<T>           source_type;
    typedef std::vector<source_type> values_type;

    Combination(const source_type& source, int n)
    {
        std::vector<int> v(n);
        combination(0, source.size(), n, source, 0, v);
    }

     values_type values;

private:
    void combination(int begin, int size, int n, const source_type& source, int index, std::vector<int>& v)
    {
        if(n == 0)
        {
            v[index] = begin;

            source_type subset;
            for(std::vector<int>::iterator i = v.begin(); i != v.end(); ++i)
            {
                subset.push_back(source[*i]);
            }
            values.push_back(subset);
        }
        else
        {
            for(int i = 0; i < size - n + 1; ++i)
            {
                v[index] = begin + i;
                combination(begin + i + 1, size - i - 1, n - 1, source, index + 1, v);
            }
        }
    }
};

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>n;
	rep(i,0,n){
		rep(j,0,n){
			cin>>a[i][j];
		}
	}
	rep(i,0,1<<n){
		VI vec;
		rep(j,0,n){
			if (i&1<<j) vec.pb(j);
		}
		rep(j,0,n){
			if (i&1<<j) continue;
			tmp = 0;
			for(int k : vec){
				tmp += a[j][k];
			}
			x[i|1<<j] = x[i] + tmp;
		}
	}
	rep(i,0,1<<n)dp[i] = -(1<<30);
	dp[0] = 0;
	rep(i,0,n)dp[1<<i] = 0;
	rep(i,0,1<<n){
		VI vec;
		tmp2 = 0;
		if (i == 0){
			tmp2 = 0;
		}
		else{
			rep(j,0,n){
				if ((i & 1<<j)==0){
					tmp2 += 1<<j;
				}
				else break;
			}
		}
		i+=tmp2;
		tmp = 0;
		rep(j,0,n){
			if (i&1<<j) {
				continue;
			}
			else tmp+=1<<j;
		}
		i-=tmp2;
	 for (int t = tmp; t != 0; t = (t-1)&tmp){
		 dp[i|t] = max(dp[i|t],dp[i]+x[t]);
	 }
	}
	cout<< dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 3712
def main():
  N, W = list(map(int, input().split()))
  Data = []
  for i in range(N):
    Data.append(list(map(int, input().split())))
  
  DP = [0 for i in range(W+1)]
  
  for i in range(N):
    for j in range(W - Data[i][0], -1, -1):
      k = j + Data[i][0]
      DP[k] = max(DP[j] + Data[i][1], DP[k])
  
  print(DP[-1])
  
main()


Measured memory_bytes: 45296
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

ll lcm(ll a, ll b){
    return a*b/gcd(a,b);
}


char li[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

char bin_six(string bin){
    reverse(bin.begin(),bin.end());
    int tmp = 0;
    for(int i = 0; i < 4; i++){
        if(bin[i] == '1'){
            tmp += pow(2,i);
        }
    }
    return li[int(tmp)];
}

int main() {
	int n,k;
    cin >> n >> k;
    int ans = 0;
    while(n != 0){
        n = n / k;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x, y, tmp, tmp2;
    cin >> x >> y;
    tmp = 4 * x - y;
    tmp2 = y - 2 * x;
    if (tmp % 2 == 0 && tmp2 % 2 == 0 && tmp >= 0 && tmp2 >=0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
    n:u64,
    x:u64,
    t:u64
  }
  println!("{}",((n+x-1)/x)*t);
}


Measured memory_bytes: 2152
from collections import defaultdict
from itertools import accumulate

n, m = map(int, input().split())
aa = list(map(int, input().split()))
counter = defaultdict(list)

cum = [0] * (m + 2)
ans_1 = 0
for a, b in zip(aa, aa[1:]):
    counter[b].append(a)
    cum[a + 1] += 1
    cum[b] += -1
    if a > b:
        cum[1] += 1
        ans_1 += b
    else:
        ans_1 += b - a

cum = list(accumulate(cum))

ans_prev = ans_1
ans_min = ans_1
for x in range(1, m):
    ans_x = ans_prev
    if x in counter:
        ans_x += sum((x - a) % m - 1 for a in counter[x])
    ans_x -= cum[x]
    ans_min = min(ans_min, ans_x)
    ans_prev = ans_x
print(ans_min)


Measured memory_bytes: 24160
#include <stdio.h>

void erase(int *a, int idx, int n) {
  for (int i = idx; i + 1 < n; i++) {
    a[i] = a[i + 1];
  }
}

void rev(int *a, int n) {
  for (int i = 0; i < n - 1 - i; i++) {
    int t = a[i];
    a[i] = a[n - 1 - i];
    a[n - 1 - i] = t;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int ans[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    a[i]--;
  }
  int del = 0;
  while (del < n) {
    bool f = false;
    for (int i = n - 1 - del; i >= 0; i--) {
      if (a[i] == i) {
        del++;
        erase(a, i, n);
        ans[del - 1] = i + 1;
        f = true;
        break;
      }
    }
    if (!f) {
      puts("-1");
      return 0;
    }
  }
  rev(ans, n);
  for (int i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 128