akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);


const int MAX_N=100010;
int par[MAX_N];
int myrank[MAX_N];

void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		myrank[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return;

	//if(myrank[x]<myrank[y]){
	//	par[x]=y;
	//}else{
		par[y]=x;
		//if(myrank[x]==myrank[y])myrank[x]++;
	//}
}

bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int n,q;
	while(cin>>n>>q,n|q){
		vi a(n);
		vi parents(n,-1);
		REP(i,n-1){
			int p;
			cin>>p;
			parents[i+1]=p-1;
		}

		init(n);
		vi marked(n);

		vector<pair<char,int> > queries;
		REP(i,q){
			char c;
			int v;
			cin>>c>>v;
			bool add=true;
			if(c=='M'){
				if(marked[v-1]){
					add=false;
				}else{
					marked[v-1]=1;
				}
			}
			if(add){
				queries.push_back(make_pair(c,v-1));
			}
		}

		REP(i,n){
			if(!marked[i]&&parents[i]!=-1){
				unite(parents[i],i);
			}
		}

		ll ans=0;
		REP(i,queries.size()){
			char c=queries[queries.size()-i-1].first;
			int v=queries[queries.size()-i-1].second;
			if(c=='Q'){
				ans+=find(v)+1;	
			}else if(v!=0){
				unite(parents[v],v);
			}
		}

		cout<<ans<<endl;
	}
}

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

using namespace std;

typedef long long ll;

const int LIM = 55555;

