akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << 
 << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

int main() {
    LL x;
    cin >> x;
    auto ans = x / 11 * 2;
    x %= 11;
    if (x == 0) cout << ans << endl;
    else if (x <= 6) cout << ans + 1 << endl;
    else cout << ans + 2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const lint di[]{0, -1, 0, 1, -1, -1, 1, 1};
const lint dj[]{1, 0, -1, 0, 1, -1, -1, 1};

void solve(lint h, lint w, lint k){
    lint dp[h+1][w];
    for (int i=0; i<=h; ++i){
        for (int j=0; j<w; ++j){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    int n = 1;
    for (int i=1; i<w; ++i){
        n *= 2;
    }
    bitset<8> b;
    bool isValid = true;
    for (int i=0; i<h; ++i){
        for (int j=0; j<w; ++j){
            for (int k=0; k<n; ++k){
                isValid = true;
                b = static_cast<bitset<8>>(k);
                for (int l=0; l<7; ++l){
                    if(b[l] == 1 && b[l+1] == 1){
                        isValid = false;
                        break;
                    }
                }
                if(!isValid){
                    continue;
                }
                // left
                if(j - 1 >= 0 && b[j - 1] == 1){
                    dp[i + 1][j - 1] += dp[i][j];
                    dp[i + 1][j - 1] = dp[i + 1][j - 1] % MOD;
                }
                // right
                else if(j + 1 < w && b[j] == 1){
                    dp[i + 1][j + 1] += dp[i][j];
                    dp[i + 1][j + 1] = dp[i + 1][j + 1] % MOD;
                }
                // down
                else {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] = dp[i + 1][j] % MOD;
                }
            }
        }
    }
    cout << dp[h][k] << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint h, w, k;
    cin >> h >> w >> k;
    k--;
    solve(h, w, k);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vvl e(n);
    vector<pll> edge;
    map<pll,ll> ans;
    rep(i,n-1){
        ll a,b;cin>>a>>b;a--;b--;
        e[a].push_back(b);
        e[b].push_back(a);
        if(a>b)swap(a,b);
        edge.emplace_back(a,b);
    }
    ll k=0;
    rep(i,n)chmax(k,(ll)e[i].size());
    queue<pll> q;
    q.emplace(0,0);
    vb v(n,false);
    while(!q.empty()){
        ll p,c;tie(p,c)=q.front();q.pop();
        if(v[p])continue;
        v[p]=true;
        ll nc=1;
        for(auto&nxt:e[p]){
            if(c==nc)nc++;
            if(!v[nxt]){
                q.emplace(nxt,nc);
                ans[make_pair(p,nxt)]=nc;
                ans[make_pair(nxt,p)]=nc;
                nc++;
            }
        }
    }
    puta(k);
    rep(i,n-1){
        puta(ans[edge[i]]);
    }
    return 0;
}

Measured memory_bytes: 20720
#include <iostream>
using namespace std;
 
int D = 100000;
int dp[2][50][3001];
int n, m, s;
 
void set(){
    int x, y, z;
    for(x = 0; x < 2; x++){
        for(y = 0; y <= n*n; y++){
            for(z = 0; z <= s; z++){
                dp[x][y][z] = 0;
            }
        }
    }
    dp[0][0][0] = 1;
    for(y = 1; y <= m; y++){
        for(x = 0; x <= n*n; x++){
            for(z = 0; z <= s; z++){
                if(x && z >= y){
                    dp[y%2][x][z]
                        = (dp[(y-1)%2][x][z]+dp[(y-1)%2][x-1][z-y]);
                }else{
                    dp[y%2][x][z] = dp[(y-1)%2][x][z];
                }
                dp[y%2][x][z] %= D;
            }
        }
    }
}
 
int main(){
    while( cin >> n >> m >> s, n|m|s ){
        set();
        cout << dp[m%2][n*n][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 2332
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
    string S;
    cin >> S;
    int stock_g = 0;
    int stock_p = 0;
    int score = 0;
    for (int i=0;i<S.size();i++){
        if (S[i] == 'g') stock_g++;
        if (S[i] == 'p') stock_p++;
    }

    score = max(0,(stock_g-stock_p)/2);
    cout << score << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

    vector<pair<ll , ll>> A;
    for(ll i=0;i<N;i++)
    {
        ll temp;
        cin >> temp;

        A.push_back(pair<ll,ll>(i+1,temp));
    }
    
    sort(A.begin(),A.end(), compare_by_b);

    for(ll i=0;i<N;i++)
    {
        cout << A[i].first << " ";
    }
    cout << endl;
    
    
    return 0;
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#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 fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head


void solve(){
    int n;
    cin >> n;
    cout << n*n << '\n';
}

int main(void){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9;
#define LINF = 1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

void input(vector<int> x, auto n){
   rep(i,n)cin >> x[i];
}

int main(){

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

   if(n >= k)n %= k;

   cout << (k-n < n ? k-n : n) << endl;

 }

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int a[3];
int ans;
int main()
{
  cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  int plu=a[2]-a[1];
  a[0]+=plu;
  a[1]+=plu;
  ans+=plu;
  plu=a[2]-a[0];
  if(plu%2)
  {
    a[1]++;
    a[2]++;
    plu++;
    ans+=plu/2+1;
  }
  else
    ans+=plu/2;
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    int x;
    cin>>x;
    if(x>=400&&x<=599)
        cout<<8<<endl;
    else if(x>=600&&x<=799)
        cout<<7<<endl;
    else if(x>=800&&x<=999)
        cout<<6<<endl;
    else if(x>=1000&&x<=1199)
        cout<<5<<endl;
    else if(x>=1200&&x<=1399)
        cout<<4<<endl;
    else if(x>=1400&&x<=1599)
        cout<<3<<endl;
    else if(x>=1600&&x<=1799)
        cout<<2<<endl;
    else if(x>=1800&&x<=1999)
        cout<<1<<endl;

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;
string t;
bool a[100010], b[100010];

void g() {
	int i;
	for (i = 0; i < n; i++) printf("%c", b[i] ? 'W' : 'S');
	printf("\n");
	exit(0);
}

void f() {
	int i;
	for (i = 2; i <= n + 1; i++) b[i] = b[i - 2] ^ b[i - 1] ^ a[i - 1];
	if (b[0] == b[n] && b[1] == b[n + 1]) g();
}

int main() {
	cin >> n >> t;
	rep(i,n) a[i] = (t[i]=='x');
	a[n] = a[0];
	
	// 連続する2匹の動物がそれぞれ何なのかさえわかればあとは連鎖して他の動物も全部わかる
	// 具体的にはi番目が羊でi+1番目が狼ってわかってたとすると、i+1が○ならそれは嘘なのでi+2は狼、とか
	// だから1番目と2番目の動物を仮に決めちゃってsに矛盾するかどうかを調べればいい
	b[0] = 0, b[1] = 0; f();
	b[0] = 0, b[1] = 1; f();
	b[0] = 1, b[1] = 0; f();
	b[0] = 1, b[1] = 1; f();
	cout << -1 << ln;
}

Measured memory_bytes: 720
#include <stdio.h>




int array[200000];
int tail = 0;

void pushBack(int x);
int randomAccess(int y);
void popBack(void);

void pushBack(int x) {
	array[tail] = x;
	tail++;
}
int randomAccess(int y) {
	int z;
	z = array[y];
	return z;
}

void popBack(void) {
	tail--;
}

int main(void) {

	int n, query, number, suuji;

	scanf("%d", &n);

	while (n--) {
		scanf("%d", &query);

		if (query == 0) {
			scanf("%d", &number);
			pushBack(number);
		}
		else if (query == 2) {
			popBack();
		}
		else {
			scanf("%d", &number);
			suuji = randomAccess(number);
			printf("%d\n", suuji);
		}
	}
	return 0;
}


Measured memory_bytes: 2568
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main () {
    char a[20], b[20], c[20];
    scanf("%s%s%s", a, b, c);
    
    if (a[strlen(a) - 1] == b[0] && c[0] == b[strlen(b) - 1])
        printf("YES");
    else
        printf("NO");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  cout << min(n % k, k - n % k) << endl;
}

Measured memory_bytes: 3580
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

MOD = 10**9+7
i2 = (MOD+1)//2


r = sum(a)
r *= r
r -= sum(i*i for i in a)

r *= i2
print(r%MOD)




Measured memory_bytes: 31212
#include <stdio.h>

int main(int argc, char** argv)
{
  unsigned long long n, a, b;
  scanf("%Lu%Lu%Lu", &n, &a, &b);
  n = (n/(a+b))*a + ( (n%(a+b)<a)?(n%(a+b)):(a) );
  printf("%llu\n", n);
  return 0;
}



Measured memory_bytes: 128
n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
for i in range(k):
    ans += (p[i]+1)/2

tmp = ans
for i in range(k, n):
    tmp = tmp + (p[i]+1)/2 - (p[i-k]+1)/2
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 25060
#!/usr/bin/env python3
import sys
import collections


def solve(N: int, S: "List[str]"):
    c = collections.Counter(S)
    values, counts = zip(*c.most_common())

    max_value = counts[0]
    result_index = 0
    for count in counts[1:]:
        if count == max_value:
            result_index += 1
        else:
            pass
    results = sorted(values[: result_index + 1])
    for result in results:
        print(result)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 59536
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin >> a;
    if((a[0]==a[1] && a[1]==a[2]) || (a[1]==a[2] && a[2]==a[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<stack>
#include<vector>
#include<cmath>
using namespace std;

int a[100000];
int l[100000];
int r[100000];

int main(){
	long long ans = 1,sum = 0,n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		if(a[i] % 2 == 0) ans *= 2;
		else ans *= 1;
	}
	sum = pow(3,n) - ans;
	cout << sum;
}

Measured memory_bytes: 640
/*____________________________Definitions__________________________*/
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
#define Rep(i, a, b) for (int i=a; i<(b); i++)
#define trav(a,x) for(auto& a : x)
#define nl '\n'
#define ri(n) int n; scanf("%d", &n);
#define rll(n) ll n; scanf("%lld", &n);
/*__________________________________________________________________*/


int main() {

	fastIO
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T = 1;
	while (T--) {
		/*_____________________Code Here____________________________*/
		int n ; cin >> n;
		vector<ll> v;
		for (int i = 0 ; i < n ; i++) {
			ll t ; cin >> t ;
			v.push_back(t);
		}
		int count = 0;
		sort(v.begin() , v.end());
		for (int i = 0; i < n; i++)
		{
			for (int j = i + 1 ; j < n; j++)
			{
				for (int k = j + 1 ; k < n ; k++)
				{

					if (v[i] != v[j] && v[j] != v[k] && v[k] != v[i]) {

						if (v[i] + v[j] > v[k] ) {

							count++;
						}

					}
				}
			}
		}



		cout << count << nl;




		/*_____________________End Here____________________________*/
	}
	return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <cmath>
using namespace std;
long long int comb[100][100], pow2[100];
int main(int argc, char const *argv[])
{
	int n,p;
	cin>>n>>p;
	int oddctr = 0, evenctr = 0;
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin>>x;
		if(x%2)
			oddctr++;
		else
			evenctr++;
	}
	comb[0][0] = 1;
	pow2[0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		pow2[i] = pow2[i-1]*2;
		for (int j = 0; j <= i; ++j)
		{
			comb[i][j] = comb[i-1][j];
			if(j)
				comb[i][j]+=comb[i-1][j-1];
		}
	}
	long long int v1 = pow2[evenctr], v2 = 0;
	for (int i = 0; i <= oddctr; i+=2)
	{
		v2+=comb[oddctr][i];
	}
	long long int ans = v1*v2;
	if(p)
		ans = pow2[n] - ans;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
point = b[a[0]-1]
for i in range(1, n):
    point += b[a[i]-1]
    if a[i] - a[i-1] == 1:
        point += c[a[i-1]-1]

print(point)

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    boolean flag = false;
    for (int i=1; i<10; i++){
      if(N%i == 0 && N/i < 10){
        flag = true;
        break;
      }
    }

    if (flag)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 22868
N = gets.to_i
if N > 99 && N < 112
 puts(111)
end
if N > 888 && N < 1000
puts(999)
end
for n in 1..7
  if N > 111*n && N < 223+111*(n-1)
   puts(111*(n+1))
  end
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] V = new int[N];
            int[] C = new int[N];
            for (int i = 0; i < N; i++) {
                V[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                C[i] = in.nextInt();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                if (V[i] > C[i]) {
                    sum += V[i] - C[i];
                }
            }
            System.out.println(sum);
        }
    }

}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> ans(N);
  
  for (int i = 0; i < M; i++) {
   vector<int> vec(2);
    for (int j = 0; j < 2; j++) {
     cin >> vec.at(j);
    }
    
      for (int k = 0; k < N; k++) {
       if (vec.at(0) == k+1) {
        ans.at(k)++; 
       }
       if (vec.at(1) == k+1) {
        ans.at(k)++; 
       }
      }
  }
  
  for (int k = 0; k < N; k++) {  
    cout << ans.at(k) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int n,m,C,S,T,p[21],q[21][51],r[21][51];
int G[20][101][101];

int calc(int c,int D){
  int res=0;
  for(int i=1;i<p[c]&&D;i++){
    int d=min(D,q[c][i]-q[c][i-1]);
    D-=d;
    res+=d*r[c][i-1];
  }
  if(D) res+=D*r[c][p[c]-1];
  return res;
}

int dijkstra(){
  int D[101];
  for(int i=0;i<101;i++) D[i]=1e9;
  priority_queue<P,vector<P>,greater<P> > Q;
  Q.push(P(0,S));
  D[S]=0;
  while(!Q.empty()){
    P t=Q.top();Q.pop();
    int pos=t.second,cost=t.first;
    if(pos==T)return cost;
    if(D[pos]<cost)continue;
    
    for(int c=0;c<C;c++)
      for(int i=0;i<n;i++){
	if(G[c][pos][i]==1e9)continue;
	int ncost=cost+calc(c,G[c][pos][i]);
	if(D[i]>ncost)D[i]=ncost,Q.push(P(ncost,i));
      }
  }
  return -1;
}

void WF(){
  for(int c=0;c<C;c++)
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  G[c][i][j]=min(G[c][i][j],G[c][i][k]+G[c][k][j]);
}

int main(){
  while(1){
  cin>>n>>m>>C>>S>>T;
  S--,T--;
  if(!n)break;
  
  fill(G[0][0],G[0][0]+sizeof(G)/sizeof(int),1e9);
  
  for(int i=0,a,b,d,c;i<m;i++){
    cin>>a>>b>>d>>c; a--,b--,c--;
    G[c][a][b]=G[c][b][a]=min(G[c][a][b],d);
  }

  for(int i=0;i<C;i++) cin>>p[i];
  for(int i=0;i<C;i++){
    for(int j=1;j<p[i];j++)cin>>q[i][j];    
    for(int j=0;j<p[i];j++)cin>>r[i][j];
  }

  WF();
  cout<<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, c;
	scanf("%d%d%d%s", &a, &b, &c);
  if(c-a+b>0){
	printf("%d\n", c-a+b);
  }else{
    printf("%d\n", 0);
  }
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>

bool findPrimeNum(int n){
  for(int i=2;i*i<=n;i++)
    if(n%i==0) return false;

  if( n!=1 ) return true; 
}
int main(){
   
  int n,cnt=0;
  scanf("%d",&n);
  int data;
  for(int i=0;i<n;i++){
    scanf("%d",&data);
    if(findPrimeNum(data)==true)cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

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

int f(int n){
   if(n < 10)  return n;
   return f(n/10) + n%10;
}

int main(void){
    
    int N;
    cin >> N;
    if(N % f(N) == 0) cout << "Yes" << endl;
    else cout << "No" <<endl;
}


Measured memory_bytes: 3556
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long n;
  cin >> n;
  vector<long> a(n);
  rep (i, n) cin >> a[i];
  long i = n-1;
  bool flag = false;
  while (i >= 0) {
    if (flag) cout << " ";
    flag = true;
    cout << a[i];
    i -= 2;
  }
  if (i == -2) i = 1;
  else i = 0;
  while (i < n) {
    if (flag) cout << " ";
    flag = true;
    cout << a[i];
    i += 2;
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<ll,ll> P; // a¥ b本
int main(){

	// 安い順に買う
	ll n,m;
	cin >> n>>m;
	vector<P> v;
	for (ll i=0; i<n;i++) {
		ll ina,inb;
		cin >> ina>>inb;
		v.push_back(P(ina,inb));
	}

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

	// rep(i,(int)v.size()) {
	// 	cout << v[i].first << " " << v[i].second <<endl;
	// }

	ll ans = 0;
	for (ll i=0; i<(ll)v.size(); i++) {
		while(m>0 && v[i].second>0) {
			v[i].second--;
			ans+=v[i].first;
			m--;
		}
	}

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

Measured memory_bytes: 2420
from __future__ import print_function
import sys

officalhouse = [0]*4*3*10

n = int( sys.stdin.readline() )
for i in range( n ):
	b, f, r, v = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	bfr = (b-1)*30+(f-1)*10+(r-1)
	officalhouse[bfr] = officalhouse[bfr] + v;
	
output = []
for b in range( 4 ):
	for f in range( 3 ):
		for r in range( 10 ):
			output.append( " {:d}".format( officalhouse[ b*30 + f*10 + r ] ) )
		output.append( "\n" )
	if b < 3:
		output.append( "####################\n" )

print( "".join( output ), end="" )

Measured memory_bytes: 4248
#include <stdio.h>
int main(void){
    int i, n, b, f, r, v;
    int count[4][3][10] = {0}; //棟,階,室
    
    scanf("%d\n", &n);
    for(i=0; i<n; i++) {
        scanf("%d %d %d %d\n", &b, &f, &r, &v); //b棟f階r室にv人入居
        count[b-1][f-1][r-1] += v;
    }
    
    for(b=1; b<=4; b++) {
        for(f=1; f<=3; f++) {
            for(r=1; r<=10; r++) {
                printf(" %d", count[b-1][f-1][r-1]);
            }
            printf("\n");
        }
        if(b != 4) printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 2036
#include<iostream>
using namespace std;
int GCD(int a,int b);
int main(){
  int k;
  long long sum=0;
  cin>>k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
	sum+=GCD(i,GCD(j,l));
      }
    }
  }
  
  cout<<sum<<endl;
  return(0);
}

int GCD(int a,int b){
  int temp;
  while(b!=0){
    temp=a%b;
    a=b;
    b=temp;
  }
  return(a);
}


Measured memory_bytes: 3636
/*SorooshH*/
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> tpi;
typedef pair<pii,pii> qpi;
const int MAX = 1e5;
const int MV = 1e5;
const int MOD = 1e9 + 7;
const int INF = 2e9;
ll MA = -INF , MI = INF , ANS;

ll n , k , m;
ll a , b , c , d;
int32_t main()
{
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n >> k;

    if( k == 0 )
        return cout << n*n , 0;

    for(ll i=k+1 ; i<=n ; i++)
    {
        ANS += (i-1) - (k-1);
        m = n-i+1;
        a = m/i;
        b = i-k;
        c = m - (a*i);
        d = max(0ll,c-k);
        ANS += d + (a*b);
    }

    cout << ANS << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i;
char c[5];
int main(){
	for(i=1;i<=3;i++){
	    scanf("%c",&c[i]);
	}
	if(c[2]=='B') printf("ARC");
	else printf("ABC");
	return 0; 
} 

Measured memory_bytes: 3724
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n, m;
    scan(n, m);
    auto a = iota(n).map!(i => readln.split.map!(x => x.to!int - 1).array).array;

    auto closed = new bool[](m);

    int ans = n;

    foreach (k ; 0 .. m) {
        auto cnt = new int[](m);
        int tmp;

        foreach (i ; 0 .. n) {
            while (!a[i].empty && closed[a[i].front]) {
                a[i].popFront();
            }
            cnt[a[i].front]++;
            tmp = max(tmp, cnt[a[i].front]);
        }

        ans = min(ans, tmp);

        foreach (i ; 0 .. m) {
            if (cnt[i] == tmp) {
                closed[i] = true;
                break;
            }
        }

        debug {
            writeln(closed);
        }
    }

    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if(s == "AC"){
        ac++;
    } else if(s == "WA") {
        wa++;
    } else if(s == "TLE") {
        tle++;
    }else if(s == "RE"){
        re++;
    }
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}

Measured memory_bytes: 3624
N = int(input())
ans = []
while N is not 0:
	ans.append(abs(N % (-2)))
	if N % (-2) == 0: N //= (-2)
	else: N = N // (-2) + 1

if ans == []:
	print(0)
else:
	ans.reverse()
	ans = list(map(str, ans))
	print(''.join(ans))

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const int MAXN = 3e6 + 123;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    int n;
    cin >> n;
    cout << (n * (n + 1)) / 2;
}

// ."ww"w"".ww"""...ww"".

int main(){
    //freopen("lepus.in","r",stdin);
    //freopen("lepus.out","w",stdout);
    //faster();
    int n=1;
    //cin>>n;
    while(n--){
    solve();
    //cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class _Class
{
	void b(int[] S)
	{
		for (int i = 0; i < S.Length; i++) {
			if (S[i] == 1)
				Console.WriteLine("Yes");
			else
				Console.WriteLine("No"); 
		}
	}

	void _()
	{
		var _NAB = _Ns();
		var S = _Ss()[0];

		var a = new int[S.Length];
		int c1= 0;
		int c2 = 0;

		for (int i = 0; i < S.Length; i++)
		{
			if (c1==_NAB[1]&&c2==_NAB[2])
				break;

			if (S[i] == 'c')
				continue;
	
			if(a[i]==1)
				continue;

			//
			if (S[i] == 'a')
			{
				if (c1 < _NAB[1])
					c1++;
				else if (c2 < _NAB[2])
					c2++;
				else
					break;
			}

			else if (S[i] == 'b')
			{
				if (c2 < _NAB[2])
					c2++;
				else
					continue;
			}

			a[i] = 1;
		}

		b(a);
			
		

	}

	static void Main(string[] args)
  {
    new _Class()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}



Measured memory_bytes: 8152
import math

NN = 2020202
MOD = 10**9+7
INF = float("inf")


a, b = map(int, input().split())
low = max(a/0.08, b/0.1)
high = min((a+1)/0.08, (b+1)/0.1)

price = math.ceil(low)

# print(a/0.08, b/0.1, (a+1)/0.08, (b+1)/0.1, price)
if price >= high:
    print(-1)
else:
    print(price)

Measured memory_bytes: 39888
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    int roop;
    int t=0,x,y;
    int now_t=0,now_x=0,now_y=0;
    int dif_t,dif_x,dif_y;
    int dist;
    cin >> roop;
    for(int i=0;i<roop;i++){
        cin >> t >> x >> y;
        dif_t = t-now_t;
        dif_x = abs(x-now_x);
        dif_y = abs(y-now_y);
        dist = dif_x+dif_y;
        if(dif_t<dist){
            cout << "No" << endl;
            //cerr << "over:" << dist << " " << dif_t;
            return 0;
        }else if(abs(dif_t-dist)%2==1){
            cout << "No" << endl;
            //cerr << "impossible";
            return 0;
        }else{
            now_t = t;
            now_x = x;
            now_y = y;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

// calculate Minimum Spanning Tree with Prim's algorithm
void mst(vector<vector<int>>& g, vector<int>& weights) {
    int n_vertex = weights.size();
    vector<bool> mst(n_vertex, false);

    weights[0] = 0;
    while (true) {
        int idx;
        int min_weight = INT_MAX;
        for (int i = 0; i < n_vertex; ++i) {
            if (!mst[i] && weights[i] < min_weight) {
                idx = i;
                min_weight = weights[i];
            }
        }

        if (min_weight == INT_MAX)
            break;

        mst[idx] = true;

        for (int i = 0; i < n_vertex; ++i) {
            if (!mst[i] && g[idx][i] != -1)
                weights[i] = min(weights[i], g[idx][i]);
        }
    }
}

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

    vector<vector<int>> g(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j)
            cin >> g[i][j];
    }

    vector<int> weights(n, INT_MAX);
    mst(g, weights);

    int sum_of_weights = 0;
    for (int i = 0; i < n; ++i)
        sum_of_weights += weights[i];
    cout << sum_of_weights << '\n';
}



Measured memory_bytes: 3148
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.B
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.NextInt();
			var a = cin.ArrayInt(n);
			int now = a[0];
			int ans = 1;
			bool ascendable = true;
			bool decsendable = true;
			for (int i = 1; i < n; i++)
			{
				if (!ascendable && now < a[i] || !decsendable && now > a[i])
				{
					ans++;
					ascendable = true;
					decsendable = true;
				}
				else if (now < a[i]) decsendable = false;
				else if (now > a[i]) ascendable = false;
				now = a[i];
			}
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 20576
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	char str[N];
	
	void main()
	{
		string str;cin>>str;int n=sz(str);while(n--) putchar('x');
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

class fenwick {
  int n;
  vector<int> v;

 public:
  fenwick(int _n) : n(_n) {
    v.resize(n);
  }

  void update(int at, int by) {
    while (at < v.size()) {
      v[at] += by;
      at |= (at + 1);
    }
  }

  int query(int at) {
    int res = 0;
    while (at >= 0) {
      res += v[at];
      at = (at & (at + 1)) - 1;
    }
    return res;
  }
};

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

  string s;
  cin >> s;

  vector<int> cnt(n + 5);
  fenwick ft(n + 5);

  for (int i = 0; i < n; ++i) {
    if (s[i] == '0' and (i == 0 or s[i - 1] == '1')) {
      cnt[i] = 1;
      ft.update(i, cnt[i]);
    }
  }

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int expected = k;
    if (s[i] == '0' and cnt[i] == 0) {
      expected--;
    }

    int left = i, right = n;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      int value = ft.query(mid);
      if (i) value -= ft.query(i - 1);

      if (value > expected) {
        right = mid;
      } else {
        left = mid;
      }
    }

    ans = max(ans, right - i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1232
#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)
int main()
{
	int count = 0, arr[105][105] = { 0 };
	scanf("%d", &count);
	for (int i = 0; i < count; i++){
		int id = 0, num = 0, arr1[105] = { 0 };
		scanf("%d %d", &id, &num);
		for (int j = 1; j <= num; j++){
			scanf("%d", &arr1[j]);
		}
		for (int j = 1; j <= num; j++){
			for (int k = 1; k <= count; k++){
				if (arr1[j] == k){
					arr[id][k] = 1;
					break;
				}
			}
		}
	}
	for (int i = 1; i <= count; i++){
		for (int j = 1; j <= count; j++){
			printf("%d", arr[i][j]);
			if (j != count){
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
int a[100005],b[100005],c[100005],n;
long long ans,f[100005];
void go(int a[]){
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
}
int main(){
	scanf("%d",&n);
	go(a); go(b); go(c);
	for (int i=1,j=0;i<=n;++i){
		while (j<n&&a[j+1]<b[i]) ++j;
		f[i]=j+f[i-1];
	}
	for (int i=1,j=0;i<=n;++i){
		while (j<n&&b[j+1]<c[i]) ++j;
		ans+=f[j];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    private static final String AMBIGUOUS = "AMBIGUOUS";
    private static final String MMYY = "MMYY";
    private static final String NA = "NA";
    private static final String YYMM = "YYMM";

    public static String process(String S) {
        String firstPart = S.substring(0, 2);
        String secondPart = S.substring(2);

        boolean isFirstPartValid = isValidMonth(firstPart);
        boolean isSecondPartValid = isValidMonth(secondPart);
        if (isFirstPartValid && isSecondPartValid) {
            return AMBIGUOUS;
        } else if (isFirstPartValid) {
            return MMYY;
        } else if (isSecondPartValid) {
            return YYMM;
        } else {
            return NA;
        }
    }

    private static boolean isValidMonth(String part) {
        try {
            Integer i = Integer.valueOf(part);
            return i > 0 && i <= 12;
        } catch (Exception e) {
            return false;
        }
    }

    // Util func

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

        String S = sc.next();

        final String result = process(S);

        output(result);
    }

    private static void output(String result) {
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
class dice():
    top = 1
    flont = 2
    right = 3
    def do_N(self):
        temp = self.flont
        self.flont = 7-self.top
        self.top = temp

    def do_S(self):
        temp = 7-self.flont
        self.flont = self.top
        self.top = temp

    def do_E(self):
        temp = self.top
        self.top = 7-self.right
        self.right = temp

    def do_W(self):
        temp = 7-self.top
        self.top = self.right
        self.right = temp

num1 = list(map(int, input().split()))
num2 = list(map(int, input().split()))
dice1 = dice()
dice2 = dice()
flag1 = False
flag2 = False

if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
    flag1 = True
    if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
        flag2 = True
for j in range(4):
    for k in range(4):
        dice1.do_E()
        if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
            flag1 = True
            if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
                flag2 = True
    dice1.do_N()
    if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
        flag1 = True
        if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
            flag2 = True

dice1.do_S()
dice1.do_E()
if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
    flag1 = True
    if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
        flag2 = True
for j in range(4):
    for k in range(4):
        dice1.do_E()
        if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
            flag1 = True
            if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
                flag2 = True
    dice1.do_N()
    if num1[dice1.flont-1] == num2[dice2.flont-1] and num1[dice1.top-1] == num2[dice2.top-1]:
        flag1 = True
        if num1[dice1.right-1] == num2[dice2.right-1] and num1[7-dice1.top-1] == num2[7-dice2.top-1] and num1[7-dice1.flont-1] == num2[7-dice2.flont-1] and num1[7-dice1.right-1] == num2[7-dice2.right-1]:
            flag2 = True

if flag1 and flag2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5748
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
A = [int(i) for i in input().split()]

ok = 1
border = A[0]
for i in range(1,len(A)):
	if border > A[i]:
		ok = 0
		break
	border = max(border,A[i]-1)
if ok==1:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 15724
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  int A, B;
  cin >> A >> B;
  int sum = 1;
  int cnt = 0;
  while(true){
    sum += A - 1;
    cnt ++;
    if (sum >= B){
      break;
    }
  }
  if (B == 1){
    cnt = 0;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++14
TASK:
*/
#include<iostream>
#include<cstdio>
//#include<fstream>
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
int main(){
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	if(b<=4)
		cout<<"Heisei";
	else
		cout<<"TBD";
	return 0;
}

Measured memory_bytes: 256