akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
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 string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n;
vi arr;
vi d;
int k;
void in(){
    cin >> n;
    rep(i,0,n)arr.push_back(input());
    int s = sum(arr);
    int t = n * (n + 1) / 2;
    if(s % t > 0){
        print("NO");
        exit(0);
    }
    k = s / t;
    rep(i,0,n - 1) d.push_back(arr[i + 1] - arr[i] - k);
}

void solve(){

    int ans = 0;
    rep(i,0,n - 1){
        if(d[i] <= 0 && abs(d[i]) % n == 0){

        }else{
            print("NO");
            exit(0);
        }
    }

    print("YES");

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define N 200005
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
 
	ll n,i,j,k;
	ll ans=0;
	cin>>n;

	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++)
			for(k=1;k<=n;k++)
				ans+=__gcd(i,(__gcd(j,k)));
	}
	cout<<ans<<endl;


 	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  double w;

  while( cin >> w )
    {
      if ( w <= 48 )
        cout << "light fly" << endl;
      else if ( w <= 51 )
        cout << "fly" << endl;
      else if ( w <= 54 )
        cout << "bantam" << endl;
      else if ( w <= 57 )
        cout << "feather" << endl;
      else if ( w <= 60 )
        cout << "light" << endl;
      else if ( w <= 64 )
        cout << "light welter" << endl;
      else if ( w <= 69 )
        cout << "welter" << endl;
      else if ( w <= 75 )
        cout << "light middle" << endl;
      else if ( w <= 81 )
        cout << "middle" << endl;
      else if ( w <= 91 )
        cout << "light heavy" << endl;
      else
        cout << "heavy" << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,q;
  cin>>n>>q;
  vector<uint64_t> d1(n-2,0);
  vector<uint64_t> d2(n-2,0);
  int64_t result=(n-2)*(n-2);
  int num;
  uint64_t index;
  uint64_t h=n-2,w=n-2;
  uint64_t h_in=n-2,w_in=n-2;
  for(int i=0;i<q;i++){
    cin>>num>>index;
    if(num==1){
      if(index-2<h){
        result-=h_in;
        w_in=index-2;
        for(int j=index-1;j<h;j++){
          d1[j]=h_in;
        }
        h=index-2;
      }else{
        result-=d1[index-2];
        d1[index-2]=0;
      }
    }else if(num==2){
      if(index-2<w){
        result-=w_in;
        h_in=index-2;
        for(int j=index-1;j<w;j++){
          d2[j]=w_in;
        }
        w=index-2;
      }else{
        result-=d2[index-2];
        d2[index-2]=0;
      }
    }
  }
  cout<<result<<endl;
}

Measured memory_bytes: 6320
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#include<vector>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    string s;
    cin >> s;
    string ans = "";
    rep(i, s.size()) {
        if (s[i] == '0') {
            ans += "0";
        }
        if (s[i] == '1') {
            ans += "1";
        }
        if (s[i] == 'B') {
            if (ans.size() > 0) {
                ans.erase(ans.size() - 1, 1);
            }
        }
    }
    cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

long long A[MAX];

