akhauriyash/Code-Regression huggingface dataset:
// Maximum Profit
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(void)
{
    int R[MAX], n;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++)
    {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
#define Clr(x) memset(x, 0, sizeof(x))
ll n, k;

struct PP {
	ll a, b;
} p[maxx];

map <ll, ll> cnt;
bool vis[maxx];
ll num[maxx];

int main() {
	Clr(vis);
	cnt.clear();
	scanf("%lld %lld", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%lld %lld", &p[i].a, &p[i].b);
	for(int i = 1; i <= n; i++) cnt[p[i].a] += p[i].b;
	int t = 0;
	for(int i = 1; i <= n; i++) {
		if(!vis[p[i].a]) {
			vis[p[i].a] = 1;
			num[++t] = p[i].a;
		}
	}
	sort(num + 1, num + t + 1);
	ll dd = 0;
	for(int i = 1; i <= t; i++) {
		dd += cnt[num[i]];
		if(dd >= k) {
			cout << num[i] << endl;
			break;
		}
	}
}

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

int main()
{
    int n;
    cin>>n;
    if(n/100%10==7||n/10%10==7||n%10==7)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3600
N = int(input())
a = 90000*(bool(N//100000))
b = 900*(bool(N//1000))
c = 9*(bool(N//10))
d = (N-99)*(bool(N//100)-bool(N//1000))
e = (N-9999)*(bool(N//10000)-bool(N//100000))
f = N*(1-bool(N//10))
print(a+b+c+d+e+f)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll in()
{
    ll re=0,f=1;char x=getchar();
    while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
    while(x>='0'&&x<='9')re=re*10+x-48,x=getchar();
    return re*f;
}
void out(ll x)
{
    if(x<0)putchar('-'),x=-x;
    if(!x){putchar('0');return;}
    char z[21],ct=0;
    while(x){z[++ct]=x%10+48,x/=10;}
    while(ct){putchar(z[ct]);--ct;}
}
struct node{
    int ls,rs;
    ll mx,tag;
};
struct segtree{
    int rt,ptr;
    node nd[1000010];
    void pushdown(int c)
    {
    	int L=nd[c].ls;
    	int R=nd[c].rs;
    	nd[L].mx+=nd[c].tag;
		nd[R].mx+=nd[c].tag; 
    	nd[L].tag+=nd[c].tag;
    	nd[R].tag+=nd[c].tag;
    	nd[c].tag=0;
	}
    void build(int &c,int l,int r)
    {
        c=++ptr;
        if(l==r)
        {
            nd[c].mx=l-1;
            return;
        }
        int mid=l+r>>1;
        build(nd[c].ls,l,mid);
        build(nd[c].rs,mid+1,r);
        nd[c].mx=max(nd[nd[c].ls].mx,nd[nd[c].rs].mx);
    }
    void modify(int c,int l,int r,int ql,int qr,ll v)
    {
		if(l==ql&&r==qr)
		{
		   nd[c].mx+=v;
		   nd[c].tag+=v;
		   return;
		}
		pushdown(c);
		int mid=l+r>>1;
		if(qr<=mid)modify(nd[c].ls,l,mid,ql,qr,v);
		else if(ql>mid)modify(nd[c].rs,mid+1,r,ql,qr,v);
		else
		{
			modify(nd[c].ls,l,mid,ql,mid,v);
			modify(nd[c].rs,mid+1,r,mid+1,qr,v);
		}
		nd[c].mx=max(nd[nd[c].ls].mx,nd[nd[c].rs].mx);
    }
    ll query(int c,int l,int r,int ql,int qr)
    {
		if(l==ql&&r==qr)return nd[c].mx;
		pushdown(c);
		int mid=l+r>>1;
		if(qr<=mid)return query(nd[c].ls,l,mid,ql,qr);
		if(ql>mid)return query(nd[c].rs,mid+1,r,ql,qr);
		return max(query(nd[c].ls,l,mid,ql,mid),query(nd[c].rs,mid+1,r,mid+1,qr));
	}
}tr;
int n,Q;
int main()
{
	n=in();Q=in();
	tr.build(tr.rt,1,n);
	ll mxr=0;
	for(int i=1;i<=Q;++i)
	{
		ll l=in(),r=in(),w=in();
		mxr=max(mxr,r);
		tr.modify(tr.rt,1,n,l,r,w);
		out(tr.query(tr.rt,1,n,1,mxr));
		putchar('\n');
	}
}


Measured memory_bytes: 7776
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int INF = INT_MAX / 2;

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

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

    vector<vector<vector<int> > > dp(day+1, vector<vector<int> >(day, vector<int>(n, INF)));
    for(int i=0; i<n; ++i)
        dp[day][0][i] = 0;
    for(int a=day-1; a>=0; --a){
        for(int b=0; b<day; ++b){
            for(int c=0; c<n; ++c){
                for(int i=0; i<n; ++i){
                    if(i == c)
                        dp[a][b][i] = min(dp[a][b][i], dp[a+1][b][c] + p[i][a]);
                    else if(b+1 < day)
                        dp[a][b+1][i] = min(dp[a][b+1][i], dp[a+1][b][c] + p[i][a]);
                }
            }
        }
    }

    int minValue = INF;
    int b, c;
    for(int b2=0; b2<day; ++b2){
        for(int c2=0; c2<n; ++c2){
            if(dp[0][b2][c2] < minValue){
                b = b2;
                c = c2;
                minValue = dp[0][b2][c2];
            }
        }
    }

    cout << minValue << ' ' << b << endl;
    for(int a=0; a<day; ++a){
        for(int i=0; ; ++i){
            if(i == c){
                if(dp[a][b][c] == dp[a+1][b][i] + p[c][a]){
                    cout << (c + 1) << endl;
                    c = i;
                    break;
                }
            }
            else{
                if(b > 0 && dp[a][b][c] == dp[a+1][b-1][i] + p[c][a]){
                    cout << (c + 1) << endl;
                    -- b;
                    c = i;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1800
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define MX 4013
#define MOD 1000000007

using namespace std;

int n, m;
int c[MX][MX], s[MX][MX];

int main()
{
	scanf("%d%d", &n, &m);
	for(int i=0; i<=n+m; i++)
	{
		c[i][0] = 1;
		for(int j=1; j<=i; j++) c[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD;
	}
	for(int j=0; j<=n+m; j++) s[0][j] = 1;
	for(int i=1; i<=n+m; i++)
		for(int j=0; j<=n+m; j++)
			s[i][j] = (s[i-1][j] + c[j][i]) % MOD;
	for(int i=1; i<=n+m; i++)
		for(int j=0; j<=n+m; j++)
			s[i][j] = (s[i][j] + s[i-1][j]) % MOD;
	int ans = 0;
	for(int i=0; i<=n; i++)
		for(int j=0; j<m&&i+j<=n; j++)
			if(!j) ans = (ans + 1) % MOD;
			else ans = (ans + 1ll*c[m-1][j]*s[i][j-1]) % MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 125824
#include <stdio.h>
#define MAX 101
#define inf 99999
#define NIL -1

int A[MAX][MAX], B[MAX], C[MAX];

void Serch(int,int);

int main()
{
  int i,j;
  int k,n;
  
  scanf("%d", &n);
  for(i=1; i<=n; i++)
    {
      C[i] = inf;
      scanf("%d", &k);
      scanf("%d", &B[k]);
      for(j=1; j<=n; j++) A[i][j] = 0;
      for(j=1; j<=B[k]; j++) scanf("%d", &A[k][j]);
    }
  
  Serch(1,0);
  
  for(i=1; i<=n; i++)
    {
      if(C[i] == inf) C[i] = NIL;
      printf("%d %d\n", i, C[i]);
    }
  return 0;
}
  
void Serch(int x, int y)
{
  int i;
  C[x] = y;
  for(i=1; i<=B[x]; i++)
    {
      if(C[A[x][i]] > y)
	Serch(A[x][i], y+1);
    }
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  int64_t N;
  cin >> N;
  vector<string> S(N);
  REP(i,N) cin >> S[i];
  map<string,int64_t> num;
  int64_t m = 0;
  REP(i,N){
    if(!num.count(S[i])){
      num[S[i]] = 1;
    }else{
      num[S[i]]++;
    }
    m = max(m,num[S[i]]);
  }
  
  vector<string> ss;
  for(auto iter = num.begin(); iter != num.end(); iter++){
    if(m == iter->second){
      ss.push_back(iter->first);
    }
  }
  sort(ALL(ss));
  REP(i,ss.size()){
    cout << ss[i] << endl;
  }


}

Measured memory_bytes: 28404
N, M = map(int, input().split())
line = [list(map(int, input().split())) for _ in range(N)]
line.sort()
price = 0
for i in line:
    if M - i[1] > 0:
        price += i[0] * i[1]
        M = M - i[1]
    elif M - i[1] == 0:
        price += i[0] * i[1]
        break
    else:
        number = i[1] - abs(M - i[1])
        price += i[0] * number
        break
print(price)

Measured memory_bytes: 27756
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll d,t,s;
    cin >> d >> t >> s;
    if((t*s) >= d) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3644
#include <stdio.h>

//値の交換 ABC Swap
void swap(int* pX, int* pY, int* pZ) {
	int tmp;
	tmp = *pX;
	*pX = *pZ;
	*pZ = *pY;
	*pY = tmp;
}


int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	swap(&a, &b, &c);
	printf("%d %d %d", a, b, c);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(int n){
    cout << "Yes" << endl;
}

void no (int n){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

int main() {
    ll n, a, b, c, d, e; cin >> n >> a >> b >> c >> d >> e;
    cout << cel(n,min({a,b,c,d,e})) + 4LL << endl;
}

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

signed
main(){
		int n;
		cin >> n;
		for(int i=0;i<n;i++)
		{
				int y,m,d;
				cin >> y >> m >> d;
				int three_y = 333 - y/3;
				int else_y = 999 - y - three_y;
				int now_y_day = 0;
				if(y%3 == 0)
				{
					now_y_day = (20-d) + (10-m)*20;
				}else
				{
						if(m%2==0)
						{
								now_y_day = (19-d) + ((10-m)/2) * (19+20);
						}else
						{
								now_y_day = (20-d) + 19 + ((10-m)/2) * (19+20);
						}
				}
				int ans = (three_y * 200) + (else_y * 195) + now_y_day + 1;
				cout << ans << endl;
		}
}


Measured memory_bytes: 3088
package main

import (
	"fmt"
	"math"

)

func main() {

	
	var  N int

	fmt.Scan(&N)

	temp:=0

	min :=N+1

	Cnt := int((math.Sqrt(float64(N))))+1

	for i:=1;i<=Cnt;i++{

		if N%i ==0{

			temp = i + (N/i)

			if temp < min {

			     min= temp
			}
		}

	}

	result := min -2

	fmt.Println(result)

}


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

int main(){
  while(1){
	int n,m,a;

	cin >> n >> m >> a;

	if(n==0&&m==0&&a==0) break;

	int i=0;
	pair<int, pair<int,int> > line[1001];
	for(i=0;i<m;i++){
	  int h,p,q;
	  cin >> h >> p >> q;
	  line[i] = make_pair(h, make_pair(p,q));
	}

	sort(line,line+m,greater<pair<int, pair<int,int> > >());


	for(int j=0; j<m; j++){
	  // cout << line[j].first <<" " << line[j].second.first <<" " <<line[j].second.second <<" "  << endl;
	  if(line[j].second.first == a){
		// cout << "yes" << endl;
		a = line[j].second.second;
	  }else if(line[j].second.second == a){
		// cout << "yes" << endl;
		a = line[j].second.first;
	  }
	}
	cout << a << endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, R;
  cin >> N >> R;
  int ans = R;
  if (N < 10)
  {
    ans += 100 * (10 - N);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N,M=list(map(int,input().split(" ")))
S=np.zeros((N,2))
C=np.zeros((M,2))

# 学生の場所
for n in range(N):
    S[n,:]=list(map(int,input().split(" ")))

# チェックポイントの場所
for m in range(M):
    C[m,:]=list(map(int,input().split(" ")))

# 各学生について、最近傍のチェックポイントを探す
for s in S:
    # print("s = ",s)
    # print("C-s = ",C-s)

    d=np.abs(C-s).sum(axis=1)
    Cnear=np.argmin(d) # 最近傍のチェックポイントのインデックス

    if type(Cnear)!=np.int64: # もし最近傍のチェックポイントが複数有る場合、最も小さいインデックスのもの
        Cnear=Cnear[0]

    print(Cnear+1) # 1から始まるので1を足す

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

using namespace std;

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

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

using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
template<class T> void writerLn(T x) { writer(x, '\n'); }
#define rep(i,n)for(int i=0;i<n;i++)
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000]{ 1 }, cnt = 1;
char b[200000], ok[100000]{ 1 };
deque<int>que;

void bfs(int u, int t) {
	que.emplace_back(u);
	while (!que.empty()) {
		int p = que.front(); que.pop_front();
		for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.emplace_back(v);
				}
			}
			else if (!d[v]) {
				d[v] = d[p] + 1; que.emplace_back(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)writerLn(ans[i]);
}

Measured memory_bytes: 13536
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
 int  a,b;
 char s[10000];
 while (cin>>a>>b)
 {
     sprintf(s, "%d", a+b);
     cout<<strlen(s)<<endl;
 }
 return 0;
        }

Measured memory_bytes: 1200
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     p=n;
     p+=n*n;
     p+=n*n*n;
     cout<<p<<endl;


     return EXIT_SUCCESS;
}


Measured memory_bytes: 3632
#include <iostream>
#include <deque>
#include <utility>
#include <limits.h>

using namespace std;

int main()
{
  int N;
  unsigned long K;
  cin >> N >> K;

  bool is_exist_at_0 = false;
  deque<int> position_plus, position_minus;

  for (int n=0; n<N; ++n) {
    int x;
    cin >> x;
    if (x<0)
      position_minus.push_front(x);
    else if (x>0)
      position_plus.push_back(x);
    else if (x==0)
      is_exist_at_0 = true;
  }

  if (is_exist_at_0)
    --K;

  int dist_min = (K>0 ? INT_MAX : 0);
  
  int num_plus = min(K,position_plus.size());
  int num_minus = K - num_plus;
  for (; num_plus >= 0 && num_minus <= position_minus.size();) {
    int dist_plus = num_plus > 0 ? position_plus[num_plus-1] : 0;
    int dist_minus = num_minus > 0 ? -1 * position_minus[num_minus-1] : 0;
    int dist_all = min(2*dist_plus+dist_minus, dist_plus+2*dist_minus);
    dist_min = min(dist_min,dist_all);

    --num_plus;
    ++num_minus;
  }

  cout << dist_min << endl;
  
  return 0;
}

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

int main()
{
   long a,b,n;
 
//   cin>>n;
//   map<string,int> m;
//     map<string,int> date;
//   // long long max=0;
//   // long double op=min(b-1,n);
//   for(long double i=1;i<=n;i++)
//   {
//       string na;
//       int k;
//       cin>>na>>k;
//       m[na]+=k;
//       date[na]=i;
//   }


string s;
cin>>s;

if(s=="ARC")
cout<<"ABC";
else
cout<<"ARC";


   return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{ 
  for (int i = 0; i < 5; i++)
  {
    int X;cin>>X;
    if(X != i+1)
    {
      cout<<i+1<<endl;
      return;
    }
  }
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main(){
  int i,j,k,n;
  string str1,str2;
  vector <char> ans;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> str1 >> str2;
  
    int result = 0;   
    int len1 = str1.size();
    int len2 = str2.size();


    for(j = 0; j < len1; j++){
      if(str1[j]=='m'){
	if(str1[j-1] >= '2' && str1[j-1] <= '9'){
	  result += (str1[j-1]-'0')*1000;
	}else{
	  result += 1000;
	}
      }
  
  
      if(str1[j]=='c'){
	if(str1[j-1] >= '2' && str1[j-1] <= '9'){
	  result += (str1[j-1]-'0')*100;
	}else{
	  result += 100;
	}
      
      }
      if(str1[j]=='x'){
	if(str1[j-1] >= '2' && str1[j-1] <= '9'){
	  result += (str1[j-1]-'0')*10;
	}else{
	  result += 10;
	}
      }
      
    
      if(str1[j]=='i'){
	if(str1[j-1] >= '2' && str1[j-1] <= '9'){
	  result += (str1[j-1]-'0')*1;
	}else{
	  result += 1;
	}  
      }
    }
    
      for(j = 0; j < len2; j++){
	if(str2[j]=='m'){
	  if(str2[j-1] >= '2' && str2[j-1] <= '9'){
	    result += (str2[j-1]-'0')*1000;
	  }else{
	    result += 1000;
	  }
      
	}
	if(str2[j]=='c'){
	  if(str2[j-1] >= '2' && str2[j-1] <= '9'){
	    result += (str2[j-1]-'0')*100;
	  }else{
	    result += 100;
	  }
      
	}
	if(str2[j]=='x'){
	  if(str2[j-1] >= '2' && str2[j-1] <= '9'){
	    result += (str2[j-1]-'0')*10;
	  }else{
	    result += 10;
	  }
	}
      
    
	if(str2[j]=='i'){
	  if(str2[j-1] >= '2' && str2[j-1] <= '9'){
	    result += (str2[j-1]-'0')*1;
	  }else{
	    result += 1;
	  }  
	}
      }

      ans.clear();
      if(result/1000 >0){
	if(result/1000 > 1){
	  ans.push_back(result/1000+'0');
	  ans.push_back('m');
	}else{
	  ans.push_back('m');
	}
	result%=1000;
      }
      if(result/100 >0){
	if(result/100 > 1){
	  ans.push_back(result/100+'0');
	  ans.push_back('c');
	}else{
	  ans.push_back('c');
	}
	result%=100;
      }
      if(result/10 >0){
	if(result/10 > 1){
	  ans.push_back(result/10+'0');
	  ans.push_back('x');
	}else{
	  ans.push_back('x');
	}
	result%=10;
      }
      if(result/1 >0){
	if(result/1 > 1){
	  ans.push_back(result/1+'0');
	  ans.push_back('i');
	}else if(result/1==1){
	  ans.push_back('i');
	}
      }
  
      int len3 = ans.size();
      for(k = 0; k < len3; k++){
	cout << ans[k];
      }
      cout << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1220
function Main(input) {
	input = input.split(" ");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
	var s = a + b
    if(s >= c){
      console.log("Yes");
    }else{
      console.log("No")
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;

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

            for(int i=0;i<n;i++){
                System.out.printf("%d", a[n-i-1]);
                if(i != n-1){
                    System.out.printf(" ");
                }else{
                    System.out.println();
                }
            }
        
    }
    
    
}


Measured memory_bytes: 26336
n=int(input())
a=[int(i) for i in input().split(" ")]
x=0
flg=1
while flg:
    flg=0
    for i in range(n-1,0,-1):
        if a[i-1] > a[i]:
            a[i],a[i-1] = a[i-1],a[i]
            x+=1
            flg=1
print(" ".join([str(i) for i in a]))
print(x)

Measured memory_bytes: 7752
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  map<char,char> t;
  t['A']='T';
  t['T']='A';
  t['C']='G';
  t['G']='C';
  string b;
  cin>>b;
  for(auto& ch : b) {
    cout << t[ch];
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	char v[10];
	cin>>v;

	int s=strlen(v);

	for(int i=0; i<s-1; i++)
	{
		if(v[i]=='A' && v[i+1]=='C')
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int N, A, B;
    try(Scanner sc = new Scanner(System.in)) {
      N = sc.nextInt();
      A = sc.nextInt();
      B = sc.nextInt();
    }
    int answer = (int)Math.min(A*N, B);
    System.out.println(answer);
  }
}

Measured memory_bytes: 23764
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array



void solve(){
	int n;
	cin >> n;
	vector<int> dp(3,0);
	for(int i = 0;i < n; i++){
		vector<int> newdp(3,0);
		vector<int> arr(3,0);
		for(auto& e: arr) cin >> e;
		for(int j = 0;j < 3; j++){
			for(int k = 0;k < 3; k++){
				if(j != k){
					newdp[k] = max(newdp[k],dp[j]+arr[k]);
				}
			}
		}		
		dp = newdp;
	}
	cout << *max_element(dp.begin(),dp.end()) << "\n";
}

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

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3652
n,a,b=map(int, input().split())
 
def dsum(n):
  res = 0
  while n>0:
    res += n%10
    n //= 10
  return res
 
cnt = 0
for i in range(1,n+1):
  if a<=dsum(i)<=b:
    cnt += i
print(cnt)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;


#define rep(i,n) for(int i=0;i<(n);i++)


int main(){
    string s;
    cin>>s;
    while(1){
        int num;
        if(s.substr(1,s.size()-2).find("mew",0)!=string::npos)
            num=(int)s.find("mew",0);
        else break;
        
        string tmp="";
        rep(i,num){
            tmp+=s[i];
            }
        for(int i=num+3;i<s.size();i++){
            tmp+=s[i];
            }
        s=tmp;
        }
    if(s=="mew")cout<<"Cat"<<endl;
    else cout<<"Rabbit"<<endl;
    
    return 0;
}

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

using namespace std;

#define ll long long
const int N=2e5;
int a[N],n,k;

bool isPossible(int ans,int a[],int log){
	for(int i=0;i<n;i++){
		log-=(a[i]+ans-1)/ans-1;
	}
	return log>=0;
}

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

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    int l=1,r=(int)1e9;
    while(l!=r){
    	int mid=(l+r)/2;
    	if(isPossible(mid,a,k))
    		r=mid;
    	else
    		l=mid+1;
	}
	cout<<l;
    return 0;
}


Measured memory_bytes: 4416
#include <iostream>
#include <string>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

int main(void) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
        a += 13;
    }
    if (b == 1) {
        b += 13;
    }
    if (a > b) {
        cout << "Alice" << endl;
    } else if (a < b) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
    return 0;
}


Measured memory_bytes: 3540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		HashMap<String, Integer> hs = new HashMap<String, Integer>();

		int maxOccured = 0;
		int maxLen = 0;
		String maxOccuredWord = "";
		String maxLenWord = "";

		for (String word : line.split(" +")) {
			if (!hs.containsKey(word)) {
				hs.put(word, 1);
			} else {
				hs.put(word, hs.get(word) + 1);
			}
			// 発生回数と単語を確認して更新
			if (maxOccured < hs.get(word)) {
				maxOccured = hs.get(word);
				maxOccuredWord = word;
			}
			// 文字数と単語を確認して更新
			// 文字数確認済みの単語は確認しない
			if (hs.get(word) == 1 && maxLen < word.length()) {
				maxLen = word.length();
				maxLenWord = word;
			}
		}
		System.out.println(maxOccuredWord + " " + maxLenWord);
	}
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int m, d;
	cin >> m >> d;
	int ans = 0;
	FOR(i, 1, d + 1)
		ans += i % 10 >= 2 && i / 10 >= 2 && (i % 10) * (i / 10) <= m;
	cout << ans;
	return 0;
}


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

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

  int count = 0;
  for(int i = 0;i<N;i++){
    string s;
    cin >> s;
    if(s == "Y")count++;
  }
  if(count == 0){
    cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
memo1 = {}
def f(i):
    if i==0:
        return 1
    if i in memo1:
        return memo1[i]
    memo1[i] = 2*f(i-1)+3
    return memo1[i]
memo2 = {}
def g(i):
    if i==0:
        return 1
    if i in memo2:
        return memo2[i]
    memo2[i]=2*g(i-1)+1
    return memo2[i]
N,X = map(int,input().split())
cnt = 0
while X>0 and N>0:
    if X==f(N):
        cnt += g(N)
        X -= f(N)
    elif X>=f(N-1)+2:
        cnt += 1+g(N-1)
        X -= f(N-1)+2
    else:
        X -= 1
    N -= 1
cnt += X
print(cnt)

Measured memory_bytes: 61640
N, M = map(int,input().split())
C = [0]*N

for k in range(M):
    a, b = map(int,input().split())
    C[a-1] += 1
    C[b-1] += 1

for e in C:
    if e%2 != 0:
        print("NO")
        exit(0)
print("YES")


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
int main() {
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans=1;
    sort(a.begin(),a.end());
    if(a[0]==0){
        cout<<0<<endl;
    }else{
        for(int i=0;i<n;i++){
            double s1=ans/1000000000;
            double s2=a[i]/1000000000;
            if(s1*s2>2){
                ans=-1;
                break;
            }
            ans*=a[i];
            if(ans>1000000000000000000){
                ans=-1;
                break;
            }
        }
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 4052
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	s := nextStr()
	if len(s) == 2 {
		fmt.Println(s)
	} else {
		fmt.Printf("%c%c%c", s[2], s[1], s[0])
	}
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    println!("{}", n.pow(3));
}


Measured memory_bytes: 4352
def _sum(l, r):
  return (l+r)*(r-l+1)//2
  

N, K = list(map(int, input().split()))
ans = 0
for i in range(K, N+2):
  l = _sum(0, i-1)
  r = _sum(N+1-i,N)
  ans += r-l+1
print(ans%(10**9+7))

Measured memory_bytes: 9132
require 'pp'
N,d=gets.chomp.split(' ').map{|n| n.to_i}
K,d=gets.chomp.split(' ').map{|n| n.to_i}

x = 1
0.upto(N-1){|i|
	a = x+K 
	b = x*2
	a<b ? x=a : x=b
}
puts x


Measured memory_bytes: 2172
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, A, B;
  cin>>H>>W>>A>>B;
  int ans[H][W];
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if((i<H-B && j<W-A) || (i>=H-B && j>=W-A)) ans[i][j] = 0;
      else ans[i][j] = 1;
    }
  }
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}



Measured memory_bytes: 7468
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

void a()
{
    int n;
    cin >> n;
    if (n % 2 == 0)
    {
        cout << n / 2 - 1;
        return;
    }
    else
    {
        cout << n / 2;
        return;
    }
}
void b()
{
    int n;
    cin >> n;
    vector<long long int> count(n, 0);
    int max = 0;
    for (int i = 0; i < n; i++)
    {
        long long int temp = 0;
        cin >> temp;
        if (temp > max)
            max = temp;
        count[temp] = count[temp] + 1ll;
        if (i == 0)
        {
            if (count[0] != 1)
            {
                cout << 0;
                return;
            }
        }
        else
        {
            if (temp == 0)
            {
                cout << 0;
                return;
            }
        }
    }
    vector<long long int> s(n, 0ll);
    s[0] = 1ll;
    int itr = 1;
    long long int div = 998244353;
    while (count[itr] != 0)
    {
        long long int multi = s[itr - 1];
        for (long long int i = 0; i < count[itr]; i++)
            multi = (multi * count[itr - 1]) % div;
        s[itr] = multi;
        itr++;
    }
    if (max > itr - 1)
        cout << 0;
    else if (count[1] != 0)
        cout << s[itr - 1];
    else
    {
        cout << s[0];
    }
    return;
}
int main(void)
{
    //a();
    b();
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

int a[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool flag = false;
    rep(i,n){
        cin >> a[i];
        if(i < a[i]){
            flag = true;
        }
        if(i >= 1 && a[i-1]+1 < a[i]){
            flag = true;
        }
    }
    if(flag){
        cout << "-1\n";
        return 0;
    }
    int prv = -1;
    ll ans = 0;
    rep(i,n){
        if(prv + 1 != a[i]){
            ans += prv;
        }
        prv = a[i];
    }
    cout << ans + prv << "\n";
    return 0;
}

Measured memory_bytes: 1024
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = -1;

int x[7];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    for (int i = 1; i <= 5; i++) {
        cin >> x[i];
        if (x[i] == 0) return cout << i << '\n', 0;
    }
}

Measured memory_bytes: 3564
def main():
    n, s = map(int, input().split())
    a = [int(i) for i in input().split()]
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        ai = a[i]
        for j in range(s + 1):
            if j < ai:
                dp[i + 1][j] = dp[i][j] * 2 % 998244353
            else:
                dp[i + 1][j] = (dp[i][j] * 2 + dp[i][j - ai]) % 998244353
    print(dp[n][s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 132184
import sys
readline = sys.stdin.readline

def popcount(i):
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

Jm = 18

MOD = 10**18+3
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(100)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD


PP = (1<<32) - 1
def popcount64(x):
    return popcount(PP&x) + popcount(x>>32)



N, K, S, T = map(int, readline().split())
lim = 60
calc = [0]*lim
for n in range(lim):
    for j in range(K):
        calc[n] += comb(n, j)

A = list(map(int, readline().split()))

ans = 1
table = [-1]*Jm
for i in range(Jm):
    si = S&(1<<i)
    ti = T&(1<<i)
    if si and ti:
        table[i] = 1
        continue
    if si and not ti:
        ans = 0
        break
    if not si and not ti:
        table[i] = 0
        continue        


if not ans:
    print(ans)
else:
    ans = 0
    B = []
    for idx in range(N):
        for i in range(Jm):
            if table[i] == 1:
                if not (A[idx] & (1<<i)):
                    break
            if table[i] == 0:
                if (A[idx] & (1<<i)):
                    break
        else:
            res = 0
            cnt = -1
            ctr = 0
            for i in range(Jm):
                if table[i] == -1:
                    ctr += 1
                    cnt += 1
                    if A[idx] & (1<<i):
                        res |= (1<<cnt)
            B.append(res)
    
    Jm = ctr
    L = len(B)
    JJ = (1<<L)-1

    G = [[0]*L for _ in range(Jm)]
    for i in range(Jm):
        for idx in range(L):
            res = 0
            for jdx in range(idx+1, L):
                if (1<<i) & B[idx] == (1<<i) & B[jdx]:
                    res |= 1<<jdx
            G[i][idx] = res
    
    
    H = [[0]*L for _ in range(1<<Jm)]
    for i in range(L):
        H[0][i] = JJ
    
    ans = 0
    for k in range(1, K+1):
        ans += comb(L, k)
    #print(B, ans)
    for U in range(1, 1<<Jm):
        R = []
        res = 0
        K = -U&U
        Uk = U^K
        for idx in range(L):
            H[U][idx] = H[Uk][idx] & G[K.bit_length()-1][idx]
            cnt = H[U][idx]
            res += calc[popcount64(cnt)]
        #print(U, (-1 if len(R)&1 else 1)*res)
        ans += (-1 if popcount(U)&1 else 1)*res
    print(ans)
        

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

int main(){
    string S;
    cin >> S;
    int odd = 0;
    int even = 0;
    int kazu = S.size();
    vector<int> ans(kazu,0);//0するべき？
    bool flag = true;
    int temp = 0;
    for(int i = 0; i < S.size(); i++){
        
        if(!flag){
            if(S[i] == 'R'){
                flag = true;
                if(temp % 2 == 0){
                    ans[temp] += even; ans[temp+1] += odd;
                }else{
                    ans[temp] += odd; ans[temp+1] += even;
                }
                odd = 0; even = 0;
            }
        }

        if(flag){
        if(S[i] == 'R' && S[i+1] == 'L'){
            temp = i;
            ans[temp] = 1; ans[temp+1] = 1;
            flag = false;
            i++;
            continue;
        }
        }

        if(flag){
        if(S[i] == 'R'){
            if(i % 2 == 1) odd++;
            else even++;
        }
        }

        if(!flag){
            if(S[i] == 'L'){
            if(i % 2 == 1) odd++;
            else even++;
        }
        }
    }

    if(temp % 2 == 0){
        ans[temp] += even; ans[temp+1] += odd;
    }else{
        ans[temp] += odd; ans[temp+1] += even;
    }

    for(int i = 0; i < kazu; i++){
        cout << ans[i] << " ";
    }
    
}

Measured memory_bytes: 1024
N,M,X=map(int, input().split())
A=list(map(int, input().split()))
c1=0
c2=0
for i in range(M):
  if N>A[i]>X:
    c1+=1
  if 0<A[i]<X:
    c2+=1

print(min(c1,c2))

Measured memory_bytes: 3060
fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let n = buf.trim().parse().unwrap();
    let mut v = vec![0 as u64; n];
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let mut buf = buf.split_whitespace();
    for i in 0..n {
        v[i] = buf.next().unwrap().parse().unwrap();
    }
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let q = buf.trim().parse().unwrap();
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf).ok();
    let mut buf = buf.split_whitespace();
    let mut count = 0;
    for _ in 0..q {
        let a: u64  = buf.next().unwrap().parse().unwrap();
        match bin_search(&v, 0, n, a) {
            Some(_) => count += 1,
            None => (),
        }
    }
    println!("{}", count);
}

fn bin_search( v: &Vec<u64>, h: usize, t: usize, a: u64) -> Option<usize> {
    let half = (h + t) / 2;
    let h_v = v[half];
    if h_v == a {
        Some(half)
    } else {
        if h == half || half == t {
            None
        } else if h_v > a {
            bin_search(v, h, half, a)
        } else {
            bin_search(v, half, t, a)
        }
    }
}



Measured memory_bytes: 6968
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    string s1;
    int len;
    cin>>len>>s;
    if(s.length()>len)
       {s1= s.substr(0,len);
       cout<<s1+"..."<<endl;
       }
    else
        cout<<s;
    return 0;
}


Measured memory_bytes: 3632
/*---Bismillahir Rahmanir Rahim---*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std; 

map <int,int> cnt;
inline void solve()
{
	int m,n,ans=0;
	cin >> n >> m;
	for (int i=0;i<n;i++) {
		int  k; cin >> k;
		while (k--) {
			int  a; cin >> a ; 
			cnt[a]++;
		}
	}
	for (int i=1;i<=m;i++)
		if (cnt[i]==n) ans++;
	cout << ans << endl ; 
}

signed main()
{
	int t=1; // cin>>t;
	while(t--) solve();
	return 0;
}

/*
3 4
2 1 3
3 1 2 3
2 3 2

*/


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll n, k;
	cin >> n >> k;
	cout << ((n-1+k-2) / (k-1)) << endl;
	return 0;
}


Measured memory_bytes: 256
import math
def find(stations, start):
	currentT=stations[start][1]
	currentS=start
	while currentS != len(stations):
		C=stations[currentS][0]
		S=stations[currentS][1]
		F=stations[currentS][2]

		if currentT < S:
			currentT=S
		tmp=math.ceil((currentT-S)/F)
		currentT=S+tmp*F+C
		currentS+=1
	return currentT

N=int(input())
stations=[]
for i in range(N-1):
	stations.append([int(i) for i in input().split()])
for i in range(N-1):
	print(find(stations, i))
print(0)


Measured memory_bytes: 3188