akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> [String] -> Int
solve h w ss = runST $ VM.replicateM h (VUM.replicate w False) >>= act1
  where

  board = V.fromListN h (map (VU.fromListN w) ss)
  color (i,j) = board V.! i VU.! j

  nbr (i,j) = filter inBoard $
                map (addPair (i,j)) [(-1,0), (1,0), (0,-1), (0,1)]
  inBoard (i,j) = 0 <= i && i < h && 0 <= j && j < w

  indices = [(i,j) | i <- [0..h-1], j <- [0..w-1]]

  act1 visited = 
    collect <$> (forM indices $ \z -> act2 (color z) z)
    where
  
    collect = sum . map (\(s,t) -> s*t)
  
    act2 c0 (i,j) = do
      vi <- VM.read visited i
      b <- VUM.read vi j
      if b || (c0 /= color (i,j)) then return (0,0)
        else do
        VUM.write vi j True
        lst <- mapM (act2 (cRev c0)) (nbr (i,j))
        let (s, t) = sumPair lst
        return (t+1, s)

addPair (!a,!b) (!c,!d) = (a+c, b+d)
sumPair = foldl' addPair (0,0)
        
cRev '.' = '#'
cRev '#' = '.'

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_h,bs_w]:remLines1 = remLines0
      h = readBInt bs_h
      w = readBInt bs_w
      ss = map (\[x] -> B.unpack x) remLines1
  in solve h w ss

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

-------------------------------------------------------------------------------

inp1 = "3 3\n.#.\n..#\n#..\n"
inp2 = "2 4\n....\n....\n"
inp3 = "4 3\n###\n###\n...\n###\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 10
test2 = tv2 == 0
test3 = tv3 == 6
alltest = test1 && test2 && test3