int isprime[LIM+1];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  for(int i=0;i<=LIM;i++) isprime[i] = true;
  isprime[0] = isprime[1] = false;
  for(int i=2;i<=LIM;i++){
    if(isprime[i]){
      for(int j=2*i;j<=LIM;j+=i) isprime[j] = false;
    }
  }
  vector<int> ans;
  for(int p=11;p<=LIM;p+=10){
    if(isprime[p]) ans.push_back(p);
  }
  for(int i=0;i<N-1;i++) cout << ans[i] << " ";
  cout << ans[N-1] << endl;
}

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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> d(n);
	rep(u,n) scanf("%d",&d[u]);

	vector<int> hist(n);
	rep(u,n) hist[d[u]]++;

	int d_min=*min_element(d.begin(),d.end());
	int d_max=*max_element(d.begin(),d.end());

	bool ok=(hist[d_min]<=2);
	if(2*(d_max-d_min)+(hist[d_min]==1?0:1)!=d_max) ok=false;
	for(int x=d_min+1;x<=d_max;x++) if(hist[x]<2) ok=false;
	puts(ok?"Possible":"Impossible");

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int X[]={-1,0,1,2,2,2,1,0,-1,-2,-2,-2};
  int Y[]={2,2,2,1,0,-1,-2,-2,-2,-1,0,1};
  int n,y[100],x[100],rr,r,t,i,j,ny,nx,sy,sx;
  while(scanf("%d %d",&x[0],&y[0]),x[t=0]||y[0]){
    int f[10][10]={0};
    scanf("%d",&n);
    for(i=r=1;i<=n;i++){
      scanf("%d %d",&sx,&sy);
      for(rr=r;rr-t;t++){
	for(j=0;j<12;j++){
	  nx=x[t]+X[j];
	  ny=y[t]+Y[j];
	  if(nx<0||ny<0||9<nx||9<ny)continue;
	  if(f[ny][nx]==i||abs(ny-sy)>1||abs(nx-sx)>1)continue;
	  f[y[r]=ny][x[r]=nx]=i;
	  r++;
	}
      }
    }
    if(r-t)printf("OK\n");
    else   printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <cstdio>
#include <cstring>
#include <algorithm>
const int MAXN = 600 + 10;
const int MOD = 1e9 + 7;


int f[2][MAXN][MAXN];
int n;
int a[MAXN];
int status[MAXN];
int pwr(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % MOD) {
    if (b & 1) ans = 1ll * ans * a % MOD;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 2 * n; i++) {
    scanf("%d", a + i);
    if (a[i] != -1) {
      status[a[i]] = 1;
    }
  }
  int val = 0;
  for (int i = 1; i <= n; i++) {
    if (a[2 * i - 1] != -1 && a[2 * i] != -1) {
      status[a[2 * i - 1]] = status[a[2 * i]] = -1;
    }
    if (a[2 * i - 1] == -1 && a[2 * i] == -1) val++;
  }

  int cur = 0;
  f[0][0][0] = 1;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 2 * n; i >= 1; i--) {

    
    if (status[i] == -1) continue;
    for (int j = 0; j <= cnt1 + 1; j++) {
      for (int k = 0; k <= cnt2 + 1; k++) {
        f[cur ^ 1][j][k] = 0;
      }
    }
        
    for (int j = 0; j <= cnt1; j++) {
      for (int k = 0; k <= cnt2; k++) {
        if (status[i] == 0) {
          if (j > 0) {
            f[cur ^ 1][j - 1][k] += f[cur][j][k];
            f[cur ^ 1][j - 1][k] %= MOD;
          }
          if (k > 0) {
            f[cur ^ 1][j][k - 1] += 1ll * f[cur][j][k] * k % MOD;
            f[cur ^ 1][j][k - 1] %= MOD;
          }
          f[cur ^ 1][j + 1][k] += f[cur][j][k];
          f[cur ^ 1][j + 1][k] %= MOD;
        } else {
          if (j > 0){
            f[cur ^ 1][j - 1][k] += f[cur][j][k];
            f[cur ^ 1][j - 1][k] %= MOD;
          }
          f[cur ^ 1][j][k + 1] += f[cur][j][k];
          f[cur ^ 1][j][k + 1] %= MOD;
        }
      }
    }
    if (status[i] == 0) cnt1++;
    else cnt2++;
    cur ^= 1;
  }
  
  int ans = f[cur][0][0];
  for (int i = 1; i <= val; i++) {
    ans = 1ll * ans * i % MOD;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 3072
n = int(input())
s = input()
e = [0] * n
w = [0] * (n + 1)
if s[0] == 'E':
        e[0] = 1
else:
        e[0] = 0
w[0] = 0
if s[0] == 'W':
        w[1] = 1
else:
        w[1] = 0
for i in range(1, n):
    if s[i] == 'E':
        e[i] = e[i - 1] + 1
        w[i + 1] = w[i]
    else:
        e[i] = e[i - 1]
        w[i + 1] = w[i] + 1
min = float("inf")
for i in range(n):
    if min > e[-1] - e[i] + w[i]:
        min = e[-1] - e[i] + w[i]
print(min)

Measured memory_bytes: 73792
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let mut a: i64 = input.next();
    let mut x: i64 = 1;
    let mut h: i64 = 0;
    for _ in 0..n - 1 {
        let t: i64 = input.next();
        if a < t {
            if h == -1 {
                h = 0;
                x += 1;
            } else {
                h = 1;
            }
        }
        if a > t {
            if h == 1 {
                h = 0;
                x += 1;
            } else {
                h = -1;
            }
        }
        a = t;
    }
    println!("{}", x);
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
int n;
map<ll, int> mp;
void upd(ll &x, ll &y, ll z)
{
    if (z >= x)
    {
        y = x;
        x = z;
    }
    else if (z > y)
    {
        y = z;
    }
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll x;
        scanf("%lld", &x);
        mp[x]++;
    }
    ll x = 0, y = 0, ans = 0;
    for (auto it : mp)
    {
        if (it.second >= 2)
        {
            upd(x, y, it.first);
        }
        if (it.second >= 4)
        {
            ans = max(ans, it.first * it.first);
        }
    }
    ans = max(ans, x * y);
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
    int n; cin >> n;
    double cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 2 == 1) cnt++;
    }
    cout << cnt / n << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = Counter(a)
ma = a[-1]

check = [True] * (ma+1)

ans = 0
for i in range(n):
    if check[a[i]]:
        if b[a[i]] == 1:
            ans += 1
            
        for j in range(a[i],ma+1,a[i]):
            check[j] = False
            
print(ans)

Measured memory_bytes: 120488
import java.util.*;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B=sc.nextInt();
		int C=1;
		int count=0;
		while(true) {
			if(B==1)break;
			C +=(A-1);
			count++;
			if(C>=B)break;
		}
		System.out.println(count);
	}
}



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

