akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

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

struct edge{ll to, cost;};
vector<edge> G[222];
vector<int> UG[222];
vector<int> color;

vector<ll> dijkstra(ll s,ll n,vector<edge> G[]){
    vector<ll> d={};
    d.resize(n);
    REP(i,n) d[i]=LINF;
    // 最短距離firstが小さい順に取り出せるようにする
    priority_queue<LP, vector<LP>, greater<LP>> que;
    d[s] = 0;// スタート地点を0で初期化
    que.push(LP(0,s));// キューに初期位置のコスト、初期位置をpush

    while(que.size()){
        LP p = que.top();que.pop(); // p: 今の{最短距離、頂点番号}
        ll v = p.second;//今の頂点番号
        if(d[v] < p.first) continue;// 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離
        for(int i=0; i < G[v].size();i++){// 今の頂点に隣接する頂点を調べる
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){// 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト
                d[e.to] = d[v] + e.cost;// 歴代最小距離の更新
                que.push(P(d[e.to],e.to));// 更新した遷移先の頂点をキューに突っ込む
            }
        }
    }
    return d;
}

bool dfs(int v, int cur=0){
    color[v] = cur;
    for(auto nv:UG[v]){
        if(color[nv]!=-1){
            if(color[nv]==cur) return false;
            continue;
        }
        if(!dfs(nv,1-cur)) return false;
    }
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s;

    ll ans = -1;
    REP(i,N){
        cin >> s;
        REP(j,N) if(s[j] == '1'){
            UG[i].push_back(j);
            UG[j].push_back(i);
            edge e;
            e.to = j;
            e.cost = 1;
            G[i].push_back(e);
            e.to = i;
            G[j].push_back(e);
        }
    }

    REP(v,N){
        auto dist = dijkstra(v, N, G);
        for(auto d : dist) chmax(ans, d);
    }
    color.assign(N,-1);
    bool bipartite =true;
    REP(v,N){
        if(color[v]!=-1) continue;
        if(!dfs(v)) bipartite = false;
    }
    if(bipartite) cout << ans + 1 << endl;
    else cout << -1 << endl;
}

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