Measured memory_bytes: 79228
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    int ans = 1;
    cin >> n >> m;
    if(n == 1){
        cout << m << endl;
        return 0;
    }

    for(int i = 1; i * n <= m; i++){
        if(m % i == 0 && m / i >= n){
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 105
#define __TRUE "YES"
#define __FALSE "NO"
#define cout(x) cout << (x) << endl
#define reps(i,s,n) for(i=s;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main() {
  int n,m,x,i;
  cin >> n >> m >> x;
  int lc=0,rc=0;
  rep(i,m) {
    int a;
    cin >> a;
    if(x>a) lc++;
    if(x<a) rc++;
  }
  if(lc<rc) cout(lc);
  else cout(rc);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,j;
  char s[5],a;
  scanf("%s",s);
  for(i=0;i<3;i++)
    for(j=i+1;j<4;j++)
      if(s[i]<s[j]){
        a=s[i];
        s[i]=s[j];
        s[j]=a;
      }
  if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
ll in(){ ll x; cin >> x; return x; }
vector<ll> in(size_t n){ vector<ll> v(n); each(x, v) cin >> x; return v; }
/* ]]] */

int n;
int a[200];

int main(){
  cin >> n;
  rep(i, n * 2) cin >> a[i];
  sort(a, a + n * 2);
  int s = 0;
  rep(i, 0, n * 2, 2) s += min(a[i], a[i + 1]);
  cout << s << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
//素数判定関数は引用
bool is_prime(const unsigned n){
    switch(n) {
        case 0: // fall-through
        case 1: return false;
        case 2: return true;
    } // n > 2 が保証された
 
    if(n % 2 == 0) return false;
 
    // 上で i=2 相当は調べたので、i=3から奇数のみ調べる
    for(unsigned i = 3; i * i <= n; i += 2) {
        if(n % i == 0) return false;
    }
 
    return true;
}
 
int main() {
  // input
  int x; cin >> x;
 
  // compute 
  int ans = 0;
  
  for(int i = 0; i < 100000; i++){
    if(is_prime(x + i)){
        ans = x + i;
        break;
    }
  }
  
  // output  
  cout << ans << endl;
  
}

Measured memory_bytes: 3476
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
    string s;
    cin>>s;
    int N=s.length();
    int score=0;
    rep(i,(N-1)/2+1) if(s[i]=='p') score--;
    rep(i,(N-1)/2+1,N) if(s[i]=='g') score++;
    cout<<score<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

int solve(){
    
    return 0;
}

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

      ll n,a;
  cin>>n>>a;
  vi v(n,0);
  rep(i,0,n) cin>>v[i];
  sort(all(v));
  ll asn=0;
  rep(i,0,a){
    asn+=v[i];
  }
  cout<<asn;
    return 0;
}


Measured memory_bytes: 3664
import sys
sys.setrecursionlimit(10**9)

N, A, B, C = list(map(int, input().split()))
s = [0] * (N+1)

for i in range(N):
    s[i] = input()
s[N] = 'AB'

sum = A + B + C
if sum != 2:
    ans = [0] * N
    for i in range(N):
        if s[i] == 'AB':
            if A > B:
                A -= 1
                B += 1
                ans[i] = 'B'
            else:
                A += 1
                B -= 1
                ans[i] = 'A'
        elif s[i] == 'AC':
            if A > C:
                A -= 1
                C += 1
                ans[i] = 'C'
            else:
                A += 1
                C -= 1
                ans[i] = 'A'
        elif s[i] == 'BC':
            if B > C:
                B -= 1
                C += 1
                ans[i] = 'C'
            else:
                B += 1
                C -= 1
                ans[i] = 'B'
        if A < 0 or B < 0 or C < 0:
            print('No')
            sys.exit()
    print('Yes')
    for i in range(N):
        print(ans[i])
    sys.exit()


ans = [0] * N
for i in range(N):
    if s[i] == 'AB':
        if A > B:
            A -= 1
            B += 1
            ans[i] = 'B'
        elif A < B:
            A += 1
            B -= 1
            ans[i] = 'A'
        else:
            if s[i+1] == 'BC':
                A -= 1
                B += 1
                ans[i] = 'B'
            else:
                A += 1
                B -= 1
                ans[i] = 'A'
    elif s[i] == 'AC':
        if A > C:
            A -= 1
            C += 1
            ans[i] = 'C'
        elif A < C:
            A += 1
            C -= 1
            ans[i] = 'A'
        else:
            if s[i+1] == 'AB':
                A += 1
                C -= 1
                ans[i] = 'A'
            else:
                A -= 1
                C += 1
                ans[i] = 'C'
    elif s[i] == 'BC':
        if B > C:
            B -= 1
            C += 1
            ans[i] = 'C'
        elif B < C:
            B += 1
            C -= 1
            ans[i] = 'B'
        else:
            if s[i+1] == 'AB':
                B += 1
                C -= 1
                ans[i] = 'B'
            else:
                B -= 1
                C += 1
                ans[i] = 'C'

    if A < 0 or B < 0 or C < 0:
        print('No')
        sys.exit()
print('Yes')
for i in range(N):
    print(ans[i])


Measured memory_bytes: 16960
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    String T = sc.nextLine();
    int[] iS = new int[27];
    int[] iT = new int[27];
    
    String ans = "Yes";
    for(int i = 0; i < S.length(); i++){
      int c1 = S.charAt(i)-'a'+1;
      int c2 = T.charAt(i)-'a'+1;
      if(iS[c1] == 0 && iT[c2] == 0){
        iS[c1] = c2;
        iT[c2] = c1;
      }else{
        if(iS[c1] != c2 || iT[c2] != c1){
          ans = "No";
          break;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 29544
def f_d():
    n, *l = map(int, open(0).read().split())

    l.sort()
    cnt = [n]*(l[-1]+l[-2]+1)
    for i in range(len(cnt)):
        o = 0
        for j in range(n):
            o = o+1 if i<l[j] else o
        cnt[i] = o

    o = 0
    for i in range(n):
        for j in range(i+1, n):
            ab1 = l[i]+l[j]
            ab2 = max(l[i], l[j]) - min(l[i], l[j])
            o += (cnt[ab2] - cnt[ab1-1])
            if ab2 < l[i] and l[i] < ab1:
                o -= 1
            if ab2 < l[j] and l[j] < ab1:
                o -= 1
    o = 0 if o<0 else o

    print(o//3)

if __name__ == "__main__":
    f_d()


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

int main() {
  string S;
  int x;
  cin >> S;
  x = S.size();
  if (S.at(x-1) == 's') {
    cout << S + "es" << endl;
  }
  else {
    cout << S + "s" << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int a[1000001], b[1000001];

int main(){
	
	for(int i = 0; i <= 1000000; i++){
		a[i] = 1000000;
		b[i] = 1000000;
	}
	
	a[0] = 0;
	b[0] = 0;
	
	for(int num = 1; num < 200; num++){
		int p = num * (num + 1) * (num + 2) / 6;
		if(p % 2 == 1){
			for(int i = 0; i <= 1000000 - p; i++){
				a[i + p] = min(a[i + p], a[i] + 1);
			}
		}
		for(int i = 0; i <= 1000000 - p; i++){
			b[i + p] = min(b[i + p], b[i] + 1);
		}
	}
	
	int N;
	
	while(true){
		cin >> N;
		if(N == 0){
			break;
		}
		cout << b[N] << " " << a[N] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int dp[18][2];

int main(){
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = s[0] - '0';
    dp[0][1] = s[0] - '1';
    rep(i, n) {
        if (i==0) continue;
        if (s[i]=='0') {
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1] + 9;
            continue;
        }
        dp[i][0] = dp[i-1][0] + (s[i]-'0');
        dp[i][1] = dp[i-1][1] + 9;
        dp[i][1] = max(dp[i][1], dp[i-1][0] + (s[i]-'1'));
    }
    int ans = max(dp[n-1][0], dp[n-1][1]);
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  char a, b, c, d;
  for (int i = 0; i < 9; i++) {
    if (i == 0) {
      cin >> a;
    }
    else if (i == 4) {
      cin >> b;
    }
    else if (i == 8) {
      cin >> c;
    }
    else if (i % 4 != 0) {
      cin >> d;
    }
  }
  cout << a << b << c << endl;
  return 0;
}

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

int main(){
	long long int n;
	cin>>n;
	vector<long long int> t(5);
	for (long long int i = 0; i < 5; i++) {
		cin>>t[i];
	}
	sort(t.begin(),t.end());
	cout<<(n+t[0]-1)/t[0]+4<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <vector>  
#include <string>
#include <cmath>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <ext/pb_ds/assoc_container.hpp>    // PBDS
#include <ext/pb_ds/tree_policy.hpp>      // PBDS

using namespace std;
using namespace __gnu_pbds;                 // PBDS

/* typedef starts */

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> PBDS_INT;               // PBDS for int
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> PBDS_LL;    // PBDS for long long

/* typedef ends */

/* macro starts */

#define PI acos(-1)
#define EPS 1e-9
#define INF ll(1e9 + 7)
#define fastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define sinD(degree) sin((degree * PI) / 180.0)
#define cosD(degree) cos((degree * PI) / 180.0)
#define tanD(degree) tan((degree * PI) / 180.0)
#define cotD(degree) (1.0 / tanD(degree))
#define secD(degree) (1.0 / cosD(degree))
#define cosecD(degree) (1.0 / sinD(degree))
#define asinD(value) (asin(value) * 180.0) / PI
#define acosD(value) (acos(value) * 180.0) / PI
#define atanD(value) (atan(value) * 180.0) / PI
#define forn(i,n) for(int i=0;i<n;i++)
#define value_at_index(x) find_by_order(x)
#define index_of(x) order_of_key(x)
#define pb push_back
#define set0(add) memset(add,0,sizeof(add))
#define max(a,b) a>b ? a : b
#define forr(i,a,b) for(int i=a;i<b;i++)

/* macro ends */

/* function starts */

/// calculates n-th (0-based) Gray Code
template<typename dataType>
dataType nthGrayCode(dataType n)
{
    return (n ^ (n >> 1));
}

/// generates all possible subsets for the given set
//template<typename dataType>
// void generateAllSubset(vector<dataType> &data)
// {
//     int i, j, n;
//     n = data.size();

//     for (i = 0; i < (1 << n); i++) {
//         for (j = 0; j < n; j++) {
//             if (i & (1 << j)) {
//                 cout << data[j] << " ";
//             }
//         }
//         cout << "\n";
//     }
// }


void swap(ll *a, ll *b){
	ll *temp=a;
	*a=*b;
	*b=*temp;
}
int n;
int dp[100005];
int a[100005];

int solve(int n){
for(int i=1;i<=n;i++){
  dp[i+2]=min(dp[i]+abs(a[i+2]-a[i]),dp[i+1]+abs(a[i+1]-a[i+2]));
}
return dp[n];
}
  
void solve(){
cin >> n;
forr(i,1,n+1)cin >> a[i];
set0(dp);
dp[2]=abs(a[2]-a[1]);
int ans=solve(n);
cout << ans << "\n";

}






int main()
{
  #ifndef ONLINE_JUDGE
       freopen("in.txt", "r", stdin);
       freopen("out.txt", "w", stdout);
  #endif
  fastIO;
    int t=1;
    //cin >> t;
    while(t--){
     solve();
    }
    return 0;
    }

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

int main() {
    int h, w;
    cin >> h >> w;
    cin.ignore(); /* skip remaind '\n' */

    vector<string> s(h);
    for (int i = 0; i < h; i++)
        cin >> s.at(i);

    for (int i = 0; i < w + 2; i++)
        cout << "#";
    cout << endl;

    for (int i = 0; i < h; i++) {
        cout << "#";
        cout << s.at(i);
        cout << "#" << endl;
    }

    for (int i = 0; i < w + 2; i++)
        cout << "#";
    cout << endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <stdio.h>

#define MAX_N 100

using namespace std;

int A[MAX_N]{};

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A + N);
  int res = 0;
  for (int i = N - 1; i >= 0; i -= 2) {
    res += A[i];
  }
  for (int i = N - 2; i >= 0; i -= 2) {
    res -= A[i];
  }
  printf("%d\n", res);
}

Measured memory_bytes: 3284
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
	int n;
	int t=0,x=0,y=0;
	int tt,xx,yy;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>tt>>xx>>yy;
		int len=tt-t-abs(xx-x)-abs(yy-y);
		if((len<0)||(len%2==1))
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
height = W * [0]
max_area = 0
for _ in range(H):
    height = [0 if t else height[j]+1 for j, t in enumerate(map(int, input().split()))]
    height.append(0)
    stack = []
    for i, h in enumerate(height):
        if stack:
            if stack[-1][1] == h:
                continue
            elif stack[-1][1] > h:
                while stack and (stack[-1][1] >= h):
                    i_stack, h_stack = stack.pop()
                    max_area = max(max_area, (i - i_stack) * (h_stack))
                i = i_stack
                
            
        stack.append((i, h))
        
print(max_area)


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



int main(){
  int N;
  cin>>N;
  vector<int> vec(N+1);
  for(int i=2;i<=N;i++){
    cin>>vec.at(i);
  }
  
  vector<int> bka(N+1);
  for(int i=2;i<=N;i++){
    bka.at(vec.at(i))+=1;
  }
  for(int i=1;i<=N;i++){
    cout<<bka.at(i)<<endl;
  }
    
    
  
}

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

using ll = long long;
const int INF = 1001001001;

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

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

  ll result = 1;
  ll count = 0;
  while (h > 1) {
    h /= 2;
    result += (ll)2 << count;
    count++;
  }

  cout << result << endl;
}


Measured memory_bytes: 256
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    t = 0
    mx = 0
    for i in range(26):
        if mx < S[d][i]:
            mx = S[d][i]
            t = i
    print(t+1)


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

const long long MOD=998244353;
long long N,K,l[11],r[11],memo[200010],prefix[400010];

void Input(){
	cin>>N>>K;
	for(long long i=1; i<=K; i++){
		cin>>l[i]>>r[i];
	}
}

void Solve(){
	memset(prefix,0,sizeof prefix);
	prefix[N]=1; memo[N]=1;
	for(long long i=N-1; i>=1; i--){
		long long total=0;
		for(long long j=1; j<=K; j++){
			long long nl=l[j],nr=r[j];
			total+=(prefix[i+nl]-prefix[i+nr+1]+MOD)%MOD;
			total=total%MOD;
		}
		memo[i]=total;
		prefix[i]=(prefix[i+1]+total)%MOD;
	}
	cout<<memo[1]<<'\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	Input();
	Solve();
}

Measured memory_bytes: 8264
import numpy as np

n = int(input())
aaa = np.fromiter(map(int, input().split()), np.int64)

all_x = np.bitwise_xor.reduce(aaa)
mask = ~all_x
bbb = aaa & mask

ans = 0
while True:
    a = bbb.max()
    if a == 0:
        break
    b = 1 << (int(a).bit_length() - 1)
    bbb[bbb & b > 0] ^= a
    if ans & b == 0:
        ans ^= a

print(2 * ans + all_x)


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

int main()
{
	int a, b, i;
	string n, d[10] = { "0111111" , "0000110" , "1011011" , "1001111" , "1100110" , "1101101" , "1111101" , "0100111" , "1111111" , "1101111" };
	while (cin >> a)
	{
		if (a == -1)break;
		n = "0000000";
		for (i = 0; i < a; i++)
		{
			cin >> b;
			for (int j = 0; j < 7; j++)
			{
				if (n[j] == d[b][j])
				{
					cout << "0";
				}
				else
				{
					cout << "1";
				}
			}
			n = d[b];
			cout << endl;
		}
	}
}

Measured memory_bytes: 1200
//This is the Property of Rishabh Agarwal
#include <bits/stdc++.h> 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
 
typedef long long int ll; 
const ll mod = 1000000007;
ll isPalindrome(string str) 
{ 
    int l = 0; 
    int h = str.length() - 1; 
  
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return 0; 
        } 
    } 
    return 1;
} 
vector<pair<ll,ll> >f;
vector<ll>v;
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    ll n=s.length();
    string h=s.substr(0,(n-1)/2);
    string g=s.substr((n+3)/2-1,(n-1)/2);
    if(isPalindrome(s)==1&&isPalindrome(h)==1&&isPalindrome(g)==1){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m, d[MAX], ans[2*MAX];
vector<pii> G[MAX];
vector<int> H[MAX];

void dfs(int v, int pv, int col, string &s){
    if(s[v] != '#') return;
    s[v] = (col ? 'B' : 'W');
    for(int nv: H[v]) dfs(nv, v, col^1, s);
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%d", &d[i]);
    rep(i, m){
        int u, v;
        scanf("%d%d", &u, &v);
        --u; --v;
        G[u].emplace_back(i, v);
        G[v].emplace_back(i, u);
    }
    fill(ans, ans+m, mod-7);
    rep(i, n){
        pii tmp = {d[i], mod}, te = {-1, -1};
        for(auto e: G[i]){
            if(chmin(tmp, {d[e.se], e.se})) te = e;
        }
        if(tmp.se == mod){
            puts("-1");
            return 0;
        }
        ans[te.fi] = max(d[i], d[te.se]);
        H[i].push_back(te.se);
        H[te.se].push_back(i);
    }
    string s(n, '#');
    rep(i, n) dfs(i, -1, 0, s);
    cout << s << "\n";
    rep(i, m) printf("%d\n", ans[i]);
}

Measured memory_bytes: 17152
n = int(input())
p = list(map(int, input().split()))
cnt = 0
ans = 0
for i in range(1, n + 1):
    if p[i - 1] == i:
        cnt += 1
    if p[i - 1] != i or i == n:
        ans += (cnt + 1) // 2
        cnt = 0
print(ans)


Measured memory_bytes: 14008
def dgsm(n):
    ans=0
    while n>0:
        ans+=n%10
        n//=10
    return(ans)
ans=10**6
n=int(input())
for i in range(1,n//2+1):
    ans=min(ans,dgsm(i)+dgsm(n-i))
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
typedef long long LL;
const int N=200010;
int n;
int a[N];
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
}
void solve(){
	LL ans=0;
	int whole=1<<20,state=0;
	for(int i=1,j=1;i<=n;state&=((whole-1)^a[i]),i++){
		for(;j<=n&&!(state&a[j]);j++)
			state|=a[j];
		ans+=j-i;
	}
	printf("%lld\n",ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int n, cnt, temp, ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		temp = i;
		cnt = 0;
		while (temp) {
			cnt++;
			temp /= 10;
		}
		if (cnt & 1)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)

import math

N=int(input())

G=[[] for i in range(N)]
for _ in range(N-1):
	a,b=map(lambda x:int(x)-1,input().split())
	G[a].append(b)
	G[b].append(a)

depth=[[0]*N for i in range(2)]

def dfs(d, i, p, k=0):
	for t in G[i]:
		if t!=p:
			depth[k][t]=d
			dfs(d+1, t, i,k)


dfs(1,0,-1, 0)
dfs(1,N-1,-1, 1)

cnt=0
for i,j in zip(depth[0], depth[1]):
	if i<=j:
		cnt+=1

print('Fennec' if cnt*2>N else 'Snuke')


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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
  bool operator==(const mint a) const { return x == a.x; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

const int MAX_N = 555555;
mint buf[MAX_N];

combination C(MAX_N);
mint P(int n, int k) { return buf[n] / buf[n - k]; }

mint f(int n, int k, int t) {
  return P(n, t) * C(k, t) * P(n - t, k - t).pow(2);
}

int main() {
  buf[0] = buf[1] = 1;
  for (int i = 2; i < MAX_N; ++i) buf[i] = buf[i - 1] * i;
  int n, m;
  while (cin >> n >> m) {
    mint x = 0;
    for (int i = 0; i <= n; ++i) {
      // if (i < 10) cout << i << " " << f(m, n, i) << endl;
      x += f(m, n, i) * ((i & 1) ? -1 : 1);
    }
    cout << x << endl;
  }
}

Measured memory_bytes: 15944
N = int(input())
F = [int("".join(input().split()), 2) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

# for i in range(N):
#     print(bin(F[i]))

ans = -10**9
for bit in range(1, 1<<10):
    money = 0
    for i in range(N):
        cnt = format(bit&F[i], 'b').count('1')
        money += P[i][cnt]
    ans = max(money, ans)
 
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 2e5 + 5, M = 64;

int nxt[N][M];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	ll k;
	cin >> n >> k;
	rep(i,1,n+1)cin >> nxt[i][0];
	rep(j,1,M)rep(i,1,n+1)nxt[i][j] = nxt[nxt[i][j-1]][j-1];
	int cur = 1;
	rep(i,0,M){
		if((k >> i)&1){
			cur=nxt[cur][i];
		}
	}
	cout << cur << '\n';
}



Measured memory_bytes: 53652
//Coded By Visnunathan

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.lang.*;

public class Main {
   // static int[] arr;
   // static int n,k;
    public static void main(String[] args) {
        FastScanner sc=new FastScanner();
        // int T=sc.nextInt();
        // for (int tt=0; tt<T; tt++) {
            double n = (double)sc.nextInt();
            double x = (double)sc.nextInt();
            double t = (double)sc.nextInt();
            System.out.println((int)((Math.ceil(n/x))*t));
            //arr = sc.readArray(n);
       // }
    }

    static final Random random=new Random();
    
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort 
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

    
}


Measured memory_bytes: 32908
N,M = map(int,input().split())
H = list(map(int,input().split()))

ans = [1] * N
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] <= H[b-1]: ans[a-1] = 0
    if H[b-1] <= H[a-1]: ans[b-1] = 0

print(sum(ans))

Measured memory_bytes: 20056
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) cout << 'x';
}


Measured memory_bytes: 3624
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**9 + 7

def pow_mod_p(n, k, p):
  x = 1
  while k:
    if k % 2 == 1:
      x *= n
      x %= p
    n **= 2
    n %= p
    k >>= 1
  return x

def comb_mod_p(n, k, p):
  x = 1
  for ik in range(k):
    x *= ((n-ik) * pow_mod_p(ik+1, p-2, p))
    x %= p
  return x

def main():
  n, k = map(int, input().strip().split())
  a, b = comb_mod_p(n-k+1, 1, MAX), comb_mod_p(k-1, 1-1, MAX)
  for i in range(1,k+1):
    if i != 1:
      a = (a * (n-k+1-(i-1))) * pow_mod_p(i, MAX-2, MAX)
      b = (b * (k-1-((i-1)-1))) * pow_mod_p(i-1, MAX-2, MAX)
    print((a * b) % MAX)

if __name__=='__main__':
  main()



Measured memory_bytes: 3444
s = input()
K = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
candidate_orig = set()

def hoge(c_list, rank, candidate):
    if len(candidate) >= 5:
        return candidate

    cur_targets = {}
    for l in sorted(c_list):
        if l + rank > len(s) - 1:
            continue
        _sub = s[l: l + 1 + rank]
        if _sub not in cur_targets:
            cur_targets[_sub] = [l]
        else:
            cur_targets[_sub].append(l)

    if len(cur_targets) == 0:
        return candidate

    for _d in sorted(cur_targets.items(), key=lambda x: x[0]):
        candidate.add(_d[0])
        candidate = hoge(_d[1], rank + 1, candidate)
        return candidate

    return candidate

for a in alp:
    idx_list = []
    for i, _s in enumerate(s):
        if a == _s:
            idx_list.append(i)
            candidate_orig.add(_s)
    candidate = hoge(idx_list, 1, candidate_orig)
    if len(candidate) >= 5:
        break

print(sorted(list(candidate_orig))[K - 1])

Measured memory_bytes: 3444
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}
/// template end ///

static int mcxi(const string &s)
{
	int ret = 0;
	int m = 1;
	for(auto c : s)
	{
		switch (c)
		{
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			m = c - '0';
			break;
		case 'm': ret += m * 1000; m = 1; break;
		case 'c': ret += m * 100; m = 1; break;
		case 'x': ret += m * 10; m = 1; break;
		case 'i': ret += m * 1; m = 1; break;
		}
	}
	return ret;
}


static string mcxi(int n)
{
	string ret;
	if (n >= 1000) { if (n / 1000 > 1) { ret.push_back(n / 1000 + '0'); } ret.push_back('m'); n %= 1000; }
	if (n >= 100) { if (n / 100 > 1) { ret.push_back(n / 100 + '0'); } ret.push_back('c'); n %= 100; }
	if (n >= 10) { if (n / 10 > 1) { ret.push_back(n / 10 + '0'); } ret.push_back('x'); n %= 10; }
	if (n >= 1) { if (n / 1 > 1) { ret.push_back(n / 1 + '0'); } ret.push_back('i'); n %= 1; }
	return ret;
}


void solve()
{
	READ(int, datasets);
	REP(dataset, datasets)
	{
		READ(string, a, b);
		write(mcxi(mcxi(a)+mcxi(b)));
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    if(a < b && b < c) cyes;
    else cno;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int count =0 ;
  for(int i=l;i<=r;i++){
    if(i%d==0)count++;
  }
  cout<<count;
  

}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int main(int argc, char**argv){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
    }
    vector<int> ans(n);
    for (int i = 0; i < n ; i++) ans[i] = 0;

    for (int i = 0 ; i < m; i++){
        ans[a[i]-1]++;
        ans[b[i]-1]++;
    }

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

    return 0;
}









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

using namespace std;

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

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] , x[MAX] , y[MAX] ;;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector< pair<int , int> >vp ;
	vector<int>v ;
	for(int i = 0 ; i < n ; ++i)
		cin>>x[i]>>y[i] ;
	for(int i = 0 ; i < n ; ++i)
		v.push_back(i) ;
	long double fact = 1.00 ;
	for(int i = 1 ; i <= n ; ++i)
		fact = (fact * i * 1.00) ;
	long double sum = 0.00 ;
	do
	{
		long double dist = 0.00 ;
		for(int i = 1 ; i < n ; ++i)
		{
			dist += sqrt((x[v[i]] - x[v[i-1]]) * (x[v[i]] - x[v[i-1]]) + (y[v[i]] - y[v[i-1]]) * (y[v[i]] - y[v[i-1]])) ;
		}
		sum += dist ;
	}
	while(next_permutation(v.begin() , v.end())) ;
	sum /= fact ;
	return cout<<fixed<<setprecision(12)<<sum<<"\n" , 0 ;
}		

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut lock = stdin.lock();
    let mut str1 = String::new();
    lock.read_to_string(&mut str1).unwrap();
    let mut iter1 = str1.trim().split_whitespace().map(|x| u32::from_str(x).unwrap());
    let n = iter1.next().unwrap();
    let an: Vec<u32> = iter1.collect();
    for a in (0usize..(n as usize)).rev() {
        if a % 2 == (n % 2 )as usize {
            continue;
        } else {
            print!("{} ", an[a]);
        }
    }
    for a in 0usize..(n as usize) {
        if a % 2 != (n % 2) as usize {
            continue;
        } else {
            print!("{}", an[a]);
            if (a + 2) <= n as usize {
                print!(" "); 
            }
        }
    }
    println!("");
}


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

using namespace std;

int main(){

    string a, b, c;
    cin >> a >> b >> c;

    if(*a.rbegin() == *b.begin() && *b.rbegin() == *c.begin()){
        cout << "YES" << endl;
    } else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define print(val) cout << #val << ": " << val << "\n";
#define print_c(a) cout<<#a<<": ";for(auto it=begin(a);it!=end(a);it++)cout<<*it<<" ";cout<<"\n";
#define fill(c,v) fill(begin(c),end(c),v);
template <typename T> T flip(T val) {reverse(begin(val),end(val)); return val;}

int main() {
  fast_io
  ll t=1; 
  while(t--) {
    int x,y; cin >> x >> y;
    string ans = "No";
    for(int i=0; i<=x; i++) {
      if((i*2 + (x-i)*4) == y) {ans = "Yes"; break;}
    }
    cout << ans;
  }
}

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
   int h,m,l;
   if (a>b)
   {
       m = a;
       l = b;
   }
   else
   {
       m = b;
       l = a;
   }
   if(m>c)
   {
       h = m;
       if(c>l)
       {
           m = c;
       }
       else
       {
           m = l;
           l = c;
       }

       }
       else
       {
           h = c;
       }
       printf("%d %d %d\n",l,m,h);
       return 0;
}




Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define f(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
ll dp[110][100010];

ll n;

ll a[100010];

// ll find(ll i,ll k){
// if(i==n){
//     if(k==0){
//         return 1;
//     }
//     else{
//         return 0;
//     }
// }
// if(dp[i][k]!=-1){
//     return dp[i][k];
// }

// dp[i][j]=d[i][]
// return dp[i][k]=count;
// }


int main(){
ll k;

cin>>n>>k;
f(i,0,n){
    cin>>a[i];
}
f(i,0,n){
    f(j,0,k+1){
        dp[i][j]=0;
    }
}
//cout<<find(0,k)%mod<<endl;

int j=0;
while(j<=a[0]){
dp[0][j]=1;
j++;
}

f(i,1,n){
    f(j,0,k+1){
        if(j==0){
           dp[i][j]=dp[i-1][j];
            continue;
        }

        dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
        if(j-a[i]-1>=0){
            dp[i][j]=(dp[i][j]%mod-dp[i-1][j-a[i]-1]%mod+mod)%mod;
        }
    }
}
cout<<dp[n-1][k]%mod<<endl;
}

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

int main() {
  // 科目の数Nを受け取る
  int L, R, d;
  cin >> L >> R >> d;

  int f = 0;
  for (int i=L; i<=R; i++) {
    if (i % d == 0) f++;
  }
  cout << f << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,c,x;
int d[34][34],t[3][34];
int main(){
   scanf("%d%d",&n,&c);
    for(int i=1;i<=c;i++)
      for(int j=1;j<=c;j++)
        scanf("%d",&d[i][j]);
    for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
      {
      	 scanf("%d",&x);
      	 for(int k=1;k<=c;k++)
      	 t[(i+j)%3][k]+=d[x][k];
      }
      int minn=1<<30;
      for(int i=1;i<=c;i++){ 
        for(int j=1;j<=c;j++)
      { 
      	if(i==j)continue;
      	for(int k=1;k<=c;k++)
      	{
      		if(i==k||j==k)continue;
      	
      	    	int  tt=t[0][i]+t[1][j]+t[2][k];
      		if(tt<minn)minn=tt;
      	}
      }
    }
    printf("%d\n",minn);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
int main(void){
    int n,l; cin>>n>>l;
    int a[100001];
    bool fl=false;
    int k;
    FOR(i,0,n){
        cin>>a[i];
        if(i>=1&&a[i]+a[i-1]>=l){
            fl=true;
            k=i;
        }
    }
    Pos(fl);
    if(fl){
        ROF(i,k+1,n) cout<<i<<endl;
        FOR(i,1,k) cout<<i<<endl;
        cout<<k<<endl;
    }
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
using namespace std::chrono;

/*
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
*/

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k,r;


ld dists[1003][1003] = {0};

vector<ll> R;
vector<ll> X;
vector<ll> Y;


ld dist(ll x, ll y){
return sqrt(x*x + y*y);
}

ll SP[1003] = {0};

ld dijk(){

priority_queue<pair<ld,ll> > pq;
pq.push({0,0});

bool mark[1003] = {0};


while(!pq.empty()){

    pair<ld,ll> pa = pq.top();
    pq.pop();
    ld w = -pa.first;
    ll a = pa.second;

    if(mark[a] == 0){
        mark[a] = 1;
        if(a == 1)return w;
        for(ll c1 = 0; c1 < n; c1++){
            if(c1 != a && mark[c1] == 0){
                ld w2 = w + dists[a][c1];
                pq.push({-w2,c1});
            }

        }

    }

}
return -1;
}


int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,c,e;
    ll x;

    ll x1,y1,x2,y2;

    cin >> x1 >> y1 >> x2 >> y2;

    cin >> n;
    n += 2;

    X.push_back(x1);
    Y.push_back(y1);
    X.push_back(x2);
    Y.push_back(y2);
    R.push_back(0);
    R.push_back(0);

    for(c1 = 0; c1 < n-2; c1++){
        cin >> x1 >> y1 >> a;
        X.push_back(x1);
        Y.push_back(y1);
        R.push_back(a);
    }


    for(c1 = 0; c1 < n; c1++){
        for(c2 = c1+1; c2 < n; c2++){
            ld di = dist(X[c1] - X[c2] , Y[c1] - Y[c2]);
            di = max(ld(0.0) , di-ld(R[c1]+R[c2]));
            dists[c1][c2] = di;
            dists[c2][c1] = di;
        }
    }

    cout << setprecision(18) << dijk() << "\n";

    return 0;
}


Measured memory_bytes: 32500
#include <stdio.h>

char s[999],*p=s;
int d[10];

char*f(char*t){
	int sn=1;
	if(*t=='-')sn=-1;
	t++;
	int coe=0;
	while('0'<=*t&&*t<='9')coe=coe*10+*t++-'0';
	if(coe==0)coe=1;
	int deg;
	if(*t!='x')deg=0;
	else{
		t++;
		if(*t=='^')deg=*++t-'0',t++;
		else deg=1;
	}
	d[deg]=sn*coe;
	return t;
}

long calc(long x){
	long ans=0,s=1;
	for(int i=0;i<=5;i++)ans+=d[i]*s,s*=x;
	return ans;
}

int main(){
	scanf("%s",s+1);
	s[0]='+';
	while(*(p=f(p)));
	for(int x=-2000;x<=2000;x++)if(calc(-x)==0)printf("(x%+d)",x);
	puts("");
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true)
    {
        c -= b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
	auto N = 0;
	auto D = 0;
	auto monitor = 0;
	auto count = 0;

	cin >> N >> D;

	monitor = D * 2 + 1;

	for (int i = 1; i <= N; i++) {
		auto n = 0;
		n = monitor * i;
		if (n >= N) {
			count = i;
			break;
		}
	}

	cout << count << endl;
}



Measured memory_bytes: 256