int main() {
    string s, t;
    cin>>s>>t;
    int DP[s.size()][t.size()];
    if(s[0] == t[0]) {
        DP[0][0] = 1;
    }
    else DP[0][0] = 0;
    for(int i=1;i<t.size();++i){
        if(s[0] == t[i]){
            DP[0][i] = 1;
        }
        else {
            DP[0][i] = DP[0][i-1];
        }
    }
    for(int i=1;i<s.size();++i){
        if(s[i] == t[0]){
            DP[i][0] = 1;
        }
        else{
            DP[i][0] = DP[i-1][0];
        }
    }
    for(int i=1;i<s.size();++i){
        for(int j=1;j<t.size();++j){
            if(s[i]==t[j]){
                DP[i][j] = DP[i-1][j-1]+1;
            }
            else {
                DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
            }
        }
    }
    /**
    for(int i=0;i<s.size();++i){
        for(int j=0;j<t.size();++j){
            cout<<DP[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    **/
    int x = s.size()-1;
    int y = t.size()-1;
    int ansnum = DP[x][y];
    string ans = "";
    while(ansnum>0){
        while(DP[x-1][y]>=ansnum & x>0) {
            x--;
        }
        while(DP[x][y-1]>=ansnum & y>0) {
            y--;
        }
        ansnum--;
        ans += s[x];
        x--;
        y--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;

ll factorial(ll n) {
	ll ret = 1;
	for (ll i = 2; i <= n; i++) {
		ret = (ret*i) % mod;
	}
	return ret;
}

int main() {
	ll N, M;
	cin >> N >> M;
	
	if (N > M + 1 || M > N + 1) {
		cout << 0 << endl;
		return 0;
	}

	if (N != M) {
		cout << factorial(N)*factorial(M) % mod << endl;
	}
	else {
		cout << (((2 * factorial(N))% mod)*factorial(M)) % mod << endl;
	}
}

Measured memory_bytes: 256
x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

ab=[]
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])

if len(ab)>k:
    ab.sort(reverse=True)
    ab=ab[:k]
else:
    ab.sort(reverse=True)

ans=[]
for i in range(len(ab)):
    for j in range(z):
        ans.append(ab[i]+c[j])
ans.sort(reverse=True)

for i in range(k):
    print(ans[i])



Measured memory_bytes: 214664
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll n,arr[3005];
ll dp[3005][3005];
bool pres[3005][3005];
ll answer(ll l,ll r){
	if(r<l) return 0;
	if(pres[l][r]) return dp[l][r];
	int turn = (n - (r-l+1))%2;
	ll ans;
	if(turn==0){
		//taro
		ans=max(arr[l]+answer(l+1,r),arr[r]+answer(l,r-1));
	}else{
		//jiro
		ans=min(-arr[l]+answer(l+1,r),-arr[r]+answer(l,r-1));
	}
	pres[l][r]=true;
	return dp[l][r]=ans;
}
void solve(ll caseno){
	ll i,j;
	cin>>n;
	fo(i,0,n) cin>>arr[i];
	mset(pres,0);
	ll ans=max(arr[n-1]+answer(0,n-2),arr[0]+answer(1,n-1));
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


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

const int N=55, mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int mul(int x,int y) {return (LL)x*y%mod;}

inline void add1(int &x,int y) {x=add(x,y);}

int n,f[N][N],c[N][N],g[N][N];

int main() {
    cin>>n;
    f[1][0]=f[1][1]=1;
    for(int i=0;i<=n;i++) c[i][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=i;j++)
            c[i][j]=add(c[i-1][j-1],c[i-1][j]);
    for(int i=1;i<n;i++)
        for(int j=0;j<=i;j++) if(f[i][j])
            for(int x=0;x+i<=n;++x)
                for(int y=0;x+y+i<=n;++y) if((x+y) && (x+y>=j) && (!((x+y-j)&1)))
                    add1(f[i+x+y][abs((x+y-j)/2+j-x)],mul(f[i][j],mul(c[i+x+y][x+y],c[x+y][x])));
    cout<<f[n][0]<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,i;
    char op; 
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+') {
            printf("%d\n",a+b);
        }
        else if(op=='-') {
            printf("%d\n",a-b);
        }
        else if(op=='*') {
            printf("%d\n",a*b);
        }
        else if(op=='/'){ 
            printf("%d\n",a/b);
        }
        else if(op=='?') {
            break;
        } 
    } 
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i) --)

#define endl '\n'
#define all(x) x.begin(),x.end()
#define mp make_pair
#define ll long long
#define ld long double
#define pb push_back

#define M 1000000007

