akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

void solve() {
    int n,q;
    cin >> n >> q;
    int t,x;
    LL ans = 1LL * (n-2) * (n-2);
    VI rs(n), cs(n);
    int r = n - 1, c = n - 1;
    REP(i,0,q) {
        cin >> t >> x;
        --x;
        if (t == 1) {
            if (x > r) ans -= rs[x] - 1;
            else {
                REP(j,x,r+1) {
                    rs[j] = c;
                }
                r = x;
                ans -= rs[x] - 1;
            }
        } else {
            if (x > c) ans -= cs[x] - 1;
            else {
                REP(j,x,c+1) {
                    cs[j] = r;
                }
                c = x;
                ans -= cs[x] - 1;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4848
def track(A, n, k, P): # 最大積載量Pを決めた時，何個の荷物を載せることができるかを返す
	i = 0
	for _ in range(k):
		weight_of_track_j = 0
		while weight_of_track_j + A[i] <= P:
			weight_of_track_j += A[i]
			i += 1
			if i == n:
				return n
	return i


if __name__ == "__main__":
	n, k = map(int, input().split())
	w = []
	for _ in range(n):
		w.append(int(input()))
	left = 0
	right = 100000 * 10000 # トラックの数 * 荷物の最大重み
	key = n
	while right - left > 1:
		mid = (left + right) // 2
		if key > track(w, n, k, mid):
			left = mid
		else:
			right = mid
	print(right)



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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 2e5 + 5;

int H[N];
ll FEN[N];

void Add(int p, ll x) {
	for (p++; p < N; p += p & -p) FEN[p] = max(FEN[p], x);
}
ll Get(int p) {
	ll res = 0;
	for (; p > 0; p -= p & -p) res = max(res, FEN[p]);
	return res;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> H[i], H[i]--;
	for (int i = 0; i < n; i++) {
		ll x; cin >> x;
		x += Get(H[i]);
		Add(H[i], x);
	}
	cout << Get(n) << endl;

	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
 

class Main{
 
    public static class P{
        public double x;
        public double y;
        public P(double x, double y) {
            this.x = x;
            this.y = y;
        }
    }
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double x = 0;
        double y = 0;
        int a = 0;
        while(true){
            String[] s = sc.next().split(",");
            int l = Integer.parseInt(s[0]);
            int da = Integer.parseInt(s[1]);
            if(l==0&&da==0)break;
            P p = rotate(l, a);
            x += p.x;
            y += p.y;
            if(da<0)da+=360;
            a+=da;
            a%=360;
        }
        System.out.printf("%d\n%d\n", (int)x, (int)y);
    }
     
    public static P rotate(int l, int a){
        double dx = l*Math.sin(a*Math.PI/180.0);
        double dy = l*Math.cos(a*Math.PI/180.0);
        return new P(dx, dy);
    }
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100007, MOD = 1000000007;

struct mint {
    int val;
 
    mint(int v = 0) {
        val = v % MOD;
        if(val < 0) val += MOD;
    }
 
    static int mod_inv(int a, int m = MOD) {
        int g = m, r = a, x = 0, y = 1;
 
        while (r != 0) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }
 
        return x < 0 ? x + m : x;
    }
 
    explicit operator int() const {
        return val;
    }
 
    mint& operator+=(const mint &other) {
        val += other.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
 
    mint& operator-=(const mint &other) {
        val -= other.val;
        if (val < 0) val += MOD;
        return *this;
    }
 
    static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
        return x % m;
    }
 
    mint& operator*=(const mint &other) {
        val = fast_mod((uint64_t) val * other.val);
        return *this;
    }
 
    mint& operator/=(const mint &other) {
        return *this *= other.inv();
    }
 
    friend mint operator+(const mint &a, const mint &b) { return mint(a) += b; }
    friend mint operator-(const mint &a, const mint &b) { return mint(a) -= b; }
    friend mint operator*(const mint &a, const mint &b) { return mint(a) *= b; }
    friend mint operator/(const mint &a, const mint &b) { return mint(a) /= b; }
 
    mint& operator++() {
        val = val == MOD - 1 ? 0 : val + 1;
        return *this;
    }
 
    mint& operator--() {
        val = val == 0 ? MOD - 1 : val - 1;
        return *this;
    }
 
    mint operator++(int32_t) { mint before = *this; ++*this; return before; }
    mint operator--(int32_t) { mint before = *this; --*this; return before; }
 
    mint operator-() const {
        return val == 0 ? 0 : MOD - val;
    }
 
    bool operator==(const mint &other) const { return val == other.val; }
    bool operator!=(const mint &other) const { return val != other.val; }
 
    mint inv() const {
        return mod_inv(val);
    }
 
    mint pow(int p) const {
        assert(p >= 0);
        mint a = *this, result = 1;
 
        while (p > 0) {
            if (p & 1)
                result *= a;
 
            a *= a;
            p >>= 1;
        }
 
        return result;
    }
 
    friend ostream& operator<<(ostream &stream, const mint &m) {
        return stream << m.val;
    }
};

int n, x[N];

mint ans = 0;

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    mint sm(0), ans(0);

    for(int i = 1; i < n; ++i) {
        mint prob(1);
        prob /= i;
        ans -= prob*x[i-1];
        sm += prob;
    }

    ans += sm*x[n-1];
    
    for(int i = 1; i <= n-1; ++i) {
        ans = ans * i;
    }

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


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();

		ArrayList<Integer> amari = new ArrayList<Integer>();

		int n = 1;
		while(true){
			int x = n*A%B;
			if(x==C){
				System.out.println("YES");
				break;
			}else{
				if(amari.contains(x)){
					System.out.println("NO");
					break;
				}else{
					amari.add(x);
				}
			}
			n++;
		}

	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    REP(i, S.length()){
        cout << 'x';
    }

    cout << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
     float n;
       cin>>n;

     int y=(n/1.08);

    int c=0,l;
     for(int i=y;i<=n;i++)
     {
        float z=i*1.08;

           if((z-n<1.00) && (z-n>=0))
            {
              c=1;
              l=i;
              break;
            }
     }
     if(c==1)
       cout<<l;

       else
       cout<<":(";
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int solve(int cnt, int x, int y, vint c, vint s, vint f) {
	if (cnt > cnt / f[x]*f[x]) {
		cnt = cnt / f[x] * f[x] + f[x];
	}
	else {
		cnt = cnt / f[x]*f[x];
	}
	if (cnt < s[x]) {
		cnt = s[x];
	}
	cnt += c[x];
	if (x + 1 == y) {
		return cnt;
	}
	else {
		return solve(cnt, x + 1, y, c, s, f);
	}
}

int main() {
	int n;
	cin >> n;
	vint c(n - 1);
	vint s(n - 1);
	vint f(n - 1);
	rep(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	int cnt = 0;
	rep(i, n) {
		if (i == n - 1) {
			cout << 0 << endl;
		}
		else {
			cout << solve(cnt, i, n - 1, c, s, f) << endl;
		}
	}
	return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bit(n) (1LL<<(n))
#define F first
#define S second
// functions
template <typename T> void unique(T& c){c.erase(std::unique(c.begin(), c.end()), c.end());}
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 60;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  ll n, x, t; cin >> n >> x >> t;
  cout << ((n + x - 1) / x) * t << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<string> C(2);
    bool s=1;
    for(int i=0;i<2;i++){
        cin>>C.at(i);
    }

    for(int i=0;i<3;i++){
        if(C.at(0).at(i)!=C.at(1).at(2-i))s=0;
    }

    if(s)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n, x;
char p;

int main() {
    while (cin >> n) {
        pint now(0, 0);
        for (int i = 0; i < n; ++i) {
            cin >> p >> x;
            if ( p == ')' ) {
                if ( now.second >= x ) now = pint(now.first, now.second - x);
                else now = pint(now.first + (x - now.second), 0);
            }
            else {
                now = pint(now.first, now.second + x);
            }
        }
        if (now.first == 0 && now.second == 0) puts("YES");
        else puts("NO");
    }
    
    return 0;
}


Measured memory_bytes: 1120
#include <iostream>

int main() {
  int N, D, X;
  std::cin >> N >> D >> X;
  int res{X};
  for (int i = 0; i < N; i++) {
    int A;
    std::cin >> A;
    res += 1 + (D - 1) / A;
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
	static PrintStream out = System.out;
	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) count++;
		}
		out.println(count);
	}
}

Measured memory_bytes: 17352
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    A = input()
    B = input()
    C = input()

    ans = 0
    for i in range(N):
        a, b, c = A[i], B[i], C[i]
        n = len(set([a, b, c]))
        if n == 2:
            ans += 1
        elif n == 3:
            ans += 2
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

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

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	int l[50];
	rep(i, N) scanf("%d", &l[i]);
	sort(l, l + N);
	int res = 0;
	rep(i, K) res += l[N - 1 - i];
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int q;
	double x;
	
	while (scanf("%d", &q), q != -1){
		x = q / 2.0;
		while (fabs(x * x * x - q) >= 0.00001 * q){
			x = x - (x * x * x - q) / (3 * x * x);
		}
		printf("%f\n", x);
	}
	
	return (0);
}

Measured memory_bytes: 632
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, c = 0;
  cin >> N;
  vector<int> p(N), s(N);
  for (int i = 0; i < N; i++)
  {
    cin >> p.at(i);
    s[i] = p[i];
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < N; i++)
  {
    if (p[i] != s[i])
    {
      c++;
    }
  }
  cout << ((c == 2 || c == 0) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3120
N, K = (int(x) for x in input().split())
check=[False]*N
ans=N
for i in range(K):
  d=int(input())
  A=list(map(int, input().split()))
  for j in range(d):
    if check[A[j]-1]==False:
      ans-=1
      check[A[j]-1]=True
print(ans)

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

#define ll          long long
#define mp      make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
//----------------------------------------------------------------------------------------------------------------

void solve(){
    
    ll n;
    cin >> n;
    vi A(n), B(n), C(n);
    int dp[3][n + 1];
    memset(dp, 0, sizeof(dp));
    rep(i, 0, n) {
        cin >> A[i] >> B[i] >>C[i];
    }

    rep(i, 0, n) {
        dp[0][i+1] = max(dp[1][i] ,dp[2][i]) + A[i];
        dp[1][i+1] = max(dp[0][i] ,dp[2][i]) + B[i];
        dp[2][i+1] = max(dp[1][i] ,dp[0][i]) + C[i];
        // cout << dp[0][i+1] << " " << dp[1][i+1] << " " << dp[2][i+1] << endl; 
    }
    cout << max(dp[0][n], max(dp[1][n], dp[2][n])) << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t ;
    
    t =1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String N = sc.next();

        final int X = sc.nextInt();
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        String msg = "delicious";
        if (A < B) {
            msg = (B - A) > X ? "dangerous" : "safe";
         }

        System.out.println(msg);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a, b, k;
	
	
	cin>>a>>b>>k;
	
	for(int i = 100, j = 0; i >= 1; i--){
		if(a%i == 0 && b%i == 0){
			j++;
		}
		if(j == k){
			cout<<i<<endl;
			return 0;
		}
	}
	
	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;




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

	int n ,x;cin>>n>>x;

	int d=0;
	int cnt=0;
	for(int i=0; i<n; i++){
		int tmp;cin>>tmp;
		d +=tmp;

		if(d<=x){cnt++;}else {
			writeln(cnt+1);
			return 0;
		}


	}
	writeln(cnt+1);

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
const ll mod=1e9+7;
const double eps=1e-6;
int main()
{
    ios::sync_with_stdio(false);
   string s;
    cin>>s;
    cout <<s[0]<<s[1]<<s[2] << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll n, m;
vector<ll> x, y, z;


ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll get_max(ll xsign, ll ysign, ll zsign){
	vector<ll> sum(n);
	for (int i = 0; i < n; i++){
		sum[i] = xsign*x[i] + ysign*y[i] + zsign*z[i];
	}
	sort(sum.begin(), sum.end(), greater<ll>());
	ll ans = 0;
	for (int i = 0; i < m; i++){
		ans += sum[i];
	}
	return ans;
}


int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		ll p, q, r;
		cin >> p >> q >> r;
		x.push_back(p);
		y.push_back(q);
		z.push_back(r);
	}
	ll a = get_max(-1, -1, -1);
	ll b = get_max(-1, -1, 1);
	ll c = get_max(-1, 1, -1);
	ll d = get_max(-1, 1, 1);
	ll e = get_max(1, -1, -1);
	ll f = get_max(1, -1, 1);
	ll g = get_max(1, 1, -1);
	ll h = get_max(1, 1, 1);

	ll k = llmax(llmax(a, b), llmax(c, d));
	ll l = llmax(llmax(e, f), llmax(g, h));
	cout << llmax(k, l) << endl;
	return 0;
}

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<String>().chars().collect::<Vec<char>>();
    let b = read::<String>().chars().collect::<Vec<char>>();
    let ans = if a == b {
        "EQUAL"
    } else if a.len() > b.len() || (a.len() == b.len() && a > b) {
        "GREATER"
    } else {
        "LESS"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INT long long int
#define MOD 1000000007
using namespace std;
string s;
int cnt[30], sum;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    for(int i = 0 ; i < 4 ; i++ )
        cnt[s[i]-'A']++;
    for(int i = 0 ; i < 26 ; i++ )
    {
        sum += cnt[i];
        if( cnt[i] == 1 or cnt[i] == 3 or cnt[i] == 4 ) return cout<<"No\n", 0;
    }
    if( sum == 4 ) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	private static       boolean flg     = false;
	private static       int     index   = 0;
	private static final boolean SUCCESS = true;
	private static final int     EMPTY   = -1,
			                     END     = 10;

	private static int[]               pipe_A = new int[10];
	private static ArrayDeque<Integer> pipe_B = new ArrayDeque<Integer>(),
                                       pipe_C = new ArrayDeque<Integer>();

    public static void main(String[] args) {

    	Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
    	int n = sc.nextInt();

    	String[] s;
    	for(int i=0;i<n;i++){
    		s = sc.next().split("\\s");
    		for(int j=0;j<10;j++){pipe_A[j] = Integer.parseInt(s[j]);}
    		init();
    		push('B');
			if   (flg){System.out.println("YES");}
			else      {System.out.println("NO"); }
    	}
    }

    private static void init(){
		pipe_B.clear();
		pipe_C.clear();
		pipe_B.add(EMPTY);
		pipe_C.add(EMPTY);
		flg = false;
		index = 0;
    }

    private static void push(char pipe){

    	if(flg){return;}
    	if(index == END){
    		flg = SUCCESS;
    		return;
   		}
    	int ball = pipe_A[index];
    	switch (pipe) {
    		case 'B': {
    			if(pipe_B.peek() < ball ){
    				pipe_B.push(ball);
    		    	index++;
    		    	break;
    			} else {
    				return;
    			}
   			}
    		case 'C': {
    			if(pipe_C.peek() < ball){
    				pipe_C.push(ball);
    				index++;
    				break;
    			} else {
    				if(index == 0){return;}
    				if     (pipe_A[index - 1] == pipe_B.peek()){pipe_B.pop();}
    				else if(pipe_A[index - 1] == pipe_C.peek()){pipe_C.pop();}
    				index--;
    				return;
    			}
    		}
    	}
		push('B');
		push('C');
    }
}

Measured memory_bytes: 17184
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) cin >> a[i] >> b[i];
    ll count = 0;
    for(ll i = n - 1; i >= 0; i--){
        if((a[i] + count) % b[i] != 0){
            count += b[i] - ((a[i] + count) % b[i]);
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    char pixel[100][100];
    for(int i;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>pixel[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int k=0;k<2;k++){
            for(int j=0;j<w;j++){
                cout<<pixel[i][j];
            }
        cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}

int a,b,c,k;
int ans;

int main(){
    //File();
	read(a);read(b);read(c);read(k);
	ans+=a+b+c;
	int p=max(a,max(b,c));
	ans-=p;
	ans+=p*(1<<k);
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m2!=m1) cout << 1 << endl;
  else cout << 0 << endl;
  
  return 0;
}


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

long long solve(int N,int A,vector<vector<vector<long long>>> dp){
  long long sum=0;
  for(int j=1;j<=N;j++){
    sum+=dp.at(N).at(j).at(j*A);
  }
  return sum;
}

int main(){
  int N,A;
  cin >> N >> A;
  vector<int> x(N);
  for(int i=0;i<N;i++){
    cin >> x.at(i);
  }
  vector<vector<vector<long long>>> dp(N+1,vector<vector<long long>> (N+1,vector<long long>(2501)));
  for(int i=0;i<=N;i++){
    for(int j=0;j<=i;j++){
      for(int k=0;k<=2500;k++){
        if(i==0&&j==0&&k==0){
          dp.at(i).at(j).at(k)=1;
        }
        else if(1<=i && k<x.at(i-1)){
          dp.at(i).at(j).at(k)=dp.at(i-1).at(j).at(k);
        }
        else if(1<=i&&1<=j&&x.at(i-1)<=k){
          dp.at(i).at(j).at(k)=dp.at(i-1).at(j).at(k)+dp.at(i-1).at(j-1).at(k-x.at(i-1));
        }
        else{
          dp.at(i).at(j).at(k)=0;
        }
      }
    }
  }
  cout << solve(N,A,dp) << endl;
}

Measured memory_bytes: 102016
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(new Main().doWork(args));
	}

	public String doWork(String[] args) {
		Scanner reader = new Scanner(System.in);

		int n = reader.nextInt();
		int k = reader.nextInt();

		reader.close();

		//		int rate = k / n;
		//		if(0 < (k % n)) {
		//			++rate;
		//		}

		BigDecimal ret = new BigDecimal(0);
		for (int i = 1; i <= n; ++i) {
//			int num = 1;
			int ct = 0;
			while (true) {
				if (k <= i * Math.pow(2, ct)) {
					break;
				}
				++ct;
			}

			BigDecimal wk = new BigDecimal(1);
			BigDecimal divisor = new BigDecimal(Math.pow(2, ct)).multiply(new BigDecimal(n));
			wk = wk.divide(divisor,200, RoundingMode.HALF_UP);
			ret = ret.add(wk);
//			return Double.toString(1.0d / Math.pow(2, ct));
		}

//		int num = 1;
//		int ct = 0;
//		while (true) {
//			if (k <= n * Math.pow(2, ct)) {
//				break;
//			}
//			++ct;
//		}

		return ret.toPlainString();
		//		return ch.substring(0, k - 1) + ch.substring(k - 1, k + 1 - 1).toLowerCase() + ch.substring(k + 1 - 1);
	}
}


Measured memory_bytes: 57816
s=input()
s1=""
s2=""
q=int(input())
Q=[input().split() for i in range(q)]

flg=1
for i in range(q):
    if Q[i][0]=="1":flg*=-1
    if Q[i][0]=="2":
        if Q[i][1]=="1" and flg==1: s1=Q[i][2]+s1
        if Q[i][1]=="2" and flg==-1:s1=Q[i][2]+s1
        if Q[i][1]=="1" and flg==-1:s2=s2+Q[i][2]
        if Q[i][1]=="2" and flg==1:s2=s2+Q[i][2]
s=s1+s+s2
if flg==-1:s=s[::-1]
print(s)

Measured memory_bytes: 40556
a,b,c,d=gets.split.map &:to_i
n=gets.to_f
r=[[0.25,a],[0.5,b],[1,c],[2,d]]
r.sort!{|x,y|1.0*x[1]/x[0] <=> 1.0*y[1]/y[0]}
c=0
4.times do |i|
  g=r[i]
  c += (n/g[0]).to_i*g[1]
  if n % g[0] == 0
    n=0
  else
    n = n % g[0]
  end
end
p c.to_i

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

const int N=3010;
int n,a[N];
vector<int>g[N];

bool dfs(int x,int fa=-1){
	for(int i:g[x])if(i!=fa&&a[i]<a[x]&&!dfs(i,x))return 1;
	return 0;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	for(int i=1;i<=n;++i)
		if(dfs(i))cout<<i<<' ';
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
    long long n; cin >> n;
    long long ans = 1e10;
    for (long long i = 1; i * i <= n; ++i) {
      //long long : nと合わせないと事故る
        if ((double)n / i != n / i) {
            continue;
        }
        int keta1 = 0;
        long long num1 = i;
        while (num1) {
            keta1++;
            num1 /= 10;
        }
        int keta2 = 0;
        long long num2 = n / i;
        while (num2) {
            keta2++;
            num2 /= 10;
        }
        if (max(keta1, keta2) < ans) {
            ans = max(keta1, keta2);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i=0; i<N; i++)
    {
        cin >> V.at(i);
    }
    for (int i=0; i<N; i++)
    {
        cin >> C.at(i);
    }
    int sum=0;
    for(int i=0; i<N; i++)
    {
        if(V.at(i)-C.at(i)>0)
        {
            sum+=V.at(i)-C.at(i);
        }
    }
    cout << sum << endl;
    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vi p(n);
    cin >> p;
    int cnt = 0;
    rep(i, 1, n - 1) {
        vi tmp = {p[i - 1], p[i], p[i + 1]};
        sort(all(tmp));
        if (tmp[1] == p[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
/* ex6_2
   masaaki52	*/
#include <stdio.h>
#include <string.h>
int main(void){
  char sentence[101],abb[5];
  int length,between;
  scanf("%s",sentence);//文字列を入力
  length = strlen(sentence);//文字列の長さをとる
  between = length - 2;//先頭・末尾文字の間の文字数
  sprintf(abb,"%c%d%c",sentence[0],between,sentence[length-1]);//先頭、間の文字数、末尾を合体
  printf("%s\n",abb);//結果を出力
  return 0;
}

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


const int MAX = 8e+3;


int main()
{
    string s;
    int x, y;
    cin >> s;
    cin >> x >> y;


    // x 方向、y方向を独立に計算できる
    int count = 0;
    vector<int> X, Y{0};  // x, y 方向それぞれに進む回数
    for( int i = 0; i < (int) s.size(); ++i ){
        if( s[i] == 'T' ){
            (X.size() != Y.size()? X: Y).push_back( count );
            count = 0;
        }else ++count;
    }
    (X.size() != Y.size()? X: Y).push_back( count );

    // dpx[i][j]: i 回目の移動の後に j に居られるか
    bool dpx[MAX][MAX*2+1] = {}; // 座標に +- があるので2倍しておく
    dpx[0][X[0]+MAX] = true;       // 最初は +x 方向しか行けないことに注意！
    for( int i = 1; i < X.size(); ++i ){
        for( int j = 0; j <= MAX*2; ++j ){
            if( dpx[i-1][j] == true ){
                if( j+X[i] <= MAX*2 ) dpx[i][j+X[i]] = true;
                if( j-X[i] >= 0     ) dpx[i][j-X[i]] = true;
            }
        }
    }
    
    // y方向についても同様
    bool dpy[MAX][MAX*2+1] = {};
    dpy[0][MAX] = true;
	for( int i = 1; i < Y.size(); ++i ){
        for( int j = 0; j <= MAX*2; ++j ){
            if( dpy[i-1][j] == true ){
                if( j+Y[i] <= MAX*2 ) dpy[i][j+Y[i]] = true;
                if( j-Y[i] >= 0     ) dpy[i][j-Y[i]] = true;
            }
        }
    }

    if( dpx[X.size()-1][x+MAX] && dpy[Y.size()-1][y+MAX] ) cout << "Yes" << endl;
    else                                                   cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 250368
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

template <class Vec>
vector<int> runlength(const Vec& a) {
  vector<int> res;
  for (int i = 0; i < a.size(); i++) {
    if (i == 0 || a[i - 1] != a[i]) {
      res.push_back(1);
    } else {
      res.back() += 1;
    }
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  string S;
  while (cin >> N >> K >> S) {
    auto lens = runlength(S);
    int c = max(1, (int)lens.size() - 2 * K);
    int res = N - c;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n;
    cin >> n;
    string s;
    int ab, a, b, ans;
    ab = a = b = ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        for (int j = 0; j < s.size() - 1; j++)
            if (s[j] == 'A' && s[j + 1] == 'B')
                ans++;
        if (s[0] == 'B' && s[s.length() - 1] == 'A')
            ab++;
        if (s[s.length() - 1] == 'A')
            a++;
        if (s[0] == 'B')
            b++;
    }
    ans += min(a, b);
    if (ab == b && ab == a && ab != 0)
        ans--;
    cout << ans << endl;
}


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

int main (void){

  int a,b,z,z1;
  scanf("%d%d",&a,&b);
  if(a>=1 && b<=100){
  z=a+a+b+b;
  z1=a*b;
  printf("%d %d\n",z1,z);
  }

  return(0);
}



Measured memory_bytes: 1968
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors
a, b, c = map(int, input().split())
div = make_divisors(c)
print(len([1 for d in div if a <= d <= b]))


Measured memory_bytes: 5644
def func(N, X):
	global l, p

	if l[N] == X:
		return p[N]
	
	if X == 1:
		return 0
	temp = 1 + l[N - 1]
	s = 0
	if X <= temp:
		return func(N - 1, X - 1)
	temp += 1
	if X == temp:
		return p[N - 1] + 1
	temp += l[N - 1]
	if X <= temp:
		return func(N - 1, X - 2 - l[N - 1]) + p[N - 1] + 1
	return 2 * p[N - 1] + 1
	
		
N, X = map(int, input().split())

l = [0] * (N + 1)
p = [0] * (N + 1)

l[0] = 1
p[0] = 1

for i in range(1, N + 1):
	l[i] = 3 + l[i - 1] * 2
	p[i] = 1 + p[i - 1] * 2

ans = func(N, X)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int box[11][11];
	int i,j;
	int x,y,z;
	int sx[4]={ 0,-1, 1, 0};
	int sy[4]={-1, 0, 0, 1};
	int mx[8]={-1, 0, 1,-1, 1,-1, 0, 1};
	int my[8]={-1,-1,-1, 0, 0, 1, 1, 1};
	int lx[12]={ 0,-1, 0, 1,-2,-1, 1, 2,-1, 0, 1, 0};
	int ly[12]={-2,-1,-1,-1, 0, 0, 0, 0, 1, 1, 1, 2};
	int xx,yy;
	int sum,MAX;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			box[i][j]=0;
		}
	}
	while(scanf("%d",&x)!=EOF){
		scanf(",%d,%d",&y,&z);
		if(0<=x&&x<10&&0<=y&&y<10)	box[y][x]++;
		if(z==1){
			for(i=0;i<4;i++){
				xx=x+sx[i];
				yy=y+sy[i];
				//cout<<xx<<" "<<yy<<endl;
				if(0<=xx&&xx<10&&0<=yy&&yy<10){
					box[yy][xx]++;
				}
			}
		}
		else if(z==2){
			for(i=0;i<8;i++){
				xx=x+mx[i];
				yy=y+my[i];
				//cout<<xx<<" "<<yy<<endl;
				if(0<=xx&&xx<10&&0<=yy&&yy<10){
					box[yy][xx]++;
				}
			}
		}
		else{
			for(i=0;i<12;i++){
				xx=x+lx[i];
				yy=y+ly[i];
				//cout<<xx<<" "<<yy<<endl;
				if(0<=xx&&xx<10&&0<=yy&&yy<10){
					box[yy][xx]++;
				}
			}
		}
	}
	sum=0;
	MAX=-1;
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(box[i][j]>0)	MAX=max(MAX,box[i][j]);
			else			sum++;
		}
	}
	cout<<sum<<endl;
	cout<<MAX<<endl;
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    cout << "square1001" << endl;
    return 0;
}
 
 



Measured memory_bytes: 2920
import java.util.Scanner;

class Main
{
   public static void main(String[] args)
   {
      int n,hh,mm,ss;
      Scanner sc = new Scanner(System.in);
      n = sc.nextInt();
      hh = n/3600;
      mm = (n/60)%60;
      ss = n%60;
      System.out.println( hh + ":" + mm + ":" + ss );
   }
}


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

int main(){
    int n, i;
    vector<int> a(100000), b(100000);
    cin >> n;
    for(i = 0;i < n;i++){
        cin >> a.at(i);
    }
    for(i = 0;i < n;i++){
        b.at(a.at(i)-1) = i+1;
    }
    
    for(i = 0;i < n-1;i++){
        cout << b.at(i) << " " ;
    }
    cout << b.at(n-1) << endl;
    return 0;
}

Measured memory_bytes: 1664
N=int(input())
A=list(map(int,input().split()))
A.sort()
count=0
zer=0
for i in range(N):
  if A[i]<0:
    count+=1
  if A[i]==0:
    zer+=1
ans=0
if zer!=0:
  for i in range(N):
    if A[i]<0:
      A[i]=-A[i]
    ans+=A[i]
else:
  if count%2==0:
    for i in range(N):
      if A[i]<0:
        A[i]=-A[i]
      ans+=A[i]
  else:
    for i in range(N):
      A[i]=abs(A[i])
    A.sort()
    ans=sum(A[1:])-A[0]
print(ans)

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

int main() {
  int A,B;
  char op;
  cin >> A >> op >> B;
  int ans =0;
  if(op =='+'){
    ans += A+B; 
  }
  else{
    ans +=A-B;
  }

  cout << ans <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

int h,w;
vector<string> g;
vvi dp;

ll f(int i,int j)
{
    if(i<0||j<0||i>=h||j>=w) return 0;
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    else
    {
        if(i==0 && j==0 ) return dp[i][j] = 1;
        else
        {
            if(g[i][j]=='#')    
            {
                return dp[i][j] =0;
            }
            else
            {
                return dp[i][j] = (f(i,j-1)%MOD+f(i-1,j)%MOD)%MOD;
            }
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC

    // trace1("hello");     
    cin>>h>>w;
    // trace1("hello");        
    g.assign(h,string(""));
    // dp[i][j] = #of ways to reach g[i][j]
    // trace1("yo");    
    for (int i = 0; i < h; i++)
    {
        cin>>g[i];
    }
    // trace1("high");
    // for (int i = 0; i < h; i++)
    // {
    //     for (int j = 0; j < w; j++)
    //     {
    //         cout<<g[i][j];
    //     }
    //     cout<<"\n";
    // }
    
    dp.assign(h,vi(w,-1));
    ll ans = f(h-1,w-1);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8444
(stdin => {
  // Define Function

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const nlist = Array.from(inputs.slice(0, -1), Number)
  // Main
  const result = nlist.map(
    (v, i) => `Case ${i + 1}: ${v}`)
  // Display
  console.log(result.join('\n'))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 19988