int main() {
	int n;cin>>n;
	rep(i,n) cin>>A[i];
	sort(A,A+n,greater<long long>());
	long long l[2], i=0, last=-1;
	rep(j,n) {
		if(i==2) break;
		if(last==A[j]) {l[i]=A[j]; i++; last=-1; continue;}
		last=A[j];
	}
	if (i==2) cout<<l[0]*l[1]<<endl;
	else cout<<0<<endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted 
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan 

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e5 + 123;                                          
const int PRI = 555557;
const int pri = 997;

int tests = 1;
ll n, a, b;

inline void Solve () {
	//easy
	cin >> n >> a >> b;
	if (n == 1) {
		cout << (a == b);
		exit(0);
	}
	if (a > b) {
		cout << 0;
		exit(0);
	}

	cout << (n * b - b + a) - (n * a - a + b) + 1;
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted; 
}

Measured memory_bytes: 256
fn main() {
    let (_n, k): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut p: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    p.sort();

    let mut ans = 0;
    for i in 0..k {
        ans += p[i];
    }
    println!("{}", ans);
}

Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int A, B, C;

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int a;
  set<int> mp;
  rep(i, 3) {
    cin >> a;
    mp.insert(a);
  }
  if (mp.size() == 2) {
     cout << "Yes\n";
  } else cout << "No\n";
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    d = {v: 7 - i for i, v in enumerate("SUN,MON,TUE,WED,THU,FRI,SAT".split(","))}
    print(d[str(readline().rstrip().decode('utf-8'))])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define RFOR(i, a, b) for (int i = (b) - 1, i##_min = (a); i >= i##_min; --i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template<typename T>
void print(vector<T> v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

void counting_sort(vi &A, vi &B, int k) {
  vi C(k+1);
  for(auto a : A) ++C[a];
  FOR(i, 1, k + 1) C[i] = C[i] + C[i-1];
  REP(i, A.size()) B[--C[A[i]]] = A[i];
}

int main() {
  int n;
  cin >> n;
  vi A(n), B(n);
  REP(i, n) cin >> A[i];
  counting_sort(A, B, 10000);
  print(B);
}



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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using Grid = vector<vector<char>>;

bool memo[1010][1010];
ll dp[1010][1010];

ll f(const Grid &g, ll x, ll y) {
  ll h=g.size(), w=g.at(0).size(); 
  if (g.at(x).at(y) == '#') {
    dp[x][y] = 0;
    memo[x][y] = true;
  }
  if(memo[x][y]) return dp[x][y];
  else {
    memo[x][y] = true;
    if (x < h-1 && y < w-1) {
      dp[x][y] = (f(g,x+1,y)+f(g,x,y+1)) % 1000000007;
    }
    else if (x == h-1 && y == w-1) dp[x][y] = 1LL;
    else if (x == h-1) dp[x][y] = f(g, x, y+1) % 1000000007;
    else if (y == w-1) dp[x][y] = f(g, x+1, y) % 1000000007;
  }
  return dp[x][y];
}

int main() {
  ll H, W;
  cin >> H >> W;
  Grid g(H, vector<char>(W));
  for (ll i = 0LL; i < H; i++) {
    for (ll j = 0LL; j < W; j++) {
      cin >> g.at(i).at(j);
    }
  }
  cout << f(g,0,0) << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b;
    rep(i, 3)
    {
        int x, y, z;
        cin >> x >> y >> z;

        if (!i)
        {
            a = abs(y - x);
            b = abs(z - y);
        }

        if (a != abs(y - x) || b != abs(z - y))
        {
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 3596
import Data.Char(isSpace)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C

main = do
    n <- readLn
    as <- U.unfoldrN n (C.readInt . C.dropWhile isSpace) <$> C.getLine
    let left = U.scanl gcd 0 as
    let right = U.scanr gcd 0 as
    let res = U.zipWith gcd left (U.tail right)
    print $ U.maximum res

Measured memory_bytes: 4732
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// gcd, lcm
ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}


int main() {
    int a, b;
    cin >> a >> b;
    int ans = a * b - a - b + 1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 764
Scanf.scanf "%d" (fun n ->
    let xy = Array.init n (fun i -> Scanf.scanf " %d %d" (fun x y -> x, y, i)) in
    Array.sort compare xy;
    let module S = Set.Make (struct type t = int * int * int let compare = compare end) in
    let rec loop j acc =
        if j = n then acc else
            let px, _, pi = xy.(j - 1) in
            let cx, _, ci = xy.(j)     in
            let acc = S.add (cx - px, pi, ci) acc in
            loop (j + 1) acc
    in
    let edges = loop 1 S.empty in
    Array.sort (fun (x0, y0, _) (x1, y1, _) -> compare (y0, x0) (y1, x1)) xy;
    let rec loop j acc =
        if j = n then acc else
            let _, py, pi = xy.(j - 1) in
            let _, cy, ci = xy.(j)     in
            let acc = S.add (cy - py, pi, ci) acc in
            loop (j + 1) acc
    in
    let edges = loop 1 edges in

    let par = Array.init n (fun i -> i) in
    let rec root x =
        if x = par.(x) then x else
            let r = root par.(x) in
            let () = par.(x) <- r in
            r
    in

    let merge a b =
        if root a <> root b then par.(par.(b)) <- par.(a)
    in

    let rec loop edges cost =
        if S.is_empty edges then cost else (
            let ((c, n1, n2) as elt) = S.min_elt edges in
            let edges = S.remove elt edges in
            if root n1 = root n2 then loop edges cost else (
                merge n1 n2;
                loop edges (cost + c)
            )
        )
    in
    loop edges 0 |> Printf.printf "%d\n"
)


Measured memory_bytes: 36220
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 14;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	fread_unlocked(cn, 1, cm, stdin);

	int N = getint();
	ll A = 1, B = 1;
	rep(i, N) {
		int a = getint(), b = getint();
		ll k = max((A + a - 1) / a, (B + b - 1) / b);
		A = a * k;
		B = b * k;
	}

	printf("%lld", A + B);

	Would you please return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<double> A(N);
    rep(i,N) cin >> A[i];
    
    double mans=0;
    rep(i,N) mans+=1.0/A[i];
    

    printf("%g\n",1/mans);
    return (0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;

const int MAXN = 2000 + 10;
int N, M, Q;
int A[MAXN];
int l, r, mid;

int main() {
	register int i, j;
	scanf( "%d%d%d", &N, &M, &Q );
	for( i = 1; i <= N; ++i ) scanf( "%d", A + i );
	l = 0, r = 2000000000;
	while(l < r) {
		int mid = (l + r) >> 1; bool ok = 0;
		for( i = 1; i <= N; ++i ) {
			int p = A[i];
			int k = 0, tmp = 0, cnt = 0;
			for(j = 1; j <= N + 1; ++j)
				if(A[j] < p || j == N + 1)
					tmp += j - k - 1 < M ? 0 : min(j - k - 1 - M + 1, j - k - 1 - cnt), k = j, cnt = 0;
				else
					if(A[j] > p + mid) ++cnt;
			if(tmp >= Q) {
				ok = 1;
				break;
			}
		}
		ok ? r = mid : l = mid + 1;
	}
	printf( "%d\n", l );
	return 0;
}

Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    if (k-a > 0) ans += a;
    else ans += k;
    k -= a;
    k -= b;
    if (k > 0) ans -= k;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if(a > 8 || b > 8) puts(":(");
    else puts("Yay!");
    
}

Measured memory_bytes: 256
#include <cstddef>
#include <array>

constexpr const std::size_t MAX_N = 100000;

namespace detail {
  constexpr std::size_t calc_digit_sum(const std::size_t n) {
    return n == 0 ? 0 : calc_digit_sum(n / 10) + n % 10;
  }
  constexpr std::size_t calc_answer(const std::size_t digit_sum) {
    return digit_sum == 1 ? 10 : digit_sum;
  }

  template <std::size_t... V> struct sequence {
    template <typename T> using join = typename T::template prepend<V...>;
    template <std::size_t... U> using prepend = sequence<U..., V...>;
    static constexpr std::array<std::size_t, sizeof...(V)> value = {V...};
  };

  template <std::size_t I, std::size_t N> struct answer_range {
    using to_sequence = typename answer_range<I, N / 2>::to_sequence::template join<typename answer_range<I + N / 2, N - N / 2>::to_sequence>;
  };
  template <std::size_t I> struct answer_range<I, 1> {
    using to_sequence = sequence<calc_answer(calc_digit_sum(I))>;
  };

  static constexpr std::array<std::size_t, MAX_N - 1> answers = answer_range<2, MAX_N - 1>::to_sequence::value;
}

constexpr std::size_t answer(std::size_t i) {
  return detail::answers.at(i - 2);
}

#include <iostream>

int main() {
  std::size_t n;
  std::cin >> n;
  std::cout << answer(n) << std::endl;
  return 0;
}

Measured memory_bytes: 256
using System;

class _0104
{
    public static void Main()
    {
        string tmp;
        string[] data = Console.ReadLine().Split();
        char[,] map;
        int x = int.Parse(data[1]), y = int.Parse(data[0]);
        int i, j;
        int[] dx = { 1, 0, -1, 0 };
        int[] dy = { 0, 1, 0, -1 };
        while (x != 0 && y != 0)
        {
            map = new char[x, y];
            for (i = 0; i < y; i++)
            {
                tmp = Console.ReadLine();
                for (j = 0; j < x; j++) map[j, i] = tmp[j];
            }
            i = j = 0;
            while (map[i, j] != '.' && map[i, j] != '-')
            {
                switch (map[i, j])
                {
                    case '>': map[i, j] = '-'; i += dx[0]; j += dy[0]; break;
                    case 'v': map[i, j] = '-'; i += dx[1]; j += dy[1]; break;
                    case '<': map[i, j] = '-'; i += dx[2]; j += dy[2]; break;
                    case '^': map[i, j] = '-'; i += dx[3]; j += dy[3]; break;
                }
            }
            Console.WriteLine((map[i, j] == '.') ? i + " " + j : "LOOP");
            data = Console.ReadLine().Split();
            x = int.Parse(data[1]); y = int.Parse(data[0]);
        }
    }
}

Measured memory_bytes: 5708
def main(str)
  as = str.split("\n")[1].split(" ").map(&:to_i)
  s = as.inject { |x,m| x ^ m }
  as.map { |a| s ^ a }.join(" ")
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("26 5 7 22", main("4
20 11 9 24"))
  end
end




Measured memory_bytes: 37276
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m;
int xx[1001];int yy[1001];
int main()
{
	cin>>n>>m>>xx[1]>>yy[1];
	int x=xx[1];
	int y=yy[1];
	for(int i=2;i<=n+1;i++)
		cin>>xx[i];
	for(int i=2;i<=m+1;i++)
		cin>>yy[i];
	sort(xx+1,xx+2+n);
	sort(yy+1,yy+2+m);
		if(xx[n+1]</*=*/yy[1]&&x<y)
		{
			cout<<"No War";
			return 0;
		}
	cout<<"War";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		while(true) {
			int H=sc.nextInt();
			int W=sc.nextInt();
			if(H==0 && W==0) {
				break;
			}
			for(int i=1;i<=H;i++) {
				if(i%2==1) {
					for(int j=1;j<=W;j++) {
						if(j%2==1) {
							System.out.print("#");
						}else {
							System.out.print(".");
						}

					}
				}else {
					for(int j=1;j<=W;j++) {
						if(j%2==1) {
							System.out.print(".");
						}else {
							System.out.print("#");
						}

					}

				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}

}



Measured memory_bytes: 37812
N = int(input())

Tmp = []
Tmp = input().rstrip().split(' ')

nAns = [ 0 for i in range(N)]


for i in range(N):
  TmpN = int(Tmp[i])
  nAns[TmpN - 1] = (i+1)

for i in range(N):
  print('%d' %(nAns[i]), end='')
  if i != N - 1:
    print(' ' , end='')
  else:
    print('')




Measured memory_bytes: 14468
N = int(input())
R =  [0]*N

for i in range(N):
    R[i] = int(input())

m = R[0]
ans = -1*10**9

for i in range(1,N):
    if R[i] - m > ans:
        ans = R[i] - m
    if R[i] < m:
        m = R[i]
    
print(ans)


Measured memory_bytes: 13372
#include<cstdio>
#include<algorithm>
using namespace std;
int a, b;
int main()
{
	scanf("%d%d",&a, &b);
	if(a == 0 || b == 0){
		if(a > b) printf("%d\n",a-b+1);
		else printf("%d\n",b-a);
	}else if(a > 0 && b > 0){
		if(a < b) printf("%d\n",b-a);
		else printf("%d\n",a-b+2);
	}else if(a > 0 && b < 0 || a < 0 && b > 0){
	    printf("%d\n",abs(abs(a)-abs(b))+1);
	}else{
	    if(a == b) printf("0\n");
		else if(a > b) printf("%d\n",abs(-a+b)+2);
		else printf("%d\n",-a+b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> sum(N+1, 0);
	rep(i,N){
		cin >> A[i];
		sum[i+1] = sum[i] + A[i];
		sum[i+1] %= MOD;
	}
	ll ans = 0;
	rep(i,N){
		ans += A[i] * ((sum[N]-sum[i + 1])%MOD);
		ans %= MOD;
	}
	if(ans < 0)ans += MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll a , b , c ;
	cin>>a>>b>>c;

	cout<<max(c-a+b,0LL)<<endl;	

	return 0;
}

Measured memory_bytes: 256
def foo(p,n)
  (p.to_r/n).ceil
end

pa = pb = 1

gets.to_i.times do
  a,b = gets.rstrip.split.map(&:to_i)
  t = [foo(pa, a), foo(pb, b)].max
  # p [pa, pb, a,b]
  pa = a*t
  pb = b*t
end

puts pa+pb

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <time.h>
#define last(x, y) (x)[(x).size() - y]
#define endl '\n'
#define flush fflush(stdout), cout.flush()
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define debug cout << "ok" << endl
#define in(X) ((X) - '0')
const int md = 1e9 + 7;
typedef long long ll;
typedef long double ldb;
using namespace std;

int n, ans = 0;
vector<bool> b;

int main() {
	fast;
	cin >> n;
	for (int i = 0, x; i < n; i++) {
		cin >> x;
		if (x - 1 == i) b.push_back(true);
		else b.push_back(false);
	}
	b.push_back(false);

	for (int i = 0; i < b.size() - 1; i++)
		if (b[i]) ans++, b[i] = false, b[i + 1] = false;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
vvl v;
vl vis,d;

pll dfs(int s,int p){
    ll x=1,y=1;
    for(int u:v[s]){
        if(u==p)continue;
        pll g=dfs(u,s);
        x=x*g.ff%mod;
        y=(g.ss+g.ff)%mod*y%mod;
    }
    return {y,x};
}

int main() {
    IOS;
    cin>>n;
    v.resize(n);
    fo(i,n-1){
        cin>>x>>y;x--;y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    pll f=dfs(0,-1);
    cout<<(f.ss+f.ff)%mod;
    return 0;
}



Measured memory_bytes: 12672
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input! {
        n: usize,
        b: [usize; n-1],
    }

    let mut bef = b[0];
    let mut ans = b[0];

    for i in b.iter().skip(1) {
        ans = ans + min(bef, *i);
        bef = *i;
    }
    ans = ans + b[n-2];

    println!("{}", ans);
}


Measured memory_bytes: 4352
import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

object Main {
  def main(args: Array[String]): Unit = {
    loop()

    def loop(): Unit = {
      val n = readInt()
      if (n != 0) {
        var t = readLine().split(' ').map(s => s.toInt)
        t = t :+ Int.MaxValue
        var ans: Seq[String] = Seq[String]()
        var preIdx = 0

        for (i <- 1 to n) {
          if (t(i - 1) + 1 != t(i)) {
            if (i - preIdx == 1) {
              ans = ans :+ t(i - 1).toString
            } else {
              ans = ans :+ s"${t(preIdx)}-${t(i - 1)}"
            }
            preIdx = i
          }
        }
        println(ans.mkString(" "))
        loop()
      }
    }
  }
}

Measured memory_bytes: 45164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
     int N, K, sum;
  	cin >> N >> K;
  
  	for (int i = 1; i <= N; i++) {
    	int x;
      	cin >> x;
      
      int sa = K- x;
      
 	if (x <= sa) {
    	sum += 2 * x;
    }     	
     else {
     	sum += 2 * sa;
     }       
      
    }
  
  cout << sum << endl;
  
  
}

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

int n, a[2000];
long long int dp[2000][2000];
long long int ans = 0;
int main()
{
  //part1
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];

  //part2
  for(int i = 0; i < n; i++)
    dp[0][i] = a[i];

  //part3
  for(int i = 1; i < n; i++)
    for(int j = 0; j < n; j++)
      if(i & 1){
	if(a[(j + i) % n] >= a[(j + n - 1) % n])
	  dp[i][j] = dp[i - 1][j];
	if(a[j] >= a[(j + i + 1) % n])
	  dp[i][j] = max(dp[i][j], dp[i - 1][(j + 1) % n]);
      }
      else
	dp[i][j] = max(dp[i - 1][(j + 1) % n] + a[j], dp[i - 1][j] + a[(j + i) % n]);
  
  //part4
  for(int i = 0; i < n; i++)
    ans = max(ans, dp[n - 1][i]);

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

Measured memory_bytes: 32412
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 1e4+5; int n,m,k; char s[N]; 
	void main() {
		n = read(); m = n<<1; k = read(); int x = 0,y; while ((1<<x) < n) ++x; k = min(k,x); scanf("%s",s+1); rep(i,1,n) s[m-i+1] = s[i];
		x = 1; while (x <= n) {int i = y = x,j = x+1; while (j <= m && s[i] <= s[j]) i = s[i] < s[j++] ? x : i+1; while (x <= i) x += j-i;}
		rep(i,1,n) s[i] = s[i+y-1]; s[n+1] = x = 0; rep(i,1,n) {++x; if (s[i] != s[i+1]) break;} y = min(x<<(k-1),n); drep(i,n,y+1) s[i] = s[i-y+x]; rep(i,1,y) s[i] = s[1]; puts(s+1);
	}
}
int main() {
	qiqi::main(); return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    char bus[3];

    rep(i, 3) {
        cin >> bus[i];
    }

    bool ans = false;

    if(bus[0] == bus[1] && bus[1] == bus[2] && bus[0] == bus[2]) ans = true;

    cout << ((ans)? "No": "Yes");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long Int;
map<Int, Int> cnt;
Int sum = 0, n, a, res = 0;
int main(){
	cin >> n;
	cnt[sum] = 1;
	for(int i = 0;i < n;i++){
		cin >> a;
		sum += a;
		if(cnt.count(sum) == 0)cnt[sum] = 0;
		cnt[sum]++;
	}
	for(map<Int, Int>::iterator it = cnt.begin();it != cnt.end();it++){
		Int c = it->second;
		res += c * (c-1) / 2;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n; cin >> n;
    int a, b, c;
    vector<int> x(n), y(n), h(n);
    rep(i, n)
    {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0)
        {
            a = x[i]; b = y[i], c = h[i];
        }
    }

    rep(cx, 101)
    {
        rep(cy, 101)
        {
            int H = c + abs(a - cx) + abs(b - cy);
            int ok = 1;
            rep(i, n) if (max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) != h[i]) ok = 0;
            if (ok)
            {
                printf("%d %d %d\n", cx, cy, H);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool t[10000] = {false};
int main()
{
	int n, i, j;
	t[0] = true;
	for (i = 2; i * i <= 10000; i++)
	{
		if (!t[i-1])
		{
			for (j = i+i; j <= 10000; j+=i)
				t[j-1] = true;
		}
	}
	while (cin >> n, n)
	{
		for (i = n; i >= 5; i--)
		{
			if ((!t[i-1]) && (!t[i-3]))
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}
}

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

#define MAX_k 1000000000 
#define MAX_l 1000000
#define MAX_m 2000000
 
struct node{
  unsigned int k;
  struct node *next;
  struct node *prev;
};
 
typedef struct node*NodePointer;
 
NodePointer NIL;

void init(void); 
void insert(int);


void del(int);
void delFirst(void);
void delLast(void);
void printList(void);

void delNode(NodePointer);
NodePointer Search(int);


int main(){
  int k, n, i;
  int size = 0;
  int np=0, nd=0;
 
  char come[20];

  scanf("%d",&n);
 
  init();
 
  for(i=0;i < n;i++){
    scanf("%s%d", come, &k);
    if(0 >= k && k >= MAX_k){
      printf("error");
    }
    if(come[0]=='i'){
      insert(k);
      np++;
      size++;
    }
    else if(come[0]== 'd'){
      if(strlen(come)>6){
    if(come[6]=='F'){
      delFirst();    
    }
    else if(come[6]=='L'){
      delLast();
    }
      } else {
    del(k);
    nd++; 
      }
      size--;
    }
    if(size > MAX_l){
      printf("error"); 
    }
  }
 
  if(!( np+nd <= MAX_m)){
    printf("error");
  }
  if(!( nd <= 20)){
    printf("error");
  }
  printList();
 
  return 0;
}
 
void insert(int k){
  NodePointer x1;
  x1 = malloc(sizeof(struct node));
  x1->k = k;
  x1->next = NIL->next;
  NIL->next->prev = x1;
  NIL->next = x1;
  x1->prev = NIL;
}

void delFirst(){
  NodePointer a;
  a = NIL->next;
  if ( a == NIL ) return;
  delNode(a);
}
 
void delLast(){
  NodePointer a;
  a = NIL->prev;
  if ( a == NIL ) return;
  delNode(a);
}
 

void del(int k){
  NodePointer a;
  a = Search(k);
  if ( a == NIL ) return;
  delNode(a);
}
 
 void delNode(NodePointer a){
  a->prev->next = a->next;
  a->next->prev = a->prev;
  free(a);
}

NodePointer Search(int k){
  NodePointer c;
  c = NIL->next;
  while(c != NIL && c->k != k ){
    c = c->next;
  }
  return c;
}
 
void init(){
  NIL = malloc(sizeof(struct node));
  NIL->next = NIL;
  NIL->prev = NIL;
}
 
void printList(){
  NodePointer c;
  c = NIL->next;
  int isf = 1;
  while(1){
    if ( c == NIL ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", c->k);
    c = c->next;
    isf = 0;
  }
  printf("\n");
}
 

Measured memory_bytes: 31788
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)5e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	void make_set(int v){
		parent[v] = v;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b)
			parent[b] = a;
	}
};


ll c[100005];
int main(){
	int n; cin>> n;
	int u;
	clr(c,0);
	
	bool flag = false;
	for(int i =  1; i <= n; i++){
		cin>> u;
		if(i == 1 && u != 0)
			flag = true;
		c[u]++;
		
	}
	
	if(flag){
		cout<<0; 
		return 0;
	}
	
	if(c[0] > 1){
		cout<<0;
		return 0;
	}
	
	while(c[n] == 0) n--;
	
	ll ans = 1;
	for(int i = 2; i <= n; i++){
		ll p = 1;
		for(int k = 1; k <= c[i]; k++){
			p = (p%mod * c[i-1]%mod)%mod;
			//~ p = (p * c[i-1]);
			
		}
		//~ ans *= p;
		ans = (ans%mod * p %mod)%mod;
		
	} 
	cout<<ans;
	return 0;
}
 
		


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	    String line = br.readLine();
	    int a = Integer.parseInt(line.split(" ")[0]);
	    int b = Integer.parseInt(line.split(" ")[1]);
	    int c = Integer.parseInt(line.split(" ")[2]);

	    if (a < b && b < c) {
		    System.out.println("Yes");
	    } else {
		    System.out.println("No");
	    }
	}
}

Measured memory_bytes: 24312
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#define ll long long

using namespace std;


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 ll int i=0,k,x,p;
 cin>>k>>x;

 for(i=x-k+1;i<=x+k-1;i++)
 {
     cout<<i<<" ";
 }
 
 
 
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll long long
#define MOD 1000000007
#define pll             pair<ll,ll>
#define pii             pair<int,int> 
#define mp(a,b)         make_pair(a,b)
#define pb 				push_back
#define vi				vector<int>
#define vl 				vector<long long>
#define vb 				vector<bool>
#define printv(v)		for(auto x : v) cout<<x<<' ';br;
#define FOR(i,a,b) 		for(ll i = a; i <= b ; i++)
#define forn(i,n) 		for(ll i = 0 ; i < n; i++)
#define br 				cout<<endl;
#define testc()			ll t;cin>>t;while(t--)
 
#define fast 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF				INT_MAX
#define INFL			LLONG_MAX
#define max1(x,y) (x)>(y)?(x):(y)
#define ss second
#define ff first
#define MAXN 3005
ll arr[MAXN][MAXN];

void lcs(string s,string t,ll m,ll n){
	forn(i,m+1){
		forn(j,n+1){
			if(i==0||j==0)
			arr[i][j]=0;
			else
			if(s[i-1]==t[j-1])
			arr[i][j]=1+arr[i-1][j-1];
			else
			arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
		}
	}
}

int main(){
    fast
	memset(arr,0,sizeof(arr));
    string s,t;
	cin>>s>>t;
	ll m,n;
	m=s.length();
	n=t.length();
	vector<char> v;
	lcs(s,t,m,n);
	// forn(i,m+1){
	// 	forn(j,n+1)
	// 	cout<<arr[i][j]<<" ";
	// 	cout<<endl;
	// }
	ll i=m,j=n;
	while(i>0&&j>0){
		if(arr[i][j]==arr[i][j-1]){
			j--;
		}
		else if(arr[i][j]==arr[i-1][j])
		i--;
		else{
			v.pb(s[i-1]);
			i--;j--;
		}
	}
	reverse(v.begin(),v.end());
	for(ll i=0;i<v.size();i++)
	cout<<v[i];
	cout<<endl;
    return 0;
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 2e5+5;
vector<int> adj[N];
int visited[N];

int dfs(int u){
	visited[u] = true;
	int res = 1;
	for(auto v : adj[u]){
		if(!visited[v]) res += dfs(v);
	}
	return res;
}

void solve(){
	int ans = 0;
	int n,m;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 1;i <= n;i++){
		ans = max(ans,dfs(i));
	}
	cout << ans << "\n";
}

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

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

using namespace std;

#define int long long
#define rep(i,x) for(int i=0;i<x;++i)
#define rrep(i,x) for(int i=x-1;i>=0;--i)
#define rep1(i,x) for(int i=1;i<=x;++i)
#define rrep1(i,x) for(int i=x;i>=1;--i)
#define fst first
#define scd second
#define PB push_back
#define PPB pop_back
#define all(a) begin(a),end(a)

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

signed main()
{
    int N; cin >> N;
    vi A(N), B(N);
    rep(i, N) cin >> A[i]>>B[i];
    int cnt = 0;

    rrep(i, N) {
        A[i] += cnt;
        if (A[i] % B[i] == 0) {
            continue;
        } else {
            int tmp = A[i];
            A[i] = ((A[i] + B[i] - 1) / B[i]) * B[i];
            cnt += A[i] - tmp;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF (1<<30)
#define LINF (1ll<<60ll)
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
#define d(a) cerr<<#a<<":"<<a<<endl
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;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

ll l(ll n){
    return (4ll<<n)-3;
}
ll f_(ll,ll);
ll f(ll n,ll x){
//ll r=f_(n,x);cerr<<n<<","<<x<<","<<r<<endl;return r;}ll f_(ll n,ll x){
    if(x<=n)return 0;
    if(n<1)return 1;
    if(l(n)==x)return f(n-1,l(n-1))*2+1;
    
    
    if(x<=l(n-1)+1)return f(n-1,x-1);
    if(x==l(n-1)+2)return f(n-1,l(n-1))+1;
    if(l(n)==x-1)return f(n-1,l(n-1))*2+1;
    //cout<<">>>"<<x-2-l(n-1)<<endl;
    if(x-2-l(n-1)<0)while(1){};
    return f(n-1,l(n-1))+f(n-1,x-2-l(n-1))+1;
}

int main(){
    /*REP(i,1,50){
        cout<<i<<","<<l(i)<<endl;
    }*/
    ll n;
    cin>>n;
    ll x;
    cin>>x;
    cout<<f(n,x)<<endl;
    return 0;
}


Measured memory_bytes: 256