#define pi 3.1415926535897932384626433832795028
#define F first
#define S second
int gcd(int a,int b){
	while (a&&b)a>b?a%=b:b%=a;
	return a+b;
}
ll lcm(ll a, ll b){
	return (a*b)/gcd(a,b);
}
ll fast_exp(ll base, ll exp){
	ll res = 1;
	while(exp>0){
		if(exp%2==1) res = ((res%M)*(base%M))%M;
		base = ((base%M)*(base%M))%M;
		exp/=2;
	}
	return res%M;
}
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
int main(){
	std::ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int A[n];
	rep(i,n)
	cin>>A[i];

	int num ;
	ll ans = INFL;
	for(num = -100 ; num<=100 ; num++){
		ll temp = 0;
		rep(i,n){
			temp += (A[i] - num)*(A[i]-num);
		}
		ans = min(ans,temp);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, P;
	cin >> n >> P;
	string s;
	cin >> s;
	vector<long long> pow;
	if(P == 2 || P == 5) {
		long long ans = 0;
		for(int i = 0; i < n; ++i) {
			if((s[i] - '0') % P == 0) {
				ans += i + 1;
			}
		}
		cout << ans << '\n';
		return 0;
	}
	pow.resize(n + 1);
	pow[0] = 1;
	for(int i = 1; i <= n; ++i) {
		pow[i] = pow[i - 1] * 10 % P;
	}
	auto power = [&] (long long x, long long t) {
		long long ret = 1;
		for(; t; t >>= 1, x = x * x % P) {
			if(t & 1) {
				ret = ret * x % P;
			}
		}
		return ret;
	};
	long long sum = 0;
	vector<long long> cnt;
	cnt.resize(P);
	cnt[0] = 1;
	long long ans = 0;
	for(int i = 1; i <= n; ++i) {
		sum = (sum * 10 + s[i - 1] - '0') % P;
		ans += cnt[sum * power(pow[i], P - 2) % P];
		++cnt[sum * power(pow[i], P - 2) % P];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 2196
n,k = map(int, input().split())
P = list(map(int, input().split()))
PP = [(i+1)/2 for i in P]
ans = 0
ttl = 0
for i,p in enumerate(PP):
    ttl += p
    if i >= k:
        ttl -= PP[i-k]
    ans = max(ttl, ans)
print(ans)

Measured memory_bytes: 25060
a, b = map(int, input().split())

# b -= a
# counter = 1
# while b > 0:
#     b -= a - 1
#     counter += 1

# print(counter)

sum_tap = 1

for i in range(100):
    if sum_tap >= b:
        print(i)
        break
    sum_tap += a - 1



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

int main()
{
    int n;
    cin>>n;
    long long a;
    long long ans=0;
    cin>>a;
    long long b=a;
    while(n>1)
    {
        cin>>a;
        if(a>b)
        {
            b=max(a,b);
        }
        if(a<b)
        {
            ans+=b-a;
            b=max(a,b);
        }
        n--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
"""
最短距離が2であるようなノードの組み合わせは、最高で(N-1)C2個存在する。
そこで、この(N-1)C2個の組み合わせがある状態をデフォルトとして、K個になるまで辺を増やしていく。
"""

N,K = map(int,input().split())
if K > (N-1)*(N-2)//2:
    print(-1)
    exit()

edges = []
for i in range(2,N+1):
    edges.append((str(1),str(i)))

rest = (N-1)*(N-2)//2 - K
for i in range(2,N+1):
    for j in range(i+1,N+1):
        if rest == 0:
            break
        else:
            edges.append((str(i),str(j)))
            rest -= 1
    else:
        continue
    break
print(len(edges))
for edge in edges:
    print(" ".join(edge))


Measured memory_bytes: 74960
n,k = list(map(int, input().split()))
r,s,p = list(map(int, input().split()))
t = input()
point = {'r':r,'s':s,'p':p}
ans = 0
d = [] #出した手の履歴
win = {'r':'p', 's':'r', 'p':'s'} #キーの手に勝つ手を返す
lose = {'r':'s', 's':'p', 'p':'r'} #キーの手に負ける手を返す
for i in range(k):
    d.append(win[t[i]])
    ans += point[win[t[i]]]
for i in range(k, n):
    if d[-k]!=win[t[i]]:
        d.append(win[t[i]])
        ans += point[win[t[i]]]
    else:
        if win[t[min(i+k, n-1)]]==t[i]:
            d.append('')
        else:
            d.append(lose[t[min(i+k, n-1)]])
print(ans)

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,s;
  cin>>n>>s;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  int i=0,j=0;
  int sum=0;
  int ans=inf;
  while(i<n){
    while(i<n&&sum<s){
      sum+=a[i];
      i++;
    }
    if(sum>=s)ans=min(ans,i-j);
    while(sum>=s){
      sum-=a[j];
      j++;
      if(sum>=s) ans=min(ans,i-j);
    }
  }

  cout<<(ans==inf?0:ans)<<endl;

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int A[200001];
int root(int x){
  if(A[x]==x) return x;
  else return A[x]=root(A[x]);
}
int unite(int x,int y){
  x=root(x),y=root(y);
  if(x!=y) A[x]=y;
}
int main(){
    int n,m,k,l,z=1;
    vector<int> L[100001];
    cin>>n>>m;
    rep(i,n){
        cin>>k;
        rep(j,k) cin>>l,L[l].push_back(i);
    }
    rep(i,n) A[i]=i;
    rep(i,m){
        int B[100001],b=0;
        for(auto j:L[i+1]) B[b]=j,b++;
        rep(j,b) unite(B[0],B[j]);
    }
    rep(i,n) if(root(0)!=root(i)) z=0;
    if(z) cout<<"YES";
    else cout<<"NO";
}

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

bool IsReversible(int n){
    bool reversible = true;
    //↓後でco
    //int n1 = n;
    //↑後でco
    vi r;
    r.clear();
    while(n>0){
        r.push_back(n%10);
        n /= 10;
    }
    int l = r.size();
    rep(0,i,l/2){
        if(r[i]!=r[l-i-1]){
            reversible = false;
            break;
        }
    }
    //co after
    //if(reversible) cout << n1 << endl;
    //co after
    return reversible;
}

int main(){
    int a,b; cin>>a>>b;
    int res = 0;
    rep(a,i,b+1){
        bool reversible = IsReversible(i);
        if(reversible) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int n,j,data[100]; 

 	  scanf("%d",&n);
 	            
 	 for(j=0;j<n;++j){
	  scanf("%d",&data[j]);
	 }	 
	
	 for(j=n-1;j>=0;j--) {
      if ( j!= n-1 ) printf(" ");
      printf("%d",data[j]);
     } 
     
	 printf("\n");
	      
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	vector<string>title(n);
  	vector<int>num(n);
  	int allsum=0;
    for(int i=0;i<n;i++){
    	cin>>title.at(i)>>num.at(i);
      	allsum=allsum+num.at(i);
    }
  	string x;
  	cin>>x;
  	int sum=0;
  	for(int i=0;i<n;i++){
      sum=sum+num.at(i);
      if(title.at(i)==x){
        	break;
        }
    }
  	cout<<allsum-sum<<endl;
  	

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <map>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF 1e+8
typedef pair<string, int> P;
typedef long long ll;
typedef priority_queue<int> pq;

map<string, int> data;
int direc[4] = {1, -1, 4, -4};

void bfs(){
	data["01234567"] = 1;
	queue<P> que;
	que.push(P("01234567", 0));

	while(!que.empty()){
		P p = que.front();
		que.pop();
		string panel = p.first;
		int now = p.second;

		rep(i, 4){
			if(now+direc[i] >= 0 && now+direc[i] < 8){
				if((now == 3 && direc[i] == 1) || (now == 4 && direc[i] == -1))continue;
				string next = panel;
				next[now] = panel[now+direc[i]];
				next[now+direc[i]] = panel[now];

				if(data[next] != 0)continue;
				que.push(P(next, now+direc[i]));
				data[next] = data[panel]+1;
			}
		}
	}
}



int main(void){
	string a;
	bfs();
	while(cin >> a){
		string S, L;
		S += a;
		for(int i = 1; i <= 7; i++){
			cin >> L;
			S += L;
		}
		cout << data[S]-1 << endl;
	}


	return 0;	
}

Measured memory_bytes: 3452
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

lint solve(vector<lint> values) {
  const int n = values.size();
  lint result = 0;
  sort(values.begin(), values.end());
  for (int i = n - 1; i - 1 >= 0; --i) {
    const int nbig = n - i;
    lint rep_count = (values[i] - values[i - 1]) / (n + 1);
    result += rep_count * nbig;
    for (int j = i; j < n; ++j)
      values[j] += rep_count * (-n + nbig - 1);
    for (int j = 0; j < i; ++j)
      values[j] += rep_count * nbig;
    for (int j = 0; j + 1 < n; ++j)
      assert(values[j] <= values[j + 1]);
  }
  if (values[0] > n) {
    lint rep_count = (values[0] - n) / 1;
    result += rep_count * n;
    for (int j = 0; j < n; ++j)
      values[j] += rep_count * (-1);
  }
  while (*max_element(values.begin(), values.end()) >= n) {
    int max_id = max_element(values.begin(), values.end()) - values.begin();
    for (int i = 0; i < n; ++i) {
      if (i == max_id) values[i] -= n;
      else ++values[i];
    }
    ++result;
  }
  return result;
}

int main() {
  int n;
  cin >> n;
  vector<lint> values(n);
  for (int i = 0; i < n; ++i)
    cin >> values[i];
  cout << solve(values) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long INF = 1e18;

int main(){
    long long a,b,k,t;
    cin>>a>>b>>k;
    if(a-k >= 0){
        cout<<a-k<<" ";
        t=a-k;
    }else{
        cout<<0<<" ";
        t=k-a;
    }
    if(a > k){
        cout<<b<<endl;
    }
    else if(b - t>= 0){
        cout<<b-t<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll num[ten52];
//ll num[10][10];
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;

int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,d;
    long long int m,n,o,i,j,k=0,money;
    long long int a,a1=0,a2=0,a3=0,ar,as,at1;
    string s;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>n>>m;
    while(n!=0)
    {
        n/=m;
        a++;
    }
    cout<<a;
    return 0;
}





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

int main() {
    int n,m;
    cin>>n>>m;
    int a[n]={0};
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        a[x-1]++;
        a[y-1]++;
    }
    for(int i=0;i<n;i++)cout<<a[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 3652
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    912 Hours of Solitude
    Quarantine_Day : 38
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 90

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

    ll n; cin>>n;
    ll ans = LONG_LONG_MAX;
    while(n--){
        ll a; cin>>a;
        ll k = 0;
        while(!(a&1)){
            k++;
            a >>= 1;
        }
        ans = min(ans, k);
    }
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int d; cin >> d;
    cout << "Christmas ";
    rep(i, 25 - d) {
        cout << "Eve ";
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt64(ReadLine());
        var min = 11;
        for(var i = 1L; i * i <= num; i++)
        {
            if (num % i != 0) continue;
            var b = num / i;
            var max = Max(i.ToString().Length, b.ToString().Length);
            min = Min(min, max);
        }
        WriteLine(min);
    }
}


Measured memory_bytes: 11220
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_131
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];

            var max = (N - 1) * (N - 2) / 2;
            var mnum = max - K + N - 1;
            if (max < K)
            {
                WriteLine("-1");
                return;
            }
            var cnt = 0;
            WriteLine(mnum);
            for (var i = 0; i < N; ++i)
            {
                for (var j = i; j < N - 1; ++j)
                {
                    WriteLine($"{i + 1} {j + 2}");
                    ++cnt;
                    if (mnum <= cnt)
                    { return; }
                }
            }
        }
    }
}

Measured memory_bytes: 13396
N, K = map(int, input().strip().split())
mdict = {}
for a in input().strip().split():
  a = int(a)
  if a in mdict:
    mdict[a] += 1
  else:
    mdict[a] = 1

total = 0
for i, (k, v) in enumerate(sorted(mdict.items(), key=lambda x: -x[1])):
  if i >= K:
    total += v

print(total)

Measured memory_bytes: 41120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] D = new int[N][2];

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

		for (int i = 0; i < D.length - 2; i++) {
			if (D[i][0] == D[i][1] && D[i + 1][0] == D[i + 1][1] && D[i + 2][0] == D[i + 2][1]) {
				System.out.print("Yes");
				return;
			}
		}

		System.out.print("No");
	}

}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    int cnt1 = 0;
    int cnt2 = 0;

    for(int i = 0;i < n;i++){
        if(s[i]-'0' == i%2){
            cnt1++;
        }else{
            cnt2++;
        }
    }

    cout << min(cnt1, cnt2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int H, W;
	cin >> H >> W;

	int x = 0;
	for( int i = 0; i < H; ++i ) {
		for( int j = 0; j < W; ++j ) {
			char ch;
			cin >> ch;

			x += (ch != '.');
		}
	}

	cout << (x == H+W-1 ? "Possible" : "Impossible") << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	a := make([][3]int, 3)
	for i := range a {
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}
	var n int
	fmt.Scan(&n)
	b := make([]int, n)
	for k := range b {
		fmt.Scan(&b[k])
		for i := range a {
			for j := range a[i] {
				if a[i][j] == b[k] {
					a[i][j] = 0
				}
			}
		}
	}

	for i := 0; i < 3; i++ {
		if a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0 ||
			a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0 {
			fmt.Println("Yes")
			return
		}
	}
	if a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0 ||
		a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int m=0,f=0,b=0,kari=0;
  cin>>m>>f>>b;
  kari=b-m;
  if(kari>f) printf("NA\n");
  else if(kari<=0)printf("0\n");
  else cout<<kari<<endl;
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a[5];
    for(int i=0; i<5; i++)  cin >> a[i];
    sort(a,a+5);
    cout << a[4];
    for(int i=3; i>=0; i--)
    cout << " " << a[i];
    cout << endl;
}


Measured memory_bytes: 3128
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
LL x[50], y[50];
int main() {
	int N, K;
	cin >> N >> K;
	vector<LL> vx, vy;
	rep(i, N) {
		cin >> x[i] >> y[i];
		vx.push_back(x[i]);
		vy.push_back(y[i]);
	}
	sort(ALL(vx));
	sort(ALL(vy));
	LL ans = 1LL << 62;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int l = k + 1; l < N; l++) {
					int cnt = 0;
					for (int m = 0; m < N; m++) {
						if (vx[i] <= x[m] && x[m] <= vx[j] && vy[k] <= y[m] && y[m] <= vy[l]) cnt++;
					}
					if (cnt >= K) ans = min(ans, (vx[j] - vx[i])*(vy[l] - vy[k]));
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
sa=0
sb=sum(a)
ans=float("inf")
for i in range(n-1):
    sa+=a[i]
    sb-=a[i]
    ans=min(ans,abs(sa-sb))
print(ans)

Measured memory_bytes: 25844
s = gets.chomp

while !s.empty? do
  if s[-5, 5] == "dream" || s[-5, 5] == "erase"
    s[-5, 5] = ""
  elsif s[-7, 7] == "dreamer"
    s[-7, 7] = ""
  elsif s[-6, 6] == "eraser"
    s[-6, 6] = ""
  else
    puts 'NO'
    exit
  end
end

puts 'YES'


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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



const int maxcnt = 13000;

char dp[80][80][maxcnt];


int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    auto start = clock();


    int n, m; cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m, 0)), b(n, vector<int>(m, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> b[i][j];
            if (a[i][j] < b[i][j]) swap(a[i][j], b[i][j]);
            a[i][j] -= b[i][j];
        }
    }
    dp[0][0][a[0][0]] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            for (int k = 0; k < maxcnt; ++k) {
                if (dp[i][j][k]) {
                    if (j + 1 < m) {
                        dp[i][j + 1][abs(k - a[i][j + 1])] = 1;
                        if (k + a[i][j + 1] < maxcnt) {
                            dp[i][j + 1][k + a[i][j + 1]] = 1;
                        }
                    }
                    if (i + 1 < n) {
                        dp[i + 1][j][abs(k - a[i + 1][j])] = 1;
                        if (k + a[i + 1][j] < maxcnt) {
                            dp[i + 1][j][k + a[i + 1][j]] = 1;
                        }
                    }
                }
            }
        }
    }
    for (int k = 0; k < maxcnt; ++k) {
        if (dp[n - 1][m - 1][k]) {
            cout << k << endl;
            return 0;
        }
    }


    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