int main() {
  string w;
  cin >> w;

  vector<int> arr(26, 0);
  for(int i=0; i<w.size(); i++) {
    char c = w[i];
    arr[c-'a']++;
  }

  for(int i=0; i<26; i++) {
    if(arr[i] % 2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i<a.size(); i++) {
    if (a[i] != b[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

int main()
{
	long long int i,j,k,n,m;
	long long int x,y,z;
	long long int w;
	cin>>n>>w;
	int wt[n];
	int va[n];
	for(i=0;i<n;i++)
	{
		cin>>wt[i]>>va[i];
	}
	
	long long int dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=w;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=wt[i-1])
				dp[i][j]=max(dp[i][j], va[i-1] + dp[i-1][j-wt[i-1]]);
		}
	}
	/*for(i=0;i<=n;i++)
	{	
		for(j=0;j<=w;j++)
		{
			cout<<dp[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	cout<<dp[n][w]<<"\n";
	return 0;
}



Measured memory_bytes: 79104
s=input()
if len(s)!=4:
    print("NA")
else:
    if int(s[:2])<=12 and int(s[:2])>=0 and int(s[2:])<=12 and int(s[2:])>=0:
        if int(s[:2])==0 and int(s[2:])==0:
            print("NA")
        elif int(s[:2])==0 and int(s[2:])!=0:
            print("YYMM")
        elif int(s[:2])!=0 and int(s[2:])==0:
            print("MMYY")
        else:
            print("AMBIGUOUS")
    else:
        if int(s[:2])<=12 and int(s[:2])>0 and int(s[2:])>12 and int(s[2:])<100:
            print("MMYY")
        elif int(s[:2])>12 and int(s[:2])<100 and int(s[2:])<=12 and int(s[2:])>0:
            print("YYMM")
        else:
            print("NA")

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


int main() {
  int n,a,b;
  cin >>n>>a>>b;
  int ans=0;
  
  for(int i=1;i<=n;++i){
    int ti = i;
    int sum=0;
    while(ti>0){
      sum+=(ti%10);
      ti/=10;
    }
    
    if(sum >= a && sum <= b) ans+=i;
  }
   
  cout << ans << endl;

}


Measured memory_bytes: 764
/*
 * src.cpp
 *
 *  Created on: 2016/09/03
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

char S[108];

int cnt['z'+1];

void solve(){
	FOR(i,'a','z'+1){
		if (cnt[i]%2==1){
			printf("No\n");
			return;
		}
	}
	printf("Yes\n");
}

int main(){
	scanf("%s",S);
	int len=strlen(S);
	REP(i,len){
		cnt[S[i]]++;
	}
	solve();
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, M;

bool B[100001];

struct UnionFind {vector<int> par, cnt;
	UnionFind(int NV) { par.clear(); cnt.resize(NV, 1); rep(i, NV) par.push_back(i); }
	void reset() { rep(i, cnt.size()) cnt[i] = 1; rep(i, par.size()) par[i] = i; }
	int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
	void operator()(int x, int y) {x = operator[](x); y = operator[](y);
		if (x != y) par[x] = y, cnt[y] += cnt[x];}};

void solve(){
	UnionFind uf(M + 1);
	rep(i, N){
		int K;
		cin >> K;
		int l;
		rep(j, K){
			int L;
			cin >> L;
			B[L] = true;
			if(!j) 
				l = L;
			else{
				uf(l, L);
			}
		}
	}
	int f = 0;
	reps(i, M){
		if(B[i]){
			if(f == 0)
				f = i;
			else if(uf[f] != uf[i]){
				cout << "NO" << endl;
				return;
			}
		}
	}
	cout << "YES" << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	solve();
	return 0;
}


Measured memory_bytes: 1276
/*
 
dunjen_master
 
*/
 
 
 
 
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
/* ordered_set A;
   A.insert(x);
   A.erase(x);
   A.order_of_key(x) // no of elements less than (<) x
   *A.find_by_order(k-1) // kth smallest element
*/
// int n;
// ll dp[200005][205];
// ll ans=0;
// int a[200005];
// int req;
// ll neg=-1e15;
 
 
// ll fun(int indx,int last){
//    // cout<<indx<<" "<<last<<" "<<req<<endl;
//     if(indx==n){
//         if(last==req){
//             return 0;
//         }else{
//             return neg;
//         }
//     }
 
//     if(dp[indx][last]!=-1){
//         return dp[indx][last];
//     }
    
//     ll ans=neg;
 
//     ans=max(ans,fun(indx+1,last));
 
//     if(last==0)ans=max(ans,1+fun(indx+1,a[indx]));
//     if(last==a[indx])ans=max(ans,1+fun(indx+1,a[indx]));
//     if(a[indx]==req)ans=max(ans,1+fun(indx+1,a[indx]));
 
//     return dp[indx][last]=ans;
 
 
// }
 
 
int main(){

    int n,k;
    cin>>n>>k;
    set<int>s;
    int ans=0;
    for(int i=1;i<=k;i++){
        int d;
        cin>>d;
        for(int j=1;j<=d;j++){
            int x;
            cin>>x;
            s.insert(x);
        }
    }

    for(int i=1;i<=n;i++){
        if(s.find(i)==s.end())ans++;
    }
    cout<<ans;
return 0;

 
 
    
 
    
 
    
 
 
 
 
 
 
 
 
 
   
 
 
 
    
    
 
    
 
    
 
  
    
 
 
 
    
 
 
    
    
    
    
 
    
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(void)
{
    int a[3] ,i ,k ,b[3], c[3];
     
    scanf("%d %d %d",&a[0] ,&a[1] ,&a[2]);
    
    for(i=0;i<3;i++){
    	b[i] = 0;
    	c[i] = -1;
    }
    
  	for(k=0;k<3;k++){
  		for(i=0;i<3;i++){
  			if(b[k]<a[i] && i!=c[0] && i!=c[1]){
  				b[k]=a[i];
  				c[k] = i;
  			}
  		}
  	}
  		
  		printf("%d %d %d\n",b[2] ,b[1] ,b[0]);
  		
    return 0;
}

Measured memory_bytes: 596
n=int(input())
a=list(map(int, input().split()))
k=len([i for i in a if i%2==1])
y=len([i for i in a if i%4==0])
g=n-k-y
if g:
    if k<=y:print('Yes')
    else:print('No')
else:
    if k<=y+1:print('Yes')
    else:print('No')

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

using namespace std ;
#define   ll long long
#define   null NULL
#define   endl '\n'
#define   mp make_pair
#define   pb push_back
#define   ff first
#define   ss second

ll mod = (ll)(1e9 + 7);
ll inf = (ll)(1e17 + 17);

struct Ava {
	ll f , s ;
};
ll N , W ;
vector <Ava> v ;
// vector <vector/ <int>> dp ;
long long dp[101][100001] ;

long long int rec (ll n , ll wts ) {
	// if (n == 0 || wts == 0) return 0 ;
	if (n == 0)return dp[n][wts] = 0 ;
	if (wts == 0)return dp[n][wts] = 0 ;
	if (dp[n][wts] != -1)return dp[n][wts] ;
	long long int inc = 0 , exc = 0 ;
	if (v[n - 1].f <= wts) inc = v[n - 1].s + rec(n - 1 , wts - v[n - 1].f ) ;
	exc = rec(n - 1 , wts) ;
	return dp[n][wts] = max (inc, exc) ;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> N >> W ;
	v.resize (N) ;
	// int a , b ;
	for (int i = 0 ; i < N ; i++) {
		cin >> v[i].f >> v[i].s ;
	}
	memset(dp, -1 , sizeof dp) ;
	// for (au)
	cout << rec (N, W) ;
	return 0 ;
}

Measured memory_bytes: 82524
n = int(input())
dat = list(map(int,input().split()))

dat = [0] + dat + [0]
total = 0
cur = 0
for i in range(n + 2):
    total += abs(cur - dat[i])
    cur = dat[i]
total += abs(cur)
cur = 0
for i in range(n):
    j = i + 1
    if dat[j-1] < dat[j] < dat[j+1]:
        # 間に挟まれているパターン１
        #print("pat1")
        print(total)
    elif dat[j-1] > dat[j] > dat[j+1]:
        # 間に挟まれているパターン2
        #print("pat2")
        print(total)
    else:
        # この場合は間に挟まれていない
        #print("{0} {1} {2}".format(total, abs(dat[j-1] -dat[j]) , abs(dat[j-1] -dat[j+1])))
        print(total - abs(dat[j-1] -dat[j]) - abs(dat[j] -dat[j+1]) + abs(dat[j-1] - dat[j+1]))


Measured memory_bytes: 65960
#include<stdio.h>
#include<stdlib.h>

int main()
{
    long N,M,Nfact,Mfact,i,j,ans;
    scanf("%ld",&N);
    scanf("%ld",&M);
    Nfact =1;
    Mfact =1;
if(N-M ==1 || N-M == -1  || N-M ==0){
  for(i=1;i<=N;i++){
    Nfact = Nfact * i;
    Nfact = Nfact %(1000000007) ;
    }
  for(j=1;j<=M;j++){
    Mfact = Mfact * j;
    Mfact = Mfact %(1000000007) ;
  }
  ans = Nfact * Mfact;
  if(N-M==0){
    ans = ans *2;
  }
  ans = ans % (1000000007);
  printf("%ld\n",ans);
  return 0;
}else{
  printf("0\n");
  return 0;
}

}


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

int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2-y2+y1 << " "  << y2+x2-x1 << " ";
  cout << x1-y2+y1 << " "  << y1+x2-x1 << endl;
}

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

int factorial(int a){
    if(a==0)return 1;
    if(a==1)return 1;
    return a*factorial(a-1);
}

int main(void){

    int N, Pbuf, Qbuf;
    vector<int> P, Q;
    cin >> N;

    for(int i=0; i<N; i++){
        cin >> Pbuf;
        P.push_back(Pbuf);
    }
    for(int i=0; i<N; i++){
        cin >> Qbuf;
        Q.push_back(Qbuf);
    }

    bool Pfirst = true;

    for(int i=0; i<N; i++){
        if(Q[i] > P[i]){
            break;
        }
        if(P[i] > Q[i]){
            Pfirst = false;
            break;
        }
    }

    int res=0;
    bool endcomparison=false;
    for(int i=0; i<factorial(N); i++){
        endcomparison=true;
        for(i=0; i<N; i++){
            if(P[i]!=Q[i]){
                endcomparison=false;
                break;
            }
        }
        if(endcomparison)break;
        res++;
        if(Pfirst){
            next_permutation(P.begin(), P.end());
        }else{
            next_permutation(Q.begin(), Q.end());
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    ll n, m, q;
    cin >> n >> m >> q;

    vector<vector<ll>> train(n,vector<ll>(n,0));
    vector<vector<ll>> train_sum(n+1,vector<ll>(n+1,0));


    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        l--; r--;
        train[l][r]++;
    }
    for(int i = 1; i < n+1; i++){
        for(int j = 1; j < n+1; j++){
            train_sum[i][j] = train_sum[i][j-1] + train[i-1][j-1];
        }
    }
    for(int i = 1; i < n+1; i++){
        for(int j = 0; j < n+1; j++){
            train_sum[i][j] += train_sum[i-1][j];
        }
    }
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << train_sum[r][r] - train_sum[l-1][r]  << endl;
    }

    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;int n,m,l,x,i,a[1<<18];main(){cin>>n>>m;n*=2;while(cin>>a[i++]);sort(a,a+n);for(i-=2;i>l;i--){while(a[i]+a[l]<m&&l<i-1)l++;if(a[i]+a[l]>=m){a[i]-=m;l++;}}sort(a,a+n);for(i=0;i<n/2;i++)x=max(x,a[i]+a[n-i-1]);cout<<x;}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include<regex>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
char a[2000010];
int sum[2000010];
signed main() {
	int n, b;
	cin >> n >> b;
	cin >> (a + 1);
	ll ans = 0;
	if (b == 2 || b == 5)
	{
		for (int i = 1; i <= n; i++) 
		{
			if ((a[i] - '0') % b == 0)
				ans += i;
		}
		cout << ans << endl;
		return 0;
	}
	int t = 1, temp = 0;
	sum[0] = 1;
	for (int i = n; i >= 1; i--)
	{
		temp = (temp + (a[i] - '0') * t) % b;
		ans += sum[temp];
		sum[temp]++;
		t = t * 10 % b;
	}
	cout << ans << endl;
	return 0;

}







Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#include<bitset>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int>PA;
#define MAX  999999
int main(){
	int n;
	while(cin>>n,n){
	vi v5(20001,0); vi v2(20001,0);
	for(int i=1;i<=6;i++){
		int cnt=pow(5,i);
		for(int j=1;;j++){ if(j*cnt>20000)break;v5[j*cnt]=i;}
		}
	for(int i=1;i<=15;i++){
		int cnt=pow(2,i);
		for(int j=1;;j++){ if(j*cnt>20000)break;v2[j*cnt]=i;}
		}
	int f=0; int d=0;
	for(int i=1;i<=n;i++){
		f+=v5[i];
		d+=v2[i];
		}
	cout<<min(f,d)<<endl;
	}
}

Measured memory_bytes: 3396
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#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 MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main()
{
    int p, q, r; cin >> p >> q >> r;
    cout << min(p+q, min(p+r, r+q)) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//void ckmax(int &x,int y){
//	if (x<y)
//		x=y;
//}
//void ckmin(int &x,int y){
//	if (x>y)
//		x=y;
//}
int main(){
	string s;
	cin>>s;
	if (s.size()&1)
		return puts("No"),0;
	For(i,0,(int)s.size()-1)
		if ("hi"[i%2]!=s[i])
			return puts("No"),0;
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;
s = '#'+ s + '#';


    bool cc = true;
    for(ll i=a;i<c;i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cc=false;
            break;
        }
    }

    for(ll i=b;i<d;i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cc=false;
            break;
        }
    }

    if(!cc){
        cout<<"No"<<endl;
        return 0;
    }

    if(c<d){
        cout<<"Yes"<<endl;
        return 0;
    }else{
//        bool f = false;
//            for (ll i = b; i < d; i++) {
//                if(i+1<n&&s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
//                   cout<<"Yes"<<endl;
//                   return 0;
//                }
//            }
//
//
//            cout<<"No"<<endl;
        for(int i=b;i<=d;i++) if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                puts("Yes");
                return 0;
            }
        puts("No");
        return 0;


    }

    return 0;
}


Measured memory_bytes: 772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

int main(void) {

  int h, w;
  cin >> h >> w;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      string s;
      cin >> s;
      char c = 'A' + j;
      if( s == "snuke" ) cout << c << i+1 << endl;
    }
  }

  return 0;
}