Measured memory_bytes: 80640
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
  print('NO')
  exit(0)
if abs(a-b)%(v-w) == 0:
  f = abs(a-b)//(v-w)
else:
  f = abs(a-b)//(v-w)+1
if f <= t:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9196
N,M= list(map(int, input().split()))
li=[list(map(int,input().split())) for _ in range(M)]
p= list(map(int, input().split()))
ans=0
s=[0 for _ in range(N)]

def hoge(s,N,ans):
    if sum(s)==N:
        print(ans)
        exit(0)
    for i in range(N-1,-1,-1):
        if s[i]==0:
            s[i]=1
            break
        else:
            s[i]=0
    return s

for i in range(2**N):
    for i in range(M):
        tmp=0
        for k in li[i][1::]:
            if s[k-1]==1:
                tmp+=1
        if tmp%2!=p[i]:
            break
    else:
        ans+=1
    s=hoge(s,N,ans)

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

using namespace std;

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

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

    for (int i = 0; i < n - 1; i++) {
        a1[i + 1] = a1[i] + a1[i + 1];
    }
    for (int i = n - 1; i > 0; i--) {
        a2[i - 1] = a2[i] + a2[i - 1];
    }

    int ans = a1[0] + a2[0];
    for (int i = 1; i < n; i++) {
        ans = max(ans, a1[i] + a2[i]);
    }
    cout << ans << endl;

    return 0;
}

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

	scanf("%d",&natural);

	if (natural >= 64) {
		printf("64\n");
	}else if (natural >= 32) {
		printf("32\n");
	}
	else if (natural >= 16) {
		printf("16\n");
	}
	else if (natural >= 8) {
		printf("8\n");
	}
	else if (natural >= 4) {
		printf("4\n");
	}
	else if (natural >= 2) {
		printf("2\n");
	}
	else {
		printf("1\n");
	}
	return 0;
	}

Measured memory_bytes: 128
N = int(input())
A = list(map(str, input().split()))
l_1 = []
l_2 = []
ans = []

for cha in A:
    l_1.append([cha[:1], int(cha[1:])])
    l_2.append([cha[:1], int(cha[1:])])

def BubbleSort(C, N):
  for i in range(N):
    nums = []
    for j in range(i+1, N):
      nums.append(j)
    nums.sort(reverse=True)
    for num in nums:
      if C[num][1] < C[num-1][1]:
        C[num], C[num-1] = C[num-1], C[num]
    a = []
    for cha in C:
      a.append(''.join(map(str, cha)))
  ans.append(' '.join(map(str, a)))
  print(ans[0])
  print('Stable')
  
BubbleSort(l_1, N)

def SelectionSort(D, N):
  for i in range(N):
    index = i
    for j in range(i, N):
      if D[j][1] < D[index][1]:
        index = j
    D[i], D[index] = D[index], D[i]
  b = []
  for cha in D:
    b.append(''.join(map(str, cha)))
  ans.append(' '.join(map(str, b)))
  if ans[0] == ans[1]:
    print(ans[1])
    print('Stable')
  else:
    print(ans[1])
    print('Not stable')

SelectionSort(l_2, N)


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  vector<long long> s(N + 1, 0);
  for (int i = 0; i < N; i++){
    s[i + 1] = s[i] + a[i];
  }
  long long sum = s[N];
  long long m = 1e15;
  for (int i = 1; i < N; i++){
    m = min(m, abs(s[i] - (sum - s[i])));
  }
  cout << m;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <bitset>