// EOF


Measured memory_bytes: 512
public class Main {
	public static void main(String[] main){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int n = scan.nextInt();
		int[][] A = new int[3][10];
		int[][] B = new int[3][10];
		int[][] C = new int[3][10];
		int[][] D = new int[3][10];
		
		for(int i = 0;i<3;i++){
			for(int j = 0;j<10;j++){
				A[i][j] = 0;
				B[i][j] = 0;
				C[i][j] = 0;
				D[i][j] = 0;
			}
		}
		for(int i = 0; i < n;i++){
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			int v = scan.nextInt();
			if(b == 1){
				A[f-1][r-1] += v;
			}else if(b == 2){
				B[f-1][r-1] += v;
			}else if(b == 3){
				C[f-1][r-1] += v;
			}else if(b == 4){
				D[f-1][r-1] += v;
			}
		}
		for(int i = 0;i<3;i++){
			for(int j = 0;j<10;j++){
				System.out.print(" "+A[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i = 0;i<3;i++){
			for(int j = 0;j<10;j++){
				System.out.print(" "+B[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i = 0;i<3;i++){
			for(int j = 0;j<10;j++){
				System.out.print(" "+C[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		for(int i = 0;i<3;i++){
			for(int j = 0;j<10;j++){
				System.out.print(" "+D[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 29856
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define lscan(n) scanf("%lld",&n)
#define print(n) printf("%d ",n)
#define lprint(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define pi pair<int,int>
#define pll pair<ll,ll>
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define all(v)        v.begin(),v.end()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          INT_MAX
#define ninf         LONG_MIN
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=5e5+5;
ll power(ll a, ll n){
  ll ans=1;
  while(n>0){
    if(n%2)
      ans=(ans*a)%mod;
    a=(a*a)%mod;
    n/=2;
  }
  return ans%mod;
}

int main() 
{ 
          fast();
          #ifndef ONLINE_JUDGE
          freopen("input.txt" , "r" , stdin);
          freopen("output.txt" , "w" , stdout);
          #endif
          ll n;
          cin>>n;
          ll ans=power(10,n);
          ans=(ans+power(8,n))%mod;
          ans=(ans-power(9,n)+mod)%mod;
          ans=(ans-power(9,n)+mod)%mod;
          cout<<ans<<endl;
           return 0; 

} 


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int32_t main(){
	int n,tmp,ans;
	cin>>n;
	n--;
	cin>>tmp;
	ans = tmp;
	while(n--){
		cin>>tmp;
		ans = ans/__gcd(ans,tmp)*tmp;
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstring>
#define rf freopen("inputf.in", "r", stdin)
#define wf freopen("outputf.in", "w", stdout)
#define endl "\n" 
#define max 1000001
//int arr[max];
using namespace std;
int main(void){//rf;wf;
	int flag =0;string a;
	cin>>a; //cin>>sum;
    for (int i = 0; i < a.length(); ++i)
    {if(a[i]=='7'){flag=1;break;}
    }
    if(flag==1){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<iomanip>
#include<iostream>
using namespace std;
string s;
int main()
{
	cin>>s;	
	string q=s;
	int len=s.size();
	reverse(q.begin(),q.end());
	for(int i=0;i<len;i++){
		if(q[i]=='b')q[i]='d';
		else if(q[i]=='d')q[i]='b';
		else if(q[i]=='p')q[i]='q';
		else if(q[i]=='q')q[i]='p';
	}
	if(s==q)printf("Yes\n");
	else printf("No\n");
	return 0;
 } 

Measured memory_bytes: 512
A, B = [int(n) for n in input().split(" ")]


XstartA = A / 0.08
XendA = (A + 1) / 0.08

XstartB = B / 0.1
XendB = (B + 1) / 0.1

start = XstartA
if XstartA < XstartB:
    start = XstartB

end = XendA
if XendB < XendA:
    end = XendB

S = int(start)
E = int(end) + 1

ans = -1
for i in range(S, E + 1):
    if start <= i and i < end:
        ans = i
        break

print(ans)

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################
char a[10][10];
int main() {
    int n=D(),m=D(),k=D();
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    ll ans=0;
    for(int maskr=0;maskr<(1<<n);maskr++){
        for(int maskc=0;maskc<(1<<m);maskc++){
            ll black=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    if((maskr&(1<<i))&&(maskc&(1<<j))&&a[i][j]=='#')
                        black++;
                }
            }
            if(black==k)ans++;
        }
    }
    cout<<ans;

}

Measured memory_bytes: 3648
#define ll long long
#include <bits/stdc++.h>
using namespace std;
const ll m = 1e9 + 7;

ll iloczyn(ll a, ll b) {
    a %= m;
    b %= m;
    return (ll)((a * b) % m);
}
ll suma(ll a, ll b) {
    a %= m;
    b %= m;
    return (ll)((a + b) % m);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int  n;
    cin >> n;

    vector<int> a(n);

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = 0;
    ll prev = 0;
    for (int i = 0; i < n; i++) {
        ans = suma(ans, iloczyn(a[i], sum - a[i]));
        sum -= a[i];
    }
    cout << ans << "\n";

}



Measured memory_bytes: 3932
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize m:usize x:i64 y:i64)(list1:[i64])(list2:[i64]));
    let max1 = std::cmp::max(x, list1.into_iter().max().unwrap());
    let min2 = std::cmp::min(y, list2.into_iter().min().unwrap());
    if max1 < min2 { "No War" } else { "War" }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 2 10 20\n8 15 13\n16 22" => "No War",
    test2: "4 2 -48 -1\n-20 -35 -91 -23\n-22 66" => "War",
    test3: "5 3 6 8\n-10 3 1 5 -100\n100 6 14" => "War",
}


Measured memory_bytes: 4352
#coding: utf-8

face = {'N':(1, 5, 2, 3, 0, 4), 'E':(3, 1, 0, 5, 4, 2), 'W':(2, 1, 5, 0, 4, 3), 'S':(4, 0, 2, 3, 5, 1)}
dice = input().split()

for o in input():
    dice = [dice[i] for i in face[o]]

print(dice[0])


Measured memory_bytes: 5572
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    fast;
    string s;
    ll n;
    cin>>s;
    n=s.size();
    if(s[n-1]=='s')
        s.append("es");
    else s.push_back('s');
    cout<<s<<endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		double bitcoin = 0;
		int jpyEn = 0;
		
		for (int i = 0; i < N; i++) {
			double x = sc.nextDouble();
			String s = sc.next();
			if (s.equals("JPY")) {
				jpyEn += x;
			} else {
				bitcoin += x;
			}
		}
		
		System.out.println(jpyEn + (bitcoin * 380000));
	}
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n, m; cin >> n >> m;
  VVI rev(n);
  VI is_root(n, true);
  REP (i, n - 1 + m) {
    int u, v; cin >> u >> v;
    u--;
    v--;
    rev[v].push_back(u);
    is_root[v] = false;
  }
  int r = -1;
  REP (i, n) {
    if (is_root[i]) r = i;
  }
  VI length(n, 0);
  VI ans(n, -1);
  VI visited(n);
  function<void(int, int)> dfs = [&](int v, int p) {
    if (length[v] > 0) return;
    for (int s: rev[v]) {
      dfs(s, v);
      if (length[s] + 1 > length[v]) {
        ans[v] = s;
        length[v] = length[s] + 1;
      }
    }
  };
  REP (i, n) {
    dfs(i, -1);
  }
  REP (i, n) {
    cout << ans[i] + 1 << endl;
  }
}


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

int main(){
  long count=0;
  int N;
  cin>>N;
  vector<long>H(N);
  vector<int>Hc(N);
  rep(i,N){
    cin>>H[i];
  }
  sort(H.begin(),H.end());
    count+=H[0];
  rep(i,N-1){
    count+=H[i+1]*pow(2,i);
  }
  double K=count/pow(2,N-1);
  cout<<K;
}

Measured memory_bytes: 256
import copy
H,W,K=map(int,input().split())
L=[[x for x in input()] for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=copy.deepcopy(L)
        for k in range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l in range(W):
            if (j>>l&1):
                for m in range(H):
                    C[m][l]="r"
        count=0
        for p in range(H):
            for q in range(W):
                if C[p][q]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)


Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const double EPS = 1e-10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    while(cin>>t&&t){
        int n;
        cin>>n;
        int sum=0;
        for(int i=0,s,f;i<n;i++){
            cin>>s>>f;
            sum+=f-s;
        }
        if(sum>=t)cout<<"OK"<<endl;
        else cout<<t-sum<<endl;
    }
}


Measured memory_bytes: 3176
#include <iostream>

using namespace std;

int main()
{
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	int total = A1 + A2 + A3;

	if (total >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

}





Measured memory_bytes: 3600
from itertools import combinations
n,k=map(int,input().split())
x=(n-1)*(n-2)//2
if k>x:
  print(-1)
  exit()
ans=[]
for i in range(2,n+1):
  ans.append((1,i))
if k<x:
  cnt=x-k
  for i,j in combinations(range(2,n+1),2):
    if cnt>0:
      ans.append((i,j))
      cnt-=1
    else:
      break
print(len(ans))
for arr in ans:
  print(*arr)

Measured memory_bytes: 3992
table = list(map(int,input().split()))

for i in range(2,0,-1):
    k = 0
    while k < i:
        if table[k] > table[k+1]:
            table[k],table[k+1] = table[k+1],table[k]
        k += 1;
        
print(table[0],table[1],table[2])


Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 3;
const int MOD = 1e9 + 7;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s, t; cin >> s >> t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << '\n';
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	A := []map[int]int{}
	for i := 0; i < N; i++ {
		var al int
		fmt.Scanf("%d\n", &al)
		m := map[int]int{}
		for i := 0; i < al; i++ {
			var x, y int
			fmt.Scanf("%d %d\n", &x, &y)
			m[x] = y
		}
		A = append(A, m)
	}

	max := 0
	for i := 1; i < 1<<uint(N); i++ {
		ok := true
		r := map[int]int{}
		for j := 1; j <= N; j++ {
			if i&(1<<uint(j-1)) == 0 {
				continue
			}
			m := A[j-1]
			if v, e := r[j]; e {
				if v == 0 {
					ok = false
					break
				}
			} else {
				r[j] = 1
			}
			if !check(A, r, m) {
				ok = false
				break
			}
		}
		if cnt := counter(i); ok && cnt > max {
			max = cnt
		}
	}
	fmt.Println(max)
}

func check(A []map[int]int, r, m map[int]int) bool {
	for k, v := range m {
		v1, e := r[k]
		if e {
			if v1 != v {
				return false
			}
			continue
		}
		r[k] = v
		if v == 1 {
			m := A[k-1]
			if !check(A, r, m) {
				return false
			}
		}
	}
	return true
}

func counter(x int) int {
	if x == 0 {
		return 0
	}
	return counter(x>>1) + (x & 1)
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[52];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n;
    while(true)
    {
        if(n<k)
        {
            k=k>>1;
            break;
        }
        k=k<<1;
    }
    cout<<k;
    return 0;
}



Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();



int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);

  int n;
  cin >> n;
  vector<ii>inter(n);
  vector<ii>L(n);
  vector<ii>R(n);
  FOR(i,0,n-1) {
    cin >> inter[i].F >> inter[i].S;
    L[i] = {inter[i].F,i};
    R[i] = {inter[i].S,i};
  }

  sort(all(L));reverse(all(L));
  sort(all(R));

  if(L[0].S == R[0].S) {
    int ans = max(0,R[0].F - L[0].F + 1);
    int maxv = 0;
    for(int i = 0; i < n; i++) {
      maxv = max(maxv, inter[i].S - inter[i].F + 1);
    }
    cout << ans + maxv << "\n";
    return 0;
  }

  //same
  int i1 = L[0].S, i2 = R[0].S;
  int ans = max(0,R[0].F - L[0].F + 1);
  int maxv = 0;
  for(int i = 0; i < n; i++) {
    if(i != i1 and i != i2)
    maxv = max(maxv, inter[i].S - inter[i].F + 1);
  }
  ans += maxv;
  // debug(ans);
  //diff
  int ans1 = 0;
  int cl = L[0].F, cr = R[0].F;
  int maxl = inter[R[0].S].F;
  for(int i = 1; i < n; i++) {
    if(R[i].S != L[0].S) {
      // debug(maxl, R[i].F);
      ans1 = max(ans1, max(0, cr - maxl + 1) + max(0, R[i].F - cl + 1));
      maxl = max(maxl, inter[R[i].S].F);
    }
  }
  int ans2 = max(0, inter[L[0].S].S - inter[L[0].S].F + 1);
  int maxxl = 0, minr = 1e9+1;
  for(int i = 0; i < n; i++) {
    if(i != i1) {
      maxxl = max(maxxl,inter[i].F);
      minr = min(minr, inter[i].S);
    }
  }
  ans2 += max(0, minr - maxxl + 1);
  ans1 = max(ans1,ans2);
  // debug(ans1);
  cout << max(ans,ans1);
  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
int arr[maxn];
struct node
{
    long long int id,val;
}lstk[maxn],rstk[maxn];
long long int pre[maxn];
long long int suf[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>arr[i];
    int len=0;
    for(int i=1;i<=n;++i)
    {
        if(len==0)
        {
            lstk[len].id=i;
            lstk[len++].val=arr[i];
            pre[i]=0;
        }
        else
        {
            while(len>0&&lstk[len-1].val>arr[i])
            {
                --len;
            }
            if(len==0)
                pre[i]=0;
            else
                pre[i]=lstk[len-1].id;
            lstk[len].id=i;
            lstk[len++].val=arr[i];
        }
    }
    len=0;
    for(int i=n;i>=0;--i)
    {
        if(len==0)
        {
            rstk[len].id=i;
            rstk[len++].val=arr[i];
            suf[i]=n+1;
        }
        else
        {
            while(len>0&&rstk[len-1].val>arr[i])
                --len;
            //cout<<i<<"****"<<rstk[len-1].id<<endl;
            if(len==0)
                suf[i]=n+1;
            else
                suf[i]=rstk[len-1].id;
                rstk[len].id=i;
                rstk[len++].val=arr[i];
        }
    }
    long long int sum=0;
    int l,r;
    for(int i=1;i<=n;++i)
    {
        //cout<<pre[i]<<" "<<suf[i]<<endl;
        sum+=(i-pre[i])*(suf[i]-i)*arr[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n;
    ll c;
    cin>>n>>c;
    vector<ll> x(n);
    vector<int> v(n);
    rep(i,n) cin>>x[i]>>v[i];
    vector<ll> rp(n), lp(n);
    rep(i,n){
        rp[i]=v[i];
        ll dif=x[i];
        if(i!=0){
            dif-=x[i-1];
            rp[i]+=rp[i-1];
        }
        rp[i]-=dif;
        lp[i]=v[n-1-i];
        dif=c-x[n-1-i];
        if(i!=0){
            dif-=c-x[n-i];
            lp[i]+=lp[i-1];
        }
        lp[i]-=dif;
    }
    vector<ll> mrp(n), mlp(n);
    mrp[0]=rp[0]; mlp[0]=lp[0];
    rep(i,n-1){
        mrp[i+1]=max(mrp[i], rp[i+1]);
        mlp[i+1]=max(mlp[i], lp[i+1]);
    }
    ll ans=0, kari=0;
    rep(i,n){
        kari=rp[i];
        if(i==n-1){
            ans=max(ans, rp[n-1]);
            continue;
        }
        if(mlp[n-2-i]>x[i]){
            kari+=(mlp[n-2-i]-x[i]);
        }
        ans=max(ans, kari);
    }
    rep(i,n){
        kari=lp[i];
        if(i==n-1){
            ans=max(ans, lp[n-1]);
            continue;
        }
        if(mrp[n-2-i]>(c-x[n-1-i])){
            kari+=(mrp[n-2-i]-c+x[n-1-i]);
        }
        ans=max(ans,kari);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7356
use proconio::input;

fn main() {
    input! {
        x: i32,
        y: i32,
    }
    for t in 0..(x + 1) {
        if 2 * t == y - 2 * x {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e6+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int a[N];
vector<int> ma[N];
void solve(){
    int n;
    cin >> n;   
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    for(int i = 1;i<=n;i++){
        int x = a[i];
        bool done = false;
        while(x%2==0){
            if(!done)
                ma[2].pb(i);
            done =true;
            x>>=1ll;
        }
        for(int j =3;j<=sqrt(x);j+=2){
            done = false;
            while(x%j==0){
                if(!done)
                    ma[x].pb(i);
                done = true;
                x /= j;
            }
        }
        if(x > 2){
            if(ma[x].empty() || ma[x].back() != i)
                ma[x].pb(i);
        }
    } 
    bool ok  =true;
    for(int i = 1;i<=1000000;i++){
        ok &= (ma[i].size() < 2);
    }
    if(ok){
        cout << "pairwise coprime\n";
        return;
    }
    int g = a[1];
    for(int i =2;i<=n;i++){
        g = __gcd(g,a[i]);
    }
    if(g == 1){
        cout << "setwise coprime\n";
        return;
    }
    cout << "not coprime\n";

}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 85132
#include <cstdio>
#include <algorithm>
#include <cstring>

#define maxn 10010
char s[maxn][30];
bool unknown[maxn][30];
int r[maxn], len[maxn];
inline bool cmp1(int a, int b)
{
	for (int i = 1; i <= len[a] && i <= len[b]; ++i)
		if (s[a][i] != s[b][i]) return s[a][i] < s[b][i];
	return len[a] == len[b] ? a < b : len[a] < len[b];
}
inline bool cmp2(int a, int b)
{
	for (int i = 1; i <= len[a] && i <= len[b]; ++i)
		if (s[a][i] != s[b][i]) return s[a][i] < s[b][i];
	return len[a] == len[b] ? a > b : len[a] < len[b];
}
int main()
{
	int n; scanf("%d", &n);
	for (int i = 1; i <= n + 1; ++i) r[i] = i;
	for (int i = 1; i <= n + 1; ++i)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n + 1; ++i)
	{
		len[i] = strlen(s[i] + 1);
		for (int j = 1; j <= len[i]; ++j)
			if (s[i][j] == '?')
				unknown[i][j] = 1, s[i][j] = 'a';
	}
	std::sort(r + 1, r + n + 2, cmp1);
	int left, right;
	for (int i = 1; i <= n + 1; ++i)
		if (r[i] == n + 1)
		{
			left = i;
			break;
		}
	for (int i = 1; i <= n + 1; ++i)
		for (int j = 1; j <= len[i]; ++j)
			if (unknown[i][j])
				s[i][j] = 'z';
	std::sort(r + 1, r + n + 2, cmp2);
	for (int i = 1; i <= n + 1; ++i)
		if (r[i] == n + 1)
		{
			right = i;
			break;
		}
	for (int i = right; i < left; ++i) printf("%d ", i);
	printf("%d\n", left);
	return 0;
}

Measured memory_bytes: 768
r, g, b, n = [int(i) for i in input().split()]

ans = 0

for i in range(n + 1):
    for j in range(n + 1):
        if (n - (i * r + j * g)) % b == 0 and (n - (i * r + j * g)) // b >= 0:
            ans += 1

print(ans)

Measured memory_bytes: 43036