using namespace std;

int n;
vector<int> graph[500000];
int col[500000];
int sz[500000];

void dfs(int v)
{
    col[v] = 1;
    sz[v] = 1;
    for (auto u : graph[v])
    {
        if (col[u] == 0)
        {
            dfs(u);
            sz[v] += sz[u];
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    if (n % 2 == 1)
    {
        cout << "First";
        return 0;
    }
    for (int i = 0; i < n - 1; i++)
    {
        int v, u;
        cin >> v >> u;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0;
        for (auto u : graph[i])
        {
            if (min(sz[u], sz[i]) % 2 == 1) cnt++;
        }
        if (cnt != 1)
        {
            cout << "First";
            return 0;
        }
    }
    cout << "Second";
}


Measured memory_bytes: 17536
#include<stdio.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>

int warizan(int a, float tax)
{
    return a*tax;
}

int main(void)
{
    int A, B, i, flag=0;
    scanf("%d%d", &A, &B);
    for(i=1; i<1009; i++){
        if(A==warizan(i,0.08) && B==warizan(i,0.10)){
            flag=1;break;
        }
    }
    if(flag==1){
        printf("%d", i);
    }else{
        printf("%d", -1);
    }

    return 0;
}

Measured memory_bytes: 1708
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ls = readLine()!!.split(Regex("""\s+""")).map { it.toInt() }.sorted()
    val sum = (0 until n).sumBy { i ->
        val idx = i * 2
        minOf(ls[idx], ls[idx + 1])
    }

    println(sum)
}

fun minOf(a: Int, b: Int) = if (a < b) a else b

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll x,y;
    cin>>x>>y;
    ll ans=x+y/2;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main() {
	double a, b, c, C, S, L, h;
	cin >> a >> b >> C;
	c = C/180*acos(-1);
	S = 0.5 * a * b * sin(c);
	L = a + b + sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c));
	h = b * sin(c);
	cout << setprecision(15) << S << setprecision(15) << " " << L << setprecision(15) << " " << setprecision(15) << h << endl;
		return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<queue>
#include<set>
using namespace std;

#define INF 20000000

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

typedef pair<int, int> P;

int main() {
	char map[1002][1002];
	static int smp[1002][1002];
	int h, w, n, c=0, x, y, ans=0;
	queue<P> q;
	cin >> h >> w >> n;
	for(int i=0; i<h+2; ++i) for(int j=0; j<w+2; ++j) {
		map[i][j] = 'X'; smp[i][j] = INF;
	}
	for(int i=1; i<=h; ++i) for(int j=1; j<=w; ++j) {
		cin >> map[i][j]; smp[i][j] = INF;
		if(map[i][j]=='S') {x = j; y = i;}
	}
	q.push(P(x, y)); smp[y][x] = 0;
	while(1) {
		x = q.front().first;
		y = q.front().second;
		q.pop();
		if(map[y][x]=='1'+c) {
			ans += smp[y][x]; c++;
			if(c==n) break;
			while(!q.empty()) q.pop();
			for(int i=1; i<=h; ++i) for(int j=1; j<=w; ++j) smp[i][j] = INF;
			smp[y][x] = 0;
		}
		for(int i=0; i<4; ++i) {
			if(map[y+dy[i]][x+dx[i]]!='X'&&smp[y+dy[i]][x+dx[i]]==INF) {
				q.push(P(x+dx[i], y+dy[i]));
				smp[y+dy[i]][x+dx[i]] = smp[y][x]+1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

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

  while(a>=b && k>0){
    b *= 2;
    k--;
  }
  while(b>=c && k>0){
    c *= 2;
    k--;
  }
  if(a<b && b<c) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3680